Skip to content

Commit d8eee11

Browse files
committed
liquidity protection - added more tests
1 parent ea7bd01 commit d8eee11

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/liquidity-protection/LiquidityProtection.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,36 @@ describe('LiquidityProtection', () => {
10951095
expect(amount).to.equal(reserveAmount);
10961096
});
10971097

1098+
it('verifies that removeLiquidityReturn returns the correct amount when the pool is not in deficit', async () => {
1099+
const reserveAmount = BigNumber.from(1000);
1100+
await addProtectedLiquidity(poolToken.address, baseToken, baseTokenAddress, reserveAmount);
1101+
const protectionIds = await liquidityProtectionStore.protectedLiquidityIds(owner.address);
1102+
const protectionId = protectionIds[0];
1103+
1104+
await liquidityProtection.setTotalPositionsValue(poolToken.address, reserveAmount);
1105+
1106+
const amount = (
1107+
await liquidityProtection.removeLiquidityReturn(protectionId, PPM_RESOLUTION, now)
1108+
)[0];
1109+
1110+
expect(amount).to.equal(reserveAmount);
1111+
});
1112+
1113+
it('verifies that removeLiquidityReturn returns the correct amount when the pool is in surplus', async () => {
1114+
const reserveAmount = BigNumber.from(1000);
1115+
await addProtectedLiquidity(poolToken.address, baseToken, baseTokenAddress, reserveAmount);
1116+
const protectionIds = await liquidityProtectionStore.protectedLiquidityIds(owner.address);
1117+
const protectionId = protectionIds[0];
1118+
1119+
await liquidityProtection.setTotalPositionsValue(poolToken.address, reserveAmount.mul(80).div(100));
1120+
1121+
const amount = (
1122+
await liquidityProtection.removeLiquidityReturn(protectionId, PPM_RESOLUTION, now)
1123+
)[0];
1124+
1125+
expect(amount).to.equal(reserveAmount);
1126+
});
1127+
10981128
it('verifies that removeLiquidityReturn returns the correct amount when the pool is in deficit', async () => {
10991129
const reserveAmount = BigNumber.from(1000);
11001130
await addProtectedLiquidity(poolToken.address, baseToken, baseTokenAddress, reserveAmount);

0 commit comments

Comments
 (0)