diff --git a/schema.graphql b/schema.graphql index 5cf6c8a..eaec4aa 100644 --- a/schema.graphql +++ b/schema.graphql @@ -86,7 +86,6 @@ type Pool @entity { htpIndex: Int! # current highest threshold price index lup: BigDecimal! # current lowest utilized price lupIndex: Int! # current lowest utilized price index - momp: BigDecimal! # most optimistic matching price # RESERVES INFORMATION # current reserves contractQuoteBalance + poolDebt - pool.depositSize() @@ -264,6 +263,7 @@ type LiquidationAuction @entity { bondSize: BigDecimal! # bond provided by kicker to initate auction bondFactor: BigDecimal! # bond factor determining the reward or penalty for the kicker neutralPrice: BigDecimal! # price at which kicker will have their bond returned without penalty or reward + referencePrice: BigDecimal! # max(HTP, NP) used in auction price curve } # tracks the reserve auction process across multiple takes in a single auction @@ -420,7 +420,6 @@ type Flashloan @entity(immutable: true) { type Kick @entity { id: Bytes! kicker: Bytes! # address of the kicker - kickMomp: BigDecimal! # pool MOMP at the time of kicking pool: Pool! # Pool in which a kick occurred loan: Loan! # Loan which was kicked locked: BigDecimal! # amount of quote from the bond locked in the kick (updated on take) TODO: rename bondLocked @@ -503,7 +502,6 @@ type RepayDebt @entity(immutable: true) { type ReserveAuctionKick @entity(immutable: true) { id: Bytes! # transaction.hash + transaction.from kicker: Bytes # address of the taker, null if emitted as start of event - kickerAward: BigDecimal! # amount of quote rewarded to kicker for starting reserves auction reserveAuction: ReserveAuction! # reserve auction in which the take is occuring pool: Pool! # pool in which the auction was kicked claimableReserves: BigDecimal! # uint256 initial amount of claimable reserves in the auction diff --git a/src/mappings/base/base-pool.ts b/src/mappings/base/base-pool.ts index 180deb6..abe6a10 100644 --- a/src/mappings/base/base-pool.ts +++ b/src/mappings/base/base-pool.ts @@ -641,7 +641,6 @@ export function _handleReserveAuctionKick(event: ethereum.Event, currentBurnEpoc updatePool(pool) addReserveAuctionToPool(pool, reserveAuction) pool.txCount = pool.txCount.plus(ONE_BI) - reserveKick.kickerAward = reserveAuctionKickerReward(pool) // update account state const account = loadOrCreateAccount(addressToBytes(event.transaction.from)) diff --git a/src/mappings/erc-20-pool.ts b/src/mappings/erc-20-pool.ts index 1ce54e7..c31faf9 100644 --- a/src/mappings/erc-20-pool.ts +++ b/src/mappings/erc-20-pool.ts @@ -384,7 +384,6 @@ export function handleKick(event: KickEvent): void { const auction = loadOrCreateLiquidationAuction(pool.id, auctionId, kick, loan) updateLiquidationAuction(auction, auctionInfo, auctionStatus) - kick.kickMomp = wadToDecimal(auctionInfo.kickMomp) kick.startingPrice = wadToDecimal(auctionStatus.price) kick.pool = pool.id kick.loan = loan.id diff --git a/src/mappings/erc-721-pool.ts b/src/mappings/erc-721-pool.ts index c595f9b..49eaf87 100644 --- a/src/mappings/erc-721-pool.ts +++ b/src/mappings/erc-721-pool.ts @@ -572,7 +572,6 @@ export function handleKick(event: KickEvent): void { const auction = loadOrCreateLiquidationAuction(pool.id, auctionId, kick, loan) updateLiquidationAuction(auction, auctionInfo, auctionStatus) - kick.kickMomp = wadToDecimal(auctionInfo.kickMomp) kick.startingPrice = wadToDecimal(auctionStatus.price) kick.pool = pool.id kick.loan = loan.id diff --git a/src/utils/pool/liquidation.ts b/src/utils/pool/liquidation.ts index 8b6c8d7..4a5f669 100644 --- a/src/utils/pool/liquidation.ts +++ b/src/utils/pool/liquidation.ts @@ -1,6 +1,6 @@ import { Address, BigDecimal, BigInt, Bytes, Value, dataSource } from "@graphprotocol/graph-ts" -import { LiquidationAuction, Kick, Loan, Pool, BucketTake } from "../../../generated/schema" +import { LiquidationAuction, Kick, Loan, Pool, BucketTake } from '../../../generated/schema'; import { ERC20Pool } from '../../../generated/templates/ERC20Pool/ERC20Pool' import { ERC721Pool } from "../../../generated/templates/ERC721Pool/ERC721Pool" import { PoolInfoUtils } from "../../../generated/templates/ERC20Pool/PoolInfoUtils" @@ -81,6 +81,7 @@ export function updateLiquidationAuction( liquidationAuction.bondSize = wadToDecimal(auctionInfo.bondSize) liquidationAuction.kickTime = auctionInfo.kickTime liquidationAuction.neutralPrice = wadToDecimal(auctionInfo.neutralPrice) + liquidationAuction.referencePrice = wadToDecimal(auctionInfo.referencePrice) } // update remaining quantities even if auction was settled and they are 0 @@ -96,18 +97,18 @@ export class AuctionInfo { bondFactor: BigInt bondSize: BigInt kickTime: BigInt - kickMomp: BigInt + referencePrice: BigInt neutralPrice: BigInt head: Address next: Address prev: Address alreadyTaken: bool - constructor(kicker: Address, bondFactor: BigInt, bondSize: BigInt, kickTime: BigInt, kickMomp: BigInt, neutralPrice: BigInt, head: Address, next: Address, prev: Address, alreadyTaken: bool) { + constructor(kicker: Address, bondFactor: BigInt, bondSize: BigInt, kickTime: BigInt, referencePrice: BigInt, neutralPrice: BigInt, head: Address, next: Address, prev: Address, alreadyTaken: bool) { this.kicker = kicker this.bondFactor = bondFactor this.bondSize = bondSize this.kickTime = kickTime - this.kickMomp = kickMomp + this.referencePrice = referencePrice this.neutralPrice = neutralPrice this.head = head this.next = next diff --git a/src/utils/pool/pool.ts b/src/utils/pool/pool.ts index 92c75ab..6b0e850 100644 --- a/src/utils/pool/pool.ts +++ b/src/utils/pool/pool.ts @@ -58,14 +58,6 @@ export function getLenderInfoERC721Pool(poolId: Bytes, bucketIndex: BigInt, lend ) } -// retrieve the current pool MOMP by calling PoolInfoUtils.momp() -export function getMomp(poolId: Bytes): BigDecimal { - const poolInfoUtilsAddress = poolInfoUtilsAddressTable.get(dataSource.network())! - const poolInfoUtilsContract = PoolInfoUtils.bind(poolInfoUtilsAddress) - const pool = Pool.load(poolId) - return wadToDecimal(poolInfoUtilsContract.momp(Address.fromBytes(poolId))) -} - export class RatesAndFees { lenderInterestMargin: BigInt borrowFeeRate: BigInt @@ -239,7 +231,6 @@ export function updatePool(pool: Pool): void { pool.htpIndex = poolPricesInfo.htpIndex.toU32() pool.lup = wadToDecimal(poolPricesInfo.lup) pool.lupIndex = poolPricesInfo.lupIndex.toU32() - pool.momp = getMomp(pool.id) // update reserve auction information const poolReservesInfo = getPoolReservesInfo(pool) @@ -440,7 +431,6 @@ export function loadOrCreatePool(id: Bytes): Pool { pool.htpIndex = 0 pool.lup = MAX_PRICE pool.lupIndex = MAX_PRICE_INDEX - pool.momp = ZERO_BD // reserve auction information pool.reserves = ZERO_BD diff --git a/tests/erc-20-pool.test.ts b/tests/erc-20-pool.test.ts index 12ae23b..9322325 100644 --- a/tests/erc-20-pool.test.ts +++ b/tests/erc-20-pool.test.ts @@ -95,7 +95,6 @@ describe("ERC20Pool assertions", () => { htpIndex: ZERO_BI, lup: MAX_PRICE_BI, lupIndex: BigInt.fromU32(MAX_PRICE_INDEX), - momp: BigInt.fromU32(623804), reserves: ZERO_BI, claimableReserves: ZERO_BI, claimableReservesRemaining: ZERO_BI, @@ -202,7 +201,6 @@ describe("ERC20Pool assertions", () => { htpIndex: ZERO_BI, lup: lup, lupIndex: BigInt.fromU32(MAX_PRICE_INDEX), //TODO: indexToPrice(lup) - momp: BigInt.fromI32(623803), reserves: ZERO_BI, claimableReserves: ZERO_BI, claimableReservesRemaining: ZERO_BI, @@ -631,8 +629,8 @@ describe("ERC20Pool assertions", () => { const kicker = Address.fromString("0x0000000000000000000000000000000000000003") const bondFactor = ONE_WAD_BI const kickTime = BigInt.fromI32(123) - const kickMomp = BigInt.fromI32(456) const neutralPrice = BigInt.fromI32(456) + const referencePrice = BigInt.fromI32(456) const head = Address.fromString("0x0000000000000000000000000000000000000000") const next = Address.fromString("0x0000000000000000000000000000000000000000") const prev = Address.fromString("0x0000000000000000000000000000000000000000") @@ -643,7 +641,7 @@ describe("ERC20Pool assertions", () => { bondFactor, bond, kickTime, - kickMomp, + referencePrice, neutralPrice, head, next, @@ -815,7 +813,7 @@ describe("ERC20Pool assertions", () => { const bondFactor = ONE_WAD_BI const debt = BigInt.fromString("567529276179422528643") // 567.529276179422528643 * 1e18 const kickTime = BigInt.fromI32(123) - const kickMomp = BigInt.fromI32(456) + const referencePrice = BigInt.fromI32(456) const neutralPrice = BigInt.fromI32(456) const head = Address.fromString("0x0000000000000000000000000000000000000000") const next = Address.fromString("0x0000000000000000000000000000000000000000") @@ -827,7 +825,7 @@ describe("ERC20Pool assertions", () => { bondFactor, bond, kickTime, - kickMomp, + referencePrice, neutralPrice, head, next, @@ -864,7 +862,7 @@ describe("ERC20Pool assertions", () => { bondFactor, bond, kickTime, - kickMomp, + referencePrice, neutralPrice, head, next, @@ -1006,7 +1004,7 @@ describe("ERC20Pool assertions", () => { const bondFactor = ONE_WAD_BI const debt = BigInt.fromString("567529276179422528643") // 567.529276179422528643 * 1e18 const kickTime = BigInt.fromI32(123) - const kickMomp = BigInt.fromI32(456) + const referencePrice = BigInt.fromI32(456) const neutralPrice = BigInt.fromI32(456) const head = Address.fromString("0x0000000000000000000000000000000000000000") const next = Address.fromString("0x0000000000000000000000000000000000000000") @@ -1017,7 +1015,7 @@ describe("ERC20Pool assertions", () => { bondFactor, bond, kickTime, - kickMomp, + referencePrice, neutralPrice, head, next, @@ -1047,7 +1045,7 @@ describe("ERC20Pool assertions", () => { bondFactor, bond, kickTime, - kickMomp, + referencePrice, neutralPrice, head, next, @@ -1201,7 +1199,7 @@ describe("ERC20Pool assertions", () => { const bondFactor = ONE_WAD_BI const debt = BigInt.fromString("567529276179422528643") // 567.529276179422528643 * 1e18 const kickTime = BigInt.fromI32(123) - const kickMomp = BigInt.fromI32(456) + const referencePrice = BigInt.fromI32(456) const neutralPrice = BigInt.fromI32(456) const head = Address.fromString("0x0000000000000000000000000000000000000000") const next = Address.fromString("0x0000000000000000000000000000000000000000") @@ -1212,7 +1210,7 @@ describe("ERC20Pool assertions", () => { bondFactor, bond, kickTime, - kickMomp, + referencePrice, neutralPrice, head, next, @@ -1264,7 +1262,6 @@ describe("ERC20Pool assertions", () => { htpIndex: ZERO_BI, lup: MAX_PRICE_BI, //TODO: indexToPrice(lup) lupIndex: BigInt.fromU32(MAX_PRICE_INDEX), - momp: BigInt.fromI32(623801), reserves: ZERO_BI, claimableReserves: claimableReserves, claimableReservesRemaining: claimableReserves, @@ -1327,12 +1324,6 @@ describe("ERC20Pool assertions", () => { "kicker", `${kicker.toHexString()}` ) - assert.fieldEquals( - "ReserveAuctionKick", - `${kickReserveAuctionID.toHexString()}`, - "kickerAward", - `${wadToDecimal(wmul(claimableReserves, ONE_PERCENT_BI))}` - ) assert.entityCount("ReserveAuction", 1) assert.fieldEquals( @@ -1382,7 +1373,6 @@ describe("ERC20Pool assertions", () => { htpIndex: ZERO_BI, lup: MAX_PRICE_BI, lupIndex: BigInt.fromU32(MAX_PRICE_INDEX), //TODO: indexToPrice(lup) - momp: BigInt.fromI32(623802), reserves: ZERO_BI, claimableReserves: claimableReservesAfterTake, claimableReservesRemaining: claimableReservesAfterTake, diff --git a/tests/erc-721-pool.test.ts b/tests/erc-721-pool.test.ts index fb9559e..490b5d4 100644 --- a/tests/erc-721-pool.test.ts +++ b/tests/erc-721-pool.test.ts @@ -95,7 +95,6 @@ describe("Describe entity assertions", () => { htpIndex: ZERO_BI, lup: MAX_PRICE_BI, lupIndex: BigInt.fromU32(MAX_PRICE_INDEX), - momp: BigInt.fromU32(623804), reserves: ZERO_BI, claimableReserves: ZERO_BI, claimableReservesRemaining: ZERO_BI, @@ -187,7 +186,6 @@ describe("Describe entity assertions", () => { htpIndex: ZERO_BI, lup: lup, lupIndex: BigInt.fromU32(MAX_PRICE_INDEX), //TODO: indexToPrice(lup) - momp: BigInt.fromI32(623803), reserves: ZERO_BI, claimableReserves: ZERO_BI, claimableReservesRemaining: ZERO_BI, @@ -579,7 +577,6 @@ describe("Describe entity assertions", () => { htpIndex: ZERO_BI, lup: MAX_PRICE_BI, lupIndex: BigInt.fromU32(MAX_PRICE_INDEX), - momp: BigInt.fromU32(623804), reserves: ZERO_BI, claimableReserves: ZERO_BI, claimableReservesRemaining: ZERO_BI, @@ -797,7 +794,7 @@ describe("Describe entity assertions", () => { const bondFactor = ONE_WAD_BI const debt = BigInt.fromString("567529276179422528643") // 567.529276179422528643 * 1e18 const kickTime = BigInt.fromI32(123) - const kickMomp = BigInt.fromI32(456) + const referencePrice = BigInt.fromI32(456) const neutralPrice = BigInt.fromI32(456) const head = Address.fromString("0x0000000000000000000000000000000000000000") const next = Address.fromString("0x0000000000000000000000000000000000000000") @@ -810,7 +807,7 @@ describe("Describe entity assertions", () => { bondFactor, bond, kickTime, - kickMomp, + referencePrice, neutralPrice, head, next, @@ -1103,7 +1100,6 @@ describe("Describe entity assertions", () => { htpIndex: ZERO_BI, lup: lup, lupIndex: BigInt.fromU32(MAX_PRICE_INDEX), //TODO: indexToPrice(lup) - momp: BigInt.fromI32(623803), reserves: ZERO_BI, claimableReserves: ZERO_BI, claimableReservesRemaining: ZERO_BI, @@ -1193,7 +1189,7 @@ describe("Describe entity assertions", () => { const bondFactor = ONE_WAD_BI const debt = BigInt.fromString("567529276179422528643") // 567.529276179422528643 * 1e18 const kickTime = BigInt.fromI32(123) - const kickMomp = BigInt.fromI32(456) + const referencePrice = BigInt.fromI32(456) const neutralPrice = BigInt.fromI32(456) const head = Address.fromString("0x0000000000000000000000000000000000000000") const next = Address.fromString("0x0000000000000000000000000000000000000000") @@ -1206,7 +1202,7 @@ describe("Describe entity assertions", () => { bondFactor, bond, kickTime, - kickMomp, + referencePrice, neutralPrice, head, next, diff --git a/tests/utils/common.ts b/tests/utils/common.ts index ef449e2..7d3b944 100644 --- a/tests/utils/common.ts +++ b/tests/utils/common.ts @@ -352,7 +352,6 @@ export function createAndHandleAddQuoteTokenEvent(poolAddress: Address, lender: htpIndex: ZERO_BI, lup: lup, lupIndex: BigInt.fromU32(MAX_PRICE_INDEX), //TODO: indexToPrice(lup) - momp: BigInt.fromI32(623803), reserves: ZERO_BI, claimableReserves: ZERO_BI, claimableReservesRemaining: ZERO_BI, diff --git a/tests/utils/mock-contract-calls.ts b/tests/utils/mock-contract-calls.ts index 9772fc5..49ca531 100644 --- a/tests/utils/mock-contract-calls.ts +++ b/tests/utils/mock-contract-calls.ts @@ -229,15 +229,6 @@ export function mockGetPoolPricesInfo(pool: Address, expectedInfo: PoolPricesInf ]) } -// mock getMomp contract calls -export function mockGetPoolMomp(pool: Address, expectedInfo: BigInt): void { - createMockedFunction(poolInfoUtilsAddressTable.get(dataSource.network())!, 'momp', 'momp(address):(uint256)') - .withArgs([ethereum.Value.fromAddress(pool)]) - .returns([ - ethereum.Value.fromUnsignedBigInt(expectedInfo) - ]) -} - // mock getPoolReserves contract calls export function mockGetPoolReserves(pool: Address, expectedInfo: ReservesInfo): void { createMockedFunction(poolInfoUtilsAddressTable.get(dataSource.network())!, 'poolReservesInfo', 'poolReservesInfo(address):(uint256,uint256,uint256,uint256,uint256)') @@ -272,7 +263,7 @@ export function mockGetAuctionInfo(borrower: Address, pool: Address, expectedInf ethereum.Value.fromUnsignedBigInt(expectedInfo.bondFactor), ethereum.Value.fromUnsignedBigInt(expectedInfo.bondSize), ethereum.Value.fromUnsignedBigInt(expectedInfo.kickTime), - ethereum.Value.fromUnsignedBigInt(expectedInfo.kickMomp), + ethereum.Value.fromUnsignedBigInt(expectedInfo.referencePrice), ethereum.Value.fromUnsignedBigInt(expectedInfo.neutralPrice), ethereum.Value.fromAddress(expectedInfo.head), ethereum.Value.fromAddress(expectedInfo.next), @@ -360,7 +351,6 @@ export class PoolMockParams { htpIndex: BigInt lup: BigInt lupIndex: BigInt - momp: BigInt // reserves info mock params reserves: BigInt claimableReserves: BigInt @@ -401,8 +391,6 @@ export function mockPoolInfoUtilsPoolUpdateCalls(pool: Address, params: PoolMock ) mockGetPoolPricesInfo(pool, expectedPoolPricesInfo) - mockGetPoolMomp(pool, params.momp) - const expectedPoolReservesInfo = new ReservesInfo( params.reserves, params.claimableReserves,