-
Notifications
You must be signed in to change notification settings - Fork 1.7k
add liquidation tracking #6175
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
base: master
Are you sure you want to change the base?
add liquidation tracking #6175
Changes from all commits
8cf13ba
96c4cb9
32fbddb
49afc7e
7d99b7a
1339799
7ec1ce7
c2c3076
c4d3887
6a2c622
86369ce
016656a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import { aaveProtocolConfigs } from "../helpers/aave"; | ||
| import { aaveLiquidationsExport } from "../helpers/aave/liquidations"; | ||
| import { chainConfig as aaveV3ChainConfig } from "../fees/aave-v3"; | ||
| import { chainConfig as sparkChainConfig } from "../fees/spark"; | ||
| import { createFactoryExports } from "./registry"; | ||
|
|
||
| type LiquidationConfig = Record<string, { pools: string[]; start?: string }>; | ||
|
|
||
| // create liquidation configs from aave fee configs so new protocols added to fee tracking are picked up | ||
| function toLiquidationConfig( | ||
| feeConfig: Record<string, { start?: any; pools: Array<{ lendingPoolProxy: string; version: number; ignoreLiquidation?: boolean }> }>, | ||
| ): LiquidationConfig | null { | ||
| const result: LiquidationConfig = {}; | ||
| for (const [chain, { pools, start }] of Object.entries(feeConfig)) { | ||
| // V1 uses a different LiquidationCall event (skips for now) | ||
| const addresses = pools | ||
| .filter((p) => !p.ignoreLiquidation && p.version >= 2) | ||
| .map((p) => p.lendingPoolProxy); | ||
| if (addresses.length > 0) { | ||
| result[chain] = { pools: addresses, start: start ? String(start) : undefined }; | ||
| } | ||
| } | ||
| return Object.keys(result).length > 0 ? result : null; | ||
| } | ||
|
|
||
| // get configs from helpers/aave fee configs | ||
| const configs: Record<string, LiquidationConfig> = {}; | ||
| for (const [name, { config }] of Object.entries(aaveProtocolConfigs)) { | ||
| const liquidationConfig = toLiquidationConfig(config as any); | ||
| if (liquidationConfig) { | ||
| configs[name] = liquidationConfig; | ||
| } | ||
| } | ||
|
|
||
| // get aave-v3 fee config | ||
| configs["aave-v3"] = {}; | ||
| for (const [chain, { pools, start }] of Object.entries(aaveV3ChainConfig)) { | ||
| configs["aave-v3"][chain] = { | ||
| pools: (pools as Array<{ lendingPoolProxy: string }>).map((p) => p.lendingPoolProxy), | ||
| start, | ||
| }; | ||
| } | ||
|
|
||
| // get spark fee config | ||
| configs["spark"] = {}; | ||
| for (const [chain, { pools, start }] of Object.entries(sparkChainConfig)) { | ||
| configs["spark"][chain] = { | ||
| pools: pools.map((p) => p.lendingPoolProxy), | ||
| start, | ||
| }; | ||
| } | ||
|
|
||
| const protocols: Record<string, any> = {}; | ||
| for (const [name, config] of Object.entries(configs)) { | ||
| protocols[name] = aaveLiquidationsExport(config); | ||
| } | ||
|
|
||
| export const { protocolList, getAdapter } = createFactoryExports(protocols); | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,89 +1,150 @@ | ||||||||||||||||||
| import { compoundV2Export } from "../helpers/compoundV2"; | ||||||||||||||||||
| import { compoundV2Export, compoundV2LiquidationsExport } from "../helpers/compoundV2"; | ||||||||||||||||||
| import { CHAIN } from "../helpers/chains"; | ||||||||||||||||||
| import { createFactoryExports } from "./registry"; | ||||||||||||||||||
|
|
||||||||||||||||||
| type ChainConfig = { | ||||||||||||||||||
| comptroller: string; | ||||||||||||||||||
| start?: string; | ||||||||||||||||||
| }; | ||||||||||||||||||
|
|
||||||||||||||||||
| type Config = { | ||||||||||||||||||
| comptrollers: Record<string, string>; | ||||||||||||||||||
| chains: Record<string, ChainConfig>; | ||||||||||||||||||
| options?: Record<string, any>; | ||||||||||||||||||
| }; | ||||||||||||||||||
|
|
||||||||||||||||||
| const feesConfigs: Record<string, Config> = { | ||||||||||||||||||
| const configs: Record<string, Config> = { | ||||||||||||||||||
| "benqi-lending": { | ||||||||||||||||||
| comptrollers: { [CHAIN.AVAX]: "0x486Af39519B4Dc9a7fCcd318217352830E8AD9b4" }, | ||||||||||||||||||
| chains: { [CHAIN.AVAX]: { comptroller: "0x486Af39519B4Dc9a7fCcd318217352830E8AD9b4", start: '2021-08-18' } }, | ||||||||||||||||||
| options: { holdersRevenueRatio: 0, protocolRevenueRatio: 1 }, | ||||||||||||||||||
| }, | ||||||||||||||||||
| "canto-lending": { | ||||||||||||||||||
| comptrollers: { [CHAIN.CANTO]: "0x5E23dC409Fc2F832f83CEc191E245A191a4bCc5C" }, | ||||||||||||||||||
| chains: { [CHAIN.CANTO]: { comptroller: "0x5E23dC409Fc2F832f83CEc191E245A191a4bCc5C", start: '2022-08-18' } }, | ||||||||||||||||||
| options: { protocolRevenueRatio: 1 }, | ||||||||||||||||||
| }, | ||||||||||||||||||
| "capyfi": { | ||||||||||||||||||
| comptrollers: { [CHAIN.ETHEREUM]: "0x0b9af1fd73885aD52680A1aeAa7A3f17AC702afA", [CHAIN.WC]: "0x589d63300976759a0fc74ea6fA7D951f581252D7" }, | ||||||||||||||||||
| chains: { | ||||||||||||||||||
| [CHAIN.ETHEREUM]: { comptroller: "0x0b9af1fd73885aD52680A1aeAa7A3f17AC702afA", start: '2025-05-20' }, | ||||||||||||||||||
| [CHAIN.WC]: { comptroller: "0x589d63300976759a0fc74ea6fA7D951f581252D7", start: '2025-07-23' }, | ||||||||||||||||||
| }, | ||||||||||||||||||
| options: { protocolRevenueRatio: 1, blacklists: ["0xbaa6bc4e24686d710b9318b49b0bb16ec7c46bfa"] }, | ||||||||||||||||||
| }, | ||||||||||||||||||
| "deepr-finance": { | ||||||||||||||||||
| comptrollers: { [CHAIN.SHIMMER_EVM]: "0xF7E452A8685D57083Edf4e4CC8064EcDcF71D7B7", [CHAIN.IOTAEVM]: "0xee07121d97FDEA35675e02017837a7a43aeDa48F" }, | ||||||||||||||||||
| chains: { | ||||||||||||||||||
| [CHAIN.SHIMMER_EVM]: { comptroller: "0xF7E452A8685D57083Edf4e4CC8064EcDcF71D7B7", start: '2024-01-09' }, | ||||||||||||||||||
| [CHAIN.IOTAEVM]: { comptroller: "0xee07121d97FDEA35675e02017837a7a43aeDa48F", start: '2024-08-22' }, | ||||||||||||||||||
| }, | ||||||||||||||||||
| options: { holdersRevenueRatio: 1 }, | ||||||||||||||||||
| }, | ||||||||||||||||||
| "elara": { | ||||||||||||||||||
| comptrollers: { [CHAIN.ZIRCUIT]: "0x695aCEf58D1a10Cf13CBb4bbB2dfB7eDDd89B296" }, | ||||||||||||||||||
| chains: { [CHAIN.ZIRCUIT]: { comptroller: "0x695aCEf58D1a10Cf13CBb4bbB2dfB7eDDd89B296", start: '2024-11-20' } }, | ||||||||||||||||||
| options: { protocolRevenueRatio: 1 }, | ||||||||||||||||||
| }, | ||||||||||||||||||
| "fluxfinance": { | ||||||||||||||||||
| comptrollers: { [CHAIN.ETHEREUM]: "0x95Af143a021DF745bc78e845b54591C53a8B3A51" }, | ||||||||||||||||||
| chains: { [CHAIN.ETHEREUM]: { comptroller: "0x95Af143a021DF745bc78e845b54591C53a8B3A51", start: '2023-02-02' } }, | ||||||||||||||||||
| options: { protocolRevenueRatio: 1 }, | ||||||||||||||||||
| }, | ||||||||||||||||||
| "hover": { | ||||||||||||||||||
| comptrollers: { [CHAIN.KAVA]: "0x3A4Ec955a18eF6eB33025599505E7d404a4d59eC" }, | ||||||||||||||||||
| chains: { [CHAIN.KAVA]: { comptroller: "0x3A4Ec955a18eF6eB33025599505E7d404a4d59eC", start: '2023-11-24' } }, | ||||||||||||||||||
| }, | ||||||||||||||||||
| "machfi": { | ||||||||||||||||||
| comptrollers: { [CHAIN.SONIC]: "0x646F91AbD5Ab94B76d1F9C5D9490A2f6DDf25730" }, | ||||||||||||||||||
| chains: { [CHAIN.SONIC]: { comptroller: "0x646F91AbD5Ab94B76d1F9C5D9490A2f6DDf25730", start: '2025-01-01' } }, | ||||||||||||||||||
| options: { protocolRevenueRatio: 1 }, | ||||||||||||||||||
| }, | ||||||||||||||||||
| "mendi-finance": { | ||||||||||||||||||
| comptrollers: { [CHAIN.LINEA]: "0x1b4d3b0421dDc1eB216D230Bc01527422Fb93103" }, | ||||||||||||||||||
| chains: { [CHAIN.LINEA]: { comptroller: "0x1b4d3b0421dDc1eB216D230Bc01527422Fb93103", start: '2023-08-18' } }, | ||||||||||||||||||
| options: { holdersRevenueRatio: 1, protocolRevenueRatio: 0 }, | ||||||||||||||||||
| }, | ||||||||||||||||||
| "morpho-compound": { | ||||||||||||||||||
| comptrollers: { [CHAIN.ETHEREUM]: "0x930f1b46e1d081ec1524efd95752be3ece51ef67" }, | ||||||||||||||||||
| chains: { [CHAIN.ETHEREUM]: { comptroller: "0x930f1b46e1d081ec1524efd95752be3ece51ef67", start: '2023-07-01' } }, | ||||||||||||||||||
| }, | ||||||||||||||||||
| "qie-lend": { | ||||||||||||||||||
| comptrollers: { [CHAIN.QIEV3]: "0x69a31E3D361C69B37463aa67Ef93067dC760fBD4"}, | ||||||||||||||||||
| chains: { [CHAIN.QIEV3]: { comptroller: "0x69a31E3D361C69B37463aa67Ef93067dC760fBD4" } }, | ||||||||||||||||||
| }, | ||||||||||||||||||
| "strike": { | ||||||||||||||||||
| comptrollers: { [CHAIN.ETHEREUM]: "0xe2e17b2CBbf48211FA7eB8A875360e5e39bA2602" }, | ||||||||||||||||||
| chains: { [CHAIN.ETHEREUM]: { comptroller: "0xe2e17b2CBbf48211FA7eB8A875360e5e39bA2602", start: '2021-03-30' } }, | ||||||||||||||||||
| options: { useExchangeRate: true, blacklists: ["0xc13fdf3af7ec87dca256d9c11ff96405d360f522", "0x1ebfd36223079dc79fefc62260db9e25f3f5e2c7"], protocolRevenueRatio: 1 }, | ||||||||||||||||||
| }, | ||||||||||||||||||
| "sumer": { | ||||||||||||||||||
| comptrollers: { [CHAIN.METER]: "0xcB4cdDA50C1B6B0E33F544c98420722093B7Aa88", [CHAIN.BASE]: "0x611375907733D9576907E125Fb29704712F0BAfA", [CHAIN.ARBITRUM]: "0xBfb69860C91A22A2287df1Ff3Cdf0476c5aab24A", [CHAIN.ETHEREUM]: "0x60A4570bE892fb41280eDFE9DB75e1a62C70456F", [CHAIN.ZKLINK]: "0xe6099D924efEf37845867D45E3362731EaF8A98D", [CHAIN.BSQUARED]: "0xdD9C863197df28f47721107f94eb031b548B5e48", [CHAIN.CORE]: "0x7f5a7aE2688A7ba6a9B36141335044c058a08b3E", [CHAIN.BSC]: "0x15B5220024c3242F7D61177D6ff715cfac4909eD", [CHAIN.BERACHAIN]: "0x16C7d1F9EA48F7DE5E8bc3165A04E8340Da574fA", [CHAIN.HEMI]: "0xB2fF02eEF85DC4eaE95Ab32AA887E0cC69DF8d8E" }, | ||||||||||||||||||
| chains: { | ||||||||||||||||||
| [CHAIN.METER]: { comptroller: "0xcB4cdDA50C1B6B0E33F544c98420722093B7Aa88", start: '2023-11-13' }, | ||||||||||||||||||
| [CHAIN.BASE]: { comptroller: "0x611375907733D9576907E125Fb29704712F0BAfA", start: '2024-01-09' }, | ||||||||||||||||||
| [CHAIN.ARBITRUM]: { comptroller: "0xBfb69860C91A22A2287df1Ff3Cdf0476c5aab24A", start: '2023-12-04' }, | ||||||||||||||||||
| [CHAIN.ETHEREUM]: { comptroller: "0x60A4570bE892fb41280eDFE9DB75e1a62C70456F", start: '2024-07-07' }, | ||||||||||||||||||
| [CHAIN.ZKLINK]: { comptroller: "0xe6099D924efEf37845867D45E3362731EaF8A98D", start: '2024-08-12' }, | ||||||||||||||||||
| [CHAIN.BSQUARED]: { comptroller: "0xdD9C863197df28f47721107f94eb031b548B5e48", start: '2024-10-18' }, | ||||||||||||||||||
| [CHAIN.CORE]: { comptroller: "0x7f5a7aE2688A7ba6a9B36141335044c058a08b3E", start: '2024-12-13' }, | ||||||||||||||||||
| [CHAIN.BSC]: { comptroller: "0x15B5220024c3242F7D61177D6ff715cfac4909eD", start: '2024-08-31' }, | ||||||||||||||||||
| [CHAIN.BERACHAIN]: { comptroller: "0x16C7d1F9EA48F7DE5E8bc3165A04E8340Da574fA", start: '2025-02-08' }, | ||||||||||||||||||
| [CHAIN.HEMI]: { comptroller: "0xB2fF02eEF85DC4eaE95Ab32AA887E0cC69DF8d8E", start: '2025-03-06' }, | ||||||||||||||||||
| }, | ||||||||||||||||||
| options: { protocolRevenueratio: 1 }, | ||||||||||||||||||
| }, | ||||||||||||||||||
|
Comment on lines
+78
to
81
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo in options key: This typo may cause the option to be silently ignored. 🐛 Fix typo },
- options: { protocolRevenueratio: 1 },
+ options: { protocolRevenueRatio: 1 },
},📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
| "takara-lend": { | ||||||||||||||||||
| comptrollers: { [CHAIN.SEI]: "0x71034bf5eC0FAd7aEE81a213403c8892F3d8CAeE" }, | ||||||||||||||||||
| chains: { [CHAIN.SEI]: { comptroller: "0x71034bf5eC0FAd7aEE81a213403c8892F3d8CAeE", start: '2025-02-13' } }, | ||||||||||||||||||
| options: { useExchangeRate: true, protocolRevenueRatio: 1 }, | ||||||||||||||||||
| }, | ||||||||||||||||||
| "traderjoe-lend": { | ||||||||||||||||||
| comptrollers: { [CHAIN.AVAX]: "0xdc13687554205E5b89Ac783db14bb5bba4A1eDaC" }, | ||||||||||||||||||
| chains: { [CHAIN.AVAX]: { comptroller: "0xdc13687554205E5b89Ac783db14bb5bba4A1eDaC", start: '2021-10-11' } }, | ||||||||||||||||||
| options: { protocolRevenueRatio: 1 }, | ||||||||||||||||||
| }, | ||||||||||||||||||
| "venus-finance": { | ||||||||||||||||||
| comptrollers: { [CHAIN.BSC]: "0xfD36E2c2a6789Db23113685031d7F16329158384", [CHAIN.ETHEREUM]: "0x687a01ecF6d3907658f7A7c714749fAC32336D1B", [CHAIN.OP_BNB]: "0xd6e3e2a1d8d95cae355d15b3b9f8e5c2511874dd", [CHAIN.ARBITRUM]: "0x317c1A5739F39046E20b08ac9BeEa3f10fD43326", [CHAIN.ERA]: "0xddE4D098D9995B659724ae6d5E3FB9681Ac941B1", [CHAIN.BASE]: "0x0C7973F9598AA62f9e03B94E92C967fD5437426C", [CHAIN.OPTIMISM]: "0x5593FF68bE84C966821eEf5F0a988C285D5B7CeC", [CHAIN.UNICHAIN]: "0xe22af1e6b78318e1Fe1053Edbd7209b8Fc62c4Fe" }, | ||||||||||||||||||
| chains: { | ||||||||||||||||||
| [CHAIN.BSC]: { comptroller: "0xfD36E2c2a6789Db23113685031d7F16329158384", start: '2020-11-23' }, | ||||||||||||||||||
| [CHAIN.ETHEREUM]: { comptroller: "0x687a01ecF6d3907658f7A7c714749fAC32336D1B", start: '2024-01-10' }, | ||||||||||||||||||
| [CHAIN.OP_BNB]: { comptroller: "0xd6e3e2a1d8d95cae355d15b3b9f8e5c2511874dd", start: '2024-02-16' }, | ||||||||||||||||||
| [CHAIN.ARBITRUM]: { comptroller: "0x317c1A5739F39046E20b08ac9BeEa3f10fD43326", start: '2024-05-30' }, | ||||||||||||||||||
| [CHAIN.ERA]: { comptroller: "0xddE4D098D9995B659724ae6d5E3FB9681Ac941B1", start: '2024-09-06' }, | ||||||||||||||||||
| [CHAIN.BASE]: { comptroller: "0x0C7973F9598AA62f9e03B94E92C967fD5437426C", start: '2024-12-07' }, | ||||||||||||||||||
| [CHAIN.OPTIMISM]: { comptroller: "0x5593FF68bE84C966821eEf5F0a988C285D5B7CeC", start: '2024-10-01' }, | ||||||||||||||||||
| [CHAIN.UNICHAIN]: { comptroller: "0xe22af1e6b78318e1Fe1053Edbd7209b8Fc62c4Fe", start: '2025-02-08' }, | ||||||||||||||||||
| }, | ||||||||||||||||||
| options: { protocolRevenueRatio: 0.6, holdersRevenueRatio: 0.4 }, | ||||||||||||||||||
| }, | ||||||||||||||||||
| "mare-finance-v2": { | ||||||||||||||||||
| comptrollers: { [CHAIN.KAVA]: "0xFcD7D41D5cfF03C7f6D573c9732B0506C72f5C72" }, | ||||||||||||||||||
| chains: { [CHAIN.KAVA]: { comptroller: "0xFcD7D41D5cfF03C7f6D573c9732B0506C72f5C72", start: '2023-07-13' } }, | ||||||||||||||||||
| }, | ||||||||||||||||||
| "quantus": { | ||||||||||||||||||
| comptrollers: { | ||||||||||||||||||
| [CHAIN.MONAD]: '0xFc57bF0733e5e65d8549fc2922919Cfb97e62D5f', | ||||||||||||||||||
| [CHAIN.MEGAETH]: '0x1F1416EbbeAb7a13fC5B6111A1E77696Be600413', | ||||||||||||||||||
| chains: { | ||||||||||||||||||
| [CHAIN.MONAD]: { comptroller: '0xFc57bF0733e5e65d8549fc2922919Cfb97e62D5f', start: '2025-11-26' }, | ||||||||||||||||||
| [CHAIN.MEGAETH]: { comptroller: '0x1F1416EbbeAb7a13fC5B6111A1E77696Be600413', start: '2026-02-08' }, | ||||||||||||||||||
| }, | ||||||||||||||||||
| }, | ||||||||||||||||||
| }; | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| const feesProtocols: Record<string, any> = {}; | ||||||||||||||||||
| for (const [name, { comptrollers, options }] of Object.entries(feesConfigs)) { | ||||||||||||||||||
| for (const [name, { chains, options }] of Object.entries(configs)) { | ||||||||||||||||||
| const comptrollers: Record<string, string> = {}; | ||||||||||||||||||
| for (const [chain, { comptroller }] of Object.entries(chains)) { | ||||||||||||||||||
| comptrollers[chain] = comptroller; | ||||||||||||||||||
| } | ||||||||||||||||||
| feesProtocols[name] = compoundV2Export(comptrollers, options); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| export const { protocolList, getAdapter } = createFactoryExports(feesProtocols); | ||||||||||||||||||
|
|
||||||||||||||||||
| // Liquidations | ||||||||||||||||||
| type LiquidationConfig = Record<string, { comptroller: string; start?: string }>; | ||||||||||||||||||
|
|
||||||||||||||||||
| const liquidationConfigs: Record<string, LiquidationConfig> = { | ||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment as aave, can keep only the missing protocols here |
||||||||||||||||||
| "compound-v2": { | ||||||||||||||||||
| ethereum: { comptroller: '0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B', start: '2019-05-07' }, | ||||||||||||||||||
| }, | ||||||||||||||||||
| }; | ||||||||||||||||||
|
|
||||||||||||||||||
| for (const [name, { chains }] of Object.entries(configs)) { | ||||||||||||||||||
| const config: LiquidationConfig = {}; | ||||||||||||||||||
| for (const [chain, { comptroller, start }] of Object.entries(chains)) { | ||||||||||||||||||
| config[chain] = { comptroller, start }; | ||||||||||||||||||
| } | ||||||||||||||||||
| if (Object.keys(config).length > 0) { | ||||||||||||||||||
| liquidationConfigs[name] = config; | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| const liquidationProtocols: Record<string, any> = {}; | ||||||||||||||||||
| for (const [name, config] of Object.entries(liquidationConfigs)) { | ||||||||||||||||||
| liquidationProtocols[name] = compoundV2LiquidationsExport(config); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| export const liquidations = createFactoryExports(liquidationProtocols); | ||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Consider consolidating aave-v3 and spark into aaveProtocolConfigs.
These chain configs are handled separately from
aaveProtocolConfigs. If they could be added to the centralized config inhelpers/aave, future additions would automatically be picked up for both fees and liquidations.Would you like me to investigate whether aave-v3 and spark can be integrated into
aaveProtocolConfigs?🤖 Prompt for AI Agents