From c49d39713a5f8ca2cba7eea551c63ec3a2400130 Mon Sep 17 00:00:00 2001 From: ReflectiveChimp <55021052+ReflectiveChimp@users.noreply.github.com> Date: Fri, 13 Sep 2024 20:52:55 +0100 Subject: [PATCH] fix apr calc --- src/queries/Vaults.graphql | 6 ++---- src/routes/v1/vaults.ts | 9 ++++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/queries/Vaults.graphql b/src/queries/Vaults.graphql index 449eaa9..89ec194 100644 --- a/src/queries/Vaults.graphql +++ b/src/queries/Vaults.graphql @@ -24,10 +24,8 @@ query Vaults($since: BigInt!, $first: Int = 1000, $skip: Int = 0) { orderDirection: desc ) { timestamp - underlyingMainAmount0 - underlyingMainAmount1 - underlyingAltAmount0 - underlyingAltAmount1 + underlyingAmount0 + underlyingAmount1 collectedAmount0 collectedAmount1 token0ToNativePrice diff --git a/src/routes/v1/vaults.ts b/src/routes/v1/vaults.ts index 47afc28..79c2a3b 100644 --- a/src/routes/v1/vaults.ts +++ b/src/routes/v1/vaults.ts @@ -127,13 +127,12 @@ const getVaultApy = (vault: VaultsQuery['clms'][0], periodSeconds: number, now: ) ), collectTimestamp: fromUnixTime(fee.timestamp), - totalValueLocked: interpretAsDecimal(fee.underlyingMainAmount0, token0.decimals) - .plus(interpretAsDecimal(fee.underlyingAltAmount0, token0.decimals)) + totalValueLocked: interpretAsDecimal(fee.underlyingAmount0, token0.decimals) .times(interpretAsDecimal(fee.token0ToNativePrice, 18)) .plus( - interpretAsDecimal(fee.underlyingMainAmount1, token1.decimals) - .plus(interpretAsDecimal(fee.underlyingAltAmount1, token1.decimals)) - .times(interpretAsDecimal(fee.token1ToNativePrice, 18)) + interpretAsDecimal(fee.underlyingAmount1, token1.decimals).times( + interpretAsDecimal(fee.token1ToNativePrice, 18) + ) ), })) );