Skip to content

Commit

Permalink
fix: tranche balance ordered amounts (#90)
Browse files Browse the repository at this point in the history
* fix: tranche balance ordered amounts

* chore: renamings
  • Loading branch information
hieronx authored Dec 22, 2023
1 parent 8ba471d commit d5d157c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
13 changes: 7 additions & 6 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
20 changes: 10 additions & 10 deletions src/mappings/services/trancheBalanceService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

0 comments on commit d5d157c

Please sign in to comment.