Skip to content
Merged
Show file tree
Hide file tree
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
19 changes: 19 additions & 0 deletions src/models/strategyContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> {
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).
*/
Expand Down
12 changes: 6 additions & 6 deletions src/strategies/lp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
),
),
Expand Down Expand Up @@ -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',
),
),
Expand Down
2 changes: 1 addition & 1 deletion src/utils/poolMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const POOL_REGISTRY: Record<string, ProtocolPoolIds> = {
},
[getCanonicalPairKey(
'0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI',
'0x27792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881::coin::COIN',
'0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881::coin::COIN',
)]: {
bluefin: '0xe71aa89df60e737f1b687f8dfbd51e2a9b35706e9e5540ce9b053bd53fcb9ec3',
cetus: '0xe0c526aa27d1729931d0051a318d795ad0299998898e4287d9da1bf095b49658',
Expand Down
Loading