@swapkit/core 1.0.0-rc.119 → 1.0.0-rc.120

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.
package/dist/index.d.ts DELETED
@@ -1,353 +0,0 @@
1
- import type { ARBToolbox } from '@swapkit/toolbox-evm';
2
- import { AssetValue } from '@swapkit/helpers';
3
- import type { AVAXToolbox } from '@swapkit/toolbox-evm';
4
- import type { BCHToolbox } from '@swapkit/toolbox-utxo';
5
- import type { BinanceToolbox } from '@swapkit/toolbox-cosmos';
6
- import type { BSCToolbox } from '@swapkit/toolbox-evm';
7
- import type { BTCToolbox } from '@swapkit/toolbox-utxo';
8
- import { Chain } from '@swapkit/types';
9
- import type { ChainflipToolbox } from '@swapkit/toolbox-substrate';
10
- import { ConnectConfig } from '@swapkit/types';
11
- import { CosmosChain } from '@swapkit/types';
12
- import type { DASHToolbox } from '@swapkit/toolbox-utxo';
13
- import type { DepositParam } from '@swapkit/toolbox-cosmos';
14
- import type { DOGEToolbox } from '@swapkit/toolbox-utxo';
15
- import type { ETHToolbox } from '@swapkit/toolbox-evm';
16
- import { EVMChain } from '@swapkit/types';
17
- import type { EVMWalletOptions } from '@swapkit/types';
18
- import type { ExtendParams } from '@swapkit/types';
19
- import { FeeOption } from '@swapkit/types';
20
- import type { GaiaToolbox } from '@swapkit/toolbox-cosmos';
21
- import type { KujiraToolbox } from '@swapkit/toolbox-cosmos';
22
- import type { LTCToolbox } from '@swapkit/toolbox-utxo';
23
- import type { MATICToolbox } from '@swapkit/toolbox-evm';
24
- import type { OPToolbox } from '@swapkit/toolbox-evm';
25
- import type { PolkadotToolbox } from '@swapkit/toolbox-substrate';
26
- import type { QuoteRoute } from '@swapkit/helpers';
27
- import type { SwapKitNumber } from '@swapkit/helpers';
28
- import type { ThorchainToolboxType } from '@swapkit/toolbox-cosmos';
29
- import type { ThornameRegisterParam } from '@swapkit/helpers';
30
- import { UTXOChain } from '@swapkit/types';
31
- import { WalletOption } from '@swapkit/types';
32
-
33
- export declare type AddLiquidityTxns = {
34
- runeTx?: string;
35
- assetTx?: string;
36
- };
37
-
38
- declare type ApisType = {
39
- [key in UTXOChain]?: string | any;
40
- } & {
41
- [key in EVMChain]?: string | any;
42
- } & {
43
- [key in CosmosChain]?: string;
44
- };
45
-
46
- export declare enum ApproveMode {
47
- Approve = "approve",
48
- CheckOnly = "checkOnly"
49
- }
50
-
51
- export declare type ApproveReturnType<T extends ApproveMode> = T extends "checkOnly" ? Promise<boolean> : Promise<string>;
52
-
53
- export declare type AvailableProviders<T> = T | {
54
- [K in PluginName]?: ProviderMethods;
55
- };
56
-
57
- export declare type ChainWallet<T extends Chain> = WalletMethods[T] & {
58
- chain: Chain;
59
- address: string;
60
- balance: AssetValue[];
61
- walletType: WalletOption;
62
- };
63
-
64
- export declare type ConnectWalletParamsLocal = {
65
- addChain: (params: ChainWallet<Chain>) => void;
66
- config: ConnectConfig;
67
- rpcUrls: {
68
- [chain in Chain]?: string;
69
- };
70
- apis: ApisType;
71
- };
72
-
73
- export declare type CoreTxParams = {
74
- assetValue: AssetValue;
75
- recipient: string;
76
- memo?: string;
77
- feeOptionKey?: FeeOption;
78
- feeRate?: number;
79
- data?: string;
80
- from?: string;
81
- expiration?: number;
82
- };
83
-
84
- export declare type CosmosBasedWallet<T extends typeof BinanceToolbox | typeof GaiaToolbox> = ReturnType<T> & {
85
- transfer: (params: CoreTxParams) => Promise<string>;
86
- };
87
-
88
- export declare type EVMWallet<T extends typeof AVAXToolbox | typeof BSCToolbox | typeof ETHToolbox | typeof OPToolbox> = ReturnType<T> & {
89
- transfer: (params: CoreTxParams) => Promise<string>;
90
- };
91
-
92
- declare type GenericSwapParams = {
93
- buyAsset: AssetValue;
94
- sellAsset: AssetValue;
95
- recipient: string;
96
- };
97
-
98
- export declare type OldChainWallet = {
99
- address: string;
100
- balance: AssetValue[];
101
- walletType: WalletOption;
102
- };
103
-
104
- export declare type OldWallet = {
105
- [key in Chain]: OldChainWallet | null;
106
- };
107
-
108
- export declare type PluginName = "thorchain" | "chainflip" | "mayachain";
109
-
110
- export declare type ProviderMethods = {
111
- swap: (swapParams: SwapParams) => Promise<string>;
112
- [key: string]: any;
113
- };
114
-
115
- export declare type QuoteRouteV2 = {
116
- buyAsset: string;
117
- sellAsset: string;
118
- sellAmount: number;
119
- destinationAddress: string;
120
- sourceAddress: string;
121
- providers: string[];
122
- };
123
-
124
- export declare type SubstrateBasedWallet<T extends typeof PolkadotToolbox | typeof ChainflipToolbox> = Awaited<ReturnType<T>>;
125
-
126
- export declare function SwapKit<ExtendedProviders extends {}, ConnectWalletMethods extends Record<string, ReturnType<SwapKitWallet["connect"]>>>({ stagenet, wallets, plugins, config, apis, rpcUrls, }: {
127
- plugins: SwapKitPlugin[];
128
- stagenet: boolean;
129
- wallets: SwapKitWallet[];
130
- config?: Record<string, any>;
131
- apis: Record<string, any>;
132
- rpcUrls: Record<string, any>;
133
- }): SwapKitReturnType & ConnectWalletMethods & AvailableProviders<ExtendedProviders>;
134
-
135
- /**
136
- * @deprecated Use SwapKit instead (import { SwapKit } from "@swapkit/core")
137
- */
138
- export declare class SwapKitCore<T = ""> {
139
-
140
- connectedChains: OldWallet;
141
- connectedWallets: WalletMethods;
142
- readonly stagenet: boolean;
143
- constructor({ stagenet }?: {
144
- stagenet?: boolean;
145
- } | undefined);
146
- getAddress: (chain: Chain) => string;
147
- getExplorerTxUrl: (chain: Chain, txHash: string) => string;
148
- getWallet: <T_1 extends Chain>(chain: Chain) => WalletMethods[T_1];
149
- getExplorerAddressUrl: (chain: Chain, address: string) => string;
150
- getBalance: (chain: Chain, potentialScamFilter?: boolean) => Promise<AssetValue[]>;
151
- swap: ({ streamSwap, recipient, route, feeOptionKey, }: SwapWithRouteParams) => Promise<string>;
152
- getWalletByChain: (chain: Chain, potentialScamFilter?: boolean) => Promise<{
153
- address?: string | undefined;
154
- balance?: AssetValue[] | undefined;
155
- walletType?: WalletOption | undefined;
156
- } | null>;
157
- approveAssetValue: (assetValue: AssetValue, contractAddress?: string) => Promise<string | true>;
158
- isAssetValueApproved: (assetValue: AssetValue, contractAddress?: string) => Promise<boolean>;
159
- validateAddress: ({ address, chain }: {
160
- address: string;
161
- chain: Chain;
162
- }) => boolean | Promise<boolean> | undefined;
163
- transfer: (params: CoreTxParams & {
164
- router?: string;
165
- }) => Promise<string>;
166
- deposit: ({ assetValue, recipient, router, ...rest }: CoreTxParams & {
167
- router?: string | undefined;
168
- }) => Promise<string>;
169
- /**
170
- * TC related Methods
171
- */
172
- createLiquidity: ({ runeAssetValue, assetValue, }: {
173
- runeAssetValue: AssetValue;
174
- assetValue: AssetValue;
175
- }) => Promise<{
176
- runeTx: string;
177
- assetTx: string;
178
- }>;
179
- addLiquidity: ({ runeAssetValue, assetValue, runeAddr, assetAddr, isPendingSymmAsset, mode, }: {
180
- runeAssetValue: AssetValue;
181
- assetValue: AssetValue;
182
- isPendingSymmAsset?: boolean | undefined;
183
- runeAddr?: string | undefined;
184
- assetAddr?: string | undefined;
185
- mode?: "sym" | "rune" | "asset" | undefined;
186
- }) => Promise<{
187
- runeTx: string | undefined;
188
- assetTx: string | undefined;
189
- }>;
190
- addLiquidityPart: ({ assetValue, poolAddress, address, symmetric, }: {
191
- assetValue: AssetValue;
192
- address?: string | undefined;
193
- poolAddress: string;
194
- symmetric: boolean;
195
- }) => Promise<string>;
196
- withdraw: ({ memo, assetValue, percent, from, to, }: {
197
- memo?: string | undefined;
198
- assetValue: AssetValue;
199
- percent: number;
200
- from: "sym" | "rune" | "asset";
201
- to: "sym" | "rune" | "asset";
202
- }) => Promise<string>;
203
- savings: ({ assetValue, memo, percent, type, }: {
204
- assetValue: AssetValue;
205
- memo?: string | undefined;
206
- } & ({
207
- type: "add";
208
- percent?: undefined;
209
- } | {
210
- type: "withdraw";
211
- percent: number;
212
- })) => Promise<string>;
213
- loan: ({ assetValue, memo, minAmount, type, }: {
214
- assetValue: AssetValue;
215
- memo?: string | undefined;
216
- minAmount: AssetValue;
217
- type: "open" | "close";
218
- }) => Promise<string>;
219
- nodeAction: ({ type, assetValue, address, }: {
220
- address: string;
221
- } & ({
222
- type: "bond" | "unbond";
223
- assetValue: AssetValue;
224
- } | {
225
- type: "leave";
226
- assetValue?: undefined;
227
- })) => Promise<string>;
228
- registerThorname: ({ assetValue, ...param }: ThornameRegisterParam & {
229
- assetValue: AssetValue;
230
- }) => Promise<string>;
231
- registerMayaname: ({ assetValue, ...param }: ThornameRegisterParam & {
232
- assetValue: AssetValue;
233
- }) => Promise<string>;
234
- extend: ({ wallets, config, apis, rpcUrls }: ExtendParams<T>) => void;
235
- estimateMaxSendableAmount: ({ chain, params, }: {
236
- chain: Chain;
237
- params: {
238
- from: string;
239
- recipient: string;
240
- assetValue: AssetValue;
241
- };
242
- }) => Promise<AssetValue>;
243
- /**
244
- * Wallet connection methods
245
- */
246
- connectXDEFI: (_chains: Chain[]) => Promise<void>;
247
- connectEVMWallet: (_chains: Chain[] | Chain, _wallet: EVMWalletOptions) => Promise<void>;
248
- connectWalletconnect: (_chains: Chain[], _options?: any) => Promise<void>;
249
- connectKeepkey: (_chains: Chain[], _derivationPath: number[][]) => Promise<string>;
250
- connectKeystore: (_chains: Chain[], _phrase: string) => Promise<void>;
251
- connectLedger: (_chains: Chain, _derivationPath: number[]) => Promise<void>;
252
- connectTrezor: (_chains: Chain, _derivationPath: number[]) => Promise<void>;
253
- connectKeplr: (_chain: Chain) => Promise<void>;
254
- connectOkx: (_chains: Chain[]) => Promise<void>;
255
- disconnectChain: (chain: Chain) => void;
256
- }
257
-
258
- export declare type SwapKitPlugin = ({ wallets, stagenet }: {
259
- wallets: Wallets;
260
- stagenet?: boolean;
261
- }) => {
262
- name: PluginName;
263
- methods: ProviderMethods;
264
- };
265
-
266
- declare type SwapKitPlugins = {
267
- [K in PluginName]?: ProviderMethods;
268
- };
269
-
270
- export declare type SwapKitReturnType = SwapKitPlugins & {
271
- getAddress: (chain: Chain) => string;
272
- getWallet: (chain: Chain) => ChainWallet<Chain> | undefined;
273
- getWalletWithBalance: (chain: Chain, potentialScamFilter?: boolean) => Promise<ChainWallet<Chain>>;
274
- getBalance: (chain: Chain, potentialScamFilter?: boolean) => AssetValue[];
275
- getExplorerTxUrl: (chain: Chain, txHash: string) => string;
276
- getExplorerAddressUrl: (chain: Chain, address: string) => string;
277
- swap: (params: SwapParams) => Promise<string>;
278
- validateAddress: (params: {
279
- address: string;
280
- chain: Chain;
281
- }) => boolean | Promise<boolean> | undefined;
282
- approveAssetValue: (assetValue: AssetValue, contractAddress: string) => boolean | Promise<string>;
283
- isAssetValueApproved: (assetValue: AssetValue, contractAddress: string) => boolean | Promise<boolean>;
284
- };
285
-
286
- export declare type SwapKitWallet = {
287
- connectMethodName: string;
288
- connect: (params: ConnectWalletParamsLocal) => (connectParams: any) => undefined | string;
289
- };
290
-
291
- export declare type SwapParams = (SwapWithRouteParams | GenericSwapParams) & {
292
- provider?: {
293
- name: PluginName;
294
- config: Record<string, any>;
295
- };
296
- };
297
-
298
- export declare type SwapWithRouteParams = {
299
- recipient: string;
300
- route: QuoteRoute | QuoteRouteV2;
301
- feeOptionKey?: FeeOption;
302
- quoteId?: string;
303
- streamSwap?: boolean;
304
- };
305
-
306
- export declare type ThorchainWallet = ThorchainToolboxType & {
307
- transfer: (params: CoreTxParams) => Promise<string>;
308
- deposit: (params: DepositParam) => Promise<string>;
309
- };
310
-
311
- export declare type UpgradeParams = {
312
- runeAmount: SwapKitNumber;
313
- recipient: string;
314
- };
315
-
316
- export declare type UTXOWallet<T extends typeof BCHToolbox | typeof BTCToolbox | typeof DOGEToolbox | typeof LTCToolbox> = ReturnType<T> & {
317
- transfer: (prams: CoreTxParams) => Promise<string>;
318
- };
319
-
320
- export declare type Wallet = {
321
- [key in Chain]?: ChainWallet<key>;
322
- };
323
-
324
- export declare type WalletMethods = {
325
- [Chain.Arbitrum]: EVMWallet<typeof ARBToolbox> | null;
326
- [Chain.Avalanche]: EVMWallet<typeof AVAXToolbox> | null;
327
- [Chain.BinanceSmartChain]: EVMWallet<typeof BSCToolbox> | null;
328
- [Chain.Binance]: CosmosBasedWallet<typeof BinanceToolbox> | null;
329
- [Chain.BitcoinCash]: UTXOWallet<typeof BCHToolbox> | null;
330
- [Chain.Bitcoin]: UTXOWallet<typeof BTCToolbox> | null;
331
- [Chain.Chainflip]: SubstrateBasedWallet<typeof ChainflipToolbox> | null;
332
- [Chain.Cosmos]: CosmosBasedWallet<typeof GaiaToolbox> | null;
333
- [Chain.Dash]: UTXOWallet<typeof DASHToolbox> | null;
334
- [Chain.Dogecoin]: UTXOWallet<typeof DOGEToolbox> | null;
335
- [Chain.Ethereum]: EVMWallet<typeof ETHToolbox> | null;
336
- [Chain.Kujira]: CosmosBasedWallet<typeof KujiraToolbox> | null;
337
- [Chain.Litecoin]: UTXOWallet<typeof LTCToolbox> | null;
338
- [Chain.Maya]: ThorchainWallet | null;
339
- [Chain.Optimism]: EVMWallet<typeof OPToolbox> | null;
340
- [Chain.Polkadot]: SubstrateBasedWallet<typeof PolkadotToolbox> | null;
341
- [Chain.Polygon]: EVMWallet<typeof MATICToolbox> | null;
342
- [Chain.THORChain]: ThorchainWallet | null;
343
- };
344
-
345
- export declare type Wallets = {
346
- [K in Chain]?: ChainWallet<K>;
347
- };
348
-
349
-
350
- export * from "@swapkit/helpers";
351
- export * from "@swapkit/types";
352
-
353
- export { }