From 26a53431eafae7dbff46258cb4b6f9c63f3d2e96 Mon Sep 17 00:00:00 2001 From: Alex Coseru Date: Wed, 25 Jan 2023 12:18:23 +0200 Subject: [PATCH] fix veDeposit id generation (#606) * fix veDeposit id generation * handle both deposit & withdraw --- schema.graphql | 2 +- src/mappings/veOCEAN.ts | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/schema.graphql b/schema.graphql index 2988cec..1905595 100644 --- a/schema.graphql +++ b/schema.graphql @@ -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! diff --git a/src/mappings/veOCEAN.ts b/src/mappings/veOCEAN.ts index 90fc607..4e4cb08 100644 --- a/src/mappings/veOCEAN.ts +++ b/src/mappings/veOCEAN.ts @@ -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()