Skip to content

Commit

Permalink
Add Equalizer on Sonic
Browse files Browse the repository at this point in the history
  • Loading branch information
MirthFutures committed Dec 27, 2024
1 parent 35b7f65 commit 28982af
Show file tree
Hide file tree
Showing 14 changed files with 206 additions and 12 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const equalizer = {
router: '0x571b196a894BaCd9C922C6b5Fefe2c955CC0d431',
voter: '0x17fa9dA6e01aD59513707F92033a6eb03CcB10B4',
};
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

export * from './equalizer.js';
export * from './beefyfinance.js';
47 changes: 44 additions & 3 deletions packages/address-book/src/address-book/sonic/tokens/tokens.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import type { Token } from '../../../types/token.js';

const S = {
Expand All @@ -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',
Expand All @@ -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<string, Token>;
15 changes: 9 additions & 6 deletions scripts/add-solidly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ const {
scroll: {
platforms: { nuri, tokan },
},
sonic: {
platforms: { equalizer: sonicEqualizer },
},
} = addressBook;

const projects = {
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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({
Expand Down
3 changes: 3 additions & 0 deletions src/api/stats/getAmmPrices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -97,13 +98,15 @@ 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;

// 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,
Expand Down
2 changes: 2 additions & 0 deletions src/api/stats/getApys.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -87,6 +88,7 @@ const updateApys = async () => {
getRootstockApys(),
getScrollApys(),
getLiskApys(),
getSonicApys(),
]);

for (const result of results) {
Expand Down
2 changes: 2 additions & 0 deletions src/api/stats/getNonAmmPrices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -142,6 +143,7 @@ export async function getNonAmmPrices(tokenPrices: Record<string, number>): Prom
getEthSiloPrices(tokenPrices),
getOptimismSiloPrices(tokenPrices),
getEqualizerStableBasePrices(tokenPrices),
getEqualizerStableSonicPrices(tokenPrices),
getKinetixPrices(tokenPrices),
getBasoStablePrices(tokenPrices),
getUniswapGammaPrices(tokenPrices),
Expand Down
39 changes: 39 additions & 0 deletions src/api/stats/sonic/getEqualizerApys.js
Original file line number Diff line number Diff line change
@@ -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;
11 changes: 11 additions & 0 deletions src/api/stats/sonic/getEqualizerStablePrices.js
Original file line number Diff line number Diff line change
@@ -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;
8 changes: 6 additions & 2 deletions src/api/stats/sonic/index.js
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
82 changes: 82 additions & 0 deletions src/data/sonic/equalizerLpPools.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
]
1 change: 1 addition & 0 deletions src/data/sonic/equalizerStableLpPools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions src/utils/fetchAmmPrices.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const MULTICALLS = {
534352: '0xD985027E547a34d4F7E569B365F24aB87c5a9F73',
111188: '0x3D6B199Ccc223283fd2f5000c3f3585d558aCf39',
1135: '0x679d78307720CCdDFf572cc56E3C35F9861033Bc',
146: '0xf2068e1FE1A80E7f5Ba80D6ABD6e8618aD4E959E',
};

const BATCH_SIZE = 128;
Expand Down

0 comments on commit 28982af

Please sign in to comment.