Skip to content

Commit

Permalink
Adding new tokens;
Browse files Browse the repository at this point in the history
Adding 2 new apr handlers, bloom and maker;
  • Loading branch information
Luiz Gustavo Abou Hatem De Liz committed Sep 8, 2023
1 parent 94f9fe3 commit 5cf2e3f
Show file tree
Hide file tree
Showing 11 changed files with 219 additions and 1 deletion.
22 changes: 22 additions & 0 deletions modules/network/apr-config-types.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
export interface IbAprConfig {
aave?: AaveAprConfig;
ankr?: AnkrAprConfig;
bloom?: BloomAprConfig;
beefy?: BeefyAprConfig;
euler?: EulerAprConfig;
gearbox?: GearBoxAprConfig;
idle?: IdleAprConfig;
maker?: MakerAprConfig;
ovix?: OvixAprConfig;
reaper?: ReaperAprConfig;
tessera?: TesseraAprConfig;
Expand Down Expand Up @@ -55,6 +57,16 @@ export interface BeefyAprConfig {
};
}

export interface BloomAprConfig {
tokens: {
[tokenName: string]: {
address: string;
feedAddress: string;
isIbYield?: boolean;
};
};
}

export interface EulerAprConfig {
subgraphUrl: string;
tokens: {
Expand Down Expand Up @@ -87,6 +99,16 @@ export interface IdleAprConfig {
};
}

export interface MakerAprConfig {
tokens: {
[tokenName: string]: {
address: string;
potAddress: string;
isIbYield?: boolean;
};
};
}

export interface OvixAprConfig {
tokens: {
[tokenName: string]: {
Expand Down
34 changes: 34 additions & 0 deletions modules/network/arbitrum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,47 @@ const arbitrumNetworkData: NetworkData = {
},
},
},
reaper: {
onchainSource: {
averageAPRAcrossLastNHarvests: 5,
tokens: {
rfGrainDAI: {
address: '0x12f256109e744081f633a827be80e06d97ff7447',
},
rfGrainUSDT: {
address: '0x0179bac7493a92ac812730a4c64a0b41b7ea0ecf',
},
rfGrainUSDC: {
address: '0xaeacf641a0342330ec681b57c0a6af0b71d5cbff',
},
},
},
},
defaultHandlers: {
wstETH: {
tokenAddress: '0x5979d7b546e38e414f7e9822514be443a4800529',
sourceUrl: 'https://eth-api.lido.fi/v1/protocol/steth/apr/sma',
path: 'data.smaApr',
isIbYield: true,
},
rETH: {
tokenAddress: '0xec70dcb4a1efa46b8f2d97c310c9c4790ba5ffa8',
sourceUrl: 'https://rocketpool.net/api/mainnet/payload',
path: 'rethAPR',
isIbYield: true,
},
cbETH: {
tokenAddress: '0x1debd73e752beaf79865fd6446b0c970eae7732f',
sourceUrl: 'https://api.exchange.coinbase.com/wrapped-assets/CBETH/',
path: 'apy',
scale: 1,
},
sfrxETH: {
tokenAddress: '0x95ab45875cffdba1e5f451b950bc2e42c0053f39',
sourceUrl: 'https://api.frax.finance/v2/frxeth/summary/latest',
path: 'sfrxethApr',
isIbYield: true,
},
},
},
beefy: {
Expand Down
19 changes: 19 additions & 0 deletions modules/network/avalanche.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,25 @@ const avalancheNetworkData: NetworkData = {
},
},
},
defaultHandlers: {
sAVAX: {
tokenAddress: '0x2b2c81e08f1af8835a78bb2a90ae924ace0ea4be',
sourceUrl: 'https://api.benqi.fi/liquidstaking/apr',
path: 'apr',
scale: 1,
},
yyAVAX: {
tokenAddress: '0xf7d9281e8e363584973f946201b82ba72c965d27',
sourceUrl: 'https://staging-api.yieldyak.com/yyavax',
path: 'yyAVAX.apr',
},
ggAVAX: {
tokenAddress: '0xa25eaf2906fa1a3a13edac9b9657108af7b703e3',
sourceUrl: 'https://ceres.gogopool.com',
path: 'ggAVAXMonthlyInterestMonth.value',
scale: -0.8333,
},
},
},
beefy: {
linearPools: [''],
Expand Down
24 changes: 23 additions & 1 deletion modules/network/mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export const mainnetNetworkData: NetworkData = {
aTokenAddress: '0x018008bfb33d285247a21d44e50697654f754e63',
wrappedTokens: {
waDAI: '0x098256c06ab24f5655c5506a6488781bd711c14b',
stataEthDAI: '0x098256c06ab24f5655c5506a6488781bd711c14b',
stataEthDAI: '0xeb708639e8e518b86a916db3685f90216b1c1c67',
},
},
wETH: {
Expand All @@ -187,6 +187,14 @@ export const mainnetNetworkData: NetworkData = {
},
},
},
bloom: {
tokens: {
tbyFeb1924: {
address: '0xc4cafefbc3dfea629c589728d648cb6111db3136',
feedAddress: '0xde1f5f2d69339171d679fb84e4562febb71f36e6',
},
},
},
euler: {
subgraphUrl: 'https://api.thegraph.com/subgraphs/name/euler-xyz/euler-mainnet',
tokens: {
Expand Down Expand Up @@ -222,6 +230,14 @@ export const mainnetNetworkData: NetworkData = {
},
},
},
maker: {
tokens: {
sDAI: {
address: '0x83f20f44975d03b1b09e64809b757c47f942beea',
potAddress: '0x197e90f9fad81970ba7976f33cbd77088e5d7cf7',
},
},
},
tessera: {
tokens: {
sAPE: {
Expand Down Expand Up @@ -299,6 +315,12 @@ export const mainnetNetworkData: NetworkData = {
path: 'wjauraApy',
isIbYield: true,
},
ETHx: {
tokenAddress: '0x0f7f961648ae6db43c75663ac7e5414eb79b5704',
sourceUrl: 'https://universe.staderlabs.com/eth/apy',
path: 'value',
isIbYield: true,
},
},
},
beefy: {
Expand Down
12 changes: 12 additions & 0 deletions modules/network/polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,18 @@ const polygonNetworkData: NetworkData = {
path: 'value',
isIbYield: true,
},
overnightUSDPlus: {
tokenAddress: '0x5d9d8509c522a47d9285b9e4e9ec686e6a580850',
sourceUrl: 'https://api.overnight.fi/optimism/usd+/fin-data/avg-apr/week',
path: 'value',
group: 'OVERNIGHT',
},
overnightstUSDPlus: {
tokenAddress: '0x5a5c6aa6164750b530b8f7658b827163b3549a4d',
sourceUrl: 'https://api.overnight.fi/optimism/usd+/fin-data/avg-apr/week',
path: 'value',
group: 'OVERNIGHT',
},
wbETH: {
tokenAddress: '0xa2e3356610840701bdf5611a53974510ae27e2e1',
sourceUrl:
Expand Down
6 changes: 6 additions & 0 deletions modules/network/zkevm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ const zkevmNetworkData: NetworkData = {
path: 'data.smaApr',
isIbYield: true,
},
rETH: {
tokenAddress: '0xb23c20efce6e24acca0cef9b7b7aa196b84ec942',
sourceUrl: 'https://rocketpool.net/api/mainnet/payload',
path: 'rethAPR',
isIbYield: true,
},
},
},
beefy: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { YearnAprHandler } from './sources/yearn-apr-handler';
import { ReaperCryptAprHandler } from './sources/reaper-crypt-apr-handler';
import { BeefyAprHandler } from './sources/beefy-apr-handler';
import { IbAprConfig } from '../../../../network/apr-config-types';
import { MakerAprHandler } from './sources/maker-apr-handler';
import { BloomAprHandler } from './sources/bloom-apr-handler';

export class IbLinearAprHandlers {
private handlers: AprHandler[] = [];
Expand All @@ -38,6 +40,10 @@ export class IbLinearAprHandlers {
const beefyHandler = new BeefyAprHandler(aprConfig.beefy);
handlers.push(beefyHandler);
}
if (aprConfig.bloom) {
const bloomAprHandler = new BloomAprHandler(aprConfig.bloom);
handlers.push(bloomAprHandler);
}
if (aprConfig.euler) {
const eulerHandler = new EulerAprHandler(aprConfig.euler);
handlers.push(eulerHandler);
Expand All @@ -50,6 +56,10 @@ export class IbLinearAprHandlers {
const idleHandler = new IdleAprHandler(aprConfig.idle);
handlers.push(idleHandler);
}
if (aprConfig.maker) {
const makerHandler = new MakerAprHandler(aprConfig.maker);
handlers.push(makerHandler);
}
if (aprConfig.ovix) {
const ovixHandler = new OvixAprHandler({
...aprConfig.ovix,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export const abi = [{
"inputs":[],
"name":"currentRate",
"outputs":[{
"internalType":"uint256",
"name":"",
"type":"uint256"
}],
"stateMutability":"view",
"type":"function"
}] as const
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const abi = [{
constant: true,
inputs: [],
name: "dsr",
outputs: [{ "internalType": "uint256", "name": "", "type": "uint256" }],
payable: false,
stateMutability: "view",
type: "function"
}] as const
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { AprHandler } from '../ib-linear-apr-handlers';
import { BloomAprConfig } from '../../../../../network/apr-config-types';
import { getContractAt } from '../../../../../web3/contract';
import { abi as bloomBpsFeed } from './abis/bloom-bps-feed';
import * as Sentry from '@sentry/node';

export class BloomAprHandler implements AprHandler {
group: string | undefined;

tokens: BloomAprConfig['tokens'];

constructor(aprConfig: BloomAprConfig) {
this.tokens = aprConfig.tokens;
}

async getAprs(): Promise<{ [p: string]: { apr: number; isIbYield: boolean } }> {
const aprs: { [p: string]: { apr: number; isIbYield: boolean } } = {};
for (const { address, feedAddress, isIbYield } of Object.values(this.tokens)) {
try {
const feedContract = getContractAt(feedAddress, bloomBpsFeed);
const currentRate = await feedContract.currentRate();
if (!currentRate) {
continue;
}
const tokenApr = (Number(currentRate) - 10000) / 10000;
aprs[address] = { apr: tokenApr, isIbYield: isIbYield ?? false };
} catch (error) {
console.error(`Bloom APR Failed for token ${address}: `, error);
Sentry.captureException(`Bloom APR Failed for token ${address}: ${error}`);
}
}
return aprs;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { AprHandler } from '../ib-linear-apr-handlers';
import { MakerAprConfig } from '../../../../../network/apr-config-types';
import { getContractAt } from '../../../../../web3/contract';
import { abi as makerPotAbi } from './abis/maker-pot';
import * as Sentry from '@sentry/node';

export class MakerAprHandler implements AprHandler {
group: string | undefined;
tokens: {
[tokenName: string]: {
address: string;
potAddress: string;
isIbYield?: boolean;
};
};

constructor(aprConfig: MakerAprConfig) {
this.tokens = aprConfig.tokens;
}

async getAprs(): Promise<{ [p: string]: { apr: number; isIbYield: boolean } }> {
const aprs: { [p: string]: { apr: number; isIbYield: boolean } } = {};
for (const { address, potAddress, isIbYield } of Object.values(this.tokens)) {
try {
const potContract = getContractAt(potAddress, makerPotAbi);
const dsr = await potContract.dsr();
if (!dsr) {
continue;
}
const tokenApr = (Number(dsr) * 10 ** -27 - 1) * 365 * 24 * 60 * 60;
aprs[address] = { apr: tokenApr, isIbYield: isIbYield ?? false };
} catch (error) {
console.error(`Maker APR Failed for token ${address}: `, error);
Sentry.captureException(`Maker APR Failed for token ${address}: ${error}`);
}
}
return aprs;
}
}

0 comments on commit 5cf2e3f

Please sign in to comment.