From 2f61ab10fc0429c3ba7f0a5b3d23768121e90c41 Mon Sep 17 00:00:00 2001 From: William Date: Wed, 18 Sep 2024 00:11:18 -0400 Subject: [PATCH] fix: update notional api --- data/mainnet/pools.js | 8 ++++---- src/lib/constants.js | 2 +- src/vaults/trading-apys/implementations/notional-api.js | 8 +++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/data/mainnet/pools.js b/data/mainnet/pools.js index 3ad582d3..02b5ba53 100644 --- a/data/mainnet/pools.js +++ b/data/mainnet/pools.js @@ -733,7 +733,7 @@ module.exports = [ type: POOL_TYPES.INCENTIVE, tradingApyFunction: { type: TRADING_APY_TYPES.NOTIONAL_API, - params: [addresses.V2.notional_nETH.Underlying], + params: [addresses.V2.notional_nETH.Underlying, CHAIN_IDS.ETH_MAINNET], }, contractAddress: addresses.V2.notional_nETH.NewPool, collateralAddress: addresses.V2.notional_nETH.NewVault, @@ -762,7 +762,7 @@ module.exports = [ type: POOL_TYPES.INCENTIVE, tradingApyFunction: { type: TRADING_APY_TYPES.NOTIONAL_API, - params: [addresses.V2.notional_nGHO.Underlying], + params: [addresses.V2.notional_nGHO.Underlying, CHAIN_IDS.ETH_MAINNET], }, contractAddress: addresses.V2.notional_nGHO.NewPool, collateralAddress: addresses.V2.notional_nGHO.NewVault, @@ -792,7 +792,7 @@ module.exports = [ type: POOL_TYPES.INCENTIVE, tradingApyFunction: { type: TRADING_APY_TYPES.NOTIONAL_API, - params: [addresses.V2.notional_nUSDC.Underlying], + params: [addresses.V2.notional_nUSDC.Underlying, CHAIN_IDS.ETH_MAINNET], }, contractAddress: addresses.V2.notional_nUSDC.NewPool, collateralAddress: addresses.V2.notional_nUSDC.NewVault, @@ -821,7 +821,7 @@ module.exports = [ type: POOL_TYPES.INCENTIVE, tradingApyFunction: { type: TRADING_APY_TYPES.NOTIONAL_API, - params: [addresses.V2.notional_nUSDT.Underlying], + params: [addresses.V2.notional_nUSDT.Underlying, CHAIN_IDS.ETH_MAINNET], }, contractAddress: addresses.V2.notional_nUSDT.NewPool, collateralAddress: addresses.V2.notional_nUSDT.NewVault, diff --git a/src/lib/constants.js b/src/lib/constants.js index 37a1c4bf..0ae1c672 100644 --- a/src/lib/constants.js +++ b/src/lib/constants.js @@ -222,7 +222,7 @@ const CURVE_API_URLS = { const GAMMA_ENDPOINT = 'https://wire2.gamma.xyz/' const MERKL_ENDPOINT = 'https://api.angle.money/v2/merkl' const PENDLE_ENDPOINT = 'https://api-v2.pendle.finance/core/v2/' -const NOTIONAL_ENDPOINT = 'https://data-dev.notional.finance/mainnet/views/analytics' +const NOTIONAL_ENDPOINT = 'https://registry.notional.finance' const CURRENCY_API_URL = `https://api.freecurrencyapi.com/v1/latest?apikey=${process.env.CURRENCY_API_KEY}` const HISTORICAL_CURRENCY_API_URL = `https://api.freecurrencyapi.com/v1/historical?apikey=${process.env.CURRENCY_API_KEY}` diff --git a/src/vaults/trading-apys/implementations/notional-api.js b/src/vaults/trading-apys/implementations/notional-api.js index 1d71e8da..38e45a8d 100644 --- a/src/vaults/trading-apys/implementations/notional-api.js +++ b/src/vaults/trading-apys/implementations/notional-api.js @@ -2,12 +2,14 @@ const BigNumber = require('bignumber.js') const axios = require('axios') const { get } = require('lodash') const { NOTIONAL_ENDPOINT } = require('../../../lib/constants') +const { CHAIN_IDS } = require('../../../../data/constants') -const getTradingApy = async poolAddress => { +const getTradingApy = async (poolAddress, chainId = CHAIN_IDS.ETH_MAINNET) => { let response, apy + let chain = chainId === CHAIN_IDS.ETH_MAINNET ? 'mainnet' : 'arbitrum' try { - response = await axios.get(NOTIONAL_ENDPOINT) + response = await axios.get(`${NOTIONAL_ENDPOINT}/${chain}/views/analytics`) const interest = new BigNumber( get( get(response, `data.values[7][1]`, []).find( @@ -31,7 +33,7 @@ const getTradingApy = async poolAddress => { ) apy = interest.div(1e9).plus(fee.div(1e9)).times(100) } catch (err) { - console.error('Gamma API error: ', err) + console.error('Notional API error: ', err) apy = 0 }