UNPKG

@swapper-finance/sdk

Version:
348 lines (320 loc) 9.4 kB
import * as react_jsx_runtime from 'react/jsx-runtime'; import { BigNumber } from 'ethers'; type Addresses = { [chainId: string]: Contracts; }; type Contracts = Partial<{ [contractName in ContractName]: string; }>; declare enum ContractName { SwapperRouter = "SwapperRouter", FeeCollector = "FeeCollector", SwapperTransferProxy = "SwapperTransferProxy", Lido = "Lido" } type SwapperConfig = { apiUrl: string; localCss: boolean; }; declare enum Web3Environment { DEVNET = "devnet", TESTNET = "testnet", MAINNET = "mainnet" } type Chain = { ecosystem: string; chainId: string; name: string; displayName: string; image: string; web3Environment: Web3Environment; tokenSymbol: string; ccipChainId: string; transactionExplorer: string; tokens: Token[]; publicRpcUrls: string[]; privateRpcUrls?: string[]; shift4Pk: string; }; type Token = { address: string; name: string; symbol: string; tokenId: string; decimals: number; image?: string; priority: number; quickPick?: boolean; supported?: boolean; chainlinkFunctionSupport?: boolean; }; type TokenWithChain = Token & { chainId: string; isCustom?: boolean; }; type Prices = { blockchainId: string; updatedAt: Date; prices: TokenPrices; }; type TokenPrices = { [tokenAddress: string]: string; }; type TokenBalances = { [tokenAddress: string]: BigNumber | undefined; }; type ImportedTokenData = { address: string; symbol: string; name: string; decimals: number; }; type CoinTypeAddress = { coinType: number; address: string; }; declare enum SwapperCallType { DEFAULT = 0, FULL_TOKEN_BALANCE = 1, FULL_NATIVE_BALANCE = 2, COLLECT_TOKEN_BALANCE = 3 } type ContractCall = { callType: SwapperCallType; target: string; value: string; callData: string; payload: string; estimatedGas?: string; }; declare enum Ecosystem { EVM = "evm" } declare enum Environment { PROD = "production", DEV = "develop", LOCAL = "local" } type GetTokenBalancesPayload = { walletAddress: string; }; type GetPricesPayload = { chainId: string | string[]; }; type GenerateRoutePayload = { integratorId: string; chainId: string; fromToken: string; toToken: string; fromAmount: string; fromAddress?: string; signerAddress?: string; toAddress?: string; slippage: number; customContractCalls?: ContractCall[]; sourceChainDexes?: string[]; isUsingChainlinkFunction: boolean; }; type ThemeMode = "light" | "dark"; type BrandTheme = { primaryColor?: string; secondaryColor?: string; }; type ComponentStyles = { backgroundColor?: string; borderRadius?: string; width?: string; textColor?: string; primaryButtonBackground?: string; primaryButtonText?: string; secondaryButtonBackground?: string; secondaryButtonText?: string; disabledButtonBackground?: string; disabledButtonText?: string; successColor?: string; warningColor?: string; errorColor?: string; inputBackground?: string; inputBorder?: string; cardBackground?: string; borderColor?: string; }; type SwapperStyles = { themeMode?: ThemeMode; brandTheme?: BrandTheme; componentStyles?: ComponentStyles; }; type SwapperCTAs = { successViewButton?: { url: string; label: string; }; }; type WidgetIntegrationPayload = { integratorId: string; integrationType?: string; chainIds?: string[]; dstChainId?: string; dstToken?: string; dstTokenImage?: string; customContractCalls?: ContractCall[]; externalWalletAddress?: string; desc?: string; defaultWalletPicker?: boolean; development?: boolean; cta?: SwapperCTAs; styles?: SwapperStyles; }; type Protocol = { name: string; part: number; fromTokenAddress: string; toTokenAddress: string; }; type SwapperCall = { callType: number; target: `0x${string}`; value: string; payload: `0x${string}`; callData: `0x${string}`; }; type Route = { id: string; receiver: string; estAmountOut: string; minAmountOut: string; transactions?: { approve: { to: `0x${string}`; data: `0x${string}`; value: string; } | undefined; swap: { to: `0x${string}`; data: `0x${string}`; value: string; }; }; gasCostInUSDC?: string; platformFeeInUSDC?: string; userOperationGasPrice?: { maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; }; swapperCalls: SwapperCall[]; }; type TransferType = "CROSS_CHAIN" | "SINGLE_CHAIN"; type TransactionHistory = { history: HistoryTransaction[]; }; type HistoryTransaction = { transferId: string; transferType: TransferType; walletAddress: string; messageId: string; failed: boolean; source: { blockchainId: string; transactionHash: string; blockTime: Date; tokenAmount: string; tokenAddress: string; transferredTokenAddress: string; transferredTokenAmount: string; valueForInstantCcipRecieve: string; tokenOutAddress: string; estimatedAmountOut: string; targetBlockchainId: string; } | null; target: { blockchainId: string; transactionHash: string; blockTime: Date; tokenAmount: string; tokenAddress: string; } | null; }; type TransactionStatus = "IN_PROGRESS" | "SUCCESS" | "FAIL" | "NOT_FOUND"; type Transaction = { messageId?: string; hash: string; timestamp: number; sourceChainId: string; targetChainId: string; amountWei: string; tokenAddress: string; tokenOutAddress: string | undefined; tokenOutAmount: string | undefined; estimatedDeliveryTimestamp: number; status: TransactionStatus; }; type Currency = { symbol: string; name: string; image: string; }; type Shift4Config = { [chainId: string]: Record<Shift4CryptoCurrencyCodeKey, string>; }; declare enum Shift4CryptoCurrencyCodeKey { USDC = "USDC", NATIVE = "NATIVE" } interface Balances { wei: string; humanReadable: string; abbreviated: string; } type EnrichedWalletToken = TokenWithChain & { balances: Balances; price: number; value: number; }; type SwapperAppPayload = { integratorId: string; integrationType?: string; chainIds?: string[] | string; dstChainId?: string; dstTokenAddr?: string; dstTokenImage?: string; customContractCalls?: ContractCall[]; externalWalletAddress?: string; desc?: string; token?: string; supportedChains: Chain[]; isFetchingChains: boolean; defaultWalletPicker?: boolean; development?: boolean; cta?: SwapperCTAs; styles?: SwapperStyles; isDirectOnRampSupported?: boolean; isCheckingDirectOnRamp?: boolean; }; type TxWidgetWCAttributes = { "integrator-id": WidgetIntegrationPayload["integratorId"]; "integration-type": WidgetIntegrationPayload["integrationType"]; "chain-ids": string; "dst-chain-id": WidgetIntegrationPayload["dstChainId"]; "dst-token": WidgetIntegrationPayload["dstToken"]; "dst-token-image": WidgetIntegrationPayload["dstTokenImage"]; "custom-contract-calls": WidgetIntegrationPayload["customContractCalls"]; desc: WidgetIntegrationPayload["desc"]; "default-wallet-picker": WidgetIntegrationPayload["defaultWalletPicker"]; development: WidgetIntegrationPayload["development"]; cta: string | undefined; styles: string | undefined; }; declare global { namespace JSX { interface IntrinsicElements { "swapper-sdk-widget": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & TxWidgetWCAttributes; } } } declare const TxWidgetWCWrapped: ({ integratorId, integrationType, chainIds, dstChainId, dstToken, dstTokenImage, customContractCalls, externalWalletAddress, desc, defaultWalletPicker, development, cta, styles, }: WidgetIntegrationPayload) => react_jsx_runtime.JSX.Element; declare const TxWidgetWC: CustomElementConstructor; declare const SwapperSDK: { TxWidget: ({ integratorId, integrationType, chainIds, dstChainId, dstToken, dstTokenImage, customContractCalls, externalWalletAddress, desc, defaultWalletPicker, development, cta, styles, }: WidgetIntegrationPayload) => react_jsx_runtime.JSX.Element; TxWidgetWC: CustomElementConstructor; }; export { type Addresses, type BrandTheme, type Chain, type CoinTypeAddress, type ComponentStyles, type ContractCall, ContractName, type Contracts, type Currency, Ecosystem, type EnrichedWalletToken, Environment, type GenerateRoutePayload, type GetPricesPayload, type GetTokenBalancesPayload, type HistoryTransaction, type ImportedTokenData, type Prices, type Protocol, type Route, type Shift4Config, Shift4CryptoCurrencyCodeKey, type SwapperAppPayload, type SwapperCTAs, SwapperCallType, type SwapperConfig, type SwapperStyles, type ThemeMode, type Token, type TokenBalances, type TokenPrices, type TokenWithChain, type Transaction, type TransactionHistory, type TransactionStatus, TxWidgetWCWrapped as TxWidget, TxWidgetWC, Web3Environment, type WidgetIntegrationPayload, SwapperSDK as default };