@swapkit/helpers 2.6.0 → 3.0.0-beta.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.
- package/dist/api/index.cjs +3 -0
- package/dist/api/index.cjs.map +16 -0
- package/dist/api/index.js +3 -0
- package/dist/api/index.js.map +16 -0
- package/dist/chunk-1gwdyyeh.js +4 -0
- package/dist/chunk-1gwdyyeh.js.map +10 -0
- package/dist/chunk-2bhvezjh.js +4 -0
- package/dist/chunk-2bhvezjh.js.map +10 -0
- package/dist/chunk-3ptwhtpd.js +3 -0
- package/dist/chunk-3ptwhtpd.js.map +10 -0
- package/dist/chunk-3wnfcm30.js +4 -0
- package/dist/chunk-3wnfcm30.js.map +9 -0
- package/dist/chunk-40epvqbm.js +3 -0
- package/dist/chunk-40epvqbm.js.map +10 -0
- package/dist/chunk-49nsjaay.js +3 -0
- package/dist/chunk-49nsjaay.js.map +10 -0
- package/dist/chunk-4b66tryh.js +4 -0
- package/dist/chunk-4b66tryh.js.map +10 -0
- package/dist/chunk-4kzjrrjv.js +3 -0
- package/dist/chunk-4kzjrrjv.js.map +10 -0
- package/dist/chunk-5m49s8z8.js +4 -0
- package/dist/chunk-5m49s8z8.js.map +10 -0
- package/dist/chunk-9b6y7r75.js +4 -0
- package/dist/chunk-9b6y7r75.js.map +10 -0
- package/dist/chunk-9zcbvqq2.js +3 -0
- package/dist/chunk-9zcbvqq2.js.map +10 -0
- package/dist/chunk-a0bpx1q3.js +4 -0
- package/dist/chunk-a0bpx1q3.js.map +10 -0
- package/dist/chunk-a0fxkkfh.js +4 -0
- package/dist/chunk-a0fxkkfh.js.map +10 -0
- package/dist/chunk-a6bjd9ar.js +3 -0
- package/dist/chunk-a6bjd9ar.js.map +10 -0
- package/dist/chunk-bg6pz5qh.js +3 -0
- package/dist/chunk-bg6pz5qh.js.map +10 -0
- package/dist/chunk-cpdcnp2x.js +4 -0
- package/dist/chunk-cpdcnp2x.js.map +10 -0
- package/dist/chunk-fazw0jvt.js +3 -0
- package/dist/chunk-fazw0jvt.js.map +9 -0
- package/dist/chunk-fr86y3rx.js +4 -0
- package/dist/chunk-fr86y3rx.js.map +10 -0
- package/dist/chunk-ftdtdkhk.js +3 -0
- package/dist/chunk-ftdtdkhk.js.map +10 -0
- package/dist/chunk-gjeaw024.js +4 -0
- package/dist/chunk-gjeaw024.js.map +10 -0
- package/dist/chunk-hdcdd2cf.js +4 -0
- package/dist/chunk-hdcdd2cf.js.map +10 -0
- package/dist/chunk-q2pb6ggs.js +3 -0
- package/dist/chunk-q2pb6ggs.js.map +10 -0
- package/dist/chunk-t9s9811k.js +3 -0
- package/dist/chunk-t9s9811k.js.map +10 -0
- package/dist/chunk-v4dvhh90.js +4 -0
- package/dist/chunk-v4dvhh90.js.map +10 -0
- package/dist/chunk-vzptz52h.js +4 -0
- package/dist/chunk-vzptz52h.js.map +10 -0
- package/dist/chunk-wyr5d8ad.js +3 -0
- package/dist/chunk-wyr5d8ad.js.map +10 -0
- package/dist/chunk-x0jsq6ag.js +3 -0
- package/dist/chunk-x0jsq6ag.js.map +10 -0
- package/dist/chunk-x2fe9scs.js +3 -0
- package/dist/chunk-x2fe9scs.js.map +10 -0
- package/dist/chunk-xm5jkehh.js +4 -0
- package/dist/chunk-xm5jkehh.js.map +10 -0
- package/dist/chunk-xzb1nshn.js +3 -0
- package/dist/chunk-xzb1nshn.js.map +10 -0
- package/dist/contracts/index.cjs +3 -0
- package/dist/contracts/index.cjs.map +38 -0
- package/dist/contracts/index.js +3 -0
- package/dist/contracts/index.js.map +38 -0
- package/dist/index.cjs +6 -0
- package/dist/index.cjs.map +30 -0
- package/dist/index.js +3 -3
- package/dist/index.js.map +23 -23
- package/dist/tokens/index.cjs +3 -0
- package/dist/tokens/index.cjs.map +10 -0
- package/dist/tokens/index.js +3 -0
- package/dist/tokens/index.js.map +10 -0
- package/package.json +35 -16
- package/src/api/index.ts +19 -0
- package/src/api/microgard/endpoints.ts +83 -0
- package/src/api/microgard/types.ts +60 -0
- package/src/api/midgard/endpoints.ts +154 -0
- package/src/api/midgard/types.ts +155 -0
- package/src/api/swapkitApi/endpoints.ts +161 -0
- package/src/api/swapkitApi/types.ts +576 -0
- package/src/api/thornode/endpoints.ts +78 -0
- package/src/api/thornode/types.ts +241 -0
- package/src/api/thorswapStatic/endpoints.ts +46 -0
- package/src/api/thorswapStatic/types.ts +18 -0
- package/src/contracts/abis/avaxGeneric.ts +92 -0
- package/src/contracts/abis/avaxWoofi.ts +145 -0
- package/src/contracts/abis/bscGeneric.ts +106 -0
- package/src/contracts/abis/chainflipGateway.ts +330 -0
- package/src/contracts/abis/erc20.ts +99 -0
- package/src/contracts/abis/ethGeneric.ts +92 -0
- package/src/contracts/abis/mayaEvmVaults.ts +331 -0
- package/src/contracts/abis/pancakeV2.ts +145 -0
- package/src/contracts/abis/pangolin.ts +120 -0
- package/src/contracts/abis/sushiswap.ts +120 -0
- package/src/contracts/abis/tcEthVault.ts +650 -0
- package/src/contracts/abis/traderJoe.ts +120 -0
- package/src/contracts/abis/uniswapV2.ts +120 -0
- package/src/contracts/abis/uniswapV2Leg.ts +128 -0
- package/src/contracts/abis/uniswapV3_100.ts +128 -0
- package/src/contracts/abis/uniswapV3_10000.ts +128 -0
- package/src/contracts/abis/uniswapV3_3000.ts +128 -0
- package/src/contracts/abis/uniswapV3_500.ts +128 -0
- package/src/contracts/index.ts +95 -0
- package/src/contracts/routers/index.ts +58 -0
- package/src/contracts/routers/kyber.ts +402 -0
- package/src/contracts/routers/oneinch.ts +2188 -0
- package/src/contracts/routers/pancakeswap.ts +340 -0
- package/src/contracts/routers/pangolin.ts +340 -0
- package/src/contracts/routers/sushiswap.ts +340 -0
- package/src/contracts/routers/traderJoe.ts +340 -0
- package/src/contracts/routers/uniswapv2.ts +340 -0
- package/src/contracts/routers/uniswapv3.ts +254 -0
- package/src/contracts/routers/woofi.ts +171 -0
- package/src/index.ts +19 -15
- package/src/modules/__tests__/assetValue.test.ts +50 -24
- package/src/modules/__tests__/swapKitConfig.test.ts +37 -0
- package/src/modules/assetValue.ts +82 -141
- package/src/modules/bigIntArithmetics.ts +6 -2
- package/src/modules/requestClient.ts +53 -65
- package/src/modules/swapKitConfig.ts +134 -0
- package/src/modules/swapKitError.ts +19 -14
- package/src/tokens/index.ts +15 -0
- package/src/tokens/lists/camelot_v3.ts +15920 -0
- package/src/tokens/lists/caviar_v1.ts +1694 -0
- package/src/tokens/lists/chainflip.ts +104 -0
- package/src/tokens/lists/index.ts +14 -0
- package/src/tokens/lists/jupiter.ts +29606 -0
- package/src/tokens/lists/mayachain.ts +513 -0
- package/src/tokens/lists/oneinch.ts +14238 -0
- package/src/tokens/lists/openocean_v2.ts +11514 -0
- package/src/tokens/lists/pancakeswap.ts +4296 -0
- package/src/tokens/lists/pangolin_v1.ts +175 -0
- package/src/tokens/lists/sushiswap_v2.ts +965 -0
- package/src/tokens/lists/thorchain.ts +669 -0
- package/src/tokens/lists/traderjoe_v2.ts +1384 -0
- package/src/tokens/lists/uniswap_v2.ts +5596 -0
- package/src/tokens/lists/uniswap_v3.ts +5946 -0
- package/src/types/chains.ts +48 -51
- package/src/types/commonTypes.ts +3 -90
- package/src/types/derivationPath.ts +11 -24
- package/src/types/index.ts +3 -4
- package/src/types/quotes.ts +0 -1
- package/src/types/radix.ts +2 -2
- package/src/types/sdk.ts +0 -40
- package/src/types/tokens.ts +14 -17
- package/src/types/wallet.ts +70 -33
- package/src/{helpers → utils}/__tests__/asset.test.ts +0 -27
- package/src/utils/asset.ts +235 -0
- package/src/{helpers → utils}/derivationPath.ts +31 -9
- package/src/{helpers → utils}/memo.ts +0 -82
- package/src/{helpers → utils}/others.ts +12 -5
- package/src/utils/plugin.ts +13 -0
- package/src/utils/tokens.ts +73 -0
- package/src/{helpers → utils}/validators.ts +7 -5
- package/src/{helpers/web3wallets.ts → utils/wallets.ts} +189 -145
- package/src/helpers/asset.ts +0 -324
- package/src/modules/walletUtils.ts +0 -30
- package/src/types/network.ts +0 -49
- /package/src/{helpers/__tests__/derivationPath.ts → utils/__tests__/derivationPath.test.ts} +0 -0
- /package/src/{helpers → utils}/__tests__/memo.test.ts +0 -0
- /package/src/{helpers → utils}/__tests__/others.test.ts +0 -0
- /package/src/{helpers → utils}/__tests__/validators.test.ts +0 -0
- /package/src/{helpers → utils}/liquidity.ts +0 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
export const woofiRouter = [
|
|
2
|
+
{
|
|
3
|
+
inputs: [
|
|
4
|
+
{ internalType: "address", name: "_weth", type: "address" },
|
|
5
|
+
{ internalType: "address", name: "_pool", type: "address" },
|
|
6
|
+
],
|
|
7
|
+
stateMutability: "nonpayable",
|
|
8
|
+
type: "constructor",
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
anonymous: false,
|
|
12
|
+
inputs: [
|
|
13
|
+
{ indexed: true, internalType: "address", name: "previousOwner", type: "address" },
|
|
14
|
+
{ indexed: true, internalType: "address", name: "newOwner", type: "address" },
|
|
15
|
+
],
|
|
16
|
+
name: "OwnershipTransferred",
|
|
17
|
+
type: "event",
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
anonymous: false,
|
|
21
|
+
inputs: [{ indexed: false, internalType: "address", name: "newPool", type: "address" }],
|
|
22
|
+
name: "WooPoolChanged",
|
|
23
|
+
type: "event",
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
anonymous: false,
|
|
27
|
+
inputs: [
|
|
28
|
+
{
|
|
29
|
+
indexed: false,
|
|
30
|
+
internalType: "enum IWooRouterV2.SwapType",
|
|
31
|
+
name: "swapType",
|
|
32
|
+
type: "uint8",
|
|
33
|
+
},
|
|
34
|
+
{ indexed: true, internalType: "address", name: "fromToken", type: "address" },
|
|
35
|
+
{ indexed: true, internalType: "address", name: "toToken", type: "address" },
|
|
36
|
+
{ indexed: false, internalType: "uint256", name: "fromAmount", type: "uint256" },
|
|
37
|
+
{ indexed: false, internalType: "uint256", name: "toAmount", type: "uint256" },
|
|
38
|
+
{ indexed: false, internalType: "address", name: "from", type: "address" },
|
|
39
|
+
{ indexed: true, internalType: "address", name: "to", type: "address" },
|
|
40
|
+
{ indexed: false, internalType: "address", name: "rebateTo", type: "address" },
|
|
41
|
+
],
|
|
42
|
+
name: "WooRouterSwap",
|
|
43
|
+
type: "event",
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
inputs: [],
|
|
47
|
+
name: "WETH",
|
|
48
|
+
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
49
|
+
stateMutability: "view",
|
|
50
|
+
type: "function",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
inputs: [
|
|
54
|
+
{ internalType: "address", name: "approveTarget", type: "address" },
|
|
55
|
+
{ internalType: "address", name: "swapTarget", type: "address" },
|
|
56
|
+
{ internalType: "address", name: "fromToken", type: "address" },
|
|
57
|
+
{ internalType: "address", name: "toToken", type: "address" },
|
|
58
|
+
{ internalType: "uint256", name: "fromAmount", type: "uint256" },
|
|
59
|
+
{ internalType: "uint256", name: "minToAmount", type: "uint256" },
|
|
60
|
+
{ internalType: "address payable", name: "to", type: "address" },
|
|
61
|
+
{ internalType: "bytes", name: "data", type: "bytes" },
|
|
62
|
+
],
|
|
63
|
+
name: "externalSwap",
|
|
64
|
+
outputs: [{ internalType: "uint256", name: "realToAmount", type: "uint256" }],
|
|
65
|
+
stateMutability: "payable",
|
|
66
|
+
type: "function",
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
inputs: [{ internalType: "address", name: "stuckToken", type: "address" }],
|
|
70
|
+
name: "inCaseTokenGotStuck",
|
|
71
|
+
outputs: [],
|
|
72
|
+
stateMutability: "nonpayable",
|
|
73
|
+
type: "function",
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
inputs: [{ internalType: "address", name: "", type: "address" }],
|
|
77
|
+
name: "isWhitelisted",
|
|
78
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
79
|
+
stateMutability: "view",
|
|
80
|
+
type: "function",
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
inputs: [],
|
|
84
|
+
name: "owner",
|
|
85
|
+
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
86
|
+
stateMutability: "view",
|
|
87
|
+
type: "function",
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
inputs: [
|
|
91
|
+
{ internalType: "address", name: "fromToken", type: "address" },
|
|
92
|
+
{ internalType: "address", name: "toToken", type: "address" },
|
|
93
|
+
{ internalType: "uint256", name: "fromAmount", type: "uint256" },
|
|
94
|
+
],
|
|
95
|
+
name: "querySwap",
|
|
96
|
+
outputs: [{ internalType: "uint256", name: "toAmount", type: "uint256" }],
|
|
97
|
+
stateMutability: "view",
|
|
98
|
+
type: "function",
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
inputs: [],
|
|
102
|
+
name: "quoteToken",
|
|
103
|
+
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
104
|
+
stateMutability: "view",
|
|
105
|
+
type: "function",
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
inputs: [],
|
|
109
|
+
name: "renounceOwnership",
|
|
110
|
+
outputs: [],
|
|
111
|
+
stateMutability: "nonpayable",
|
|
112
|
+
type: "function",
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
inputs: [{ internalType: "address", name: "newPool", type: "address" }],
|
|
116
|
+
name: "setPool",
|
|
117
|
+
outputs: [],
|
|
118
|
+
stateMutability: "nonpayable",
|
|
119
|
+
type: "function",
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
inputs: [
|
|
123
|
+
{ internalType: "address", name: "target", type: "address" },
|
|
124
|
+
{ internalType: "bool", name: "whitelisted", type: "bool" },
|
|
125
|
+
],
|
|
126
|
+
name: "setWhitelisted",
|
|
127
|
+
outputs: [],
|
|
128
|
+
stateMutability: "nonpayable",
|
|
129
|
+
type: "function",
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
inputs: [
|
|
133
|
+
{ internalType: "address", name: "fromToken", type: "address" },
|
|
134
|
+
{ internalType: "address", name: "toToken", type: "address" },
|
|
135
|
+
{ internalType: "uint256", name: "fromAmount", type: "uint256" },
|
|
136
|
+
{ internalType: "uint256", name: "minToAmount", type: "uint256" },
|
|
137
|
+
{ internalType: "address payable", name: "to", type: "address" },
|
|
138
|
+
{ internalType: "address", name: "rebateTo", type: "address" },
|
|
139
|
+
],
|
|
140
|
+
name: "swap",
|
|
141
|
+
outputs: [{ internalType: "uint256", name: "realToAmount", type: "uint256" }],
|
|
142
|
+
stateMutability: "payable",
|
|
143
|
+
type: "function",
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
inputs: [{ internalType: "address", name: "newOwner", type: "address" }],
|
|
147
|
+
name: "transferOwnership",
|
|
148
|
+
outputs: [],
|
|
149
|
+
stateMutability: "nonpayable",
|
|
150
|
+
type: "function",
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
inputs: [
|
|
154
|
+
{ internalType: "address", name: "fromToken", type: "address" },
|
|
155
|
+
{ internalType: "address", name: "toToken", type: "address" },
|
|
156
|
+
{ internalType: "uint256", name: "fromAmount", type: "uint256" },
|
|
157
|
+
],
|
|
158
|
+
name: "tryQuerySwap",
|
|
159
|
+
outputs: [{ internalType: "uint256", name: "toAmount", type: "uint256" }],
|
|
160
|
+
stateMutability: "view",
|
|
161
|
+
type: "function",
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
inputs: [],
|
|
165
|
+
name: "wooPool",
|
|
166
|
+
outputs: [{ internalType: "contract IWooPPV2", name: "", type: "address" }],
|
|
167
|
+
stateMutability: "view",
|
|
168
|
+
type: "function",
|
|
169
|
+
},
|
|
170
|
+
{ stateMutability: "payable", type: "receive" },
|
|
171
|
+
];
|
package/src/index.ts
CHANGED
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
export * from "@swapkit/contracts";
|
|
2
|
-
export * from "./types/index";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Helpers
|
|
6
|
-
*/
|
|
7
|
-
export * from "./helpers/asset";
|
|
8
|
-
export * from "./helpers/derivationPath";
|
|
9
|
-
export * from "./helpers/liquidity";
|
|
10
|
-
export * from "./helpers/memo";
|
|
11
|
-
export * from "./helpers/others";
|
|
12
|
-
export * from "./helpers/validators";
|
|
13
|
-
export * from "./helpers/web3wallets";
|
|
14
|
-
|
|
15
1
|
/**
|
|
16
2
|
* Modules
|
|
17
3
|
*/
|
|
@@ -20,4 +6,22 @@ export * from "./modules/bigIntArithmetics";
|
|
|
20
6
|
export * from "./modules/requestClient";
|
|
21
7
|
export * from "./modules/swapKitError";
|
|
22
8
|
export * from "./modules/swapKitNumber";
|
|
23
|
-
export * from "./modules/
|
|
9
|
+
export * from "./modules/swapKitConfig";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Utils
|
|
13
|
+
*/
|
|
14
|
+
export * from "./utils/asset";
|
|
15
|
+
export * from "./utils/derivationPath";
|
|
16
|
+
export * from "./utils/liquidity";
|
|
17
|
+
export * from "./utils/memo";
|
|
18
|
+
export * from "./utils/others";
|
|
19
|
+
export * from "./utils/plugin";
|
|
20
|
+
export * from "./utils/validators";
|
|
21
|
+
export * from "./utils/wallets";
|
|
22
|
+
export * from "./utils/tokens";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Types
|
|
26
|
+
*/
|
|
27
|
+
export * from "./types";
|
|
@@ -79,13 +79,15 @@ describe("AssetValue", () => {
|
|
|
79
79
|
|
|
80
80
|
expect(atomDerived.toString()).toBe("THOR.ATOM");
|
|
81
81
|
|
|
82
|
+
const value = 10;
|
|
82
83
|
const mayaCacao = AssetValue.from({
|
|
83
84
|
asset: "MAYA.CACAO",
|
|
84
|
-
value
|
|
85
|
+
value,
|
|
85
86
|
});
|
|
86
87
|
|
|
87
88
|
expect(mayaCacao.toString()).toBe("MAYA.CACAO");
|
|
88
|
-
|
|
89
|
+
const expectedValue = value * 10_000_000_000;
|
|
90
|
+
expect(mayaCacao.getBaseValue("string")).toBe(expectedValue.toString());
|
|
89
91
|
|
|
90
92
|
const ethMayaSynth = AssetValue.from({
|
|
91
93
|
asset: "MAYA.ETH/ETH",
|
|
@@ -105,29 +107,38 @@ describe("AssetValue", () => {
|
|
|
105
107
|
expect(ethTCSynthFallback.toString({ includeSynthProtocol: true })).toBe("THOR.ETH/ETH");
|
|
106
108
|
expect(ethTCSynthFallback.getBaseValue("string")).toBe("1000000000");
|
|
107
109
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
110
|
+
const solFromString = AssetValue.from({ asset: "SOL.SOL" });
|
|
111
|
+
expect(solFromString.toString()).toBe("SOL.SOL");
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test("regres cases", () => {
|
|
115
|
+
const arbWeth = AssetValue.from({
|
|
116
|
+
asset: "ARB.WETH-0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
|
|
117
|
+
});
|
|
118
|
+
expect(arbWeth.toString()).toBe("ARB.WETH-0x82af49447d8a07e3bd95bd0d56f35241523fbab1");
|
|
119
|
+
|
|
120
|
+
const baseAssetFromString = AssetValue.from({
|
|
121
|
+
asset: "BASE.USDC-0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
|
|
122
|
+
});
|
|
123
|
+
expect(baseAssetFromString.toString()).toBe(
|
|
124
|
+
"BASE.USDC-0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
const avaxSolanaAsset = AssetValue.from({
|
|
128
|
+
asset: "AVAX.SOL-0XFE6B19286885A4F7F55ADAD09C3CD1F906D2478F",
|
|
129
|
+
});
|
|
130
|
+
expect(avaxSolanaAsset.toString()).toBe(
|
|
131
|
+
"AVAX.SOL-0xfe6b19286885a4f7f55adad09c3cd1f906d2478f",
|
|
132
|
+
);
|
|
119
133
|
});
|
|
120
134
|
});
|
|
121
135
|
|
|
122
136
|
describe("set", () => {
|
|
123
137
|
test("get a copy of an assetValue with a new value", () => {
|
|
124
|
-
const btc = AssetValue.from({
|
|
125
|
-
asset: "BTC.BTC",
|
|
126
|
-
});
|
|
138
|
+
const btc = AssetValue.from({ asset: "BTC.BTC" });
|
|
127
139
|
|
|
128
140
|
const btc2 = btc.set(10);
|
|
129
141
|
|
|
130
|
-
expect(btc2).toBeDefined();
|
|
131
142
|
expect(btc2).toEqual(
|
|
132
143
|
expect.objectContaining({
|
|
133
144
|
chain: Chain.Bitcoin,
|
|
@@ -293,8 +304,21 @@ describe("AssetValue", () => {
|
|
|
293
304
|
const thor = AssetValue.from({ asset: "ETH.THOR" });
|
|
294
305
|
expect(thor.toString()).toBe("ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044");
|
|
295
306
|
|
|
296
|
-
const ethSynth = await AssetValue.from({
|
|
307
|
+
const ethSynth = await AssetValue.from({
|
|
308
|
+
asset: "ETH/ETH",
|
|
309
|
+
asyncTokenLookup: true,
|
|
310
|
+
});
|
|
297
311
|
expect(ethSynth.toString()).toBe("ETH/ETH");
|
|
312
|
+
|
|
313
|
+
const eth = await AssetValue.from({
|
|
314
|
+
asset: "eth.eth",
|
|
315
|
+
});
|
|
316
|
+
expect(eth.toString()).toBe("ETH.ETH");
|
|
317
|
+
|
|
318
|
+
const ethFromChain = await AssetValue.from({
|
|
319
|
+
chain: Chain.Ethereum,
|
|
320
|
+
});
|
|
321
|
+
expect(ethFromChain.toString()).toBe("ETH.ETH");
|
|
298
322
|
});
|
|
299
323
|
});
|
|
300
324
|
|
|
@@ -509,7 +533,9 @@ describe("AssetValue", () => {
|
|
|
509
533
|
test("returns safe decimals if string is not in `@swapkit/tokens` lists", async () => {
|
|
510
534
|
await AssetValue.loadStaticAssets();
|
|
511
535
|
const fakeAvaxUSDCAssetString = "AVAX.USDC-1234";
|
|
512
|
-
const fakeAvaxUSDCAsset = AssetValue.from({
|
|
536
|
+
const fakeAvaxUSDCAsset = AssetValue.from({
|
|
537
|
+
asset: fakeAvaxUSDCAssetString,
|
|
538
|
+
});
|
|
513
539
|
|
|
514
540
|
expect(fakeAvaxUSDCAsset).toBeDefined();
|
|
515
541
|
expect(fakeAvaxUSDCAsset).toEqual(
|
|
@@ -528,7 +554,9 @@ describe("AssetValue", () => {
|
|
|
528
554
|
test("returns safe decimals if string is not in `@swapkit/tokens` lists with multiple dashes", async () => {
|
|
529
555
|
await AssetValue.loadStaticAssets();
|
|
530
556
|
const fakeAvaxUSDCAssetString = "AVAX.USDC-LPT-1234";
|
|
531
|
-
const fakeAvaxUSDCAsset2 = AssetValue.from({
|
|
557
|
+
const fakeAvaxUSDCAsset2 = AssetValue.from({
|
|
558
|
+
asset: fakeAvaxUSDCAssetString,
|
|
559
|
+
});
|
|
532
560
|
|
|
533
561
|
expect(fakeAvaxUSDCAsset2).toBeDefined();
|
|
534
562
|
expect(fakeAvaxUSDCAsset2).toEqual(
|
|
@@ -557,8 +585,8 @@ describe("AssetValue", () => {
|
|
|
557
585
|
decimal: 8,
|
|
558
586
|
isGasAsset: false,
|
|
559
587
|
isSynthetic: false,
|
|
560
|
-
symbol: "BTC.
|
|
561
|
-
ticker: "BTC.
|
|
588
|
+
symbol: "BTC.B-0x152b9d0fdc40c096757f570a51e494bd4b943e50",
|
|
589
|
+
ticker: "BTC.B",
|
|
562
590
|
}),
|
|
563
591
|
);
|
|
564
592
|
});
|
|
@@ -758,12 +786,10 @@ describe("AssetValue", () => {
|
|
|
758
786
|
const xrdAsset = AssetValue.from({ chain: Chain.Radix });
|
|
759
787
|
expect(xrdAsset).toEqual(
|
|
760
788
|
expect.objectContaining({
|
|
761
|
-
address: undefined,
|
|
762
789
|
chain: Chain.Radix,
|
|
763
790
|
decimal: BaseDecimal.XRD,
|
|
764
791
|
isGasAsset: true,
|
|
765
792
|
isSynthetic: false,
|
|
766
|
-
symbol: "XRD",
|
|
767
793
|
ticker: "XRD",
|
|
768
794
|
type: "Native",
|
|
769
795
|
}),
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { Chain } from "../../types";
|
|
3
|
+
import { SKConfig } from "../swapKitConfig";
|
|
4
|
+
|
|
5
|
+
describe("swapKitConfig", () => {
|
|
6
|
+
test("properly sets api keys", () => {
|
|
7
|
+
const initialState = SKConfig.get("apiKeys").swapKit;
|
|
8
|
+
expect(initialState).toBe("");
|
|
9
|
+
|
|
10
|
+
SKConfig.setApiKey("swapKit", "123");
|
|
11
|
+
|
|
12
|
+
const changedState = SKConfig.get("apiKeys").swapKit;
|
|
13
|
+
expect(changedState).toBe("123");
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test("do not drop if other keys are changed", () => {
|
|
17
|
+
SKConfig.setApiKey("swapKit", "123");
|
|
18
|
+
expect(SKConfig.get("apiKeys").swapKit).toBe("123");
|
|
19
|
+
|
|
20
|
+
SKConfig.setApiKey("walletConnectProjectId", "123");
|
|
21
|
+
expect(SKConfig.get("apiKeys")).toMatchObject({
|
|
22
|
+
swapKit: "123",
|
|
23
|
+
walletConnectProjectId: "123",
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
SKConfig.setExplorerUrl(Chain.Ethereum, "https://lul.xyz");
|
|
27
|
+
expect(SKConfig.getState()).toMatchObject({
|
|
28
|
+
apiKeys: {
|
|
29
|
+
swapKit: "123",
|
|
30
|
+
walletConnectProjectId: "123",
|
|
31
|
+
},
|
|
32
|
+
explorerUrls: {
|
|
33
|
+
[Chain.Ethereum]: "https://lul.xyz",
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
});
|