Skip to content

Commit

Permalink
fix: convert liquidator collateral balance mismatch assertion from eq…
Browse files Browse the repository at this point in the history
…ual to isAtMost to handle timestamp differences (naked margin put pre expiry integration test)
  • Loading branch information
CruzMolina committed Aug 24, 2021
1 parent 98c41a8 commit c90dd08
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions test/integration-tests/nakedMarginPutPreExpiry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,7 @@ contract('Naked margin: put position pre expiry', ([owner, accountOwner1, buyer1
)[0]

assert.equal(vaultAfterLiquidation.shortAmounts[0].toString(), '0', 'Vault was not fully liquidated')

assert.isAtMost(
calcRelativeDiff(
new BigNumber(vaultAfterLiquidation.collateralAmounts[0]),
Expand All @@ -649,16 +650,21 @@ contract('Naked margin: put position pre expiry', ([owner, accountOwner1, buyer1
new BigNumber(errorDelta).toNumber(),
'Vault collateral mismatch after liquidation',
)
assert.equal(
liquidatorUsdcAfter.toString(),
liquidatorUsdcBefore.minus(collateralToDeposit).plus(isLiquidatable[1]).toString(),

assert.isAtMost(
calcRelativeDiff(liquidatorUsdcAfter, liquidatorUsdcBefore.minus(collateralToDeposit).plus(isLiquidatable[1]))
.dividedBy(new BigNumber(10 ** usdcDecimals))
.toNumber(),
new BigNumber(errorDelta).toNumber(),
'Liquidator collateral balance mismatch after liquidation',
)

assert.equal(
poolUsdcAfter.plus(isLiquidatable[1].toString()).minus(collateralToDeposit.toString()).toString(),
poolUsdcBefore.toString(),
'Pool balance after openining position mismatch',
)

assert.equal(
liquidatorVaultAfter[0].collateralAmounts[0].toString(),
collateralToDeposit.toString(),
Expand Down

0 comments on commit c90dd08

Please sign in to comment.