Skip to content

Commit

Permalink
fix(morpho): wrong entities created
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-devatom committed Mar 28, 2024
1 parent c56d29d commit 62521d6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
13 changes: 7 additions & 6 deletions src/morpho-blue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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();
}
Expand Down
1 change: 1 addition & 0 deletions src/sdk/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 62521d6

Please sign in to comment.