Skip to content

Commit

Permalink
feat: add rates to tx entities
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-devatom committed May 22, 2024
1 parent 56c4d43 commit 26f6fd7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
18 changes: 18 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1638,6 +1638,9 @@ type Deposit implements Event @entity(immutable: true) @transaction {

isCollateral: Boolean!
shares: BigInt

" All interest rates for this borrow. Should be in APR format "
rates: [InterestRate!]
}

type Withdraw implements Event @entity(immutable: true) @transaction {
Expand Down Expand Up @@ -1698,6 +1701,9 @@ type Withdraw implements Event @entity(immutable: true) @transaction {
isCollateral: Boolean!

shares: BigInt

" All interest rates for this borrow. Should be in APR format "
rates: [InterestRate!]
}

# For CDPs, use this for mint events
Expand Down Expand Up @@ -1752,6 +1758,9 @@ type Borrow implements Event @entity(immutable: true) @transaction {

#### Addons ####
shares: BigInt!

" All interest rates for this borrow. Should be in APR format "
rates: [InterestRate!]
}

# For CDPs, use this for burn events
Expand Down Expand Up @@ -1806,6 +1815,9 @@ type Repay implements Event @entity(immutable: true) @transaction {

#### Addons ####
shares: BigInt!

" All interest rates for this Repay. Should be in APR format "
rates: [InterestRate!]
}

type Liquidate implements Event @entity(immutable: true) @transaction {
Expand Down Expand Up @@ -2216,6 +2228,8 @@ type MetaMorphoDeposit @entity(immutable: true) {
metaMorpho: MetaMorpho!

shares: BigInt!

rate: InterestRate!
}

type MetaMorphoWithdraw @entity(immutable: true) {
Expand Down Expand Up @@ -2267,6 +2281,8 @@ type MetaMorphoWithdraw @entity(immutable: true) {
metaMorpho: MetaMorpho!

shares: BigInt!

rate: InterestRate!
}

type AllocatorSet @entity(immutable: true) {
Expand Down Expand Up @@ -2354,4 +2370,6 @@ type MetaMorphoTransfer @entity(immutable: true) {

metaMorpho: MetaMorpho!

rate: InterestRate!

}
3 changes: 3 additions & 0 deletions src/meta-morpho.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ export function handleDeposit(event: DepositEvent): void {
deposit.shares = event.params.shares;
deposit.metaMorpho = mm.id;
deposit.metaMorphoPosition = position.id;
deposit.rate = mm.rate;
deposit.save();
}

Expand Down Expand Up @@ -693,6 +694,7 @@ export function handleTransfer(event: TransferEvent): void {
transfer.metaMorphoPositionFrom = fromPosition.id;
transfer.metaMorphoPositionTo = toPosition.id;
transfer.metaMorpho = mm.id;
transfer.rate = mm.rate;
transfer.save();
}

Expand Down Expand Up @@ -750,5 +752,6 @@ export function handleWithdraw(event: WithdrawEvent): void {
withdraw.shares = event.params.shares;
withdraw.metaMorpho = mm.id;
withdraw.metaMorphoPosition = position.id;
withdraw.rate = mm.rate;
withdraw.save();
}
7 changes: 7 additions & 0 deletions src/sdk/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ export class DataManager {
deposit.account = position.account;
deposit.market = this._market.id;
deposit.position = position.id;
deposit.rates = this._market.rates;
deposit.asset = position.asset;
deposit.amount = amount;
deposit.amountUSD = amountUSD;
Expand Down Expand Up @@ -268,6 +269,7 @@ export class DataManager {
deposit.market = this._market.id;
deposit.position = position.id;
deposit.asset = position.asset;
deposit.rates = this._market.rates;
deposit.shares = shares;
deposit.amount = amount;
deposit.amountUSD = amountUSD;
Expand Down Expand Up @@ -303,6 +305,7 @@ export class DataManager {
withdraw.market = this._market.id;
withdraw.position = position.id;
withdraw.asset = position.asset;
withdraw.rates = this._market.rates;
withdraw.amount = amount;
withdraw.amountUSD = amountUSD;
withdraw.isCollateral = true;
Expand Down Expand Up @@ -346,6 +349,7 @@ export class DataManager {
withdraw.market = this._market.id;
withdraw.position = position.id;
withdraw.asset = this._market.borrowedToken;
withdraw.rates = this._market.rates;
withdraw.amount = amount;
withdraw.amountUSD = amountUSD;
withdraw.isCollateral = false;
Expand Down Expand Up @@ -380,6 +384,7 @@ export class DataManager {
borrow.market = this._market.id;
borrow.position = position.id;
borrow.asset = this._market.borrowedToken;
borrow.rates = this._market.rates;
borrow.amount = amount;
borrow.amountUSD = amountUSD;
borrow.shares = shares;
Expand Down Expand Up @@ -418,6 +423,8 @@ export class DataManager {
repay.market = this._market.id;
repay.position = position.id;
repay.asset = position.asset;

repay.rates = this._market.rates;
repay.amount = amount;
repay.shares = shares;
repay.amountUSD = amountUSD;
Expand Down

0 comments on commit 26f6fd7

Please sign in to comment.