Skip to content
This repository has been archived by the owner on Oct 26, 2022. It is now read-only.

fix: xSushiAgeTranfered null check #100

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion subgraphs/bar/src/bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions subgraphs/bar/template.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down