8000 extracting APRs module by gmbronco · Pull Request #2027 · balancer/backend · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

extracting APRs module #2027

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

Merged
merged 40 commits into from
Jun 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
bffd0cd
extracting APRs module
gmbronco May 21, 2025
797715e
Merge branch 'v3-canary' into aprs-module
franzns Jun 13, 2025
5f390b6
fix yield fee collection bool
franzns Jun 13, 2025
064fdb0
move config
franzns Jun 13, 2025
9886e23
add dynamic swapfee apr handler
franzns Jun 16, 2025
a2c85ff
add mabeets apr
franzns Jun 16, 2025
7b98d4e
move types
franzns Jun 16, 2025
072ce65
add morpho rewards handler
franzns Jun 16, 2025
c606276
add nested pool apr service
franzns Jun 16, 2025
8866cc2
add quant amm apr handler
franzns Jun 16, 2025
4a29981
liquidity gauge apr handler
franzns Jun 16, 2025
1e2257d
rename calculator to handler
franzns Jun 16, 2025
f8f6214
add vebal apr handlers
franzns Jun 16, 2025
816bffb
remove config from aave rewards and enable it on chains
franzns Jun 16, 2025
f1912b4
remove items that dont exist anymore
franzns Jun 16, 2025
5250be7
add merkl
franzns Jun 16, 2025
af79da9
add but dont enable 7d30d swap fee apr handler
franzns Jun 16, 2025
aa4e447
fix imports
franzns Jun 16, 2025
76fbbf8
sync incentivized category after apr sync
franzns Jun 16, 2025
b17d40f
replace old service with new one
franzns Jun 16, 2025
2ffc0f7
add surplus handler, move dynamic fee handler
franzns Jun 16, 2025
14c56f8
integrate surplus apr
franzns Jun 16, 2025
092bb61
integrate apr items, get rid of apr group
franzns Jun 16, 2025
20b6e59
get rid of apr range
franzns Jun 16, 2025
783a4e7
types
franzns Jun 16, 2025
01c94ca
cleanup and move yb apr handlers
franzns Jun 16, 2025
14e9c29
drop apr range
franzns Jun 16, 2025
23d16e5
fix merkl query
franzns Jun 16, 2025
f3c1d8a
fix await
franzns Jun 16, 2025
7f1bc1e
fix update total apr
franzns Jun 16, 2025
a0e0097
fix beetswars
franzns Jun 16, 2025
7288a78
fux yusd apr
franzns Jun 16, 2025
cdd30ec
fix yusd2 apr base
franzns Jun 16, 2025
5dba053
changeset
franzns Jun 16, 2025
d362ed8
Merge branch 'v3-canary' into aprs-module
franzns Jun 16, 2025
798ad99
add back aave for avax
franzns Jun 16, 2025
93c9680
move logic to controller
franzns Jun 19, 2025
c63f0a2
extract tokenservice from handlers for DI
franzns Jun 19, 2025
eec5cd0
add stability apr
franzns Jun 19, 2025
ea559fb
Merge branch 'v3-canary' into aprs-module
franzns Jun 19, 2025
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
5 changes: 5 additions & 0 deletions .changeset/cool-spiders-bake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'backend': minor
---

extract all APRs into APR-module
3 changes: 2 additions & 1 deletion apps/api/gql/resolvers/pool.resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { GraphQLError } from 'graphql';
import { upsertLastSyncedBlock } from '../../../../modules/actions/last-synced-block';
import { PrismaLastBlockSyncedCategory } from '@prisma/client';
import graphqlFields from 'graphql-fields';
import { AprsController } from '../../../../modules/controllers/aprs-controller';

const balancerResolvers: Resolvers = {
Query: {
Expand Down Expand Up @@ -120,7 +121,7 @@ const balancerResolvers: Resolvers = {
poolReloadAllPoolAprs: async (parent, { chain }, context) => {
isAdminRoute(context);

await poolService.reloadAllPoolAprs(chain);
await AprsController().reloadAprsAndIncentivizedCategory(chain);

return 'success';
},
Expand Down
13 changes: 2 additions & 11 deletions apps/worker/job-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
SftmxController,
CowAmmController,
SnapshotsController,
AprsController,
ContentController,
PoolController,
EventController,
Expand All @@ -33,6 +32,7 @@ import { TokenController } from '../../modules/controllers/token-controller';
import { SubgraphMonitorController } from '../../modules/controllers/subgraph-monitor-controller';
import config from '../../config';
import { LBPController } from '../../modules/controllers/lbp-controller';
import { AprsController } from '../../modules/controllers/aprs-controller';

const runningJobs: Set<string> = new Set();

Expand Down Expand Up @@ -312,22 +312,13 @@ const setupJobHandlers = async (name: string, chainId: string, res: any, next: N
);
break;
// APRs
case 'sync-merkl':
await runIfNotAlreadyRunning(name, chainId, () => AprsController().syncMerkl(), res, next);
break;
case 'update-7-30-days-swap-apr':
// Disabling unused APRs
break;
case 'update-surplus-aprs':
await runIfNotAlreadyRunning(name, chainId, () => CowAmmController().updateSurplusAprs(), res, next);
break;
case 'update-pool-apr':
await runIfNotAlreadyRunning(
name,
chainId,
() => {
const chain = chainIdToChain[chainId];
return poolService.updatePoolAprs(chain);
return AprsController().updateAprsAndIncentivizedCategory(chain);
},
res,
next,
Expand Down
405 changes: 196 additions & 209 deletions config/arbitrum.ts

Large diffs are not rendered by default.

186 changes: 95 additions & 91 deletions config/avalanche.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { tr } from '@faker-js/faker';
import { env } from '../apps/env';
import { DeploymentEnv, NetworkData } from '../modules/network/network-config-types';

Expand Down Expand Up @@ -72,107 +73,110 @@ export default <NetworkData>{
multicall: '0xca11bde05977b3631167028862be2a173976ca11',
multicall3: '0xca11bde05977b3631167028862be2a173976ca11',
avgBlockSpeed: 2,
ybAprConfig: {
aave: {
v3: {
subgraphUrl: `https://gateway-arbitrum.network.thegraph.com/api/${env.THEGRAPH_API_KEY_BALANCER}/subgraphs/id/2h9woxy8RTjHu1HJsCEnmzpPHFArU33avmUh4f71JpVn`,
tokens: {
USDC: {
underlyingAssetAddress: '0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e',
aTokenAddress: '0x625e7708f30ca75bfd92586e17077590c60eb4cd',
wrappedTokens: {
stataAvaUSDC: '0xe7839ea8ea8543c7f5d9c9d7269c661904729fe7',
aprHandlers: {
aaveRewardsAprHandler: true,
ybAprConfig: {
aave: {
v3: {
subgraphUrl: `https://gateway-arbitrum.network.thegraph.com/api/${env.THEGRAPH_API_KEY_BALANCER}/subgraphs/id/2h9woxy8RTjHu1HJsCEnmzpPHFArU33avmUh4f71JpVn`,
tokens: {
USDC: {
underlyingAssetAddress: '0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e',
aTokenAddress: '0x625e7708f30ca75bfd92586e17077590c60eb4cd',
wrappedTokens: {
stataAvaUSDC: '0xe7839ea8ea8543c7f5d9c9d7269c661904729fe7',
},
},
},
USDT: {
underlyingAssetAddress: '0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7',
aTokenAddress: '0x6ab707aca953edaefbc4fd23ba73294241490620',
wrappedTokens: {
stataAvaUSDT: '0x759a2e28d4c3ad394d3125d5ab75a6a5d6782fd9',
USDT: {
underlyingAssetAddress: '0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7',
aTokenAddress: '0x6ab707aca953edaefbc4fd23ba73294241490620',
wrappedTokens: {
stataAvaUSDT: '0x759a2e28d4c3ad394d3125d5ab75a6a5d6782fd9',
},
},
},
DAI: {
underlyingAssetAddress: '0xd586e7f844cea2f87f50152665bcbc2c279d8d70',
aTokenAddress: '0x 10000 82e64f49ed5ec1bc6e43dad4fc8af9bb3a2312ee',
wrappedTokens: {
stataAvaDAI: '0x234c4b76f749dfffd9c18ea7cc0972206b42d019',
DAI: {
underlyingAssetAddress: '0xd586e7f844cea2f87f50152665bcbc2c279d8d70',
aTokenAddress: '0x82e64f49ed5ec1bc6e43dad4fc8af9bb3a2312ee',
wrappedTokens: {
stataAvaDAI: '0x234c4b76f749dfffd9c18ea7cc0972206b42d019',
},
},
},
wETH: {
underlyingAssetAddress: '0x49d5c2bdffac6ce2bfdb6640f4f80f226bc10bab',
aTokenAddress: '0xe50fa9b3c56ffb159cb0fca61f5c9d750e8128c8',
wrappedTokens: {
stataAvaWETH: '0x41bafe0091d55378ed921af3784622923651fdd8',
wETH: {
underlyingAssetAddress: '0x49d5c2bdffac6ce2bfdb6640f4f80f226bc10bab',
aTokenAddress: '0xe50fa9b3c56ffb159cb0fca61f5c9d750e8128c8',
wrappedTokens: {
stataAvaWETH: '0x41bafe0091d55378ed921af3784622923651fdd8',
},
},
},
wAVAX: {
underlyingAssetAddress: '0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7',
aTokenAddress: '0x6d80113e533a2c0fe82eabd35f1875dcea89ea97',
wrappedTokens: {
stataAvaWAVAX: '0xa291ae608d8854cdbf9838e28e9badcf10181669',
stataAvaWAVAX2: '0x6a02c7a974f1f13a67980c80f774ec1d2ed8f98d',
wAVAX: {
underlyingAssetAddress: '0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7',
aTokenAddress: '0x6d80113e533a2c0fe82eabd35f1875dcea89ea97',
wrappedTokens: {
stataAvaWAVAX: '0xa291ae608d8854cdbf9838e28e9badcf10181669',
stataAvaWAVAX2: '0x6a02c7a974f1f13a67980c80f774ec1d2ed8f98d',
},
},
},
wBTC: {
underlyingAssetAddress: '0x50b7545627a5162f82a992c33b87adc75187b218',
aTokenAddress: '0x078f358208685046a11c85e8ad32895ded33a249',
wrappedTokens: {
stataAvaWBTC: '0xb516f74eb030cebd5f616b1a33f88e1213b93c2c',
wBTC: {
underlyingAssetAddress: '0x50b7545627a5162f82a992c33b87adc75187b218',
aTokenAddress: '0x078f358208685046a11c85e8ad32895ded33a249',
wrappedTokens: {
stataAvaWBTC: '0xb516f74eb030cebd5f616b1a33f88e1213b93c2c',
},
},
},
},
},
},
euler: {
vaultsJsonUrl:
'https://raw.githubusercontent.com/euler-xyz/euler-labels/refs/heads/master/43114/vaults.json',
lensContractAddress: '0xc820c24905c210aefe21dae40723ec28d62c1544',
},
defaultHandlers: {
yUTY: {
tokenAddress: '0x580d5e1399157fd0d58218b7a514b60974f2ab01',
sourceUrl: 'https://api.xsy.fi/v1/yuty',
path: 'apy',
scale: 100,
},
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://api.gogopool.com/metrics',
path: 'ggavax_apy',
// Updated from https://ceres.gogopool.com/ which used below calculation and scale -8.3333
// According to solarcurve, the AVAX Monthly Interest must be multiplied by -12 to represent the APR in normal scale, for example, if the monthly interest is -0,15, the APR would be -0,15 * -12 = 1,8%.
// @solarcurve: We estimate by multiplying that value by -12 since its the exchange rate of AVAX -> ggAVAX, which will always return less ggAVAX than AVAX
// How this -12 became -8,333? It's because the scale parameter is used to divide the number, and the final apr percentage is in decimal format (1,8% = 0,018), so if:
// M * -12 = A (M is monthly rate and A is APR) => (M/x) = (A/100) => (A / -12x) = (A / 100) [replacing M by A/-12] => x = 100/-12 = -8,33333
euler: {
vaultsJsonUrl:
'https://raw.githubusercontent.com/euler-xyz/euler-labels/refs/heads/master/43114/vaults.json',
lensContractAddress: '0xc820c24905c210aefe21dae40723ec28d62c1544',
},
ankrAVAX: {
tokenAddress: '0xc3344870d52688874b06d844e0c36cc39fc727f6',
sourceUrl: 'https://api.staking.ankr.com/v1alpha/metrics',
path: 'services.{serviceName == "avax"}.apy',
isIbYield: true,
},
sdeUSD: {
tokenAddress: '0x68088c91446c7bea49ea7dbd3b96ce62b272dc96',
sourceUrl: 'https://api-deusd-prod-public.elixir.xyz/public/deusd_apy',
path: 'deusd_apy',
isIbYield: true,
},
savUSD: {
tokenAddress: '0x06d47f3fb376649c3a9dafe069b3d6e35572219e',
sourceUrl: 'https://app.avantprotocol.com/api/savusdApy',
BDB1 path: 'savusdApy',
isIbYield: true,
defaultHandlers: {
yUTY: {
tokenAddress: '0x580d5e1399157fd0d58218b7a514b60974f2ab01',
sourceUrl: 'https://api.xsy.fi/v1/yuty',
path: 'apy',
scale: 100,
},
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://api.gogopool.com/metrics',
path: 'ggavax_apy',
// Updated from https://ceres.gogopool.com/ which used below calculation and scale -8.3333
// According to solarcurve, the AVAX Monthly Interest must be multiplied by -12 to represent the APR in normal scale, for example, if the monthly interest is -0,15, the APR would be -0,15 * -12 = 1,8%.
// @solarcurve: We estimate by multiplying that value by -12 since its the exchange rate of AVAX -> ggAVAX, which will always return less ggAVAX than AVAX
// How this -12 became -8,333? It's because the scale parameter is used to divide the number, and the final apr percentage is in decimal format (1,8% = 0,018), so if:
// M * -12 = A (M is monthly rate and A is APR) => (M/x) = (A/100) => (A / -12x) = (A / 100) [replacing M by A/-12] => x = 100/-12 = -8,33333
},
ankrAVAX: {
tokenAddress: '0xc3344870d52688874b06d844e0c36cc39fc727f6',
sourceUrl: 'https://api.staking.ankr.com/v1alpha/metrics',
path: 'services.{serviceName == "avax"}.apy',
isIbYield: true,
},
sdeUSD: {
tokenAddress: '0x68088c91446c7bea49ea7dbd3b96ce62b272dc96',
sourceUrl: 'https://api-deusd-prod-public.elixir.xyz/public/deusd_apy',
path: 'deusd_apy',
isIbYield: true,
},
savUSD: {
tokenAddress: '0x06d47f3fb376649c3a9dafe069b3d6e35572219e',
sourceUrl: 'https://app.avantprotocol.com/api/savusdApy',
path: 'savusdApy',
isIbYield: true,
},
},
},
},
Expand Down
Loading
0