@cowprotocol/cow-sdk
Version:
## 📚 [Docs website](https://docs.cow.fi/)
88 lines (86 loc) • 2.96 kB
TypeScript
import { SwapAdvancedSettings, TradingSdk } from '../../trading';
import { BridgeProvider, BridgeQuoteResult, BridgeStatusResult, BuyTokensParams, CrossChainOrder, CrossChainQuoteAndPost, QuoteBridgeRequest } from '../types';
import { CowEnv, TokenInfo } from '../../common';
import { ChainInfo, SupportedChainId } from '../../chains';
import { OrderBookApi } from '../../order-book';
export interface BridgingSdkOptions {
/**
* Providers for the bridging.
*/
providers: BridgeProvider<BridgeQuoteResult>[];
/**
* Trading SDK.
*/
tradingSdk?: TradingSdk;
/**
* Order book API.
*/
orderBookApi?: OrderBookApi;
/**
* Enable logging for the bridging SDK.
*/
enableLogging?: boolean;
}
/**
* Parameters for the `getOrder` method.
*/
export interface GetOrderParams {
/**
* Id of a network where order was settled
*/
chainId: SupportedChainId;
/**
* The unique identifier of the order.
*/
orderId: string;
/**
* The environment of the order
*/
env?: CowEnv;
}
export type BridgingSdkConfig = Required<Omit<BridgingSdkOptions, 'enableLogging'>>;
/**
* SDK for bridging for swapping tokens between different chains.
*/
export declare class BridgingSdk {
readonly options: BridgingSdkOptions;
protected config: BridgingSdkConfig;
constructor(options: BridgingSdkOptions);
private get provider();
/**
* Get the providers for the bridging.
*/
getProviders(): BridgeProvider<BridgeQuoteResult>[];
/**
* Get the available sources networks for the bridging.
*/
getSourceNetworks(): Promise<ChainInfo[]>;
/**
* Get the available target networks for the bridging.
*/
getTargetNetworks(): Promise<ChainInfo[]>;
/**
* Get the available buy tokens for buying in a specific target chain
* @param params
*/
getBuyTokens(params: BuyTokensParams): Promise<TokenInfo[]>;
/**
* Get quote details, including a callback function to post the order on-chain.
*
* This method support both, cross-chain swaps and single-chain swap.
*
* The return type will be either `QuoteAndPost` or `BridgeQuoteAndPost`.
*
* To safely assert the type in Typescript, you can use:
* - `isBridgeQuoteAndPost(result)` utility.
* - `isQuoteAndPost(result)` utility.
* - `assertIsBridgeQuoteAndPost(result)` assertion.
* - `assertIsQuoteAndPost(result)` assertion.
*
* @throws Error if no path is found
*/
getQuote(quoteBridgeRequest: QuoteBridgeRequest, advancedSettings?: SwapAdvancedSettings): Promise<CrossChainQuoteAndPost>;
getOrder(params: GetOrderParams): Promise<CrossChainOrder | null>;
getOrderBridgingStatus(bridgingId: string, originChainId: SupportedChainId): Promise<BridgeStatusResult>;
getProviderFromAppData(fullAppData: string): BridgeProvider<BridgeQuoteResult> | undefined;
}