@hinkal/common 0.2.4 → 0.2.13

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 (257) hide show
  1. package/API/API.cjs +1 -1
  2. package/API/API.d.ts +2 -2
  3. package/API/API.mjs +22 -22
  4. package/API/duneAPI.cjs +1 -1
  5. package/API/duneAPI.mjs +2 -3
  6. package/API/userVerifyTransactions.cjs +1 -1
  7. package/API/userVerifyTransactions.d.ts +7 -6
  8. package/API/userVerifyTransactions.mjs +14 -13
  9. package/constants/chains.constants.cjs +1 -1
  10. package/constants/chains.constants.mjs +2 -2
  11. package/constants/contracts.constants.cjs +1 -1
  12. package/constants/contracts.constants.mjs +134 -138
  13. package/constants/deploy-data/deploy-data-arbMainnet.json.cjs +1 -1
  14. package/constants/deploy-data/deploy-data-arbMainnet.json.mjs +11 -846
  15. package/constants/deploy-data/deploy-data-avalanche.json.cjs +1 -1
  16. package/constants/deploy-data/deploy-data-avalanche.json.mjs +13 -848
  17. package/constants/deploy-data/deploy-data-base.json.cjs +1 -1
  18. package/constants/deploy-data/deploy-data-base.json.mjs +17 -852
  19. package/constants/deploy-data/deploy-data-bnbMainnet.json.cjs +1 -1
  20. package/constants/deploy-data/deploy-data-bnbMainnet.json.mjs +20 -855
  21. package/constants/deploy-data/deploy-data-ethMainnet.json.cjs +1 -1
  22. package/constants/deploy-data/deploy-data-ethMainnet.json.mjs +15 -850
  23. package/constants/deploy-data/deploy-data-localhost.json.cjs +1 -1
  24. package/constants/deploy-data/deploy-data-localhost.json.mjs +100 -935
  25. package/constants/deploy-data/deploy-data-optimism.json.cjs +1 -1
  26. package/constants/deploy-data/deploy-data-optimism.json.mjs +18 -849
  27. package/constants/deploy-data/deploy-data-polygon.json.cjs +1 -1
  28. package/constants/deploy-data/deploy-data-polygon.json.mjs +9 -844
  29. package/constants/kyc.constants.cjs +1 -1
  30. package/constants/kyc.constants.mjs +18 -30
  31. package/constants/server.constants.cjs +1 -1
  32. package/constants/server.constants.d.ts +2 -3
  33. package/constants/server.constants.mjs +6 -7
  34. package/constants/token-data/ERC20Registry.cjs +1 -1
  35. package/constants/token-data/ERC20Registry.mjs +48 -48
  36. package/constants/token-data/arbMainnetRegistry.json.cjs +1 -1
  37. package/constants/token-data/arbMainnetRegistry.json.mjs +1 -4
  38. package/constants/token-data/arbMainnetRegistryFixed.json.cjs +1 -1
  39. package/constants/token-data/arbMainnetRegistryFixed.json.mjs +1 -4
  40. package/constants/token-data/avalancheRegistry.json.cjs +1 -1
  41. package/constants/token-data/avalancheRegistry.json.mjs +1 -4
  42. package/constants/token-data/avalancheRegistryFixed.json.cjs +1 -1
  43. package/constants/token-data/avalancheRegistryFixed.json.mjs +1 -4
  44. package/constants/token-data/baseRegistry.json.cjs +1 -1
  45. package/constants/token-data/baseRegistry.json.mjs +1 -4
  46. package/constants/token-data/baseRegistryFixed.json.cjs +1 -1
  47. package/constants/token-data/baseRegistryFixed.json.mjs +1 -4
  48. package/constants/token-data/bnbMainnetRegistry.json.cjs +1 -1
  49. package/constants/token-data/bnbMainnetRegistry.json.mjs +1 -4
  50. package/constants/token-data/bnbMainnetRegistryFixed.json.cjs +1 -1
  51. package/constants/token-data/bnbMainnetRegistryFixed.json.mjs +1 -4
  52. package/constants/token-data/ethMainnetRegistry.json.cjs +1 -1
  53. package/constants/token-data/ethMainnetRegistry.json.mjs +1 -4
  54. package/constants/token-data/ethMainnetRegistryFixed.json.cjs +1 -1
  55. package/constants/token-data/ethMainnetRegistryFixed.json.mjs +1 -4
  56. package/constants/token-data/index.d.ts +15 -972
  57. package/constants/token-data/localhostRegistry.json.cjs +1 -1
  58. package/constants/token-data/localhostRegistry.json.mjs +1 -4
  59. package/constants/token-data/optimismRegistry.json.cjs +1 -1
  60. package/constants/token-data/optimismRegistry.json.mjs +1 -4
  61. package/constants/token-data/optimismRegistryFixed.json.cjs +1 -1
  62. package/constants/token-data/optimismRegistryFixed.json.mjs +1 -4
  63. package/constants/token-data/polygonRegistry.json.cjs +1 -1
  64. package/constants/token-data/polygonRegistry.json.mjs +1 -4
  65. package/constants/token-data/polygonRegistryFixed.json.cjs +1 -1
  66. package/constants/token-data/polygonRegistryFixed.json.mjs +1 -4
  67. package/data-structures/Hinkal/Hinkal.cjs +1 -1
  68. package/data-structures/Hinkal/Hinkal.d.ts +0 -2
  69. package/data-structures/Hinkal/Hinkal.mjs +32 -38
  70. package/data-structures/Hinkal/IHinkal.d.ts +0 -2
  71. package/data-structures/Hinkal/hinkalActionBeefy.cjs +1 -1
  72. package/data-structures/Hinkal/hinkalActionBeefy.mjs +20 -21
  73. package/data-structures/Hinkal/hinkalActionConvex.cjs +1 -1
  74. package/data-structures/Hinkal/hinkalActionConvex.mjs +12 -13
  75. package/data-structures/Hinkal/hinkalActionCurve.cjs +1 -1
  76. package/data-structures/Hinkal/hinkalActionCurve.mjs +14 -15
  77. package/data-structures/Hinkal/hinkalActionLidoEth.cjs +1 -1
  78. package/data-structures/Hinkal/hinkalActionLidoEth.mjs +16 -17
  79. package/data-structures/Hinkal/hinkalActionPendle.cjs +1 -1
  80. package/data-structures/Hinkal/hinkalActionPendle.d.ts +1 -1
  81. package/data-structures/Hinkal/hinkalActionPendle.mjs +23 -24
  82. package/data-structures/Hinkal/hinkalActionPendleLP.cjs +1 -1
  83. package/data-structures/Hinkal/hinkalActionPendleLP.mjs +20 -21
  84. package/data-structures/Hinkal/hinkalActionStake.cjs +1 -1
  85. package/data-structures/Hinkal/hinkalActionStake.d.ts +1 -1
  86. package/data-structures/Hinkal/hinkalActionStake.mjs +5 -6
  87. package/data-structures/Hinkal/hinkalActionVolatile.cjs +1 -1
  88. package/data-structures/Hinkal/hinkalActionVolatile.d.ts +1 -1
  89. package/data-structures/Hinkal/hinkalActionVolatile.mjs +8 -9
  90. package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
  91. package/data-structures/Hinkal/hinkalDeposit.d.ts +2 -2
  92. package/data-structures/Hinkal/hinkalDeposit.mjs +54 -93
  93. package/data-structures/Hinkal/hinkalGetZkMeProvider.cjs +1 -1
  94. package/data-structures/Hinkal/hinkalGetZkMeProvider.mjs +2 -3
  95. package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
  96. package/data-structures/Hinkal/hinkalPrivateWallet.mjs +4 -5
  97. package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
  98. package/data-structures/Hinkal/hinkalSwap.mjs +22 -23
  99. package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
  100. package/data-structures/Hinkal/hinkalWithdraw.d.ts +1 -1
  101. package/data-structures/Hinkal/hinkalWithdraw.mjs +12 -13
  102. package/data-structures/merkle-tree/MerkleTree.cjs +1 -1
  103. package/data-structures/merkle-tree/MerkleTree.d.ts +0 -2
  104. package/data-structures/merkle-tree/MerkleTree.mjs +25 -38
  105. package/data-structures/merkle-tree/index.d.ts +0 -1
  106. package/data-structures/transactions-manager/TransactionsManager.cjs +1 -1
  107. package/data-structures/transactions-manager/TransactionsManager.d.ts +5 -6
  108. package/data-structures/transactions-manager/TransactionsManager.mjs +111 -118
  109. package/error-handling/error-codes.constants.cjs +1 -1
  110. package/error-handling/error-codes.constants.d.ts +0 -4
  111. package/error-handling/error-codes.constants.mjs +2 -6
  112. package/externalABIs/BabPassport.json.cjs +1 -1
  113. package/externalABIs/BabPassport.json.mjs +3 -8
  114. package/externalABIs/BeefyRouterAbi.json.cjs +1 -1
  115. package/externalABIs/BeefyRouterAbi.json.mjs +2 -5
  116. package/externalABIs/BeefyStrategyAbi.json.cjs +1 -1
  117. package/externalABIs/BeefyStrategyAbi.json.mjs +2 -5
  118. package/externalABIs/BeefyVaultAbi.json.cjs +1 -1
  119. package/externalABIs/BeefyVaultAbi.json.mjs +2 -5
  120. package/externalABIs/BeefyZapAbi.json.cjs +1 -1
  121. package/externalABIs/BeefyZapAbi.json.mjs +2 -5
  122. package/externalABIs/BeefyZapOneInchAbi.json.cjs +1 -1
  123. package/externalABIs/BeefyZapOneInchAbi.json.mjs +2 -5
  124. package/externalABIs/ConvexBoosterAbi.json.cjs +1 -1
  125. package/externalABIs/ConvexBoosterAbi.json.mjs +2 -5
  126. package/externalABIs/ConvexBoosterAbiMainnet.json.cjs +1 -1
  127. package/externalABIs/ConvexBoosterAbiMainnet.json.mjs +2 -5
  128. package/externalABIs/ConvexRewardPoolAbi.json.cjs +1 -1
  129. package/externalABIs/ConvexRewardPoolAbi.json.mjs +2 -5
  130. package/externalABIs/CurveReadingWrapperAbi.json.cjs +1 -1
  131. package/externalABIs/CurveReadingWrapperAbi.json.mjs +2 -5
  132. package/externalABIs/CurveWrappedMainPool.json.cjs +1 -1
  133. package/externalABIs/CurveWrappedMainPool.json.mjs +2 -5
  134. package/externalABIs/CurveZap.json.cjs +1 -1
  135. package/externalABIs/CurveZap.json.mjs +2 -5
  136. package/externalABIs/CvxCrvUtilities.json.cjs +1 -1
  137. package/externalABIs/CvxCrvUtilities.json.mjs +2 -5
  138. package/externalABIs/ERC20.json.cjs +1 -1
  139. package/externalABIs/ERC20.json.mjs +3 -20
  140. package/externalABIs/GalxePassport.json.cjs +1 -1
  141. package/externalABIs/GalxePassport.json.mjs +3 -8
  142. package/externalABIs/IQuoterV2.json.cjs +1 -1
  143. package/externalABIs/IQuoterV2.json.mjs +3 -20
  144. package/externalABIs/ISwapRouter.json.cjs +1 -1
  145. package/externalABIs/ISwapRouter.json.mjs +2 -5
  146. package/externalABIs/IUniswapV3Factory.json.cjs +1 -1
  147. package/externalABIs/IUniswapV3Factory.json.mjs +3 -20
  148. package/externalABIs/IUniswapV3Pool.json.cjs +1 -1
  149. package/externalABIs/IUniswapV3Pool.json.mjs +3 -20
  150. package/externalABIs/PendleRouterAbi.json.cjs +1 -1
  151. package/externalABIs/PendleRouterAbi.json.mjs +2 -5
  152. package/externalABIs/UniswapV2PoolAbi.json.cjs +1 -1
  153. package/externalABIs/UniswapV2PoolAbi.json.mjs +3 -16
  154. package/externalABIs/index.d.ts +11 -307
  155. package/externalABIs/transactionsProver.json.cjs +1 -1
  156. package/externalABIs/transactionsProver.json.mjs +3 -20
  157. package/functions/kyc/zkMeHelper.cjs +1 -1
  158. package/functions/kyc/zkMeHelper.d.ts +1 -0
  159. package/functions/kyc/zkMeHelper.mjs +11 -8
  160. package/functions/pre-transaction/process-gas-estimates.cjs +1 -1
  161. package/functions/pre-transaction/process-gas-estimates.mjs +2 -3
  162. package/functions/private-wallet/emporium.helpers.cjs +1 -1
  163. package/functions/private-wallet/emporium.helpers.d.ts +8 -3
  164. package/functions/private-wallet/emporium.helpers.mjs +23 -11
  165. package/functions/private-wallet/index.d.ts +1 -0
  166. package/functions/private-wallet/opProducer.cjs +1 -1
  167. package/functions/private-wallet/opProducer.mjs +10 -9
  168. package/functions/private-wallet/smartContractWalletCalculator.cjs +1 -0
  169. package/functions/private-wallet/smartContractWalletCalculator.d.ts +1 -0
  170. package/functions/private-wallet/smartContractWalletCalculator.mjs +20 -0
  171. package/functions/protocols/convex.protocols.cjs +1 -1
  172. package/functions/protocols/convex.protocols.mjs +2 -3
  173. package/functions/protocols/pendle.helpers.cjs +1 -1
  174. package/functions/protocols/pendle.helpers.mjs +13 -14
  175. package/functions/snarkjs/constant.cjs +1 -1
  176. package/functions/snarkjs/constant.d.ts +0 -1
  177. package/functions/snarkjs/constant.mjs +5 -6
  178. package/functions/snarkjs/constructEmporiumProof.cjs +1 -1
  179. package/functions/snarkjs/constructEmporiumProof.d.ts +1 -1
  180. package/functions/snarkjs/constructEmporiumProof.mjs +31 -31
  181. package/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
  182. package/functions/snarkjs/constructGeneralZkProof.d.ts +1 -1
  183. package/functions/snarkjs/constructGeneralZkProof.mjs +75 -76
  184. package/functions/snarkjs/generateZkProof.cjs +1 -1
  185. package/functions/snarkjs/generateZkProof.d.ts +1 -1
  186. package/functions/snarkjs/generateZkProof.mjs +15 -4
  187. package/functions/utils/axelar.utils.cjs +1 -1
  188. package/functions/utils/axelar.utils.mjs +2 -3
  189. package/functions/utils/cacheDevice.utils.cjs +1 -1
  190. package/functions/utils/cacheDevice.utils.mjs +8 -9
  191. package/functions/utils/erc20tokenFunctions.cjs +1 -1
  192. package/functions/utils/erc20tokenFunctions.mjs +7 -8
  193. package/functions/utils/evmNetworkFunctions.cjs +1 -1
  194. package/functions/utils/evmNetworkFunctions.mjs +3 -4
  195. package/functions/utils/string.utils.cjs +1 -1
  196. package/functions/utils/string.utils.d.ts +1 -0
  197. package/functions/utils/string.utils.mjs +16 -6
  198. package/functions/utils/userAgent.cjs +1 -1
  199. package/functions/utils/userAgent.mjs +8 -8
  200. package/functions/web3/functionCalls/accessTokenCalls.cjs +1 -1
  201. package/functions/web3/functionCalls/accessTokenCalls.mjs +8 -8
  202. package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
  203. package/functions/web3/functionCalls/transactCallDirect.d.ts +1 -1
  204. package/functions/web3/functionCalls/transactCallDirect.mjs +29 -43
  205. package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
  206. package/functions/web3/functionCalls/transactCallRelayer.mjs +8 -10
  207. package/functions/web3/odosAPI.cjs +1 -1
  208. package/functions/web3/odosAPI.d.ts +2 -1
  209. package/functions/web3/odosAPI.mjs +18 -19
  210. package/functions/web3/oneInchAPI.cjs +1 -1
  211. package/functions/web3/oneInchAPI.d.ts +2 -1
  212. package/functions/web3/oneInchAPI.mjs +15 -17
  213. package/functions/web3/uniswapAPI.cjs +1 -1
  214. package/functions/web3/uniswapAPI.d.ts +4 -4
  215. package/functions/web3/uniswapAPI.mjs +43 -54
  216. package/index.cjs +1 -1
  217. package/index.mjs +641 -617
  218. package/package.json +2 -3
  219. package/providers/EthersProviderAdapter.cjs +1 -1
  220. package/providers/EthersProviderAdapter.d.ts +0 -1
  221. package/providers/EthersProviderAdapter.mjs +37 -26
  222. package/providers/WagmiProviderAdapter.cjs +1 -1
  223. package/providers/WagmiProviderAdapter.d.ts +0 -1
  224. package/providers/WagmiProviderAdapter.mjs +56 -45
  225. package/providers/prepareEthersHinkal.cjs +1 -1
  226. package/providers/prepareEthersHinkal.mjs +2 -4
  227. package/providers/prepareWagmiHinkal.cjs +1 -1
  228. package/providers/prepareWagmiHinkal.mjs +2 -4
  229. package/types/ethereum-network.types.cjs +1 -1
  230. package/types/ethereum-network.types.d.ts +61 -62
  231. package/types/ethereum-network.types.mjs +1 -1
  232. package/types/hinkal.types.d.ts +0 -4
  233. package/types/kyc.types.cjs +1 -1
  234. package/types/kyc.types.d.ts +1 -1
  235. package/types/kyc.types.mjs +1 -1
  236. package/types/rewards.types.d.ts +0 -5
  237. package/types/time.types.cjs +1 -1
  238. package/types/time.types.mjs +1 -1
  239. package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
  240. package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
  241. package/constants/token-data/index.cjs +0 -1
  242. package/constants/token-data/index.mjs +0 -34
  243. package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.cjs +0 -1
  244. package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.d.ts +0 -3
  245. package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.mjs +0 -9
  246. package/externalABIs/index.cjs +0 -1
  247. package/externalABIs/index.mjs +0 -23
  248. package/functions/snarkjs/generateZkProofEnclave.cjs +0 -1
  249. package/functions/snarkjs/generateZkProofEnclave.d.ts +0 -5
  250. package/functions/snarkjs/generateZkProofEnclave.mjs +0 -33
  251. package/functions/snarkjs/generateZkProofSelf.cjs +0 -1
  252. package/functions/snarkjs/generateZkProofSelf.d.ts +0 -5
  253. package/functions/snarkjs/generateZkProofSelf.mjs +0 -17
  254. package/functions/web3/getContractMetadata.cjs +0 -1
  255. package/functions/web3/getContractMetadata.d.ts +0 -5
  256. package/functions/web3/getContractMetadata.mjs +0 -30
  257. package/types/remote-proof.types.d.ts +0 -15
@@ -1,14 +1,24 @@
1
- function e(t) {
1
+ function s(t) {
2
2
  return t?.toLowerCase().split(" ").map((r) => r.charAt(0).toUpperCase() + r.substring(1)).join(" ");
3
3
  }
4
- function n(t) {
4
+ function u(t) {
5
5
  return t.charAt(0).toUpperCase() + t.slice(1);
6
6
  }
7
- function i(t) {
7
+ function c(t) {
8
8
  return !t || t === null || Array.isArray(t) && t.length === 0 ? !0 : Object.keys(t).length === 0 && t.constructor === Object;
9
9
  }
10
+ const o = (t) => {
11
+ t.startsWith("0x") && (t = t.slice(2));
12
+ const r = [];
13
+ for (let e = 0; e < t.length; e += 2) {
14
+ const n = parseInt(t.slice(e, e + 2), 16);
15
+ r.push(n);
16
+ }
17
+ return new TextDecoder("utf-8").decode(new Uint8Array(r));
18
+ };
10
19
  export {
11
- n as capitalizeFirstLetter,
12
- i as isNullOrEmpty,
13
- e as toTitleCase
20
+ u as capitalizeFirstLetter,
21
+ o as hexToUtf8,
22
+ c as isNullOrEmpty,
23
+ s as toTitleCase
14
24
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("ua-parser-js"),a=new s.UAParser,o=17,n=()=>{const{name:e,version:r}=a.getBrowser(),t=parseInt(r?.split(".")[0]??"0",10);return!(e==="Safari"&&t&&o>t)},l={mpcVault:"MPCVault - Multisig Wallet",utila:"UtilaWallet"},u=e=>{const r=e?.session?.peer?.metadata?.name;return!Object.values(l).includes(r)};exports.browserSupported=n;exports.walletSupported=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("ua-parser-js"),a=new s.UAParser,o=["17"],n=()=>{const{name:e,version:r}=a.getBrowser(),t=r?.substring(0,2);return!(e==="Safari"&&t&&!o.includes(t))},u={mpcVault:"MPCVault - Multisig Wallet",utila:"UtilaWallet"},l=e=>{const r=e?.session?.peer?.metadata?.name;return!Object.values(u).includes(r)};exports.browserSupported=n;exports.walletSupported=l;
@@ -1,15 +1,15 @@
1
1
  import { UAParser as s } from "ua-parser-js";
2
- const a = new s(), n = 17, i = () => {
3
- const { name: e, version: t } = a.getBrowser(), r = parseInt(t?.split(".")[0] ?? "0", 10);
4
- return !(e === "Safari" && r && n > r);
2
+ const a = new s(), n = ["17"], u = () => {
3
+ const { name: e, version: r } = a.getBrowser(), t = r?.substring(0, 2);
4
+ return !(e === "Safari" && t && !n.includes(t));
5
5
  }, o = {
6
6
  mpcVault: "MPCVault - Multisig Wallet",
7
7
  utila: "UtilaWallet"
8
- }, u = (e) => {
9
- const t = e?.session?.peer?.metadata?.name;
10
- return !Object.values(o).includes(t);
8
+ }, i = (e) => {
9
+ const r = e?.session?.peer?.metadata?.name;
10
+ return !Object.values(o).includes(r);
11
11
  };
12
12
  export {
13
- i as browserSupported,
14
- u as walletSupported
13
+ u as browserSupported,
14
+ i as walletSupported
15
15
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../../constants/chains.constants.cjs");require("../../../types/circom-data.types.cjs");const r=require("../../../types/ethereum-network.types.cjs");require("../../../types/transactions.types.cjs");require("../../../types/curve.types.cjs");const T=require("../etherFunctions.cjs"),g=async e=>(await e.getContractWithFetcher(r.ContractType.CrossChainAccessTokenManagerContract).functions.hasToken(e.userKeys.getAccessKey()))[0],y=async(e,n)=>{const t=e.getContractWithSigner(r.ContractType.CrossChainAccessTokenManagerContract),s=i.networkRegistry[e.getCurrentChainId()].accessTokenMintingFee??"0",c={value:T.ethToWei(s)};return await t.addToken(n,c)},d=async(e,n,t)=>{const s=e.getContractWithSigner(r.ContractType.CrossChainAccessTokenContract),a=i.networkRegistry[e.getCurrentChainId()].accessTokenMintingFee??"0",c=T.ethToWei(a),o=t.reduce((k,h)=>k+h.messageFee,0n),u={chains:t,totalMessageFees:o},C={value:c+o};return await s.addTokenCrossChain(n,u,C)};exports.checkHinkalAccessToken=g;exports.mintAccessToken=y;exports.mintTokenCrossChain=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../../constants/chains.constants.cjs");require("../../../types/circom-data.types.cjs");const r=require("../../../types/ethereum-network.types.cjs");require("../../../types/transactions.types.cjs");require("../../../types/curve.types.cjs");const T=require("../etherFunctions.cjs"),g=async e=>(await e.getContractWithFetcher(r.ContractType.CrossChainAccessTokenContract).functions.hasToken(e.userKeys.getAccessKey()))[0],y=async(e,n)=>{const t=e.getContractWithSigner(r.ContractType.CrossChainAccessTokenContract),s=i.networkRegistry[e.getCurrentChainId()].accessTokenMintingFee??"0",c={value:T.ethToWei(s)};return await t.addToken(n,c)},d=async(e,n,t)=>{const s=e.getContractWithSigner(r.ContractType.CrossChainAccessTokenContract),a=i.networkRegistry[e.getCurrentChainId()].accessTokenMintingFee??"0",c=T.ethToWei(a),o=t.reduce((k,h)=>k+h.messageFee,0n),u={chains:t,totalMessageFees:o},C={value:c+o};return await s.addTokenCrossChain(n,u,C)};exports.checkHinkalAccessToken=g;exports.mintAccessToken=y;exports.mintTokenCrossChain=d;
@@ -1,16 +1,16 @@
1
1
  import { networkRegistry as i } from "../../../constants/chains.constants.mjs";
2
2
  import "../../../types/circom-data.types.mjs";
3
- import { ContractType as a } from "../../../types/ethereum-network.types.mjs";
3
+ import { ContractType as r } from "../../../types/ethereum-network.types.mjs";
4
4
  import "../../../types/transactions.types.mjs";
5
5
  import "../../../types/curve.types.mjs";
6
6
  import { ethToWei as C } from "../etherFunctions.mjs";
7
- const y = async (e) => (await e.getContractWithFetcher(a.CrossChainAccessTokenManagerContract).functions.hasToken(e.userKeys.getAccessKey()))[0], W = async (e, n) => {
8
- const t = e.getContractWithSigner(a.CrossChainAccessTokenManagerContract), s = i[e.getCurrentChainId()].accessTokenMintingFee ?? "0", o = {
9
- value: C(s)
7
+ const y = async (e) => (await e.getContractWithFetcher(r.CrossChainAccessTokenContract).functions.hasToken(e.userKeys.getAccessKey()))[0], W = async (e, s) => {
8
+ const t = e.getContractWithSigner(r.CrossChainAccessTokenContract), n = i[e.getCurrentChainId()].accessTokenMintingFee ?? "0", o = {
9
+ value: C(n)
10
10
  };
11
- return await t.addToken(n, o);
12
- }, A = async (e, n, t) => {
13
- const s = e.getContractWithSigner(a.CrossChainAccessTokenContract), r = i[e.getCurrentChainId()].accessTokenMintingFee ?? "0", o = C(r), c = t.reduce(
11
+ return await t.addToken(s, o);
12
+ }, A = async (e, s, t) => {
13
+ const n = e.getContractWithSigner(r.CrossChainAccessTokenContract), a = i[e.getCurrentChainId()].accessTokenMintingFee ?? "0", o = C(a), c = t.reduce(
14
14
  (k, g) => k + g.messageFee,
15
15
  0n
16
16
  ), T = {
@@ -19,7 +19,7 @@ const y = async (e) => (await e.getContractWithFetcher(a.CrossChainAccessTokenMa
19
19
  }, u = {
20
20
  value: o + c
21
21
  };
22
- return await s.addTokenCrossChain(n, T, u);
22
+ return await n.addTokenCrossChain(s, T, u);
23
23
  };
24
24
  export {
25
25
  y as checkHinkalAccessToken,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("../../../constants/protocol.constants.cjs"),I=require("../../../types/ethereum-network.types.cjs"),S=require("./approveToken.cjs"),f=require("../../utils/time.utils.cjs");require("../../../constants/chains.constants.cjs");require("../../../constants/vite.constants.cjs");require("axios");require("../../../constants/coingecko.constants.cjs");const b=require("../../../API/API.cjs");require("ethers");require("../../../types/curve.types.cjs");require("../../../constants/token-data/index.cjs");require("../../../constants/contracts.constants.cjs");require("../../../constants/kyc.constants.cjs");require("../../../constants/axelar.constants.cjs");require("../../../constants/rewards.constants.cjs");require("../../../constants/reorg-depths.constants.cjs");const x=async(e,t,o,i,A,y,C,T,n=!0)=>{const p=e.getCurrentChainId(),a=e.getContractWithSigner(I.ContractType.HinkalContract),u=await e.getEthereumAddress(),v=C??a,d=T??a,h=e.userKeys.getAccessKey(),g=n?"transact":"addTokenAndTransact";t>0n&&o.erc20TokenAddress!==m.zeroAddress&&await S.approveTokenToHinkal(e,v,t,o);const q={value:t>0n&&o.erc20TokenAddress===m.zeroAddress?BigInt(t).toString():void 0};let r;const l=[i[0],i[1],i[2],y,A,{...q,from:u}];let s=[];if(n)s=l;else{const{signatureData:c}=await b.API.getAccessTokenSignature(p,u,h);s=[c,...l]}try{r=(await d.estimateGas[g](...s)).toNumber()}catch(c){console.log("hinkalDeposit: gas estimation error",{err:c})}const w=r&&r>=0?Math.ceil(r*12/10):void 0;return q.gasLimit=w,await f.waitLittle(),await d[g](...s)};exports.transactCallDirect=x;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../../../constants/protocol.constants.cjs"),T=require("../../../types/ethereum-network.types.cjs"),A=require("./approveToken.cjs"),q=require("../../utils/time.utils.cjs"),S=async(s,e,o,t,i,n,l,h)=>{const a=s.getContractWithSigner(T.ContractType.HinkalContract),p=await s.getEthereumAddress(),v=l??a,d=h??a,g="transact";e>0n&&o.erc20TokenAddress!==u.zeroAddress&&await A.approveTokenToHinkal(s,v,e,o);const c={value:e>0n&&o.erc20TokenAddress===u.zeroAddress?BigInt(e).toString():void 0};let r;try{r=(await d.estimateGas[g](t[0],t[1],t[2],n,i,{...c,from:p})).toNumber()}catch(y){console.log("hinkalDeposit: gas estimation error: ",{err:y})}const m=r&&r>=0?Math.ceil(r*12/10):void 0;return c.gasLimit=m,await q.waitLittle(),await d[g](t[0],t[1],t[2],n,i,c)};exports.transactCallDirect=S;
@@ -3,4 +3,4 @@ import { IHinkal } from '../../../data-structures/Hinkal/IHinkal';
3
3
  import { CircomDataType, DimDataType } from '../../../types/circom-data.types';
4
4
  import { ERC20Token } from '../../../types/token.types';
5
5
  import { NewZkCallDataType } from '../../../types/snark.types';
6
- export declare const transactCallDirect: (hinkal: IHinkal, amount: bigint, tokenToApprove: ERC20Token, newZkCallData: NewZkCallDataType, circomData: CircomDataType, dimData: DimDataType, contractApproval?: ethers.Contract, contractTransaction?: ethers.Contract, hasAccessToken?: boolean) => Promise<any>;
6
+ export declare const transactCallDirect: (hinkal: IHinkal, amount: bigint, tokenToApprove: ERC20Token, newZkCallData: NewZkCallDataType, circomData: CircomDataType, dimData: DimDataType, contractApporval?: ethers.Contract, contractTransaction?: ethers.Contract) => Promise<ethers.ContractTransaction>;
@@ -1,50 +1,36 @@
1
- import { zeroAddress as f } from "../../../constants/protocol.constants.mjs";
2
- import { ContractType as x } from "../../../types/ethereum-network.types.mjs";
3
- import { approveTokenToHinkal as I } from "./approveToken.mjs";
4
- import { waitLittle as K } from "../../utils/time.utils.mjs";
5
- import "../../../constants/chains.constants.mjs";
6
- import "../../../constants/vite.constants.mjs";
7
- import "axios";
8
- import "../../../constants/coingecko.constants.mjs";
9
- import { API as S } from "../../../API/API.mjs";
10
- import "ethers";
11
- import "../../../types/curve.types.mjs";
12
- import "../../../constants/token-data/index.mjs";
13
- import "../../../constants/contracts.constants.mjs";
14
- import "../../../constants/kyc.constants.mjs";
15
- import "../../../constants/axelar.constants.mjs";
16
- import "../../../constants/rewards.constants.mjs";
17
- import "../../../constants/reorg-depths.constants.mjs";
18
- const Q = async (t, r, s, i, u, A, C, y, c = !0) => {
19
- const T = t.getCurrentChainId(), n = t.getContractWithSigner(x.HinkalContract), m = await t.getEthereumAddress(), h = C ?? n, d = y ?? n, v = t.userKeys.getAccessKey(), p = c ? "transact" : "addTokenAndTransact";
20
- r > 0n && s.erc20TokenAddress !== f && await I(t, h, r, s);
21
- const g = {
22
- value: r > 0n && s.erc20TokenAddress === f ? BigInt(r).toString() : void 0
1
+ import { zeroAddress as g } from "../../../constants/protocol.constants.mjs";
2
+ import { ContractType as T } from "../../../types/ethereum-network.types.mjs";
3
+ import { approveTokenToHinkal as y } from "./approveToken.mjs";
4
+ import { waitLittle as u } from "../../utils/time.utils.mjs";
5
+ const S = async (s, r, e, t, c, n, p, f) => {
6
+ const a = s.getContractWithSigner(T.HinkalContract), h = await s.getEthereumAddress(), v = p ?? a, d = f ?? a, m = "transact";
7
+ r > 0n && e.erc20TokenAddress !== g && await y(s, v, r, e);
8
+ const i = {
9
+ value: r > 0n && e.erc20TokenAddress === g ? BigInt(r).toString() : void 0
23
10
  };
24
11
  let o;
25
- const l = [
26
- i[0],
27
- i[1],
28
- i[2],
29
- A,
30
- u,
31
- { ...g, from: m }
32
- ];
33
- let e = [];
34
- if (c)
35
- e = l;
36
- else {
37
- const { signatureData: a } = await S.getAccessTokenSignature(T, m, v);
38
- e = [a, ...l];
39
- }
40
12
  try {
41
- o = (await d.estimateGas[p](...e)).toNumber();
42
- } catch (a) {
43
- console.log("hinkalDeposit: gas estimation error", { err: a });
13
+ o = (await d.estimateGas[m](
14
+ t[0],
15
+ t[1],
16
+ t[2],
17
+ n,
18
+ c,
19
+ { ...i, from: h }
20
+ )).toNumber();
21
+ } catch (A) {
22
+ console.log("hinkalDeposit: gas estimation error: ", { err: A });
44
23
  }
45
- const w = o && o >= 0 ? Math.ceil(o * 12 / 10) : void 0;
46
- return g.gasLimit = w, await K(), await d[p](...e);
24
+ const x = o && o >= 0 ? Math.ceil(o * 12 / 10) : void 0;
25
+ return i.gasLimit = x, await u(), await d[m](
26
+ t[0],
27
+ t[1],
28
+ t[2],
29
+ n,
30
+ c,
31
+ i
32
+ );
47
33
  };
48
34
  export {
49
- Q as transactCallDirect
35
+ S as transactCallDirect
50
36
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../../API/callRelayer.cjs");require("../../../constants/chains.constants.cjs");require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("../../../constants/vite.constants.cjs");const u=require("../../snarkjs/common.snarkjs.cjs");require("../../../types/circom-data.types.cjs");require("../../utils/external-action.utils.cjs");require("node-forge");require("axios");const n=async(a,r,s,c,t)=>{const i=u.serializeCircomData(c),e=await o.callRelayerTransactAPI(a,{a:r[0],b:r[1],c:r[2],dimData:s,circomData:i,withPrivateMempool:t});if(e.status==="success")return e.message;throw new Error(e.error)};exports.transactCallRelayer=n;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../../API/callRelayer.cjs");require("../../../constants/chains.constants.cjs");require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("../../../constants/vite.constants.cjs");const n=require("../../snarkjs/common.snarkjs.cjs");require("../../../types/circom-data.types.cjs");require("../../utils/external-action.utils.cjs");const u=async(a,r,s,c,t)=>{const i=n.serializeCircomData(c),e=await o.callRelayerTransactAPI(a,{a:r[0],b:r[1],c:r[2],dimData:s,circomData:i,withPrivateMempool:t});if(e.status==="success")return e.message;throw new Error(e.error)};exports.transactCallRelayer=u;
@@ -1,27 +1,25 @@
1
- import { callRelayerTransactAPI as c } from "../../../API/callRelayer.mjs";
1
+ import { callRelayerTransactAPI as e } from "../../../API/callRelayer.mjs";
2
2
  import "../../../constants/chains.constants.mjs";
3
3
  import "ethers";
4
4
  import "circomlibjs-hinkal-fork";
5
5
  import "libsodium-wrappers";
6
6
  import "../../../constants/vite.constants.mjs";
7
- import { serializeCircomData as e } from "../../snarkjs/common.snarkjs.mjs";
7
+ import { serializeCircomData as m } from "../../snarkjs/common.snarkjs.mjs";
8
8
  import "../../../types/circom-data.types.mjs";
9
9
  import "../../utils/external-action.utils.mjs";
10
- import "node-forge";
11
- import "axios";
12
- const x = async (t, r, i, m, s) => {
13
- const a = e(m), o = await c(t, {
10
+ const h = async (t, r, s, a, i) => {
11
+ const c = m(a), o = await e(t, {
14
12
  a: r[0],
15
13
  b: r[1],
16
14
  c: r[2],
17
- dimData: i,
18
- circomData: a,
19
- withPrivateMempool: s
15
+ dimData: s,
16
+ circomData: c,
17
+ withPrivateMempool: i
20
18
  });
21
19
  if (o.status === "success")
22
20
  return o.message;
23
21
  throw new Error(o.error);
24
22
  };
25
23
  export {
26
- x as transactCallRelayer
24
+ h as transactCallRelayer
27
25
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../API/callOdosAPI.cjs");require("../../constants/token-data/index.cjs");const n=require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const a=require("../../constants/protocol.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const d=require("../../error-handling/error-codes.constants.cjs"),q=require("./etherFunctions.cjs");require("axios");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const l=async(r,e,t,u)=>{try{const o={chainId:r!==31337?r:n.localhostNetwork,inputTokens:[{tokenAddress:e?.wrappedErc20TokenAddress??e.erc20TokenAddress,amount:q.getAmountInWei(e,u).toString()}],outputTokens:[{tokenAddress:t?.wrappedErc20TokenAddress??t.erc20TokenAddress,proportion:1}],userAddr:n.networkRegistry[r].contractData.odosExternalActionInstanceAddress||a.zeroAddress,slippageLimitPercent:10,disableRFQs:!0},{odosResponse:s,status:i}=await c.callOdosAPI(r,o);if(i!=="success")throw Error("Odos API Fetch Error");return{outSwapAmountValue:BigInt(s.outputTokens[0].amount),odosDataValue:s.transaction.data}}catch(o){throw console.log({error:o}),Error(d.transactionErrorCodes.NO_ODOS_PRICE)}};exports.getOdosPrice=l;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../API/callOdosAPI.cjs"),n=require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const d=require("../../constants/protocol.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const a=require("../../error-handling/error-codes.constants.cjs"),q=require("./etherFunctions.cjs");require("axios");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const A=async(r,e,o,u)=>{try{const t={chainId:r.getCurrentChainId()!==31337?r.getCurrentChainId():n.localhostNetwork,inputTokens:[{tokenAddress:e?.wrappedErc20TokenAddress??e.erc20TokenAddress,amount:q.getAmountInWei(e,u).toString()}],outputTokens:[{tokenAddress:o?.wrappedErc20TokenAddress??o.erc20TokenAddress,proportion:1}],userAddr:n.networkRegistry[r.getCurrentChainId()].contractData.odosExternalActionInstanceAddress||d.zeroAddress,slippageLimitPercent:10,disableRFQs:!0},{odosResponse:s,status:i}=await c.callOdosAPI(r.getCurrentChainId(),t);if(i!=="success")throw Error("Odos API Fetch Error");return{outSwapAmountValue:BigInt(s.outputTokens[0].amount),odosDataValue:s.transaction.data}}catch(t){throw console.log({error:t}),Error(a.transactionErrorCodes.NO_ODOS_PRICE)}};exports.getOdosPrice=A;
@@ -1,5 +1,6 @@
1
+ import { IHinkal } from '../../data-structures';
1
2
  import { ERC20Token } from '../../types';
2
- export declare const getOdosPrice: (chainId: number, inSwapToken: ERC20Token, outSwapToken: ERC20Token, inSwapAmount: string) => Promise<{
3
+ export declare const getOdosPrice: (hinkal: IHinkal, inSwapToken: ERC20Token, outSwapToken: ERC20Token, inSwapAmount: string) => Promise<{
3
4
  outSwapAmountValue: bigint;
4
5
  odosDataValue: string;
5
6
  }>;
@@ -1,6 +1,5 @@
1
- import { callOdosAPI as m } from "../../API/callOdosAPI.mjs";
2
- import "../../constants/token-data/index.mjs";
3
- import { localhostNetwork as n, networkRegistry as d } from "../../constants/chains.constants.mjs";
1
+ import { callOdosAPI as d } from "../../API/callOdosAPI.mjs";
2
+ import { localhostNetwork as p, networkRegistry as m } from "../../constants/chains.constants.mjs";
4
3
  import "../../constants/vite.constants.mjs";
5
4
  import "../../constants/contracts.constants.mjs";
6
5
  import "../../constants/kyc.constants.mjs";
@@ -20,40 +19,40 @@ import "circomlibjs-hinkal-fork";
20
19
  import "libsodium-wrappers";
21
20
  import "process";
22
21
  import "buffer";
23
- const z = async (r, o, s, i) => {
22
+ const b = async (r, t, e, i) => {
24
23
  try {
25
- const t = {
26
- chainId: r !== 31337 ? r : n,
24
+ const o = {
25
+ chainId: r.getCurrentChainId() !== 31337 ? r.getCurrentChainId() : p,
27
26
  inputTokens: [
28
27
  {
29
- tokenAddress: o?.wrappedErc20TokenAddress ?? o.erc20TokenAddress,
30
- amount: u(o, i).toString()
28
+ tokenAddress: t?.wrappedErc20TokenAddress ?? t.erc20TokenAddress,
29
+ amount: u(t, i).toString()
31
30
  }
32
31
  ],
33
32
  outputTokens: [
34
33
  {
35
- tokenAddress: s?.wrappedErc20TokenAddress ?? s.erc20TokenAddress,
34
+ tokenAddress: e?.wrappedErc20TokenAddress ?? e.erc20TokenAddress,
36
35
  proportion: 1
37
36
  }
38
37
  ],
39
- userAddr: d[r].contractData.odosExternalActionInstanceAddress || a,
38
+ userAddr: m[r.getCurrentChainId()].contractData.odosExternalActionInstanceAddress || a,
40
39
  slippageLimitPercent: 10,
41
40
  disableRFQs: !0
42
41
  // sometimes swap fails because of RFQs
43
- }, { odosResponse: e, status: p } = await m(
44
- r,
45
- t
42
+ }, { odosResponse: s, status: n } = await d(
43
+ r.getCurrentChainId(),
44
+ o
46
45
  );
47
- if (p !== "success")
46
+ if (n !== "success")
48
47
  throw Error("Odos API Fetch Error");
49
48
  return {
50
- outSwapAmountValue: BigInt(e.outputTokens[0].amount),
51
- odosDataValue: e.transaction.data
49
+ outSwapAmountValue: BigInt(s.outputTokens[0].amount),
50
+ odosDataValue: s.transaction.data
52
51
  };
53
- } catch (t) {
54
- throw console.log({ error: t }), Error(c.NO_ODOS_PRICE);
52
+ } catch (o) {
53
+ throw console.log({ error: o }), Error(c.NO_ODOS_PRICE);
55
54
  }
56
55
  };
57
56
  export {
58
- z as getOdosPrice
57
+ b as getOdosPrice
59
58
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../API/callOneInchAPI.cjs");require("../../constants/token-data/index.cjs");require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const e=require("../../constants/protocol.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const u=require("../../error-handling/error-codes.constants.cjs"),a=require("./etherFunctions.cjs");require("axios");require("../../types/circom-data.types.cjs");const d=require("../../types/ethereum-network.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const q=require("./getContractMetadata.cjs"),l=async(s,t,n,c)=>{try{const o={fromTokenAddress:t.erc20TokenAddress!==e.zeroAddress?t.erc20TokenAddress:e.oneInchZeroAddress,toTokenAddress:n.erc20TokenAddress!==e.zeroAddress?n.erc20TokenAddress:e.oneInchZeroAddress,fromAddress:e.zeroAddress,destReceiver:q.getContractMetadata(d.ContractType.OneInchExternalActionContract,s).address,amount:a.getAmountInWei(t,c),slippage:10,disableEstimate:!0,allowPartialFill:!1},r=await i.callOneInchAPI(s,o);if(!r||!r.tx)throw Error("OneInch API price fetch error");return{outSwapAmountValue:BigInt(r.toAmount),oneInchDataValue:r.tx.data}}catch(o){throw console.log({error:o}),Error(u.transactionErrorCodes.NO_ONEINCH_PRICE)}};exports.getOneInchPrice=l;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../API/callOneInchAPI.cjs");require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const e=require("../../constants/protocol.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const u=require("../../error-handling/error-codes.constants.cjs"),d=require("./etherFunctions.cjs");require("axios");require("../../types/circom-data.types.cjs");const a=require("../../types/ethereum-network.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const q=async(s,t,n,c)=>{try{const o={fromTokenAddress:t.erc20TokenAddress!==e.zeroAddress?t.erc20TokenAddress:e.oneInchZeroAddress,toTokenAddress:n.erc20TokenAddress!==e.zeroAddress?n.erc20TokenAddress:e.oneInchZeroAddress,fromAddress:e.zeroAddress,destReceiver:s.getContractMetadata(a.ContractType.OneInchExternalActionContract).address,amount:d.getAmountInWei(t,c),slippage:10,disableEstimate:!0,allowPartialFill:!1},r=await i.callOneInchAPI(s.getCurrentChainId(),o);if(!r||!r.tx)throw Error("OneInch API price fetch error");return{outSwapAmountValue:BigInt(r.toAmount),oneInchDataValue:r.tx.data}}catch(o){throw console.log({error:o}),Error(u.transactionErrorCodes.NO_ONEINCH_PRICE)}};exports.getOneInchPrice=q;
@@ -1,5 +1,6 @@
1
+ import { IHinkal } from '../../data-structures/Hinkal/IHinkal';
1
2
  import { ERC20Token } from '../../types';
2
- export declare const getOneInchPrice: (chainId: number, inSwapToken: ERC20Token, outSwapToken: ERC20Token, inSwapAmount: string) => Promise<{
3
+ export declare const getOneInchPrice: (hinkal: IHinkal, inSwapToken: ERC20Token, outSwapToken: ERC20Token, inSwapAmount: string) => Promise<{
3
4
  outSwapAmountValue: bigint;
4
5
  oneInchDataValue: string;
5
6
  }>;
@@ -1,19 +1,18 @@
1
- import { callOneInchAPI as p } from "../../API/callOneInchAPI.mjs";
2
- import "../../constants/token-data/index.mjs";
1
+ import { callOneInchAPI as a } from "../../API/callOneInchAPI.mjs";
3
2
  import "../../constants/chains.constants.mjs";
4
3
  import "../../constants/vite.constants.mjs";
5
4
  import "../../constants/contracts.constants.mjs";
6
5
  import "../../constants/kyc.constants.mjs";
7
- import { zeroAddress as e, oneInchZeroAddress as s } from "../../constants/protocol.constants.mjs";
6
+ import { zeroAddress as e, oneInchZeroAddress as m } from "../../constants/protocol.constants.mjs";
8
7
  import "../../constants/coingecko.constants.mjs";
9
8
  import "../../constants/axelar.constants.mjs";
10
9
  import "../../constants/rewards.constants.mjs";
11
10
  import "../../constants/reorg-depths.constants.mjs";
12
- import { transactionErrorCodes as a } from "../../error-handling/error-codes.constants.mjs";
13
- import { getAmountInWei as c } from "./etherFunctions.mjs";
11
+ import { transactionErrorCodes as c } from "../../error-handling/error-codes.constants.mjs";
12
+ import { getAmountInWei as d } from "./etherFunctions.mjs";
14
13
  import "axios";
15
14
  import "../../types/circom-data.types.mjs";
16
- import { ContractType as d } from "../../types/ethereum-network.types.mjs";
15
+ import { ContractType as p } from "../../types/ethereum-network.types.mjs";
17
16
  import "../../types/transactions.types.mjs";
18
17
  import "../../types/curve.types.mjs";
19
18
  import "ethers";
@@ -21,16 +20,15 @@ import "circomlibjs-hinkal-fork";
21
20
  import "libsodium-wrappers";
22
21
  import "process";
23
22
  import "buffer";
24
- import { getContractMetadata as l } from "./getContractMetadata.mjs";
25
- const D = async (m, o, i, n) => {
23
+ const v = async (s, t, i, n) => {
26
24
  try {
27
- const t = {
28
- fromTokenAddress: o.erc20TokenAddress !== e ? o.erc20TokenAddress : s,
29
- toTokenAddress: i.erc20TokenAddress !== e ? i.erc20TokenAddress : s,
25
+ const o = {
26
+ fromTokenAddress: t.erc20TokenAddress !== e ? t.erc20TokenAddress : m,
27
+ toTokenAddress: i.erc20TokenAddress !== e ? i.erc20TokenAddress : m,
30
28
  fromAddress: e,
31
29
  // we user zero address here because this paramater is not relevant to us, only destReceiver is
32
- destReceiver: l(d.OneInchExternalActionContract, m).address,
33
- amount: c(o, n),
30
+ destReceiver: s.getContractMetadata(p.OneInchExternalActionContract).address,
31
+ amount: d(t, n),
34
32
  slippage: 10,
35
33
  disableEstimate: !0,
36
34
  // disable gas estimation, we don't need it
@@ -39,7 +37,7 @@ const D = async (m, o, i, n) => {
39
37
  // and returning leftover tokens to fromAddress
40
38
  // this is not what we want
41
39
  allowPartialFill: !1
42
- }, r = await p(m, t);
40
+ }, r = await a(s.getCurrentChainId(), o);
43
41
  if (!r || !r.tx)
44
42
  throw Error("OneInch API price fetch error");
45
43
  return {
@@ -47,10 +45,10 @@ const D = async (m, o, i, n) => {
47
45
  oneInchDataValue: r.tx.data
48
46
  // calldata to use
49
47
  };
50
- } catch (t) {
51
- throw console.log({ error: t }), Error(a.NO_ONEINCH_PRICE);
48
+ } catch (o) {
49
+ throw console.log({ error: o }), Error(c.NO_ONEINCH_PRICE);
52
50
  }
53
51
  };
54
52
  export {
55
- D as getOneInchPrice
53
+ v as getOneInchPrice
56
54
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("ethers");require("../../constants/token-data/index.cjs");const d=require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const C=require("../../constants/protocol.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const l=require("../../error-handling/error-codes.constants.cjs"),P=require("./etherFunctions.cjs");require("axios");require("../../types/circom-data.types.cjs");const u=require("../../types/ethereum-network.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const h=require("../../error-handling/logError.cjs"),w=async(s,t,c,r)=>{const o=(await Promise.all([100,500,3e3,1e4].map(async e=>({poolAddress:await t.getPool(c,r,e),fee:e})))).filter(({poolAddress:e})=>e!==C.zeroAddress),n=await Promise.all(o.map(async e=>({poolAddress:e.poolAddress,fee:e.fee,token1Balance:(await s.balanceOf(e.poolAddress)).toBigInt()}))),i=n.map(e=>e.token1Balance).reduce((e,p)=>p>=e?p:e,0n);if(i===0n)throw new Error(l.transactionErrorCodes.UNISWAP_NOT_ENOUGH_LIQUIDITY);return n.find(e=>e.token1Balance===i)},q=async(s,t,c,r,o,n)=>{try{if(!d.networkRegistry[t].quoterV2Address)throw Error("No Quoter Contract Provided");return(await s.getContractWithFetcherByChainId(t,u.ContractType.UniswapV3QuoterContract,d.networkRegistry[t].quoterV2Address).callStatic.quoteExactInputSingle({tokenIn:c.wrappedErc20TokenAddress??c.erc20TokenAddress,tokenOut:r.wrappedErc20TokenAddress??r.erc20TokenAddress,fee:o,amountIn:n,sqrtPriceLimitX96:0})).amountOut.toBigInt()}catch(a){throw h.logError(a),a}},A=async(s,t,c,r)=>{try{const o=s.getContractWithFetcherByChainId(t,u.ContractType.UniswapV3FactoryContract,d.networkRegistry[t].uniswapV3FactoryAddress),n=s.getContractWithFetcherByChainId(t,u.ContractType.ERC20Contract,r.wrappedErc20TokenAddress??r.erc20TokenAddress),{fee:a}=await w(n,o,c.wrappedErc20TokenAddress??c.erc20TokenAddress,r.wrappedErc20TokenAddress??r.erc20TokenAddress);return a}catch(o){throw console.log("Error in getUniswapFee",o),o}},E=async(s,t,c,r,o)=>{try{const n=await A(s,t,r,o),a=g.utils.defaultAbiCoder.encode(["uint24"],[n]),i=P.getAmountInWei(r,c);return{tokenPrice:await q(s,t,r,o,n,i),poolFee:a}}catch{throw Error(l.transactionErrorCodes.NO_UNISWAP_PRICE)}};exports.getUniswapFee=A;exports.getUniswapPrice=E;exports.getUniswapPriceHelper=q;exports.searchPoolAndFee=w;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("ethers"),d=require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const C=require("../../constants/protocol.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const l=require("../../error-handling/error-codes.constants.cjs"),y=require("./etherFunctions.cjs");require("axios");require("../../types/circom-data.types.cjs");const u=require("../../types/ethereum-network.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const h=require("../../error-handling/logError.cjs"),w=async(t,s,r,o)=>{const c=(await Promise.all([100,500,3e3,1e4].map(async e=>({poolAddress:await s.getPool(r,o,e),fee:e})))).filter(({poolAddress:e})=>e!==C.zeroAddress),n=await Promise.all(c.map(async e=>({poolAddress:e.poolAddress,fee:e.fee,token1Balance:(await t.balanceOf(e.poolAddress)).toBigInt()}))),i=n.map(e=>e.token1Balance).reduce((e,p)=>p>=e?p:e,0n);if(i===0n)throw new Error(l.transactionErrorCodes.UNISWAP_NOT_ENOUGH_LIQUIDITY);return n.find(e=>e.token1Balance===i)},q=async(t,s,r,o,c)=>{try{if(!d.networkRegistry[t.getCurrentChainId()].quoterV2Address)throw Error("No Quoter Contract Provided");return(await t.getContractWithFetcher(u.ContractType.UniswapV3QuoterContract,d.networkRegistry[t.getCurrentChainId()].quoterV2Address).callStatic.quoteExactInputSingle({tokenIn:s.wrappedErc20TokenAddress??s.erc20TokenAddress,tokenOut:r.wrappedErc20TokenAddress??r.erc20TokenAddress,fee:o,amountIn:c,sqrtPriceLimitX96:0})).amountOut.toBigInt()}catch(n){throw h.logError(n),n}},g=async(t,s,r)=>{try{const o=t.getCurrentChainId(),c=t.getContractWithFetcher(u.ContractType.UniswapV3FactoryContract,d.networkRegistry[o].uniswapV3FactoryAddress),n=t.getContractWithFetcher(u.ContractType.ERC20Contract,r.wrappedErc20TokenAddress??r.erc20TokenAddress),{fee:a}=await w(n,c,s.wrappedErc20TokenAddress??s.erc20TokenAddress,r.wrappedErc20TokenAddress??r.erc20TokenAddress);return a}catch(o){throw console.log("Error in getUniswapFee",o),o}},P=async(t,s,r,o)=>{try{const c=await g(t,r,o),n=A.utils.defaultAbiCoder.encode(["uint24"],[c]),a=y.getAmountInWei(r,s);return{tokenPrice:await q(t,r,o,c,a),poolFee:n}}catch{throw Error(l.transactionErrorCodes.NO_UNISWAP_PRICE)}};exports.getUniswapFee=g;exports.getUniswapPrice=P;exports.getUniswapPriceHelper=q;exports.searchPoolAndFee=w;
@@ -1,15 +1,15 @@
1
1
  import { Contract } from 'ethers';
2
+ import { IHinkal } from '../../data-structures';
2
3
  import { ERC20Token } from '../../types';
3
- import { IHinkal } from '../../data-structures/Hinkal/IHinkal';
4
4
  interface PoolAndFee {
5
5
  poolAddress: string;
6
6
  fee: number;
7
7
  token1Balance: bigint;
8
8
  }
9
9
  export declare const searchPoolAndFee: (token1Contract: Contract, factory: Contract, token0Address: string, token1Address: string) => Promise<PoolAndFee>;
10
- export declare const getUniswapPriceHelper: (hinkal: IHinkal, chainId: number, token0: ERC20Token, token1: ERC20Token, fee: number, inSwapAmount: bigint) => Promise<bigint>;
11
- export declare const getUniswapFee: (hinkal: IHinkal, chainId: number, token0: ERC20Token, token1: ERC20Token) => Promise<number>;
12
- export declare const getUniswapPrice: (hinkal: IHinkal, chainId: number, inSwapAmount: string, inSwapToken: ERC20Token, outSwapToken: ERC20Token) => Promise<{
10
+ export declare const getUniswapPriceHelper: (hinkal: IHinkal, token0: ERC20Token, token1: ERC20Token, fee: number, inSwapAmount: bigint) => Promise<bigint>;
11
+ export declare const getUniswapFee: (hinkal: IHinkal, token0: ERC20Token, token1: ERC20Token) => Promise<number>;
12
+ export declare const getUniswapPrice: (hinkal: IHinkal, inSwapAmount: string, inSwapToken: ERC20Token, outSwapToken: ERC20Token) => Promise<{
13
13
  tokenPrice: bigint;
14
14
  poolFee: string;
15
15
  }>;
@@ -1,98 +1,87 @@
1
- import { utils as A } from "ethers";
2
- import "../../constants/token-data/index.mjs";
3
- import { networkRegistry as p } from "../../constants/chains.constants.mjs";
1
+ import { utils as w } from "ethers";
2
+ import { networkRegistry as d } from "../../constants/chains.constants.mjs";
4
3
  import "../../constants/vite.constants.mjs";
5
4
  import "../../constants/contracts.constants.mjs";
6
5
  import "../../constants/kyc.constants.mjs";
7
- import { zeroAddress as u } from "../../constants/protocol.constants.mjs";
6
+ import { zeroAddress as A } from "../../constants/protocol.constants.mjs";
8
7
  import "../../constants/coingecko.constants.mjs";
9
8
  import "../../constants/axelar.constants.mjs";
10
9
  import "../../constants/rewards.constants.mjs";
11
10
  import "../../constants/reorg-depths.constants.mjs";
12
- import { transactionErrorCodes as l } from "../../error-handling/error-codes.constants.mjs";
13
- import { getAmountInWei as f } from "./etherFunctions.mjs";
11
+ import { transactionErrorCodes as u } from "../../error-handling/error-codes.constants.mjs";
12
+ import { getAmountInWei as l } from "./etherFunctions.mjs";
14
13
  import "axios";
15
14
  import "../../types/circom-data.types.mjs";
16
- import { ContractType as d } from "../../types/ethereum-network.types.mjs";
15
+ import { ContractType as p } from "../../types/ethereum-network.types.mjs";
17
16
  import "../../types/transactions.types.mjs";
18
17
  import "../../types/curve.types.mjs";
19
18
  import "circomlibjs-hinkal-fork";
20
19
  import "libsodium-wrappers";
21
20
  import "process";
22
21
  import "buffer";
23
- import { logError as y } from "../../error-handling/logError.mjs";
24
- const C = async (s, o, a, t) => {
25
- const e = (await Promise.all(
22
+ import { logError as C } from "../../error-handling/logError.mjs";
23
+ const f = async (e, s, t, o) => {
24
+ const c = (await Promise.all(
26
25
  [100, 500, 3e3, 1e4].map(async (r) => ({
27
- poolAddress: await o.getPool(a, t, r),
26
+ poolAddress: await s.getPool(t, o, r),
28
27
  fee: r
29
28
  }))
30
- )).filter(({ poolAddress: r }) => r !== u), n = await Promise.all(
31
- e.map(async (r) => ({
29
+ )).filter(({ poolAddress: r }) => r !== A), n = await Promise.all(
30
+ c.map(async (r) => ({
32
31
  poolAddress: r.poolAddress,
33
32
  fee: r.fee,
34
- token1Balance: (await s.balanceOf(r.poolAddress)).toBigInt()
33
+ token1Balance: (await e.balanceOf(r.poolAddress)).toBigInt()
35
34
  }))
36
35
  ), i = n.map((r) => r.token1Balance).reduce((r, m) => m >= r ? m : r, 0n);
37
36
  if (i === 0n)
38
- throw new Error(l.UNISWAP_NOT_ENOUGH_LIQUIDITY);
37
+ throw new Error(u.UNISWAP_NOT_ENOUGH_LIQUIDITY);
39
38
  return n.find((r) => r.token1Balance === i);
40
- }, g = async (s, o, a, t, e, n) => {
39
+ }, g = async (e, s, t, o, c) => {
41
40
  try {
42
- if (!p[o].quoterV2Address)
41
+ if (!d[e.getCurrentChainId()].quoterV2Address)
43
42
  throw Error("No Quoter Contract Provided");
44
- return (await s.getContractWithFetcherByChainId(
45
- o,
46
- d.UniswapV3QuoterContract,
47
- p[o].quoterV2Address
43
+ return (await e.getContractWithFetcher(
44
+ p.UniswapV3QuoterContract,
45
+ d[e.getCurrentChainId()].quoterV2Address
48
46
  ).callStatic.quoteExactInputSingle({
49
- tokenIn: a.wrappedErc20TokenAddress ?? a.erc20TokenAddress,
47
+ tokenIn: s.wrappedErc20TokenAddress ?? s.erc20TokenAddress,
50
48
  tokenOut: t.wrappedErc20TokenAddress ?? t.erc20TokenAddress,
51
- fee: e,
52
- amountIn: n,
49
+ fee: o,
50
+ amountIn: c,
53
51
  sqrtPriceLimitX96: 0
54
52
  })).amountOut.toBigInt();
55
- } catch (c) {
56
- throw y(c), c;
53
+ } catch (n) {
54
+ throw C(n), n;
57
55
  }
58
- }, E = async (s, o, a, t) => {
56
+ }, I = async (e, s, t) => {
59
57
  try {
60
- const e = s.getContractWithFetcherByChainId(
61
- o,
62
- d.UniswapV3FactoryContract,
63
- p[o].uniswapV3FactoryAddress
64
- ), n = s.getContractWithFetcherByChainId(
65
- o,
66
- d.ERC20Contract,
58
+ const o = e.getCurrentChainId(), c = e.getContractWithFetcher(
59
+ p.UniswapV3FactoryContract,
60
+ d[o].uniswapV3FactoryAddress
61
+ ), n = e.getContractWithFetcher(
62
+ p.ERC20Contract,
67
63
  t.wrappedErc20TokenAddress ?? t.erc20TokenAddress
68
- ), { fee: c } = await C(
64
+ ), { fee: a } = await f(
69
65
  n,
70
- e,
71
- a.wrappedErc20TokenAddress ?? a.erc20TokenAddress,
66
+ c,
67
+ s.wrappedErc20TokenAddress ?? s.erc20TokenAddress,
72
68
  t.wrappedErc20TokenAddress ?? t.erc20TokenAddress
73
69
  );
74
- return c;
75
- } catch (e) {
76
- throw console.log("Error in getUniswapFee", e), e;
70
+ return a;
71
+ } catch (o) {
72
+ throw console.log("Error in getUniswapFee", o), o;
77
73
  }
78
- }, G = async (s, o, a, t, e) => {
74
+ }, D = async (e, s, t, o) => {
79
75
  try {
80
- const n = await E(s, o, t, e), c = A.defaultAbiCoder.encode(["uint24"], [n]), i = f(t, a);
81
- return { tokenPrice: await g(
82
- s,
83
- o,
84
- t,
85
- e,
86
- n,
87
- i
88
- ), poolFee: c };
76
+ const c = await I(e, t, o), n = w.defaultAbiCoder.encode(["uint24"], [c]), a = l(t, s);
77
+ return { tokenPrice: await g(e, t, o, c, a), poolFee: n };
89
78
  } catch {
90
- throw Error(l.NO_UNISWAP_PRICE);
79
+ throw Error(u.NO_UNISWAP_PRICE);
91
80
  }
92
81
  };
93
82
  export {
94
- E as getUniswapFee,
95
- G as getUniswapPrice,
83
+ I as getUniswapFee,
84
+ D as getUniswapPrice,
96
85
  g as getUniswapPriceHelper,
97
- C as searchPoolAndFee
86
+ f as searchPoolAndFee
98
87
  };