mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
fix: fixed test with wrong descimals in uniswap liquidity swap
This commit is contained in:
parent
e18bd375cc
commit
f3418670f8
|
@ -187,17 +187,12 @@ makeSuite('Uniswap adapters', (testEnv: TestEnv) => {
|
||||||
const collateralDecimals = (await usdc.decimals()).toString();
|
const collateralDecimals = (await usdc.decimals()).toString();
|
||||||
const principalDecimals = (await dai.decimals()).toString();
|
const principalDecimals = (await dai.decimals()).toString();
|
||||||
|
|
||||||
const expectedDaiAmountForUsdc = await convertToCurrencyDecimals(
|
const expectedDaiAmountForUsdc = new BigNumber(amountUSDCtoSwap.toString())
|
||||||
dai.address,
|
|
||||||
new BigNumber(amountUSDCtoSwap.toString())
|
|
||||||
.times(
|
.times(
|
||||||
new BigNumber(usdcPrice.toString()).times(new BigNumber(10).pow(principalDecimals))
|
new BigNumber(usdcPrice.toString()).times(new BigNumber(10).pow(principalDecimals))
|
||||||
)
|
)
|
||||||
.div(
|
.div(new BigNumber(daiPrice.toString()).times(new BigNumber(10).pow(collateralDecimals)))
|
||||||
new BigNumber(daiPrice.toString()).times(new BigNumber(10).pow(collateralDecimals))
|
.toFixed(0);
|
||||||
)
|
|
||||||
.toFixed(0)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Make a deposit for user
|
// Make a deposit for user
|
||||||
await usdc.connect(user).mint(amountUSDCtoSwap);
|
await usdc.connect(user).mint(amountUSDCtoSwap);
|
||||||
|
@ -240,7 +235,6 @@ makeSuite('Uniswap adapters', (testEnv: TestEnv) => {
|
||||||
],
|
],
|
||||||
[false, false]
|
[false, false]
|
||||||
);
|
);
|
||||||
|
|
||||||
await pool
|
await pool
|
||||||
.connect(user)
|
.connect(user)
|
||||||
.flashLoan(
|
.flashLoan(
|
||||||
|
@ -309,17 +303,12 @@ makeSuite('Uniswap adapters', (testEnv: TestEnv) => {
|
||||||
const collateralDecimals = (await usdc.decimals()).toString();
|
const collateralDecimals = (await usdc.decimals()).toString();
|
||||||
const principalDecimals = (await dai.decimals()).toString();
|
const principalDecimals = (await dai.decimals()).toString();
|
||||||
|
|
||||||
const expectedDaiAmountForUsdc = await convertToCurrencyDecimals(
|
const expectedDaiAmountForUsdc = new BigNumber(amountUSDCtoSwap.toString())
|
||||||
dai.address,
|
|
||||||
new BigNumber(amountUSDCtoSwap.toString())
|
|
||||||
.times(
|
.times(
|
||||||
new BigNumber(usdcPrice.toString()).times(new BigNumber(10).pow(principalDecimals))
|
new BigNumber(usdcPrice.toString()).times(new BigNumber(10).pow(principalDecimals))
|
||||||
)
|
)
|
||||||
.div(
|
.div(new BigNumber(daiPrice.toString()).times(new BigNumber(10).pow(collateralDecimals)))
|
||||||
new BigNumber(daiPrice.toString()).times(new BigNumber(10).pow(collateralDecimals))
|
.toFixed(0);
|
||||||
)
|
|
||||||
.toFixed(0)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Make a deposit for user
|
// Make a deposit for user
|
||||||
await usdc.connect(user).mint(amountUSDCtoSwap);
|
await usdc.connect(user).mint(amountUSDCtoSwap);
|
||||||
|
@ -862,17 +851,12 @@ makeSuite('Uniswap adapters', (testEnv: TestEnv) => {
|
||||||
const collateralDecimals = (await usdc.decimals()).toString();
|
const collateralDecimals = (await usdc.decimals()).toString();
|
||||||
const principalDecimals = (await dai.decimals()).toString();
|
const principalDecimals = (await dai.decimals()).toString();
|
||||||
|
|
||||||
const expectedDaiAmount = await convertToCurrencyDecimals(
|
const expectedDaiAmount = new BigNumber(amountUSDCtoSwap.toString())
|
||||||
dai.address,
|
|
||||||
new BigNumber(amountUSDCtoSwap.toString())
|
|
||||||
.times(
|
.times(
|
||||||
new BigNumber(usdcPrice.toString()).times(new BigNumber(10).pow(principalDecimals))
|
new BigNumber(usdcPrice.toString()).times(new BigNumber(10).pow(principalDecimals))
|
||||||
)
|
)
|
||||||
.div(
|
.div(new BigNumber(daiPrice.toString()).times(new BigNumber(10).pow(collateralDecimals)))
|
||||||
new BigNumber(daiPrice.toString()).times(new BigNumber(10).pow(collateralDecimals))
|
.toFixed(0);
|
||||||
)
|
|
||||||
.toFixed(0)
|
|
||||||
);
|
|
||||||
|
|
||||||
await mockUniswapRouter.connect(user).setAmountToReturn(usdc.address, expectedDaiAmount);
|
await mockUniswapRouter.connect(user).setAmountToReturn(usdc.address, expectedDaiAmount);
|
||||||
|
|
||||||
|
@ -1484,17 +1468,12 @@ makeSuite('Uniswap adapters', (testEnv: TestEnv) => {
|
||||||
const collateralDecimals = (await usdc.decimals()).toString();
|
const collateralDecimals = (await usdc.decimals()).toString();
|
||||||
const principalDecimals = (await dai.decimals()).toString();
|
const principalDecimals = (await dai.decimals()).toString();
|
||||||
|
|
||||||
const expectedDaiAmountForUsdc = await convertToCurrencyDecimals(
|
const expectedDaiAmountForUsdc = new BigNumber(amountUSDCtoSwap.toString())
|
||||||
dai.address,
|
|
||||||
new BigNumber(amountUSDCtoSwap.toString())
|
|
||||||
.times(
|
.times(
|
||||||
new BigNumber(usdcPrice.toString()).times(new BigNumber(10).pow(principalDecimals))
|
new BigNumber(usdcPrice.toString()).times(new BigNumber(10).pow(principalDecimals))
|
||||||
)
|
)
|
||||||
.div(
|
.div(new BigNumber(daiPrice.toString()).times(new BigNumber(10).pow(collateralDecimals)))
|
||||||
new BigNumber(daiPrice.toString()).times(new BigNumber(10).pow(collateralDecimals))
|
.toFixed(0);
|
||||||
)
|
|
||||||
.toFixed(0)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Make a deposit for user
|
// Make a deposit for user
|
||||||
await usdc.connect(user).mint(amountUSDCtoSwap);
|
await usdc.connect(user).mint(amountUSDCtoSwap);
|
||||||
|
@ -1592,17 +1571,12 @@ makeSuite('Uniswap adapters', (testEnv: TestEnv) => {
|
||||||
const collateralDecimals = (await usdc.decimals()).toString();
|
const collateralDecimals = (await usdc.decimals()).toString();
|
||||||
const principalDecimals = (await dai.decimals()).toString();
|
const principalDecimals = (await dai.decimals()).toString();
|
||||||
|
|
||||||
const expectedDaiAmountForUsdc = await convertToCurrencyDecimals(
|
const expectedDaiAmountForUsdc = new BigNumber(amountUSDCtoSwap.toString())
|
||||||
dai.address,
|
|
||||||
new BigNumber(amountUSDCtoSwap.toString())
|
|
||||||
.times(
|
.times(
|
||||||
new BigNumber(usdcPrice.toString()).times(new BigNumber(10).pow(principalDecimals))
|
new BigNumber(usdcPrice.toString()).times(new BigNumber(10).pow(principalDecimals))
|
||||||
)
|
)
|
||||||
.div(
|
.div(new BigNumber(daiPrice.toString()).times(new BigNumber(10).pow(collateralDecimals)))
|
||||||
new BigNumber(daiPrice.toString()).times(new BigNumber(10).pow(collateralDecimals))
|
.toFixed(0);
|
||||||
)
|
|
||||||
.toFixed(0)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Make a deposit for user
|
// Make a deposit for user
|
||||||
await usdc.connect(user).mint(amountUSDCtoSwap);
|
await usdc.connect(user).mint(amountUSDCtoSwap);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user