Skip to content

Commit 7f9c8eb

Browse files
Hiksangclaude
andcommitted
Replace KittenSwap KNOWN_NONCES with dynamic multicall scan
- Remove all hardcoded pool→nonce mappings - Dynamic discovery: 55 token pairs × poolByPair → nonce 0-60 scan - All via multicall (2 RPC calls: pool lookup + nonce batch) - Runtime nonce cache (Map) for repeat queries - 16 active farming pools found (was 3 hardcoded) - 11 tokens in scan list (WHYPE, USDC, USDT0, UETH, UBTC, USDH, USDe, sUSDe, XAUt0, kHYPE, KITTEN) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9f81f75 commit 7f9c8eb

11 files changed

Lines changed: 1112 additions & 604 deletions

File tree

‎ts/packages/defi-cli/dist/index.js‎

Lines changed: 219 additions & 119 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎ts/packages/defi-cli/dist/index.js.map‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎ts/packages/defi-cli/dist/main.js‎

Lines changed: 219 additions & 119 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎ts/packages/defi-cli/dist/main.js.map‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎ts/packages/defi-cli/dist/mcp-server.js‎

Lines changed: 220 additions & 120 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎ts/packages/defi-cli/dist/mcp-server.js.map‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎ts/packages/defi-protocols/dist/index.d.ts‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,14 @@ declare class KittenSwapFarmingAdapter {
127127
private readonly eternalFarming;
128128
private readonly positionManager;
129129
private readonly rpcUrl;
130-
constructor(protocolName: string, farmingCenter: Address, eternalFarming: Address, positionManager: Address, rpcUrl: string);
130+
private readonly factory;
131+
constructor(protocolName: string, farmingCenter: Address, eternalFarming: Address, positionManager: Address, rpcUrl: string, factory?: Address);
131132
name(): string;
132133
/**
133134
* Discover the active IncentiveKey for a given pool.
134135
* 1. Check runtime cache
135-
* 2. Read numOfIncentives() for max nonce
136-
* 3. Batch-query via Multicall3 in reverse order (newest first)
137-
* 4. Return first active (non-deactivated, totalReward > 0) incentive
136+
* 2. Batch-query nonces 0-60 via single multicall (61 calls)
137+
* 3. Return first non-zero incentive (totalReward > 0 and not deactivated)
138138
*/
139139
discoverIncentiveKey(pool: Address): Promise<IncentiveKey | null>;
140140
/**
@@ -168,9 +168,13 @@ declare class KittenSwapFarmingAdapter {
168168
bonusReward: bigint;
169169
}>;
170170
/**
171-
* Discover all pools with active farming incentives.
172-
* Dynamically scans all nonces (0..numOfIncentives) via Multicall3 and
173-
* groups results by pool. Only returns the latest active incentive per pool.
171+
* Discover all KittenSwap pools with active farming incentives.
172+
*
173+
* Steps:
174+
* 1. Generate all unique token pair combos from HYPEREVM_TOKENS (includes KITTEN)
175+
* 2. Batch poolByPair calls via multicall against the Algebra factory
176+
* 3. For each found pool, batch-scan nonces 0-60 via multicall
177+
* 4. Return enriched FarmingPool[] for pools with active incentives
174178
*/
175179
discoverFarmingPools(): Promise<FarmingPool[]>;
176180
}

0 commit comments

Comments
 (0)