@tcswap/toolboxes 4.3.15

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 (275) hide show
  1. package/dist/src/cardano/index.cjs +4 -0
  2. package/dist/src/cardano/index.cjs.map +11 -0
  3. package/dist/src/cardano/index.js +4 -0
  4. package/dist/src/cardano/index.js.map +11 -0
  5. package/dist/src/cosmos/index.cjs +4 -0
  6. package/dist/src/cosmos/index.cjs.map +20 -0
  7. package/dist/src/cosmos/index.js +4 -0
  8. package/dist/src/cosmos/index.js.map +20 -0
  9. package/dist/src/evm/index.cjs +4 -0
  10. package/dist/src/evm/index.cjs.map +20 -0
  11. package/dist/src/evm/index.js +4 -0
  12. package/dist/src/evm/index.js.map +20 -0
  13. package/dist/src/index.cjs +5 -0
  14. package/dist/src/index.cjs.map +67 -0
  15. package/dist/src/index.js +5 -0
  16. package/dist/src/index.js.map +67 -0
  17. package/dist/src/near/index.cjs +4 -0
  18. package/dist/src/near/index.cjs.map +16 -0
  19. package/dist/src/near/index.js +4 -0
  20. package/dist/src/near/index.js.map +16 -0
  21. package/dist/src/radix/index.cjs +4 -0
  22. package/dist/src/radix/index.cjs.map +10 -0
  23. package/dist/src/radix/index.js +4 -0
  24. package/dist/src/radix/index.js.map +10 -0
  25. package/dist/src/ripple/index.cjs +4 -0
  26. package/dist/src/ripple/index.cjs.map +10 -0
  27. package/dist/src/ripple/index.js +4 -0
  28. package/dist/src/ripple/index.js.map +10 -0
  29. package/dist/src/solana/index.cjs +4 -0
  30. package/dist/src/solana/index.cjs.map +11 -0
  31. package/dist/src/solana/index.js +4 -0
  32. package/dist/src/solana/index.js.map +11 -0
  33. package/dist/src/substrate/index.cjs +4 -0
  34. package/dist/src/substrate/index.cjs.map +13 -0
  35. package/dist/src/substrate/index.js +4 -0
  36. package/dist/src/substrate/index.js.map +13 -0
  37. package/dist/src/sui/index.cjs +4 -0
  38. package/dist/src/sui/index.cjs.map +11 -0
  39. package/dist/src/sui/index.js +4 -0
  40. package/dist/src/sui/index.js.map +11 -0
  41. package/dist/src/ton/index.cjs +4 -0
  42. package/dist/src/ton/index.cjs.map +11 -0
  43. package/dist/src/ton/index.js +4 -0
  44. package/dist/src/ton/index.js.map +11 -0
  45. package/dist/src/tron/index.cjs +4 -0
  46. package/dist/src/tron/index.cjs.map +13 -0
  47. package/dist/src/tron/index.js +4 -0
  48. package/dist/src/tron/index.js.map +13 -0
  49. package/dist/src/utxo/index.cjs +5 -0
  50. package/dist/src/utxo/index.cjs.map +21 -0
  51. package/dist/src/utxo/index.js +5 -0
  52. package/dist/src/utxo/index.js.map +21 -0
  53. package/dist/types/cardano/index.d.ts +3 -0
  54. package/dist/types/cardano/index.d.ts.map +1 -0
  55. package/dist/types/cardano/toolbox.d.ts +37 -0
  56. package/dist/types/cardano/toolbox.d.ts.map +1 -0
  57. package/dist/types/cardano/types.d.ts +11 -0
  58. package/dist/types/cardano/types.d.ts.map +1 -0
  59. package/dist/types/cosmos/index.d.ts +5 -0
  60. package/dist/types/cosmos/index.d.ts.map +1 -0
  61. package/dist/types/cosmos/thorchainUtils/addressFormat.d.ts +8 -0
  62. package/dist/types/cosmos/thorchainUtils/addressFormat.d.ts.map +1 -0
  63. package/dist/types/cosmos/thorchainUtils/index.d.ts +5 -0
  64. package/dist/types/cosmos/thorchainUtils/index.d.ts.map +1 -0
  65. package/dist/types/cosmos/thorchainUtils/messages.d.ts +211 -0
  66. package/dist/types/cosmos/thorchainUtils/messages.d.ts.map +1 -0
  67. package/dist/types/cosmos/thorchainUtils/registry.d.ts +4 -0
  68. package/dist/types/cosmos/thorchainUtils/registry.d.ts.map +1 -0
  69. package/dist/types/cosmos/thorchainUtils/types/MsgCompiled.d.ts +2 -0
  70. package/dist/types/cosmos/thorchainUtils/types/MsgCompiled.d.ts.map +1 -0
  71. package/dist/types/cosmos/thorchainUtils/types/client-types.d.ts +63 -0
  72. package/dist/types/cosmos/thorchainUtils/types/client-types.d.ts.map +1 -0
  73. package/dist/types/cosmos/thorchainUtils/types/index.d.ts +2 -0
  74. package/dist/types/cosmos/thorchainUtils/types/index.d.ts.map +1 -0
  75. package/dist/types/cosmos/toolbox/cosmos.d.ts +65 -0
  76. package/dist/types/cosmos/toolbox/cosmos.d.ts.map +1 -0
  77. package/dist/types/cosmos/toolbox/index.d.ts +18 -0
  78. package/dist/types/cosmos/toolbox/index.d.ts.map +1 -0
  79. package/dist/types/cosmos/toolbox/thorchain.d.ts +161 -0
  80. package/dist/types/cosmos/toolbox/thorchain.d.ts.map +1 -0
  81. package/dist/types/cosmos/types.d.ts +49 -0
  82. package/dist/types/cosmos/types.d.ts.map +1 -0
  83. package/dist/types/cosmos/util.d.ts +77 -0
  84. package/dist/types/cosmos/util.d.ts.map +1 -0
  85. package/dist/types/evm/api.d.ts +8 -0
  86. package/dist/types/evm/api.d.ts.map +1 -0
  87. package/dist/types/evm/contracts/eth/multicall.d.ts +36 -0
  88. package/dist/types/evm/contracts/eth/multicall.d.ts.map +1 -0
  89. package/dist/types/evm/contracts/op/gasOracle.d.ts +40 -0
  90. package/dist/types/evm/contracts/op/gasOracle.d.ts.map +1 -0
  91. package/dist/types/evm/helpers.d.ts +6 -0
  92. package/dist/types/evm/helpers.d.ts.map +1 -0
  93. package/dist/types/evm/index.d.ts +5 -0
  94. package/dist/types/evm/index.d.ts.map +1 -0
  95. package/dist/types/evm/toolbox/baseEVMToolbox.d.ts +88 -0
  96. package/dist/types/evm/toolbox/baseEVMToolbox.d.ts.map +1 -0
  97. package/dist/types/evm/toolbox/evm.d.ts +767 -0
  98. package/dist/types/evm/toolbox/evm.d.ts.map +1 -0
  99. package/dist/types/evm/toolbox/index.d.ts +7 -0
  100. package/dist/types/evm/toolbox/index.d.ts.map +1 -0
  101. package/dist/types/evm/toolbox/op.d.ts +67 -0
  102. package/dist/types/evm/toolbox/op.d.ts.map +1 -0
  103. package/dist/types/evm/types.d.ts +108 -0
  104. package/dist/types/evm/types.d.ts.map +1 -0
  105. package/dist/types/index.d.ts +78 -0
  106. package/dist/types/index.d.ts.map +1 -0
  107. package/dist/types/near/helpers/core.d.ts +18 -0
  108. package/dist/types/near/helpers/core.d.ts.map +1 -0
  109. package/dist/types/near/helpers/gasEstimation.d.ts +41 -0
  110. package/dist/types/near/helpers/gasEstimation.d.ts.map +1 -0
  111. package/dist/types/near/helpers/nep141.d.ts +36 -0
  112. package/dist/types/near/helpers/nep141.d.ts.map +1 -0
  113. package/dist/types/near/index.d.ts +10 -0
  114. package/dist/types/near/index.d.ts.map +1 -0
  115. package/dist/types/near/toolbox.d.ts +35 -0
  116. package/dist/types/near/toolbox.d.ts.map +1 -0
  117. package/dist/types/near/types/contract.d.ts +38 -0
  118. package/dist/types/near/types/contract.d.ts.map +1 -0
  119. package/dist/types/near/types/nep141.d.ts +29 -0
  120. package/dist/types/near/types/nep141.d.ts.map +1 -0
  121. package/dist/types/near/types/toolbox.d.ts +51 -0
  122. package/dist/types/near/types/toolbox.d.ts.map +1 -0
  123. package/dist/types/near/types.d.ts +47 -0
  124. package/dist/types/near/types.d.ts.map +1 -0
  125. package/dist/types/radix/index.d.ts +17 -0
  126. package/dist/types/radix/index.d.ts.map +1 -0
  127. package/dist/types/ripple/index.d.ts +49 -0
  128. package/dist/types/ripple/index.d.ts.map +1 -0
  129. package/dist/types/solana/index.d.ts +23 -0
  130. package/dist/types/solana/index.d.ts.map +1 -0
  131. package/dist/types/solana/toolbox.d.ts +54 -0
  132. package/dist/types/solana/toolbox.d.ts.map +1 -0
  133. package/dist/types/substrate/balance.d.ts +20 -0
  134. package/dist/types/substrate/balance.d.ts.map +1 -0
  135. package/dist/types/substrate/index.d.ts +3 -0
  136. package/dist/types/substrate/index.d.ts.map +1 -0
  137. package/dist/types/substrate/substrate.d.ts +151 -0
  138. package/dist/types/substrate/substrate.d.ts.map +1 -0
  139. package/dist/types/substrate/types.d.ts +100 -0
  140. package/dist/types/substrate/types.d.ts.map +1 -0
  141. package/dist/types/sui/index.d.ts +3 -0
  142. package/dist/types/sui/index.d.ts.map +1 -0
  143. package/dist/types/sui/toolbox.d.ts +22 -0
  144. package/dist/types/sui/toolbox.d.ts.map +1 -0
  145. package/dist/types/sui/types.d.ts +16 -0
  146. package/dist/types/sui/types.d.ts.map +1 -0
  147. package/dist/types/ton/index.d.ts +3 -0
  148. package/dist/types/ton/index.d.ts.map +1 -0
  149. package/dist/types/ton/toolbox.d.ts +17 -0
  150. package/dist/types/ton/toolbox.d.ts.map +1 -0
  151. package/dist/types/ton/types.d.ts +22 -0
  152. package/dist/types/ton/types.d.ts.map +1 -0
  153. package/dist/types/tron/helpers/trc20.abi.d.ts +156 -0
  154. package/dist/types/tron/helpers/trc20.abi.d.ts.map +1 -0
  155. package/dist/types/tron/helpers/trongrid.d.ts +11 -0
  156. package/dist/types/tron/helpers/trongrid.d.ts.map +1 -0
  157. package/dist/types/tron/index.d.ts +6 -0
  158. package/dist/types/tron/index.d.ts.map +1 -0
  159. package/dist/types/tron/toolbox.d.ts +29 -0
  160. package/dist/types/tron/toolbox.d.ts.map +1 -0
  161. package/dist/types/tron/types.d.ts +103 -0
  162. package/dist/types/tron/types.d.ts.map +1 -0
  163. package/dist/types/types.d.ts +26 -0
  164. package/dist/types/types.d.ts.map +1 -0
  165. package/dist/types/utils.d.ts +7 -0
  166. package/dist/types/utils.d.ts.map +1 -0
  167. package/dist/types/utxo/helpers/api.d.ts +104 -0
  168. package/dist/types/utxo/helpers/api.d.ts.map +1 -0
  169. package/dist/types/utxo/helpers/bchaddrjs.d.ts +13 -0
  170. package/dist/types/utxo/helpers/bchaddrjs.d.ts.map +1 -0
  171. package/dist/types/utxo/helpers/coinselect.d.ts +20 -0
  172. package/dist/types/utxo/helpers/coinselect.d.ts.map +1 -0
  173. package/dist/types/utxo/helpers/index.d.ts +5 -0
  174. package/dist/types/utxo/helpers/index.d.ts.map +1 -0
  175. package/dist/types/utxo/helpers/txSize.d.ts +24 -0
  176. package/dist/types/utxo/helpers/txSize.d.ts.map +1 -0
  177. package/dist/types/utxo/index.d.ts +7 -0
  178. package/dist/types/utxo/index.d.ts.map +1 -0
  179. package/dist/types/utxo/toolbox/bitcoinCash.d.ts +96 -0
  180. package/dist/types/utxo/toolbox/bitcoinCash.d.ts.map +1 -0
  181. package/dist/types/utxo/toolbox/index.d.ts +31 -0
  182. package/dist/types/utxo/toolbox/index.d.ts.map +1 -0
  183. package/dist/types/utxo/toolbox/params.d.ts +32 -0
  184. package/dist/types/utxo/toolbox/params.d.ts.map +1 -0
  185. package/dist/types/utxo/toolbox/utxo.d.ts +106 -0
  186. package/dist/types/utxo/toolbox/utxo.d.ts.map +1 -0
  187. package/dist/types/utxo/toolbox/validators.d.ts +4 -0
  188. package/dist/types/utxo/toolbox/validators.d.ts.map +1 -0
  189. package/dist/types/utxo/toolbox/zcash.d.ts +75 -0
  190. package/dist/types/utxo/toolbox/zcash.d.ts.map +1 -0
  191. package/dist/types/utxo/types.d.ts +46 -0
  192. package/dist/types/utxo/types.d.ts.map +1 -0
  193. package/package.json +205 -0
  194. package/src/__tests__/address-validation-all-chains.test.ts +162 -0
  195. package/src/__tests__/addressValidator.test.ts +162 -0
  196. package/src/cardano/__tests__/toolbox.test.ts +48 -0
  197. package/src/cardano/index.ts +2 -0
  198. package/src/cardano/toolbox.ts +172 -0
  199. package/src/cardano/types.ts +10 -0
  200. package/src/cosmos/__tests__/toolbox.test.ts +95 -0
  201. package/src/cosmos/index.ts +4 -0
  202. package/src/cosmos/thorchainUtils/addressFormat.ts +26 -0
  203. package/src/cosmos/thorchainUtils/index.ts +4 -0
  204. package/src/cosmos/thorchainUtils/messages.ts +216 -0
  205. package/src/cosmos/thorchainUtils/registry.ts +43 -0
  206. package/src/cosmos/thorchainUtils/types/MsgCompiled.ts +2800 -0
  207. package/src/cosmos/thorchainUtils/types/client-types.ts +54 -0
  208. package/src/cosmos/thorchainUtils/types/index.ts +1 -0
  209. package/src/cosmos/toolbox/cosmos.ts +354 -0
  210. package/src/cosmos/toolbox/index.ts +39 -0
  211. package/src/cosmos/toolbox/thorchain.ts +253 -0
  212. package/src/cosmos/types.ts +48 -0
  213. package/src/cosmos/util.ts +218 -0
  214. package/src/evm/__tests__/address-validation.test.ts +84 -0
  215. package/src/evm/__tests__/ethereum.test.ts +141 -0
  216. package/src/evm/__tests__/signMessage.test.ts +60 -0
  217. package/src/evm/api.ts +10 -0
  218. package/src/evm/contracts/eth/multicall.ts +165 -0
  219. package/src/evm/contracts/op/gasOracle.ts +145 -0
  220. package/src/evm/helpers.ts +71 -0
  221. package/src/evm/index.ts +4 -0
  222. package/src/evm/toolbox/baseEVMToolbox.ts +701 -0
  223. package/src/evm/toolbox/evm.ts +66 -0
  224. package/src/evm/toolbox/index.ts +44 -0
  225. package/src/evm/toolbox/op.ts +147 -0
  226. package/src/evm/types.ts +146 -0
  227. package/src/index.ts +264 -0
  228. package/src/near/__tests__/core.test.ts +70 -0
  229. package/src/near/helpers/core.ts +89 -0
  230. package/src/near/helpers/gasEstimation.ts +96 -0
  231. package/src/near/helpers/nep141.ts +50 -0
  232. package/src/near/index.ts +21 -0
  233. package/src/near/toolbox.ts +425 -0
  234. package/src/near/types/contract.ts +32 -0
  235. package/src/near/types/nep141.ts +34 -0
  236. package/src/near/types/toolbox.ts +55 -0
  237. package/src/near/types.ts +44 -0
  238. package/src/radix/index.ts +142 -0
  239. package/src/ripple/index.ts +180 -0
  240. package/src/solana/index.ts +36 -0
  241. package/src/solana/toolbox.ts +413 -0
  242. package/src/substrate/balance.ts +92 -0
  243. package/src/substrate/index.ts +2 -0
  244. package/src/substrate/substrate.ts +285 -0
  245. package/src/substrate/types.ts +115 -0
  246. package/src/sui/__tests__/toolbox.test.ts +86 -0
  247. package/src/sui/index.ts +2 -0
  248. package/src/sui/toolbox.ts +170 -0
  249. package/src/sui/types.ts +11 -0
  250. package/src/ton/__tests__/toolbox.test.ts +67 -0
  251. package/src/ton/index.ts +2 -0
  252. package/src/ton/toolbox.ts +140 -0
  253. package/src/ton/types.ts +13 -0
  254. package/src/tron/__tests__/toolbox.test.ts +225 -0
  255. package/src/tron/helpers/trc20.abi.ts +107 -0
  256. package/src/tron/helpers/trongrid.ts +57 -0
  257. package/src/tron/index.ts +21 -0
  258. package/src/tron/toolbox.ts +589 -0
  259. package/src/tron/types.ts +83 -0
  260. package/src/types.ts +28 -0
  261. package/src/utils.ts +38 -0
  262. package/src/utxo/__tests__/zcash-integration.test.ts +97 -0
  263. package/src/utxo/helpers/api.ts +475 -0
  264. package/src/utxo/helpers/bchaddrjs.ts +170 -0
  265. package/src/utxo/helpers/coinselect.ts +96 -0
  266. package/src/utxo/helpers/index.ts +4 -0
  267. package/src/utxo/helpers/txSize.ts +141 -0
  268. package/src/utxo/index.ts +6 -0
  269. package/src/utxo/toolbox/bitcoinCash.ts +247 -0
  270. package/src/utxo/toolbox/index.ts +63 -0
  271. package/src/utxo/toolbox/params.ts +18 -0
  272. package/src/utxo/toolbox/utxo.ts +443 -0
  273. package/src/utxo/toolbox/validators.ts +36 -0
  274. package/src/utxo/toolbox/zcash.ts +246 -0
  275. package/src/utxo/types.ts +39 -0
@@ -0,0 +1,701 @@
1
+ /**
2
+ * Modifications © 2025 Horizontal Systems.
3
+ */
4
+
5
+ import {
6
+ type Asset,
7
+ AssetValue,
8
+ applyFeeMultiplierToBigInt,
9
+ Chain,
10
+ type ChainSigner,
11
+ type EVMChain,
12
+ EVMChains,
13
+ FeeOption,
14
+ isGasAsset,
15
+ USwapError,
16
+ USwapNumber,
17
+ } from "@tcswap/helpers";
18
+ import { erc20ABI } from "@tcswap/helpers/contracts";
19
+ import {
20
+ BrowserProvider,
21
+ Contract,
22
+ type ContractTransaction,
23
+ type Fragment,
24
+ getAddress,
25
+ type HDNodeWallet,
26
+ Interface,
27
+ type JsonFragment,
28
+ type JsonRpcSigner,
29
+ type Provider,
30
+ type Signer,
31
+ } from "ethers";
32
+ import { match } from "ts-pattern";
33
+ import { getEvmApi } from "../api";
34
+ import { getNetworkParams, toHexString } from "../helpers";
35
+ import type {
36
+ ApproveParams,
37
+ CallParams,
38
+ EIP1559TxParams,
39
+ EstimateCallParams,
40
+ EVMCreateTransactionParams,
41
+ EVMTransferParams,
42
+ EVMTxParams,
43
+ IsApprovedParams,
44
+ LegacyEVMTxParams,
45
+ } from "../types";
46
+
47
+ type ToolboxWrapParams<P = Provider | BrowserProvider, T = {}> = T & {
48
+ isEIP1559Compatible?: boolean;
49
+ provider: P;
50
+ signer?: Signer;
51
+ chain: EVMChain;
52
+ };
53
+
54
+ export const MAX_APPROVAL = BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
55
+
56
+ export function BaseEVMToolbox<
57
+ P extends Provider | BrowserProvider,
58
+ S extends (ChainSigner<EVMTransferParams, string> & Signer) | JsonRpcSigner | HDNodeWallet | undefined,
59
+ >({
60
+ chain = Chain.Ethereum,
61
+ provider,
62
+ signer,
63
+ isEIP1559Compatible = true,
64
+ }: {
65
+ signer: S;
66
+ provider: P;
67
+ isEIP1559Compatible?: boolean;
68
+ chain?: EVMChain;
69
+ }) {
70
+ return {
71
+ approve: getApprove({ chain, isEIP1559Compatible, provider, signer }),
72
+ approvedAmount: getApprovedAmount({ chain, provider }),
73
+ broadcastTransaction: provider.broadcastTransaction,
74
+ call: getCall({ chain, isEIP1559Compatible, provider, signer }),
75
+ createApprovalTx: getCreateApprovalTx({ chain, provider, signer }),
76
+ createContract: getCreateContract({ chain, provider }),
77
+ createContractTxObject: getCreateContractTxObject({ chain, provider }),
78
+ createTransaction: getCreateTransferTx({ chain, provider, signer }),
79
+ createTransferTx: getCreateTransferTx({ chain, provider, signer }),
80
+ EIP1193SendTransaction: getEIP1193SendTransaction(provider),
81
+ estimateCall: getEstimateCall({ provider, signer }),
82
+ estimateGasLimit: getEstimateGasLimit({ chain, provider, signer }),
83
+ estimateGasPrices: getEstimateGasPrices({ chain, isEIP1559Compatible, provider }),
84
+ estimateTransactionFee: getEstimateTransactionFee({ chain, isEIP1559Compatible, provider }),
85
+ getAddress: () => {
86
+ return signer ? signer.getAddress() : undefined;
87
+ },
88
+ getBalance: getEvmApi(chain).getBalance,
89
+ getNetworkParams: getNetworkParams(chain),
90
+ isApproved: getIsApproved({ chain, provider }),
91
+ sendTransaction: getSendTransaction({ chain, isEIP1559Compatible, provider, signer }),
92
+ signMessage: signer ? (message: string | Uint8Array) => signer.signMessage(message) : undefined,
93
+ transfer: getTransfer({ chain, isEIP1559Compatible, provider, signer }),
94
+ validateAddress: (address: string) => evmValidateAddress({ address }),
95
+ };
96
+ }
97
+
98
+ export function evmValidateAddress({ address }: { address: string }) {
99
+ try {
100
+ getAddress(address);
101
+ return true;
102
+ } catch {
103
+ return false;
104
+ }
105
+ }
106
+
107
+ export function isBrowserProvider(provider: any) {
108
+ return provider instanceof BrowserProvider;
109
+ }
110
+
111
+ export function createContract(address: string, abi: readonly (JsonFragment | Fragment)[], provider: Provider) {
112
+ return new Contract(address, Interface.from(abi), provider);
113
+ }
114
+
115
+ export function getCreateContract({ provider }: ToolboxWrapParams) {
116
+ return function createContract(address: string, abi: readonly (JsonFragment | Fragment)[]) {
117
+ return new Contract(address, Interface.from(abi), provider);
118
+ };
119
+ }
120
+
121
+ const stateMutable = ["payable", "nonpayable"];
122
+ // const nonStateMutable = ['view', 'pure'];
123
+ export function isStateChangingCall({ abi, funcName }: { abi: readonly JsonFragment[]; funcName: string }) {
124
+ const abiFragment = abi.find((fragment: any) => fragment.name === funcName) as any;
125
+ if (!abiFragment) throw new USwapError("toolbox_evm_no_abi_fragment", { funcName });
126
+ return abiFragment.stateMutability && stateMutable.includes(abiFragment.stateMutability);
127
+ }
128
+
129
+ export function toChecksumAddress(address: string) {
130
+ return getAddress(address);
131
+ }
132
+
133
+ export function getEIP1193SendTransaction(provider: Provider | BrowserProvider) {
134
+ return function EIP1193SendTransaction({ value, ...params }: EVMTxParams | ContractTransaction): Promise<string> {
135
+ if (!isBrowserProvider(provider)) {
136
+ throw new USwapError("toolbox_evm_provider_not_eip1193_compatible");
137
+ }
138
+
139
+ // Remove gas-related parameters to let the wallet estimate them
140
+ // EIP-1193 providers (MetaMask, etc.) will estimate these automatically
141
+ const {
142
+ gasLimit: _gasLimit,
143
+ gasPrice: _gasPrice,
144
+ maxFeePerGas: _maxFeePerGas,
145
+ maxPriorityFeePerGas: _maxPriorityFeePerGas,
146
+ ...cleanParams
147
+ } = params as any;
148
+
149
+ return (provider as BrowserProvider).send("eth_sendTransaction", [
150
+ { ...cleanParams, value: toHexString(BigInt(value || 0)) } as any,
151
+ ]);
152
+ };
153
+ }
154
+
155
+ export function getChecksumAddressFromAsset(asset: Asset, chain: EVMChain) {
156
+ const assetAddress = getTokenAddress(asset, chain);
157
+
158
+ if (assetAddress) {
159
+ return getAddress(assetAddress.toLowerCase());
160
+ }
161
+
162
+ throw new USwapError("toolbox_evm_invalid_gas_asset_address");
163
+ }
164
+
165
+ const baseContractAddresses = EVMChains.reduce(
166
+ (acc, chain) => {
167
+ acc[chain] = "0x0000000000000000000000000000000000000000";
168
+ return acc;
169
+ },
170
+ {} as Record<EVMChain, string>,
171
+ );
172
+
173
+ export const ContractAddress: Record<EVMChain, string> = {
174
+ ...baseContractAddresses,
175
+ [Chain.Optimism]: "0x4200000000000000000000000000000000000042",
176
+ [Chain.Polygon]: "0x0000000000000000000000000000000000001010",
177
+ };
178
+
179
+ const ethGasChains = [Chain.Arbitrum, Chain.Aurora, Chain.Base, Chain.Optimism] as string[];
180
+
181
+ export function getTokenAddress({ chain, symbol, ticker }: Asset, baseAssetChain: EVMChain) {
182
+ try {
183
+ const isBSCBNB = chain === Chain.BinanceSmartChain && symbol === "BNB" && ticker === "BNB";
184
+ const isBaseAsset = chain === baseAssetChain && symbol === baseAssetChain && ticker === baseAssetChain;
185
+ const isEVMAsset = ethGasChains.includes(chain) && symbol === "ETH" && ticker === "ETH";
186
+
187
+ if (isBaseAsset || isBSCBNB || isEVMAsset) {
188
+ return ContractAddress[baseAssetChain];
189
+ }
190
+
191
+ // strip 0X only - 0x is still valid
192
+ return getAddress(symbol.slice(ticker.length + 1).replace(/^0X/, ""));
193
+ } catch {
194
+ return null;
195
+ }
196
+ }
197
+
198
+ export function getCreateContractTxObject({ provider }: ToolboxWrapParams) {
199
+ return async ({ contractAddress, abi, funcName, funcParams = [], txOverrides }: CallParams) =>
200
+ createContract(contractAddress, abi, provider)
201
+ .getFunction(funcName)
202
+ .populateTransaction(...funcParams.concat(txOverrides).filter((p) => typeof p !== "undefined"));
203
+ }
204
+
205
+ export function getEstimateGasPrices({
206
+ chain,
207
+ provider,
208
+ isEIP1559Compatible = true,
209
+ }: {
210
+ provider: Provider;
211
+ isEIP1559Compatible?: boolean;
212
+ chain: EVMChain;
213
+ }): () => Promise<{
214
+ [key in FeeOption]: { l1GasPrice?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint };
215
+ }> {
216
+ return match(chain)
217
+ .with(Chain.Gnosis, () => {
218
+ return async function estimateGasPrices() {
219
+ try {
220
+ const { gasPrice, maxPriorityFeePerGas } = await provider.getFeeData();
221
+ if (!gasPrice || maxPriorityFeePerGas === null) throw new USwapError("toolbox_evm_no_fee_data");
222
+
223
+ return {
224
+ [FeeOption.Average]: {
225
+ maxFeePerGas: applyFeeMultiplierToBigInt(gasPrice, FeeOption.Average),
226
+ maxPriorityFeePerGas: applyFeeMultiplierToBigInt(maxPriorityFeePerGas, FeeOption.Average),
227
+ },
228
+ [FeeOption.Fast]: {
229
+ maxFeePerGas: applyFeeMultiplierToBigInt(gasPrice, FeeOption.Fast),
230
+ maxPriorityFeePerGas: applyFeeMultiplierToBigInt(maxPriorityFeePerGas, FeeOption.Fast),
231
+ },
232
+ [FeeOption.Fastest]: {
233
+ maxFeePerGas: applyFeeMultiplierToBigInt(gasPrice, FeeOption.Fastest),
234
+ maxPriorityFeePerGas: applyFeeMultiplierToBigInt(maxPriorityFeePerGas, FeeOption.Fastest),
235
+ },
236
+ };
237
+ } catch (error) {
238
+ throw new USwapError("toolbox_evm_gas_estimation_error", {
239
+ error: (error as any).msg ?? (error as any).toString(),
240
+ });
241
+ }
242
+ };
243
+ })
244
+ .with(Chain.Arbitrum, () => {
245
+ return async function estimateGasPrices() {
246
+ try {
247
+ const { gasPrice } = await provider.getFeeData();
248
+ if (!gasPrice) throw new USwapError("toolbox_evm_no_fee_data");
249
+
250
+ return {
251
+ [FeeOption.Average]: { gasPrice },
252
+ [FeeOption.Fast]: { gasPrice },
253
+ [FeeOption.Fastest]: { gasPrice },
254
+ };
255
+ } catch (error) {
256
+ throw new USwapError("toolbox_evm_gas_estimation_error", {
257
+ error: (error as any).msg ?? (error as any).toString(),
258
+ });
259
+ }
260
+ };
261
+ })
262
+ .otherwise(() => {
263
+ return async function estimateGasPrices() {
264
+ try {
265
+ const { maxFeePerGas, maxPriorityFeePerGas, gasPrice } = await provider.getFeeData();
266
+
267
+ if (isEIP1559Compatible) {
268
+ if (maxFeePerGas === null || maxPriorityFeePerGas === null) throw new USwapError("toolbox_evm_no_fee_data");
269
+
270
+ return {
271
+ [FeeOption.Average]: { maxFeePerGas, maxPriorityFeePerGas },
272
+ [FeeOption.Fast]: {
273
+ maxFeePerGas: applyFeeMultiplierToBigInt(maxFeePerGas, FeeOption.Fast),
274
+ maxPriorityFeePerGas: applyFeeMultiplierToBigInt(maxPriorityFeePerGas, FeeOption.Fast),
275
+ },
276
+ [FeeOption.Fastest]: {
277
+ maxFeePerGas: applyFeeMultiplierToBigInt(maxFeePerGas, FeeOption.Fastest),
278
+ maxPriorityFeePerGas: applyFeeMultiplierToBigInt(maxPriorityFeePerGas, FeeOption.Fastest),
279
+ },
280
+ };
281
+ }
282
+ if (!gasPrice) throw new USwapError("toolbox_evm_no_gas_price");
283
+
284
+ return {
285
+ [FeeOption.Average]: { gasPrice },
286
+ [FeeOption.Fast]: { gasPrice: applyFeeMultiplierToBigInt(gasPrice, FeeOption.Fast) },
287
+ [FeeOption.Fastest]: { gasPrice: applyFeeMultiplierToBigInt(gasPrice, FeeOption.Fastest) },
288
+ };
289
+ } catch (error) {
290
+ throw new USwapError("toolbox_evm_gas_estimation_error", {
291
+ error: (error as any).msg ?? (error as any).toString(),
292
+ });
293
+ }
294
+ };
295
+ });
296
+ }
297
+
298
+ function getCall({ provider, isEIP1559Compatible, signer, chain }: ToolboxWrapParams) {
299
+ /**
300
+ * @info call contract function
301
+ * When using this method to make a non state changing call to the blockchain, like a isApproved call,
302
+ * the signer needs to be set to undefined
303
+ */
304
+ return async function call<T>({
305
+ callProvider,
306
+ contractAddress,
307
+ abi,
308
+ funcName,
309
+ funcParams = [],
310
+ txOverrides = {},
311
+ feeOption = FeeOption.Fast,
312
+ }: CallParams): Promise<T> {
313
+ const contractProvider = callProvider || provider;
314
+ if (!contractAddress)
315
+ throw new USwapError("toolbox_evm_invalid_params", { error: "contractAddress must be provided" });
316
+
317
+ const isStateChanging = isStateChangingCall({ abi, funcName });
318
+
319
+ if (isStateChanging && isBrowserProvider(contractProvider) && signer) {
320
+ const createTx = getCreateContractTxObject({ chain, provider: contractProvider });
321
+ const from = txOverrides?.from || (await signer?.getAddress());
322
+ const txObject = await createTx({
323
+ abi,
324
+ contractAddress,
325
+ funcName,
326
+ funcParams,
327
+ txOverrides: { ...txOverrides, from },
328
+ });
329
+ const sendTx = getEIP1193SendTransaction(contractProvider);
330
+
331
+ return sendTx(txObject) as Promise<T>;
332
+ }
333
+ const contract = createContract(contractAddress, abi, contractProvider);
334
+
335
+ // only use signer if the contract function is state changing
336
+ if (isStateChanging) {
337
+ if (!signer) throw new USwapError("toolbox_evm_no_signer");
338
+
339
+ const from = txOverrides?.from || (await signer.getAddress());
340
+ if (!from) throw new USwapError("toolbox_evm_no_signer_address");
341
+
342
+ const connectedContract = contract.connect(signer);
343
+ const estimateGasPrices = getEstimateGasPrices({ chain, isEIP1559Compatible, provider });
344
+ const { maxFeePerGas, maxPriorityFeePerGas, gasPrice } = (await estimateGasPrices())[feeOption];
345
+
346
+ const gasLimit = await contract.getFunction(funcName).estimateGas(...funcParams, txOverrides);
347
+
348
+ // @ts-expect-error
349
+ const result = await connectedContract[funcName](...funcParams, {
350
+ ...txOverrides,
351
+ gasLimit,
352
+ gasPrice,
353
+ maxFeePerGas,
354
+ maxPriorityFeePerGas,
355
+ /**
356
+ * nonce must be set due to a possible bug with ethers.js,
357
+ * expecting a synchronous nonce while the JsonRpcProvider delivers Promise
358
+ */
359
+ nonce: txOverrides?.nonce || (await contractProvider.getTransactionCount(from)),
360
+ });
361
+
362
+ return typeof result?.hash === "string" ? result?.hash : result;
363
+ }
364
+
365
+ const result = await contract[funcName]?.(...funcParams);
366
+
367
+ return typeof result?.hash === "string" ? result?.hash : result;
368
+ };
369
+ }
370
+
371
+ function getApprovedAmount({ provider, chain }: ToolboxWrapParams) {
372
+ return function approveAmount({ assetAddress, spenderAddress, from }: IsApprovedParams) {
373
+ const call = getCall({ chain, isEIP1559Compatible: true, provider });
374
+
375
+ return call<bigint>({
376
+ abi: erc20ABI,
377
+ contractAddress: assetAddress,
378
+ funcName: "allowance",
379
+ funcParams: [from, spenderAddress],
380
+ });
381
+ };
382
+ }
383
+
384
+ function getIsApproved({ provider, chain }: ToolboxWrapParams) {
385
+ return async function isApproved({ assetAddress, spenderAddress, from, amount = MAX_APPROVAL }: IsApprovedParams) {
386
+ const approvedAmount = await getApprovedAmount({ chain, provider })({ assetAddress, from, spenderAddress });
387
+
388
+ return USwapNumber.fromBigInt(approvedAmount).gte(USwapNumber.fromBigInt(BigInt(amount)));
389
+ };
390
+ }
391
+
392
+ function getApprove({ signer, isEIP1559Compatible = true, provider, chain }: ToolboxWrapParams) {
393
+ return async function approve({
394
+ assetAddress,
395
+ spenderAddress,
396
+ feeOptionKey = FeeOption.Fast,
397
+ amount,
398
+ gasLimitFallback,
399
+ from: fromParam,
400
+ nonce,
401
+ }: ApproveParams) {
402
+ const funcParams = [spenderAddress, BigInt(amount || MAX_APPROVAL)];
403
+ const from = (await signer?.getAddress()) || fromParam;
404
+
405
+ const functionCallParams = {
406
+ abi: erc20ABI,
407
+ contractAddress: assetAddress,
408
+ funcName: "approve",
409
+ funcParams,
410
+ signer,
411
+ txOverrides: { from },
412
+ };
413
+
414
+ if (isBrowserProvider(provider)) {
415
+ const createTx = getCreateContractTxObject({ chain, provider });
416
+ const sendTx = getEIP1193SendTransaction(provider);
417
+ const txObject = await createTx(functionCallParams);
418
+
419
+ return sendTx(txObject);
420
+ }
421
+
422
+ const call = getCall({ chain, isEIP1559Compatible, provider, signer });
423
+
424
+ return call<string>({
425
+ ...functionCallParams,
426
+ feeOption: feeOptionKey,
427
+ funcParams,
428
+ txOverrides: { from, gasLimit: gasLimitFallback ? BigInt(gasLimitFallback.toString()) : undefined, nonce },
429
+ });
430
+ };
431
+ }
432
+
433
+ function getTransfer({ signer, isEIP1559Compatible = true, provider }: ToolboxWrapParams) {
434
+ return async function transfer({
435
+ assetValue,
436
+ memo,
437
+ recipient,
438
+ feeOptionKey = FeeOption.Fast,
439
+ sender,
440
+ // data,
441
+ // from: fromOverride,
442
+ // maxFeePerGas,
443
+ // maxPriorityFeePerGas,
444
+ // gasPrice,
445
+ ...tx
446
+ }: EVMTransferParams) {
447
+ const { hexlify, toUtf8Bytes } = await import("ethers");
448
+ const txAmount = assetValue.getBaseValue("bigint");
449
+ const chain = assetValue.chain as EVMChain;
450
+ const from = sender || (await signer?.getAddress());
451
+ const sendTx = getSendTransaction({ chain, isEIP1559Compatible, provider, signer });
452
+
453
+ if (!from) throw new USwapError("toolbox_evm_no_from_address");
454
+
455
+ if (assetValue.isGasAsset) {
456
+ const transaction = {
457
+ ...tx,
458
+ data: hexlify(toUtf8Bytes(memo || "")),
459
+ feeOptionKey,
460
+ from,
461
+ to: recipient,
462
+ value: txAmount,
463
+ };
464
+
465
+ return sendTx(transaction);
466
+ }
467
+
468
+ // const call = getCall({ signer, provider, isEIP1559Compatible });
469
+ const contractAddress = getTokenAddress(assetValue, chain);
470
+ if (!contractAddress) throw new USwapError("toolbox_evm_no_contract_address");
471
+
472
+ const { maxFeePerGas, maxPriorityFeePerGas, gasPrice } = (
473
+ await getEstimateGasPrices({ chain, isEIP1559Compatible, provider })()
474
+ )[feeOptionKey];
475
+
476
+ const transaction = await getCreateTransferTx({ chain, provider, signer })({
477
+ assetValue,
478
+ data: hexlify(toUtf8Bytes(memo || "")),
479
+ gasPrice,
480
+ maxFeePerGas,
481
+ maxPriorityFeePerGas,
482
+ memo,
483
+ recipient,
484
+ sender: from,
485
+ });
486
+
487
+ return sendTx(transaction);
488
+ };
489
+ }
490
+
491
+ function getEstimateCall({ provider, signer }: { signer?: Signer; provider: Provider }) {
492
+ return function estimateCall({ contractAddress, abi, funcName, funcParams = [], txOverrides }: EstimateCallParams) {
493
+ if (!contractAddress) throw new USwapError("toolbox_evm_no_contract_address");
494
+
495
+ const contract = createContract(contractAddress, abi, provider);
496
+ return signer
497
+ ? contract
498
+ .connect(signer)
499
+ .getFunction(funcName)
500
+ .estimateGas(...funcParams, txOverrides)
501
+ : contract.getFunction(funcName).estimateGas(...funcParams, txOverrides);
502
+ };
503
+ }
504
+
505
+ function getEstimateGasLimit({ provider, signer }: ToolboxWrapParams) {
506
+ return async function estimateGasLimit({
507
+ assetValue,
508
+ recipient,
509
+ memo,
510
+ data,
511
+ sender,
512
+ funcName,
513
+ funcParams,
514
+ txOverrides,
515
+ }: EVMTransferParams & {
516
+ assetValue: AssetValue;
517
+ funcName?: string;
518
+ funcParams?: unknown[];
519
+ txOverrides?: EVMTxParams;
520
+ data?: string;
521
+ }) {
522
+ // const value = assetValue.getBaseValue("bigint");
523
+ const value = assetValue.bigIntValue;
524
+
525
+ const assetAddress = assetValue.isGasAsset ? null : getTokenAddress(assetValue, assetValue.chain as EVMChain);
526
+
527
+ if (assetAddress && funcName) {
528
+ const estimateCall = getEstimateCall({ provider, signer });
529
+ // ERC20 gas estimate
530
+ return estimateCall({ abi: erc20ABI, contractAddress: assetAddress, funcName, funcParams, txOverrides });
531
+ }
532
+
533
+ const { hexlify, toUtf8Bytes } = await import("ethers");
534
+
535
+ return provider.estimateGas({
536
+ data: data ? data : memo ? hexlify(toUtf8Bytes(memo)) : undefined,
537
+ from: sender,
538
+ to: recipient,
539
+ value,
540
+ });
541
+ };
542
+ }
543
+
544
+ const isEIP1559Transaction = (tx: EVMTxParams) =>
545
+ (tx as EIP1559TxParams).type === 2 ||
546
+ !!(tx as EIP1559TxParams).maxFeePerGas ||
547
+ !!(tx as EIP1559TxParams).maxPriorityFeePerGas;
548
+
549
+ function getSendTransaction({ provider, signer, isEIP1559Compatible = true, chain }: ToolboxWrapParams) {
550
+ return async function sendTransaction({
551
+ feeOptionKey = FeeOption.Fast,
552
+ ...tx
553
+ }: EVMTxParams & { feeOptionKey?: FeeOption }) {
554
+ const { from, to, data, value, ...transaction } = tx;
555
+
556
+ if (!signer) throw new USwapError("toolbox_evm_no_signer");
557
+ if (!to) throw new USwapError("toolbox_evm_no_to_address");
558
+
559
+ const parsedTxObject = { ...transaction, data: data || "0x", from, to, value: BigInt(value || 0) };
560
+
561
+ // early return to skip gas estimation if provider is EIP-1193
562
+ if (isBrowserProvider(provider)) {
563
+ const sendTx = getEIP1193SendTransaction(provider);
564
+ return sendTx(parsedTxObject);
565
+ }
566
+
567
+ const address = from || (await signer.getAddress());
568
+ const nonce = tx.nonce || (await provider.getTransactionCount(address));
569
+ const chainId = (await provider.getNetwork()).chainId;
570
+
571
+ const isEIP1559 = isEIP1559Transaction(parsedTxObject) || isEIP1559Compatible;
572
+ const estimateGasPrices = getEstimateGasPrices({ chain, isEIP1559Compatible, provider });
573
+
574
+ const feeData =
575
+ (isEIP1559 &&
576
+ !(
577
+ (parsedTxObject as EIP1559TxParams).maxFeePerGas && (parsedTxObject as EIP1559TxParams).maxPriorityFeePerGas
578
+ )) ||
579
+ !(parsedTxObject as LegacyEVMTxParams).gasPrice
580
+ ? Object.entries((await estimateGasPrices())[feeOptionKey]).reduce(
581
+ // biome-ignore lint/performance/noAccumulatingSpread: this is a small object
582
+ (acc, [k, v]) => ({ ...acc, [k]: toHexString(BigInt(v)) }),
583
+ {} as { maxFeePerGas?: string; maxPriorityFeePerGas?: string; gasPrice?: string },
584
+ )
585
+ : {};
586
+ let gasLimit: string;
587
+ try {
588
+ gasLimit = toHexString(parsedTxObject.gasLimit || ((await provider.estimateGas(parsedTxObject)) * 11n) / 10n);
589
+ } catch (error) {
590
+ throw new USwapError("toolbox_evm_error_estimating_gas_limit", { error });
591
+ }
592
+
593
+ try {
594
+ const txObject = { ...parsedTxObject, chainId, gasLimit, nonce, type: isEIP1559 ? 2 : 0, ...feeData };
595
+
596
+ try {
597
+ const response = await signer.sendTransaction(txObject);
598
+ return response.hash;
599
+ } catch {
600
+ const txHex = await signer.signTransaction({ ...txObject, from: address });
601
+ const response = await provider.broadcastTransaction(txHex);
602
+ return response.hash;
603
+ }
604
+ } catch (error) {
605
+ throw new USwapError("toolbox_evm_error_sending_transaction", { error });
606
+ }
607
+ };
608
+ }
609
+
610
+ function getCreateTransferTx({ provider, signer }: ToolboxWrapParams) {
611
+ return async function createTransferTx({
612
+ assetValue,
613
+ memo,
614
+ recipient,
615
+ data,
616
+ sender: fromOverride,
617
+ maxFeePerGas,
618
+ maxPriorityFeePerGas,
619
+ gasPrice,
620
+ ...tx
621
+ }: EVMCreateTransactionParams) {
622
+ const txAmount = assetValue.getBaseValue("bigint");
623
+ const chain = assetValue.chain as EVMChain;
624
+ const from = fromOverride || (await signer?.getAddress());
625
+
626
+ if (!from) throw new USwapError("toolbox_evm_no_from_address");
627
+
628
+ if (isGasAsset(assetValue)) {
629
+ const { hexlify, toUtf8Bytes } = await import("ethers");
630
+
631
+ return { ...tx, data: data || hexlify(toUtf8Bytes(memo || "")), from, to: recipient, value: txAmount };
632
+ }
633
+
634
+ const contractAddress = getTokenAddress(assetValue, chain);
635
+ if (!contractAddress) throw new USwapError("toolbox_evm_no_contract_address");
636
+ const createTx = getCreateContractTxObject({ chain: assetValue.chain as EVMChain, provider });
637
+
638
+ return createTx({
639
+ abi: erc20ABI,
640
+ contractAddress,
641
+ funcName: "transfer",
642
+ funcParams: [recipient, txAmount],
643
+ txOverrides: { from, gasPrice, maxFeePerGas, maxPriorityFeePerGas },
644
+ });
645
+ };
646
+ }
647
+
648
+ function getCreateApprovalTx({ provider, signer, chain }: ToolboxWrapParams) {
649
+ return async function createApprovalTx({ assetAddress, spenderAddress, amount, from: fromParam }: ApproveParams) {
650
+ const from = (await signer?.getAddress()) || fromParam;
651
+
652
+ const createTx = getCreateContractTxObject({ chain, provider });
653
+ const approvalAmount = ["bigint", "number"].includes(typeof amount)
654
+ ? (amount as bigint | number)
655
+ : amount || MAX_APPROVAL;
656
+
657
+ const txObject = await createTx({
658
+ abi: erc20ABI,
659
+ contractAddress: assetAddress,
660
+ funcName: "approve",
661
+ funcParams: [spenderAddress, BigInt(approvalAmount)],
662
+ txOverrides: { from },
663
+ });
664
+
665
+ return txObject;
666
+ };
667
+ }
668
+
669
+ function getEstimateTransactionFee({
670
+ provider,
671
+ isEIP1559Compatible = true,
672
+ }: {
673
+ provider: Provider | BrowserProvider;
674
+ isEIP1559Compatible?: boolean;
675
+ chain: EVMChain;
676
+ }) {
677
+ return async function estimateTransactionFee({
678
+ feeOption = FeeOption.Fast,
679
+ chain,
680
+ ...txObject
681
+ }: EIP1559TxParams & { feeOption: FeeOption; chain: EVMChain }) {
682
+ const estimateGasPrices = getEstimateGasPrices({ chain, isEIP1559Compatible, provider });
683
+ const gasPrices = await estimateGasPrices();
684
+ const gasLimit = await provider.estimateGas(txObject);
685
+
686
+ const assetValue = AssetValue.from({ chain });
687
+ const { gasPrice, maxFeePerGas, maxPriorityFeePerGas } = gasPrices[feeOption];
688
+
689
+ if (!isEIP1559Compatible && gasPrice) {
690
+ return assetValue.set(USwapNumber.fromBigInt(gasPrice * gasLimit, assetValue.decimal));
691
+ }
692
+
693
+ if (maxFeePerGas && maxPriorityFeePerGas) {
694
+ const fee = (maxFeePerGas + maxPriorityFeePerGas) * gasLimit;
695
+
696
+ return assetValue.set(USwapNumber.fromBigInt(fee, assetValue.decimal));
697
+ }
698
+
699
+ throw new USwapError("toolbox_evm_no_gas_price");
700
+ };
701
+ }