From cd894ef63a62db472ddb4ee9a3daace420461b71 Mon Sep 17 00:00:00 2001 From: leifu Date: Wed, 21 Feb 2024 13:33:08 +0200 Subject: [PATCH] Fix the account id for leaderboard data (#178) * Fixed the account id for leaderboard data * Added accountOwner * Updated the field name --- src/perps-v3.ts | 11 +++++++---- subgraphs/perps-v3.graphql | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/perps-v3.ts b/src/perps-v3.ts index d48c8f69..2bcf6031 100644 --- a/src/perps-v3.ts +++ b/src/perps-v3.ts @@ -79,7 +79,8 @@ export function handlePositionLiquidated(event: PositionLiquidatedEvent): void { return; } - let statEntity = PerpsV3Stat.load(account.owner.toHex()); + let statId = event.params.accountId.toString() + '-' + account.owner.toHexString(); + let statEntity = PerpsV3Stat.load(statId); if (openPosition === null) { log.warning('Position entity not found for positionId {}', [positionId]); @@ -146,11 +147,13 @@ export function handleOrderSettled(event: OrderSettledEvent): void { return; } - let statEntity = PerpsV3Stat.load(account.owner.toHex()); + let statId = event.params.accountId.toString() + '-' + account.owner.toHexString(); + let statEntity = PerpsV3Stat.load(statId); if (statEntity == null) { - statEntity = new PerpsV3Stat(account.owner.toHex()); - statEntity.account = account.owner; + statEntity = new PerpsV3Stat(statId); + statEntity.accountId = event.params.accountId; + statEntity.accountOwner = account.owner; statEntity.feesPaid = ZERO; statEntity.pnl = ZERO; statEntity.pnlWithFeesPaid = ZERO; diff --git a/subgraphs/perps-v3.graphql b/subgraphs/perps-v3.graphql index f09dd7fc..81aa6ced 100644 --- a/subgraphs/perps-v3.graphql +++ b/subgraphs/perps-v3.graphql @@ -158,7 +158,8 @@ type CollateralChange @entity { type PerpsV3Stat @entity { id: ID! - account: Bytes! + accountId: BigInt! + accountOwner: Bytes! feesPaid: BigInt! pnl: BigInt! pnlWithFeesPaid: BigInt!