@shapeshiftoss/swap-widget 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,195 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { AssetId, ChainId } from '@shapeshiftoss/caip';
3
+ export { AssetId, ChainId } from '@shapeshiftoss/caip';
4
+ import { Asset as Asset$1 } from '@shapeshiftoss/types';
5
+ import { UseQueryResult } from '@tanstack/react-query';
6
+
7
+ declare enum SwapperName {
8
+ NearIntents = "NEAR Intents",
9
+ Relay = "Relay",
10
+ Thorchain = "THORChain",
11
+ Mayachain = "MAYAChain"
12
+ }
13
+ type Chain = {
14
+ chainId: ChainId;
15
+ name: string;
16
+ icon: string;
17
+ color: string;
18
+ nativeAssetId: AssetId;
19
+ };
20
+ type Asset = {
21
+ assetId: AssetId;
22
+ chainId: ChainId;
23
+ symbol: string;
24
+ name: string;
25
+ precision: number;
26
+ icon?: string;
27
+ color?: string;
28
+ networkName?: string;
29
+ networkIcon?: string;
30
+ explorer?: string;
31
+ explorerTxLink?: string;
32
+ explorerAddressLink?: string;
33
+ relatedAssetKey?: AssetId | null;
34
+ };
35
+ type TradeQuoteStep = {
36
+ sellAsset: Asset;
37
+ buyAsset: Asset;
38
+ sellAmountCryptoBaseUnit: string;
39
+ buyAmountCryptoBaseUnit: string;
40
+ rate: string;
41
+ source: SwapperName;
42
+ feeData: {
43
+ networkFeeCryptoBaseUnit: string;
44
+ protocolFees?: Record<AssetId, {
45
+ amountCryptoBaseUnit: string;
46
+ }>;
47
+ };
48
+ allowanceContract?: string;
49
+ estimatedExecutionTimeMs?: number;
50
+ };
51
+ type TradeQuote = {
52
+ id: string;
53
+ rate: string;
54
+ swapperName: SwapperName;
55
+ steps: TradeQuoteStep[];
56
+ receiveAddress: string;
57
+ partnerBps?: string;
58
+ shapeshiftBps: string;
59
+ affiliateBps: string;
60
+ slippageTolerancePercentageDecimal?: string;
61
+ isStreaming?: boolean;
62
+ };
63
+ type TradeRate = {
64
+ swapperName: SwapperName;
65
+ rate: string;
66
+ buyAmountCryptoBaseUnit: string;
67
+ sellAmountCryptoBaseUnit: string;
68
+ steps: number;
69
+ estimatedExecutionTimeMs?: number;
70
+ partnerBps?: string;
71
+ shapeshiftBps: string;
72
+ affiliateBps: string;
73
+ networkFeeCryptoBaseUnit?: string;
74
+ error?: {
75
+ code: string;
76
+ message: string;
77
+ };
78
+ id?: string;
79
+ };
80
+ type ThemeMode = 'light' | 'dark';
81
+ type ThemeConfig = {
82
+ mode: ThemeMode;
83
+ accentColor?: string;
84
+ backgroundColor?: string;
85
+ cardColor?: string;
86
+ textColor?: string;
87
+ borderRadius?: string;
88
+ fontFamily?: string;
89
+ borderColor?: string;
90
+ secondaryTextColor?: string;
91
+ mutedTextColor?: string;
92
+ inputColor?: string;
93
+ hoverColor?: string;
94
+ buttonVariant?: 'filled' | 'outline';
95
+ };
96
+ type SwapWidgetFilters = {
97
+ allowedChainIds?: ChainId[];
98
+ disabledChainIds?: ChainId[];
99
+ allowedAssetIds?: AssetId[];
100
+ disabledAssetIds?: AssetId[];
101
+ };
102
+ type SwapWidgetProps = {
103
+ partnerCode?: string;
104
+ apiBaseUrl?: string;
105
+ allowShapeshiftRedirect?: boolean;
106
+ defaultSellAsset?: Asset;
107
+ defaultBuyAsset?: Asset;
108
+ sellFilters?: SwapWidgetFilters;
109
+ buyFilters?: SwapWidgetFilters;
110
+ allowedSwapperNames?: SwapperName[];
111
+ onSwapSuccess?: (txHash: string) => void;
112
+ onSwapError?: (error: Error) => void;
113
+ theme?: ThemeMode | ThemeConfig;
114
+ defaultSlippage?: string;
115
+ showPoweredBy?: boolean;
116
+ showConnectButton?: boolean;
117
+ walletConnectProjectId?: string;
118
+ ratesRefetchInterval?: number;
119
+ isBuyAssetLocked?: boolean;
120
+ };
121
+ declare const EVM_CHAIN_IDS: {
122
+ readonly ethereum: ChainId;
123
+ readonly arbitrum: ChainId;
124
+ readonly optimism: ChainId;
125
+ readonly polygon: ChainId;
126
+ readonly base: ChainId;
127
+ readonly avalanche: ChainId;
128
+ readonly bsc: ChainId;
129
+ readonly gnosis: ChainId;
130
+ readonly monad: ChainId;
131
+ readonly megaEth: ChainId;
132
+ readonly hyperEvm: ChainId;
133
+ readonly plasma: ChainId;
134
+ readonly katana: ChainId;
135
+ };
136
+ declare const UTXO_CHAIN_IDS: {
137
+ readonly bitcoin: ChainId;
138
+ readonly bitcoinCash: ChainId;
139
+ readonly dogecoin: ChainId;
140
+ readonly litecoin: ChainId;
141
+ };
142
+ declare const COSMOS_CHAIN_IDS: {
143
+ readonly cosmos: ChainId;
144
+ readonly thorchain: ChainId;
145
+ readonly mayachain: ChainId;
146
+ };
147
+ declare const OTHER_CHAIN_IDS: {
148
+ readonly solana: ChainId;
149
+ };
150
+ declare const REDIRECT_ONLY_CHAIN_IDS: {
151
+ readonly zcash: ChainId;
152
+ readonly tron: ChainId;
153
+ readonly sui: ChainId;
154
+ readonly ton: ChainId;
155
+ readonly near: ChainId;
156
+ readonly starknet: ChainId;
157
+ };
158
+ declare const isEvmChainId: (chainId: string) => boolean;
159
+ declare const getEvmNetworkId: (chainId: string) => number;
160
+ declare const getChainType: (chainId: string) => 'evm' | 'utxo' | 'cosmos' | 'solana' | 'other';
161
+ declare const isWidgetExecutableChainId: (chainId: string) => boolean;
162
+ declare const isWidgetSupportedChainId: (chainId: string) => boolean;
163
+ declare const formatAmount: (amount: string, decimals: number, maxDecimals?: number) => string;
164
+ declare const parseAmount: (amount: string, decimals: number) => string;
165
+ declare const truncateAddress: (address: string, chars?: number) => string;
166
+
167
+ declare const SwapWidget: (props: SwapWidgetProps) => react_jsx_runtime.JSX.Element;
168
+
169
+ declare const getBaseAsset: (chainId: ChainId) => Asset$1 | undefined;
170
+ declare const getChainName: (chainId: ChainId) => string;
171
+ declare const getChainIcon: (chainId: ChainId) => string | undefined;
172
+ declare const getChainColor: (chainId: ChainId) => string;
173
+ declare const getExplorerTxLink: (chainId: ChainId) => string;
174
+
175
+ type AssetQueryResult<TData> = Omit<UseQueryResult<RawAssetData>, 'data'> & {
176
+ data: TData;
177
+ };
178
+ type RawAssetData = {
179
+ byId: Record<AssetId, Asset>;
180
+ ids: AssetId[];
181
+ };
182
+ declare const useAssets: () => AssetQueryResult<Asset[]>;
183
+ declare const useAssetById: (assetId: AssetId | undefined) => AssetQueryResult<Asset | undefined>;
184
+ type ChainInfo = {
185
+ chainId: ChainId;
186
+ name: string;
187
+ icon?: string;
188
+ color?: string;
189
+ nativeAsset: Asset;
190
+ };
191
+ declare const useChains: () => AssetQueryResult<ChainInfo[]>;
192
+ declare const useAssetsByChainId: (chainId: ChainId | undefined) => AssetQueryResult<Asset[]>;
193
+ declare const useAssetSearch: (query: string, chainId?: ChainId) => AssetQueryResult<Asset[]>;
194
+
195
+ export { type Asset, COSMOS_CHAIN_IDS, type Chain, EVM_CHAIN_IDS, OTHER_CHAIN_IDS, REDIRECT_ONLY_CHAIN_IDS, SwapWidget, type SwapWidgetFilters, type SwapWidgetProps, SwapperName, type ThemeConfig, type ThemeMode, type TradeQuote, type TradeRate, UTXO_CHAIN_IDS, formatAmount, getBaseAsset, getChainColor, getChainIcon, getChainName, getChainType, getEvmNetworkId, getExplorerTxLink, isEvmChainId, isWidgetExecutableChainId, isWidgetSupportedChainId, parseAmount, truncateAddress, useAssetById, useAssetSearch, useAssets, useAssetsByChainId, useChains };