added payout to the position
This commit is contained in:
parent
84999fc90a
commit
fd6899fb01
2 changed files with 5 additions and 0 deletions
|
|
@ -50,6 +50,7 @@ type Position @entity {
|
|||
totalSupplyInit: BigInt!
|
||||
totalSupplyEnd: BigInt
|
||||
status: PositionStatus!
|
||||
payout: BigInt!
|
||||
}
|
||||
|
||||
# type Query {
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue