From 62521d64058814be27860cbd089367a6b849942f Mon Sep 17 00:00:00 2001 From: Julien-devatom Date: Thu, 28 Mar 2024 11:36:32 +0100 Subject: [PATCH] fix(morpho): wrong entities created --- schema.graphql | 1 + src/morpho-blue.ts | 13 +++++++------ src/sdk/manager.ts | 1 + 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/schema.graphql b/schema.graphql index c104721..c38da8d 100644 --- a/schema.graphql +++ b/schema.graphql @@ -1637,6 +1637,7 @@ type Deposit implements Event @entity(immutable: true) @transaction { ##### Add Ons ##### isCollateral: Boolean! + shares: BigInt } type Withdraw implements Event @entity(immutable: true) @transaction { diff --git a/src/morpho-blue.ts b/src/morpho-blue.ts index f9be01f..ae66e74 100644 --- a/src/morpho-blue.ts +++ b/src/morpho-blue.ts @@ -88,7 +88,7 @@ export function handleBorrow(event: Borrow): void { market.save(); const manager = new DataManager(market.id, event); - manager.createBorrow(position, event.params.shares, event.params.assets); + manager.createBorrow(position, event.params.assets, event.params.shares); manager.updateMarketAndProtocolData(); } @@ -178,8 +178,9 @@ export function handleLiquidate(event: Liquidate): void { new AccountManager(event.params.caller).getAccount(), borrowPosition.getPosition()!, collateralPosition.getPosition()!, - event.params.seizedAssets, - event.params.repaidAssets + + event.params.repaidAssets, + event.params.seizedAssets ); collateralPosition.reduceCollateralPosition(event, event.params.seizedAssets); @@ -231,7 +232,7 @@ export function handleRepay(event: Repay): void { market.save(); const manager = new DataManager(market.id, event); - manager.createRepay(position, event.params.shares, event.params.assets); + manager.createRepay(position, event.params.assets, event.params.shares); manager.updateMarketAndProtocolData(); } @@ -276,7 +277,7 @@ export function handleSupply(event: Supply): void { market.save(); const manager = new DataManager(market.id, event); - manager.createDeposit(position, event.params.shares, event.params.assets); + manager.createDeposit(position, event.params.assets, event.params.shares); manager.updateMarketAndProtocolData(); } @@ -325,7 +326,7 @@ export function handleWithdraw(event: Withdraw): void { market.save(); const manager = new DataManager(market.id, event); - manager.createWithdraw(position, event.params.shares, event.params.assets); + manager.createWithdraw(position, event.params.assets, event.params.shares); manager.updateMarketAndProtocolData(); } diff --git a/src/sdk/manager.ts b/src/sdk/manager.ts index a7361eb..181fb44 100644 --- a/src/sdk/manager.ts +++ b/src/sdk/manager.ts @@ -268,6 +268,7 @@ export class DataManager { deposit.market = this._market.id; deposit.position = position.id; deposit.asset = position.asset; + deposit.shares = shares; deposit.amount = amount; deposit.amountUSD = amountUSD; deposit.save();