@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.
- package/API/API.js +58 -0
- package/API/HinkalPointsCalls.js +38 -0
- package/API/callBeefyGraphAPI.js +37 -0
- package/API/callCurveAPI.js +156 -0
- package/API/callMonitor.js +30 -0
- package/API/callOdosAPI.js +44 -0
- package/API/callOneInchAPI.js +37 -0
- package/API/callRelayer.js +32 -0
- package/API/checkRisk.js +30 -0
- package/API/dataServerCalls.js +32 -0
- package/API/fetchCommitmentsCache.js +31 -0
- package/API/fetchNullifiers.js +30 -0
- package/API/getAxelarGasEstimate.js +37 -0
- package/API/getCoingeckoPrice.js +27 -0
- package/API/getConnextReceiveFee.js +30 -0
- package/API/getGasEstimates.js +38 -0
- package/API/getRelayerURL.js +32 -0
- package/API/getServerURL.js +67 -0
- package/API/getTokenPrice.js +41 -0
- package/API/kycCalls.js +32 -0
- package/API/passwordCalls.js +36 -0
- package/API/referralProgramCalls.js +58 -0
- package/API/relayCalls.js +30 -0
- package/API/restoreSnapshots.js +32 -0
- package/API/rewardsPointsCalls.js +40 -0
- package/API/userVerifyTransactions.js +45 -0
- package/README.md +116 -1
- package/assets/{snarkjsWorkerLogic-CatB8Hso.js → snarkjsWorkerLogic-Fv0M38Mc.js} +2 -2
- package/assets/{utxoWorkerLogic-DDqTe7hT.js → utxoWorkerLogic-CtFLQiAX.js} +2 -2
- package/assets/{zkProofWorkerLauncher-C-pvCm0b.js → zkProofWorkerLauncher-J3Ts5_Ba.js} +1 -1
- package/assets/{zkProofWorkerLogic-CLpRqNRx.js → zkProofWorkerLogic-CPNuu61R.js} +18 -19
- package/constants/assets.constants.js +16 -0
- package/constants/axelar.constants.js +55 -0
- package/constants/backend.constants.js +18 -0
- package/constants/beefy.registry.js +24 -0
- package/constants/chains.constants.js +204 -0
- package/constants/coingecko.constants.js +53 -0
- package/constants/contracts.constants.js +276 -0
- package/constants/crvCvx.registry.js +636 -0
- package/constants/crvDynamic.registry.js +24 -0
- package/constants/deploy-data/deploy-data-arbMainnet.json.js +7415 -0
- package/constants/deploy-data/deploy-data-avalanche.json.js +7411 -0
- package/constants/deploy-data/deploy-data-axelar1.json.js +4329 -0
- package/constants/deploy-data/deploy-data-axelar2.json.js +4329 -0
- package/constants/deploy-data/deploy-data-base.json.js +8425 -0
- package/constants/deploy-data/deploy-data-blast.json.js +9600 -0
- package/constants/deploy-data/deploy-data-bnbMainnet.json.js +6877 -0
- package/constants/deploy-data/deploy-data-ethMainnet.json.js +11427 -0
- package/constants/deploy-data/deploy-data-localhost.json.js +13283 -0
- package/constants/deploy-data/deploy-data-optimism.json.js +7417 -0
- package/constants/deploy-data/deploy-data-polygon.json.js +7439 -0
- package/constants/fees.constants.js +57 -0
- package/constants/kyc.constants.js +118 -0
- package/constants/lido.constants.js +13 -0
- package/constants/pendle.registry.js +253 -0
- package/constants/protocol.constants.js +26 -0
- package/constants/reorg-depths.constants.js +15 -0
- package/constants/rewards.constants.js +27 -0
- package/constants/server.constants.js +157 -0
- package/constants/token-data/ERC20Registry.js +85 -0
- package/constants/token-data/arbMainnetRegistry.json.js +946 -0
- package/constants/token-data/arbMainnetRegistryFixed.json.js +856 -0
- package/constants/token-data/avalancheRegistry.json.js +591 -0
- package/constants/token-data/avalancheRegistryFixed.json.js +591 -0
- package/constants/token-data/baseRegistry.json.js +490 -0
- package/constants/token-data/baseRegistryFixed.json.js +463 -0
- package/constants/token-data/blastRegistry.json.js +137 -0
- package/constants/token-data/blastRegistryFixed.json.js +137 -0
- package/constants/token-data/bnbMainnetRegistry.json.js +973 -0
- package/constants/token-data/bnbMainnetRegistryFixed.json.js +973 -0
- package/constants/token-data/coingeckoRegistry.json.js +115623 -0
- package/constants/token-data/ethMainnetRegistry.json.js +2700 -0
- package/constants/token-data/ethMainnetRegistryFixed.json.js +2251 -0
- package/constants/token-data/index.js +6 -0
- package/constants/token-data/localhostRegistry.json.js +2768 -0
- package/constants/token-data/optimismRegistry.json.js +1455 -0
- package/constants/token-data/optimismRegistryFixed.json.js +1392 -0
- package/constants/token-data/polygonRegistry.json.js +1327 -0
- package/constants/token-data/polygonRegistryFixed.json.js +1255 -0
- package/constants/token-data/popularTokens.constants.js +14 -0
- package/constants/token-data/tokenPricing.consts.js +8 -0
- package/constants/vite.constants.js +29 -0
- package/crypto/babyJub.js +15 -0
- package/crypto/poseidon.js +26 -0
- package/crypto/preProcessing.js +9 -0
- package/data-structures/Hinkal/Hinkal.js +299 -0
- package/data-structures/Hinkal/hinkalActionBeefy.js +101 -0
- package/data-structures/Hinkal/hinkalActionConvex.js +83 -0
- package/data-structures/Hinkal/hinkalActionCurve.js +112 -0
- package/data-structures/Hinkal/hinkalActionLidoEth.js +91 -0
- package/data-structures/Hinkal/hinkalActionPendle.js +140 -0
- package/data-structures/Hinkal/hinkalActionPendleLP.js +96 -0
- package/data-structures/Hinkal/hinkalActionStake.js +138 -0
- package/data-structures/Hinkal/hinkalActionVolatile.js +112 -0
- package/data-structures/Hinkal/hinkalDeposit.js +95 -0
- package/data-structures/Hinkal/hinkalGetZkMeProvider.js +47 -0
- package/data-structures/Hinkal/hinkalPrivateWallet.js +66 -0
- package/data-structures/Hinkal/hinkalSwap.js +98 -0
- package/data-structures/Hinkal/hinkalTransfer.js +5 -0
- package/data-structures/Hinkal/hinkalWithdraw.js +91 -0
- package/data-structures/Hinkal/resetMerkleTrees.js +49 -0
- package/data-structures/MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.js +83 -0
- package/data-structures/ValueCache/ValueCache.js +25 -0
- package/data-structures/crypto-keys/decodeUTXO.js +40 -0
- package/data-structures/crypto-keys/encryptDecryptUtxo.js +41 -0
- package/data-structures/crypto-keys/keyUtils.js +10 -0
- package/data-structures/crypto-keys/keys.js +90 -0
- package/data-structures/custom-token-registry/CustomTokenRegistry.js +33 -0
- package/data-structures/event-service/AbstractAccessTokenSnapshotService.js +131 -0
- package/data-structures/event-service/AbstractCommitmentsSnapshotService.js +132 -0
- package/data-structures/event-service/AbstractEventService.js +118 -0
- package/data-structures/event-service/AbstractNullifierSnapshotService.js +59 -0
- package/data-structures/event-service/AbstractSnapshotService.js +35 -0
- package/data-structures/merkle-tree/MerkleTree.js +177 -0
- package/data-structures/merkle-tree/MerkleTreeIncompleteError.js +8 -0
- package/data-structures/snapshot/ClientAccessTokenSnapshotService.js +48 -0
- package/data-structures/snapshot/ClientCommitmentsSnapshotService.js +47 -0
- package/data-structures/snapshot/ClientNullifierSnapshotService.js +44 -0
- package/data-structures/token-price-fetcher/TokenChecker.js +29 -0
- package/data-structures/token-price-fetcher/TokenPriceFetcher.js +218 -0
- package/data-structures/transactions-manager/TransactionsManager.js +194 -0
- package/data-structures/transactions-manager/history/getBeefyData.js +68 -0
- package/data-structures/transactions-manager/history/getConvexData.js +57 -0
- package/data-structures/transactions-manager/history/getCurveData.js +97 -0
- package/data-structures/transactions-manager/history/getDepositData.js +36 -0
- package/data-structures/transactions-manager/history/getLidoData.js +44 -0
- package/data-structures/transactions-manager/history/getPendleData.js +59 -0
- package/data-structures/transactions-manager/history/getSwapData.js +43 -0
- package/data-structures/transactions-manager/history/getTxDetails.js +74 -0
- package/data-structures/transactions-manager/history/getVolatileData.js +75 -0
- package/data-structures/transactions-manager/history/history.types.js +62 -0
- package/data-structures/transactions-manager/history/history.utils.js +8 -0
- package/data-structures/utxo/Utxo.js +134 -0
- package/data-structures/volatile-helper/VolatileHelper.js +181 -0
- package/error-handling/customErrors/ErrorWithAmount.js +9 -0
- package/error-handling/customErrors/FeeOverTransactionValueError.js +9 -0
- package/error-handling/customErrors/customErrors.helpers.js +21 -0
- package/error-handling/error-codes.constants.js +184 -0
- package/error-handling/get-error.message.js +53 -0
- package/error-handling/handleErrorRestore.js +35 -0
- package/error-handling/logError.js +7 -0
- package/error-handling/types.js +4 -0
- package/externalABIs/BUSD.js +519 -0
- package/externalABIs/BabPassport.json.js +24 -0
- package/externalABIs/BeefyRouterAbi.json.js +1022 -0
- package/externalABIs/BeefyStrategyAbi.json.js +1423 -0
- package/externalABIs/BeefyVaultAbi.json.js +570 -0
- package/externalABIs/BeefyZapAbi.json.js +208 -0
- package/externalABIs/BeefyZapOneInchAbi.json.js +340 -0
- package/externalABIs/ConvexBoosterAbi.json.js +674 -0
- package/externalABIs/ConvexBoosterAbiMainnet.json.js +1002 -0
- package/externalABIs/ConvexRewardPoolAbi.json.js +883 -0
- package/externalABIs/CurveReadingWrapperAbi.json.js +1422 -0
- package/externalABIs/CurveWrappedMainPool.json.js +1136 -0
- package/externalABIs/CurveZap.json.js +262 -0
- package/externalABIs/CvxCrvUtilities.json.js +264 -0
- package/externalABIs/DAI.js +334 -0
- package/externalABIs/ERC20.json.js +291 -0
- package/externalABIs/GalxePassport.json.js +41 -0
- package/externalABIs/IQuoterV2.json.js +205 -0
- package/externalABIs/ISwapRouter.json.js +568 -0
- package/externalABIs/IUniswapV3Factory.json.js +201 -0
- package/externalABIs/IUniswapV3Pool.json.js +999 -0
- package/externalABIs/LidoStEthAbi.json.js +1603 -0
- package/externalABIs/LidoStMaticAbi.json.js +1764 -0
- package/externalABIs/LidoStakeManagerAbi.json.js +2082 -0
- package/externalABIs/LidoWithdrawalQueueERC721Abi.json.js +2030 -0
- package/externalABIs/LidoWstEthAbi.json.js +480 -0
- package/externalABIs/OptimismGasPriceOracle.json.js +206 -0
- package/externalABIs/PendleRouterAbi.json.js +173 -0
- package/externalABIs/PoLidoNftAbi.json.js +701 -0
- package/externalABIs/SanctionsList.js +89 -0
- package/externalABIs/USDC.js +721 -0
- package/externalABIs/USDR.js +346 -0
- package/externalABIs/USDR3CRV.js +542 -0
- package/externalABIs/USDT.js +393 -0
- package/externalABIs/UniswapV2PoolAbi.json.js +80 -0
- package/externalABIs/WETH.js +156 -0
- package/externalABIs/amToken.js +350 -0
- package/externalABIs/transactionsProver.json.js +39 -0
- package/functions/kyc/authentoHelper.js +42 -0
- package/functions/kyc/passportHelper.js +39 -0
- package/functions/kyc/zkMeHelper.js +56 -0
- package/functions/pre-transaction/getFlatFees.js +203 -0
- package/functions/pre-transaction/interaction-to-action.js +57 -0
- package/functions/pre-transaction/outputUtxoProcessing.js +45 -0
- package/functions/pre-transaction/process-gas-estimates.js +57 -0
- package/functions/pre-transaction/processAmountChanges.js +229 -0
- package/functions/private-wallet/emporium.helpers.js +19 -0
- package/functions/private-wallet/opProducer.js +24 -0
- package/functions/protocols/convex.protocols.js +41 -0
- package/functions/protocols/curve.protocols.js +45 -0
- package/functions/protocols/pendle.helpers.js +108 -0
- package/functions/snarkjs/common.snarkjs.js +96 -0
- package/functions/snarkjs/constant.js +211 -0
- package/functions/snarkjs/constructEmporiumProof.js +105 -0
- package/functions/snarkjs/constructGeneralZkProof.js +129 -0
- package/functions/snarkjs/generateCircomData.js +60 -0
- package/functions/snarkjs/generateZkProof.js +18 -0
- package/functions/snarkjs/getZKFiles.js +30 -0
- package/functions/staking/index.js +40 -0
- package/functions/utils/amounts.utils.js +70 -0
- package/functions/utils/axelar.utils.js +38 -0
- package/functions/utils/cacheFunctions.js +67 -0
- package/functions/utils/caseInsensitive.utils.js +6 -0
- package/functions/utils/convertIntegrationProviderToExternalActionId.js +16 -0
- package/functions/utils/create-provider.js +5 -0
- package/functions/utils/enum.utils.js +14 -0
- package/functions/utils/erc20tokenFunctions.js +20 -0
- package/functions/utils/evmNetworkFunctions.js +29 -0
- package/functions/utils/external-action.utils.js +61 -0
- package/functions/utils/getDataFromTransaction.js +105 -0
- package/functions/utils/memoize.utils.js +14 -0
- package/functions/utils/nickname.utils.js +7 -0
- package/functions/utils/process.utils.js +4 -0
- package/functions/utils/reloadPage.js +4 -0
- package/functions/utils/requireEnv.js +7 -0
- package/functions/utils/resolve-sync.utils.js +22 -0
- package/functions/utils/serialize.utils.js +4 -0
- package/functions/utils/string.utils.js +14 -0
- package/functions/utils/time.utils.js +8 -0
- package/functions/utils/userAgent.js +15 -0
- package/functions/utils/volatile-patcher.utils.js +40 -0
- package/functions/web3/etherFunctions.js +41 -0
- package/functions/web3/events/balanceChangedHandler.js +10 -0
- package/functions/web3/events/getInputUtxoAndBalance.js +72 -0
- package/functions/web3/events/getShieldedBalance.js +107 -0
- package/functions/web3/events/web3RetrieveEvents.js +9 -0
- package/functions/web3/functionCalls/accessTokenCalls.js +48 -0
- package/functions/web3/functionCalls/approveToken.js +153 -0
- package/functions/web3/functionCalls/estimateGasRelayer.js +18 -0
- package/functions/web3/functionCalls/transactCallDirect.js +60 -0
- package/functions/web3/functionCalls/transactCallRelayer.js +42 -0
- package/functions/web3/odosAPI.js +65 -0
- package/functions/web3/oneInchAPI.js +61 -0
- package/functions/web3/runContractFunction.js +95 -0
- package/functions/web3/uniswapAPI.js +97 -0
- package/index.js +644 -0
- package/package.json +5 -4
- package/types/beefy.types.js +21 -0
- package/types/circom-data.types.js +22 -0
- package/types/curve.types.js +25 -0
- package/types/ethereum-network.types.js +4 -0
- package/types/external-action.types.js +4 -0
- package/types/hinkal.stake.types.js +4 -0
- package/types/hinkal.types.js +15 -0
- package/types/kyc.types.js +13 -0
- package/types/pendle.types.js +15 -0
- package/types/rewards.types.js +27 -0
- package/types/slippage.types.js +15 -0
- package/types/time.types.js +58 -0
- package/types/token.types.js +4 -0
- package/types/transactions.types.js +36 -0
- package/webworker/performTaskWithWorker.js +62 -0
- package/webworker/snarkjsWorker/snarkjsWorker.types.js +4 -0
- package/webworker/snarkjsWorker/snarkjsWorkerLogic.js +32 -0
- package/webworker/utxoWorker/utxoWorker.types.js +4 -0
- package/webworker/utxoWorker/utxoWorkerLogic.js +70 -0
- package/webworker/viteWorkerURL.constant.d.ts +3 -3
- package/webworker/worker.registry.js +4 -0
- package/webworker/workerFactory.d.ts +0 -1
- package/webworker/workerFactory.js +42 -0
- package/{workerProxy-BDj498Ht.mjs → webworker/workerProxy.js} +1 -1
- package/webworker/zkProofWorker/zkProofWorker.types.js +4 -0
- package/webworker/zkProofWorker/zkProofWorkerLogic.js +66 -0
- package/assets/viteWorkerURL.constant-DrIQXA2B.js +0 -11
- package/index-DbehuQxV.mjs +0 -398145
- package/index.mjs +0 -457
- package/snarkjsWorkerLogic-BpNWzeoy.mjs +0 -12086
- package/utxoWorkerLogic-D7NuHk_K.mjs +0 -64
- package/viteWorkerURL.constant-Bc7ufzqC.mjs +0 -9
- 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
|
+
};
|