Skip to content

Commit

Permalink
Hotfix zero division on pricePerShare, curation avoid updating reserv…
Browse files Browse the repository at this point in the history
…eRatio
  • Loading branch information
juanmardefago committed Jul 13, 2021
1 parent 5b86ff8 commit 89651c7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 0 additions & 2 deletions src/mappings/curation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ export function handleSignalled(event: Signalled): void {
deployment.signalAmount = deployment.signalAmount.plus(event.params.signal)
deployment.pricePerShare = calculatePricePerShare(deployment as SubgraphDeployment)

let curation = Curation.bind(event.address)
deployment.reserveRatio = curation.pools(event.params.subgraphDeploymentID).value1.toI32()
deployment.save()

// Update epoch
Expand Down
3 changes: 2 additions & 1 deletion src/mappings/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,8 @@ export function calculatePricePerShare(deployment: SubgraphDeployment): BigDecim
// to implement the actual sell share formula for 1 share.

// reserve ratio multiplier = MAX_WEIGHT / reserveRatio = 1M (ppm) / reserveRatio
let reserveRatioMultiplier = 1000000 / deployment.reserveRatio
// HOTFIX for now, if deployment.reserveRatio -> 0, use a known previous default
let reserveRatioMultiplier = deployment.reserveRatio == 0 ? 2 : 1000000 / deployment.reserveRatio
let pricePerShare =
deployment.signalAmount == BigInt.fromI32(0)
? BigDecimal.fromString('0')
Expand Down

0 comments on commit 89651c7

Please sign in to comment.