From 89651c728a7ee2a11dfec7fecfd6a98a74499471 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Mon, 12 Jul 2021 22:21:00 -0300 Subject: [PATCH] Hotfix zero division on pricePerShare, curation avoid updating reserveRatio --- src/mappings/curation.ts | 2 -- src/mappings/helpers.ts | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/mappings/curation.ts b/src/mappings/curation.ts index d48b9013..aab4a924 100644 --- a/src/mappings/curation.ts +++ b/src/mappings/curation.ts @@ -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 diff --git a/src/mappings/helpers.ts b/src/mappings/helpers.ts index da467248..ac327bdc 100644 --- a/src/mappings/helpers.ts +++ b/src/mappings/helpers.ts @@ -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')