From 7e133870ae2c83b5bb57eca94bbd90ba29f5689c Mon Sep 17 00:00:00 2001 From: Ola Stenberg Date: Tue, 30 Aug 2022 12:08:13 +0200 Subject: [PATCH] fix: xSushiAgeTranfered null check --- subgraphs/bar/src/bar.ts | 5 ++++- subgraphs/bar/template.yaml | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/subgraphs/bar/src/bar.ts b/subgraphs/bar/src/bar.ts index 68581204..7a42e5b3 100644 --- a/subgraphs/bar/src/bar.ts +++ b/subgraphs/bar/src/bar.ts @@ -282,7 +282,10 @@ export function transfer(event: TransferEvent): void { // Recalc xSushi age first fromUser.xSushiAge = fromUser.xSushiAge.plus(fromUserDays.times(fromUser.xSushi)) // Calculate xSushiAge being transfered - const xSushiAgeTranfered = fromUser.xSushiAge.div(fromUser.xSushi).times(value) + let xSushiAgeTranfered = BigDecimal.fromString('0') + if (!fromUser.xSushiAge.equals(BigDecimal.fromString('0')) && !fromUser.xSushi.equals(BigDecimal.fromString('0'))) { + xSushiAgeTranfered = fromUser.xSushiAge.div(fromUser.xSushi).times(value) + } // Subtract from xSushiAge fromUser.xSushiAge = fromUser.xSushiAge.minus(xSushiAgeTranfered) fromUser.updatedAt = event.block.timestamp diff --git a/subgraphs/bar/template.yaml b/subgraphs/bar/template.yaml index acb354c8..fbbdde3f 100644 --- a/subgraphs/bar/template.yaml +++ b/subgraphs/bar/template.yaml @@ -1,4 +1,9 @@ specVersion: 0.0.3 +# features: +# - grafting +# graft: +# base: 'QmTSGqvK8kYdNFe8cRJ1S1naUb4C19cB9tijNU872hqc2i' +# block: 15439322 #NOTE: the next block had a div by 0 issue description: Bar repository: https://github.com/sushiswap/sushiswap-subgraph schema: