Skip to content

Commit dbe63fb

Browse files
authored
Merge pull request #2169 from alex0xhodler/gearbox/add-kpk-and-more-plasma-pools
Gearbox update: add kpk and more plasma pools
2 parents 58515e8 + 4fddc45 commit dbe63fb

File tree

1 file changed

+61
-5
lines changed

1 file changed

+61
-5
lines changed

src/adaptors/gearbox/index.js

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,19 @@ var CHAIN_CONFIGS = {
338338
EXCLUDED_POOLS: {
339339
'0x1dc0f3359a254f876b37906cfc1000a35ce2d717': 'USDT V3 Broken',
340340
},
341+
// Ethereum KPK (PoolQuotaKeeper) pools that need manual configuration
342+
POOLS: {
343+
'0xa9d17f6d3285208280a1fd9b94479c62e0aaba64': {
344+
symbol: 'wstETH',
345+
underlying: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0', // wstETH
346+
name: 'kpk wstETH',
347+
},
348+
'0x9396dcbf78fc526bb003665337c5e73b699571ef': {
349+
symbol: 'ETH',
350+
underlying: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', // WETH
351+
name: 'kpk ETH',
352+
},
353+
},
341354
},
342355
plasma: {
343356
ADDRESS_PROVIDER_V3: null, // Plasma uses individual pool approach
@@ -349,7 +362,17 @@ var CHAIN_CONFIGS = {
349362
'0x76309A9a56309104518847BbA321c261B7B4a43f': {
350363
symbol: 'dUSDT0',
351364
underlying: '0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb', // USDT0 deposit token
352-
name: 'USDT0 Lending Pool',
365+
name: 'Invariant USDT0',
366+
},
367+
'0x53e4e9b8766969c43895839cc9c673bb6bc8ac97': {
368+
symbol: 'USDT0 v3',
369+
underlying: '0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb', // USDT0
370+
name: 'Edge UltraYield',
371+
},
372+
'0xb74760fd26400030620027dd29d19d74d514700e': {
373+
symbol: 'hyperGearboxUSDT',
374+
underlying: '0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb', // USDT0
375+
name: 'Hyperithm Gearbox USDT',
353376
},
354377
},
355378
},
@@ -471,12 +494,18 @@ const MERKL_CONFIGS = {
471494
'0x05A811275fE9b4DE503B3311F51edF6A856D936e', // USDT
472495
'0x4d56c9cBa373AD39dF69Eb18F076b7348000AE09', // GHO
473496
'0x72CCB97cbdC40f8fb7FFA42Ed93AE74923547200', // wstETH (with Merkl rewards)
497+
'0xa9d17f6d3285208280a1fd9b94479c62e0aaba64', // KPK wstETH
498+
'0x9396dcbf78fc526bb003665337c5e73b699571ef', // KPK ETH
474499
],
475500
},
476501
plasma: {
477502
chainId: 9745,
478-
poolId: '0x76309A9a56309104518847BbA321c261B7B4a43f',
479503
rewardToken: '0x6100e367285b01f48d07953803a2d8dca5d19873', // WXPL
504+
pools: [
505+
'0x76309A9a56309104518847BbA321c261B7B4a43f', // Invariant USDT0 (existing)
506+
'0xB74760FD26400030620027DD29D19d74D514700e', // Hyperithm Gearbox
507+
'0x53E4e9b8766969c43895839CC9c673bb6bC8Ac97', // Edge UltraYield
508+
],
480509
},
481510
etlk: {
482511
chainId: 42793,
@@ -717,6 +746,18 @@ async function getPoolsV3(chain) {
717746
return await getPlasmaPoolsV3(chain);
718747
}
719748

749+
const chainConfig = CHAIN_CONFIGS[chain];
750+
751+
// Check if there are manual pools configured for this chain
752+
const manualPools = chainConfig?.POOLS || {};
753+
const hasManualPools = Object.keys(manualPools).length > 0;
754+
755+
// If there are manual pools, fetch them using the Plasma approach
756+
let manualPoolsData = [];
757+
if (hasManualPools) {
758+
manualPoolsData = await getPlasmaPoolsV3(chain);
759+
}
760+
720761
// Original Ethereum implementation with registry
721762
const stakedDieselTokens = [
722763
'0x9ef444a6d7F4A5adcd68FD5329aA5240C90E14d2',
@@ -762,7 +803,6 @@ async function getPoolsV3(chain) {
762803
},
763804
};
764805
}
765-
const chainConfig = CHAIN_CONFIGS[chain];
766806
const dc300 = await call({
767807
abi: abis_default.getAddressOrRevert,
768808
target: chainConfig.ADDRESS_PROVIDER_V3,
@@ -785,7 +825,7 @@ async function getPoolsV3(chain) {
785825
})),
786826
chain,
787827
});
788-
return pools
828+
const registryPools = pools
789829
.map((pool, i) => ({
790830
pool: pool.addr,
791831
name: pool.name,
@@ -801,10 +841,26 @@ async function getPoolsV3(chain) {
801841
...farmingPoolsData[pool.addr],
802842
}))
803843
.filter(({ pool }) => {
804-
const chainConfig = CHAIN_CONFIGS[chain];
805844
const excludedPools = chainConfig?.EXCLUDED_POOLS || {};
806845
return !excludedPools[pool.toLowerCase()];
807846
});
847+
848+
// Merge registry pools with manual pools, with manual pools taking precedence
849+
if (hasManualPools) {
850+
const poolMap = new Map();
851+
// Add registry pools first
852+
for (const pool of registryPools) {
853+
poolMap.set(pool.pool.toLowerCase(), pool);
854+
}
855+
// Add or override with manual pools
856+
for (const pool of manualPoolsData) {
857+
const key = pool.pool.toLowerCase();
858+
poolMap.set(key, { ...(poolMap.get(key) || {}), ...pool });
859+
}
860+
return Array.from(poolMap.values());
861+
}
862+
863+
return registryPools;
808864
}
809865
async function getTokensData(chain, pools) {
810866
// For non-registry chains, we need to use known token addresses for pricing

0 commit comments

Comments
 (0)