fix veDeposit id generation (#606)

* fix veDeposit id generation

* handle both deposit & withdraw
This commit is contained in:
Alex Coseru 2023-01-25 12:18:23 +02:00 committed by GitHub
parent 25021ac9ea
commit 26a53431ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View File

@ -486,7 +486,7 @@ type VeOCEAN @entity {
}
type VeDeposit @entity {
"id = {user address}-{timestamp}"
"id = {user address}-{tx}-{eventIndex}"
id: ID!
"veOcean holder"
provider:String!

View File

@ -12,7 +12,13 @@ export function handleDeposit(event: Deposit): void {
const veOCEAN = getveOCEAN(provider.toHex())
// Create new Deposit entity
const deposit = getDeposit(provider.toHex() + '-' + locktime.toString())
const deposit = getDeposit(
provider.toHex() +
'-' +
event.transaction.hash.toHex() +
'-' +
event.logIndex.toString()
)
deposit.provider = provider.toHex()
deposit.value = weiToDecimal(value.toBigDecimal(), 18)
deposit.unlockTime = locktime
@ -39,7 +45,13 @@ export function handleWithdraw(event: Withdraw): void {
const veOCEAN = getveOCEAN(provider.toHex())
// Create new Deposit entity
const deposit = getDeposit(provider.toHex() + '-' + ts.toString())
const deposit = getDeposit(
provider.toHex() +
'-' +
event.transaction.hash.toHex() +
'-' +
event.logIndex.toString()
)
deposit.provider = provider.toHex()
deposit.value = weiToDecimal(value.toBigDecimal(), 18).neg()
deposit.unlockTime = BigInt.zero()