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 70846eafe2.

* fix

* fix

---------

Co-authored-by: alexcos20 <alex.coseru@gmail.com>
This commit is contained in:
trizin 2023-05-13 15:38:57 +03:00 committed by GitHub
parent e1df119197
commit 2ca1280328
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 3 deletions

View File

@ -481,6 +481,8 @@ type VeDelegation @entity {
receiver: VeOCEAN!
tokenId: BigInt!
amount: BigDecimal!
lockedAmount: BigDecimal!
timeLeftUnlock: Int!
cancelTime: BigInt!
expireTime: BigInt!
updates: [VeDelegationUpdate!] @derivedFrom(field: "veDelegation")
@ -628,4 +630,3 @@ type NftTransferHistory @entity {
timestamp: Int!
block: Int!
}

View File

@ -140,6 +140,8 @@ export function getveDelegation(
veDelegation.amount = BigDecimal.zero()
veDelegation.receiver = ''
veDelegation.delegator = ''
veDelegation.lockedAmount = BigDecimal.zero()
veDelegation.timeLeftUnlock = 0
veDelegation.save()
}
return veDelegation

View File

@ -18,9 +18,10 @@ export function handleDelegation(event: DelegateBoost): void {
const _expireTime = event.params._expire_time
// create veOcean if does not exists
getveOCEAN(_receiver)
getveOCEAN(_delegator)
const delegator = getveOCEAN(_delegator)
const veDelegation = getveDelegation(event.address, _tokenId.toHex())
const ts = event.block.timestamp.toI32()
veDelegation.delegator = _delegator
veDelegation.receiver = _receiver
veDelegation.tokenId = _tokenId
@ -28,6 +29,8 @@ export function handleDelegation(event: DelegateBoost): void {
_amount.toBigDecimal(),
BigInt.fromI32(18).toI32()
)
veDelegation.lockedAmount = delegator.lockedAmount
veDelegation.timeLeftUnlock = delegator.unlockTime.toI32() - ts
veDelegation.cancelTime = _cancelTime
veDelegation.expireTime = _expireTime
veDelegation.save()