Skip to content

Commit

Permalink
Remove exit by unwrapping test scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoguerios committed Aug 18, 2023
1 parent 8bf5357 commit aadc392
Showing 1 changed file with 1 addition and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ describe('generalised exit execution', async function () {
const network = Network.MAINNET;
const pool = ADDRESSES[network].bbausd;
const slippage = '10'; // 10 bps = 0.1%
let unwrappingTokensAmountsOut: string[];
let unwrappingTokensGasUsed: BigNumber;
let mainTokensAmountsOut: string[];
let mainTokensGasUsed: BigNumber;
const poolAddresses = Object.values(ADDRESSES[network]).map(
(address) => address.address
);
Expand All @@ -33,25 +29,9 @@ describe('generalised exit execution', async function () {
// Amount smaller than the underlying main token balance, which will cause the exit to be done directly
const mainExitAmount = unwrapExitAmount.div(amountRatio);

context('exit by unwrapping tokens', async () => {
it('should exit via unwrapping', async () => {
const { expectedAmountsOut, gasUsed } = await testFlow(
pool,
slippage,
unwrapExitAmount.toString(),
[ADDRESSES[network].DAI.address],
network,
blockNo,
poolAddresses
);
unwrappingTokensAmountsOut = expectedAmountsOut;
unwrappingTokensGasUsed = gasUsed;
});
});

context('exit to main tokens directly', async () => {
it('should exit to main tokens directly', async () => {
const { expectedAmountsOut, gasUsed } = await testFlow(
await testFlow(
pool,
slippage,
mainExitAmount.toString(),
Expand All @@ -60,24 +40,6 @@ describe('generalised exit execution', async function () {
blockNo,
poolAddresses
);
mainTokensAmountsOut = expectedAmountsOut;
mainTokensGasUsed = gasUsed;
});
});

context('exit by unwrapping vs exit to main tokens', async () => {
it('should return similar amounts (proportional to the input)', async () => {
mainTokensAmountsOut.forEach((amount, i) => {
const unwrappedAmount = BigNumber.from(
unwrappingTokensAmountsOut[i]
).div(amountRatio);
expect(
accuracy(unwrappedAmount, BigNumber.from(amount))
).to.be.closeTo(1, 1e-4); // inaccuracy should not be over 1 bps
});
});
it('should spend more gas when unwrapping tokens', async () => {
expect(unwrappingTokensGasUsed.gt(mainTokensGasUsed)).to.be.true;
});
});
});
Expand Down

0 comments on commit aadc392

Please sign in to comment.