Skip to content

Commit

Permalink
feat: add arbitrum notional vaults
Browse files Browse the repository at this point in the history
  • Loading branch information
Crypto-One-dev committed Sep 19, 2024
1 parent a92390a commit 1dd6c93
Show file tree
Hide file tree
Showing 6 changed files with 256 additions and 9 deletions.
19 changes: 19 additions & 0 deletions data/mainnet/addresses.json
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,7 @@
"CBETH": "0x1DEBd73E752bEaF79865Fd6446b0c970EaE7732f",
"dlcBTC": "0x050C24dBf1eEc17babE5fc585F06116A259CC77A",
"WINR": "0xD77B108d4f6cefaa0Cae9506A934e825BEccA46E",
"NOTE": "0x019bE259BC299F3F653688c7655C87F998Bc7bC1",
"V2": {
"iPoison": {
"Underlying": "0xDA016d31f2B52C73D7c1956E955ae8A507b305bB",
Expand Down Expand Up @@ -1770,6 +1771,24 @@
"NewStrategy": "0x557Ac11511b3F826582Cce1FC63a86773A1AE6ca",
"NewPool": "0x1e13861122B7fc524502E7Bf4fCDAa51c4f69c4F",
"Gauge": "0x02b8e750E68cb648dB2c2ac4BBb47A10A5c12588"
},
"notional_nETH_arbitrum": {
"Underlying": "0x18b0Fc5A233acF1586Da7C199Ca9E3f486305A29",
"NewVault": "0x77BD2F95aAD869C9b6a4B3Ea6EC1201293f4b708",
"NewStrategy": "0xAA9CF6C538fA5ed5b1F32E68Dd74168A103bB8C9",
"NewPool": "0x82511db8EbE47a14DF68412529A8DF26AddD2179"
},
"notional_nUSDC_arbitrum": {
"Underlying": "0x0F13fb925eDC3E1FE947209010d9c0E072986ADc",
"NewVault": "0xe5CCea9A64a096365F05Dffb1CBbe04B8Fd7c710",
"NewStrategy": "0xE2012161227654831fB510741a717AB9b6715149",
"NewPool": "0x7c18F8dDE08e1e388e7B8693ce8Bb0a0a7347127"
},
"notional_nUSDT_arbitrum": {
"Underlying": "0x9c0Fbb8caDE7B178b135fD2F1da125a37B27f442",
"NewVault": "0x9eADb45AC9F467063A4DCa28d21B3142C24697ee",
"NewStrategy": "0xbe7F135f9bBe8355596f64452E8CA6bE03dB6434",
"NewPool": "0xd7Af3498B861BC070FA3bd694aD0a823558F10b8"
}
}
},
Expand Down
93 changes: 93 additions & 0 deletions data/mainnet/pools.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,99 @@ const addresses = require('./addresses.json')
const strat15PercentFactor = '0.85'

module.exports = [
{
chain: CHAIN_IDS.ARBITRUM_ONE,
id: 'notional_nETH_arbitrum',
type: POOL_TYPES.INCENTIVE,
tradingApyFunction: {
type: TRADING_APY_TYPES.NOTIONAL_API,
params: [addresses.ARBITRUM_ONE.V2.notional_nETH_arbitrum.Underlying, CHAIN_IDS.ARBITRUM_ONE],
},
contractAddress: addresses.ARBITRUM_ONE.V2.notional_nETH_arbitrum.NewPool,
collateralAddress: addresses.ARBITRUM_ONE.V2.notional_nETH_arbitrum.NewVault,
rewardAPY: [],
rewardTokens: [addresses.ARBITRUM_ONE.iFARM],
rewardTokenSymbols: ['iFARM'],
liquidityUrl: 'https://notional.finance/liquidity-variable/arbitrum/ETH',
stakeAndDepositHelpMessage: `
<div class="help-message">
<p> The vault supplies
<a href="https://arbiscan.io/token/${addresses.ARBITRUM_ONE.V2.notional_nETH_arbitrum.Underlying}" target="_blank" rel="noopener noreferrer"> nETH </a>in a Notional farm, earning
<a href="https://arbiscan.io/token/${addresses.ARBITRUM_ONE.NOTE}" target="_blank" rel="noopener noreferrer">NOTE</a>.
At every harvest, the earned rewards are converted into more
<a href="https://arbiscan.io/token/${addresses.ARBITRUM_ONE.V2.notional_nETH_arbitrum.Underlying}" target="_blank" rel="noopener noreferrer"> nETH</a>.
</p>
<p> Get
<a href="https://arbiscan.io/token/${addresses.ARBITRUM_ONE.V2.notional_nETH_arbitrum.Underlying}" target="_blank" rel="noopener noreferrer"> nETH </a>by supplying liquidity on
<a href="https://notional.finance/liquidity-variable/arbitrum/ETH" target="_blank" rel="noopener noreferrer">NotionalV3</a>.
</p>
</div>
`,
},
{
chain: CHAIN_IDS.ARBITRUM_ONE,
id: 'notional_nUSDC_arbitrum',
type: POOL_TYPES.INCENTIVE,
tradingApyFunction: {
type: TRADING_APY_TYPES.NOTIONAL_API,
params: [
addresses.ARBITRUM_ONE.V2.notional_nUSDC_arbitrum.Underlying,
CHAIN_IDS.ARBITRUM_ONE,
],
},
contractAddress: addresses.ARBITRUM_ONE.V2.notional_nUSDC_arbitrum.NewPool,
collateralAddress: addresses.ARBITRUM_ONE.V2.notional_nUSDC_arbitrum.NewVault,
rewardAPY: [],
rewardTokens: [addresses.ARBITRUM_ONE.iFARM],
rewardTokenSymbols: ['iFARM'],
liquidityUrl: 'https://notional.finance/liquidity-variable/arbitrum/USDC',
stakeAndDepositHelpMessage: `
<div class="help-message">
<p> The vault supplies
<a href="https://arbiscan.io/token/${addresses.ARBITRUM_ONE.V2.notional_nUSDC_arbitrum.Underlying}" target="_blank" rel="noopener noreferrer"> nUSDC </a>in a Notional farm, earning
<a href="https://arbiscan.io/token/${addresses.ARBITRUM_ONE.NOTE}" target="_blank" rel="noopener noreferrer">NOTE</a>.
At every harvest, the earned rewards are converted into more
<a href="https://arbiscan.io/token/${addresses.ARBITRUM_ONE.V2.notional_nUSDC_arbitrum.Underlying}" target="_blank" rel="noopener noreferrer"> nUSDC</a>.
</p>
<p> Get
<a href="https://arbiscan.io/token/${addresses.ARBITRUM_ONE.V2.notional_nUSDC_arbitrum.Underlying}" target="_blank" rel="noopener noreferrer"> nUSDC </a>by supplying liquidity on
<a href="https://notional.finance/liquidity-variable/arbitrum/USDC" target="_blank" rel="noopener noreferrer">NotionalV3</a>.
</p>
</div>
`,
},
{
chain: CHAIN_IDS.ARBITRUM_ONE,
id: 'notional_nUSDT_arbitrum',
type: POOL_TYPES.INCENTIVE,
tradingApyFunction: {
type: TRADING_APY_TYPES.NOTIONAL_API,
params: [
addresses.ARBITRUM_ONE.V2.notional_nUSDT_arbitrum.Underlying,
CHAIN_IDS.ARBITRUM_ONE,
],
},
contractAddress: addresses.ARBITRUM_ONE.V2.notional_nUSDT_arbitrum.NewPool,
collateralAddress: addresses.ARBITRUM_ONE.V2.notional_nUSDT_arbitrum.NewVault,
rewardAPY: [],
rewardTokens: [addresses.ARBITRUM_ONE.iFARM],
rewardTokenSymbols: ['iFARM'],
liquidityUrl: 'https://notional.finance/liquidity-variable/arbitrum/USDT',
stakeAndDepositHelpMessage: `
<div class="help-message">
<p> The vault supplies
<a href="https://arbiscan.io/token/${addresses.ARBITRUM_ONE.V2.notional_nUSDT_arbitrum.Underlying}" target="_blank" rel="noopener noreferrer"> nUSDT </a>in a Notional farm, earning
<a href="https://arbiscan.io/token/${addresses.ARBITRUM_ONE.NOTE}" target="_blank" rel="noopener noreferrer">NOTE</a>.
At every harvest, the earned rewards are converted into more
<a href="https://arbiscan.io/token/${addresses.ARBITRUM_ONE.V2.notional_nUSDT_arbitrum.Underlying}" target="_blank" rel="noopener noreferrer"> nUSDT</a>.
</p>
<p> Get
<a href="https://arbiscan.io/token/${addresses.ARBITRUM_ONE.V2.notional_nUSDT_arbitrum.Underlying}" target="_blank" rel="noopener noreferrer"> nUSDT </a>by supplying liquidity on
<a href="https://notional.finance/liquidity-variable/arbitrum/USDT" target="_blank" rel="noopener noreferrer">NotionalV3</a>.
</p>
</div>
`,
},
{
chain: CHAIN_IDS.BASE,
id: 'aerodrome_cbBTC_ETH',
Expand Down
116 changes: 116 additions & 0 deletions data/mainnet/tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,122 @@ module.exports = {
],
cmcRewardTokenSymbols: ['FARM', 'WETH'],
},
NOTE_arbitrum: {
chain: CHAIN_IDS.ARBITRUM_ONE,
logoUrl: [''],
tokenAddress: addresses.ARBITRUM_ONE.NOTE,
decimals: '8',
vaultAddress: null,
priceFunction: {
type: GET_PRICE_TYPES.COINGECKO_ID,
params: ['notional-finance'],
},
},
notional_nETH_arbitrum: {
chain: CHAIN_IDS.ARBITRUM_ONE,
logoUrl: ['./icons/eth.svg'],
tokenNames: ['nETH'],
apyIconUrls: ['./icons/note.svg'],
apyTokenSymbols: ['NOTE'],
platform: ['NotionalV3'],
tags: ['Advanced'],
tokenAddress: addresses.ARBITRUM_ONE.V2.notional_nETH_arbitrum.Underlying,
decimals: '8',
vaultAddress: addresses.ARBITRUM_ONE.V2.notional_nETH_arbitrum.NewVault,
strategyAddress: addresses.ARBITRUM_ONE.V2.notional_nETH_arbitrum.NewStrategy,
priceFunction: {
type: GET_PRICE_TYPES.NOTIONAL,
params: [
CHAIN_IDS.ARBITRUM_ONE,
1,
addresses.ARBITRUM_ONE.V2.notional_nETH_arbitrum.Underlying,
addresses.ARBITRUM_ONE.WETH,
],
},
estimateApyFunctions: [
{
type: ESTIMATED_APY_TYPES.NOTIONAL,
params: [
CHAIN_IDS.ARBITRUM_ONE,
1,
addresses.ARBITRUM_ONE.NOTE,
addresses.ARBITRUM_ONE.V2.notional_nETH_arbitrum.Underlying,
addresses.ARBITRUM_ONE.WETH,
profitSharingCut10Percent,
],
},
],
},
notional_nUSDC_arbitrum: {
chain: CHAIN_IDS.ARBITRUM_ONE,
logoUrl: ['./icons/usdc.svg'],
tokenNames: ['nUSDC'],
apyIconUrls: ['./icons/note.svg'],
apyTokenSymbols: ['NOTE'],
platform: ['NotionalV3'],
tags: ['Advanced'],
tokenAddress: addresses.ARBITRUM_ONE.V2.notional_nUSDC_arbitrum.Underlying,
decimals: '8',
vaultAddress: addresses.ARBITRUM_ONE.V2.notional_nUSDC_arbitrum.NewVault,
strategyAddress: addresses.ARBITRUM_ONE.V2.notional_nUSDC_arbitrum.NewStrategy,
priceFunction: {
type: GET_PRICE_TYPES.NOTIONAL,
params: [
CHAIN_IDS.ARBITRUM_ONE,
1,
addresses.ARBITRUM_ONE.V2.notional_nUSDC_arbitrum.Underlying,
addresses.ARBITRUM_ONE.WETH,
],
},
estimateApyFunctions: [
{
type: ESTIMATED_APY_TYPES.NOTIONAL,
params: [
CHAIN_IDS.ARBITRUM_ONE,
1,
addresses.ARBITRUM_ONE.NOTE,
addresses.ARBITRUM_ONE.V2.notional_nUSDC_arbitrum.Underlying,
addresses.ARBITRUM_ONE.WETH,
profitSharingCut10Percent,
],
},
],
},
notional_nUSDT_arbitrum: {
chain: CHAIN_IDS.ARBITRUM_ONE,
logoUrl: ['./icons/usdt.svg'],
tokenNames: ['nUSDT'],
apyIconUrls: ['./icons/note.svg'],
apyTokenSymbols: ['NOTE'],
platform: ['NotionalV3'],
tags: ['Advanced'],
tokenAddress: addresses.ARBITRUM_ONE.V2.notional_nUSDT_arbitrum.Underlying,
decimals: '8',
vaultAddress: addresses.ARBITRUM_ONE.V2.notional_nUSDT_arbitrum.NewVault,
strategyAddress: addresses.ARBITRUM_ONE.V2.notional_nUSDT_arbitrum.NewStrategy,
priceFunction: {
type: GET_PRICE_TYPES.NOTIONAL,
params: [
CHAIN_IDS.ARBITRUM_ONE,
1,
addresses.ARBITRUM_ONE.V2.notional_nUSDT_arbitrum.Underlying,
addresses.ARBITRUM_ONE.WETH,
],
},
estimateApyFunctions: [
{
type: ESTIMATED_APY_TYPES.NOTIONAL,
params: [
CHAIN_IDS.ARBITRUM_ONE,
1,
addresses.ARBITRUM_ONE.NOTE,
addresses.ARBITRUM_ONE.V2.notional_nUSDT_arbitrum.Underlying,
addresses.ARBITRUM_ONE.WETH,
profitSharingCut10Percent,
],
},
],
},
aerodrome_cbBTC_ETH: {
chain: CHAIN_IDS.BASE,
apyIconUrls: ['./icons/aero.svg'],
Expand Down
12 changes: 9 additions & 3 deletions src/prices/implementations/notional.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
const BigNumber = require('bignumber.js')
const { web3 } = require('../../lib/web3')
const { getWeb3 } = require('../../lib/web3')
const { abi: notionalContractAbi } = require('../../lib/web3/contracts/notional/contract.json')
const {
getNTokenPresentValueUnderlyingDenominated,
} = require('../../lib/web3/contracts/notional/methods')
const { getTokenPrice } = require('../index')
const { token: tokenContractData } = require('../../lib/web3/contracts')
const { CHAIN_IDS } = require('../../../data/constants')

const notionalProxy = '0x6e7058c91F85E0F6db4fc9da2CA41241f5e4263f'
const notionalProxy_mainnet = '0x6e7058c91F85E0F6db4fc9da2CA41241f5e4263f'
const notionalProxy_arbitrum = '0x1344A36A1B56144C3Bc62E7757377D288fDE0369'

const getPrice = async (currencyId, nToken, underlyingToken) => {
const getPrice = async (chainId = CHAIN_IDS.ETH_MAINNET, currencyId, nToken, underlyingToken) => {
let notionalProxy
const web3 = getWeb3(chainId)
if (chainId == CHAIN_IDS.ETH_MAINNET) notionalProxy = notionalProxy_mainnet
else notionalProxy = notionalProxy_arbitrum
const underlyingPrice = await getTokenPrice(underlyingToken)
const {
methods: { getTotalSupply },
Expand Down
20 changes: 16 additions & 4 deletions src/vaults/apys/implementations/notional.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const BigNumber = require('bignumber.js')
const { web3 } = require('../../../lib/web3')
const { getWeb3 } = require('../../../lib/web3')
const { abi: notionalAbi } = require('../../../lib/web3/contracts/notional/contract.json')
const {
abi: notionalRewardAbi,
Expand All @@ -15,12 +15,24 @@ const {
} = require('../../../lib/web3/contracts/notional-reward/methods')
const { getTokenPrice } = require('../../../prices')
const getNTokenPrice = require('../../../prices/implementations/notional.js').getPrice
const { CHAIN_IDS } = require('../../../../data/constants')
const notionalProxy_mainnet = '0x6e7058c91F85E0F6db4fc9da2CA41241f5e4263f'
const notionalProxy_arbitrum = '0x1344A36A1B56144C3Bc62E7757377D288fDE0369'

const notionalProxy = '0x6e7058c91F85E0F6db4fc9da2CA41241f5e4263f'
const getApy = async (
chainId = CHAIN_IDS.ETH_MAINNET,
currencyId,
note,
nToken,
underlyingToken,
reduction,
) => {
let notionalProxy =
chainId == CHAIN_IDS.ETH_MAINNET ? notionalProxy_mainnet : notionalProxy_arbitrum
const web3 = getWeb3(chainId)

const getApy = async (currencyId, note, nToken, underlyingToken, reduction) => {
const notePrice = await getTokenPrice(note)
const nTokenPrice = await getNTokenPrice(currencyId, nToken, underlyingToken)
const nTokenPrice = await getNTokenPrice(chainId, currencyId, nToken, underlyingToken)

const notionalInstance = new web3.eth.Contract(notionalAbi, notionalProxy)
const { totalSupply, incentiveAnnualEmissionRate } = await getNTokenAccount(
Expand Down
5 changes: 3 additions & 2 deletions src/vaults/trading-apys/implementations/notional-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ const { CHAIN_IDS } = require('../../../../data/constants')
const getTradingApy = async (poolAddress, chainId = CHAIN_IDS.ETH_MAINNET) => {
let response, apy
let chain = chainId === CHAIN_IDS.ETH_MAINNET ? 'mainnet' : 'arbitrum'
let dataValues = chainId === CHAIN_IDS.ETH_MAINNET ? `data.values[7][1]` : `data.values[14][1]`

try {
response = await axios.get(`${NOTIONAL_ENDPOINT}/${chain}/views/analytics`)
const interest = new BigNumber(
get(
get(response, `data.values[7][1]`, []).find(
get(response, dataValues, []).find(
oracle =>
oracle.quote == poolAddress.toLowerCase() &&
oracle.oracleType == 'nTokenBlendedInterestRate',
Expand All @@ -23,7 +24,7 @@ const getTradingApy = async (poolAddress, chainId = CHAIN_IDS.ETH_MAINNET) => {
)
const fee = new BigNumber(
get(
get(response, `data.values[7][1]`, []).find(
get(response, dataValues, []).find(
oracle =>
oracle.quote == poolAddress.toLowerCase() && oracle.oracleType == 'nTokenFeeRate',
),
Expand Down

0 comments on commit 1dd6c93

Please sign in to comment.