From 08552eb4465455dd57b147f35dba80d5237f4ee8 Mon Sep 17 00:00:00 2001 From: "Miquel A. Cabot" Date: Thu, 31 Mar 2022 23:43:32 +0200 Subject: [PATCH] refactor constants --- test/unit/pools/Router.test.ts | 41 +++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/test/unit/pools/Router.test.ts b/test/unit/pools/Router.test.ts index 10d09701..2e7b14d0 100644 --- a/test/unit/pools/Router.test.ts +++ b/test/unit/pools/Router.test.ts @@ -25,6 +25,17 @@ describe('Router unit test', () => { const FEE = '0.001' const FEE_ZERO = '0' const DAI_AMOUNT = web3.utils.toWei('2') + const CAP_AMOUNT = '1000000' + const VESTING_AMOUNT = '10000' + const TOKEN_DECIMALS = 18 + const VESTED_BLOCKS = 2500000 + const BASE_TOKEN_LIQUIDITY = '2000' + const EXCHANGE_IDS = keccak256('0x00') + const AMOUNTS_IN = web3.utils.toWei('1') + const AMOUNTS_OUT = web3.utils.toWei('0.1') + const MAX_PRICE = web3.utils.toWei('10') + const SWAP_MARKET_FEE = web3.utils.toWei('0.1') + const NFT_DATA: NftCreateData = { name: NFT_NAME, @@ -104,7 +115,7 @@ describe('Router unit test', () => { paymentCollector: user2, mpFeeAddress: factoryOwner, feeToken: ZERO_ADDRESS, - cap: '0', + cap: CAP_AMOUNT, feeAmount: FEE_ZERO, name: ERC20_NAME, symbol: ERC20_SYMBOL @@ -118,10 +129,10 @@ describe('Router unit test', () => { marketFeeCollector: factoryOwner, poolTemplateAddress: contracts.poolTemplateAddress, rate: RATE, - baseTokenDecimals: 18, - vestingAmount: '10000', - vestedBlocks: 2500000, - initialBaseTokenLiquidity: '2000', + baseTokenDecimals: TOKEN_DECIMALS, + vestingAmount: VESTING_AMOUNT, + vestedBlocks: VESTED_BLOCKS, + initialBaseTokenLiquidity: BASE_TOKEN_LIQUIDITY, swapFeeLiquidityProvider: FEE, swapFeeMarketRunner: FEE } @@ -160,28 +171,28 @@ describe('Router unit test', () => { // 2 - FixedRateExchange // 3 - Dispenser const operations1: Operation = { - exchangeIds: keccak256('0x00'), // used only for FixedRate or Dispenser, but needs to be filled even for pool + exchangeIds: EXCHANGE_IDS, // used only for FixedRate or Dispenser, but needs to be filled even for pool source: pool1, // pool Address operation: 0, // swapExactAmountIn tokenIn: contracts.daiAddress, - amountsIn: web3.utils.toWei('1'), // when swapExactAmountIn is EXACT amount IN + amountsIn: AMOUNTS_IN, // when swapExactAmountIn is EXACT amount IN tokenOut: erc20TokenAddress, - amountsOut: web3.utils.toWei('0.1'), // when swapExactAmountIn is MIN amount OUT - maxPrice: web3.utils.toWei('10'), // max price (only for pools), - swapMarketFee: web3.utils.toWei('0.1'), + amountsOut: AMOUNTS_OUT, // when swapExactAmountIn is MIN amount OUT + maxPrice: MAX_PRICE, // max price (only for pools), + swapMarketFee: SWAP_MARKET_FEE, marketFeeAddress: factoryOwner } const operations2: Operation = { - exchangeIds: keccak256('0x00'), // used only for FixedRate or Dispenser, but needs to be filled even for pool + exchangeIds: EXCHANGE_IDS, // used only for FixedRate or Dispenser, but needs to be filled even for pool source: pool2, // pool Address operation: 0, // swapExactAmountIn tokenIn: contracts.daiAddress, - amountsIn: web3.utils.toWei('1'), // when swapExactAmountIn is EXACT amount IN + amountsIn: AMOUNTS_IN, // when swapExactAmountIn is EXACT amount IN tokenOut: erc20Token2Address, - amountsOut: web3.utils.toWei('0.1'), // when swapExactAmountIn is MIN amount OUT - maxPrice: web3.utils.toWei('10'), // max price (only for pools) - swapMarketFee: web3.utils.toWei('0.1'), + amountsOut: AMOUNTS_OUT, // when swapExactAmountIn is MIN amount OUT + maxPrice: MAX_PRICE, // max price (only for pools), + swapMarketFee: SWAP_MARKET_FEE, marketFeeAddress: factoryOwner }