Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APR Services - Add some yield tokens APR to linear pools #396

Merged
merged 48 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
e6a65b3
Created a service to fetch yield tokens APR and push into DB
Jun 30, 2023
1f18d5c
Merge remote-tracking branch 'origin/v3-canary' into non-reaper-yield…
Jun 30, 2023
27ca26d
Adding Apr Service to Mainnet network
Jul 3, 2023
3d84c4b
Added yield tokens fetch funcionality directly on beethovenx-backend,…
Jul 7, 2023
6120e3a
Adapting contracts from apr handler to ethers instead of viem;
Jul 8, 2023
65211ed
Changing apr type if pool type is linear;
Jul 8, 2023
304988e
removing viem
Jul 8, 2023
5cc075b
Merge commit 'fccc29b6e65ffd3df41b7b7de0c2e407e8de2c59' into non-reap…
Jul 13, 2023
11cd519
Fixing Ovix APR;
Jul 13, 2023
a1a20dd
Redesigning Ib Apr Handlers to be more scalable and open to new netwo…
Jul 28, 2023
b3d5575
adding interface to default, ankr and aave apr handlers;
Jul 28, 2023
65047bb
Adding multichain support;
Aug 1, 2023
19a48fc
Types files for ankr and default-fetch; (Missing in the last commit)
Aug 1, 2023
bfe33c1
Merge commit 'a0eb08ebd453441e8f566fb03cc684ec8b4e324d' into non-reap…
Aug 1, 2023
a7b904b
Creating new migration file;
Aug 2, 2023
4cff5b7
Removing test route;
Aug 2, 2023
1e74f53
removing unused imports;
Aug 7, 2023
6b00046
Removing ethers-multicall-provider package
Aug 7, 2023
8c2432e
removing undefined from "group" type
Aug 7, 2023
500f6c4
Moving tokens and types to apr-handler file;
Aug 9, 2023
4d97f48
Using prismaId instead of chain id;
Aug 11, 2023
37366a4
Checking if the pool is linear boosted by the token address;
Aug 18, 2023
32b5a52
Renaming ib-yield-apr-handlers to base-apr-handlers
Aug 21, 2023
74d2bce
Removing ib-yield-apr-handlers folder
Aug 21, 2023
8c04318
Refactoring all code to be more scalable;
Aug 24, 2023
8f040cd
removing aave tokens unused;
Aug 24, 2023
85f76fd
Renaming aprConfig to IbAprConfig;
Aug 29, 2023
c509044
Removing Reaper Crypt Apr Service;
Aug 29, 2023
3d568ca
Removing services that are already in the ib-yield service;
Aug 29, 2023
ae0d54c
Removing test route;
Aug 29, 2023
7913842
Merge branch 'v3-canary' into non-reaper-yield-tokens-apr
Aug 29, 2023
98e9df6
fixing base network incompatibilities;
Aug 29, 2023
fd7f136
fixing optional beefy property in network config;
Aug 29, 2023
a836720
Removing all unused functions of liquid staked base apr, left just xB…
Aug 29, 2023
114386d
Renaming AprConfig to IbAprConfig;
Aug 29, 2023
9ac7a10
clean up types
franzns Sep 1, 2023
a5ca109
simplify ib-tokens-apr service
franzns Sep 1, 2023
97a795f
change default handler, adapt token lists
franzns Sep 4, 2023
ea59577
fix percentage
franzns Sep 4, 2023
1a9352e
add try catch
franzns Sep 4, 2023
c174806
Changing the ib yield filter to network config;
Sep 4, 2023
b00f57d
ibyield flag
franzns Sep 5, 2023
21cd9ae
cleanup
franzns Sep 5, 2023
1261ec6
dont use nested query for apr
franzns Sep 5, 2023
5563895
Merge branch 'v3-canary' into non-reaper-yield-tokens-apr
franzns Sep 5, 2023
e68f06a
lower case all addresses in configs
franzns Sep 5, 2023
c511a9b
Merge branch 'v3-canary' into non-reaper-yield-tokens-apr
franzns Sep 5, 2023
57099bf
adding rocket eth apr
franzns Sep 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
179 changes: 179 additions & 0 deletions modules/network/apr-config-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
export interface IbAprConfig {
aave?: AaveAprConfig;
ankr?: AnkrAprConfig;
beefy?: BeefyAprConfig;
euler?: EulerAprConfig;
gearbox?: GearBoxAprConfig;
idle?: IdleAprConfig;
ovix?: OvixAprConfig;
reaper?: ReaperAprConfig;
tessera?: TesseraAprConfig;
tetu?: TetuAprConfig;
tranchess?: TranchessAprConfig;
yearn?: YearnAprConfig;
defaultHandlers?: DefaultHandlerAprConfig;
fixedAprHandler?: FixedAprConfig;
}

export interface AaveAprConfig {
[version: string]: {
subgraphUrl: string;
tokens: {
[underlyingAssetName: string]: {
underlyingAssetAddress: string;
aTokenAddress: string;
wrappedTokens: {
[wrappedTokenName: string]: string;
};
isIbYield?: boolean;
};
};
};
}

export interface AnkrAprConfig {
sourceUrl: string;
tokens: {
[underlyingAssetName: string]: {
address: string;
serviceName: string;
isIbYield?: boolean;
};
};
}

export interface BeefyAprConfig {
sourceUrl: string;
tokens: {
[tokenName: string]: {
address: string;
// To get the vaultId, get the vault address from the token contract(token.vault()),
// and search for the vault address in the link: https://api.beefy.finance/vaults
vaultId: string;
isIbYield?: boolean;
};
};
}

export interface EulerAprConfig {
subgraphUrl: string;
tokens: {
[tokenName: string]: {
address: string;
isIbYield?: boolean;
};
};
}

export interface GearBoxAprConfig {
sourceUrl: string;
tokens: {
[tokenName: string]: {
address: string;
isIbYield?: boolean;
};
};
}

export interface IdleAprConfig {
sourceUrl: string;
authorizationHeader: string;
tokens: {
[tokenName: string]: {
address: string;
wrapped4626Address: string;
isIbYield?: boolean;
};
};
}

export interface OvixAprConfig {
tokens: {
[tokenName: string]: {
yieldAddress: string;
wrappedAddress: string;
isIbYield?: boolean;
};
};
}

export interface ReaperAprConfig {
subgraphSource?: {
subgraphUrl: string;
tokens: {
[tokenName: string]: {
address: string;
isSftmX?: boolean;
isWstETH?: boolean;
isIbYield?: boolean;
};
};
};
onchainSource?: {
averageAPRAcrossLastNHarvests: number;
tokens: {
[tokenName: string]: {
address: string;
isSftmX?: boolean;
isWstETH?: boolean;
isIbYield?: boolean;
};
};
};
}

export interface TesseraAprConfig {
tokens: {
[tokenName: string]: {
tesseraPoolAddress: string;
tokenAddress: string;
isIbYield?: boolean;
};
};
}

export interface TetuAprConfig {
sourceUrl: string;
tokens: {
[tokenName: string]: {
address: string;
isIbYield?: boolean;
};
};
}

export interface TranchessAprConfig {
sourceUrl: string;
tokens: {
[tokenName: string]: {
address: string;
underlyingAssetName: string;
isIbYield?: boolean;
};
};
}

export interface YearnAprConfig {
sourceUrl: string;
isIbYield?: boolean;
}

export interface DefaultHandlerAprConfig {
[tokenName: string]: {
sourceUrl: string;
tokenAddress: string;
path?: string;
scale?: number;
group?: string;
isIbYield?: boolean;
};
}

export interface FixedAprConfig {
[tokenName: string]: {
address: string;
apr: number;
group?: string;
isIbYield?: boolean;
};
}
86 changes: 70 additions & 16 deletions modules/network/arbitrum.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { BigNumber, ethers } from 'ethers';
import { DeploymentEnv, NetworkConfig, NetworkData } from './network-config-types';
import { tokenService } from '../token/token.service';
import { WstethAprService } from '../pool/lib/apr-data-sources/optimism/wsteth-apr.service';
import { ReaperCryptAprService } from '../pool/lib/apr-data-sources/reaper-crypt-apr.service';
import { PhantomStableAprService } from '../pool/lib/apr-data-sources/phantom-stable-apr.service';
import { BoostedPoolAprService } from '../pool/lib/apr-data-sources/boosted-pool-apr.service';
import { SwapFeeAprService } from '../pool/lib/apr-data-sources/swap-fee-apr.service';
Expand All @@ -17,6 +15,7 @@ import { GithubContentService } from '../content/github-content.service';
import { gaugeSubgraphService } from '../subgraphs/gauge-subgraph/gauge-subgraph.service';
import { CoingeckoPriceHandlerService } from '../token/lib/token-price-handlers/coingecko-price-handler.service';
import { coingeckoService } from '../coingecko/coingecko.service';
import { IbTokensAprService } from '../pool/lib/apr-data-sources/ib-tokens-apr.service';
import { env } from '../../app/env';

const arbitrumNetworkData: NetworkData = {
Expand Down Expand Up @@ -103,16 +102,79 @@ const arbitrumNetworkData: NetworkData = {
swapGas: BigNumber.from('1000000'),
},
},
reaper: {
linearPoolFactories: ['0xc101dca301a4011c1f925e9622e749e550a1b667'],
linearPoolIdsFromErc4626Factory: [],
averageAPRAcrossLastNHarvests: 2,
multistratAprSubgraphUrl: '',
ibAprConfig: {
aave: {
v3: {
subgraphUrl: 'https://api.thegraph.com/subgraphs/name/aave/protocol-v3-arbitrum',
tokens: {
USDC: {
underlyingAssetAddress: '0xff970a61a04b1ca14834a43f5de4533ebddb5cc8',
aTokenAddress: '0x625e7708f30ca75bfd92586e17077590c60eb4cd',
wrappedTokens: {
waUSDC: '0xe719aef17468c7e10c0c205be62c990754dff7e5',
stataArbUSDC: '0x3a301e7917689b8e8a19498b8a28fc912583490c',
stataArbUSDCn: '0xbde67e089886ec0e615d6f054bc6f746189a3d56',
},
},
USDT: {
underlyingAssetAddress: '0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9',
aTokenAddress: '0x6ab707aca953edaefbc4fd23ba73294241490620',
wrappedTokens: {
waUSDT: '0x3c7680dfe7f732ca0279c39ff30fe2eafdae49db',
stataArbUSDT: '0x8b5541b773dd781852940490b0c3dc1a8cdb6a87',
},
},
DAI: {
underlyingAssetAddress: '0xda10009cbd5d07dd0cecc66161fc93d7c9000da1',
aTokenAddress: '0x82e64f49ed5ec1bc6e43dad4fc8af9bb3a2312ee',
wrappedTokens: {
waDAI: '0x345a864ac644c82c2d649491c905c71f240700b2',
stataArbDAI: '0x426e8778bf7f54b0e4fc703dcca6f26a4e5b71de',
},
},
wETH: {
underlyingAssetAddress: '0x82af49447d8a07e3bd95bd0d56f35241523fbab1',
aTokenAddress: '0xe50fa9b3c56ffb159cb0fca61f5c9d750e8128c8',
wrappedTokens: {
waWETH: '0x18c100415988bef4354effad1188d1c22041b046',
stataArbWETH: '0x18468b6eba332285c6d9bb03fe7fb52e108c4596',
},
},
},
},
},
defaultHandlers: {
wstETH: {
tokenAddress: '0x5979d7b546e38e414f7e9822514be443a4800529',
sourceUrl: 'https://eth-api.lido.fi/v1/protocol/steth/apr/sma',
path: 'data.smaApr',
isIbYield: true,
},
},
},
beefy: {
linearPools: [''],
},
lido: {
wstEthAprEndpoint: 'https://eth-api.lido.fi/v1/protocol/steth/apr/sma',
wstEthContract: '0x5979d7b546e38e414f7e9822514be443a4800529',
},
datastudio: {
main: {
user: '[email protected]',
sheetId: '11anHUEb9snGwvB-errb5HvO8TvoLTRJhkDdD80Gxw1Q',
databaseTabName: 'Database v2',
compositionTabName: 'Pool Composition v2',
emissionDataTabName: 'EmissionData',
},
canary: {
user: '[email protected]',
sheetId: '1HnJOuRQXGy06tNgqjYMzQNIsaCSCC01Yxe_lZhXBDpY',
databaseTabName: 'Database v2',
compositionTabName: 'Pool Composition v2',
emissionDataTabName: 'EmissionData',
},
},
monitoring: {
main: {
alarmTopicArn: 'arn:aws:sns:ca-central-1:118697801881:api_alarms',
Expand All @@ -128,15 +190,7 @@ export const arbitrumNetworkConfig: NetworkConfig = {
contentService: new GithubContentService(),
provider: new ethers.providers.JsonRpcProvider({ url: arbitrumNetworkData.rpcUrl, timeout: 60000 }),
poolAprServices: [
new WstethAprService(tokenService, arbitrumNetworkData.lido!.wstEthContract),
new ReaperCryptAprService(
arbitrumNetworkData.reaper!.multistratAprSubgraphUrl,
arbitrumNetworkData.reaper!.linearPoolFactories,
arbitrumNetworkData.reaper!.linearPoolIdsFromErc4626Factory,
arbitrumNetworkData.reaper!.averageAPRAcrossLastNHarvests,
arbitrumNetworkData.stader ? arbitrumNetworkData.stader.sFtmxContract : undefined,
arbitrumNetworkData.lido ? arbitrumNetworkData.lido.wstEthContract : undefined,
),
new IbTokensAprService(arbitrumNetworkData.ibAprConfig),
new PhantomStableAprService(),
new BoostedPoolAprService(),
new SwapFeeAprService(arbitrumNetworkData.balancer.swapProtocolFeePercentage),
Expand Down
Loading