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

Aprs fixes #452

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e9c3a76
lower case all contracts in config
franzns Sep 5, 2023
4b000ae
APR Services - Add some yield tokens APR to linear pools (#396)
lgahdl Sep 6, 2023
6c621f7
bal apr range for mainnet
franzns Sep 6, 2023
0ae2f35
fix fantom apr services
franzns Sep 6, 2023
d50bcb8
gauge apr fix
franzns Sep 6, 2023
97c22c8
needs to run as transaction
franzns Sep 6, 2023
93a464e
add missing factories
franzns Sep 6, 2023
5c69fc3
Aprs fixes (#447)
gmbronco Sep 6, 2023
f5bba34
fix: Delete votingGauge entry before deleting a staking gauge. (#449)
johngrantuk Sep 7, 2023
bf8c8ed
only apply fees to IB tokens if there is a price rate != 1.0
franzns Sep 7, 2023
9ddfbfd
pull swap fee apr to top, dont collect fees on nested pools without r…
franzns Sep 7, 2023
cd78056
fix: Delete associate PoolGyroData when deleting pool. (#450)
johngrantuk Sep 7, 2023
b2bfc19
change apr title
franzns Sep 7, 2023
9e925a5
check for liquidity
franzns Sep 7, 2023
7bd02c4
enabling sentry
franzns Sep 8, 2023
0668d60
sync gauge version, allow for reload
franzns Sep 8, 2023
a15481c
fix gauge service
franzns Sep 8, 2023
8634adc
set transaction name for sentry
franzns Sep 8, 2023
e9a9791
take tokens decimals into account for gauge reward rate
franzns Sep 8, 2023
94f9fe3
use job id including chain for sentry
franzns Sep 8, 2023
4cd1b7a
change bal address for base
franzns Sep 11, 2023
5de90d4
add todo
franzns Sep 11, 2023
67b6a91
exclude new tarot token from cg feed
franzns Sep 11, 2023
2595c7e
reduce cron frequency for unused
franzns Sep 11, 2023
770d336
aprs: adding working supply
gmbronco Sep 12, 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
2 changes: 1 addition & 1 deletion env.local
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ SENTRY_AUTH_TOKEN=<insert-me>
APOLLO_GRAPH_REF=<not-required-if-reporting-false>
APOLLO_API_KEY=<not-required-if-reporting-false>

INFURA_API_KEY=<insert key>
INFURA_API_KEY=

# Admin routes
ADMIN_API_KEY=<chose-a-value>
Expand Down
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;
};
}
119 changes: 84 additions & 35 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,14 +15,15 @@ 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 = {
chain: {
slug: 'arbitrum',
id: 42161,
nativeAssetAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
wrappedNativeAssetAddress: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1',
wrappedNativeAssetAddress: '0x82af49447d8a07e3bd95bd0d56f35241523fbab1',
prismaId: 'ARBITRUM',
gqlId: 'ARBITRUM',
},
Expand Down Expand Up @@ -68,24 +67,23 @@ const arbitrumNetworkData: NetworkData = {
delegationProxy: '0x81cfae226343b24ba12ec6521db2c79e7aeeb310',
},
balancer: {
vault: '0xBA12222222228d8Ba445958a75a0704d566BF2C8',
vault: '0xba12222222228d8ba445958a75a0704d566bf2c8',
composableStablePoolFactories: [
'0xaEb406b0E430BF5Ea2Dc0B9Fe62E4E53f74B3a33',
'0x85a80afee867aDf27B50BdB7b76DA70f1E853062',
'0x1c99324EDC771c82A0DCCB780CC7DDA0045E50e7',
'0x2498A2B0d6462d2260EAC50aE1C3e03F4829BA95',
'0xA8920455934Da4D853faac1f94Fe7bEf72943eF1',
'0xaeb406b0e430bf5ea2dc0b9fe62e4e53f74b3a33',
'0x85a80afee867adf27b50bdb7b76da70f1e853062',
'0x1c99324edc771c82a0dccb780cc7dda0045e50e7',
'0x2498a2b0d6462d2260eac50ae1c3e03f4829ba95',
'0xa8920455934da4d853faac1f94fe7bef72943ef1',
],
weightedPoolV2Factories: [
'0x8df6EfEc5547e31B0eb7d1291B511FF8a2bf987c',
'0xf1665E19bc105BE4EDD3739F88315cC699cc5b65',
'0xc7E5ED1054A24Ef31D827E6F86caA58B3Bc168d7',
'0x8df6efec5547e31b0eb7d1291b511ff8a2bf987c',
'0xf1665e19bc105be4edd3739f88315cc699cc5b65',
'0xc7e5ed1054a24ef31d827e6f86caa58b3bc168d7',
],
swapProtocolFeePercentage: 0.5,
yieldProtocolFeePercentage: 0.5,
poolDataQueryContract: '0x7Ba29fE8E83dd6097A7298075C4AFfdBda3121cC',
},
multicall: '0x80C7DD17B01855a6D2347444a0FCC36136a314de',
multicall: '0x80c7dd17b01855a6d2347444a0fcc36136a314de',
multicall3: '0xca11bde05977b3631167028862be2a173976ca11',
avgBlockSpeed: 1,
sor: {
Expand All @@ -104,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 @@ -129,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 Expand Up @@ -217,15 +270,11 @@ export const arbitrumNetworkConfig: NetworkConfig = {
},
{
name: 'user-sync-wallet-balances-for-all-pools',
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(30, 'seconds') : every(15, 'seconds'),
alarmEvaluationPeriod: 1,
alarmDatapointsToAlarm: 1,
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(5, 'minutes') : every(2, 'minutes'),
},
{
name: 'user-sync-staked-balances',
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(30, 'seconds') : every(15, 'seconds'),
alarmEvaluationPeriod: 1,
alarmDatapointsToAlarm: 1,
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(5, 'minutes') : every(2, 'minutes'),
},
{
name: 'sync-user-snapshots',
Expand All @@ -247,7 +296,7 @@ export const arbitrumNetworkConfig: NetworkConfig = {
},
{
name: 'sync-vebal-balances',
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(2, 'minutes') : every(1, 'minutes'),
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(5, 'minutes') : every(3, 'minutes'),
},
{
name: 'sync-vebal-totalSupply',
Expand Down
Loading
Loading