From d5d157c85b86dc2c1f75a0d5c5fd0518eb2406c7 Mon Sep 17 00:00:00 2001 From: Jeroen <1748621+hieronx@users.noreply.github.com> Date: Fri, 22 Dec 2023 13:54:27 +0100 Subject: [PATCH] fix: tranche balance ordered amounts (#90) * fix: tranche balance ordered amounts * chore: renamings --- schema.graphql | 13 ++++++------ .../services/trancheBalanceService.ts | 20 +++++++++---------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/schema.graphql b/schema.graphql index a900dabe..a17d911a 100644 --- a/schema.graphql +++ b/schema.graphql @@ -277,13 +277,14 @@ type TrancheBalance @entity { pool: Pool! @index tranche: Tranche! @index - sumInvestOrderedAmount: BigInt! - sumInvestUncollectedAmount: BigInt! - sumInvestCollectedAmount: BigInt! + pendingInvestCurrency: BigInt! + claimableTrancheTokens: BigInt! - sumRedeemOrderedAmount: BigInt! - sumRedeemUncollectedAmount: BigInt! - sumRedeemCollectedAmount: BigInt! + pendingRedeemTrancheTokens: BigInt! + claimableCurrency: BigInt! + + sumClaimedTrancheTokens: BigInt! + sumClaimedCurrency: BigInt! } enum LoanStatus { diff --git a/src/mappings/services/trancheBalanceService.ts b/src/mappings/services/trancheBalanceService.ts index 78dc048a..288b8e4b 100644 --- a/src/mappings/services/trancheBalanceService.ts +++ b/src/mappings/services/trancheBalanceService.ts @@ -33,30 +33,30 @@ export class TrancheBalanceService extends TrancheBalance { } public investOrder(currencyAmount: bigint) { - this.sumInvestOrderedAmount += currencyAmount + this.pendingInvestCurrency = currencyAmount } public redeemOrder(tokenAmount: bigint) { - this.sumRedeemOrderedAmount += tokenAmount + this.pendingRedeemTrancheTokens = tokenAmount } public investExecute(currencyAmount: bigint, tokenAmount: bigint) { - this.sumInvestOrderedAmount -= currencyAmount - this.sumInvestUncollectedAmount += tokenAmount + this.pendingInvestCurrency -= currencyAmount + this.claimableTrancheTokens += tokenAmount } public redeemExecute(tokenAmount: bigint, currencyAmount: bigint) { - this.sumRedeemOrderedAmount -= tokenAmount - this.sumRedeemUncollectedAmount += currencyAmount + this.pendingRedeemTrancheTokens -= tokenAmount + this.claimableCurrency += currencyAmount } public investCollect(tokenAmount: bigint) { - this.sumInvestUncollectedAmount -= tokenAmount - this.sumInvestCollectedAmount += tokenAmount + this.claimableTrancheTokens -= tokenAmount + this.sumClaimedTrancheTokens += tokenAmount } public redeemCollect(currencyAmount: bigint) { - this.sumRedeemUncollectedAmount -= currencyAmount - this.sumRedeemCollectedAmount += currencyAmount + this.claimableCurrency -= currencyAmount + this.sumClaimedCurrency += currencyAmount } }