From 571613bb50ea019359d3aa10f2f11472a2f90dc4 Mon Sep 17 00:00:00 2001 From: nms-7 Date: Thu, 19 Dec 2024 12:47:40 -0500 Subject: [PATCH 1/3] adds timestamp to swap events subgraph Signed-off-by: nms-7 --- .gitignore | 3 ++- spot-staking-subgraph/schema.graphql | 3 ++- spot-staking-subgraph/src/billBroker.ts | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 8261c8d3..48cb62f1 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ node_modules coverage coverage.json typechain +typechain-types #Hardhat files cache @@ -21,4 +22,4 @@ artifacts #Generated files RolloverBatch.json -RedeemBatch.json \ No newline at end of file +RedeemBatch.json diff --git a/spot-staking-subgraph/schema.graphql b/spot-staking-subgraph/schema.graphql index c8095c09..61e1d6f3 100644 --- a/spot-staking-subgraph/schema.graphql +++ b/spot-staking-subgraph/schema.graphql @@ -46,6 +46,7 @@ type BillBrokerSwap @entity { "-" id: ID! vault: BillBroker! + timestamp: BigInt! nonce: BigInt! type: String! swapAmt: BigDecimal! @@ -94,4 +95,4 @@ type CharmVaultDailyStat @entity { token1Fees: BigDecimal! totalFeeVal: BigDecimal! feeYield: BigDecimal! -} \ No newline at end of file +} diff --git a/spot-staking-subgraph/src/billBroker.ts b/spot-staking-subgraph/src/billBroker.ts index 4603dac3..b4bc5d37 100644 --- a/spot-staking-subgraph/src/billBroker.ts +++ b/spot-staking-subgraph/src/billBroker.ts @@ -162,6 +162,7 @@ export function handleSwapPerpsForUSD(event: SwapPerpsForUSD): void { swap.type = 'perps' swap.swapAmt = formatBalance(event.params.perpAmtIn, vault.perpDecimals) swap.tx = event.transaction.hash.toHex() + swap.timestamp = event.block.timestamp swap.save() let vaultContract = BillBrokerABI.bind(stringToAddress(vault.id)) @@ -213,6 +214,7 @@ export function handleSwapUSDForPerps(event: SwapUSDForPerps): void { swap.type = 'usd' swap.swapAmt = formatBalance(event.params.usdAmtIn, vault.perpDecimals) swap.tx = event.transaction.hash.toHex() + swap.timestamp = event.block.timestamp swap.save() let vaultContract = BillBrokerABI.bind(stringToAddress(vault.id)) From 93f2df844dd1f1e1c99b25b1ec4dd388d087ec53 Mon Sep 17 00:00:00 2001 From: nms-7 Date: Thu, 19 Dec 2024 12:50:13 -0500 Subject: [PATCH 2/3] linting Signed-off-by: nms-7 --- spot-staking-subgraph/src/billBroker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spot-staking-subgraph/src/billBroker.ts b/spot-staking-subgraph/src/billBroker.ts index b4bc5d37..87058796 100644 --- a/spot-staking-subgraph/src/billBroker.ts +++ b/spot-staking-subgraph/src/billBroker.ts @@ -97,7 +97,7 @@ export function fetchBillBrokerDailyStat(vault: BillBroker, timestamp: BigInt): return dailyStat as BillBrokerDailyStat } -export function fetchBillBrokerSwap(vault: BillBroker, nonce: BigInt): BillBrokerSwap { +function fetchBillBrokerSwap(vault: BillBroker, nonce: BigInt): BillBrokerSwap { let id = vault.id.concat('-').concat(nonce.toString()) let swap = BillBrokerSwap.load(id) if (swap === null) { From b2e6a2ad97287583df2f38493ebea8135ba1b9c9 Mon Sep 17 00:00:00 2001 From: nms-7 Date: Fri, 20 Dec 2024 19:22:01 -0500 Subject: [PATCH 3/3] fixed null swap creation with 0 timestamp Signed-off-by: nms-7 --- spot-staking-subgraph/src/billBroker.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/spot-staking-subgraph/src/billBroker.ts b/spot-staking-subgraph/src/billBroker.ts index 87058796..c43664be 100644 --- a/spot-staking-subgraph/src/billBroker.ts +++ b/spot-staking-subgraph/src/billBroker.ts @@ -108,6 +108,7 @@ function fetchBillBrokerSwap(vault: BillBroker, nonce: BigInt): BillBrokerSwap { swap.swapAmt = BIGDECIMAL_ZERO swap.feeAmt = BIGDECIMAL_ZERO swap.tx = '0x' + swap.timestamp = BIGINT_ZERO swap.save() } return swap as BillBrokerSwap