diff --git a/packages/swapper/src/okx/constants.ts b/packages/swapper/src/okx/constants.ts index e2a4526..a6088ae 100644 --- a/packages/swapper/src/okx/constants.ts +++ b/packages/swapper/src/okx/constants.ts @@ -2,9 +2,27 @@ import { Chain } from "@gemwallet/types"; export const CHAIN_INDEX: Record = { [Chain.Solana]: "501", + [Chain.Ethereum]: "1", + [Chain.SmartChain]: "56", + [Chain.Polygon]: "137", + [Chain.Arbitrum]: "42161", + [Chain.Optimism]: "10", [Chain.Base]: "8453", + [Chain.AvalancheC]: "43114", + [Chain.OpBNB]: "204", + [Chain.Fantom]: "250", + [Chain.Gnosis]: "100", [Chain.Manta]: "169", + [Chain.Blast]: "81457", + [Chain.ZkSync]: "324", + [Chain.Linea]: "59144", [Chain.Mantle]: "5000", + [Chain.Celo]: "42220", + [Chain.Sonic]: "146", + [Chain.Abstract]: "2741", + [Chain.Berachain]: "80094", + [Chain.Unichain]: "130", + [Chain.Monad]: "143", [Chain.XLayer]: "196", }; @@ -31,13 +49,13 @@ export const SOLANA_CHAIN_INDEX = CHAIN_INDEX[Chain.Solana]; export const SOLANA_NATIVE_TOKEN_ADDRESS = "11111111111111111111111111111111"; export const SOLANA_DEX_IDS_PARAM = SOLANA_DEX_IDS.join(","); export const DEFAULT_SLIPPAGE_PERCENT = "1"; +export const DEFAULT_EVM_GAS_LIMIT = "920000"; const EVM_GAS_LIMITS: Partial> = { - [Chain.Base]: "800000", [Chain.Manta]: "600000", + [Chain.ZkSync]: "2000000", [Chain.Mantle]: "2000000000", - [Chain.XLayer]: "800000", }; -export function evmGasLimit(chain: Chain): string | undefined { - return EVM_GAS_LIMITS[chain]; +export function evmGasLimit(chain: Chain): string { + return EVM_GAS_LIMITS[chain] ?? DEFAULT_EVM_GAS_LIMIT; } diff --git a/packages/swapper/src/okx/integration.test.ts b/packages/swapper/src/okx/integration.test.ts index 88e7ca3..e80a8e6 100644 --- a/packages/swapper/src/okx/integration.test.ts +++ b/packages/swapper/src/okx/integration.test.ts @@ -5,7 +5,7 @@ import { Chain, QuoteRequest } from "@gemwallet/types"; import { createOkxEvmQuoteRequest, createSolanaUsdcQuoteRequest } from "../testkit/mock"; import { OkxDexClient } from "./client"; -import { CHAIN_INDEX } from "./constants"; +import { CHAIN_INDEX, DEFAULT_EVM_GAS_LIMIT } from "./constants"; import { OkxProvider } from "./provider"; const OKX_ENV_KEYS = ["OKX_API_KEY", "OKX_SECRET_KEY", "OKX_API_PASSPHRASE", "OKX_PROJECT_ID"]; @@ -88,7 +88,7 @@ describe("OKX live integration", () => { expect(quoteData.dataType).toBe("contract"); expect(quoteData.data).toMatch(/^0x/); - expect(quoteData.gasLimit).toBe("800000"); + expect(quoteData.gasLimit).toBe(DEFAULT_EVM_GAS_LIMIT); expect(quoteData.approval).toBeUndefined(); }); }); diff --git a/packages/swapper/src/okx/provider.test.ts b/packages/swapper/src/okx/provider.test.ts index 626c37e..d44a86f 100644 --- a/packages/swapper/src/okx/provider.test.ts +++ b/packages/swapper/src/okx/provider.test.ts @@ -7,6 +7,7 @@ import { XLAYER_USD0_ADDRESS, } from "../testkit/mock"; import type { OkxDexClient } from "./client"; +import { DEFAULT_EVM_GAS_LIMIT } from "./constants"; import { OkxProvider } from "./provider"; const SOL_MINT = "11111111111111111111111111111111"; @@ -255,7 +256,7 @@ describe("OkxProvider", () => { expect(result.data).toBe("0xswapCalldata"); expect(result.value).toBe("0"); - expect(result.gasLimit).toBe("800000"); + expect(result.gasLimit).toBe(DEFAULT_EVM_GAS_LIMIT); expect(result.approval).toEqual({ token: XLAYER_USD0_ADDRESS, spender: MOCK_APPROVE_ADDRESS,