Skip to content

Commit

Permalink
divide by zero error
Browse files Browse the repository at this point in the history
  • Loading branch information
0xdavinchee committed Jan 10, 2024
1 parent 7cd6bb3 commit 77555f8
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/subgraph/src/mappingHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1620,11 +1620,14 @@ export function updateAggregateEntitiesTransferData(
* @returns the updated pool member entity to be saved
*/
export function updatePoolMemberTotalAmountUntilUpdatedAtFields(pool: Pool, poolMember: PoolMember): PoolMember {
const amountReceivedDelta = pool.totalAmountDistributedUntilUpdatedAt
.minus(poolMember.poolTotalAmountDistributedUntilUpdatedAt)
.div(pool.totalUnits)
.times(poolMember.units);
poolMember.totalAmountReceivedUntilUpdatedAt = poolMember.totalAmountReceivedUntilUpdatedAt.plus(amountReceivedDelta);
const amountReceivedDelta = pool.totalUnits.equals(BIG_INT_ZERO)
? BIG_INT_ZERO
: pool.totalAmountDistributedUntilUpdatedAt
.minus(poolMember.poolTotalAmountDistributedUntilUpdatedAt)
.div(pool.totalUnits)
.times(poolMember.units);
poolMember.totalAmountReceivedUntilUpdatedAt =
poolMember.totalAmountReceivedUntilUpdatedAt.plus(amountReceivedDelta);
poolMember.poolTotalAmountDistributedUntilUpdatedAt = pool.totalAmountDistributedUntilUpdatedAt;

return poolMember;
Expand Down

0 comments on commit 77555f8

Please sign in to comment.