Skip to content

Commit

Permalink
chore: correcting linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
kupermind committed Apr 19, 2022
1 parent f2b4d18 commit 14f83ff
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions test/unit/tokenomics/depository/Depository.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ describe("Depository LP", async () => {
// Transfer all LP tokens back to deployer
await pairODAI.connect(bob).transfer(deployer.address, amountTo);
const amount = (await pairODAI.balanceOf(deployer.address));
// console.log("LP token in:",amount);
// console.log("LP token in:",amount);

const totalSupply = (await pairODAI.totalSupply());
// Calculate payout based on the amount of LP
Expand All @@ -250,31 +250,31 @@ describe("Depository LP", async () => {
// Get the balances of tokens in LP
let balance0 = (await token0.balanceOf(pairODAI.address));
let balance1 = (await token1.balanceOf(pairODAI.address));
// console.log("token0",token0.address);
// console.log("token1",token1.address);
// console.log("balance0",balance0);
// console.log("balance1",balance1);
// console.log("ola token",ola.address);
// console.log("totalSupply LP",totalSupply);
// console.log("token0",token0.address);
// console.log("token1",token1.address);
// console.log("balance0",balance0);
// console.log("balance1",balance1);
// console.log("ola token",ola.address);
// console.log("totalSupply LP",totalSupply);

// Token fractions based on the LP tokens amount and total supply
const amount0 = ethers.BigNumber.from(amount).mul(balance0).div(totalSupply);
const amount1 = ethers.BigNumber.from(amount).mul(balance1).div(totalSupply);
// console.log("token0 amount ref LP",amount0);
// console.log("token1 amount ref LP",amount1);
// console.log("token0 amount ref LP",amount0);
// console.log("token1 amount ref LP",amount1);

// This is equivalent to removing the liquidity
let amountOLA = amount1;
balance0 = balance0.sub(amount0);
balance1 = balance1.sub(amount1);
// console.log("balance0",balance0);
// console.log("balance1",balance1);
// console.log("balance0",balance0);
// console.log("balance1",balance1);

// This is the equivalent of a swap operation to calculate additional OLA
const reserveIn = balance0;
const reserveOut = balance1;
let amountIn = amount0;
// console.log("amountIn",amountIn);
// console.log("amountIn",amountIn);
// amountOLA = amountOLA + getAmountOut(amountPairForOLA, reserveIn, reserveOut);

// We use this tutorial to correctly calculate the in-out amounts:
Expand All @@ -284,18 +284,18 @@ describe("Depository LP", async () => {
const denominator = (reserveIn.mul(1000)).add(amountInWithFee);
const amountOut = numerator.div(denominator);
amountOLA = amountOLA.add(amountOut);
// console.log("amountInWithFee",amountInWithFee);
// console.log("numerator",numerator);
// console.log("denominator",denominator);
// console.log("delta amountOut:",amountOut);
// console.log("sutotal amountOLA:",amountOLA);
// console.log("amountInWithFee",amountInWithFee);
// console.log("numerator",numerator);
// console.log("denominator",denominator);
// console.log("delta amountOut:",amountOut);
// console.log("sutotal amountOLA:",amountOLA);
const payout = await tokenomics.calculatePayoutFromLP(pairODAI.address, amount, 0);
const df = await tokenomics.getDF(0);

// Payouts with direct calculation and via DF must be equal
expect(amountOLA.mul(df).div(E18)).to.equal(payout);
// console.log("payout direclty", payout);
// console.log("payout via df", amountOLA.mul(df).div(E18));
// console.log("payout direclty", payout);
// console.log("payout via df", amountOLA.mul(df).div(E18));

// Trying to deposit the amount that would result in an overflow payout for the LP supply
await pairODAI.connect(deployer).approve(depository.address, LARGE_APPROVAL);
Expand Down

0 comments on commit 14f83ff

Please sign in to comment.