@swapkit/core 1.0.0-rc.10 → 1.0.0-rc.101

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 (43) hide show
  1. package/dist/index.cjs +2 -2
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.ts +162 -28
  4. package/dist/index.es.js +6481 -1101
  5. package/dist/index.es.js.map +1 -0
  6. package/package.json +23 -30
  7. package/src/__tests__/helpers.test.ts +79 -0
  8. package/src/aggregator/contracts/avaxGeneric.ts +50 -50
  9. package/src/aggregator/contracts/avaxWoofi.ts +80 -80
  10. package/src/aggregator/contracts/bscGeneric.ts +59 -59
  11. package/src/aggregator/contracts/ethGeneric.ts +50 -50
  12. package/src/aggregator/contracts/index.ts +30 -28
  13. package/src/aggregator/contracts/pancakeV2.ts +80 -80
  14. package/src/aggregator/contracts/pangolin.ts +65 -65
  15. package/src/aggregator/contracts/routers/index.ts +58 -0
  16. package/src/aggregator/contracts/routers/kyber.ts +402 -0
  17. package/src/aggregator/contracts/routers/oneinch.ts +2188 -0
  18. package/src/aggregator/contracts/routers/pancakeswap.ts +340 -0
  19. package/src/aggregator/contracts/routers/pangolin.ts +340 -0
  20. package/src/aggregator/contracts/routers/sushiswap.ts +340 -0
  21. package/src/aggregator/contracts/routers/traderJoe.ts +340 -0
  22. package/src/aggregator/contracts/routers/uniswapv2.ts +340 -0
  23. package/src/aggregator/contracts/routers/uniswapv3.ts +254 -0
  24. package/src/aggregator/contracts/routers/woofi.ts +171 -0
  25. package/src/aggregator/contracts/sushiswap.ts +65 -65
  26. package/src/aggregator/contracts/traderJoe.ts +65 -65
  27. package/src/aggregator/contracts/uniswapV2.ts +65 -65
  28. package/src/aggregator/contracts/uniswapV2Leg.ts +70 -70
  29. package/src/aggregator/contracts/uniswapV3_100.ts +70 -70
  30. package/src/aggregator/contracts/uniswapV3_10000.ts +70 -70
  31. package/src/aggregator/contracts/uniswapV3_3000.ts +70 -70
  32. package/src/aggregator/contracts/uniswapV3_500.ts +70 -70
  33. package/src/aggregator/getSwapParams.ts +12 -12
  34. package/src/client/index.ts +212 -646
  35. package/src/client/old.ts +837 -0
  36. package/src/{client → helpers}/explorerUrls.ts +9 -10
  37. package/src/{client → helpers}/thornode.ts +5 -5
  38. package/src/index.ts +6 -4
  39. package/src/types.ts +149 -0
  40. package/dist/index-9e36735e.cjs +0 -1
  41. package/dist/index-cf1865cd.js +0 -649
  42. package/src/client/__tests__/helpers.test.ts +0 -69
  43. package/src/client/types.ts +0 -103
@@ -1,69 +0,0 @@
1
- import { Chain, ChainToExplorerUrl } from '@swapkit/types';
2
- import { describe, expect, test } from 'vitest';
3
-
4
- import { getExplorerAddressUrl, getExplorerTxUrl } from '../explorerUrls.ts';
5
-
6
- describe('Explorer URLs', () => {
7
- Object.values(Chain)
8
- .filter((c) => ![Chain.Litecoin, Chain.Dogecoin, Chain.Cosmos].includes(c))
9
- .forEach((chain) => {
10
- test(`getExplorerTxUrl returns correct URL for ${chain}`, () => {
11
- expect(getExplorerTxUrl({ chain, txHash: '0x12345' })).toBe(
12
- `${ChainToExplorerUrl[chain]}/tx/0x12345`,
13
- );
14
-
15
- expect(getExplorerAddressUrl({ chain, address: 'asdfg' })).toBe(
16
- `${ChainToExplorerUrl[chain]}/address/asdfg`,
17
- );
18
- });
19
- });
20
-
21
- test('getExplorerTxUrl throws Error for unsupported Chain', () => {
22
- expect(() =>
23
- getExplorerTxUrl({ chain: 'unsupported' as Chain, txHash: '0x12345' }),
24
- ).toThrowError('Unsupported chain: unsupported');
25
- });
26
- test('getExplorerAddressUrl throws Error for unsupported Chain', () => {
27
- expect(() =>
28
- getExplorerAddressUrl({ chain: 'unsupported' as Chain, address: 'asdfg' }),
29
- ).toThrowError('Unsupported chain: unsupported');
30
- });
31
- test('getExplorerTxUrl adds 0x for EVM like chains', () => {
32
- expect(getExplorerTxUrl({ chain: Chain.Ethereum, txHash: '12345' })).toBe(
33
- 'https://etherscan.io/tx/0x12345',
34
- );
35
- });
36
-
37
- test('getExplorerTxUrl returns correct URL for Litecoin', () => {
38
- expect(getExplorerTxUrl({ chain: Chain.Litecoin, txHash: 'efghi' })).toBe(
39
- 'https://ltc.bitaps.com/efghi',
40
- );
41
- });
42
- test('getExplorerAddressUrl returns correct URL for Litecoin', () => {
43
- expect(getExplorerAddressUrl({ chain: Chain.Litecoin, address: '12345' })).toBe(
44
- 'https://ltc.bitaps.com/12345',
45
- );
46
- });
47
-
48
- test('getExplorerTxUrl returns correct URL for Cosmos', () => {
49
- expect(getExplorerTxUrl({ chain: Chain.Cosmos, txHash: 'pqrst' })).toBe(
50
- 'https://cosmos.bigdipper.live/transactions/pqrst',
51
- );
52
- });
53
- test('getExplorerAddressUrl returns correct URL for Cosmos', () => {
54
- expect(getExplorerAddressUrl({ chain: Chain.Cosmos, address: 'zabcd' })).toBe(
55
- 'https://cosmos.bigdipper.live/account/zabcd',
56
- );
57
- });
58
-
59
- test('getExplorerTxUrl returns correct URL for Doge', () => {
60
- expect(getExplorerTxUrl({ chain: Chain.Dogecoin, txHash: 'uvwxy' })).toBe(
61
- 'https://blockchair.com/dogecoin/transaction/uvwxy',
62
- );
63
- });
64
- test('getExplorerAddressUrl returns correct URL for Doge', () => {
65
- expect(getExplorerAddressUrl({ chain: Chain.Dogecoin, address: 'efghi' })).toBe(
66
- 'https://blockchair.com/dogecoin/address/efghi',
67
- );
68
- });
69
- });
@@ -1,103 +0,0 @@
1
- import type { QuoteRoute } from '@swapkit/api';
2
- import type { AssetValue, SwapKitNumber } from '@swapkit/helpers';
3
- import type {
4
- BinanceToolbox,
5
- DepositParam,
6
- GaiaToolbox,
7
- KujiraToolbox,
8
- ThorchainToolboxType,
9
- } from '@swapkit/toolbox-cosmos';
10
- import type {
11
- ARBToolbox,
12
- AVAXToolbox,
13
- BSCToolbox,
14
- ETHToolbox,
15
- MATICToolbox,
16
- OPToolbox,
17
- } from '@swapkit/toolbox-evm';
18
- import type { BCHToolbox, BTCToolbox, DOGEToolbox, LTCToolbox } from '@swapkit/toolbox-utxo';
19
- import type { Chain, FeeOption, WalletOption } from '@swapkit/types';
20
-
21
- type BaseWalletMethods = {
22
- getAddress: () => Promise<string> | string;
23
- };
24
-
25
- export type CoreTxParams = {
26
- assetValue: AssetValue;
27
- recipient: string;
28
- memo?: string;
29
- feeOptionKey?: FeeOption;
30
- feeRate?: number;
31
- data?: string;
32
- from?: string;
33
- expiration?: number;
34
- };
35
-
36
- export type AddLiquidityTxns = {
37
- runeTx?: string;
38
- assetTx?: string;
39
- };
40
-
41
- export type UpgradeParams = {
42
- runeAmount: SwapKitNumber;
43
- recipient: string;
44
- };
45
-
46
- export type ChainWallet = {
47
- address: string;
48
- balance: AssetValue[];
49
- walletType: WalletOption;
50
- };
51
-
52
- export type Wallet = Record<Chain, ChainWallet | null>;
53
-
54
- export type ThorchainWallet = BaseWalletMethods &
55
- ThorchainToolboxType & {
56
- transfer: (params: CoreTxParams) => Promise<string>;
57
- deposit: (params: DepositParam) => Promise<string>;
58
- };
59
-
60
- export type CosmosBasedWallet<T extends typeof BinanceToolbox | typeof GaiaToolbox> =
61
- BaseWalletMethods &
62
- ReturnType<T> & {
63
- transfer: (params: CoreTxParams) => Promise<string>;
64
- };
65
-
66
- export type EVMWallet<
67
- T extends typeof AVAXToolbox | typeof BSCToolbox | typeof ETHToolbox | typeof OPToolbox,
68
- > = BaseWalletMethods &
69
- ReturnType<T> & {
70
- transfer: (params: CoreTxParams) => Promise<string>;
71
- };
72
-
73
- export type UTXOWallet<
74
- T extends typeof BCHToolbox | typeof BTCToolbox | typeof DOGEToolbox | typeof LTCToolbox,
75
- > = BaseWalletMethods &
76
- ReturnType<T> & {
77
- transfer: (prams: CoreTxParams) => Promise<string>;
78
- };
79
-
80
- export type WalletMethods = {
81
- [Chain.Arbitrum]: EVMWallet<typeof ARBToolbox> | null;
82
- [Chain.Avalanche]: EVMWallet<typeof AVAXToolbox> | null;
83
- [Chain.BinanceSmartChain]: EVMWallet<typeof BSCToolbox> | null;
84
- [Chain.Binance]: CosmosBasedWallet<typeof BinanceToolbox> | null;
85
- [Chain.BitcoinCash]: UTXOWallet<typeof BCHToolbox> | null;
86
- [Chain.Bitcoin]: UTXOWallet<typeof BTCToolbox> | null;
87
- [Chain.Cosmos]: CosmosBasedWallet<typeof GaiaToolbox> | null;
88
- [Chain.Dogecoin]: UTXOWallet<typeof DOGEToolbox> | null;
89
- [Chain.Ethereum]: EVMWallet<typeof ETHToolbox> | null;
90
- [Chain.Kujira]: CosmosBasedWallet<typeof KujiraToolbox> | null;
91
- [Chain.Litecoin]: UTXOWallet<typeof LTCToolbox> | null;
92
- [Chain.Maya]: ThorchainWallet | null;
93
- [Chain.Optimism]: EVMWallet<typeof OPToolbox> | null;
94
- [Chain.Polygon]: EVMWallet<typeof MATICToolbox> | null;
95
- [Chain.THORChain]: ThorchainWallet | null;
96
- };
97
-
98
- export type SwapParams = {
99
- recipient: string;
100
- streamSwap?: boolean;
101
- route: QuoteRoute;
102
- feeOptionKey: FeeOption;
103
- };