@hinkal/common 0.2.3 → 0.2.4

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