Skip to content

Commit

Permalink
fix: cfg pending amounts (#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
filo87 authored Nov 19, 2024
1 parent 2de44dc commit d1ca2a2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 0 additions & 1 deletion .github/workflows/subql_multi_deploy_workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ jobs:
--dict="$SUBQL_DICTIONARIES" \
--type=$SUBQL_DEPLOYMENT_TYPE \
--disableHistorical \
--disableIndexerStoreCacheAsync \
--queryLimit=1000 \
--indexerWorkers=0 \
--indexerUnsafe \
Expand Down
13 changes: 10 additions & 3 deletions src/mappings/services/poolFeeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ export class PoolFeeService extends PoolFee {
}

static async getActives(poolId: string) {
const poolFees = await this.getByFields([['poolId', '=', poolId],['isActive', '=', true]], { limit: 100 })
const poolFees = await this.getByFields(
[
['poolId', '=', poolId],
['isActive', '=', true],
],
{ limit: 100 }
)
return poolFees as PoolFeeService[]
}

Expand Down Expand Up @@ -147,11 +153,12 @@ export class PoolFeeService extends PoolFee {
}

static computeSumPendingFees(poolFees: PoolFeeService[]): bigint {
if(poolFees.length === 0) return BigInt(0)
if (poolFees.length === 0) return BigInt(0)
const poolId = poolFees[0].poolId
logger.info(`Computing pendingFees for pool: ${poolId} `)
return poolFees.reduce((sumPendingAmount, poolFee) => {
if (!poolFee.pendingAmount) throw new Error(`pendingAmount not available in poolFee ${poolFee.id}`)
if (typeof poolFee.pendingAmount !== 'bigint')
throw new Error(`pendingAmount not available in poolFee ${poolFee.id}`)
return sumPendingAmount + poolFee.pendingAmount
}, BigInt(0))
}
Expand Down

0 comments on commit d1ca2a2

Please sign in to comment.