Skip to content
Merged
Changes from all commits
Commits
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
66 changes: 61 additions & 5 deletions src/adaptors/gearbox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,19 @@ var CHAIN_CONFIGS = {
EXCLUDED_POOLS: {
'0x1dc0f3359a254f876b37906cfc1000a35ce2d717': 'USDT V3 Broken',
},
// Ethereum KPK (PoolQuotaKeeper) pools that need manual configuration
POOLS: {
'0xa9d17f6d3285208280a1fd9b94479c62e0aaba64': {
symbol: 'wstETH',
underlying: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0', // wstETH
name: 'kpk wstETH',
},
'0x9396dcbf78fc526bb003665337c5e73b699571ef': {
symbol: 'ETH',
underlying: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', // WETH
name: 'kpk ETH',
},
},
},
plasma: {
ADDRESS_PROVIDER_V3: null, // Plasma uses individual pool approach
Expand All @@ -349,7 +362,17 @@ var CHAIN_CONFIGS = {
'0x76309A9a56309104518847BbA321c261B7B4a43f': {
symbol: 'dUSDT0',
underlying: '0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb', // USDT0 deposit token
name: 'USDT0 Lending Pool',
name: 'Invariant USDT0',
},
'0x53e4e9b8766969c43895839cc9c673bb6bc8ac97': {
symbol: 'USDT0 v3',
underlying: '0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb', // USDT0
name: 'Edge UltraYield',
},
'0xb74760fd26400030620027dd29d19d74d514700e': {
symbol: 'hyperGearboxUSDT',
underlying: '0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb', // USDT0
name: 'Hyperithm Gearbox USDT',
},
},
},
Expand Down Expand Up @@ -471,12 +494,18 @@ const MERKL_CONFIGS = {
'0x05A811275fE9b4DE503B3311F51edF6A856D936e', // USDT
'0x4d56c9cBa373AD39dF69Eb18F076b7348000AE09', // GHO
'0x72CCB97cbdC40f8fb7FFA42Ed93AE74923547200', // wstETH (with Merkl rewards)
'0xa9d17f6d3285208280a1fd9b94479c62e0aaba64', // KPK wstETH
'0x9396dcbf78fc526bb003665337c5e73b699571ef', // KPK ETH
],
},
plasma: {
chainId: 9745,
poolId: '0x76309A9a56309104518847BbA321c261B7B4a43f',
rewardToken: '0x6100e367285b01f48d07953803a2d8dca5d19873', // WXPL
pools: [
'0x76309A9a56309104518847BbA321c261B7B4a43f', // Invariant USDT0 (existing)
'0xB74760FD26400030620027DD29D19d74D514700e', // Hyperithm Gearbox
'0x53E4e9b8766969c43895839CC9c673bb6bC8Ac97', // Edge UltraYield
],
},
etlk: {
chainId: 42793,
Expand Down Expand Up @@ -717,6 +746,18 @@ async function getPoolsV3(chain) {
return await getPlasmaPoolsV3(chain);
}

const chainConfig = CHAIN_CONFIGS[chain];

// Check if there are manual pools configured for this chain
const manualPools = chainConfig?.POOLS || {};
const hasManualPools = Object.keys(manualPools).length > 0;

// If there are manual pools, fetch them using the Plasma approach
let manualPoolsData = [];
if (hasManualPools) {
manualPoolsData = await getPlasmaPoolsV3(chain);
}

// Original Ethereum implementation with registry
const stakedDieselTokens = [
'0x9ef444a6d7F4A5adcd68FD5329aA5240C90E14d2',
Expand Down Expand Up @@ -762,7 +803,6 @@ async function getPoolsV3(chain) {
},
};
}
const chainConfig = CHAIN_CONFIGS[chain];
const dc300 = await call({
abi: abis_default.getAddressOrRevert,
target: chainConfig.ADDRESS_PROVIDER_V3,
Expand All @@ -785,7 +825,7 @@ async function getPoolsV3(chain) {
})),
chain,
});
return pools
const registryPools = pools
.map((pool, i) => ({
pool: pool.addr,
name: pool.name,
Expand All @@ -801,10 +841,26 @@ async function getPoolsV3(chain) {
...farmingPoolsData[pool.addr],
}))
.filter(({ pool }) => {
const chainConfig = CHAIN_CONFIGS[chain];
const excludedPools = chainConfig?.EXCLUDED_POOLS || {};
return !excludedPools[pool.toLowerCase()];
});

// Merge registry pools with manual pools, with manual pools taking precedence
if (hasManualPools) {
const poolMap = new Map();
// Add registry pools first
for (const pool of registryPools) {
poolMap.set(pool.pool.toLowerCase(), pool);
}
// Add or override with manual pools
for (const pool of manualPoolsData) {
const key = pool.pool.toLowerCase();
poolMap.set(key, { ...(poolMap.get(key) || {}), ...pool });
}
return Array.from(poolMap.values());
}

return registryPools;
}
async function getTokensData(chain, pools) {
// For non-registry chains, we need to use known token addresses for pricing
Expand Down
Loading