swapnet-sdk-test-1
Version:
TypeScript SDK for SwapNet API.
65 lines (64 loc) • 2.43 kB
TypeScript
import { type TokenOperation } from "./common/routingPlan.js";
import { type RoutePlanner } from "./routers/universalRouter/routerCommands.js";
import type { PermitSingle } from '@uniswap/permit2-sdk';
import type { BigNumberish } from 'ethers';
import type { FeeOptions, PermitOptions } from 'blast-mainnet-few-v3-sdk-8';
import { Percent } from 'blast-mainnet-few-sdk-core-2';
import type { Validation } from 'blast-mainnet-few-router-sdk-20';
export type TokenOperationNodeType = 'SOURCE' | 'PASSING_THROUGH' | 'MERGING' | 'FORKING' | 'DESTINATION';
export declare const toNodeType: (tokenOp: TokenOperation) => TokenOperationNodeType;
export declare const toAmountOutMinimum: (amountOut: bigint, slippageTolerance: number) => bigint;
export declare const fromTokenUnits: (tokenUnits: number, decimals: number) => bigint;
export declare const toTokenUnits: (tokenAmount: bigint, decimals: number) => number;
export interface Permit2Permit extends PermitSingle {
signature: string;
}
export type ApproveProtocol = {
token: string;
protocol: string;
};
export type Permit2TransferFrom = {
token: string;
amount: string;
recipient?: string;
};
export type InputTokenOptions = {
approval?: ApproveProtocol;
permit2Permit?: Permit2Permit;
permit2TransferFrom?: Permit2TransferFrom;
};
export interface Permit2Permit extends PermitSingle {
signature: string;
}
export declare function encodePermit(planner: RoutePlanner, permit2: Permit2Permit): void;
export type FlatFeeOptions = {
amount: BigNumberish;
recipient: string;
};
export interface RouterSwapOptions {
/**
* How much the execution price is allowed to move unfavorably from the trade execution price.
*/
slippageTolerance: Percent;
/**
* The account that should receive the output. If omitted, output is sent to msg.sender.
*/
recipient?: string;
/**
* Either deadline (when the transaction expires, in epoch seconds), or previousBlockhash.
*/
deadlineOrPreviousBlockhash?: Validation;
/**
* The optional permit parameters for spending the input.
*/
inputTokenPermit?: PermitOptions;
/**
* Optional information for taking a fee on output.
*/
fee?: FeeOptions;
}
export type SwapOptions = Omit<RouterSwapOptions, 'inputTokenPermit'> & {
inputTokenPermit?: Permit2Permit;
payerIsRouter?: boolean;
flatFee?: FlatFeeOptions;
};