diff --git a/src/models/strategyContext.ts b/src/models/strategyContext.ts index 1481499..9c7e4d7 100644 --- a/src/models/strategyContext.ts +++ b/src/models/strategyContext.ts @@ -660,6 +660,25 @@ export class StrategyContext { return poolId; } + /** + * Get pool ID by coin types and protocol. + */ + async getPoolIdByTypesAndProtocol( + typeA: string, + typeB: string, + protocol: 'cetus' | 'bluefin' | 'mmt', + fixCoinTypes?: boolean, + ): Promise { + const poolIds = await this.getPoolIdsByTypes(typeA, typeB, fixCoinTypes); + const poolId = poolIds[protocol]; + if (!poolId) { + throw new Error( + `Pool for protocol: ${protocol} not found for coin pair: ${typeA} or ${typeB}`, + ); + } + return poolId; + } + /** * Lookup pool IDs by coin symbols (order-agnostic). */ diff --git a/src/strategies/lp.ts b/src/strategies/lp.ts index cf56ee3..167f56c 100644 --- a/src/strategies/lp.ts +++ b/src/strategies/lp.ts @@ -590,9 +590,9 @@ export class LpStrategy extends BaseStrategy< ), ), tx.object( - await this.context.getPoolIdBySymbolsAndProtocol( - this.poolLabel.assetA.name, - this.poolLabel.assetB.name, + await this.context.getPoolIdByTypesAndProtocol( + this.poolLabel.assetA.type, + this.poolLabel.assetB.type, 'cetus', ), ), @@ -663,9 +663,9 @@ export class LpStrategy extends BaseStrategy< ), ), tx.object( - await this.context.getPoolIdBySymbolsAndProtocol( - this.poolLabel.assetA.name, - this.poolLabel.assetB.name, + await this.context.getPoolIdByTypesAndProtocol( + this.poolLabel.assetA.type, + this.poolLabel.assetB.type, 'cetus', ), ), diff --git a/src/utils/poolMap.ts b/src/utils/poolMap.ts index a1aae0d..0dbb356 100644 --- a/src/utils/poolMap.ts +++ b/src/utils/poolMap.ts @@ -45,7 +45,7 @@ export const POOL_REGISTRY: Record = { }, [getCanonicalPairKey( '0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI', - '0x27792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881::coin::COIN', + '0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881::coin::COIN', )]: { bluefin: '0xe71aa89df60e737f1b687f8dfbd51e2a9b35706e9e5540ce9b053bd53fcb9ec3', cetus: '0xe0c526aa27d1729931d0051a318d795ad0299998898e4287d9da1bf095b49658',