@swapkit/helpers 4.0.0-beta.33 → 4.0.0-beta.34

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 (251) hide show
  1. package/dist/api/index.js +2 -2
  2. package/dist/api/index.js.map +1 -1
  3. package/dist/{chunk-ganzk321.js → chunk-hm14bfyg.js} +3 -3
  4. package/dist/{chunk-fazw0jvt.js.map → chunk-hm14bfyg.js.map} +1 -1
  5. package/dist/chunk-vb4wtm2w.js +4 -0
  6. package/dist/{chunk-ganzk321.js.map → chunk-vb4wtm2w.js.map} +1 -1
  7. package/dist/contracts.cjs +4 -0
  8. package/dist/contracts.cjs.map +10 -0
  9. package/dist/contracts.js +4 -0
  10. package/dist/contracts.js.map +10 -0
  11. package/dist/index.cjs +3 -3
  12. package/dist/index.cjs.map +9 -9
  13. package/dist/index.js +3 -3
  14. package/dist/index.js.map +9 -9
  15. package/dist/tokens.cjs +4 -0
  16. package/dist/tokens.cjs.map +10 -0
  17. package/dist/tokens.js +4 -0
  18. package/dist/tokens.js.map +10 -0
  19. package/dist/types/api/index.d.ts +238 -0
  20. package/dist/types/api/index.d.ts.map +1 -0
  21. package/dist/types/api/microgard/endpoints.d.ts +25 -0
  22. package/dist/types/api/microgard/endpoints.d.ts.map +1 -0
  23. package/dist/types/api/microgard/types.d.ts +56 -0
  24. package/dist/types/api/microgard/types.d.ts.map +1 -0
  25. package/dist/types/api/midgard/endpoints.d.ts +35 -0
  26. package/dist/types/api/midgard/endpoints.d.ts.map +1 -0
  27. package/dist/types/api/midgard/types.d.ts +102 -0
  28. package/dist/types/api/midgard/types.d.ts.map +1 -0
  29. package/dist/types/api/swapkitApi/endpoints.d.ts +194 -0
  30. package/dist/types/api/swapkitApi/endpoints.d.ts.map +1 -0
  31. package/dist/types/api/swapkitApi/types.d.ts +7238 -0
  32. package/dist/types/api/swapkitApi/types.d.ts.map +1 -0
  33. package/dist/types/api/thornode/endpoints.d.ts +31 -0
  34. package/dist/types/api/thornode/endpoints.d.ts.map +1 -0
  35. package/dist/types/api/thornode/types.d.ts +264 -0
  36. package/dist/types/api/thornode/types.d.ts.map +1 -0
  37. package/dist/types/api/thorswapStatic/endpoints.d.ts +7 -0
  38. package/dist/types/api/thorswapStatic/endpoints.d.ts.map +1 -0
  39. package/dist/types/api/thorswapStatic/types.d.ts +22 -0
  40. package/dist/types/api/thorswapStatic/types.d.ts.map +1 -0
  41. package/dist/types/contracts.d.ts +2 -0
  42. package/dist/types/contracts.d.ts.map +1 -0
  43. package/{src/index.ts → dist/types/index.d.ts} +3 -4
  44. package/dist/types/index.d.ts.map +1 -0
  45. package/dist/types/modules/assetValue.d.ts +71 -0
  46. package/dist/types/modules/assetValue.d.ts.map +1 -0
  47. package/dist/types/modules/bigIntArithmetics.d.ts +56 -0
  48. package/dist/types/modules/bigIntArithmetics.d.ts.map +1 -0
  49. package/dist/types/modules/feeMultiplier.d.ts +45 -0
  50. package/dist/types/modules/feeMultiplier.d.ts.map +1 -0
  51. package/dist/types/modules/requestClient.d.ts +22 -0
  52. package/dist/types/modules/requestClient.d.ts.map +1 -0
  53. package/dist/types/modules/swapKitConfig.d.ts +98 -0
  54. package/dist/types/modules/swapKitConfig.d.ts.map +1 -0
  55. package/dist/types/modules/swapKitError.d.ts +829 -0
  56. package/dist/types/modules/swapKitError.d.ts.map +1 -0
  57. package/dist/types/modules/swapKitNumber.d.ts +7 -0
  58. package/dist/types/modules/swapKitNumber.d.ts.map +1 -0
  59. package/dist/types/tokens.d.ts +2 -0
  60. package/dist/types/tokens.d.ts.map +1 -0
  61. package/dist/types/types/chains.d.ts +187 -0
  62. package/dist/types/types/chains.d.ts.map +1 -0
  63. package/dist/types/types/commonTypes.d.ts +37 -0
  64. package/dist/types/types/commonTypes.d.ts.map +1 -0
  65. package/dist/types/types/derivationPath.d.ts +17 -0
  66. package/dist/types/types/derivationPath.d.ts.map +1 -0
  67. package/dist/types/types/errors/apiV1.d.ts +2 -0
  68. package/dist/types/types/errors/apiV1.d.ts.map +1 -0
  69. package/{src/types/index.ts → dist/types/types/index.d.ts} +1 -1
  70. package/dist/types/types/index.d.ts.map +1 -0
  71. package/dist/types/types/quotes.d.ts +170 -0
  72. package/dist/types/types/quotes.d.ts.map +1 -0
  73. package/dist/types/types/radix.d.ts +15 -0
  74. package/dist/types/types/radix.d.ts.map +1 -0
  75. package/dist/types/types/sdk.d.ts +35 -0
  76. package/dist/types/types/sdk.d.ts.map +1 -0
  77. package/dist/types/types/wallet.d.ts +121 -0
  78. package/dist/types/types/wallet.d.ts.map +1 -0
  79. package/dist/types/utils/asset.d.ts +40 -0
  80. package/dist/types/utils/asset.d.ts.map +1 -0
  81. package/dist/types/utils/derivationPath.d.ts +19 -0
  82. package/dist/types/utils/derivationPath.d.ts.map +1 -0
  83. package/dist/types/utils/explorerUrls.d.ts +10 -0
  84. package/dist/types/utils/explorerUrls.d.ts.map +1 -0
  85. package/dist/types/utils/liquidity.d.ts +59 -0
  86. package/dist/types/utils/liquidity.d.ts.map +1 -0
  87. package/dist/types/utils/memo.d.ts +65 -0
  88. package/dist/types/utils/memo.d.ts.map +1 -0
  89. package/dist/types/utils/others.d.ts +9 -0
  90. package/dist/types/utils/others.d.ts.map +1 -0
  91. package/dist/types/utils/validators.d.ts +3 -0
  92. package/dist/types/utils/validators.d.ts.map +1 -0
  93. package/dist/types/utils/wallets.d.ts +32 -0
  94. package/dist/types/utils/wallets.d.ts.map +1 -0
  95. package/package.json +14 -15
  96. package/dist/chunk-06q78xy3.js +0 -4
  97. package/dist/chunk-06q78xy3.js.map +0 -10
  98. package/dist/chunk-0q5vvg5c.js +0 -5
  99. package/dist/chunk-0q5vvg5c.js.map +0 -10
  100. package/dist/chunk-18bxh1n7.js +0 -5
  101. package/dist/chunk-18bxh1n7.js.map +0 -10
  102. package/dist/chunk-3qya5ng9.js +0 -4
  103. package/dist/chunk-3qya5ng9.js.map +0 -10
  104. package/dist/chunk-4yqymkbp.js +0 -5
  105. package/dist/chunk-4yqymkbp.js.map +0 -10
  106. package/dist/chunk-50gpwcq9.js +0 -4
  107. package/dist/chunk-50gpwcq9.js.map +0 -10
  108. package/dist/chunk-6atq9cs7.js +0 -4
  109. package/dist/chunk-6atq9cs7.js.map +0 -10
  110. package/dist/chunk-6m0d5pv4.js +0 -5
  111. package/dist/chunk-6m0d5pv4.js.map +0 -10
  112. package/dist/chunk-8x46g3wq.js +0 -5
  113. package/dist/chunk-8x46g3wq.js.map +0 -10
  114. package/dist/chunk-92sk0g47.js +0 -5
  115. package/dist/chunk-92sk0g47.js.map +0 -10
  116. package/dist/chunk-9f2b3enk.js +0 -5
  117. package/dist/chunk-9f2b3enk.js.map +0 -10
  118. package/dist/chunk-adrafsdk.js +0 -5
  119. package/dist/chunk-adrafsdk.js.map +0 -10
  120. package/dist/chunk-b1hang9z.js +0 -5
  121. package/dist/chunk-b1hang9z.js.map +0 -10
  122. package/dist/chunk-becdmywt.js +0 -4
  123. package/dist/chunk-becdmywt.js.map +0 -10
  124. package/dist/chunk-ehz0t9d1.js +0 -4
  125. package/dist/chunk-ehz0t9d1.js.map +0 -10
  126. package/dist/chunk-fazw0jvt.js +0 -4
  127. package/dist/chunk-fm9ycn0h.js +0 -5
  128. package/dist/chunk-fm9ycn0h.js.map +0 -10
  129. package/dist/chunk-g67e2r57.js +0 -4
  130. package/dist/chunk-g67e2r57.js.map +0 -10
  131. package/dist/chunk-he3vy8gt.js +0 -4
  132. package/dist/chunk-he3vy8gt.js.map +0 -10
  133. package/dist/chunk-jjayk2y5.js +0 -4
  134. package/dist/chunk-jjayk2y5.js.map +0 -10
  135. package/dist/chunk-mmyv2vsv.js +0 -5
  136. package/dist/chunk-mmyv2vsv.js.map +0 -10
  137. package/dist/chunk-phev7aw7.js +0 -4
  138. package/dist/chunk-phev7aw7.js.map +0 -10
  139. package/dist/chunk-rhqk87p2.js +0 -5
  140. package/dist/chunk-rhqk87p2.js.map +0 -10
  141. package/dist/chunk-rnv7fdjk.js +0 -4
  142. package/dist/chunk-rnv7fdjk.js.map +0 -10
  143. package/dist/chunk-rwh98p1c.js +0 -4
  144. package/dist/chunk-rwh98p1c.js.map +0 -10
  145. package/dist/chunk-v9zj2gsj.js +0 -5
  146. package/dist/chunk-v9zj2gsj.js.map +0 -10
  147. package/dist/chunk-vv5bgsn8.js +0 -4
  148. package/dist/chunk-vv5bgsn8.js.map +0 -10
  149. package/dist/chunk-vwh9jfxn.js +0 -5
  150. package/dist/chunk-vwh9jfxn.js.map +0 -10
  151. package/dist/chunk-x0rqy75t.js +0 -4
  152. package/dist/chunk-x0rqy75t.js.map +0 -10
  153. package/dist/contracts/index.cjs +0 -4
  154. package/dist/contracts/index.cjs.map +0 -38
  155. package/dist/contracts/index.js +0 -4
  156. package/dist/contracts/index.js.map +0 -38
  157. package/dist/tokens/index.cjs +0 -4
  158. package/dist/tokens/index.cjs.map +0 -10
  159. package/dist/tokens/index.js +0 -4
  160. package/dist/tokens/index.js.map +0 -10
  161. package/src/api/index.ts +0 -19
  162. package/src/api/microgard/endpoints.ts +0 -83
  163. package/src/api/microgard/types.ts +0 -57
  164. package/src/api/midgard/endpoints.ts +0 -90
  165. package/src/api/midgard/types.ts +0 -106
  166. package/src/api/swapkitApi/endpoints.ts +0 -193
  167. package/src/api/swapkitApi/types.ts +0 -635
  168. package/src/api/thornode/endpoints.ts +0 -116
  169. package/src/api/thornode/types.ts +0 -276
  170. package/src/api/thorswapStatic/endpoints.ts +0 -46
  171. package/src/api/thorswapStatic/types.ts +0 -18
  172. package/src/contracts/abis/avaxGeneric.ts +0 -92
  173. package/src/contracts/abis/avaxWoofi.ts +0 -145
  174. package/src/contracts/abis/bscGeneric.ts +0 -106
  175. package/src/contracts/abis/chainflipGateway.ts +0 -330
  176. package/src/contracts/abis/erc20.ts +0 -99
  177. package/src/contracts/abis/ethGeneric.ts +0 -92
  178. package/src/contracts/abis/mayaEvmVaults.ts +0 -331
  179. package/src/contracts/abis/pancakeV2.ts +0 -145
  180. package/src/contracts/abis/pangolin.ts +0 -120
  181. package/src/contracts/abis/sushiswap.ts +0 -120
  182. package/src/contracts/abis/tcEthVault.ts +0 -650
  183. package/src/contracts/abis/traderJoe.ts +0 -120
  184. package/src/contracts/abis/uniswapV2.ts +0 -120
  185. package/src/contracts/abis/uniswapV2Leg.ts +0 -128
  186. package/src/contracts/abis/uniswapV3_100.ts +0 -128
  187. package/src/contracts/abis/uniswapV3_10000.ts +0 -128
  188. package/src/contracts/abis/uniswapV3_3000.ts +0 -128
  189. package/src/contracts/abis/uniswapV3_500.ts +0 -128
  190. package/src/contracts/index.ts +0 -95
  191. package/src/contracts/routers/index.ts +0 -58
  192. package/src/contracts/routers/kyber.ts +0 -402
  193. package/src/contracts/routers/oneinch.ts +0 -2188
  194. package/src/contracts/routers/pancakeswap.ts +0 -340
  195. package/src/contracts/routers/pangolin.ts +0 -340
  196. package/src/contracts/routers/sushiswap.ts +0 -340
  197. package/src/contracts/routers/traderJoe.ts +0 -340
  198. package/src/contracts/routers/uniswapv2.ts +0 -340
  199. package/src/contracts/routers/uniswapv3.ts +0 -254
  200. package/src/contracts/routers/woofi.ts +0 -171
  201. package/src/modules/__tests__/assetValue.test.ts +0 -877
  202. package/src/modules/__tests__/bigIntArithmetics.test.ts +0 -30
  203. package/src/modules/__tests__/swapKitConfig.test.ts +0 -37
  204. package/src/modules/__tests__/swapKitNumber.test.ts +0 -560
  205. package/src/modules/assetValue.ts +0 -387
  206. package/src/modules/bigIntArithmetics.ts +0 -436
  207. package/src/modules/feeMultiplier.ts +0 -87
  208. package/src/modules/requestClient.ts +0 -83
  209. package/src/modules/swapKitConfig.ts +0 -143
  210. package/src/modules/swapKitError.ts +0 -442
  211. package/src/modules/swapKitNumber.ts +0 -16
  212. package/src/tokens/index.ts +0 -15
  213. package/src/tokens/lists/camelot_v3.ts +0 -16060
  214. package/src/tokens/lists/caviar_v1.ts +0 -1704
  215. package/src/tokens/lists/chainflip.ts +0 -104
  216. package/src/tokens/lists/index.ts +0 -14
  217. package/src/tokens/lists/jupiter.ts +0 -33563
  218. package/src/tokens/lists/mayachain.ts +0 -509
  219. package/src/tokens/lists/near.ts +0 -458
  220. package/src/tokens/lists/oneinch.ts +0 -15006
  221. package/src/tokens/lists/openocean_v2.ts +0 -12434
  222. package/src/tokens/lists/pancakeswap.ts +0 -6136
  223. package/src/tokens/lists/pangolin_v1.ts +0 -75
  224. package/src/tokens/lists/sushiswap_v2.ts +0 -595
  225. package/src/tokens/lists/thorchain.ts +0 -748
  226. package/src/tokens/lists/traderjoe_v2.ts +0 -594
  227. package/src/tokens/lists/uniswap_v2.ts +0 -11484
  228. package/src/tokens/lists/uniswap_v3.ts +0 -19424
  229. package/src/types/chains.ts +0 -555
  230. package/src/types/commonTypes.ts +0 -58
  231. package/src/types/derivationPath.ts +0 -58
  232. package/src/types/errors/apiV1.ts +0 -0
  233. package/src/types/quotes.ts +0 -172
  234. package/src/types/radix.ts +0 -14
  235. package/src/types/sdk.ts +0 -42
  236. package/src/types/tokens.ts +0 -17
  237. package/src/types/wallet.ts +0 -166
  238. package/src/utils/__tests__/asset.test.ts +0 -193
  239. package/src/utils/__tests__/derivationPath.test.ts +0 -16
  240. package/src/utils/__tests__/memo.test.ts +0 -103
  241. package/src/utils/__tests__/others.test.ts +0 -88
  242. package/src/utils/__tests__/validators.test.ts +0 -24
  243. package/src/utils/asset.ts +0 -231
  244. package/src/utils/derivationPath.ts +0 -98
  245. package/src/utils/liquidity.ts +0 -179
  246. package/src/utils/memo.ts +0 -143
  247. package/src/utils/others.ts +0 -86
  248. package/src/utils/plugin.ts +0 -13
  249. package/src/utils/tokens.ts +0 -73
  250. package/src/utils/validators.ts +0 -32
  251. package/src/utils/wallets.ts +0 -276
@@ -1,877 +0,0 @@
1
- import { describe, expect, test } from "bun:test";
2
-
3
- import { BaseDecimal, Chain } from "../../types/chains";
4
- import { AssetValue, getMinAmountByChain } from "../assetValue";
5
-
6
- describe("AssetValue", () => {
7
- describe("assetValue", () => {
8
- test("returns asset ticker with value", () => {
9
- const fakeAvaxUSDCAsset = new AssetValue({
10
- decimal: 6,
11
- value: 1234567890,
12
- chain: Chain.Avalanche,
13
- symbol: "USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
14
- });
15
- expect(fakeAvaxUSDCAsset.toString()).toBe(
16
- "AVAX.USDC-0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
17
- );
18
-
19
- const ethSynth = new AssetValue({
20
- chain: Chain.THORChain,
21
- symbol: "ETH/ETH",
22
- decimal: 8,
23
- value: 1234567890,
24
- });
25
-
26
- expect(ethSynth.toString()).toBe("ETH/ETH");
27
- expect(ethSynth.mul(21.37).getValue("string")).toBe("26382715809.3");
28
-
29
- const ethTrade = new AssetValue({
30
- chain: Chain.THORChain,
31
- symbol: "ETH~ETH",
32
- decimal: 8,
33
- value: 1234567890,
34
- });
35
-
36
- expect(ethTrade.toString()).toBe("ETH~ETH");
37
- expect(ethTrade.mul(21.37).getValue("string")).toBe("26382715809.3");
38
-
39
- const ethThorTrade = new AssetValue({
40
- chain: Chain.THORChain,
41
- symbol: "ETH~THOR-0xa5f2211b9b8170f694421f2046281775e8468044",
42
- decimal: 8,
43
- value: 1234567890,
44
- });
45
-
46
- expect(ethThorTrade.toString()).toBe("ETH~THOR-0xa5f2211b9b8170f694421f2046281775e8468044");
47
- expect(ethThorTrade.chain).toBe(Chain.THORChain);
48
-
49
- const ethThorSynth = new AssetValue({
50
- chain: Chain.THORChain,
51
- symbol: "ETH/THOR-0xa5f2211b9b8170f694421f2046281775e8468044",
52
- decimal: 8,
53
- value: 1234567890,
54
- });
55
- expect(ethThorSynth.toString()).toBe("ETH/THOR-0xa5f2211b9b8170f694421f2046281775e8468044");
56
- expect(ethThorSynth.chain).toBe(Chain.THORChain);
57
-
58
- const mayaEthSynth = new AssetValue({
59
- chain: Chain.Maya,
60
- symbol: "ETH/ETH",
61
- decimal: 8,
62
- value: 1234567890,
63
- });
64
- expect(mayaEthSynth.toString()).toBe("ETH/ETH");
65
- expect(mayaEthSynth.chain).toBe(Chain.Maya);
66
-
67
- const mayaEthSynthFrom = AssetValue.from({
68
- asset: "MAYA.ETH/ETH",
69
- value: 12.3456789,
70
- });
71
- expect(mayaEthSynthFrom.toString()).toBe("ETH/ETH");
72
- expect(mayaEthSynthFrom.chain).toBe(Chain.Maya);
73
-
74
- const atomDerived = new AssetValue({
75
- identifier: "THOR.ATOM",
76
- decimal: 6,
77
- value: 123456789,
78
- });
79
-
80
- expect(atomDerived.toString()).toBe("THOR.ATOM");
81
-
82
- const value = 10;
83
- const mayaCacao = AssetValue.from({
84
- asset: "MAYA.CACAO",
85
- value,
86
- });
87
-
88
- expect(mayaCacao.toString()).toBe("MAYA.CACAO");
89
- const expectedValue = value * 10_000_000_000;
90
- expect(mayaCacao.getBaseValue("string")).toBe(expectedValue.toString());
91
-
92
- const ethMayaSynth = AssetValue.from({
93
- asset: "MAYA.ETH/ETH",
94
- value: 10,
95
- });
96
-
97
- expect(ethMayaSynth.toString()).toBe("ETH/ETH");
98
- expect(ethMayaSynth.toString({ includeSynthProtocol: true })).toBe("MAYA.ETH/ETH");
99
- expect(ethMayaSynth.getBaseValue("string")).toBe("1000000000");
100
-
101
- const ethTCSynthFallback = AssetValue.from({
102
- asset: "ETH/ETH",
103
- value: 10,
104
- });
105
-
106
- expect(ethTCSynthFallback.toString()).toBe("ETH/ETH");
107
- expect(ethTCSynthFallback.toString({ includeSynthProtocol: true })).toBe("THOR.ETH/ETH");
108
- expect(ethTCSynthFallback.getBaseValue("string")).toBe("1000000000");
109
-
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
- );
133
- });
134
- });
135
-
136
- describe("set", () => {
137
- test("get a copy of an assetValue with a new value", () => {
138
- const btc = AssetValue.from({ asset: "BTC.BTC" });
139
-
140
- const btc2 = btc.set(10);
141
-
142
- expect(btc2).toEqual(
143
- expect.objectContaining({
144
- chain: Chain.Bitcoin,
145
- decimal: 8,
146
- isGasAsset: true,
147
- isSynthetic: false,
148
- symbol: "BTC",
149
- ticker: "BTC",
150
- }),
151
- );
152
-
153
- expect(btc.getValue("string")).toBe("0");
154
- expect(btc2.getValue("string")).toBe("10");
155
- });
156
-
157
- test("get a copy of a synth assetValue with a new value", () => {
158
- const synthAvax = AssetValue.from({
159
- asset: "THOR.AVAX/AVAX",
160
- value: 1,
161
- });
162
-
163
- const synthAvax2 = synthAvax.set(10);
164
-
165
- expect(synthAvax2).toBeDefined();
166
- expect(synthAvax2).toEqual(
167
- expect.objectContaining({
168
- chain: Chain.THORChain,
169
- decimal: 8,
170
- isGasAsset: false,
171
- isSynthetic: true,
172
- symbol: "AVAX/AVAX",
173
- ticker: "AVAX",
174
- }),
175
- );
176
-
177
- expect(synthAvax.getValue("string")).toBe("1");
178
- expect(synthAvax2.getValue("string")).toBe("10");
179
- expect(synthAvax.toString({ includeSynthProtocol: true })).toBe("THOR.AVAX/AVAX");
180
- expect(synthAvax2.toString({ includeSynthProtocol: true })).toBe("THOR.AVAX/AVAX");
181
- });
182
- });
183
-
184
- describe("toUrl", () => {
185
- test("returns asset compliance with url", () => {
186
- const fakeAvaxUSDCAsset = new AssetValue({
187
- decimal: 6,
188
- value: 1234567890,
189
- chain: Chain.Avalanche,
190
- symbol: "USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
191
- });
192
- expect(fakeAvaxUSDCAsset.toUrl()).toBe(
193
- "AVAX.USDC-0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
194
- );
195
-
196
- const thor = AssetValue.from({ asset: "ETH.THOR" });
197
- expect(thor.toUrl()).toBe("ETH.THOR-0xa5f2211B9b8170F694421f2046281775E8468044");
198
-
199
- const ethSynth = new AssetValue({
200
- chain: Chain.THORChain,
201
- symbol: "ETH/ETH",
202
- decimal: 8,
203
- value: 1234567890,
204
- });
205
- expect(ethSynth.toUrl()).toBe("THOR.ETH.ETH");
206
-
207
- const ethThorSynth = new AssetValue({
208
- chain: Chain.THORChain,
209
- symbol: "ETH/THOR-0xa5f2211b9b8170f694421f2046281775e8468044",
210
- decimal: 8,
211
- value: 1234567890,
212
- });
213
- expect(ethThorSynth.toUrl()).toBe("THOR.ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044");
214
-
215
- const ethThorTrade = new AssetValue({
216
- chain: Chain.THORChain,
217
- symbol: "ETH~THOR-0xa5f2211b9b8170f694421f2046281775e8468044",
218
- decimal: 8,
219
- value: 1234567890,
220
- });
221
- expect(ethThorTrade.toUrl()).toBe(
222
- "THOR.ETH..THOR-0xa5f2211b9b8170f694421f2046281775e8468044",
223
- );
224
- });
225
- });
226
-
227
- describe("eq", () => {
228
- test("checks if assets are same chain and symbol", () => {
229
- const firstThor = AssetValue.from({ asset: "ETH.THOR" });
230
- const secondThor = AssetValue.from({ asset: "ETH.THOR" });
231
- const vThor = AssetValue.from({ asset: "ETH.vTHOR" });
232
- const firstUsdc = new AssetValue({
233
- chain: Chain.Avalanche,
234
- symbol: "USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
235
- decimal: 6,
236
- value: 1234567890,
237
- });
238
- const secondUsdc = new AssetValue({
239
- chain: Chain.Avalanche,
240
- symbol: "USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
241
- decimal: 6,
242
- value: 1234,
243
- });
244
-
245
- expect(firstThor.eqAsset(firstThor)).toBe(true);
246
- expect(firstThor.eqAsset(secondThor)).toBe(true);
247
- expect(firstThor.eqAsset(vThor)).toBe(false);
248
- expect(firstThor.eqAsset(firstUsdc)).toBe(false);
249
- expect(firstThor.eqAsset(secondUsdc)).toBe(false);
250
-
251
- expect(firstUsdc.eqAsset(firstThor)).toBe(false);
252
- expect(firstUsdc.eqAsset(secondThor)).toBe(false);
253
- expect(firstUsdc.eqAsset(vThor)).toBe(false);
254
- expect(firstUsdc.eqAsset(firstUsdc)).toBe(true);
255
- expect(firstUsdc.eqAsset(secondUsdc)).toBe(true);
256
- });
257
-
258
- test("check if assets have same value, even if not same asset", () => {
259
- const firstThor = AssetValue.from({ asset: "ETH.THOR", value: "20" });
260
- const secondThor = AssetValue.from({ asset: "ETH.THOR", value: "35" });
261
- const thirdThor = AssetValue.from({ asset: "ETH.THOR", value: "35" });
262
- const vThor = AssetValue.from({ asset: "ETH.vTHOR", value: "20" });
263
-
264
- expect(firstThor.eqValue(firstThor)).toBe(true);
265
- expect(firstThor.eqValue(secondThor)).toBe(false);
266
- expect(secondThor.eqValue(thirdThor)).toBe(true);
267
- expect(firstThor.eqValue(vThor)).toBe(true);
268
- });
269
-
270
- test("check if assets have identical asset and value", () => {
271
- const firstThor = AssetValue.from({ asset: "ETH.THOR", value: "20" });
272
- const secondThor = AssetValue.from({ asset: "ETH.THOR", value: "35" });
273
- const thirdThor = AssetValue.from({ asset: "ETH.THOR", value: "35" });
274
- const vThor = AssetValue.from({ asset: "ETH.vTHOR", value: "20" });
275
-
276
- expect(firstThor.eq(firstThor)).toBe(true);
277
- expect(firstThor.eq(secondThor)).toBe(false);
278
- expect(secondThor.eq(thirdThor)).toBe(true);
279
- expect(firstThor.eq(vThor)).toBe(false);
280
- });
281
- });
282
-
283
- describe("from bigint", () => {
284
- test.todo("returns asset value with correct decimal", async () => {
285
- const avaxUSDCAsset = await AssetValue.from({
286
- asset: `${Chain.Avalanche}.USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e`,
287
- value: 1234567800n,
288
- asyncTokenLookup: true,
289
- });
290
- expect(avaxUSDCAsset.getValue("string")).toBe("1234.5678");
291
- });
292
- });
293
-
294
- describe("toString", () => {
295
- test("returns asset value string/identifier", async () => {
296
- const avaxUSDCAsset = new AssetValue({
297
- decimal: 6,
298
- value: 1234567890,
299
- chain: Chain.Avalanche,
300
- symbol: "USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
301
- });
302
- expect(avaxUSDCAsset.toString()).toBe("AVAX.USDC-0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E");
303
-
304
- const thor = AssetValue.from({ asset: "ETH.THOR" });
305
- expect(thor.toString()).toBe("ETH.THOR-0xa5f2211B9b8170F694421f2046281775E8468044");
306
-
307
- const ethSynth = await AssetValue.from({
308
- asset: "ETH/ETH",
309
- asyncTokenLookup: true,
310
- });
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");
322
- });
323
- });
324
-
325
- describe("fromIdentifier", () => {
326
- test("creates AssetValue from string", async () => {
327
- const avaxUSDCAsset = await AssetValue.from({
328
- asset: "AVAX.USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
329
- asyncTokenLookup: true,
330
- });
331
-
332
- expect(avaxUSDCAsset).toEqual(
333
- expect.objectContaining({
334
- address: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
335
- chain: Chain.Avalanche,
336
- decimal: 6,
337
- isGasAsset: false,
338
- isSynthetic: false,
339
- symbol: "USDC-0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
340
- ticker: "USDC",
341
- }),
342
- );
343
- });
344
-
345
- test("creates AssetValue from string with multiple dashes", async () => {
346
- const ethPendleLptAsset = await AssetValue.from({
347
- asset: "ETH.PENDLE-LPT-0x1234",
348
- asyncTokenLookup: true,
349
- });
350
-
351
- expect(ethPendleLptAsset).toEqual(
352
- expect.objectContaining({
353
- address: "0x1234",
354
- chain: Chain.Ethereum,
355
- decimal: 18,
356
- isGasAsset: false,
357
- isSynthetic: false,
358
- symbol: "PENDLE-LPT-0x1234",
359
- ticker: "PENDLE-LPT",
360
- }),
361
- );
362
- });
363
- });
364
-
365
- describe("fromString", () => {
366
- test("creates AssetValue from string", async () => {
367
- const fakeAvaxAssetString = "AVAX.ASDF-1234";
368
- const fakeAvaxAsset = await AssetValue.from({
369
- asset: fakeAvaxAssetString,
370
- asyncTokenLookup: true,
371
- });
372
-
373
- expect(fakeAvaxAsset).toEqual(
374
- expect.objectContaining({
375
- address: "1234",
376
- chain: Chain.Avalanche,
377
- decimal: 18,
378
- isGasAsset: false,
379
- isSynthetic: false,
380
- symbol: "ASDF-1234",
381
- ticker: "ASDF",
382
- }),
383
- );
384
- });
385
-
386
- test("creates AssetValue from string with multiple dashes", async () => {
387
- const fakeAvaxAssetString = "AVAX.ASDF-LP-1234";
388
- const fakeAvaxAsset = await AssetValue.from({
389
- asset: fakeAvaxAssetString,
390
- asyncTokenLookup: true,
391
- });
392
-
393
- expect(fakeAvaxAsset).toEqual(
394
- expect.objectContaining({
395
- address: "1234",
396
- chain: Chain.Avalanche,
397
- decimal: 18,
398
- isGasAsset: false,
399
- isSynthetic: false,
400
- symbol: "ASDF-LP-1234",
401
- ticker: "ASDF-LP",
402
- }),
403
- );
404
- });
405
-
406
- test.todo("creates AssetValue with _ symbol", async () => {
407
- const radixXWBTC = await AssetValue.from({
408
- asset: "XRD.XWBTC-resource_rdx1t580qxc7upat7lww4l2c4jckacafjeudxj5wpjrrct0p3e82sq4y75",
409
- asyncTokenLookup: true,
410
- });
411
-
412
- expect(radixXWBTC).toEqual(
413
- expect.objectContaining({
414
- address: "resource_rdx1t580qxc7upat7lww4l2c4jckacafjeudxj5wpjrrct0p3e82sq4y75",
415
- chain: Chain.Radix,
416
- decimal: 8,
417
- isGasAsset: false,
418
- isSynthetic: false,
419
- symbol: "XWBTC-resource_rdx1t580qxc7upat7lww4l2c4jckacafjeudxj5wpjrrct0p3e82sq4y75",
420
- ticker: "XWBTC",
421
- }),
422
- );
423
- });
424
- });
425
-
426
- describe("fromStringWithBase", () => {
427
- test("creates AssetValue from string with base", async () => {
428
- const fakeAvaxAssetString = "AVAX.ASDF-1234";
429
- const fakeAvaxAsset = await AssetValue.from({
430
- asset: fakeAvaxAssetString,
431
- value: 1,
432
- fromBaseDecimal: 8,
433
- asyncTokenLookup: true,
434
- });
435
-
436
- expect(fakeAvaxAsset).toEqual(
437
- expect.objectContaining({
438
- address: "1234",
439
- chain: Chain.Avalanche,
440
- decimal: 18,
441
- isGasAsset: false,
442
- isSynthetic: false,
443
- symbol: "ASDF-1234",
444
- ticker: "ASDF",
445
- }),
446
- );
447
- expect(fakeAvaxAsset.getValue("string")).toBe("0.00000001");
448
- expect(fakeAvaxAsset.getBaseValue("string")).toBe("10000000000");
449
- });
450
- });
451
-
452
- describe("fromUrl", () => {
453
- test("creates AssetValue from url like format", () => {
454
- const synthETHString = "THOR.ETH.ETH";
455
- const ethString = "ETH.ETH";
456
- const thorString = "ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044";
457
- const synthThorString = "THOR.ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044";
458
- const synthDashesString = "THOR.ETH.PENDLE-LPT-0x1234";
459
-
460
- const synthETH = AssetValue.fromUrl(synthETHString);
461
- const eth = AssetValue.fromUrl(ethString);
462
- const thor = AssetValue.fromUrl(thorString);
463
- const synthThor = AssetValue.fromUrl(synthThorString);
464
- const synthDashes = AssetValue.fromUrl(synthDashesString);
465
-
466
- expect(synthETH.toString()).toBe("ETH/ETH");
467
- expect(eth.toString()).toBe("ETH.ETH");
468
- expect(thor.toString()).toBe("ETH.THOR-0xa5f2211B9b8170F694421f2046281775E8468044");
469
- expect(synthThor.toString()).toBe("ETH/THOR-0xa5f2211b9b8170f694421f2046281775e8468044");
470
- expect(synthDashes.toString()).toBe("ETH/PENDLE-LPT-0x1234");
471
- });
472
- });
473
-
474
- describe("fromIdentifierSync", () => {
475
- test("(same as fromIdentifier) - creates AssetValue from string via `@swapkit/tokens` lists", async () => {
476
- await AssetValue.loadStaticAssets();
477
- const thor = AssetValue.from({
478
- asset: "ARB.USDT-0XFD086BC7CD5C481DCC9C85EBE478A1C0B69FCBB9",
479
- });
480
-
481
- expect(thor).toBeDefined();
482
- expect(thor).toEqual(
483
- expect.objectContaining({
484
- address: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
485
- chain: Chain.Arbitrum,
486
- decimal: 6,
487
- isGasAsset: false,
488
- isSynthetic: false,
489
- symbol: "USDT-0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
490
- ticker: "USDT",
491
- }),
492
- );
493
- });
494
- });
495
-
496
- describe("fromStringSync", () => {
497
- test("creates AssetValue from string via `@swapkit/tokens` lists", async () => {
498
- await AssetValue.loadStaticAssets();
499
- const thor = AssetValue.from({
500
- asset: "ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044",
501
- });
502
-
503
- expect(thor).toBeDefined();
504
- expect(thor).toEqual(
505
- expect.objectContaining({
506
- address: "0xa5f2211B9b8170F694421f2046281775E8468044",
507
- chain: Chain.Ethereum,
508
- decimal: 18,
509
- isGasAsset: false,
510
- isSynthetic: false,
511
- symbol: "THOR-0xa5f2211B9b8170F694421f2046281775E8468044",
512
- ticker: "THOR",
513
- }),
514
- );
515
-
516
- const usdc = AssetValue.from({
517
- asset: "ETH.USDC-0XA0B86991C6218B36C1D19D4A2E9EB0CE3606EB48",
518
- });
519
- expect(usdc).toBeDefined();
520
- expect(usdc).toEqual(
521
- expect.objectContaining({
522
- address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
523
- chain: Chain.Ethereum,
524
- decimal: 6,
525
- isGasAsset: false,
526
- isSynthetic: false,
527
- symbol: "USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
528
- ticker: "USDC",
529
- }),
530
- );
531
- });
532
-
533
- test("returns safe decimals if string is not in `@swapkit/tokens` lists", async () => {
534
- await AssetValue.loadStaticAssets();
535
- const fakeAvaxUSDCAssetString = "AVAX.USDC-1234";
536
- const fakeAvaxUSDCAsset = AssetValue.from({
537
- asset: fakeAvaxUSDCAssetString,
538
- });
539
-
540
- expect(fakeAvaxUSDCAsset).toBeDefined();
541
- expect(fakeAvaxUSDCAsset).toEqual(
542
- expect.objectContaining({
543
- address: "1234",
544
- chain: Chain.Avalanche,
545
- decimal: 18,
546
- isGasAsset: false,
547
- isSynthetic: false,
548
- symbol: "USDC-1234",
549
- ticker: "USDC",
550
- }),
551
- );
552
- });
553
-
554
- test("returns safe decimals if string is not in `@swapkit/tokens` lists with multiple dashes", async () => {
555
- await AssetValue.loadStaticAssets();
556
- const fakeAvaxUSDCAssetString = "AVAX.USDC-LPT-1234";
557
- const fakeAvaxUSDCAsset2 = AssetValue.from({
558
- asset: fakeAvaxUSDCAssetString,
559
- });
560
-
561
- expect(fakeAvaxUSDCAsset2).toBeDefined();
562
- expect(fakeAvaxUSDCAsset2).toEqual(
563
- expect.objectContaining({
564
- address: "1234",
565
- chain: Chain.Avalanche,
566
- decimal: 18,
567
- isGasAsset: false,
568
- isSynthetic: false,
569
- symbol: "USDC-LPT-1234",
570
- ticker: "USDC-LPT",
571
- }),
572
- );
573
- });
574
-
575
- test("returns proper avax string with address from `@swapkit/tokens` lists", async () => {
576
- await AssetValue.loadStaticAssets();
577
- const avaxBTCb = "AVAX.BTC.b-0x152b9d0fdc40c096757f570a51e494bd4b943e50";
578
- const AvaxBTCb = AssetValue.from({ asset: avaxBTCb });
579
-
580
- expect(AvaxBTCb).toBeDefined();
581
- expect(AvaxBTCb).toEqual(
582
- expect.objectContaining({
583
- address: "0x152b9d0FdC40C096757F570A51E494bd4b943E50",
584
- chain: Chain.Avalanche,
585
- decimal: 8,
586
- isGasAsset: false,
587
- isSynthetic: false,
588
- symbol: "BTC.B-0x152b9d0FdC40C096757F570A51E494bd4b943E50",
589
- ticker: "BTC.B",
590
- }),
591
- );
592
- });
593
- });
594
-
595
- describe("fromStringWithBaseSync", () => {
596
- test("creates AssetValue from string with base decimals via `@swapkit/tokens` lists", async () => {
597
- await AssetValue.loadStaticAssets();
598
- const btc = AssetValue.from({
599
- asset: "BTC.BTC",
600
- value: 5200000000000,
601
- fromBaseDecimal: 8,
602
- });
603
-
604
- expect(btc).toBeDefined();
605
- expect(btc).toEqual(
606
- expect.objectContaining({
607
- chain: Chain.Bitcoin,
608
- decimal: 8,
609
- isGasAsset: true,
610
- isSynthetic: false,
611
- symbol: "BTC",
612
- ticker: "BTC",
613
- }),
614
- );
615
-
616
- expect(btc.getValue("string")).toBe("52000");
617
- expect(btc.getBaseValue("string")).toBe("5200000000000");
618
- });
619
-
620
- test("returns safe decimals if string is not in `@swapkit/tokens` lists", async () => {
621
- await AssetValue.loadStaticAssets();
622
- const fakeAvaxUSDCAssetString = "AVAX.USDC-1234";
623
- const fakeAvaxUSDCAsset = AssetValue.from({
624
- asset: fakeAvaxUSDCAssetString,
625
- value: 1,
626
- fromBaseDecimal: 8,
627
- });
628
-
629
- expect(fakeAvaxUSDCAsset).toBeDefined();
630
- expect(fakeAvaxUSDCAsset).toEqual(
631
- expect.objectContaining({
632
- address: "1234",
633
- chain: Chain.Avalanche,
634
- decimal: 18,
635
- isGasAsset: false,
636
- isSynthetic: false,
637
- symbol: "USDC-1234",
638
- ticker: "USDC",
639
- }),
640
- );
641
-
642
- expect(fakeAvaxUSDCAsset.getValue("string")).toBe("0.00000001");
643
- expect(fakeAvaxUSDCAsset.getBaseValue("string")).toBe("10000000000");
644
- });
645
-
646
- test("returns proper avax string with address from `@swapkit/tokens` lists", async () => {
647
- await AssetValue.loadStaticAssets();
648
- const avaxUSDC = "AVAX.USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e";
649
- const AvaxUSDC = AssetValue.from({
650
- asset: avaxUSDC,
651
- value: 100000000,
652
- fromBaseDecimal: 8,
653
- });
654
-
655
- expect(AvaxUSDC).toBeDefined();
656
- expect(AvaxUSDC).toEqual(
657
- expect.objectContaining({
658
- address: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
659
- chain: Chain.Avalanche,
660
- decimal: 6,
661
- isGasAsset: false,
662
- isSynthetic: false,
663
- symbol: "USDC-0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
664
- ticker: "USDC",
665
- }),
666
- );
667
-
668
- expect(AvaxUSDC.getValue("string")).toBe("1");
669
- expect(AvaxUSDC.getBaseValue("string")).toBe("1000000");
670
- });
671
- });
672
-
673
- describe("fromChainOrSignature", () => {
674
- test("creates AssetValue from common asset string or chain", () => {
675
- const cosmosAsset = AssetValue.from({ chain: Chain.Cosmos });
676
- expect(cosmosAsset).toEqual(
677
- expect.objectContaining({
678
- address: undefined,
679
- chain: Chain.Cosmos,
680
- decimal: BaseDecimal.GAIA,
681
- isGasAsset: true,
682
- isSynthetic: false,
683
- symbol: "ATOM",
684
- ticker: "ATOM",
685
- type: "Native",
686
- }),
687
- );
688
-
689
- const bscAsset = AssetValue.from({ chain: Chain.BinanceSmartChain });
690
- expect(bscAsset).toEqual(
691
- expect.objectContaining({
692
- address: undefined,
693
- chain: Chain.BinanceSmartChain,
694
- decimal: BaseDecimal.BSC,
695
- isGasAsset: true,
696
- isSynthetic: false,
697
- symbol: "BNB",
698
- ticker: "BNB",
699
- type: "Native",
700
- }),
701
- );
702
-
703
- const thorAsset = AssetValue.from({ chain: Chain.THORChain });
704
- expect(thorAsset).toEqual(
705
- expect.objectContaining({
706
- address: undefined,
707
- chain: Chain.THORChain,
708
- decimal: BaseDecimal.THOR,
709
- isGasAsset: true,
710
- isSynthetic: false,
711
- symbol: "RUNE",
712
- ticker: "RUNE",
713
- type: "Native",
714
- }),
715
- );
716
-
717
- const cacaoAsset = AssetValue.from({ chain: Chain.Maya });
718
- expect(cacaoAsset).toEqual(
719
- expect.objectContaining({
720
- address: undefined,
721
- chain: Chain.Maya,
722
- decimal: 10,
723
- isGasAsset: true,
724
- isSynthetic: false,
725
- symbol: "CACAO",
726
- ticker: "CACAO",
727
- type: "Native",
728
- }),
729
- );
730
-
731
- const thor = AssetValue.from({ asset: "ETH.THOR" });
732
- expect(thor).toEqual(
733
- expect.objectContaining({
734
- address: "0xa5f2211B9b8170F694421f2046281775E8468044",
735
- chain: Chain.Ethereum,
736
- decimal: 18,
737
- isGasAsset: false,
738
- isSynthetic: false,
739
- symbol: "THOR-0xa5f2211B9b8170F694421f2046281775E8468044",
740
- ticker: "THOR",
741
- }),
742
- );
743
-
744
- // FIXME: just some casing? is it safe to change
745
- // const vthor = AssetValue.from({ asset: "ETH.vTHOR" });
746
- // expect(vthor).toEqual(
747
- // expect.objectContaining({
748
- // address: "0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",
749
- // chain: Chain.Ethereum,
750
- // decimal: 18,
751
- // isGasAsset: false,
752
- // isSynthetic: false,
753
- // symbol: "vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",
754
- // ticker: "vTHOR",
755
- // }),
756
- // );
757
-
758
- const arbAsset = AssetValue.from({ chain: Chain.Arbitrum });
759
- expect(arbAsset).toEqual(
760
- expect.objectContaining({
761
- address: undefined,
762
- chain: Chain.Arbitrum,
763
- decimal: BaseDecimal.ARB,
764
- isGasAsset: true,
765
- isSynthetic: false,
766
- symbol: "ETH",
767
- ticker: "ETH",
768
- type: "Native",
769
- }),
770
- );
771
-
772
- const opAsset = AssetValue.from({ chain: Chain.Optimism });
773
- expect(opAsset).toEqual(
774
- expect.objectContaining({
775
- address: undefined,
776
- chain: Chain.Optimism,
777
- decimal: BaseDecimal.OP,
778
- isGasAsset: true,
779
- isSynthetic: false,
780
- symbol: "ETH",
781
- ticker: "ETH",
782
- type: "Native",
783
- }),
784
- );
785
-
786
- const xrdAsset = AssetValue.from({ chain: Chain.Radix });
787
- expect(xrdAsset).toEqual(
788
- expect.objectContaining({
789
- chain: Chain.Radix,
790
- decimal: BaseDecimal.XRD,
791
- isGasAsset: true,
792
- isSynthetic: false,
793
- ticker: "XRD",
794
- type: "Native",
795
- }),
796
- );
797
-
798
- const trxAsset = AssetValue.from({ chain: Chain.Tron });
799
- expect(trxAsset).toEqual(
800
- expect.objectContaining({
801
- chain: Chain.Tron,
802
- decimal: BaseDecimal.TRX,
803
- isGasAsset: true,
804
- isSynthetic: false,
805
- symbol: "TRX",
806
- ticker: "TRX",
807
- type: "Native",
808
- }),
809
- );
810
-
811
- const trxAssetFromString = AssetValue.from({ asset: "TRX.TRX" });
812
- expect(trxAssetFromString).toEqual(
813
- expect.objectContaining({
814
- chain: Chain.Tron,
815
- decimal: BaseDecimal.TRX,
816
- isGasAsset: true,
817
- isSynthetic: false,
818
- symbol: "TRX",
819
- ticker: "TRX",
820
- type: "Native",
821
- }),
822
- );
823
- });
824
-
825
- test("keep SOL address casing", () => {
826
- const solUsdc = AssetValue.from({
827
- asset: "SOL.USDC-EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
828
- });
829
- expect(solUsdc).toEqual(
830
- expect.objectContaining({
831
- address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
832
- chain: Chain.Solana,
833
- isGasAsset: false,
834
- isSynthetic: false,
835
- symbol: "USDC-EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
836
- ticker: "USDC",
837
- }),
838
- );
839
- });
840
-
841
- test("TRC20 tokens are not marked as gas assets", () => {
842
- const tronUsdt = AssetValue.from({
843
- asset: "TRX.USDT-TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
844
- });
845
-
846
- expect(tronUsdt).toEqual(
847
- expect.objectContaining({
848
- address: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
849
- chain: Chain.Tron,
850
- isGasAsset: false,
851
- isSynthetic: false,
852
- symbol: "USDT-TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
853
- ticker: "USDT",
854
- }),
855
- );
856
- });
857
- });
858
- });
859
-
860
- describe("getMinAmountByChain", () => {
861
- test("returns min amount for chain", () => {
862
- expect(getMinAmountByChain(Chain.THORChain).getValue("string")).toBe("0");
863
- expect(getMinAmountByChain(Chain.Maya).getValue("string")).toBe("0");
864
- expect(getMinAmountByChain(Chain.Cosmos).getValue("string")).toBe("0.000001");
865
-
866
- expect(getMinAmountByChain(Chain.Bitcoin).getValue("string")).toBe("0.00010001");
867
- expect(getMinAmountByChain(Chain.Litecoin).getValue("string")).toBe("0.00010001");
868
- expect(getMinAmountByChain(Chain.BitcoinCash).getValue("string")).toBe("0.00010001");
869
- expect(getMinAmountByChain(Chain.Dogecoin).getValue("string")).toBe("1.00000001");
870
-
871
- expect(getMinAmountByChain(Chain.BinanceSmartChain).getValue("string")).toBe("0.00000001");
872
- expect(getMinAmountByChain(Chain.Ethereum).getValue("string")).toBe("0.00000001");
873
- expect(getMinAmountByChain(Chain.Avalanche).getValue("string")).toBe("0.00000001");
874
- expect(getMinAmountByChain(Chain.Arbitrum).getValue("string")).toBe("0.00000001");
875
- expect(getMinAmountByChain(Chain.Optimism).getValue("string")).toBe("0.00000001");
876
- });
877
- });