UNPKG

kirapay-axelar-sdk

Version:

TypeScript SDK for cross-chain swaps with CCIP and Axelar bridges

1,433 lines (1,432 loc) 39.2 kB
export const QUOTER_V2_ABI = [ { type: "function", name: "quoteExactInputSingle", stateMutability: "nonpayable", inputs: [ { name: "tokenIn", type: "address" }, { name: "tokenOut", type: "address" }, { name: "amountIn", type: "uint256" }, { name: "fee", type: "uint24" }, { name: "sqrtPriceLimitX96", type: "uint160" }, ], outputs: [ { name: "amountOut", type: "uint256" }, { name: "sqrtPriceX96After", type: "uint160" }, { name: "initializedTicksCrossed", type: "uint32" }, { name: "gasEstimate", type: "uint256" }, ], }, { type: "function", name: "quoteExactInput", stateMutability: "nonpayable", inputs: [ { name: "path", type: "bytes" }, { name: "amountIn", type: "uint256" }, ], outputs: [ { name: "amountOut", type: "uint256" }, { name: "sqrtPriceX96After", type: "uint160" }, { name: "initializedTicksCrossed", type: "uint32" }, { name: "gasEstimate", type: "uint256" }, ], }, ]; export const ERC20_ABI = [ { type: "function", name: "allowance", stateMutability: "view", inputs: [ { name: "owner", type: "address" }, { name: "spender", type: "address" }, ], outputs: [{ type: "uint256" }], }, { type: "function", name: "approve", stateMutability: "nonpayable", inputs: [ { name: "spender", type: "address" }, { name: "amount", type: "uint256" }, ], outputs: [{ type: "bool" }], }, ]; export const CCIP_SEND_REQUESTED_ABI = [ { type: "event", name: "CCIPSendRequested", inputs: [ { name: "message", type: "tuple", components: [ { name: "sourceChainSelector", type: "uint64" }, { name: "sender", type: "address" }, { name: "receiver", type: "address" }, { name: "sequenceNumber", type: "uint64" }, { name: "gasLimit", type: "uint256" }, { name: "strict", type: "bool" }, { name: "nonce", type: "uint64" }, { name: "feeToken", type: "address" }, { name: "feeTokenAmount", type: "uint256" }, { name: "data", type: "bytes" }, { name: "tokenAmounts", type: "tuple[]", components: [ { name: "token", type: "address" }, { name: "amount", type: "uint256" }, ], }, { name: "sourceTokenData", type: "bytes[]" }, { name: "messageId", type: "bytes32" }, ], }, ], }, ]; export const UNIFIED_BRIDGE_WITH_SWAPS_ABI = [ { inputs: [], stateMutability: "nonpayable", type: "constructor", }, { inputs: [ { internalType: "address", name: "target", type: "address", }, ], name: "AddressEmptyCode", type: "error", }, { inputs: [], name: "ContractPaused", type: "error", }, { inputs: [ { internalType: "uint256", name: "deadline", type: "uint256", }, { internalType: "uint256", name: "currentTime", type: "uint256", }, ], name: "DeadlineExceeded", type: "error", }, { inputs: [ { internalType: "address", name: "implementation", type: "address", }, ], name: "ERC1967InvalidImplementation", type: "error", }, { inputs: [], name: "ERC1967NonPayable", type: "error", }, { inputs: [], name: "FailedCall", type: "error", }, { inputs: [ { internalType: "uint256", name: "required", type: "uint256", }, { internalType: "uint256", name: "provided", type: "uint256", }, ], name: "InsufficientFunds", type: "error", }, { inputs: [], name: "InsufficientGasFee", type: "error", }, { inputs: [], name: "InsufficientOutputAmount", type: "error", }, { inputs: [ { internalType: "uint256", name: "actual", type: "uint256", }, { internalType: "uint256", name: "minimum", type: "uint256", }, ], name: "InsufficientSwapOutput", type: "error", }, { inputs: [], name: "InvalidInitialization", type: "error", }, { inputs: [], name: "InvalidPayload", type: "error", }, { inputs: [], name: "InvalidSwapPath", type: "error", }, { inputs: [ { internalType: "bytes32", name: "messageId", type: "bytes32", }, ], name: "MessageAlreadyProcessed", type: "error", }, { inputs: [], name: "NotInitializing", type: "error", }, { inputs: [ { internalType: "address", name: "owner", type: "address", }, ], name: "OwnableInvalidOwner", type: "error", }, { inputs: [ { internalType: "address", name: "account", type: "address", }, ], name: "OwnableUnauthorizedAccount", type: "error", }, { inputs: [], name: "ReentrancyGuardReentrantCall", type: "error", }, { inputs: [ { internalType: "bytes32", name: "routeId", type: "bytes32", }, ], name: "RouteAlreadyProcessed", type: "error", }, { inputs: [ { internalType: "address", name: "token", type: "address", }, ], name: "SafeERC20FailedOperation", type: "error", }, { inputs: [ { internalType: "string", name: "reason", type: "string", }, ], name: "SwapFailed", type: "error", }, { inputs: [], name: "UUPSUnauthorizedCallContext", type: "error", }, { inputs: [ { internalType: "bytes32", name: "slot", type: "bytes32", }, ], name: "UUPSUnsupportedProxiableUUID", type: "error", }, { inputs: [ { internalType: "uint64", name: "chainSelector", type: "uint64", }, { internalType: "address", name: "sender", type: "address", }, ], name: "UnauthorizedSender", type: "error", }, { inputs: [], name: "ZeroAddress", type: "error", }, { anonymous: false, inputs: [ { indexed: true, internalType: "bytes32", name: "routeId", type: "bytes32", }, { indexed: true, internalType: "address", name: "recipient", type: "address", }, { indexed: false, internalType: "address", name: "token", type: "address", }, { indexed: false, internalType: "uint256", name: "amount", type: "uint256", }, { indexed: false, internalType: "string", name: "reason", type: "string", }, ], name: "DestinationSwapFailed", type: "event", }, { anonymous: false, inputs: [ { indexed: false, internalType: "uint64", name: "version", type: "uint64", }, ], name: "Initialized", type: "event", }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "previousOwner", type: "address", }, { indexed: true, internalType: "address", name: "newOwner", type: "address", }, ], name: "OwnershipTransferred", type: "event", }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "recipient", type: "address", }, { indexed: false, internalType: "address", name: "tokenIn", type: "address", }, { indexed: false, internalType: "address", name: "tokenOut", type: "address", }, { indexed: false, internalType: "uint256", name: "amountIn", type: "uint256", }, { indexed: false, internalType: "uint256", name: "amountOut", type: "uint256", }, { indexed: true, internalType: "bytes32", name: "routeId", type: "bytes32", }, ], name: "ReceiveAndSwap", type: "event", }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "sender", type: "address", }, { indexed: false, internalType: "address", name: "tokenIn", type: "address", }, { indexed: false, internalType: "address", name: "tokenOut", type: "address", }, { indexed: false, internalType: "uint256", name: "amountIn", type: "uint256", }, { indexed: false, internalType: "uint256", name: "amountOut", type: "uint256", }, { indexed: true, internalType: "uint64", name: "destinationChainSelector", type: "uint64", }, { indexed: true, internalType: "bytes32", name: "routeId", type: "bytes32", }, ], name: "SwapAndBridge", type: "event", }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "tokenIn", type: "address", }, { indexed: true, internalType: "address", name: "tokenOut", type: "address", }, { indexed: false, internalType: "uint256", name: "amountIn", type: "uint256", }, { indexed: false, internalType: "uint256", name: "amountOut", type: "uint256", }, { indexed: true, internalType: "address", name: "recipient", type: "address", }, ], name: "SwapExecuted", type: "event", }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "implementation", type: "address", }, ], name: "Upgraded", type: "event", }, { inputs: [], name: "UPGRADE_INTERFACE_VERSION", outputs: [ { internalType: "string", name: "", type: "string", }, ], stateMutability: "view", type: "function", }, { inputs: [], name: "USDC", outputs: [ { internalType: "contract IERC20", name: "", type: "address", }, ], stateMutability: "view", type: "function", }, { inputs: [], name: "VERSION", outputs: [ { internalType: "uint256", name: "", type: "uint256", }, ], stateMutability: "view", type: "function", }, { inputs: [ { internalType: "address", name: "receivedToken", type: "address", }, { internalType: "address[]", name: "destPath", type: "address[]", }, { components: [ { internalType: "uint24", name: "fee", type: "uint24", }, { internalType: "int24", name: "tickSpacing", type: "int24", }, { internalType: "address", name: "hooks", type: "address", }, ], internalType: "struct PoolParams[]", name: "destPoolParams", type: "tuple[]", }, { internalType: "uint256", name: "amount", type: "uint256", }, { internalType: "uint256", name: "minAmountOut", type: "uint256", }, { internalType: "uint256", name: "deadline", type: "uint256", }, { internalType: "enum SwapVersion", name: "destSwapVersion", type: "uint8", }, { internalType: "address", name: "tokenOut", type: "address", }, ], name: "_executeDestinationSwap", outputs: [ { internalType: "uint256", name: "outputAmount", type: "uint256", }, ], stateMutability: "nonpayable", type: "function", }, { inputs: [ { internalType: "uint64", name: "chainSelector", type: "uint64", }, { internalType: "address", name: "sender", type: "address", }, ], name: "addAuthorizedSender", outputs: [], stateMutability: "nonpayable", type: "function", }, { inputs: [ { internalType: "uint64", name: "", type: "uint64", }, { internalType: "address", name: "", type: "address", }, ], name: "authorizedSenders", outputs: [ { internalType: "bool", name: "", type: "bool", }, ], stateMutability: "view", type: "function", }, { inputs: [], name: "bridgeAsset", outputs: [ { internalType: "contract IERC20", name: "", type: "address", }, ], stateMutability: "view", type: "function", }, { inputs: [ { components: [ { internalType: "string", name: "destinationChain", type: "string", }, { internalType: "uint64", name: "destinationChainSelector", type: "uint64", }, { internalType: "string", name: "destinationContract", type: "string", }, { internalType: "address", name: "recipient", type: "address", }, { internalType: "bytes32", name: "routeId", type: "bytes32", }, { internalType: "uint256", name: "deadline", type: "uint256", }, { internalType: "address[]", name: "srcPath", type: "address[]", }, { components: [ { internalType: "uint24", name: "fee", type: "uint24", }, { internalType: "int24", name: "tickSpacing", type: "int24", }, { internalType: "address", name: "hooks", type: "address", }, ], internalType: "struct PoolParams[]", name: "srcPoolParams", type: "tuple[]", }, { internalType: "enum SwapVersion", name: "srcSwapVersion", type: "uint8", }, { internalType: "uint256", name: "inputAmount", type: "uint256", }, { internalType: "uint256", name: "minBridgeAmount", type: "uint256", }, { internalType: "bool", name: "shouldSwapOnDest", type: "bool", }, { internalType: "address[]", name: "destPath", type: "address[]", }, { components: [ { internalType: "uint24", name: "fee", type: "uint24", }, { internalType: "int24", name: "tickSpacing", type: "int24", }, { internalType: "address", name: "hooks", type: "address", }, ], internalType: "struct PoolParams[]", name: "destPoolParams", type: "tuple[]", }, { internalType: "enum SwapVersion", name: "destSwapVersion", type: "uint8", }, { internalType: "uint256", name: "minAmountOut", type: "uint256", }, ], internalType: "struct UniversalSwapBase.SwapParams", name: "params", type: "tuple", }, ], name: "bridgeWithSwap", outputs: [], stateMutability: "payable", type: "function", }, { inputs: [ { components: [ { internalType: "bytes32", name: "messageId", type: "bytes32", }, { internalType: "uint64", name: "sourceChainSelector", type: "uint64", }, { internalType: "bytes", name: "sender", type: "bytes", }, { internalType: "bytes", name: "data", type: "bytes", }, { components: [ { internalType: "address", name: "token", type: "address", }, { internalType: "uint256", name: "amount", type: "uint256", }, ], internalType: "struct ICCIPReceiver.EVMTokenAmount[]", name: "destTokenAmounts", type: "tuple[]", }, ], internalType: "struct ICCIPReceiver.Any2EVMMessage", name: "message", type: "tuple", }, ], name: "ccipReceive", outputs: [], stateMutability: "nonpayable", type: "function", }, { inputs: [], name: "ccipRouter", outputs: [ { internalType: "contract ICCIPRouter", name: "", type: "address", }, ], stateMutability: "view", type: "function", }, { inputs: [ { internalType: "address", name: "token", type: "address", }, { internalType: "uint256", name: "amount", type: "uint256", }, ], name: "emergencyWithdraw", outputs: [], stateMutability: "nonpayable", type: "function", }, { inputs: [ { internalType: "uint64", name: "destinationChainSelector", type: "uint64", }, { components: [ { internalType: "address", name: "recipient", type: "address", }, { internalType: "bytes32", name: "routeId", type: "bytes32", }, { internalType: "uint256", name: "deadline", type: "uint256", }, { internalType: "bool", name: "shouldSwapOnDest", type: "bool", }, { internalType: "address", name: "tokenOut", type: "address", }, { internalType: "uint256", name: "minAmountOut", type: "uint256", }, { internalType: "enum SwapVersion", name: "swapVersion", type: "uint8", }, { internalType: "bytes", name: "extraData", type: "bytes", }, ], internalType: "struct UnifiedCCIPBridgeWithSwaps.BridgePayload", name: "payload", type: "tuple", }, { internalType: "uint256", name: "bridgeAmount", type: "uint256", }, ], name: "getFee", outputs: [ { internalType: "uint256", name: "fee", type: "uint256", }, ], stateMutability: "view", type: "function", }, { inputs: [ { internalType: "address", name: "_ccipRouter", type: "address", }, { internalType: "address", name: "_universalRouter", type: "address", }, { internalType: "address", name: "_weth", type: "address", }, { internalType: "address", name: "_usdc", type: "address", }, { internalType: "address", name: "_bridgeAsset", type: "address", }, { internalType: "address", name: "_owner", type: "address", }, ], name: "initialize", outputs: [], stateMutability: "nonpayable", type: "function", }, { inputs: [], name: "owner", outputs: [ { internalType: "address", name: "", type: "address", }, ], stateMutability: "view", type: "function", }, { inputs: [], name: "pause", outputs: [], stateMutability: "nonpayable", type: "function", }, { inputs: [], name: "paused", outputs: [ { internalType: "bool", name: "", type: "bool", }, ], stateMutability: "view", type: "function", }, { inputs: [ { internalType: "bytes32", name: "", type: "bytes32", }, ], name: "processedMessages", outputs: [ { internalType: "bool", name: "", type: "bool", }, ], stateMutability: "view", type: "function", }, { inputs: [ { internalType: "bytes32", name: "", type: "bytes32", }, ], name: "processedRoutes", outputs: [ { internalType: "bool", name: "", type: "bool", }, ], stateMutability: "view", type: "function", }, { inputs: [], name: "proxiableUUID", outputs: [ { internalType: "bytes32", name: "", type: "bytes32", }, ], stateMutability: "view", type: "function", }, { inputs: [ { internalType: "uint64", name: "chainSelector", type: "uint64", }, { internalType: "address", name: "sender", type: "address", }, ], name: "removeAuthorizedSender", outputs: [], stateMutability: "nonpayable", type: "function", }, { inputs: [], name: "renounceOwnership", outputs: [], stateMutability: "nonpayable", type: "function", }, { inputs: [], name: "swapRouter", outputs: [ { internalType: "contract ISwapRouter", name: "", type: "address", }, ], stateMutability: "view", type: "function", }, { inputs: [ { internalType: "address", name: "newOwner", type: "address", }, ], name: "transferOwnership", outputs: [], stateMutability: "nonpayable", type: "function", }, { inputs: [], name: "universalRouter", outputs: [ { internalType: "contract IUniversalRouter", name: "", type: "address", }, ], stateMutability: "view", type: "function", }, { inputs: [], name: "unpause", outputs: [], stateMutability: "nonpayable", type: "function", }, { inputs: [ { internalType: "address", name: "newImplementation", type: "address", }, { internalType: "bytes", name: "data", type: "bytes", }, ], name: "upgradeToAndCall", outputs: [], stateMutability: "payable", type: "function", }, { inputs: [], name: "weth", outputs: [ { internalType: "contract IWeth", name: "", type: "address", }, ], stateMutability: "view", type: "function", }, { stateMutability: "payable", type: "receive", }, ]; export const UNISWAP_V3_ROUTER_ABI = [ { type: "function", name: "exactInput", stateMutability: "payable", inputs: [ { name: "params", type: "tuple", components: [ { name: "path", type: "bytes" }, { name: "recipient", type: "address" }, { name: "deadline", type: "uint256" }, { name: "amountIn", type: "uint256" }, { name: "amountOutMinimum", type: "uint256" }, ], }, ], outputs: [{ name: "amountOut", type: "uint256" }], }, { type: "function", name: "exactInputSingle", stateMutability: "payable", inputs: [ { name: "params", type: "tuple", components: [ { name: "tokenIn", type: "address" }, { name: "tokenOut", type: "address" }, { name: "fee", type: "uint24" }, { name: "recipient", type: "address" }, { name: "deadline", type: "uint256" }, { name: "amountIn", type: "uint256" }, { name: "amountOutMinimum", type: "uint256" }, { name: "sqrtPriceLimitX96", type: "uint160" }, ], }, ], outputs: [{ name: "amountOut", type: "uint256" }], }, ]; export const UNIVERSAL_ROUTER_ABI = [ { type: "function", name: "execute", stateMutability: "payable", inputs: [ { name: "commands", type: "bytes" }, { name: "inputs", type: "bytes[]" }, ], outputs: [], }, { type: "function", name: "executeWithETH", stateMutability: "payable", inputs: [ { name: "commands", type: "bytes" }, { name: "inputs", type: "bytes[]" }, { name: "deadline", type: "uint256" }, ], outputs: [], }, ]; // Minimal V4 Quoter ABI for single-hop and multi-hop quoting export const QUOTER_V4_ABI = [ { inputs: [ { components: [ { components: [ { internalType: "Currency", name: "currency0", type: "address", }, { internalType: "Currency", name: "currency1", type: "address", }, { internalType: "uint24", name: "fee", type: "uint24", }, { internalType: "int24", name: "tickSpacing", type: "int24", }, { internalType: "contract IHooks", name: "hooks", type: "address", }, ], internalType: "struct PoolKey", name: "poolKey", type: "tuple", }, { internalType: "bool", name: "zeroForOne", type: "bool", }, { internalType: "uint128", name: "exactAmount", type: "uint128", }, { internalType: "bytes", name: "hookData", type: "bytes", }, ], internalType: "struct IV4Quoter.QuoteExactSingleParams", name: "params", type: "tuple", }, ], name: "quoteExactInputSingle", outputs: [ { internalType: "uint256", name: "amountOut", type: "uint256", }, { internalType: "uint256", name: "gasEstimate", type: "uint256", }, ], stateMutability: "nonpayable", type: "function", }, { inputs: [ { components: [ { internalType: "bytes", name: "path", type: "bytes", }, { internalType: "uint128", name: "exactAmount", type: "uint128", }, { internalType: "bytes", name: "hookData", type: "bytes", }, ], internalType: "struct IV4Quoter.QuoteExactInputParams", name: "params", type: "tuple", }, ], name: "quoteExactInput", outputs: [ { internalType: "uint256", name: "amountOut", type: "uint256", }, { internalType: "uint256", name: "gasEstimate", type: "uint256", }, ], stateMutability: "nonpayable", type: "function", }, ]; // Minimal Uniswap V2 Factory ABI (getPair) export const UNISWAP_V2_FACTORY_ABI = [ { type: "function", name: "getPair", stateMutability: "view", inputs: [ { name: "tokenA", type: "address" }, { name: "tokenB", type: "address" }, ], outputs: [{ type: "address" }], }, ]; // Minimal Uniswap V2 Pair ABI (token0, token1, getReserves) export const UNISWAP_V2_PAIR_ABI = [ { type: "function", name: "token0", stateMutability: "view", inputs: [], outputs: [{ type: "address" }], }, { type: "function", name: "token1", stateMutability: "view", inputs: [], outputs: [{ type: "address" }], }, { type: "function", name: "getReserves", stateMutability: "view", inputs: [], outputs: [ { name: "reserve0", type: "uint112" }, { name: "reserve1", type: "uint112" }, { name: "blockTimestampLast", type: "uint32" }, ], }, ];