From 28982af95715ada9200139b61d8dab435155e9b2 Mon Sep 17 00:00:00 2001 From: MirthFutures Date: Fri, 27 Dec 2024 08:48:11 -0500 Subject: [PATCH] Add Equalizer on Sonic --- package.json | 1 + .../address-book/sonic/platforms/equalizer.ts | 4 + .../src/address-book/sonic/platforms/index.ts | 2 +- .../src/address-book/sonic/tokens/tokens.ts | 47 ++++++++++- scripts/add-solidly.ts | 15 ++-- src/api/stats/getAmmPrices.ts | 3 + src/api/stats/getApys.js | 2 + src/api/stats/getNonAmmPrices.ts | 2 + src/api/stats/sonic/getEqualizerApys.js | 39 +++++++++ .../stats/sonic/getEqualizerStablePrices.js | 11 +++ src/api/stats/sonic/index.js | 8 +- src/data/sonic/equalizerLpPools.json | 82 +++++++++++++++++++ src/data/sonic/equalizerStableLpPools.json | 1 + src/utils/fetchAmmPrices.js | 1 + 14 files changed, 206 insertions(+), 12 deletions(-) create mode 100644 packages/address-book/src/address-book/sonic/platforms/equalizer.ts create mode 100644 src/api/stats/sonic/getEqualizerApys.js create mode 100644 src/api/stats/sonic/getEqualizerStablePrices.js create mode 100644 src/data/sonic/equalizerLpPools.json create mode 100644 src/data/sonic/equalizerStableLpPools.json diff --git a/package.json b/package.json index 6209ddf54..44676f301 100644 --- a/package.json +++ b/package.json @@ -77,6 +77,7 @@ "zksync:velocore:add": "ts-node scripts/add-solidly.ts --network zksync --project velocore --newFee true --lp", "zksync:vesync:add": "ts-node scripts/add-solidly.ts --network zksync --project vesync --newFee true --lp", "zksync:dracula:add": "ts-node scripts/add-solidly.ts --network zksync --project dracula --newFee true --lp", + "sonic:equalizer:add": "ts-node scripts/add-solidly.ts --network sonic --project sonicEqualizer --newFee true --lp", "eols": "ts-node scripts/findEolPools.js" }, "dependencies": { diff --git a/packages/address-book/src/address-book/sonic/platforms/equalizer.ts b/packages/address-book/src/address-book/sonic/platforms/equalizer.ts new file mode 100644 index 000000000..7a1e424ca --- /dev/null +++ b/packages/address-book/src/address-book/sonic/platforms/equalizer.ts @@ -0,0 +1,4 @@ +export const equalizer = { + router: '0x571b196a894BaCd9C922C6b5Fefe2c955CC0d431', + voter: '0x17fa9dA6e01aD59513707F92033a6eb03CcB10B4', +}; diff --git a/packages/address-book/src/address-book/sonic/platforms/index.ts b/packages/address-book/src/address-book/sonic/platforms/index.ts index fdce11a4a..165f41a71 100644 --- a/packages/address-book/src/address-book/sonic/platforms/index.ts +++ b/packages/address-book/src/address-book/sonic/platforms/index.ts @@ -1,2 +1,2 @@ - +export * from './equalizer.js'; export * from './beefyfinance.js'; diff --git a/packages/address-book/src/address-book/sonic/tokens/tokens.ts b/packages/address-book/src/address-book/sonic/tokens/tokens.ts index d72c7ec32..74825e04c 100644 --- a/packages/address-book/src/address-book/sonic/tokens/tokens.ts +++ b/packages/address-book/src/address-book/sonic/tokens/tokens.ts @@ -1,4 +1,3 @@ - import type { Token } from '../../../types/token.js'; const S = { @@ -7,9 +6,10 @@ const S = { symbol: 'wS', oracleId: 'wS', decimals: 18, - chainId: 146, + chainId: 146, website: 'https://www.soniclabs.com/', - description: 'Wrapped S, (S) Sonic is an EVM layer-1 platform that offers developers attractive incentives and powerful infrastructure.', + description: + 'Wrapped S, (S) Sonic is an EVM layer-1 platform that offers developers attractive incentives and powerful infrastructure.', bridge: 'canonical', logoURI: '', documentation: 'https://www.soniclabs.com/developer-resources', @@ -19,4 +19,45 @@ export const tokens = { S, WS: S, WNATIVE: S, + EQUAL: { + name: 'Equalizer on Sonic', + symbol: 'EQUAL', + oracleId: 'EQUAL', + address: '0xddF26B42C1d903De8962d3F79a74a501420d5F19', + chainId: 146, + decimals: 18, + logoURI: '', + website: 'https://sonic.equalizer.exchange/', + description: + 'Equalizer Exchange is the fastest liquidity hub providing optimized trading and earning opportunities.', + documentation: '', + bridge: 'native', + }, + USDCe: { + name: 'Bridged USDC (Sonic Labs)', + symbol: 'sUSDC.e', + oracleId: 'sUSDC.e', + address: '0x29219dd400f2Bf60E5a23d13Be72B486D4038894', + chainId: 146, + decimals: 6, + logoURI: '', + website: 'https://www.centre.io/', + description: + 'USDC is a fully collateralized US dollar stablecoin. USDC is issued by regulated financial institutions, backed by fully reserved assets, redeemable on a 1:1 basis for US dollars.', + documentation: '', + bridge: 'sonic-canonical', + }, + WETH: { + name: 'Wrapped Ether on Sonic', + symbol: 'WETH', + oracleId: 'WETH', + address: '0x50c42dEAcD8Fc9773493ED674b675bE577f2634b', + chainId: 146, + decimals: 18, + logoURI: '', + website: 'https://weth.io/', + description: 'Ether or ETH is the native currency built on the Ethereum blockchain.', + bridge: 'sonic-canonical', + documentation: 'https://ethereum.org/en/developers/docs/', + }, } as const satisfies Record; diff --git a/scripts/add-solidly.ts b/scripts/add-solidly.ts index 4b63b3df6..56a2145be 100644 --- a/scripts/add-solidly.ts +++ b/scripts/add-solidly.ts @@ -51,6 +51,9 @@ const { scroll: { platforms: { nuri, tokan }, }, + sonic: { + platforms: { equalizer: sonicEqualizer }, + }, } = addressBook; const projects = { @@ -112,12 +115,6 @@ const projects = { volatileFile: '../src/data/ethereum/solidlyLpPools.json', voter: solidly.voter, }, - solidlizard: { - prefix: 'solidlizard', - stableFile: '../src/data/arbitrum/solidlizardStableLpPools.json', - volatileFile: '../src/data/arbitrum/solidlizardLpPools.json', - voter: solidlizard.voter, - }, cvm: { prefix: 'cvm', stableFile: '../src/data/canto/cvmStableLpPools.json', @@ -190,6 +187,12 @@ const projects = { volatileFile: '../src/data/scroll/tokanVolatilePools.json', voter: tokan.voter, }, + sonicEqualizer: { + prefix: 'equalizer-sonic', + stableFile: '../src/data/sonic/equalizerStableLpPools.json', + volatileFile: '../src/data/sonic/equalizerLpPools.json', + voter: sonicEqualizer.voter, + }, }; const args = yargs.options({ diff --git a/src/api/stats/getAmmPrices.ts b/src/api/stats/getAmmPrices.ts index c219a91f8..b9b327949 100644 --- a/src/api/stats/getAmmPrices.ts +++ b/src/api/stats/getAmmPrices.ts @@ -88,6 +88,7 @@ import tokanPools from '../../data/scroll/tokanVolatilePools.json'; import pearlPools from '../../data/real/pearlLpPools.json'; import velodromeModePools from '../../data/mode/velodromeModePools.json'; import velodromeLiskPools from '../../data/lisk/velodromeLiskPools.json'; +import equalizerSonicPools from '../../data/sonic/equalizerLpPools.json'; import { addressBookByChainId } from '../../../packages/address-book/src/address-book'; import { sleep } from '../../utils/time'; import { isFiniteNumber } from '../../utils/number'; @@ -97,6 +98,7 @@ import { fetchVenusPrices } from './bsc/venus/getVenusPrices'; import { getLpBasedPrices } from './getLpBasedPrices'; import uniswapLpPools from '../../data/ethereum/uniswapV2LpPools.json'; import { fetchDexScreenerPriceOracles, OraclePriceRequest } from '../../utils/fetchDexScreenerPrices'; +import { eq } from 'lodash'; const INIT_DELAY = 2 * 1000; const REFRESH_INTERVAL = 5 * 60 * 1000; @@ -104,6 +106,7 @@ const REFRESH_INTERVAL = 5 * 60 * 1000; // FIXME: if this list grows too big we might hit the ratelimit on initialization everytime // Implement in case of emergency -> https://github.com/beefyfinance/beefy-api/issues/103 const pools = normalizePoolOracleIds([ + ...equalizerSonicPools, ...velodromeLiskPools, ...velodromeModePools, ...pearlPools, diff --git a/src/api/stats/getApys.js b/src/api/stats/getApys.js index e39d0ecf7..fedb2f272 100644 --- a/src/api/stats/getApys.js +++ b/src/api/stats/getApys.js @@ -29,6 +29,7 @@ const { getSeiApys } = require('./sei'); const { getRootstockApys } = require('./rootstock'); const { getScrollApys } = require('./scroll'); const { getLiskApys } = require('./lisk'); +const { getSonicApys } = require('./sonic'); const { getKey, setKey } = require('../../utils/cache'); const { fetchBoostAprs, BOOST_APR_EXPIRED } = require('./getBoostAprs'); const { serviceEventBus } = require('../../utils/ServiceEventBus'); @@ -87,6 +88,7 @@ const updateApys = async () => { getRootstockApys(), getScrollApys(), getLiskApys(), + getSonicApys(), ]); for (const result of results) { diff --git a/src/api/stats/getNonAmmPrices.ts b/src/api/stats/getNonAmmPrices.ts index 30e59c45f..058484293 100644 --- a/src/api/stats/getNonAmmPrices.ts +++ b/src/api/stats/getNonAmmPrices.ts @@ -65,6 +65,7 @@ import { getAerodromeStablePrices } from './base/getAerodromeStablePrices'; import getGammaArbPrices from './arbitrum/getGammaPrices'; import { getKinetixPrices } from './kava/getKinetixPrices'; import getEqualizerStableBasePrices from './base/getEqualizerStablePrices'; +import getEqualizerStableSonicPrices from './sonic/getEqualizerStablePrices'; import getBalancerGnosisPrices from './gnosis/getBalancerGnosisPrices'; import getCurvePricesCommon from './common/curve/getCurvePricesCommon'; import { getCurveLendPricesCommon } from './common/curve/getCurveLendPricesCommon'; @@ -142,6 +143,7 @@ export async function getNonAmmPrices(tokenPrices: Record): Prom getEthSiloPrices(tokenPrices), getOptimismSiloPrices(tokenPrices), getEqualizerStableBasePrices(tokenPrices), + getEqualizerStableSonicPrices(tokenPrices), getKinetixPrices(tokenPrices), getBasoStablePrices(tokenPrices), getUniswapGammaPrices(tokenPrices), diff --git a/src/api/stats/sonic/getEqualizerApys.js b/src/api/stats/sonic/getEqualizerApys.js new file mode 100644 index 000000000..11c055eb1 --- /dev/null +++ b/src/api/stats/sonic/getEqualizerApys.js @@ -0,0 +1,39 @@ +const { SONIC_CHAIN_ID: chainId } = require('../../../constants'); +const { getSolidlyGaugeApys } = require('../common/getSolidlyGaugeApys'); + +const stablePools = require('../../../data/sonic/equalizerStableLpPools.json'); +const volatilePools = require('../../../data/sonic/equalizerLpPools.json'); + +const pools = [...stablePools, ...volatilePools]; +const getEqualizerApys = async () => { + const gaugeApys = getSolidlyGaugeApys({ + chainId: chainId, + pools: pools, + oracleId: 'EQUAL', + oracle: 'tokens', + decimals: '1e18', + reward: '0xddF26B42C1d903De8962d3F79a74a501420d5F19', + boosted: false, + // log: true, + }); + + let apys = {}; + let apyBreakdowns = {}; + + const results = await Promise.allSettled([gaugeApys]); + for (const result of results) { + if (result.status !== 'fulfilled') { + console.warn('getEqualizerSonicApys error', result.reason); + } else { + apys = { ...apys, ...result.value.apys }; + apyBreakdowns = { ...apyBreakdowns, ...result.value.apyBreakdowns }; + } + } + + return { + apys, + apyBreakdowns, + }; +}; + +module.exports = getEqualizerApys; diff --git a/src/api/stats/sonic/getEqualizerStablePrices.js b/src/api/stats/sonic/getEqualizerStablePrices.js new file mode 100644 index 000000000..95b9cf48c --- /dev/null +++ b/src/api/stats/sonic/getEqualizerStablePrices.js @@ -0,0 +1,11 @@ +const getSolidlyStablePrices = require('../common/getSolidlyStablePrices'); +const pools = require('../../../data/sonic/equalizerStableLpPools.json'); +const { SONIC_CHAIN_ID } = require('../../../constants'); + +const stablePools = [...pools]; + +const getEqualizerStableSonicPrices = async tokenPrices => { + return await getSolidlyStablePrices(SONIC_CHAIN_ID, stablePools, tokenPrices); +}; + +module.exports = getEqualizerStableSonicPrices; diff --git a/src/api/stats/sonic/index.js b/src/api/stats/sonic/index.js index 1df12aa5d..173e6b8e6 100644 --- a/src/api/stats/sonic/index.js +++ b/src/api/stats/sonic/index.js @@ -1,6 +1,10 @@ -const { getBeefyCowSonicApys } = require('./getBeefyCowSonicApys'); +//const { getBeefyCowSonicApys } = require('./getBeefyCowSonicApys'); +const getEqualizerApys = require('./getEqualizerApys'); -const getApys = [getBeefyCowSonicApys]; +const getApys = [ + // getBeefyCowSonicApys, + getEqualizerApys, +]; const getSonicApys = async () => { const start = Date.now(); diff --git a/src/data/sonic/equalizerLpPools.json b/src/data/sonic/equalizerLpPools.json new file mode 100644 index 000000000..81685aeea --- /dev/null +++ b/src/data/sonic/equalizerLpPools.json @@ -0,0 +1,82 @@ +[ + { + "name": "equalizer-sonic-ws-weth", + "address": "0xcD7D89FF7bB263a5C45aD81ddE4Eed5892Ad540C", + "gauge": "0x09548deFD1016cFFd6f74417bE3503b1e6aA6c51", + "decimals": "1e18", + "chainId": 146, + "beefyFee": 0.095, + "lp0": { + "address": "0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38", + "oracle": "tokens", + "oracleId": "wS", + "decimals": "1e18" + }, + "lp1": { + "address": "0x50c42dEAcD8Fc9773493ED674b675bE577f2634b", + "oracle": "tokens", + "oracleId": "WETH", + "decimals": "1e18" + } + }, + { + "name": "equalizer-sonic-ws-usdc.e", + "address": "0xdc85F86d5E3189e0d4a776e6Ae3B3911eC7B0133", + "gauge": "0x9b55Fbd8Cd27B81aCc6adfd42D441858FeDe4326", + "decimals": "1e18", + "chainId": 146, + "beefyFee": 0.095, + "lp0": { + "address": "0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38", + "oracle": "tokens", + "oracleId": "wS", + "decimals": "1e18" + }, + "lp1": { + "address": "0x29219dd400f2Bf60E5a23d13Be72B486D4038894", + "oracle": "tokens", + "oracleId": "sUSDC.e", + "decimals": "1e6" + } + }, + { + "name": "equalizer-sonic-ws-equal", + "address": "0x139f8eCC5fC8Ef11226a83911FEBecC08476cfB1", + "gauge": "0xe73267246Aa678A28D8e7B957135faEc1Db48aEF", + "decimals": "1e18", + "chainId": 146, + "beefyFee": 0.095, + "lp0": { + "address": "0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38", + "oracle": "tokens", + "oracleId": "wS", + "decimals": "1e18" + }, + "lp1": { + "address": "0xddF26B42C1d903De8962d3F79a74a501420d5F19", + "oracle": "tokens", + "oracleId": "EQUAL", + "decimals": "1e18" + } + }, + { + "name": "equalizer-sonic-usdc.e-weth", + "address": "0xbCbC5777537c0D0462fb82BA48Eeb6cb361E853f", + "gauge": "0xf8F2462A8Fa08Df933C0d6bbaf34108Fd7af526E", + "decimals": "1e18", + "chainId": 146, + "beefyFee": 0.095, + "lp0": { + "address": "0x29219dd400f2Bf60E5a23d13Be72B486D4038894", + "oracle": "tokens", + "oracleId": "sUSDC.e", + "decimals": "1e6" + }, + "lp1": { + "address": "0x50c42dEAcD8Fc9773493ED674b675bE577f2634b", + "oracle": "tokens", + "oracleId": "WETH", + "decimals": "1e18" + } + } +] diff --git a/src/data/sonic/equalizerStableLpPools.json b/src/data/sonic/equalizerStableLpPools.json new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/src/data/sonic/equalizerStableLpPools.json @@ -0,0 +1 @@ +[] diff --git a/src/utils/fetchAmmPrices.js b/src/utils/fetchAmmPrices.js index 31aa636f6..041cf0731 100644 --- a/src/utils/fetchAmmPrices.js +++ b/src/utils/fetchAmmPrices.js @@ -37,6 +37,7 @@ const MULTICALLS = { 534352: '0xD985027E547a34d4F7E569B365F24aB87c5a9F73', 111188: '0x3D6B199Ccc223283fd2f5000c3f3585d558aCf39', 1135: '0x679d78307720CCdDFf572cc56E3C35F9861033Bc', + 146: '0xf2068e1FE1A80E7f5Ba80D6ABD6e8618aD4E959E', }; const BATCH_SIZE = 128;