Skip to content

Commit 2ca1280

Browse files
trizinalexcos20
andauthored
Add lockedAmount to veDelegation (#672)
* Add lockedAmount to veDelegation * Fix typo * Fixes * Add lockedAmountinVe * Replace lockedAmountinVe with timeLeft * Use event.params.ts * Fixes * Fix * Delete maxtime * Fix * Fix and rename * Revert "Fix and rename" This reverts commit 70846ea. * fix * fix --------- Co-authored-by: alexcos20 <[email protected]>
1 parent e1df119 commit 2ca1280

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

schema.graphql

+2-1
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,8 @@ type VeDelegation @entity {
481481
receiver: VeOCEAN!
482482
tokenId: BigInt!
483483
amount: BigDecimal!
484+
lockedAmount: BigDecimal!
485+
timeLeftUnlock: Int!
484486
cancelTime: BigInt!
485487
expireTime: BigInt!
486488
updates: [VeDelegationUpdate!] @derivedFrom(field: "veDelegation")
@@ -628,4 +630,3 @@ type NftTransferHistory @entity {
628630
timestamp: Int!
629631
block: Int!
630632
}
631-

src/mappings/utils/veUtils.ts

+2
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ export function getveDelegation(
140140
veDelegation.amount = BigDecimal.zero()
141141
veDelegation.receiver = ''
142142
veDelegation.delegator = ''
143+
veDelegation.lockedAmount = BigDecimal.zero()
144+
veDelegation.timeLeftUnlock = 0
143145
veDelegation.save()
144146
}
145147
return veDelegation

src/mappings/veDelegation.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,19 @@ export function handleDelegation(event: DelegateBoost): void {
1818
const _expireTime = event.params._expire_time
1919
// create veOcean if does not exists
2020
getveOCEAN(_receiver)
21-
getveOCEAN(_delegator)
22-
21+
const delegator = getveOCEAN(_delegator)
2322
const veDelegation = getveDelegation(event.address, _tokenId.toHex())
23+
const ts = event.block.timestamp.toI32()
24+
2425
veDelegation.delegator = _delegator
2526
veDelegation.receiver = _receiver
2627
veDelegation.tokenId = _tokenId
2728
veDelegation.amount = weiToDecimal(
2829
_amount.toBigDecimal(),
2930
BigInt.fromI32(18).toI32()
3031
)
32+
veDelegation.lockedAmount = delegator.lockedAmount
33+
veDelegation.timeLeftUnlock = delegator.unlockTime.toI32() - ts
3134
veDelegation.cancelTime = _cancelTime
3235
veDelegation.expireTime = _expireTime
3336
veDelegation.save()

0 commit comments

Comments
 (0)