diff --git a/src/utils/pool/liquidation.ts b/src/utils/pool/liquidation.ts index 0766e73..e56d5b9 100644 --- a/src/utils/pool/liquidation.ts +++ b/src/utils/pool/liquidation.ts @@ -7,7 +7,6 @@ import { PoolInfoUtils } from "../../../generated/templates/ERC20Pool/PoolInfoUt import { wadToDecimal } from "../convert" import { ONE_BI, ZERO_ADDRESS, ZERO_BD, ZERO_BI, poolInfoUtilsAddressTable } from "../constants" -import { thresholdPrice } from './loan'; export function getLiquidationAuctionId(poolId: Bytes, loanId: Bytes, kickBlock: BigInt): Bytes { return poolId.concat(Bytes.fromUTF8('|' + loanId.toString() + '|' + kickBlock.toString())) diff --git a/tests/erc-20-pool.test.ts b/tests/erc-20-pool.test.ts index 4f3ad87..77202a7 100644 --- a/tests/erc-20-pool.test.ts +++ b/tests/erc-20-pool.test.ts @@ -498,8 +498,9 @@ describe("ERC20Pool assertions", () => { const expectedBorrowerInfo = new BorrowerInfo( wdiv(amountBorrowed, inflator), collateralPledged, - BigInt.fromString("8766934085068726351")), + BigInt.fromString("8766934085068726351"), thresholdPrice + ) mockGetBorrowerInfo(poolAddress, borrower, expectedBorrowerInfo) // mock drawDebt event @@ -601,8 +602,8 @@ describe("ERC20Pool assertions", () => { const thresholdPrice = quoteRepaid.div(collateralPulled) // TODO: fix mismatch between using pre-repay and post-repay update returns - const expectedBorrowerInfo = new BorrowerInfo(quoteRepaid, collateralPulled, BigInt.fromString("501250000000000000")) - mockGetBorrowerInfo(poolAddress, borrower, expectedBorrowerInfo, thresholdPrice) + const expectedBorrowerInfo = new BorrowerInfo(quoteRepaid, collateralPulled, BigInt.fromString("501250000000000000"), thresholdPrice) + mockGetBorrowerInfo(poolAddress, borrower, expectedBorrowerInfo) const newRepayDebtEvent = createRepayDebtEvent( poolAddress, @@ -867,8 +868,9 @@ describe("ERC20Pool assertions", () => { let expectedBorrowerInfo = new BorrowerInfo( wdiv(debt, inflator), collateral, - wdiv(neutralPrice, inflator)), + wdiv(neutralPrice, inflator), thresholdPrice + ) mockGetBorrowerInfo(poolAddress, borrower, expectedBorrowerInfo) // mock kick event @@ -915,8 +917,9 @@ describe("ERC20Pool assertions", () => { expectedBorrowerInfo = new BorrowerInfo( wdiv(debt, inflator), collateral.minus(amountToTake), - wdiv(neutralPrice, inflator)), + wdiv(neutralPrice, inflator), thresholdPrice + ) mockGetBorrowerInfo(poolAddress, borrower, expectedBorrowerInfo) // mock take event diff --git a/tests/erc-721-pool.test.ts b/tests/erc-721-pool.test.ts index 14c10b1..66b8666 100644 --- a/tests/erc-721-pool.test.ts +++ b/tests/erc-721-pool.test.ts @@ -287,8 +287,9 @@ describe("Describe entity assertions", () => { const expectedBorrowerInfo = new BorrowerInfo( wdiv(amountBorrowed, inflator), amountPledged, - BigInt.fromString("8766934085068726351")), + BigInt.fromString("8766934085068726351"), thresholdPrice + ) mockGetBorrowerInfo(poolAddress, borrower, expectedBorrowerInfo) const newDrawDebtEvent = createDrawDebtNFTEvent( @@ -415,8 +416,9 @@ describe("Describe entity assertions", () => { let expectedBorrowerInfo = new BorrowerInfo( wdiv(amountBorrowed, inflator), amountPledged, - BigInt.fromString("8766934085068726351")), + BigInt.fromString("8766934085068726351"), thresholdPrice + ) mockGetBorrowerInfo(poolAddress, borrower, expectedBorrowerInfo) const newDrawDebtEvent = createDrawDebtNFTEvent( @@ -762,7 +764,7 @@ describe("Describe entity assertions", () => { const tokenIdsPledged = [BigInt.fromI32(234), BigInt.fromI32(345), BigInt.fromI32(456), BigInt.fromI32(567), BigInt.fromI32(789)] const amountPledged = BigInt.fromString("5000000000000000000") // 5 * 1e18 const lup = BigInt.fromString("9529276179422528643") // 9.529276179422528643 * 1e18 - const thresholdPrice = amountBorrowed.div(amountPledged) + let thresholdPrice = amountBorrowed.div(amountPledged) // mock required contract calls const expectedPoolDebtInfo = new DebtInfo(amountBorrowed, ZERO_BI, ZERO_BI, ZERO_BI) @@ -772,8 +774,9 @@ describe("Describe entity assertions", () => { let expectedBorrowerInfo = new BorrowerInfo( wdiv(amountBorrowed, inflator), amountPledged, - BigInt.fromString("8766934085068726351")), + BigInt.fromString("8766934085068726351"), thresholdPrice + ) mockGetBorrowerInfo(poolAddress, borrower, expectedBorrowerInfo) // create and handle DrawDebt event @@ -823,7 +826,7 @@ describe("Describe entity assertions", () => { const kickTime = BigInt.fromI32(123) const referencePrice = BigInt.fromI32(456) const neutralPrice = BigInt.fromI32(456) - const thresholdPrice = debt.div(amountPledged) + thresholdPrice = debt.div(amountPledged) const head = Address.fromString("0x0000000000000000000000000000000000000000") const next = Address.fromString("0x0000000000000000000000000000000000000000") const prev = Address.fromString("0x0000000000000000000000000000000000000000") @@ -882,8 +885,9 @@ describe("Describe entity assertions", () => { expectedBorrowerInfo = new BorrowerInfo( wdiv(amountBorrowed, inflator), amountPledged.minus(collateralToTake), - BigInt.fromString("8766934085068726351")), + BigInt.fromString("8766934085068726351"), thresholdPrice + ) mockGetBorrowerInfo(poolAddress, borrower, expectedBorrowerInfo) // create and handle Take event @@ -1163,7 +1167,7 @@ describe("Describe entity assertions", () => { const amountBorrowed = BigInt.fromString("567529276179422528643") // 567.529276179422528643 * 1e18 const tokenIdsPledged = [BigInt.fromI32(234), BigInt.fromI32(345), BigInt.fromI32(456), BigInt.fromI32(567), BigInt.fromI32(789)] const amountPledged = BigInt.fromString("5000000000000000000") // 5 * 1e18 - const thresholdPrice = amountBorrowed.div(amountPledged) + let thresholdPrice = amountBorrowed.div(amountPledged) // mock required contract calls const expectedPoolDebtInfo = new DebtInfo(amountBorrowed, ZERO_BI, ZERO_BI, ZERO_BI) @@ -1173,8 +1177,9 @@ describe("Describe entity assertions", () => { let expectedBorrowerInfo = new BorrowerInfo( wdiv(amountBorrowed, inflator), amountPledged, - BigInt.fromString("8766934085068726351")), + BigInt.fromString("8766934085068726351"), thresholdPrice + ) mockGetBorrowerInfo(poolAddress, borrower, expectedBorrowerInfo) // create and handle DrawDebt event @@ -1224,7 +1229,7 @@ describe("Describe entity assertions", () => { const kickTime = BigInt.fromI32(123) const referencePrice = BigInt.fromI32(456) const neutralPrice = BigInt.fromI32(456) - const thresholdPrice = debt.div(amountPledged) + thresholdPrice = debt.div(amountPledged) const head = Address.fromString("0x0000000000000000000000000000000000000000") const next = Address.fromString("0x0000000000000000000000000000000000000000") const prev = Address.fromString("0x0000000000000000000000000000000000000000") @@ -1314,8 +1319,9 @@ describe("Describe entity assertions", () => { expectedBorrowerInfo = new BorrowerInfo( wdiv(amountBorrowed, inflator), amountPledged.minus(collateralToTake), - BigInt.fromString("8766934085068726351")), + BigInt.fromString("8766934085068726351"), thresholdPrice + ) mockGetBorrowerInfo(poolAddress, borrower, expectedBorrowerInfo) // mock bucket take event diff --git a/tests/utils/mock-contract-calls.ts b/tests/utils/mock-contract-calls.ts index f53787e..ab97f4d 100644 --- a/tests/utils/mock-contract-calls.ts +++ b/tests/utils/mock-contract-calls.ts @@ -137,7 +137,7 @@ export function mockGetPositionInfo(tokenId: BigInt, bucketIndex: BigInt, expect /***************************/ export function mockGetBorrowerInfo(pool: Address, borrower: Address, expectedInfo: BorrowerInfo): void { - createMockedFunction(pool, 'borrowerInfo', 'borrowerInfo(address):(uint256,uint256,uint256)') + createMockedFunction(pool, 'borrowerInfo', 'borrowerInfo(address):(uint256,uint256,uint256,uint256)') .withArgs([ethereum.Value.fromAddress(borrower)]) .returns([ ethereum.Value.fromUnsignedBigInt(expectedInfo.t0debt),