@paraswap/sdk
Version:
51 lines • 2.14 kB
TypeScript
import { SwapSide } from '../../constants';
import type { DeltaPrice } from '../delta/getDeltaPrice';
import type { ConstructFetchInput, EnumerateLiteral, OptimalRate } from '../../types';
type TradeMode = 'delta' | 'market' | 'all';
type SwapSideUnion = EnumerateLiteral<typeof SwapSide>;
export type QuoteParams<M extends TradeMode = TradeMode> = {
/** @description Source Token Address */
srcToken: string;
/** @description Destination Token Address */
destToken: string;
/** @description srcToken amount (in case of SELL) or destToken amount (in case of BUY), in wei */
amount: string;
/** @description Source Token Decimals. */
srcDecimals: number;
/** @description Destination Token Decimals */
destDecimals: number;
/** @description SELL or BUY */
side: SwapSideUnion;
/** @description User's Wallet Address */
userAddress?: string;
/** @description Partner string */
partner?: string;
/** @description Preferred mode for the trade. In case of "all", Delta pricing is returned, with Market as a fallback */
mode: M;
};
type FallbackReason = {
errorType: string;
details: string;
};
export type QuoteWithMarketPrice = {
market: OptimalRate;
};
export type QuoteWithDeltaPrice = {
delta: DeltaPrice;
};
export type QuoteWithMarketPriceAsFallback = QuoteWithMarketPrice & {
fallbackReason: FallbackReason;
};
export type QuoteResponse = QuoteWithDeltaPrice | QuoteWithMarketPrice | QuoteWithMarketPriceAsFallback;
interface GetQuoteFunc {
(options: QuoteParams<'delta'>, signal?: AbortSignal): Promise<QuoteWithDeltaPrice>;
(options: QuoteParams<'market'>, signal?: AbortSignal): Promise<QuoteWithMarketPrice>;
(options: QuoteParams<'all'>, signal?: AbortSignal): Promise<QuoteWithDeltaPrice | QuoteWithMarketPriceAsFallback>;
(options: QuoteParams, signal?: AbortSignal): Promise<QuoteResponse>;
}
export type GetQuoteFunctions = {
getQuote: GetQuoteFunc;
};
export declare const constructGetQuote: ({ apiURL, chainId, fetcher, }: ConstructFetchInput) => GetQuoteFunctions;
export {};
//# sourceMappingURL=getQuote.d.ts.map