hermes-swap-router-sdk
Version:
An sdk for routing swaps using Uniswap v2, Uniswap v3 and Balancer Stable Pools.
67 lines (66 loc) • 3.18 kB
TypeScript
import { Interface } from '@ethersproject/abi';
import { ComposableStablePool, ComposableStablePoolWrapper, FeeOptions, PermitOptions, Pool, Position, Trade as V3Trade, TradeType, V2Trade } from 'hermes-v2-sdk';
import { Currency, MethodParameters, Percent } from 'maia-core-sdk';
import { ApprovalTypes, CondensedAddLiquidityOptions } from './approveAndCall';
import { MixedRouteTrade } from './entities/mixedRoute/trade';
import { Trade } from './entities/trade';
import { Validation } from './multicallExtended';
/**
* Options for producing the arguments to send calls to the router.
*/
export interface SwapOptions {
/**
* 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 interface SwapAndAddOptions extends SwapOptions {
/**
* The optional permit parameters for pulling in remaining output token.
*/
outputTokenPermit?: PermitOptions;
}
export declare type AllTrades = V2Trade<Currency, Currency, TradeType> | V3Trade<Pool, Currency, Currency, TradeType> | V3Trade<ComposableStablePool, Currency, Currency, TradeType> | V3Trade<ComposableStablePoolWrapper, Currency, Currency, TradeType> | MixedRouteTrade<Currency, Currency, TradeType>;
export declare type AnyTrade = Trade<Currency, Currency, TradeType> | AllTrades;
export declare type AnyTradeType = AnyTrade | AllTrades[];
/**
* Represents the Uniswap V2 + V3 SwapRouter02, and has static methods for helping execute trades.
*/
export declare abstract class SwapRouter {
static INTERFACE: Interface;
/**
* Cannot be constructed.
*/
private constructor();
/**
* Produces the on-chain method name to call and the hex encoded parameters to pass as arguments for a given trade.
* @param trades to produce call parameters for
* @param options options for the call parameters
*/
static swapCallParameters(trades: AnyTradeType, options: SwapOptions): MethodParameters;
/**
* Produces the on-chain method name to call and the hex encoded parameters to pass as arguments for a given trade.
* @param trades to produce call parameters for
* @param options options for the call parameters
*/
static swapAndAddCallParameters(trades: AnyTradeType, options: SwapAndAddOptions, position: Position, addLiquidityOptions: CondensedAddLiquidityOptions, tokenInApprovalType: ApprovalTypes, tokenOutApprovalType: ApprovalTypes): MethodParameters;
private static riskOfPartialFill;
private static v3TradeWithHighPriceImpact;
private static getPositionAmounts;
}