update new contracts + taxPaid event
This commit is contained in:
parent
e392690da5
commit
aba495976d
2 changed files with 12 additions and 11 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import {
|
||||
PositionCreated as PositionCreatedEvent,
|
||||
PositionRemoved as PositionRemovedEvent,
|
||||
TaxPaid,
|
||||
PositionTaxPaid as PositionTaxPaidEvent,
|
||||
} from "../generated/Stake/Stake"
|
||||
import { Harb } from "../generated/Harb/Harb"
|
||||
import { BigDecimal, BigInt, Bytes } from "@graphprotocol/graph-ts"
|
||||
|
|
@ -14,7 +14,7 @@ export function handlePositionCreated(event: PositionCreatedEvent): void {
|
|||
let position = new Position(Bytes.fromI32(event.params.positionId.toI32()))
|
||||
position.owner = event.params.owner
|
||||
position.share = event.params.share.toBigDecimal().div(totalSupply)
|
||||
position.creationTime = event.params.creationTime.toI32();
|
||||
position.creationTime = event.block.timestamp.toI32();
|
||||
position.taxRate = event.params.taxRate.toBigDecimal().div(BigDecimal.fromString("100"))
|
||||
position.status = "Active"
|
||||
position.taxPaid = BigInt.fromString("0")
|
||||
|
|
@ -33,10 +33,11 @@ export function handlePositionRemoved(event: PositionRemovedEvent): void {
|
|||
}
|
||||
}
|
||||
|
||||
export function handleTaxPaid(event: TaxPaid): void {
|
||||
export function handleTaxPaid(event: PositionTaxPaidEvent): void {
|
||||
let position = Position.load(Bytes.fromI32(event.params.positionId.toI32()))
|
||||
if (position != null) {
|
||||
position.taxPaid = position.taxPaid.plus(event.params.taxAmount)
|
||||
position.taxPaid = position.taxPaid.plus(event.params.taxPaid)
|
||||
position.taxRate = event.params.taxRate.toBigDecimal().div(BigDecimal.fromString("100"))
|
||||
position.save()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ dataSources:
|
|||
name: Harb
|
||||
network: sepolia
|
||||
source:
|
||||
address: "0x7517db0f2b24223f2f0e3567149ca180e204da8a"
|
||||
address: "0x087F256D11fe533b0c7d372e44Ee0F9e47C89dF9"
|
||||
abi: Harb
|
||||
startBlock: 5909060
|
||||
startBlock: 6152180
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.7
|
||||
|
|
@ -33,9 +33,9 @@ dataSources:
|
|||
name: Stake
|
||||
network: sepolia
|
||||
source:
|
||||
address: "0x00b4d656b8182d0c2f4841b7a6f1429b94f73a66"
|
||||
address: "0xCd21a41a137BCAf8743E47D048F57D92398f7Da9"
|
||||
abi: Stake
|
||||
startBlock: 5909060
|
||||
startBlock: 6182180
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.7
|
||||
|
|
@ -48,10 +48,10 @@ dataSources:
|
|||
- name: Harb
|
||||
file: ./abis/Harb.json
|
||||
eventHandlers:
|
||||
- event: PositionCreated(indexed uint256,indexed address,uint256,uint32,uint32)
|
||||
- event: PositionCreated(indexed uint256,indexed address,uint256,uint256,uint32)
|
||||
handler: handlePositionCreated
|
||||
- event: PositionRemoved(indexed uint256,uint256,uint32)
|
||||
- event: PositionRemoved(indexed uint256,indexed address,uint256)
|
||||
handler: handlePositionRemoved
|
||||
- event: TaxPaid(indexed uint256,indexed address,uint256)
|
||||
- event: PositionTaxPaid(indexed uint256,indexed address,uint256,uint256,uint256)
|
||||
handler: handleTaxPaid
|
||||
file: ./src/stake.ts
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue