@hinkal/common 0.0.104 → 0.0.107

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 (272) hide show
  1. package/API/API.js +58 -0
  2. package/API/HinkalPointsCalls.js +38 -0
  3. package/API/callBeefyGraphAPI.js +37 -0
  4. package/API/callCurveAPI.js +156 -0
  5. package/API/callMonitor.js +30 -0
  6. package/API/callOdosAPI.js +44 -0
  7. package/API/callOneInchAPI.js +37 -0
  8. package/API/callRelayer.js +32 -0
  9. package/API/checkRisk.js +30 -0
  10. package/API/dataServerCalls.js +32 -0
  11. package/API/fetchCommitmentsCache.js +31 -0
  12. package/API/fetchNullifiers.js +30 -0
  13. package/API/getAxelarGasEstimate.js +37 -0
  14. package/API/getCoingeckoPrice.js +27 -0
  15. package/API/getConnextReceiveFee.js +30 -0
  16. package/API/getGasEstimates.js +38 -0
  17. package/API/getRelayerURL.js +32 -0
  18. package/API/getServerURL.js +67 -0
  19. package/API/getTokenPrice.js +41 -0
  20. package/API/kycCalls.js +32 -0
  21. package/API/passwordCalls.js +36 -0
  22. package/API/referralProgramCalls.js +58 -0
  23. package/API/relayCalls.js +30 -0
  24. package/API/restoreSnapshots.js +32 -0
  25. package/API/rewardsPointsCalls.js +40 -0
  26. package/API/userVerifyTransactions.js +45 -0
  27. package/README.md +116 -1
  28. package/assets/{snarkjsWorkerLogic-CatB8Hso.js → snarkjsWorkerLogic-Fv0M38Mc.js} +2 -2
  29. package/assets/{utxoWorkerLogic-DDqTe7hT.js → utxoWorkerLogic-CtFLQiAX.js} +2 -2
  30. package/assets/{zkProofWorkerLauncher-C-pvCm0b.js → zkProofWorkerLauncher-J3Ts5_Ba.js} +1 -1
  31. package/assets/{zkProofWorkerLogic-CLpRqNRx.js → zkProofWorkerLogic-CPNuu61R.js} +18 -19
  32. package/constants/assets.constants.js +16 -0
  33. package/constants/axelar.constants.js +55 -0
  34. package/constants/backend.constants.js +18 -0
  35. package/constants/beefy.registry.js +24 -0
  36. package/constants/chains.constants.js +204 -0
  37. package/constants/coingecko.constants.js +53 -0
  38. package/constants/contracts.constants.js +276 -0
  39. package/constants/crvCvx.registry.js +636 -0
  40. package/constants/crvDynamic.registry.js +24 -0
  41. package/constants/deploy-data/deploy-data-arbMainnet.json.js +7415 -0
  42. package/constants/deploy-data/deploy-data-avalanche.json.js +7411 -0
  43. package/constants/deploy-data/deploy-data-axelar1.json.js +4329 -0
  44. package/constants/deploy-data/deploy-data-axelar2.json.js +4329 -0
  45. package/constants/deploy-data/deploy-data-base.json.js +8425 -0
  46. package/constants/deploy-data/deploy-data-blast.json.js +9600 -0
  47. package/constants/deploy-data/deploy-data-bnbMainnet.json.js +6877 -0
  48. package/constants/deploy-data/deploy-data-ethMainnet.json.js +11427 -0
  49. package/constants/deploy-data/deploy-data-localhost.json.js +13283 -0
  50. package/constants/deploy-data/deploy-data-optimism.json.js +7417 -0
  51. package/constants/deploy-data/deploy-data-polygon.json.js +7439 -0
  52. package/constants/fees.constants.js +57 -0
  53. package/constants/kyc.constants.js +118 -0
  54. package/constants/lido.constants.js +13 -0
  55. package/constants/pendle.registry.js +253 -0
  56. package/constants/protocol.constants.js +26 -0
  57. package/constants/reorg-depths.constants.js +15 -0
  58. package/constants/rewards.constants.js +27 -0
  59. package/constants/server.constants.js +157 -0
  60. package/constants/token-data/ERC20Registry.js +85 -0
  61. package/constants/token-data/arbMainnetRegistry.json.js +946 -0
  62. package/constants/token-data/arbMainnetRegistryFixed.json.js +856 -0
  63. package/constants/token-data/avalancheRegistry.json.js +591 -0
  64. package/constants/token-data/avalancheRegistryFixed.json.js +591 -0
  65. package/constants/token-data/baseRegistry.json.js +490 -0
  66. package/constants/token-data/baseRegistryFixed.json.js +463 -0
  67. package/constants/token-data/blastRegistry.json.js +137 -0
  68. package/constants/token-data/blastRegistryFixed.json.js +137 -0
  69. package/constants/token-data/bnbMainnetRegistry.json.js +973 -0
  70. package/constants/token-data/bnbMainnetRegistryFixed.json.js +973 -0
  71. package/constants/token-data/coingeckoRegistry.json.js +115623 -0
  72. package/constants/token-data/ethMainnetRegistry.json.js +2700 -0
  73. package/constants/token-data/ethMainnetRegistryFixed.json.js +2251 -0
  74. package/constants/token-data/index.js +6 -0
  75. package/constants/token-data/localhostRegistry.json.js +2768 -0
  76. package/constants/token-data/optimismRegistry.json.js +1455 -0
  77. package/constants/token-data/optimismRegistryFixed.json.js +1392 -0
  78. package/constants/token-data/polygonRegistry.json.js +1327 -0
  79. package/constants/token-data/polygonRegistryFixed.json.js +1255 -0
  80. package/constants/token-data/popularTokens.constants.js +14 -0
  81. package/constants/token-data/tokenPricing.consts.js +8 -0
  82. package/constants/vite.constants.js +29 -0
  83. package/crypto/babyJub.js +15 -0
  84. package/crypto/poseidon.js +26 -0
  85. package/crypto/preProcessing.js +9 -0
  86. package/data-structures/Hinkal/Hinkal.js +299 -0
  87. package/data-structures/Hinkal/hinkalActionBeefy.js +101 -0
  88. package/data-structures/Hinkal/hinkalActionConvex.js +83 -0
  89. package/data-structures/Hinkal/hinkalActionCurve.js +112 -0
  90. package/data-structures/Hinkal/hinkalActionLidoEth.js +91 -0
  91. package/data-structures/Hinkal/hinkalActionPendle.js +140 -0
  92. package/data-structures/Hinkal/hinkalActionPendleLP.js +96 -0
  93. package/data-structures/Hinkal/hinkalActionStake.js +138 -0
  94. package/data-structures/Hinkal/hinkalActionVolatile.js +112 -0
  95. package/data-structures/Hinkal/hinkalDeposit.js +95 -0
  96. package/data-structures/Hinkal/hinkalGetZkMeProvider.js +47 -0
  97. package/data-structures/Hinkal/hinkalPrivateWallet.js +66 -0
  98. package/data-structures/Hinkal/hinkalSwap.js +98 -0
  99. package/data-structures/Hinkal/hinkalTransfer.js +5 -0
  100. package/data-structures/Hinkal/hinkalWithdraw.js +91 -0
  101. package/data-structures/Hinkal/resetMerkleTrees.js +49 -0
  102. package/data-structures/MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.js +83 -0
  103. package/data-structures/ValueCache/ValueCache.js +25 -0
  104. package/data-structures/crypto-keys/decodeUTXO.js +40 -0
  105. package/data-structures/crypto-keys/encryptDecryptUtxo.js +41 -0
  106. package/data-structures/crypto-keys/keyUtils.js +10 -0
  107. package/data-structures/crypto-keys/keys.js +90 -0
  108. package/data-structures/custom-token-registry/CustomTokenRegistry.js +33 -0
  109. package/data-structures/event-service/AbstractAccessTokenSnapshotService.js +131 -0
  110. package/data-structures/event-service/AbstractCommitmentsSnapshotService.js +132 -0
  111. package/data-structures/event-service/AbstractEventService.js +118 -0
  112. package/data-structures/event-service/AbstractNullifierSnapshotService.js +59 -0
  113. package/data-structures/event-service/AbstractSnapshotService.js +35 -0
  114. package/data-structures/merkle-tree/MerkleTree.js +177 -0
  115. package/data-structures/merkle-tree/MerkleTreeIncompleteError.js +8 -0
  116. package/data-structures/snapshot/ClientAccessTokenSnapshotService.js +48 -0
  117. package/data-structures/snapshot/ClientCommitmentsSnapshotService.js +47 -0
  118. package/data-structures/snapshot/ClientNullifierSnapshotService.js +44 -0
  119. package/data-structures/token-price-fetcher/TokenChecker.js +29 -0
  120. package/data-structures/token-price-fetcher/TokenPriceFetcher.js +218 -0
  121. package/data-structures/transactions-manager/TransactionsManager.js +194 -0
  122. package/data-structures/transactions-manager/history/getBeefyData.js +68 -0
  123. package/data-structures/transactions-manager/history/getConvexData.js +57 -0
  124. package/data-structures/transactions-manager/history/getCurveData.js +97 -0
  125. package/data-structures/transactions-manager/history/getDepositData.js +36 -0
  126. package/data-structures/transactions-manager/history/getLidoData.js +44 -0
  127. package/data-structures/transactions-manager/history/getPendleData.js +59 -0
  128. package/data-structures/transactions-manager/history/getSwapData.js +43 -0
  129. package/data-structures/transactions-manager/history/getTxDetails.js +74 -0
  130. package/data-structures/transactions-manager/history/getVolatileData.js +75 -0
  131. package/data-structures/transactions-manager/history/history.types.js +62 -0
  132. package/data-structures/transactions-manager/history/history.utils.js +8 -0
  133. package/data-structures/utxo/Utxo.js +134 -0
  134. package/data-structures/volatile-helper/VolatileHelper.js +181 -0
  135. package/error-handling/customErrors/ErrorWithAmount.js +9 -0
  136. package/error-handling/customErrors/FeeOverTransactionValueError.js +9 -0
  137. package/error-handling/customErrors/customErrors.helpers.js +21 -0
  138. package/error-handling/error-codes.constants.js +184 -0
  139. package/error-handling/get-error.message.js +53 -0
  140. package/error-handling/handleErrorRestore.js +35 -0
  141. package/error-handling/logError.js +7 -0
  142. package/error-handling/types.js +4 -0
  143. package/externalABIs/BUSD.js +519 -0
  144. package/externalABIs/BabPassport.json.js +24 -0
  145. package/externalABIs/BeefyRouterAbi.json.js +1022 -0
  146. package/externalABIs/BeefyStrategyAbi.json.js +1423 -0
  147. package/externalABIs/BeefyVaultAbi.json.js +570 -0
  148. package/externalABIs/BeefyZapAbi.json.js +208 -0
  149. package/externalABIs/BeefyZapOneInchAbi.json.js +340 -0
  150. package/externalABIs/ConvexBoosterAbi.json.js +674 -0
  151. package/externalABIs/ConvexBoosterAbiMainnet.json.js +1002 -0
  152. package/externalABIs/ConvexRewardPoolAbi.json.js +883 -0
  153. package/externalABIs/CurveReadingWrapperAbi.json.js +1422 -0
  154. package/externalABIs/CurveWrappedMainPool.json.js +1136 -0
  155. package/externalABIs/CurveZap.json.js +262 -0
  156. package/externalABIs/CvxCrvUtilities.json.js +264 -0
  157. package/externalABIs/DAI.js +334 -0
  158. package/externalABIs/ERC20.json.js +291 -0
  159. package/externalABIs/GalxePassport.json.js +41 -0
  160. package/externalABIs/IQuoterV2.json.js +205 -0
  161. package/externalABIs/ISwapRouter.json.js +568 -0
  162. package/externalABIs/IUniswapV3Factory.json.js +201 -0
  163. package/externalABIs/IUniswapV3Pool.json.js +999 -0
  164. package/externalABIs/LidoStEthAbi.json.js +1603 -0
  165. package/externalABIs/LidoStMaticAbi.json.js +1764 -0
  166. package/externalABIs/LidoStakeManagerAbi.json.js +2082 -0
  167. package/externalABIs/LidoWithdrawalQueueERC721Abi.json.js +2030 -0
  168. package/externalABIs/LidoWstEthAbi.json.js +480 -0
  169. package/externalABIs/OptimismGasPriceOracle.json.js +206 -0
  170. package/externalABIs/PendleRouterAbi.json.js +173 -0
  171. package/externalABIs/PoLidoNftAbi.json.js +701 -0
  172. package/externalABIs/SanctionsList.js +89 -0
  173. package/externalABIs/USDC.js +721 -0
  174. package/externalABIs/USDR.js +346 -0
  175. package/externalABIs/USDR3CRV.js +542 -0
  176. package/externalABIs/USDT.js +393 -0
  177. package/externalABIs/UniswapV2PoolAbi.json.js +80 -0
  178. package/externalABIs/WETH.js +156 -0
  179. package/externalABIs/amToken.js +350 -0
  180. package/externalABIs/transactionsProver.json.js +39 -0
  181. package/functions/kyc/authentoHelper.js +42 -0
  182. package/functions/kyc/passportHelper.js +39 -0
  183. package/functions/kyc/zkMeHelper.js +56 -0
  184. package/functions/pre-transaction/getFlatFees.js +203 -0
  185. package/functions/pre-transaction/interaction-to-action.js +57 -0
  186. package/functions/pre-transaction/outputUtxoProcessing.js +45 -0
  187. package/functions/pre-transaction/process-gas-estimates.js +57 -0
  188. package/functions/pre-transaction/processAmountChanges.js +229 -0
  189. package/functions/private-wallet/emporium.helpers.js +19 -0
  190. package/functions/private-wallet/opProducer.js +24 -0
  191. package/functions/protocols/convex.protocols.js +41 -0
  192. package/functions/protocols/curve.protocols.js +45 -0
  193. package/functions/protocols/pendle.helpers.js +108 -0
  194. package/functions/snarkjs/common.snarkjs.js +96 -0
  195. package/functions/snarkjs/constant.js +211 -0
  196. package/functions/snarkjs/constructEmporiumProof.js +105 -0
  197. package/functions/snarkjs/constructGeneralZkProof.js +129 -0
  198. package/functions/snarkjs/generateCircomData.js +60 -0
  199. package/functions/snarkjs/generateZkProof.js +18 -0
  200. package/functions/snarkjs/getZKFiles.js +30 -0
  201. package/functions/staking/index.js +40 -0
  202. package/functions/utils/amounts.utils.js +70 -0
  203. package/functions/utils/axelar.utils.js +38 -0
  204. package/functions/utils/cacheFunctions.js +67 -0
  205. package/functions/utils/caseInsensitive.utils.js +6 -0
  206. package/functions/utils/convertIntegrationProviderToExternalActionId.js +16 -0
  207. package/functions/utils/create-provider.js +5 -0
  208. package/functions/utils/enum.utils.js +14 -0
  209. package/functions/utils/erc20tokenFunctions.js +20 -0
  210. package/functions/utils/evmNetworkFunctions.js +29 -0
  211. package/functions/utils/external-action.utils.js +61 -0
  212. package/functions/utils/getDataFromTransaction.js +105 -0
  213. package/functions/utils/memoize.utils.js +14 -0
  214. package/functions/utils/nickname.utils.js +7 -0
  215. package/functions/utils/process.utils.js +4 -0
  216. package/functions/utils/reloadPage.js +4 -0
  217. package/functions/utils/requireEnv.js +7 -0
  218. package/functions/utils/resolve-sync.utils.js +22 -0
  219. package/functions/utils/serialize.utils.js +4 -0
  220. package/functions/utils/string.utils.js +14 -0
  221. package/functions/utils/time.utils.js +8 -0
  222. package/functions/utils/userAgent.js +15 -0
  223. package/functions/utils/volatile-patcher.utils.js +40 -0
  224. package/functions/web3/etherFunctions.js +41 -0
  225. package/functions/web3/events/balanceChangedHandler.js +10 -0
  226. package/functions/web3/events/getInputUtxoAndBalance.js +72 -0
  227. package/functions/web3/events/getShieldedBalance.js +107 -0
  228. package/functions/web3/events/web3RetrieveEvents.js +9 -0
  229. package/functions/web3/functionCalls/accessTokenCalls.js +48 -0
  230. package/functions/web3/functionCalls/approveToken.js +153 -0
  231. package/functions/web3/functionCalls/estimateGasRelayer.js +18 -0
  232. package/functions/web3/functionCalls/transactCallDirect.js +60 -0
  233. package/functions/web3/functionCalls/transactCallRelayer.js +42 -0
  234. package/functions/web3/odosAPI.js +65 -0
  235. package/functions/web3/oneInchAPI.js +61 -0
  236. package/functions/web3/runContractFunction.js +95 -0
  237. package/functions/web3/uniswapAPI.js +97 -0
  238. package/index.js +644 -0
  239. package/package.json +5 -4
  240. package/types/beefy.types.js +21 -0
  241. package/types/circom-data.types.js +22 -0
  242. package/types/curve.types.js +25 -0
  243. package/types/ethereum-network.types.js +4 -0
  244. package/types/external-action.types.js +4 -0
  245. package/types/hinkal.stake.types.js +4 -0
  246. package/types/hinkal.types.js +15 -0
  247. package/types/kyc.types.js +13 -0
  248. package/types/pendle.types.js +15 -0
  249. package/types/rewards.types.js +27 -0
  250. package/types/slippage.types.js +15 -0
  251. package/types/time.types.js +58 -0
  252. package/types/token.types.js +4 -0
  253. package/types/transactions.types.js +36 -0
  254. package/webworker/performTaskWithWorker.js +62 -0
  255. package/webworker/snarkjsWorker/snarkjsWorker.types.js +4 -0
  256. package/webworker/snarkjsWorker/snarkjsWorkerLogic.js +32 -0
  257. package/webworker/utxoWorker/utxoWorker.types.js +4 -0
  258. package/webworker/utxoWorker/utxoWorkerLogic.js +70 -0
  259. package/webworker/viteWorkerURL.constant.d.ts +3 -3
  260. package/webworker/worker.registry.js +4 -0
  261. package/webworker/workerFactory.d.ts +0 -1
  262. package/webworker/workerFactory.js +42 -0
  263. package/{workerProxy-BDj498Ht.mjs → webworker/workerProxy.js} +1 -1
  264. package/webworker/zkProofWorker/zkProofWorker.types.js +4 -0
  265. package/webworker/zkProofWorker/zkProofWorkerLogic.js +66 -0
  266. package/assets/viteWorkerURL.constant-DrIQXA2B.js +0 -11
  267. package/index-DbehuQxV.mjs +0 -398145
  268. package/index.mjs +0 -457
  269. package/snarkjsWorkerLogic-BpNWzeoy.mjs +0 -12086
  270. package/utxoWorkerLogic-D7NuHk_K.mjs +0 -64
  271. package/viteWorkerURL.constant-Bc7ufzqC.mjs +0 -9
  272. package/zkProofWorkerLogic-Bnalmuka.mjs +0 -60
@@ -0,0 +1,112 @@
1
+ import { utils as V } from "ethers";
2
+ import { getNonLocalhostChainId as L, networkRegistry as U } from "../../constants/chains.constants.js";
3
+ import "../../types/circom-data.types.js";
4
+ import { ExternalActionId as i } from "../../types/external-action.types.js";
5
+ import { CurveAction as n } from "../../types/hinkal.types.js";
6
+ import "../../types/transactions.types.js";
7
+ import "../../types/curve.types.js";
8
+ import { transactionErrorCodes as h } from "../../error-handling/error-codes.constants.js";
9
+ import { curveWithdrawGasTokenAddress as T } from "../../constants/protocol.constants.js";
10
+ import "circomlibjs";
11
+ import "../crypto-keys/keys.js";
12
+ import "axios";
13
+ import "../crypto-keys/encryptDecryptUtxo.js";
14
+ import { addPaddingToUtxos as M } from "../../functions/web3/events/getShieldedBalance.js";
15
+ import { outputUtxoProcessing as S } from "../../functions/pre-transaction/outputUtxoProcessing.js";
16
+ import { constructZkProof as F } from "../../functions/snarkjs/constructGeneralZkProof.js";
17
+ import { estimateGasRelayer as W } from "../../functions/web3/functionCalls/estimateGasRelayer.js";
18
+ import { transactCallRelayer as k } from "../../functions/web3/functionCalls/transactCallRelayer.js";
19
+ import "../../functions/utils/external-action.utils.js";
20
+ import "../custom-token-registry/CustomTokenRegistry.js";
21
+ import "../../functions/utils/convertIntegrationProviderToExternalActionId.js";
22
+ import "../../constants/coingecko.constants.js";
23
+ import "../../constants/vite.constants.js";
24
+ import { processAmountChanges as G } from "../../functions/pre-transaction/processAmountChanges.js";
25
+ import { getFlatFees as N } from "../../functions/pre-transaction/getFlatFees.js";
26
+ import "../../functions/utils/userAgent.js";
27
+ import "../../constants/reorg-depths.constants.js";
28
+ import "../../constants/kyc.constants.js";
29
+ import "../../webworker/workerFactory.js";
30
+ import "../volatile-helper/VolatileHelper.js";
31
+ import { getCRV as $ } from "../../functions/protocols/curve.protocols.js";
32
+ import "libsodium-wrappers";
33
+ import "../../constants/contracts.constants.js";
34
+ import "../../constants/axelar.constants.js";
35
+ import { getCalcTokenAmountWithDynamicArray as b } from "../../constants/crvDynamic.registry.js";
36
+ import "../../constants/rewards.constants.js";
37
+ const O = (t, o, r, a) => o ? a ? i.CurveCRVRewards : i.CurveCRV : b(t).includes(r.toLowerCase()) ? i.CurveDynamic : i.Curve, P = (t, o) => {
38
+ const { contractData: r } = U[t.getCurrentChainId()];
39
+ switch (o) {
40
+ case i.Curve:
41
+ return r.curveExternalActionInstanceAddress;
42
+ case i.CurveDynamic:
43
+ return r.curveExternalActionDynamicInstanceAddress;
44
+ case i.CurveCRV:
45
+ return r.curveExternalActionInstanceAddress;
46
+ case i.CurveCRVRewards:
47
+ return r.curveStakeExternalActionInstanceAddress;
48
+ default:
49
+ return r.curveExternalActionInstanceAddress;
50
+ }
51
+ }, K = (t, o, r) => V.defaultAbiCoder.encode(
52
+ ["uint8", "address", "uint256", "uint256"],
53
+ [Number(t), o, r[0][0].amount, r[0][0].timeStamp]
54
+ ), _ = (t, o, r, a) => {
55
+ if ([n.Deposit, n.WithdrawInt, n.WithdrawUint].includes(a))
56
+ return t.map((e) => e > 0n);
57
+ if (a === n.WithdrawImbalance)
58
+ return t.map(() => !1);
59
+ if ([n.Stake, n.Unstake, n.GetCRV].includes(a)) {
60
+ let e = !1;
61
+ return o.map((p) => (p.toLowerCase() === $(r).toLowerCase() && (e = !0), e));
62
+ }
63
+ return t.map((e) => e > 0n);
64
+ }, Lt = async (t, o, r, a, e, p, I = !1) => {
65
+ const s = [...await M(t, o, r)];
66
+ let u = `swapperM${r.length.toString()}x${s[0].length}x1`;
67
+ const d = e === n.GetCRV || e === n.Stake || e === n.Unstake;
68
+ d && (u = `swapperMO${r.length.toString()}x${s[0].length}x1`);
69
+ const l = L(t.getCurrentChainId()), c = O(l, d, a, p), { flatFees: C, feeUnit: R } = await N(
70
+ t.getCurrentChainId(),
71
+ o,
72
+ c,
73
+ r,
74
+ e,
75
+ T?.current
76
+ );
77
+ r = G({
78
+ erc20Addresses: o,
79
+ amountChanges: r,
80
+ flatFees: C,
81
+ feeUnit: R,
82
+ externalActionId: c,
83
+ action: e
84
+ });
85
+ const y = _(r, o, l, e), f = [];
86
+ for (let m = 0; m < o.length; m += 1) {
87
+ const { outputUtxos: v } = S(t.userKeys, s[m], r[m]);
88
+ f.push(v);
89
+ }
90
+ const E = P(t, c), D = K(e, a, s), x = await t.getRandomRelay();
91
+ if (!x)
92
+ throw Error(h.RELAYER_NOT_AVAILABLE);
93
+ const { zkCallData: A, circomData: w, dimData: g } = await F(
94
+ t.merkleTreeHinkal,
95
+ t.merkleTreeAccessToken,
96
+ s,
97
+ f,
98
+ t.userKeys,
99
+ u,
100
+ c,
101
+ E,
102
+ D,
103
+ x,
104
+ t.getCurrentChainId(),
105
+ y,
106
+ C
107
+ );
108
+ return I ? await W(t, A, g, w) : await k(t.getCurrentChainId(), A, g, w);
109
+ };
110
+ export {
111
+ Lt as hinkalActionCurve
112
+ };
@@ -0,0 +1,91 @@
1
+ import { ethers as M } from "ethers";
2
+ import { networkRegistry as U } from "../../constants/chains.constants.js";
3
+ import "../../types/circom-data.types.js";
4
+ import { ExternalActionId as m } from "../../types/external-action.types.js";
5
+ import { LidoAction as s, LidoVariant as u } from "../../types/hinkal.types.js";
6
+ import "../../types/transactions.types.js";
7
+ import "../../types/curve.types.js";
8
+ import { transactionErrorCodes as N } from "../../error-handling/error-codes.constants.js";
9
+ import "circomlibjs";
10
+ import "../crypto-keys/keys.js";
11
+ import "axios";
12
+ import "../crypto-keys/encryptDecryptUtxo.js";
13
+ import { addPaddingToUtxos as D } from "../../functions/web3/events/getShieldedBalance.js";
14
+ import { outputUtxoProcessing as P } from "../../functions/pre-transaction/outputUtxoProcessing.js";
15
+ import { constructZkProof as H } from "../../functions/snarkjs/constructGeneralZkProof.js";
16
+ import { estimateGasRelayer as S } from "../../functions/web3/functionCalls/estimateGasRelayer.js";
17
+ import { transactCallRelayer as b } from "../../functions/web3/functionCalls/transactCallRelayer.js";
18
+ import "../../functions/utils/external-action.utils.js";
19
+ import "../custom-token-registry/CustomTokenRegistry.js";
20
+ import "../../functions/utils/convertIntegrationProviderToExternalActionId.js";
21
+ import "../../constants/coingecko.constants.js";
22
+ import "../../constants/vite.constants.js";
23
+ import { processAmountChanges as v } from "../../functions/pre-transaction/processAmountChanges.js";
24
+ import { getFlatFees as K } from "../../functions/pre-transaction/getFlatFees.js";
25
+ import "../../functions/utils/userAgent.js";
26
+ import "../../constants/reorg-depths.constants.js";
27
+ import "../../constants/kyc.constants.js";
28
+ import "../../webworker/workerFactory.js";
29
+ import "../volatile-helper/VolatileHelper.js";
30
+ import "libsodium-wrappers";
31
+ import "../../constants/contracts.constants.js";
32
+ import "../../constants/axelar.constants.js";
33
+ import "../../constants/rewards.constants.js";
34
+ const _ = (t, i) => {
35
+ if (t === u.Ethereum)
36
+ return i === s.Stake ? m.LidoETH : m.LidoETHNFT;
37
+ if (t === u.Polygon)
38
+ return i === s.Stake ? m.LidoMATIC : m.LidoMATICNFT;
39
+ throw new Error("Invalid LidoVariant used");
40
+ }, $ = (t) => M.utils.defaultAbiCoder.encode(["uint8"], [Number(t)]), Ct = async (t, i, e, a, o, f, A = !1) => {
41
+ const p = [...await D(t, a, o, 6, f)], y = p[0].length, C = `${e === s.Stake ? "swapperM" : "swapperToken"}2x${y}x1`, n = _(i, e), { flatFees: x, feeUnit: L } = await K(
42
+ t.getCurrentChainId(),
43
+ a,
44
+ n,
45
+ o,
46
+ e
47
+ );
48
+ o = v({
49
+ erc20Addresses: a,
50
+ amountChanges: o,
51
+ flatFees: x,
52
+ feeUnit: L,
53
+ externalActionId: n,
54
+ action: e
55
+ });
56
+ const g = e === s.Request ? o.map(() => !1) : o.map((r) => r > 0n), l = [];
57
+ for (let r = 0; r < a.length; r += 1) {
58
+ const { outputUtxos: F } = P(
59
+ t.userKeys,
60
+ p[r],
61
+ o[r],
62
+ void 0,
63
+ f[r]
64
+ );
65
+ l.push(F);
66
+ }
67
+ if (!await t.getRandomRelay())
68
+ throw Error(N.RELAYER_NOT_AVAILABLE);
69
+ const { lidoExternalActionEthAddress: T, lidoExternalActionMaticAddress: I } = U[t.getCurrentChainId()].contractData, c = i === u.Ethereum ? T : I;
70
+ if (!c)
71
+ throw new Error("Can't find external action address");
72
+ const R = $(e), { zkCallData: E, circomData: d, dimData: w } = await H(
73
+ t.merkleTreeHinkal,
74
+ t.merkleTreeAccessToken,
75
+ p,
76
+ l,
77
+ t.userKeys,
78
+ C,
79
+ n,
80
+ c,
81
+ R,
82
+ await t.getRandomRelay(),
83
+ t.getCurrentChainId(),
84
+ g,
85
+ x
86
+ );
87
+ return console.log({ externalActionAddress: c, externalActionId: n, circomData: d }), A ? await S(t, E, w, d) : await b(t.getCurrentChainId(), E, w, d);
88
+ };
89
+ export {
90
+ Ct as hinkalActionLido
91
+ };
@@ -0,0 +1,140 @@
1
+ import { networkRegistry as W } from "../../constants/chains.constants.js";
2
+ import { defaultHookData as H } from "../../types/circom-data.types.js";
3
+ import { ContractType as A } from "../../types/ethereum-network.types.js";
4
+ import { ExternalActionId as O } from "../../types/external-action.types.js";
5
+ import { PendleAction as o } from "../../types/hinkal.types.js";
6
+ import "../../types/transactions.types.js";
7
+ import "../../types/curve.types.js";
8
+ import { utils as U } from "ethers";
9
+ import { transactionErrorCodes as b } from "../../error-handling/error-codes.constants.js";
10
+ import { zeroAddress as R } from "../../constants/protocol.constants.js";
11
+ import "circomlibjs";
12
+ import "../crypto-keys/keys.js";
13
+ import "axios";
14
+ import "../crypto-keys/encryptDecryptUtxo.js";
15
+ import { addPaddingToUtxos as z } from "../../functions/web3/events/getShieldedBalance.js";
16
+ import { outputUtxoProcessing as L } from "../../functions/pre-transaction/outputUtxoProcessing.js";
17
+ import { constructZkProof as N } from "../../functions/snarkjs/constructGeneralZkProof.js";
18
+ import { estimateGasRelayer as $ } from "../../functions/web3/functionCalls/estimateGasRelayer.js";
19
+ import { transactCallRelayer as v } from "../../functions/web3/functionCalls/transactCallRelayer.js";
20
+ import { transactCallDirect as D } from "../../functions/web3/functionCalls/transactCallDirect.js";
21
+ import "../../functions/utils/external-action.utils.js";
22
+ import { getERC20Token as E } from "../../functions/utils/erc20tokenFunctions.js";
23
+ import "../../functions/utils/convertIntegrationProviderToExternalActionId.js";
24
+ import "../../constants/coingecko.constants.js";
25
+ import "../../constants/vite.constants.js";
26
+ import { processAmountChanges as G } from "../../functions/pre-transaction/processAmountChanges.js";
27
+ import { getFlatFees as K } from "../../functions/pre-transaction/getFlatFees.js";
28
+ import "../../functions/utils/userAgent.js";
29
+ import "../../constants/reorg-depths.constants.js";
30
+ import "../../constants/kyc.constants.js";
31
+ import "../../webworker/workerFactory.js";
32
+ import "../volatile-helper/VolatileHelper.js";
33
+ import "../custom-token-registry/CustomTokenRegistry.js";
34
+ import "libsodium-wrappers";
35
+ import "../../constants/contracts.constants.js";
36
+ import "../../constants/axelar.constants.js";
37
+ import "../../constants/rewards.constants.js";
38
+ const _ = (t) => {
39
+ let r = [];
40
+ return t === o.Deposit ? r = [!1, !0] : t === o.Withdraw ? r = [!1, !0] : t === o.SwapFromYt ? r = [!1, !0, !0] : t === o.SwapToYt ? r = [!1, !1, !0] : t === o.SwapPt ? r = [!1, !0] : t === o.Mint ? r = [!1, !0, !1, !0] : t === o.Redeem ? r = [!1, !1, !0, !0] : t === o.Checkpoint && (r = [!1, !0]), r;
41
+ }, B = (t, r) => {
42
+ const { pendleAction: i, ytAddress: n, userAddress: l, evmData: d } = t, a = d ?? "0x00", s = l ?? R;
43
+ if ([
44
+ o.Deposit,
45
+ o.Withdraw,
46
+ o.SwapFromYt,
47
+ o.SwapToYt,
48
+ o.SwapPt,
49
+ o.Mint,
50
+ o.Redeem,
51
+ o.Checkpoint
52
+ ].includes(t.pendleAction))
53
+ return U.defaultAbiCoder.encode(
54
+ ["uint8", "address", "uint256", "uint256", "address", "bool", "bytes"],
55
+ [
56
+ i,
57
+ n,
58
+ r[0][0].amount,
59
+ r[0][0].timeStamp,
60
+ s,
61
+ !0,
62
+ a
63
+ ]
64
+ );
65
+ throw new Error("Not implemented");
66
+ }, Ft = async (t, r, i, n, l, d = !1) => {
67
+ const a = O.Pendle, { pendleAction: s } = n, c = [...await z(t, r, i)], C = `swapperMO${i.length.toString()}x${c[0].length}x1`;
68
+ console.log({ inputUtxosArray: c, circuitName: C, pendleMetadata: n });
69
+ const { flatFees: w, feeUnit: T } = await K(
70
+ t.getCurrentChainId(),
71
+ r,
72
+ a,
73
+ i,
74
+ s,
75
+ l
76
+ );
77
+ console.log("hinkalActionPendle flatFees:", w), i = G({
78
+ erc20Addresses: r,
79
+ amountChanges: i,
80
+ flatFees: w,
81
+ feeUnit: T,
82
+ externalActionId: a,
83
+ action: s,
84
+ gasTokenAddress: l
85
+ });
86
+ const g = [];
87
+ for (let e = 0; e < r.length; e += 1) {
88
+ const { outputUtxos: u } = L(t.userKeys, c[e], i[e]);
89
+ g.push(u);
90
+ }
91
+ const P = _(s), { contractData: S } = W[t.getCurrentChainId()], I = S?.pendleExternalActionInstanceAddress, h = B(n, c), x = s === o.Deposit || n.isRelayerOff ? R : await t.getRandomRelay();
92
+ if (!x)
93
+ throw Error(b.RELAYER_NOT_AVAILABLE);
94
+ const Y = `0x0${s.toString(16)}`, k = { ...H, preHookMetadata: Y }, { zkCallData: m, circomData: p, dimData: f } = await N(
95
+ t.merkleTreeHinkal,
96
+ t.merkleTreeAccessToken,
97
+ c,
98
+ g,
99
+ t.userKeys,
100
+ C,
101
+ a,
102
+ I,
103
+ h,
104
+ x,
105
+ t.getCurrentChainId(),
106
+ P,
107
+ w,
108
+ k
109
+ );
110
+ if (console.log("hinkalActionPendle: zkCallData, dimData, circomData:", { zkCallData: m, dimData: f, circomData: p }), d)
111
+ return await $(t, m, f, p);
112
+ const y = t.getCurrentChainId();
113
+ if (s === o.Deposit) {
114
+ console.log("inside pendle deposit");
115
+ const e = E(n.ytAddress, y);
116
+ if (!e)
117
+ throw Error("Yt Token not found");
118
+ const u = t.getContractWithSigner(A.PendleGeneralExternalAction), F = t.getContractWithSigner(A.HinkalWrapper);
119
+ return await D(
120
+ t,
121
+ i[0],
122
+ e,
123
+ m,
124
+ p,
125
+ f,
126
+ u,
127
+ F
128
+ );
129
+ }
130
+ if (s === o.Withdraw && n.isRelayerOff) {
131
+ const e = E(n.ytAddress, y);
132
+ if (!e)
133
+ throw Error("Yt Token not found");
134
+ return await D(t, i[0], e, m, p, f);
135
+ }
136
+ return await v(t.getCurrentChainId(), m, f, p);
137
+ };
138
+ export {
139
+ Ft as hinkalActionPendle
140
+ };
@@ -0,0 +1,96 @@
1
+ import { ethers as I } from "ethers";
2
+ import { defaultHookData as U } from "../../types/circom-data.types.js";
3
+ import { ExternalActionId as h } from "../../types/external-action.types.js";
4
+ import { PendleLPAction as A } from "../../types/hinkal.types.js";
5
+ import "../../types/transactions.types.js";
6
+ import "../../types/curve.types.js";
7
+ import { networkRegistry as k } from "../../constants/chains.constants.js";
8
+ import "../../constants/vite.constants.js";
9
+ import "../../constants/contracts.constants.js";
10
+ import "../../constants/kyc.constants.js";
11
+ import "../../constants/coingecko.constants.js";
12
+ import "../../constants/axelar.constants.js";
13
+ import "../../constants/rewards.constants.js";
14
+ import "../../constants/reorg-depths.constants.js";
15
+ import { transactionErrorCodes as F } from "../../error-handling/error-codes.constants.js";
16
+ import "circomlibjs";
17
+ import "../crypto-keys/keys.js";
18
+ import "axios";
19
+ import "../crypto-keys/encryptDecryptUtxo.js";
20
+ import { addPaddingToUtxos as P } from "../../functions/web3/events/getShieldedBalance.js";
21
+ import { outputUtxoProcessing as O } from "../../functions/pre-transaction/outputUtxoProcessing.js";
22
+ import { constructZkProof as T } from "../../functions/snarkjs/constructGeneralZkProof.js";
23
+ import { estimateGasRelayer as b } from "../../functions/web3/functionCalls/estimateGasRelayer.js";
24
+ import { transactCallRelayer as S } from "../../functions/web3/functionCalls/transactCallRelayer.js";
25
+ import "../../functions/utils/external-action.utils.js";
26
+ import "../custom-token-registry/CustomTokenRegistry.js";
27
+ import "../../functions/utils/convertIntegrationProviderToExternalActionId.js";
28
+ import { processAmountChanges as v } from "../../functions/pre-transaction/processAmountChanges.js";
29
+ import { getFlatFees as z } from "../../functions/pre-transaction/getFlatFees.js";
30
+ import "../../functions/utils/userAgent.js";
31
+ import "../../webworker/workerFactory.js";
32
+ import "../volatile-helper/VolatileHelper.js";
33
+ import "libsodium-wrappers";
34
+ const G = (t, o) => {
35
+ if (t === A.AddOrRemoveLiquidity)
36
+ return o.length === 3 ? [!1, !0, !1] : [!1, !0, !1, !1];
37
+ if (t === A.Checkpoint)
38
+ return [!1, !0];
39
+ throw new Error("Unknown PendleLPAction not implemented");
40
+ }, H = (t, o) => {
41
+ const { pendleLPAction: r, lpAddress: e, evmData: a } = t;
42
+ return I.utils.defaultAbiCoder.encode(
43
+ ["uint8", "address", "uint256", "uint256", "bytes"],
44
+ [r, e, o[0][0].amount, o[0][0].timeStamp, a]
45
+ );
46
+ }, Ct = async (t, o, r, e, a, g = !1) => {
47
+ const m = h.PendleLP, { pendleLPAction: s } = e, i = [...await P(t, o, r)], y = `swapperMO${r.length.toString()}x${i[0].length}x1`, { flatFees: c, feeUnit: C } = await z(
48
+ t.getCurrentChainId(),
49
+ o,
50
+ m,
51
+ r,
52
+ s,
53
+ a
54
+ );
55
+ console.log("hinkalActionPendle flatFees:", c), r = v({
56
+ erc20Addresses: o,
57
+ amountChanges: r,
58
+ flatFees: c,
59
+ feeUnit: C,
60
+ externalActionId: m,
61
+ action: s,
62
+ gasTokenAddress: a
63
+ });
64
+ const u = [];
65
+ for (let n = 0; n < o.length; n += 1) {
66
+ const { outputUtxos: R } = O(t.userKeys, i[n], r[n]);
67
+ u.push(R);
68
+ }
69
+ const x = G(s, o), { contractData: w } = k[t.getCurrentChainId()], E = w?.pendleLPExternalActionInstanceAddress, D = H(e, i), d = await t.getRandomRelay();
70
+ if (!d)
71
+ throw Error(F.RELAYER_NOT_AVAILABLE);
72
+ const L = { ...U }, { zkCallData: p, circomData: l, dimData: f } = await T(
73
+ t.merkleTreeHinkal,
74
+ t.merkleTreeAccessToken,
75
+ i,
76
+ u,
77
+ t.userKeys,
78
+ y,
79
+ m,
80
+ E,
81
+ D,
82
+ d,
83
+ t.getCurrentChainId(),
84
+ x,
85
+ c,
86
+ L
87
+ );
88
+ return console.log("hinkalActionPendle: zkCallData, dimData, circomData:", { zkCallData: p, dimData: f, circomData: l }), g ? await b(t, p, f, l) : await S(t.getCurrentChainId(), p, f, l);
89
+ }, xt = async (t, o, r) => {
90
+ const e = [...await P(t, [o], [-1n * r])];
91
+ return { amount: e[0][0].amount, timestamp: e[0][0].timeStamp };
92
+ };
93
+ export {
94
+ Ct as hinkalActionPendleLP,
95
+ xt as hinkalGetPendleLPClaimableParams
96
+ };
@@ -0,0 +1,138 @@
1
+ import "../../constants/chains.constants.js";
2
+ import "../../types/circom-data.types.js";
3
+ import { ContractType as k } from "../../types/ethereum-network.types.js";
4
+ import { ExternalActionId as h } from "../../types/external-action.types.js";
5
+ import "../../types/transactions.types.js";
6
+ import "../../types/curve.types.js";
7
+ import { HinkalStakeMode as g } from "../../types/hinkal.stake.types.js";
8
+ import { randomBigInt as B } from "../../functions/web3/etherFunctions.js";
9
+ import { Utxo as f } from "../utxo/Utxo.js";
10
+ import "axios";
11
+ import "ethers";
12
+ import { UserKeys as O } from "../crypto-keys/keys.js";
13
+ import "../crypto-keys/encryptDecryptUtxo.js";
14
+ import { ownerPublicKey as b, zeroAddress as N } from "../../constants/protocol.constants.js";
15
+ import { addPaddingToUtxos as z } from "../../functions/web3/events/getShieldedBalance.js";
16
+ import { outputUtxoProcessing as $ } from "../../functions/pre-transaction/outputUtxoProcessing.js";
17
+ import { constructZkProof as j } from "../../functions/snarkjs/constructGeneralZkProof.js";
18
+ import "../../webworker/workerFactory.js";
19
+ import "../../functions/utils/external-action.utils.js";
20
+ import { getERC20Token as Z, getHToken as q } from "../../functions/utils/erc20tokenFunctions.js";
21
+ import "../../functions/utils/convertIntegrationProviderToExternalActionId.js";
22
+ import "../../constants/coingecko.constants.js";
23
+ import "../../constants/vite.constants.js";
24
+ import "../../functions/utils/userAgent.js";
25
+ import { transactCallDirect as T } from "../../functions/web3/functionCalls/transactCallDirect.js";
26
+ import "circomlibjs";
27
+ import "../../constants/reorg-depths.constants.js";
28
+ import "../../constants/kyc.constants.js";
29
+ import "../volatile-helper/VolatileHelper.js";
30
+ import "../custom-token-registry/CustomTokenRegistry.js";
31
+ import { encryptStake as w, createStakeCommitment as G, encodeHStakeMetadata as J } from "../../functions/staking/index.js";
32
+ import "../../constants/contracts.constants.js";
33
+ import "../../constants/axelar.constants.js";
34
+ import "../../constants/rewards.constants.js";
35
+ const It = async (t, y, e, a, s) => {
36
+ const A = await t.getEthereumAddress(), m = Z(y[0], t.getCurrentChainId());
37
+ if (!m)
38
+ throw Error("Deposit Action: No Token Found");
39
+ const c = a === g.Stake, n = a === g.Unstake, { symbol: U } = m;
40
+ console.log(`${a} token ${U} Start`);
41
+ const { erc20TokenAddress: E } = m, r = [
42
+ ...await z(
43
+ t,
44
+ y,
45
+ e,
46
+ 2,
47
+ void 0,
48
+ a !== g.Deposit
49
+ )
50
+ ];
51
+ if (c || n) {
52
+ r[0][0] = f.createFrom(r[0][0], {
53
+ amount: e[0] * (c ? 1n : -1n),
54
+ isStakeOrUnstakeInput: !0
55
+ });
56
+ for (let o = 0; o < r.length; o += 1)
57
+ for (let i = 0; i < r[o].length; i += 1)
58
+ o === 0 && i === 0 || (r[o][i] = f.createFrom(r[o][i], { amount: 0n }));
59
+ }
60
+ const { outputUtxos: K } = $(t.userKeys, r[0], e[0]), p = [
61
+ K.map(
62
+ (o) => f.createFrom(o, {
63
+ isStake: c,
64
+ isUnstakeOutput: n
65
+ })
66
+ )
67
+ ];
68
+ n && (p[0][0] = f.createFrom(p[0][0], {
69
+ amount: 0n,
70
+ isUnstakeOutput: n
71
+ }));
72
+ const H = [!1], d = B(30), I = O.getEncryptionKeyPair(t.userKeys.getShieldedPrivateKey()), P = w(d, s, b), D = w(d, s, I.publicKey), F = n ? 0n : G(
73
+ !0,
74
+ s,
75
+ d,
76
+ E,
77
+ e[0],
78
+ BigInt(p[0][0].timeStamp)
79
+ ), W = J(
80
+ c ? 0 : 1,
81
+ F,
82
+ A,
83
+ P,
84
+ D
85
+ ), C = t.getContractWithSigner(k.HinkalWrapper2), u = t.getContractWithSigner(k.HinkalStakeExternalAction);
86
+ console.log("external action address", u.address);
87
+ const { zkCallData: S, dimData: x, circomData: l } = await j(
88
+ t.merkleTreeHinkal,
89
+ t.merkleTreeAccessToken,
90
+ r,
91
+ p,
92
+ t.userKeys,
93
+ "swapperME1x2x1",
94
+ h.HinkalStake,
95
+ u.address,
96
+ W,
97
+ N,
98
+ t.getCurrentChainId(),
99
+ H,
100
+ void 0,
101
+ void 0,
102
+ {
103
+ stakedTokenRecipient: s,
104
+ stakeBlinding: d,
105
+ mode: a,
106
+ depositorAddress: A
107
+ }
108
+ );
109
+ if (console.log(l), n) {
110
+ const o = q(m, t.getCurrentChainId());
111
+ if (!o)
112
+ throw new Error("hToken not found");
113
+ const v = (await t.getContractWithFetcher(k.HToken, o.erc20TokenAddress).previewWithdraw(-e[0])).toBigInt();
114
+ return T(
115
+ t,
116
+ v,
117
+ o,
118
+ S,
119
+ l,
120
+ x,
121
+ u,
122
+ C
123
+ );
124
+ }
125
+ return T(
126
+ t,
127
+ e[0],
128
+ m,
129
+ S,
130
+ l,
131
+ x,
132
+ u,
133
+ C
134
+ );
135
+ };
136
+ export {
137
+ It as hinkalActionStake
138
+ };