@velora-dex/sdk
Version:
72 lines • 3.17 kB
TypeScript
import { SwapSide } from '../../constants';
import type { BridgePrice, DeltaPrice } from '../delta/getDeltaPrice';
import type { ConstructFetchInput, EnumerateLiteral, RequestParameters, 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, default is SELL */
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;
deltaAddress: string;
};
export type QuoteWithBridgePrice = {
delta: BridgePrice;
deltaAddress: string;
};
export type QuoteWithDeltaPriceAndBridgePrice = {
delta: DeltaPrice | BridgePrice;
deltaAddress: string;
};
export type QuoteWithMarketPriceAsFallback = QuoteWithMarketPrice & {
fallbackReason: FallbackReason;
};
export type QuoteResponse = QuoteWithDeltaPrice | QuoteWithMarketPrice | QuoteWithBridgePrice | QuoteWithMarketPriceAsFallback | QuoteWithDeltaPriceAndBridgePrice;
interface GetQuoteFunc {
(options: QuoteParams<'delta'> & {
destChainId?: undefined;
}, requestParams?: RequestParameters): Promise<QuoteWithDeltaPrice>;
(options: QuoteParams<'delta'> & {
destChainId: number;
}, requestParams?: RequestParameters): Promise<QuoteWithBridgePrice>;
(options: QuoteParams<'delta'>, requestParams?: RequestParameters): Promise<QuoteWithDeltaPriceAndBridgePrice>;
(options: QuoteParams<'market'>, requestParams?: RequestParameters): Promise<QuoteWithMarketPrice>;
(options: QuoteParams<'all'> & {
destChainId?: undefined;
}, requestParams?: RequestParameters): Promise<QuoteWithDeltaPrice | QuoteWithMarketPriceAsFallback>;
(options: QuoteParams<'all'> & {
destChainId: number;
}, requestParams?: RequestParameters): Promise<QuoteWithBridgePrice>;
(options: QuoteParams<'all'>, requestParams?: RequestParameters): Promise<QuoteWithDeltaPriceAndBridgePrice | QuoteWithMarketPriceAsFallback>;
(options: QuoteParams, requestParams?: RequestParameters): Promise<QuoteResponse>;
}
export type GetQuoteFunctions = {
getQuote: GetQuoteFunc;
};
export declare const constructGetQuote: ({ apiURL, chainId, fetcher, }: ConstructFetchInput) => GetQuoteFunctions;
export {};
//# sourceMappingURL=getQuote.d.ts.map