Skip to content

Commit

Permalink
minor clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
MattPereira committed Oct 3, 2024
1 parent 0d2c6b2 commit 1835e24
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 48 deletions.
13 changes: 4 additions & 9 deletions test/lib/utils/initPoolHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,26 @@ import { TxOutput, sendTransactionGetBalances } from './helper';
import { InitPoolTxInput } from './types';

function sdkInitPool({
initPool,
initPoolInput: addLiquidityInput,
initPoolInput,
poolState,
}: {
initPool: InitPool;
initPoolInput: InitPoolInput;
poolState: PoolState;
}): {
initPoolBuildOutput: InitPoolBuildOutput;
} {
const initPoolBuildOutput = initPool.buildCall(
addLiquidityInput,
poolState,
);
const initPool = new InitPool();
const initPoolBuildOutput = initPool.buildCall(initPoolInput, poolState);

return {
initPoolBuildOutput,
};
}

export async function doInitPool(txInput: InitPoolTxInput) {
const { initPool, poolState, initPoolInput, testAddress, client } = txInput;
const { poolState, initPoolInput, testAddress, client } = txInput;

const { initPoolBuildOutput } = sdkInitPool({
initPool,
initPoolInput,
poolState,
});
Expand Down
2 changes: 0 additions & 2 deletions test/lib/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
Address,
ChainId,
CreatePoolInput,
InitPool,
InitPoolInput,
NestedPoolState,
PoolState,
Expand All @@ -33,7 +32,6 @@ export type InitPoolTxInput = Omit<
'addLiquidity' | 'addLiquidityInput'
> & {
initPoolInput: InitPoolInput;
initPool: InitPool;
};

export type RemoveLiquidityTxInputBase = {
Expand Down
2 changes: 0 additions & 2 deletions test/v2/initPool/composableStable.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
Slippage,
CreatePoolV2ComposableStableInput,
InitPoolDataProvider,
InitPool,
InitPoolInput,
} from 'src';
import { ANVIL_NETWORKS, startFork } from '../../anvil/anvil-global-setup';
Expand Down Expand Up @@ -99,7 +98,6 @@ describe('Composable Stable Pool - Init Pool tests', async () => {

initPoolTxInput = {
client,
initPool: new InitPool(),
testAddress: signerAddress,
initPoolInput: {} as InitPoolInput,
slippage: Slippage.fromPercentage('0.01'),
Expand Down
2 changes: 0 additions & 2 deletions test/v2/initPool/weighted.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
Slippage,
CreatePoolV2WeightedInput,
InitPoolDataProvider,
InitPool,
InitPoolInput,
} from 'src';
import { ANVIL_NETWORKS, startFork } from '../../anvil/anvil-global-setup';
Expand Down Expand Up @@ -96,7 +95,6 @@ describe('Add Liquidity Init - Weighted Pool', async () => {

initPoolTxInput = {
client,
initPool: new InitPool(),
testAddress: signerAddress,
initPoolInput: {} as InitPoolInput,
slippage: Slippage.fromPercentage('0.01'),
Expand Down
37 changes: 17 additions & 20 deletions test/v3/createPool/stable/stable.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
TokenType,
CreatePoolV3StableInput,
InitPoolDataProvider,
InitPool,
Slippage,
} from 'src';
import { ANVIL_NETWORKS, startFork } from '../../../anvil/anvil-global-setup';
Expand All @@ -30,13 +29,12 @@ import { vaultExtensionAbi_V3 } from 'src/abi/';
import { doInitPool, assertInitPool } from 'test/lib/utils/initPoolHelper';
import { forkSetup } from 'test/lib/utils/helper';

describe('Create Stable Pool tests', () => {
describe('create stable pool test', () => {
const protocolVersion = 3;
const chainId = ChainId.SEPOLIA;
const poolType = PoolType.Stable;
const protocolVersion = 3;
const DAI = TOKENS[chainId].DAI;
const BAL = TOKENS[chainId].BAL;
const INIT_AMOUNT = '100';
const scUSD = TOKENS[chainId].scUSD;
const scDAI = TOKENS[chainId].scDAI;

let rpcUrl: string;
let client: PublicWalletClient & TestActions;
Expand All @@ -59,18 +57,18 @@ describe('Create Stable Pool tests', () => {
poolType,
chainId,
protocolVersion,
name: 'DAI USDC Stable Pool',
symbol: 'DAI-USDC',
name: 'scUSD scDAI Stable Pool',
symbol: 'scUSD-scDAI',
amplificationParameter: 420n,
tokens: [
{
address: DAI.address,
address: scUSD.address,
rateProvider: zeroAddress,
tokenType: TokenType.STANDARD,
paysYieldFees: false,
},
{
address: BAL.address,
address: scDAI.address,
rateProvider: zeroAddress,
tokenType: TokenType.STANDARD,
paysYieldFees: false,
Expand Down Expand Up @@ -116,26 +114,26 @@ describe('Create Stable Pool tests', () => {
client,
testAddress,
poolState.tokens.map((t) => t.address),
[BAL.slot!, DAI.slot!],
poolState.tokens.map((t) => parseUnits(INIT_AMOUNT, t.decimals)),
[scDAI.slot!, scUSD.slot!],
poolState.tokens.map((t) => parseUnits('100', t.decimals)),
undefined,
protocolVersion,
);

const initPoolInput = {
amountsIn: [
{
address: createPoolInput.tokens[1].address,
rawAmount: parseUnits(INIT_AMOUNT, BAL.decimals),
decimals: BAL.decimals,
address: createPoolInput.tokens[0].address,
rawAmount: parseUnits('100', scUSD.decimals),
decimals: scUSD.decimals,
},
{
address: createPoolInput.tokens[0].address,
rawAmount: parseUnits(INIT_AMOUNT, DAI.decimals),
decimals: DAI.decimals,
address: createPoolInput.tokens[1].address,
rawAmount: parseUnits('100', scDAI.decimals),
decimals: scDAI.decimals,
},
],
minBptAmountOut: parseEther('1'),
minBptAmountOut: parseEther('10'),
chainId,
};

Expand All @@ -144,7 +142,6 @@ describe('Create Stable Pool tests', () => {
testAddress,
initPoolInput,
poolState,
initPool: new InitPool(),
slippage: Slippage.fromPercentage('0.01'),
});

Expand Down
4 changes: 1 addition & 3 deletions test/v3/createPool/stable/stable.validation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
MAX_TOKENS,
} from 'src/entities/inputValidator/stable/inputValidatorStable';

describe('Create stable pool input validation tests', () => {
describe('create stable pool input validations', () => {
const chainId = ChainId.SEPOLIA;
const createPool = new CreatePool();
let createStablePoolInput: CreatePoolV3StableInput;
Expand Down Expand Up @@ -48,8 +48,6 @@ describe('Create stable pool input validation tests', () => {
enableDonation: false,
disableUnbalancedLiquidity: false,
};

console.log('createStablePoolInput', createStablePoolInput);
});

test('Should throw error if duplicate token addresses', async () => {
Expand Down
18 changes: 9 additions & 9 deletions test/v3/createPool/weighted/weighted.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
TokenType,
CreatePoolV3WeightedInput,
InitPoolDataProvider,
InitPool,
Slippage,
} from 'src';
import { ANVIL_NETWORKS, startFork } from '../../../anvil/anvil-global-setup';
Expand All @@ -30,10 +29,12 @@ import { PublicWalletClient } from '@/utils';
import { VAULT_V3 } from 'src/utils/constants';
import { vaultExtensionAbi_V3 } from 'src/abi/';

describe('Create Weighted Pool tests', () => {
describe('create weighted pool test', () => {
const protocolVersion = 3;
const chainId = ChainId.SEPOLIA;
const poolType = PoolType.Weighted;
const protocolVersion = 3;
const BAL = TOKENS[chainId].BAL;
const WETH = TOKENS[chainId].WETH;

let rpcUrl: string;
let client: PublicWalletClient & TestActions;
Expand All @@ -58,13 +59,13 @@ describe('Create Weighted Pool tests', () => {
symbol: '50BAL-50WETH',
tokens: [
{
address: TOKENS[chainId].BAL.address, // BAL
address: BAL.address,
weight: parseEther(`${1 / 2}`),
rateProvider: zeroAddress,
tokenType: TokenType.STANDARD,
},
{
address: TOKENS[chainId].WETH.address, // WETH
address: WETH.address,
weight: parseEther(`${1 / 2}`),
rateProvider: zeroAddress,
tokenType: TokenType.STANDARD,
Expand Down Expand Up @@ -113,7 +114,7 @@ describe('Create Weighted Pool tests', () => {
client,
testAddress,
[...poolState.tokens.map((t) => t.address)],
[3, 1],
[WETH.slot!, BAL.slot!],
[...poolState.tokens.map((t) => parseUnits('100', t.decimals))],
undefined,
protocolVersion,
Expand All @@ -124,12 +125,12 @@ describe('Create Weighted Pool tests', () => {
{
address: createPoolInput.tokens[0].address,
rawAmount: parseEther('100'),
decimals: 18,
decimals: BAL.decimals,
},
{
address: createPoolInput.tokens[1].address,
rawAmount: parseEther('100'),
decimals: 18,
decimals: WETH.decimals,
},
],
minBptAmountOut: parseEther('90'),
Expand All @@ -141,7 +142,6 @@ describe('Create Weighted Pool tests', () => {
testAddress,
initPoolInput,
poolState,
initPool: new InitPool(),
slippage: Slippage.fromPercentage('0.01'),
});

Expand Down
2 changes: 1 addition & 1 deletion test/v3/createPool/weighted/weighted.validation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from 'src';
import { TOKENS } from 'test/lib/utils/addresses';

describe('Create weighted pool input validation tests', () => {
describe('create weighted pool input validations', () => {
const chainId = ChainId.SEPOLIA;
const createPool = new CreatePool();
let createWeightedPoolInput: CreatePoolV3WeightedInput;
Expand Down

0 comments on commit 1835e24

Please sign in to comment.