UNPKG

@f5i23q999d/cow-sdk

Version:

<p align="center"> <img width="400" src="https://github.com/cowprotocol/cow-sdk/raw/main/docs/images/CoW.png" /> </p>

68 lines (67 loc) 2.42 kB
import { SwapAdvancedSettings, TradingSdk } from '../../trading/index.js'; import { BridgeProvider, BridgeQuoteResult, CrossChainQuoteAndPost, GetErc20Decimals, QuoteBridgeRequest } from '../types.js'; import { TokenInfo } from '../../common/index.js'; import { ChainInfo, TargetChainId } from '../../chains/index.js'; export interface BridgingSdkOptions { /** * Providers for the bridging. */ providers: BridgeProvider<BridgeQuoteResult>[]; /** * Function to get the decimals of the ERC20 tokens */ getErc20Decimals?: GetErc20Decimals; /** * Trading SDK. */ tradingSdk?: TradingSdk; /** * Enable logging for the bridging SDK. */ enableLogging?: boolean; } export type BridgingSdkConfig = Required<Omit<BridgingSdkOptions, 'enableLogging' | 'getErc20Decimals'>> & Pick<BridgingSdkOptions, 'getErc20Decimals'>; /** * 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 param * @returns */ getBuyTokens(targetChainId: TargetChainId): 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>; }