UNPKG

@plasma-fi/sdk

Version:

🛠 An SDK for building dapp on PlasmaSwap.

82 lines (81 loc) • 2.62 kB
import { TransactionRequest } from '@ethersproject/providers'; import { CurrencyAmount, Percent } from '../amounts'; import { Trade0xLiquiditySource } from '../constants/constants'; import { BaseTrade } from '../types'; import { Currency } from './currency'; export interface Trade0xSwapOptions { /** * From (Sell, Input) currency */ from: CurrencyAmount | Currency; /** * To (Buy, Output) currency */ to: CurrencyAmount | Currency; /** * (Optional) percent = slippagePercentage * 100 * @description The maximum acceptable slippage in % of the buyToken * amount if sellAmount is provided, the maximum acceptable slippage * in % of the sellAmount amount if inputAmount is provided. * This parameter will change over time with market conditions. */ slippagePercentage: string; /** * (Optional) Liquidity sources (Eth2Dai, Uniswap, Kyber, 0x, LiquidityProvider etc) * that will not be included in the provided quote. */ excludedSources?: Trade0xLiquiditySource[]; /** * (Optional) The percentage (between 0 - 100) of the {@link from} */ sellTokenPercentageFee?: number; } export interface Trade0xSwapProportion { /** * Liquidity source provider info */ name: Trade0xLiquiditySource; /** * In percentage */ proportion: number; } export declare class Trade0xSwap extends BaseTrade { readonly networkFee: CurrencyAmount; readonly tradeFee: CurrencyAmount; readonly allowanceTarget?: string; readonly proportions: Trade0xSwapProportion[]; readonly priceImpact?: Percent; /** * Saved settings with which the trade was created * @private */ private readonly _optsSlippagePercentage; private readonly _optsExcludedSources?; private readonly _optSellTokenPercentageFee?; /** * 0x Trade Class factory * @param opts * @param abort */ static getTrade(opts: Trade0xSwapOptions, abort?: AbortSignal): Promise<Trade0xSwap>; /** * Fetch quote and reformat output for using with the Hyper Dex Router Contract * @param opts * @param justPrice * @param abort * @private */ private static _fetchQuote; /** * Calculate the approximate amount of gas required * @param quote * @private */ private static _getEstimateGas; private constructor(); /** * Returns transaction data */ getTransactionData(account: string): Promise<TransactionRequest>; }