From 3993d3855b5957b7627afd805029ed206480146c Mon Sep 17 00:00:00 2001 From: Dhruv Chauhan Date: Thu, 20 Jul 2023 13:45:53 +0530 Subject: [PATCH 1/2] fix financialSnapshots.tvl --- deployment/deployment.json | 4 ++-- subgraphs/ribbon-finance/src/mappings/vault.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/deployment/deployment.json b/deployment/deployment.json index 3f54792320..49d43799e5 100644 --- a/deployment/deployment.json +++ b/deployment/deployment.json @@ -3224,7 +3224,7 @@ "status": "prod", "versions": { "schema": "1.3.1", - "subgraph": "1.0.1", + "subgraph": "1.0.2", "methodology": "1.0.0" }, "files": { @@ -3250,7 +3250,7 @@ "status": "prod", "versions": { "schema": "1.3.1", - "subgraph": "1.0.1", + "subgraph": "1.0.2", "methodology": "1.0.0" }, "files": { diff --git a/subgraphs/ribbon-finance/src/mappings/vault.ts b/subgraphs/ribbon-finance/src/mappings/vault.ts index 8d0324e863..ead4b6e785 100644 --- a/subgraphs/ribbon-finance/src/mappings/vault.ts +++ b/subgraphs/ribbon-finance/src/mappings/vault.ts @@ -89,7 +89,6 @@ export function handleDeposit(event: DepositEvent): void { getOrCreateVault(vaultAddress, event.block); updateVaultTVL(vaultAddress, block); updateUsageMetrics(event.block, event.params.account); - updateFinancials(block); updateVaultSnapshots(vaultAddress, event.block); Transaction( @@ -99,6 +98,7 @@ export function handleDeposit(event: DepositEvent): void { event.block, constants.TransactionType.DEPOSIT ); + updateFinancials(block); } export function handleWithdraw(event: WithdrawEvent): void { @@ -109,7 +109,6 @@ export function handleWithdraw(event: WithdrawEvent): void { getOrCreateVault(vaultAddress, event.block); updateVaultTVL(vaultAddress, block); updateUsageMetrics(event.block, event.params.account); - updateFinancials(block); updateVaultSnapshots(vaultAddress, event.block); Transaction( @@ -119,6 +118,7 @@ export function handleWithdraw(event: WithdrawEvent): void { event.block, constants.TransactionType.WITHDRAW ); + updateFinancials(block); } export function handleInstantWithdraw(event: InstantWithdraw): void { @@ -128,7 +128,6 @@ export function handleInstantWithdraw(event: InstantWithdraw): void { updateVaultTVL(vaultAddress, block); updateUsageMetrics(event.block, event.params.account); - updateFinancials(block); updateVaultSnapshots(vaultAddress, event.block); Transaction( @@ -138,6 +137,7 @@ export function handleInstantWithdraw(event: InstantWithdraw): void { event.block, constants.TransactionType.WITHDRAW ); + updateFinancials(block); } export function handleCollectVaultFees(event: CollectVaultFees): void { @@ -302,7 +302,6 @@ export function handleWithdrawWithFee(event: WithdrawWithFee): void { getOrCreateVault(vaultAddress, event.block); updateVaultTVL(vaultAddress, block); updateUsageMetrics(event.block, event.params.account); - updateFinancials(block); updateVaultSnapshots(vaultAddress, block); Transaction( @@ -313,6 +312,7 @@ export function handleWithdrawWithFee(event: WithdrawWithFee): void { constants.TransactionType.WITHDRAW, feeAmount ); + updateFinancials(block); } export function handleCollectManagementFee(event: CollectManagementFee): void { From 2b37290fcd3f0f1cbeb554e4eb65ff35ed974f07 Mon Sep 17 00:00:00 2001 From: Dhruv Chauhan Date: Thu, 20 Jul 2023 13:51:32 +0530 Subject: [PATCH 2/2] fix lint --- subgraphs/ribbon-finance/src/common/constants.ts | 2 ++ subgraphs/ribbon-finance/src/mappings/vault.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/subgraphs/ribbon-finance/src/common/constants.ts b/subgraphs/ribbon-finance/src/common/constants.ts index b63c6687cb..e904e343c5 100644 --- a/subgraphs/ribbon-finance/src/common/constants.ts +++ b/subgraphs/ribbon-finance/src/common/constants.ts @@ -80,6 +80,8 @@ export const SECONDS_PER_DAY = 60 * 60 * 24; export const MAX_BPS = BigInt.fromI32(10000); export const DEFAULT_DECIMALS = BigInt.fromI32(18); +export const INT_SIX = 6 as i32; + export const BIGINT_ZERO = BigInt.fromI32(0); export const BIGINT_ONE = BigInt.fromI32(1); export const BIGINT_TEN = BigInt.fromI32(10); diff --git a/subgraphs/ribbon-finance/src/mappings/vault.ts b/subgraphs/ribbon-finance/src/mappings/vault.ts index ead4b6e785..2f6c27a0e6 100644 --- a/subgraphs/ribbon-finance/src/mappings/vault.ts +++ b/subgraphs/ribbon-finance/src/mappings/vault.ts @@ -357,7 +357,7 @@ export function handleCollectPerformanceFee( false ); const performanceFeeUSD = utils - .bigIntToBigDecimal(performanceFee, 6) + .bigIntToBigDecimal(performanceFee, constants.INT_SIX) .times(usdcToken.lastPriceUSD!); updateRevenueSnapshots(