diff --git a/tests/liquidateMaxLps.ts b/tests/liquidateMaxLps.ts index e66887f80..99045c5fc 100644 --- a/tests/liquidateMaxLps.ts +++ b/tests/liquidateMaxLps.ts @@ -190,7 +190,7 @@ describe('max lp liq', () => { const oracleGuardRails: OracleGuardRails = { priceDivergence: { markOraclePercentDivergence: PERCENTAGE_PRECISION, - oracleTwap5MinPercentDivergence: PERCENTAGE_PRECISION.div(new BN(10)), + oracleTwap5MinPercentDivergence: PERCENTAGE_PRECISION.mul(new BN(10)), }, validity: { slotsBeforeStaleForAmm: new BN(100), diff --git a/tests/liquidatePerp.ts b/tests/liquidatePerp.ts index f3d42eee2..03db2ab14 100644 --- a/tests/liquidatePerp.ts +++ b/tests/liquidatePerp.ts @@ -193,7 +193,7 @@ describe('liquidate perp (no open orders)', () => { console.log('deltaValueToLiq:', deltaValueToLiq.toString()); console.log('pp.base:', pp.baseAssetAmount.toString()); - const expectedLiqPrice = 0.452181; + const expectedLiqPrice = 0.45219; const liqPrice = driftClientUser.liquidationPrice(0, ZERO); console.log('liqPrice:', liqPrice.toString()); assert(liqPrice.eq(new BN(expectedLiqPrice * PRICE_PRECISION.toNumber()))); @@ -288,7 +288,7 @@ describe('liquidate perp (no open orders)', () => { const oracleGuardRails: OracleGuardRails = { priceDivergence: { markOraclePercentDivergence: PERCENTAGE_PRECISION, - oracleTwap5MinPercentDivergence: PERCENTAGE_PRECISION.div(new BN(10)), + oracleTwap5MinPercentDivergence: PERCENTAGE_PRECISION.muln(10), }, validity: { slotsBeforeStaleForAmm: new BN(100), @@ -392,7 +392,7 @@ describe('liquidate perp (no open orders)', () => { assert( driftClient .getUserAccount() - .perpPositions[0].quoteAssetAmount.eq(new BN(-5767508)) + .perpPositions[0].quoteAssetAmount.eq(new BN(-5767653)) ); // try to add liq when bankrupt -- should fail @@ -470,7 +470,11 @@ describe('liquidate perp (no open orders)', () => { eventSubscriber.getEventsArray('LiquidationRecord')[0]; assert(isVariant(perpBankruptcyRecord.liquidationType, 'perpBankruptcy')); assert(perpBankruptcyRecord.perpBankruptcy.marketIndex === 0); - assert(perpBankruptcyRecord.perpBankruptcy.pnl.eq(new BN(-5767508))); + console.log(perpBankruptcyRecord.perpBankruptcy.pnl.toString()); + console.log( + perpBankruptcyRecord.perpBankruptcy.cumulativeFundingRateDelta.toString() + ); + assert(perpBankruptcyRecord.perpBankruptcy.pnl.eq(new BN(-5767653))); console.log( perpBankruptcyRecord.perpBankruptcy.cumulativeFundingRateDelta.toString() ); @@ -485,7 +489,7 @@ describe('liquidate perp (no open orders)', () => { market.amm.cumulativeFundingRateLong.toString(), market.amm.cumulativeFundingRateShort.toString() ); - assert(market.amm.cumulativeFundingRateLong.eq(new BN(328572000))); - assert(market.amm.cumulativeFundingRateShort.eq(new BN(-328572000))); + assert(market.amm.cumulativeFundingRateLong.eq(new BN(328580333))); + assert(market.amm.cumulativeFundingRateShort.eq(new BN(-328563667))); }); }); diff --git a/tests/liquidatePerpAndLp.ts b/tests/liquidatePerpAndLp.ts index 9d50ad994..b02b2914d 100644 --- a/tests/liquidatePerpAndLp.ts +++ b/tests/liquidatePerpAndLp.ts @@ -210,7 +210,7 @@ describe('liquidate perp and lp', () => { // const expectedLiqPrice = 0.521639; const liqPrice = driftClientUser.liquidationPrice(0, ZERO); console.log('liqPrice:', liqPrice.toString()); - const expectedLiqPrice2 = new BN('500341'); + const expectedLiqPrice2 = new BN('500350'); console.log('expected liqPrice:', expectedLiqPrice2.toString()); assert(liqPrice.eq(expectedLiqPrice2)); @@ -282,7 +282,7 @@ describe('liquidate perp and lp', () => { const oracleGuardRails: OracleGuardRails = { priceDivergence: { markOraclePercentDivergence: PERCENTAGE_PRECISION, - oracleTwap5MinPercentDivergence: PERCENTAGE_PRECISION.div(new BN(10)), + oracleTwap5MinPercentDivergence: PERCENTAGE_PRECISION.mul(new BN(10)), }, validity: { slotsBeforeStaleForAmm: new BN(100), @@ -389,7 +389,7 @@ describe('liquidate perp and lp', () => { assert( driftClient .getUserAccount() - .perpPositions[0].quoteAssetAmount.eq(new BN(-4447508)) + .perpPositions[0].quoteAssetAmount.eq(new BN(-4447653)) ); // try to add liq when bankrupt -- should fail @@ -476,7 +476,7 @@ describe('liquidate perp and lp', () => { console.log( perpBankruptcyRecord.perpBankruptcy.cumulativeFundingRateDelta.toString() ); - assert(perpBankruptcyRecord.perpBankruptcy.pnl.eq(new BN(-4447508))); + assert(perpBankruptcyRecord.perpBankruptcy.pnl.eq(new BN(-4447653))); console.log( perpBankruptcyRecord.perpBankruptcy.cumulativeFundingRateDelta.toString() ); @@ -491,7 +491,7 @@ describe('liquidate perp and lp', () => { // market.amm.cumulativeFundingRateLong.toString(), // market.amm.cumulativeFundingRateShort.toString() // ); - assert(market.amm.cumulativeFundingRateLong.eq(new BN(253144000))); - assert(market.amm.cumulativeFundingRateShort.eq(new BN(-253144000))); + assert(market.amm.cumulativeFundingRateLong.eq(new BN(253152333))); + assert(market.amm.cumulativeFundingRateShort.eq(new BN(-253135667))); }); });