diff --git a/schema.graphql b/schema.graphql index 10fc29fd..f0a963bd 100644 --- a/schema.graphql +++ b/schema.graphql @@ -67,6 +67,8 @@ type Pool @entity { sumPoolFeesPaidAmount: BigInt #Applies to All sumPoolFeesPendingAmount: BigInt #Applies to All + sumRealizedProfitFifoByPeriod: BigInt + # Cumulated transaction data since pool creation sumBorrowedAmount: BigInt sumRepaidAmount: BigInt @@ -123,6 +125,8 @@ type PoolSnapshot @entity { sumPoolFeesPaidAmount: BigInt #Applies to All sumPoolFeesPendingAmount: BigInt #Applies to All + sumRealizedProfitFifoByPeriod: BigInt + # Cumulated transaction data since pool creation sumBorrowedAmount: BigInt sumRepaidAmount: BigInt diff --git a/src/mappings/handlers/loansHandlers.ts b/src/mappings/handlers/loansHandlers.ts index 41e6564f..a5fbae00 100644 --- a/src/mappings/handlers/loansHandlers.ts +++ b/src/mappings/handlers/loansHandlers.ts @@ -222,6 +222,7 @@ async function _handleLoanRepaid(event: SubstrateEvent) { quantity.toBigInt(), settlementPrice.toBigInt() ) + await pool.increaseRealizedProfitFifo(realizedProfitFifo) } const at = await AssetTransactionService.repaid({ ...assetTransactionBaseData, realizedProfitFifo }) @@ -337,6 +338,7 @@ async function _handleLoanDebtTransferred(event: SubstrateEvent