kirapay-axelar-sdk
Version:
TypeScript SDK for cross-chain swaps with CCIP and Axelar bridges
187 lines (186 loc) • 4.11 kB
TypeScript
/**
* Core type definitions for the Kira SDK
*/
export type Address = `0x${string}`;
export type ChainId = number;
/**
* Token representation
*/
export type Token = {
address: Address;
chainId: ChainId;
decimals: number;
symbol: string;
};
/**
* Bridge protocol types
*/
export type Bridge = "CCIP" | "AXELAR";
/**
* Input parameters for a cross-chain swap quote
*/
export type QuoteInputRaw = {
srcChainId: ChainId;
dstChainId: ChainId;
recipient: Address;
tokenIn: Token;
tokenOut: Token;
amountIn: bigint;
maxSlippageBps: number;
ttlSeconds?: number;
preferredBridge: Bridge;
};
/**
* Input parameters for a cross-chain swap quote
*/
export type QuoteInput = {
srcChainId: ChainId;
dstChainId: ChainId;
recipient: Address;
tokenIn: Token;
tokenOut: Token;
amountIn: bigint;
maxSlippageBps: number;
ttlSeconds: number;
preferredBridge: Bridge;
};
/**
* DEX swap leg
*/
export type DexLeg = {
gasEstimate: bigint;
kind: "V4" | "V3" | "V2";
path: Address[];
feeTiers?: number[];
amountIn: bigint;
minAmountOut: bigint;
poolParams: PoolParams[];
};
/**
* Bridge fee information
*/
export type BridgeFee = {
bridge: Bridge;
feeToken: Address;
feeAmount: bigint;
};
/**
* Quote result for a cross-chain swap route
*/
export type RouteQuote = {
srcDex: DexLeg;
dstDexGasEstimate?: bigint;
dstDex?: DexLeg;
bridgeAsset: Token;
bridgeContract: {
srcContract: Address;
dstContract: Address;
};
};
/**
* Prepared transaction data
*/
export type PreparedTx = {
to: Address;
data: `0x${string}`;
value: bigint;
metadata?: {
params: ProxyContractParams;
bridgeFee: BridgeFee;
};
};
/**
* Result of preparing a cross-chain transaction
*/
export type PrepareResult = {
route: RouteQuote;
bridgeFee: BridgeFee;
deadline: bigint;
routeId: `0x${string}`;
};
/**
* Gas estimation for a single chain
*/
export type GasEstimation = {
gasLimit: bigint;
maxFeePerGas: bigint;
maxPriorityFeePerGas: bigint;
totalGasWei: bigint;
totalGasUsd: number;
};
/**
* Complete gas estimation results for a cross-chain transaction
*/
export type GasEstimationResult = {
sourceChain: GasEstimation & {
needsSwap: boolean;
swapGasEstimate?: GasEstimation;
};
bridge: {
fee: BridgeFee;
feeUsd: number;
};
total: {
gasUsd: number;
bridgeFeeUsd: number;
totalUsd: number;
};
};
/**
* Configuration for SDK initialization
*/
export type KiraSdkConfig = {
rpcs?: Record<number, string | string[]>;
ccip?: {
[chainId: number]: {
router: Address;
selector: bigint;
};
};
axelar?: {
[chainId: number]: {
gateway: Address;
dstChainName?: string;
dstContract?: string;
usdcSymbol?: string;
wrappedSymbols?: {
usdc?: string;
weth?: string;
};
};
};
sourceRouters?: Record<number, Address>;
defaultTtlSeconds?: number;
defaultSwapDeadlineSeconds?: number;
};
export type ProxyContractParams = {
destinationChain: string;
destinationContract: string;
recipient: Address;
routeId: `0x${string}`;
deadline: bigint;
srcPath: Address[];
srcPoolParams: PoolParams[];
srcSwapVersion: any;
destinationChainSelector: bigint;
inputAmount: bigint;
minBridgeAmount: bigint;
shouldSwapOnDest: boolean;
destPath: Address[];
destPoolParams: PoolParams[];
destSwapVersion: any;
minAmountOut: bigint;
};
export type PoolParams = {
fee: number;
tickSpacing: number;
hooks: Address;
};
/**
* Error thrown when a route cannot be found
*/
export declare class RouteNotFoundError extends Error {
readonly leg: "SRC" | "DST";
readonly context: Record<string, unknown>;
constructor(leg: "SRC" | "DST", message: string, context?: Record<string, unknown>);
}