@swapkit/core 1.0.0-rc.99 → 1.0.0

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.
Files changed (45) hide show
  1. package/dist/index.js +3 -0
  2. package/dist/index.js.map +12 -0
  3. package/package.json +23 -44
  4. package/src/__tests__/helpers.test.ts +65 -0
  5. package/src/client.ts +415 -0
  6. package/src/helpers/explorerUrls.ts +44 -0
  7. package/src/index.ts +6 -4
  8. package/src/types.ts +44 -0
  9. package/LICENSE +0 -201
  10. package/dist/index.cjs +0 -3
  11. package/dist/index.cjs.map +0 -1
  12. package/dist/index.d.ts +0 -230
  13. package/dist/index.es.js +0 -9119
  14. package/dist/index.es.js.map +0 -1
  15. package/src/aggregator/contracts/avaxGeneric.ts +0 -92
  16. package/src/aggregator/contracts/avaxWoofi.ts +0 -145
  17. package/src/aggregator/contracts/bscGeneric.ts +0 -106
  18. package/src/aggregator/contracts/ethGeneric.ts +0 -92
  19. package/src/aggregator/contracts/index.ts +0 -76
  20. package/src/aggregator/contracts/pancakeV2.ts +0 -145
  21. package/src/aggregator/contracts/pangolin.ts +0 -120
  22. package/src/aggregator/contracts/routers/index.ts +0 -58
  23. package/src/aggregator/contracts/routers/kyber.ts +0 -402
  24. package/src/aggregator/contracts/routers/oneinch.ts +0 -2188
  25. package/src/aggregator/contracts/routers/pancakeswap.ts +0 -340
  26. package/src/aggregator/contracts/routers/pangolin.ts +0 -340
  27. package/src/aggregator/contracts/routers/sushiswap.ts +0 -340
  28. package/src/aggregator/contracts/routers/traderJoe.ts +0 -340
  29. package/src/aggregator/contracts/routers/uniswapv2.ts +0 -340
  30. package/src/aggregator/contracts/routers/uniswapv3.ts +0 -254
  31. package/src/aggregator/contracts/routers/woofi.ts +0 -171
  32. package/src/aggregator/contracts/sushiswap.ts +0 -120
  33. package/src/aggregator/contracts/traderJoe.ts +0 -120
  34. package/src/aggregator/contracts/uniswapV2.ts +0 -120
  35. package/src/aggregator/contracts/uniswapV2Leg.ts +0 -128
  36. package/src/aggregator/contracts/uniswapV3_100.ts +0 -128
  37. package/src/aggregator/contracts/uniswapV3_10000.ts +0 -128
  38. package/src/aggregator/contracts/uniswapV3_3000.ts +0 -128
  39. package/src/aggregator/contracts/uniswapV3_500.ts +0 -128
  40. package/src/aggregator/getSwapParams.ts +0 -70
  41. package/src/client/__tests__/helpers.test.ts +0 -77
  42. package/src/client/explorerUrls.ts +0 -61
  43. package/src/client/index.ts +0 -769
  44. package/src/client/thornode.ts +0 -31
  45. package/src/client/types.ts +0 -115
package/dist/index.d.ts DELETED
@@ -1,230 +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 type { DASHToolbox } from '@swapkit/toolbox-utxo';
11
- import type { DepositParam } from '@swapkit/toolbox-cosmos';
12
- import type { DOGEToolbox } from '@swapkit/toolbox-utxo';
13
- import type { ETHToolbox } from '@swapkit/toolbox-evm';
14
- import type { EVMWalletOptions } from '@swapkit/types';
15
- import type { ExtendParams } from '@swapkit/types';
16
- import type { FeeOption } from '@swapkit/types';
17
- import type { GaiaToolbox } from '@swapkit/toolbox-cosmos';
18
- import type { KujiraToolbox } from '@swapkit/toolbox-cosmos';
19
- import type { LTCToolbox } from '@swapkit/toolbox-utxo';
20
- import type { MATICToolbox } from '@swapkit/toolbox-evm';
21
- import type { OPToolbox } from '@swapkit/toolbox-evm';
22
- import type { PolkadotToolbox } from '@swapkit/toolbox-substrate';
23
- import type { QuoteRoute } from '@swapkit/helpers';
24
- import type { SwapKitNumber } from '@swapkit/helpers';
25
- import type { ThorchainToolboxType } from '@swapkit/toolbox-cosmos';
26
- import type { ThornameRegisterParam } from '@swapkit/helpers';
27
- import type { WalletOption } from '@swapkit/types';
28
-
29
- export declare type AddLiquidityTxns = {
30
- runeTx?: string;
31
- assetTx?: string;
32
- };
33
-
34
- declare type BaseWalletMethods = {
35
- getAddress: () => Promise<string> | string;
36
- };
37
-
38
- export declare type ChainWallet = {
39
- address: string;
40
- balance: AssetValue[];
41
- walletType: WalletOption;
42
- };
43
-
44
- export declare type CoreTxParams = {
45
- assetValue: AssetValue;
46
- recipient: string;
47
- memo?: string;
48
- feeOptionKey?: FeeOption;
49
- feeRate?: number;
50
- data?: string;
51
- from?: string;
52
- expiration?: number;
53
- };
54
-
55
- export declare type CosmosBasedWallet<T extends typeof BinanceToolbox | typeof GaiaToolbox> = BaseWalletMethods & ReturnType<T> & {
56
- transfer: (params: CoreTxParams) => Promise<string>;
57
- };
58
-
59
- export declare type EVMWallet<T extends typeof AVAXToolbox | typeof BSCToolbox | typeof ETHToolbox | typeof OPToolbox> = BaseWalletMethods & ReturnType<T> & {
60
- transfer: (params: CoreTxParams) => Promise<string>;
61
- };
62
-
63
- export declare type SubstrateBasedWallet<T extends typeof PolkadotToolbox | typeof ChainflipToolbox> = Awaited<ReturnType<T>>;
64
-
65
- export declare class SwapKitCore<T = ''> {
66
-
67
- connectedChains: Wallet;
68
- connectedWallets: WalletMethods;
69
- readonly stagenet: boolean;
70
- constructor({ stagenet }?: {
71
- stagenet?: boolean;
72
- } | undefined);
73
- getAddress: (chain: Chain) => string;
74
- getExplorerTxUrl: (chain: Chain, txHash: string) => string;
75
- getWallet: <T_1 extends Chain>(chain: Chain) => WalletMethods[T_1];
76
- getExplorerAddressUrl: (chain: Chain, address: string) => string;
77
- getBalance: (chain: Chain, potentialScamFilter?: boolean) => Promise<AssetValue[]>;
78
- swap: ({ streamSwap, recipient, route, feeOptionKey }: SwapParams) => Promise<string>;
79
- getWalletByChain: (chain: Chain, potentialScamFilter?: boolean) => Promise<{
80
- address?: string | undefined;
81
- balance?: AssetValue[] | undefined;
82
- walletType?: WalletOption | undefined;
83
- } | null>;
84
- approveAssetValue: (assetValue: AssetValue, contractAddress?: string) => Promise<string | true>;
85
- isAssetValueApproved: (assetValue: AssetValue, contractAddress?: string) => Promise<boolean>;
86
- validateAddress: ({ address, chain }: {
87
- address: string;
88
- chain: Chain;
89
- }) => boolean | Promise<boolean> | undefined;
90
- transfer: (params: CoreTxParams & {
91
- router?: string;
92
- }) => Promise<string>;
93
- deposit: ({ assetValue, recipient, router, ...rest }: CoreTxParams & {
94
- router?: string | undefined;
95
- }) => Promise<string>;
96
- /**
97
- * TC related Methods
98
- */
99
- createLiquidity: ({ runeAssetValue, assetValue, }: {
100
- runeAssetValue: AssetValue;
101
- assetValue: AssetValue;
102
- }) => Promise<{
103
- runeTx: string;
104
- assetTx: string;
105
- }>;
106
- addLiquidity: ({ runeAssetValue, assetValue, runeAddr, assetAddr, isPendingSymmAsset, mode, }: {
107
- runeAssetValue: AssetValue;
108
- assetValue: AssetValue;
109
- isPendingSymmAsset?: boolean | undefined;
110
- runeAddr?: string | undefined;
111
- assetAddr?: string | undefined;
112
- mode?: "sym" | "rune" | "asset" | undefined;
113
- }) => Promise<{
114
- runeTx: string | undefined;
115
- assetTx: string | undefined;
116
- }>;
117
- addLiquidityPart: ({ assetValue, poolAddress, address, symmetric, }: {
118
- assetValue: AssetValue;
119
- address?: string | undefined;
120
- poolAddress: string;
121
- symmetric: boolean;
122
- }) => Promise<string>;
123
- withdraw: ({ memo, assetValue, percent, from, to, }: {
124
- memo?: string | undefined;
125
- assetValue: AssetValue;
126
- percent: number;
127
- from: 'sym' | 'rune' | 'asset';
128
- to: 'sym' | 'rune' | 'asset';
129
- }) => Promise<string>;
130
- savings: ({ assetValue, memo, percent, type, }: {
131
- assetValue: AssetValue;
132
- memo?: string | undefined;
133
- } & ({
134
- type: 'add';
135
- percent?: undefined;
136
- } | {
137
- type: 'withdraw';
138
- percent: number;
139
- })) => Promise<string>;
140
- loan: ({ assetValue, memo, minAmount, type, }: {
141
- assetValue: AssetValue;
142
- memo?: string | undefined;
143
- minAmount: AssetValue;
144
- type: 'open' | 'close';
145
- }) => Promise<string>;
146
- nodeAction: ({ type, assetValue, address, }: {
147
- address: string;
148
- } & ({
149
- type: 'bond' | 'unbond';
150
- assetValue: AssetValue;
151
- } | {
152
- type: 'leave';
153
- assetValue?: undefined;
154
- })) => Promise<string>;
155
- registerThorname: ({ assetValue, ...param }: ThornameRegisterParam & {
156
- assetValue: AssetValue;
157
- }) => Promise<string>;
158
- extend: ({ wallets, config, apis, rpcUrls }: ExtendParams<T>) => void;
159
- estimateMaxSendableAmount: ({ chain, params, }: {
160
- chain: Chain;
161
- params: {
162
- from: string;
163
- recipient: string;
164
- assetValue: AssetValue;
165
- };
166
- }) => Promise<AssetValue>;
167
- /**
168
- * Wallet connection methods
169
- */
170
- connectXDEFI: (_chains: Chain[]) => Promise<void>;
171
- connectEVMWallet: (_chains: Chain[] | Chain, _wallet: EVMWalletOptions) => Promise<void>;
172
- connectWalletconnect: (_chains: Chain[], _options?: any) => Promise<void>;
173
- connectKeepkey: (_chains: Chain[], _derivationPath: number[][]) => Promise<string>;
174
- connectKeystore: (_chains: Chain[], _phrase: string) => Promise<void>;
175
- connectLedger: (_chains: Chain, _derivationPath: number[]) => Promise<void>;
176
- connectTrezor: (_chains: Chain, _derivationPath: number[]) => Promise<void>;
177
- connectKeplr: (_chain: Chain) => Promise<void>;
178
- connectOkx: (_chains: Chain[]) => Promise<void>;
179
- disconnectChain: (chain: Chain) => void;
180
- }
181
-
182
- export declare type SwapParams = {
183
- recipient: string;
184
- streamSwap?: boolean;
185
- route: QuoteRoute;
186
- feeOptionKey: FeeOption;
187
- };
188
-
189
- export declare type ThorchainWallet = BaseWalletMethods & ThorchainToolboxType & {
190
- transfer: (params: CoreTxParams) => Promise<string>;
191
- deposit: (params: DepositParam) => Promise<string>;
192
- };
193
-
194
- export declare type UpgradeParams = {
195
- runeAmount: SwapKitNumber;
196
- recipient: string;
197
- };
198
-
199
- export declare type UTXOWallet<T extends typeof BCHToolbox | typeof BTCToolbox | typeof DOGEToolbox | typeof LTCToolbox> = BaseWalletMethods & ReturnType<T> & {
200
- transfer: (prams: CoreTxParams) => Promise<string>;
201
- };
202
-
203
- export declare type Wallet = Record<Chain, ChainWallet | null>;
204
-
205
- export declare type WalletMethods = {
206
- [Chain.Arbitrum]: EVMWallet<typeof ARBToolbox> | null;
207
- [Chain.Avalanche]: EVMWallet<typeof AVAXToolbox> | null;
208
- [Chain.BinanceSmartChain]: EVMWallet<typeof BSCToolbox> | null;
209
- [Chain.Binance]: CosmosBasedWallet<typeof BinanceToolbox> | null;
210
- [Chain.BitcoinCash]: UTXOWallet<typeof BCHToolbox> | null;
211
- [Chain.Bitcoin]: UTXOWallet<typeof BTCToolbox> | null;
212
- [Chain.Chainflip]: SubstrateBasedWallet<typeof ChainflipToolbox> | null;
213
- [Chain.Cosmos]: CosmosBasedWallet<typeof GaiaToolbox> | null;
214
- [Chain.Dash]: UTXOWallet<typeof DASHToolbox> | null;
215
- [Chain.Dogecoin]: UTXOWallet<typeof DOGEToolbox> | null;
216
- [Chain.Ethereum]: EVMWallet<typeof ETHToolbox> | null;
217
- [Chain.Kujira]: CosmosBasedWallet<typeof KujiraToolbox> | null;
218
- [Chain.Litecoin]: UTXOWallet<typeof LTCToolbox> | null;
219
- [Chain.Maya]: ThorchainWallet | null;
220
- [Chain.Optimism]: EVMWallet<typeof OPToolbox> | null;
221
- [Chain.Polkadot]: SubstrateBasedWallet<typeof PolkadotToolbox> | null;
222
- [Chain.Polygon]: EVMWallet<typeof MATICToolbox> | null;
223
- [Chain.THORChain]: ThorchainWallet | null;
224
- };
225
-
226
-
227
- export * from "@swapkit/helpers";
228
- export * from "@swapkit/types";
229
-
230
- export { }