From fd6899fb01fb24e739b22fa010e644926b4e4dc2 Mon Sep 17 00:00:00 2001 From: EmberSpirit007 <148816965+EmberSpirit007@users.noreply.github.com> Date: Fri, 19 Jul 2024 15:50:07 +0200 Subject: [PATCH] added payout to the position --- subgraph/harb/schema.graphql | 1 + subgraph/harb/src/stake.ts | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/subgraph/harb/schema.graphql b/subgraph/harb/schema.graphql index 1c4b9bb..601f294 100644 --- a/subgraph/harb/schema.graphql +++ b/subgraph/harb/schema.graphql @@ -50,6 +50,7 @@ type Position @entity { totalSupplyInit: BigInt! totalSupplyEnd: BigInt status: PositionStatus! + payout: BigInt! } # type Query { diff --git a/subgraph/harb/src/stake.ts b/subgraph/harb/src/stake.ts index 9e7bf12..401dd93 100644 --- a/subgraph/harb/src/stake.ts +++ b/subgraph/harb/src/stake.ts @@ -20,6 +20,7 @@ export function handlePositionCreated(event: PositionCreatedEvent): void { position.harbDeposit = event.params.harbDeposit; position.status = "Active"; position.snatched = 0; + position.payout = BigInt.fromString("0"); position.taxPaid = BigInt.fromString("0"); let harb = Harb.bind(event.address); position.totalSupplyInit = harb.totalSupply(); @@ -32,6 +33,7 @@ export function handlePositionRemoved(event: PositionRemovedEvent): void { position.status = "Closed"; let harb = Harb.bind(event.address); position.totalSupplyEnd = harb.totalSupply(); + position.payout = position.payout.plus(event.params.harbPayout); position.save(); } } @@ -42,6 +44,8 @@ export function handlePositionShrunk(event: PositionShrunkEvent): void { position.share = event.params.newShares.toBigDecimal().div(totalSupply); position.harbDeposit = position.harbDeposit.minus(event.params.harbPayout); position.snatched = position.snatched++; + + position.payout = position.payout.plus(event.params.harbPayout); position.save(); } }