@hinkal/common 0.2.4 → 0.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API/API.cjs +1 -1
- package/API/API.d.ts +2 -2
- package/API/API.mjs +22 -22
- package/API/duneAPI.cjs +1 -1
- package/API/duneAPI.mjs +2 -3
- package/API/userVerifyTransactions.cjs +1 -1
- package/API/userVerifyTransactions.d.ts +7 -6
- package/API/userVerifyTransactions.mjs +14 -13
- package/constants/chains.constants.cjs +1 -1
- package/constants/chains.constants.mjs +2 -2
- package/constants/contracts.constants.cjs +1 -1
- package/constants/contracts.constants.mjs +134 -138
- package/constants/deploy-data/deploy-data-arbMainnet.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-arbMainnet.json.mjs +11 -846
- package/constants/deploy-data/deploy-data-avalanche.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-avalanche.json.mjs +13 -848
- package/constants/deploy-data/deploy-data-base.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-base.json.mjs +17 -852
- package/constants/deploy-data/deploy-data-bnbMainnet.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-bnbMainnet.json.mjs +20 -855
- package/constants/deploy-data/deploy-data-ethMainnet.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-ethMainnet.json.mjs +15 -850
- package/constants/deploy-data/deploy-data-localhost.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-localhost.json.mjs +100 -935
- package/constants/deploy-data/deploy-data-optimism.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-optimism.json.mjs +18 -849
- package/constants/deploy-data/deploy-data-polygon.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-polygon.json.mjs +9 -844
- package/constants/kyc.constants.cjs +1 -1
- package/constants/kyc.constants.mjs +18 -30
- package/constants/server.constants.cjs +1 -1
- package/constants/server.constants.d.ts +2 -3
- package/constants/server.constants.mjs +6 -7
- package/constants/token-data/ERC20Registry.cjs +1 -1
- package/constants/token-data/ERC20Registry.mjs +48 -48
- package/constants/token-data/arbMainnetRegistry.json.cjs +1 -1
- package/constants/token-data/arbMainnetRegistry.json.mjs +1 -4
- package/constants/token-data/arbMainnetRegistryFixed.json.cjs +1 -1
- package/constants/token-data/arbMainnetRegistryFixed.json.mjs +1 -4
- package/constants/token-data/avalancheRegistry.json.cjs +1 -1
- package/constants/token-data/avalancheRegistry.json.mjs +1 -4
- package/constants/token-data/avalancheRegistryFixed.json.cjs +1 -1
- package/constants/token-data/avalancheRegistryFixed.json.mjs +1 -4
- package/constants/token-data/baseRegistry.json.cjs +1 -1
- package/constants/token-data/baseRegistry.json.mjs +1 -4
- package/constants/token-data/baseRegistryFixed.json.cjs +1 -1
- package/constants/token-data/baseRegistryFixed.json.mjs +1 -4
- package/constants/token-data/bnbMainnetRegistry.json.cjs +1 -1
- package/constants/token-data/bnbMainnetRegistry.json.mjs +1 -4
- package/constants/token-data/bnbMainnetRegistryFixed.json.cjs +1 -1
- package/constants/token-data/bnbMainnetRegistryFixed.json.mjs +1 -4
- package/constants/token-data/ethMainnetRegistry.json.cjs +1 -1
- package/constants/token-data/ethMainnetRegistry.json.mjs +1 -4
- package/constants/token-data/ethMainnetRegistryFixed.json.cjs +1 -1
- package/constants/token-data/ethMainnetRegistryFixed.json.mjs +1 -4
- package/constants/token-data/index.d.ts +15 -972
- package/constants/token-data/localhostRegistry.json.cjs +1 -1
- package/constants/token-data/localhostRegistry.json.mjs +1 -4
- package/constants/token-data/optimismRegistry.json.cjs +1 -1
- package/constants/token-data/optimismRegistry.json.mjs +1 -4
- package/constants/token-data/optimismRegistryFixed.json.cjs +1 -1
- package/constants/token-data/optimismRegistryFixed.json.mjs +1 -4
- package/constants/token-data/polygonRegistry.json.cjs +1 -1
- package/constants/token-data/polygonRegistry.json.mjs +1 -4
- package/constants/token-data/polygonRegistryFixed.json.cjs +1 -1
- package/constants/token-data/polygonRegistryFixed.json.mjs +1 -4
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.d.ts +0 -2
- package/data-structures/Hinkal/Hinkal.mjs +32 -38
- package/data-structures/Hinkal/IHinkal.d.ts +0 -2
- package/data-structures/Hinkal/hinkalActionBeefy.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionBeefy.mjs +20 -21
- package/data-structures/Hinkal/hinkalActionConvex.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionConvex.mjs +12 -13
- package/data-structures/Hinkal/hinkalActionCurve.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionCurve.mjs +14 -15
- package/data-structures/Hinkal/hinkalActionLidoEth.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionLidoEth.mjs +16 -17
- package/data-structures/Hinkal/hinkalActionPendle.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionPendle.d.ts +1 -1
- package/data-structures/Hinkal/hinkalActionPendle.mjs +23 -24
- package/data-structures/Hinkal/hinkalActionPendleLP.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionPendleLP.mjs +20 -21
- package/data-structures/Hinkal/hinkalActionStake.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionStake.d.ts +1 -1
- package/data-structures/Hinkal/hinkalActionStake.mjs +5 -6
- package/data-structures/Hinkal/hinkalActionVolatile.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionVolatile.d.ts +1 -1
- package/data-structures/Hinkal/hinkalActionVolatile.mjs +8 -9
- package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalDeposit.d.ts +2 -2
- package/data-structures/Hinkal/hinkalDeposit.mjs +54 -93
- package/data-structures/Hinkal/hinkalGetZkMeProvider.cjs +1 -1
- package/data-structures/Hinkal/hinkalGetZkMeProvider.mjs +2 -3
- package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.mjs +4 -5
- package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSwap.mjs +22 -23
- package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdraw.d.ts +1 -1
- package/data-structures/Hinkal/hinkalWithdraw.mjs +12 -13
- package/data-structures/merkle-tree/MerkleTree.cjs +1 -1
- package/data-structures/merkle-tree/MerkleTree.d.ts +0 -2
- package/data-structures/merkle-tree/MerkleTree.mjs +25 -38
- package/data-structures/merkle-tree/index.d.ts +0 -1
- package/data-structures/transactions-manager/TransactionsManager.cjs +1 -1
- package/data-structures/transactions-manager/TransactionsManager.d.ts +5 -6
- package/data-structures/transactions-manager/TransactionsManager.mjs +111 -118
- package/error-handling/error-codes.constants.cjs +1 -1
- package/error-handling/error-codes.constants.d.ts +0 -4
- package/error-handling/error-codes.constants.mjs +2 -6
- package/externalABIs/BabPassport.json.cjs +1 -1
- package/externalABIs/BabPassport.json.mjs +3 -8
- package/externalABIs/BeefyRouterAbi.json.cjs +1 -1
- package/externalABIs/BeefyRouterAbi.json.mjs +2 -5
- package/externalABIs/BeefyStrategyAbi.json.cjs +1 -1
- package/externalABIs/BeefyStrategyAbi.json.mjs +2 -5
- package/externalABIs/BeefyVaultAbi.json.cjs +1 -1
- package/externalABIs/BeefyVaultAbi.json.mjs +2 -5
- package/externalABIs/BeefyZapAbi.json.cjs +1 -1
- package/externalABIs/BeefyZapAbi.json.mjs +2 -5
- package/externalABIs/BeefyZapOneInchAbi.json.cjs +1 -1
- package/externalABIs/BeefyZapOneInchAbi.json.mjs +2 -5
- package/externalABIs/ConvexBoosterAbi.json.cjs +1 -1
- package/externalABIs/ConvexBoosterAbi.json.mjs +2 -5
- package/externalABIs/ConvexBoosterAbiMainnet.json.cjs +1 -1
- package/externalABIs/ConvexBoosterAbiMainnet.json.mjs +2 -5
- package/externalABIs/ConvexRewardPoolAbi.json.cjs +1 -1
- package/externalABIs/ConvexRewardPoolAbi.json.mjs +2 -5
- package/externalABIs/CurveReadingWrapperAbi.json.cjs +1 -1
- package/externalABIs/CurveReadingWrapperAbi.json.mjs +2 -5
- package/externalABIs/CurveWrappedMainPool.json.cjs +1 -1
- package/externalABIs/CurveWrappedMainPool.json.mjs +2 -5
- package/externalABIs/CurveZap.json.cjs +1 -1
- package/externalABIs/CurveZap.json.mjs +2 -5
- package/externalABIs/CvxCrvUtilities.json.cjs +1 -1
- package/externalABIs/CvxCrvUtilities.json.mjs +2 -5
- package/externalABIs/ERC20.json.cjs +1 -1
- package/externalABIs/ERC20.json.mjs +3 -20
- package/externalABIs/GalxePassport.json.cjs +1 -1
- package/externalABIs/GalxePassport.json.mjs +3 -8
- package/externalABIs/IQuoterV2.json.cjs +1 -1
- package/externalABIs/IQuoterV2.json.mjs +3 -20
- package/externalABIs/ISwapRouter.json.cjs +1 -1
- package/externalABIs/ISwapRouter.json.mjs +2 -5
- package/externalABIs/IUniswapV3Factory.json.cjs +1 -1
- package/externalABIs/IUniswapV3Factory.json.mjs +3 -20
- package/externalABIs/IUniswapV3Pool.json.cjs +1 -1
- package/externalABIs/IUniswapV3Pool.json.mjs +3 -20
- package/externalABIs/PendleRouterAbi.json.cjs +1 -1
- package/externalABIs/PendleRouterAbi.json.mjs +2 -5
- package/externalABIs/UniswapV2PoolAbi.json.cjs +1 -1
- package/externalABIs/UniswapV2PoolAbi.json.mjs +3 -16
- package/externalABIs/index.d.ts +11 -307
- package/externalABIs/transactionsProver.json.cjs +1 -1
- package/externalABIs/transactionsProver.json.mjs +3 -20
- package/functions/kyc/zkMeHelper.cjs +1 -1
- package/functions/kyc/zkMeHelper.d.ts +1 -0
- package/functions/kyc/zkMeHelper.mjs +11 -8
- package/functions/pre-transaction/process-gas-estimates.cjs +1 -1
- package/functions/pre-transaction/process-gas-estimates.mjs +2 -3
- package/functions/private-wallet/emporium.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.helpers.d.ts +8 -3
- package/functions/private-wallet/emporium.helpers.mjs +23 -11
- package/functions/private-wallet/index.d.ts +1 -0
- package/functions/private-wallet/opProducer.cjs +1 -1
- package/functions/private-wallet/opProducer.mjs +10 -9
- package/functions/private-wallet/smartContractWalletCalculator.cjs +1 -0
- package/functions/private-wallet/smartContractWalletCalculator.d.ts +1 -0
- package/functions/private-wallet/smartContractWalletCalculator.mjs +20 -0
- package/functions/protocols/convex.protocols.cjs +1 -1
- package/functions/protocols/convex.protocols.mjs +2 -3
- package/functions/protocols/pendle.helpers.cjs +1 -1
- package/functions/protocols/pendle.helpers.mjs +13 -14
- package/functions/snarkjs/constant.cjs +1 -1
- package/functions/snarkjs/constant.d.ts +0 -1
- package/functions/snarkjs/constant.mjs +5 -6
- package/functions/snarkjs/constructEmporiumProof.cjs +1 -1
- package/functions/snarkjs/constructEmporiumProof.d.ts +1 -1
- package/functions/snarkjs/constructEmporiumProof.mjs +31 -31
- package/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
- package/functions/snarkjs/constructGeneralZkProof.d.ts +1 -1
- package/functions/snarkjs/constructGeneralZkProof.mjs +75 -76
- package/functions/snarkjs/generateZkProof.cjs +1 -1
- package/functions/snarkjs/generateZkProof.d.ts +1 -1
- package/functions/snarkjs/generateZkProof.mjs +15 -4
- package/functions/utils/axelar.utils.cjs +1 -1
- package/functions/utils/axelar.utils.mjs +2 -3
- package/functions/utils/cacheDevice.utils.cjs +1 -1
- package/functions/utils/cacheDevice.utils.mjs +8 -9
- package/functions/utils/erc20tokenFunctions.cjs +1 -1
- package/functions/utils/erc20tokenFunctions.mjs +7 -8
- package/functions/utils/evmNetworkFunctions.cjs +1 -1
- package/functions/utils/evmNetworkFunctions.mjs +3 -4
- package/functions/utils/string.utils.cjs +1 -1
- package/functions/utils/string.utils.d.ts +1 -0
- package/functions/utils/string.utils.mjs +16 -6
- package/functions/utils/userAgent.cjs +1 -1
- package/functions/utils/userAgent.mjs +8 -8
- package/functions/web3/functionCalls/accessTokenCalls.cjs +1 -1
- package/functions/web3/functionCalls/accessTokenCalls.mjs +8 -8
- package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/functions/web3/functionCalls/transactCallDirect.d.ts +1 -1
- package/functions/web3/functionCalls/transactCallDirect.mjs +29 -43
- package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.mjs +8 -10
- package/functions/web3/odosAPI.cjs +1 -1
- package/functions/web3/odosAPI.d.ts +2 -1
- package/functions/web3/odosAPI.mjs +18 -19
- package/functions/web3/oneInchAPI.cjs +1 -1
- package/functions/web3/oneInchAPI.d.ts +2 -1
- package/functions/web3/oneInchAPI.mjs +15 -17
- package/functions/web3/uniswapAPI.cjs +1 -1
- package/functions/web3/uniswapAPI.d.ts +4 -4
- package/functions/web3/uniswapAPI.mjs +43 -54
- package/index.cjs +1 -1
- package/index.mjs +641 -617
- package/package.json +2 -3
- package/providers/EthersProviderAdapter.cjs +1 -1
- package/providers/EthersProviderAdapter.d.ts +0 -1
- package/providers/EthersProviderAdapter.mjs +37 -26
- package/providers/WagmiProviderAdapter.cjs +1 -1
- package/providers/WagmiProviderAdapter.d.ts +0 -1
- package/providers/WagmiProviderAdapter.mjs +56 -45
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.mjs +2 -4
- package/providers/prepareWagmiHinkal.cjs +1 -1
- package/providers/prepareWagmiHinkal.mjs +2 -4
- package/types/ethereum-network.types.cjs +1 -1
- package/types/ethereum-network.types.d.ts +61 -62
- package/types/ethereum-network.types.mjs +1 -1
- package/types/hinkal.types.d.ts +0 -4
- package/types/kyc.types.cjs +1 -1
- package/types/kyc.types.d.ts +1 -1
- package/types/kyc.types.mjs +1 -1
- package/types/rewards.types.d.ts +0 -5
- package/types/time.types.cjs +1 -1
- package/types/time.types.mjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
- package/constants/token-data/index.cjs +0 -1
- package/constants/token-data/index.mjs +0 -34
- package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.cjs +0 -1
- package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.d.ts +0 -3
- package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.mjs +0 -9
- package/externalABIs/index.cjs +0 -1
- package/externalABIs/index.mjs +0 -23
- package/functions/snarkjs/generateZkProofEnclave.cjs +0 -1
- package/functions/snarkjs/generateZkProofEnclave.d.ts +0 -5
- package/functions/snarkjs/generateZkProofEnclave.mjs +0 -33
- package/functions/snarkjs/generateZkProofSelf.cjs +0 -1
- package/functions/snarkjs/generateZkProofSelf.d.ts +0 -5
- package/functions/snarkjs/generateZkProofSelf.mjs +0 -17
- package/functions/web3/getContractMetadata.cjs +0 -1
- package/functions/web3/getContractMetadata.d.ts +0 -5
- package/functions/web3/getContractMetadata.mjs +0 -30
- package/types/remote-proof.types.d.ts +0 -15
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { utils as
|
|
1
|
+
import { utils as H } from "ethers";
|
|
2
2
|
import { zeroAddress as R } from "../../constants/protocol.constants.mjs";
|
|
3
|
-
import { networkRegistry as
|
|
3
|
+
import { networkRegistry as O } from "../../constants/chains.constants.mjs";
|
|
4
4
|
import { getERC20Token as g } from "../../functions/utils/erc20tokenFunctions.mjs";
|
|
5
|
-
import { getFlatFees as
|
|
6
|
-
import { processAmountChanges as
|
|
7
|
-
import { constructZkProof as
|
|
8
|
-
import { outputUtxoProcessing as
|
|
9
|
-
import { addPaddingToUtxos as
|
|
10
|
-
import { estimateGasRelayer as
|
|
5
|
+
import { getFlatFees as U } from "../../functions/pre-transaction/getFlatFees.mjs";
|
|
6
|
+
import { processAmountChanges as b } from "../../functions/pre-transaction/processAmountChanges.mjs";
|
|
7
|
+
import { constructZkProof as k } from "../../functions/snarkjs/constructGeneralZkProof.mjs";
|
|
8
|
+
import { outputUtxoProcessing as L } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
|
|
9
|
+
import { addPaddingToUtxos as N } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
10
|
+
import { estimateGasRelayer as $ } from "../../functions/web3/functionCalls/estimateGasRelayer.mjs";
|
|
11
11
|
import { transactCallRelayer as v } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
12
12
|
import { transactCallDirect as A } from "../../functions/web3/functionCalls/transactCallDirect.mjs";
|
|
13
13
|
import { ContractType as E } from "../../types/ethereum-network.types.mjs";
|
|
@@ -30,7 +30,7 @@ const _ = (t) => {
|
|
|
30
30
|
r.Redeem,
|
|
31
31
|
r.Checkpoint
|
|
32
32
|
].includes(t.pendleAction))
|
|
33
|
-
return
|
|
33
|
+
return H.defaultAbiCoder.encode(
|
|
34
34
|
["uint8", "address", "uint256", "uint256", "address", "bool", "bytes"],
|
|
35
35
|
[
|
|
36
36
|
s,
|
|
@@ -44,7 +44,7 @@ const _ = (t) => {
|
|
|
44
44
|
);
|
|
45
45
|
throw new Error("Not implemented");
|
|
46
46
|
}, ut = async (t, e, s, a, c, d = !1) => {
|
|
47
|
-
const i = G.Pendle, { pendleAction: n } = a, f = [...await
|
|
47
|
+
const i = G.Pendle, { pendleAction: n } = a, f = [...await N(t, e, s)], T = `swapperMO${s.length.toString()}x${f[0].length}x1`, { flatFees: w, feeUnit: D } = await U(
|
|
48
48
|
t.getCurrentChainId(),
|
|
49
49
|
e,
|
|
50
50
|
i,
|
|
@@ -52,7 +52,7 @@ const _ = (t) => {
|
|
|
52
52
|
n,
|
|
53
53
|
c
|
|
54
54
|
);
|
|
55
|
-
s =
|
|
55
|
+
s = b({
|
|
56
56
|
erc20Addresses: e,
|
|
57
57
|
amountChanges: s,
|
|
58
58
|
flatFees: w,
|
|
@@ -61,39 +61,38 @@ const _ = (t) => {
|
|
|
61
61
|
action: n,
|
|
62
62
|
gasTokenAddress: c
|
|
63
63
|
});
|
|
64
|
-
const
|
|
64
|
+
const x = [];
|
|
65
65
|
for (let o = 0; o < e.length; o += 1) {
|
|
66
|
-
const { outputUtxos: p } =
|
|
67
|
-
|
|
66
|
+
const { outputUtxos: p } = L(t.userKeys, f[o], s[o]);
|
|
67
|
+
x.push(p);
|
|
68
68
|
}
|
|
69
|
-
const S = _(n), { contractData: I } =
|
|
70
|
-
if (!
|
|
69
|
+
const S = _(n), { contractData: I } = O[t.getCurrentChainId()], P = I?.pendleExternalActionInstanceAddress, Y = B(a, f), y = n === r.Deposit || a.isRelayerOff ? R : await t.getRandomRelay();
|
|
70
|
+
if (!y)
|
|
71
71
|
throw Error(K.RELAYER_NOT_AVAILABLE);
|
|
72
|
-
const W = `0x0${n.toString(16)}`,
|
|
72
|
+
const W = `0x0${n.toString(16)}`, h = { ...z, preHookMetadata: W }, { zkCallData: m, circomData: u, dimData: l } = await k(
|
|
73
73
|
t.merkleTreeHinkal,
|
|
74
74
|
t.merkleTreeAccessToken,
|
|
75
75
|
f,
|
|
76
|
-
|
|
76
|
+
x,
|
|
77
77
|
t.userKeys,
|
|
78
78
|
T,
|
|
79
79
|
i,
|
|
80
80
|
P,
|
|
81
81
|
Y,
|
|
82
|
-
|
|
83
|
-
x,
|
|
82
|
+
y,
|
|
84
83
|
t.getCurrentChainId(),
|
|
85
84
|
S,
|
|
86
85
|
w,
|
|
87
|
-
|
|
86
|
+
h
|
|
88
87
|
);
|
|
89
88
|
if (d)
|
|
90
|
-
return await
|
|
89
|
+
return await $(t, m, l, u);
|
|
91
90
|
const C = t.getCurrentChainId();
|
|
92
91
|
if (n === r.Deposit) {
|
|
93
92
|
const o = g(a.ytAddress, C);
|
|
94
93
|
if (!o)
|
|
95
94
|
throw Error("Yt Token not found");
|
|
96
|
-
const p = t.getContractWithSigner(E.PendleGeneralExternalAction),
|
|
95
|
+
const p = t.getContractWithSigner(E.PendleGeneralExternalAction), F = t.getContractWithSigner(E.HinkalWrapper);
|
|
97
96
|
return await A(
|
|
98
97
|
t,
|
|
99
98
|
s[0],
|
|
@@ -102,7 +101,7 @@ const _ = (t) => {
|
|
|
102
101
|
u,
|
|
103
102
|
l,
|
|
104
103
|
p,
|
|
105
|
-
|
|
104
|
+
F
|
|
106
105
|
);
|
|
107
106
|
}
|
|
108
107
|
if (n === r.Withdraw && a.isRelayerOff) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("ethers"),U=require("../../types/circom-data.types.cjs"),D=require("../../types/external-action.types.cjs"),y=require("../../types/hinkal.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");const A=require("../../functions/web3/events/getShieldedBalance.cjs"),I=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),_=require("../../functions/pre-transaction/getFlatFees.cjs"),b=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),k=require("../../functions/pre-transaction/processAmountChanges.cjs"),S=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),T=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),F=require("../../constants/chains.constants.cjs"),G=require("../../error-handling/error-codes.constants.cjs"),O=(t,e)=>{if(t===y.PendleLPAction.AddOrRemoveLiquidity)return e.length===3?[!1,!0,!1]:[!1,!0,!1,!1];if(t===y.PendleLPAction.Checkpoint)return[!1,!0];throw new Error("Unknown PendleLPAction not implemented")},v=(t,e)=>{const{pendleLPAction:n,lpAddress:r,evmData:o}=t;return E.ethers.utils.defaultAbiCoder.encode(["uint8","address","uint256","uint256","bytes"],[n,r,e[0][0].amount,e[0][0].timeStamp,o])},M=async(t,e,n,r,o,g=!1)=>{const i=D.ExternalActionId.PendleLP,{pendleLPAction:c}=r,s=[...await A.addPaddingToUtxos(t,e,n)],f=`swapperMO${n.length.toString()}x${s[0].length}x1`,{flatFees:l,feeUnit:C}=await _.getFlatFees(t.getCurrentChainId(),e,i,n,c,o);n=k.processAmountChanges({erc20Addresses:e,amountChanges:n,flatFees:l,feeUnit:C,externalActionId:i,action:c,gasTokenAddress:o});const u=[];for(let a=0;a<e.length;a+=1){const{outputUtxos:h}=b.outputUtxoProcessing(t.userKeys,s[a],n[a]);u.push(h)}const q=O(c,e),{contractData:x}=F.networkRegistry[t.getCurrentChainId()],w=x?.pendleLPExternalActionInstanceAddress,L=v(r,s),d=await t.getRandomRelay();if(!d)throw Error(G.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const R={...U.defaultHookData},{zkCallData:m,circomData:P,dimData:p}=await I.constructZkProof(t.merkleTreeHinkal,t.merkleTreeAccessToken,s,u,t.userKeys,f,i,w,L,d,t.getCurrentChainId(),q,l,R);return g?await S.estimateGasRelayer(t,m,p,P):await T.transactCallRelayer(t.getCurrentChainId(),m,p,P)},B=async(t,e,n)=>{const r=[...await A.addPaddingToUtxos(t,[e],[-1n*n])];return{amount:r[0][0].amount,timestamp:r[0][0].timeStamp}};exports.hinkalActionPendleLP=M;exports.hinkalGetPendleLPClaimableParams=B;
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import { ethers as D } from "ethers";
|
|
2
2
|
import { defaultHookData as U } from "../../types/circom-data.types.mjs";
|
|
3
|
-
import { ExternalActionId as
|
|
3
|
+
import { ExternalActionId as h } from "../../types/external-action.types.mjs";
|
|
4
4
|
import { PendleLPAction as A } from "../../types/hinkal.types.mjs";
|
|
5
5
|
import "../../types/transactions.types.mjs";
|
|
6
6
|
import "../../types/curve.types.mjs";
|
|
7
7
|
import { addPaddingToUtxos as y } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
8
|
-
import { constructZkProof as
|
|
9
|
-
import { getFlatFees as
|
|
10
|
-
import { outputUtxoProcessing as
|
|
8
|
+
import { constructZkProof as O } from "../../functions/snarkjs/constructGeneralZkProof.mjs";
|
|
9
|
+
import { getFlatFees as T } from "../../functions/pre-transaction/getFlatFees.mjs";
|
|
10
|
+
import { outputUtxoProcessing as b } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
|
|
11
11
|
import { processAmountChanges as F } from "../../functions/pre-transaction/processAmountChanges.mjs";
|
|
12
12
|
import { estimateGasRelayer as S } from "../../functions/web3/functionCalls/estimateGasRelayer.mjs";
|
|
13
|
-
import { transactCallRelayer as
|
|
14
|
-
import { networkRegistry as
|
|
15
|
-
import { transactionErrorCodes as
|
|
16
|
-
const
|
|
13
|
+
import { transactCallRelayer as k } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
14
|
+
import { networkRegistry as v } from "../../constants/chains.constants.mjs";
|
|
15
|
+
import { transactionErrorCodes as G } from "../../error-handling/error-codes.constants.mjs";
|
|
16
|
+
const H = (t, e) => {
|
|
17
17
|
if (t === A.AddOrRemoveLiquidity)
|
|
18
18
|
return e.length === 3 ? [!1, !0, !1] : [!1, !0, !1, !1];
|
|
19
19
|
if (t === A.Checkpoint)
|
|
20
20
|
return [!1, !0];
|
|
21
21
|
throw new Error("Unknown PendleLPAction not implemented");
|
|
22
|
-
},
|
|
22
|
+
}, K = (t, e) => {
|
|
23
23
|
const { pendleLPAction: o, lpAddress: r, evmData: a } = t;
|
|
24
24
|
return D.utils.defaultAbiCoder.encode(
|
|
25
25
|
["uint8", "address", "uint256", "uint256", "bytes"],
|
|
26
26
|
[o, r, e[0][0].amount, e[0][0].timeStamp, a]
|
|
27
27
|
);
|
|
28
28
|
}, et = async (t, e, o, r, a, P = !1) => {
|
|
29
|
-
const s =
|
|
29
|
+
const s = h.PendleLP, { pendleLPAction: m } = r, i = [...await y(t, e, o)], x = `swapperMO${o.length.toString()}x${i[0].length}x1`, { flatFees: c, feeUnit: C } = await T(
|
|
30
30
|
t.getCurrentChainId(),
|
|
31
31
|
e,
|
|
32
32
|
s,
|
|
@@ -38,37 +38,36 @@ const K = (t, e) => {
|
|
|
38
38
|
erc20Addresses: e,
|
|
39
39
|
amountChanges: o,
|
|
40
40
|
flatFees: c,
|
|
41
|
-
feeUnit:
|
|
41
|
+
feeUnit: C,
|
|
42
42
|
externalActionId: s,
|
|
43
43
|
action: m,
|
|
44
44
|
gasTokenAddress: a
|
|
45
45
|
});
|
|
46
46
|
const l = [];
|
|
47
47
|
for (let n = 0; n < e.length; n += 1) {
|
|
48
|
-
const { outputUtxos: I } =
|
|
48
|
+
const { outputUtxos: I } = b(t.userKeys, i[n], o[n]);
|
|
49
49
|
l.push(I);
|
|
50
50
|
}
|
|
51
|
-
const
|
|
51
|
+
const g = H(m, e), { contractData: w } = v[t.getCurrentChainId()], E = w?.pendleLPExternalActionInstanceAddress, L = K(r, i), p = await t.getRandomRelay();
|
|
52
52
|
if (!p)
|
|
53
|
-
throw Error(
|
|
54
|
-
const
|
|
53
|
+
throw Error(G.RELAYER_NOT_AVAILABLE);
|
|
54
|
+
const R = { ...U }, { zkCallData: u, circomData: f, dimData: d } = await O(
|
|
55
55
|
t.merkleTreeHinkal,
|
|
56
56
|
t.merkleTreeAccessToken,
|
|
57
57
|
i,
|
|
58
58
|
l,
|
|
59
59
|
t.userKeys,
|
|
60
|
-
|
|
60
|
+
x,
|
|
61
61
|
s,
|
|
62
62
|
E,
|
|
63
|
-
|
|
64
|
-
t.generateProofRemotely,
|
|
63
|
+
L,
|
|
65
64
|
p,
|
|
66
65
|
t.getCurrentChainId(),
|
|
67
|
-
|
|
66
|
+
g,
|
|
68
67
|
c,
|
|
69
|
-
|
|
68
|
+
R
|
|
70
69
|
);
|
|
71
|
-
return P ? await S(t,
|
|
70
|
+
return P ? await S(t, u, d, f) : await k(t.getCurrentChainId(), u, d, f);
|
|
72
71
|
}, ot = async (t, e, o) => {
|
|
73
72
|
const r = [...await y(t, [e], [-1n * o])];
|
|
74
73
|
return { amount: r[0][0].amount, timestamp: r[0][0].timeStamp };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../../constants/protocol.constants.cjs"),p=require("../../functions/staking/index.cjs"),f=require("../../functions/utils/erc20tokenFunctions.cjs"),B=require("../../functions/web3/etherFunctions.cjs"),O=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),_=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),b=require("../../functions/web3/events/getShieldedBalance.cjs"),l=require("../utxo/Utxo.cjs");require("../../types/circom-data.types.cjs");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../../constants/protocol.constants.cjs"),p=require("../../functions/staking/index.cjs"),f=require("../../functions/utils/erc20tokenFunctions.cjs"),B=require("../../functions/web3/etherFunctions.cjs"),O=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),_=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),b=require("../../functions/web3/events/getShieldedBalance.cjs"),l=require("../utxo/Utxo.cjs");require("../../types/circom-data.types.cjs");const S=require("../../types/ethereum-network.types.cjs"),M=require("../../types/external-action.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");const m=require("../../types/hinkal.stake.types.cjs");require("ethers");const j=require("../crypto-keys/keys.cjs");require("libsodium-wrappers");const w=require("../../functions/web3/functionCalls/transactCallDirect.cjs"),z=async(t,g,o,s,a)=>{const C=await t.getEthereumAddress(),i=f.getERC20Token(g[0],t.getCurrentChainId());if(!i)throw Error("Deposit Action: No Token Found");const u=s===m.HinkalStakeMode.Stake,n=s===m.HinkalStakeMode.Unstake,{erc20TokenAddress:E}=i,r=[...await b.addPaddingToUtxos(t,g,o,2,void 0,s!==m.HinkalStakeMode.Deposit)];if(u||n){r[0][0]=l.Utxo.createFrom(r[0][0],{amount:o[0]*(u?1n:-1n),isStakeOrUnstakeInput:!0});for(let e=0;e<r.length;e+=1)for(let c=0;c<r[e].length;c+=1)e===0&&c===0||(r[e][c]=l.Utxo.createFrom(r[e][c],{amount:0n}))}const{outputUtxos:H}=O.outputUtxoProcessing(t.userKeys,r[0],o[0]),d=[H.map(e=>l.Utxo.createFrom(e,{isStake:u,isUnstakeOutput:n}))];n&&(d[0][0]=l.Utxo.createFrom(d[0][0],{amount:0n,isUnstakeOutput:n}));const P=[!1],k=B.randomBigInt(30),h=j.UserKeys.getEncryptionKeyPair(t.userKeys.getShieldedPrivateKey()),K=p.encryptStake(k,a,T.ownerPublicKey),D=p.encryptStake(k,a,h.publicKey),F=n?0n:p.createStakeCommitment(!0,a,k,E,o[0],BigInt(d[0][0].timeStamp)),I=u?0:1,v=p.encodeHStakeMetadata(I,F,C,K,D),x=t.getContractWithSigner(S.ContractType.HinkalWrapper2),y=t.getContractWithSigner(S.ContractType.HinkalStakeExternalAction),{zkCallData:q,dimData:A,circomData:U}=await _.constructZkProof(t.merkleTreeHinkal,t.merkleTreeAccessToken,r,d,t.userKeys,"swapperME1x2x1",M.ExternalActionId.HinkalStake,y.address,v,T.zeroAddress,t.getCurrentChainId(),P,void 0,void 0,{stakedTokenRecipient:a,stakeBlinding:k,mode:s,depositorAddress:C});if(n){const e=f.getHToken(i,t.getCurrentChainId());if(!e)throw new Error("hToken not found");const W=(await t.getContractWithFetcher(S.ContractType.HToken,e.erc20TokenAddress).previewWithdraw(-o[0])).toBigInt();return w.transactCallDirect(t,W,e,q,U,A,y,x)}return w.transactCallDirect(t,o[0],i,q,U,A,y,x)};exports.hinkalActionStake=z;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { IHinkal } from './IHinkal';
|
|
2
2
|
import { HinkalStakeMode } from '../../types';
|
|
3
|
-
export declare const hinkalActionStake: (hinkal: IHinkal, erc20Addresses: string[], amountChanges: bigint[], stakeMode: HinkalStakeMode, stakedTokenRecipient: string) => Promise<
|
|
3
|
+
export declare const hinkalActionStake: (hinkal: IHinkal, erc20Addresses: string[], amountChanges: bigint[], stakeMode: HinkalStakeMode, stakedTokenRecipient: string) => Promise<import("ethers").ContractTransaction>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ownerPublicKey as v, zeroAddress as
|
|
2
|
-
import { encryptStake as T, createStakeCommitment as
|
|
1
|
+
import { ownerPublicKey as v, zeroAddress as h } from "../../constants/protocol.constants.mjs";
|
|
2
|
+
import { encryptStake as T, createStakeCommitment as B, encodeHStakeMetadata as O } from "../../functions/staking/index.mjs";
|
|
3
3
|
import { getERC20Token as b, getHToken as z } from "../../functions/utils/erc20tokenFunctions.mjs";
|
|
4
4
|
import { randomBigInt as j } from "../../functions/web3/etherFunctions.mjs";
|
|
5
5
|
import { outputUtxoProcessing as M } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
|
|
@@ -51,14 +51,14 @@ const pt = async (t, g, e, a, s) => {
|
|
|
51
51
|
amount: 0n,
|
|
52
52
|
isUnstakeOutput: n
|
|
53
53
|
}));
|
|
54
|
-
const K = [!1], d = j(30), H = G.getEncryptionKeyPair(t.userKeys.getShieldedPrivateKey()), I = T(d, s, v), P = T(d, s, H.publicKey), D = n ? 0n :
|
|
54
|
+
const K = [!1], d = j(30), H = G.getEncryptionKeyPair(t.userKeys.getShieldedPrivateKey()), I = T(d, s, v), P = T(d, s, H.publicKey), D = n ? 0n : B(
|
|
55
55
|
!0,
|
|
56
56
|
s,
|
|
57
57
|
d,
|
|
58
58
|
U,
|
|
59
59
|
e[0],
|
|
60
60
|
BigInt(p[0][0].timeStamp)
|
|
61
|
-
), F =
|
|
61
|
+
), F = O(
|
|
62
62
|
m ? 0 : 1,
|
|
63
63
|
D,
|
|
64
64
|
A,
|
|
@@ -74,8 +74,7 @@ const pt = async (t, g, e, a, s) => {
|
|
|
74
74
|
q.HinkalStake,
|
|
75
75
|
f.address,
|
|
76
76
|
F,
|
|
77
|
-
|
|
78
|
-
B,
|
|
77
|
+
h,
|
|
79
78
|
t.getCurrentChainId(),
|
|
80
79
|
K,
|
|
81
80
|
void 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("../../constants/protocol.constants.cjs"),m=require("../../functions/utils/erc20tokenFunctions.cjs"),P=require("../../functions/pre-transaction/getFlatFees.cjs"),U=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),H=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),N=require("../../functions/web3/events/getShieldedBalance.cjs"),f=require("../../functions/web3/functionCalls/transactCallDirect.cjs"),W=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),b=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),E=require("../volatile-helper/VolatileHelper.cjs"),n=require("../../types/hinkal.types.cjs"),q=require("../../types/ethereum-network.types.cjs"),M=require("../../types/external-action.types.cjs"),z=require("../../error-handling/error-codes.constants.cjs"),G=async(t,a,e,D,R)=>{const{action:r,isRelayerOff:i,recipientAddress:T,baseExternalActionId:I,baseExternalActionMetadata:S}=D,p=m.getERC20Token(a[0],t.getCurrentChainId());if(!p)throw Error("Deposit Action: No Token Found");const A=[...e],F=[...a];let g=[],y=e.map(()=>0n);({erc20Addresses:a,amountChanges:e,onChainCreation:g}=await E.VolatileHelper.processVolatileData(t.getCurrentChainId(),r,a,e));const c=await E.VolatileHelper.getVolatileExternalData(t,r,A,T,I,S);if(!c)throw Error("No External Action Data");(r===n.VolatileAction.Withdraw&&!i||r===n.VolatileAction.Swap)&&({flatFees:y}=await P.getFlatFees(t.getCurrentChainId(),F,M.ExternalActionId.Volatile,A,r),r===n.VolatileAction.Swap&&(e[1]=0n));const d=[...await N.addPaddingToUtxos(t,a,e)],_=`swapperM${e.length.toString()}x${d[0].length}x1`,w=[];for(let o=0;o<a.length;o+=1){const{outputUtxos:x}=U.outputUtxoProcessing(t.userKeys,d[o],e[o]);w.push(x)}const C=r===n.VolatileAction.Deposit||i?V.zeroAddress:await t.getRandomRelay();if(!i&&!C)throw Error(z.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const{zkCallData:s,circomData:l,dimData:u}=await H.constructZkProof(t.merkleTreeHinkal,t.merkleTreeAccessToken,d,w,t.userKeys,_,c.externalActionId,c.externalAddress,c.externalActionMetadata,i?V.zeroAddress:C,t.getCurrentChainId(),g,y);if(r===n.VolatileAction.Deposit){const o=t.getContractWithSigner(q.ContractType.VolatileVault),x=t.getContractWithSigner(q.ContractType.HinkalWrapper);return await f.transactCallDirect(t,A[0],p,s,l,u,o,x)}return r===n.VolatileAction.Withdraw&&i?await f.transactCallDirect(t,e[0],p,s,l,u):R?await b.estimateGasRelayer(t,s,u,l):await W.transactCallRelayer(t.getCurrentChainId(),s,u,l)};exports.hinkalActionVolatile=G;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { IHinkal } from './IHinkal';
|
|
2
2
|
import { VolatileHelperData } from '../../types/hinkal.types';
|
|
3
|
-
export declare const hinkalActionVolatile: (hinkal: IHinkal, erc20Addresses: string[], amountChanges: bigint[], volatileHelperData: VolatileHelperData, onlyGasEstimate: boolean) => Promise<
|
|
3
|
+
export declare const hinkalActionVolatile: (hinkal: IHinkal, erc20Addresses: string[], amountChanges: bigint[], volatileHelperData: VolatileHelperData, onlyGasEstimate: boolean) => Promise<bigint | import('../../index.ts').RelayerTransaction | import("ethers").ContractTransaction>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { zeroAddress as E } from "../../constants/protocol.constants.mjs";
|
|
2
2
|
import { getERC20Token as F } from "../../functions/utils/erc20tokenFunctions.mjs";
|
|
3
3
|
import { getFlatFees as N } from "../../functions/pre-transaction/getFlatFees.mjs";
|
|
4
|
-
import { outputUtxoProcessing as
|
|
5
|
-
import { constructZkProof as
|
|
6
|
-
import { addPaddingToUtxos as
|
|
4
|
+
import { outputUtxoProcessing as H } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
|
|
5
|
+
import { constructZkProof as L } from "../../functions/snarkjs/constructGeneralZkProof.mjs";
|
|
6
|
+
import { addPaddingToUtxos as M } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
7
7
|
import { transactCallDirect as y } from "../../functions/web3/functionCalls/transactCallDirect.mjs";
|
|
8
|
-
import { transactCallRelayer as
|
|
8
|
+
import { transactCallRelayer as P } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
9
9
|
import { estimateGasRelayer as b } from "../../functions/web3/functionCalls/estimateGasRelayer.mjs";
|
|
10
10
|
import { VolatileHelper as C } from "../volatile-helper/VolatileHelper.mjs";
|
|
11
11
|
import { VolatileAction as i } from "../../types/hinkal.types.mjs";
|
|
@@ -41,15 +41,15 @@ const rt = async (t, a, r, R, T) => {
|
|
|
41
41
|
f,
|
|
42
42
|
o
|
|
43
43
|
), o === i.Swap && (r[1] = 0n));
|
|
44
|
-
const x = [...await
|
|
44
|
+
const x = [...await M(t, a, r)], W = `swapperM${r.length.toString()}x${x[0].length}x1`, g = [];
|
|
45
45
|
for (let e = 0; e < a.length; e += 1) {
|
|
46
|
-
const { outputUtxos: d } =
|
|
46
|
+
const { outputUtxos: d } = H(t.userKeys, x[e], r[e]);
|
|
47
47
|
g.push(d);
|
|
48
48
|
}
|
|
49
49
|
const u = o === i.Deposit || n ? E : await t.getRandomRelay();
|
|
50
50
|
if (!n && !u)
|
|
51
51
|
throw Error(K.RELAYER_NOT_AVAILABLE);
|
|
52
|
-
const { zkCallData: s, circomData: p, dimData: l } = await
|
|
52
|
+
const { zkCallData: s, circomData: p, dimData: l } = await L(
|
|
53
53
|
t.merkleTreeHinkal,
|
|
54
54
|
t.merkleTreeAccessToken,
|
|
55
55
|
x,
|
|
@@ -59,7 +59,6 @@ const rt = async (t, a, r, R, T) => {
|
|
|
59
59
|
c.externalActionId,
|
|
60
60
|
c.externalAddress,
|
|
61
61
|
c.externalActionMetadata,
|
|
62
|
-
t.generateProofRemotely,
|
|
63
62
|
n ? E : u,
|
|
64
63
|
t.getCurrentChainId(),
|
|
65
64
|
w,
|
|
@@ -78,7 +77,7 @@ const rt = async (t, a, r, R, T) => {
|
|
|
78
77
|
d
|
|
79
78
|
);
|
|
80
79
|
}
|
|
81
|
-
return o === i.Withdraw && n ? await y(t, r[0], m, s, p, l) : T ? await b(t, s, l, p) : await
|
|
80
|
+
return o === i.Withdraw && n ? await y(t, r[0], m, s, p, l) : T ? await b(t, s, l, p) : await P(t.getCurrentChainId(), s, l, p);
|
|
82
81
|
};
|
|
83
82
|
export {
|
|
84
83
|
rt as hinkalActionVolatile
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../../constants/protocol.constants.cjs"),C=require("../../functions/utils/erc20tokenFunctions.cjs"),I=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),D=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),f=require("../../functions/web3/events/getShieldedBalance.cjs"),h=require("../../functions/web3/functionCalls/transactCallDirect.cjs"),y=require("../utxo/Utxo.cjs"),k=require("../../error-handling/error-codes.constants.cjs"),q=async(t,n,r)=>{const a=C.getERC20Token(n[0],t.getCurrentChainId());if(!a)throw Error("Deposit Action: No Token Found");const c=r[0],e={externalActionId:0n,externalAddress:await t.getEthereumAddress(),externalActionMetadata:"0x00"},o=[...await f.addPaddingToUtxos(t,n,r)],d=`swapperM${r.length.toString()}x${o[0].length}x1`,i=[];for(let s=0;s<n.length;s+=1){const{outputUtxos:p}=I.outputUtxoProcessing(t.userKeys,o[s],r[s]);i.push(p)}const{zkCallData:l,circomData:x,dimData:g}=await D.constructZkProof(t.merkleTreeHinkal,t.merkleTreeAccessToken,o,i,t.userKeys,d,e.externalActionId,e.externalAddress,e.externalActionMetadata,T.zeroAddress,t.getCurrentChainId());return await h.transactCallDirect(t,c,a,l,x,g)},S=async(t,n,r,a)=>{const[c,e,o]=a.split(","),d=!c||!e||!o,i=e?.substring(0,2)!=="0x"||o?.substring(0,2)!=="0x",l=o?.length!==66||e?.length>66||e?.length<64,x=a?.includes('"');if(d||i||l||x)throw Error(k.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);const g=[BigInt(c)],A=[e],s=n.map(u=>[new y.Utxo({amount:0n,erc20TokenAddress:u,shieldedPrivateKey:t.userKeys.getShieldedPrivateKey()}),new y.Utxo({amount:0n,erc20TokenAddress:u,shieldedPrivateKey:t.userKeys.getShieldedPrivateKey()})]),p=`swapperM${r.length.toString()}x${s[0].length}x1`,P=n.map((u,m)=>[new y.Utxo({amount:r[m],erc20TokenAddress:u,randomization:g[m],stealthAddress:A[m],encryptionKey:o})]),{zkCallData:U,circomData:E,dimData:K}=await D.constructZkProof(t.merkleTreeHinkal,t.merkleTreeAccessToken,s,P,t.userKeys,p,0n,await t.getEthereumAddress(),"0x00",T.zeroAddress,t.getCurrentChainId()),w=C.getERC20Token(n[0],t.getCurrentChainId());if(!w)throw Error("Withdraw Action: No Token Found");return await h.transactCallDirect(t,r[0],w,U,E,K)};exports.hinkalDeposit=q;exports.hinkalDepositForOther=S;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { IHinkal } from './IHinkal';
|
|
2
|
-
export declare const hinkalDeposit: (hinkal: IHinkal, erc20Addresses: string[], amountChanges: bigint[]) => Promise<
|
|
3
|
-
export declare const hinkalDepositForOther: (hinkal: IHinkal, erc20Addresses: string[], amountChanges: bigint[], recipinetInfo: string) => Promise<
|
|
2
|
+
export declare const hinkalDeposit: (hinkal: IHinkal, erc20Addresses: string[], amountChanges: bigint[]) => Promise<import("ethers").ContractTransaction>;
|
|
3
|
+
export declare const hinkalDepositForOther: (hinkal: IHinkal, erc20Addresses: string[], amountChanges: bigint[], recipinetInfo: string) => Promise<import("ethers").ContractTransaction>;
|
|
@@ -1,110 +1,71 @@
|
|
|
1
|
-
import { zeroAddress as
|
|
2
|
-
import { getERC20Token as
|
|
3
|
-
import { outputUtxoProcessing as
|
|
4
|
-
import { constructZkProof as
|
|
5
|
-
import { addPaddingToUtxos as
|
|
6
|
-
import { transactCallDirect as
|
|
7
|
-
import { Utxo as
|
|
8
|
-
import { transactionErrorCodes as
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import "../../types/transactions.types.mjs";
|
|
12
|
-
import "../../types/curve.types.mjs";
|
|
13
|
-
const K = async (t) => {
|
|
14
|
-
const e = await t.checkAccessToken(), o = e ? void 0 : t.getContractWithSigner(F.CrossChainAccessTokenManagerContract);
|
|
15
|
-
return { externalActionData: {
|
|
16
|
-
externalActionId: 0n,
|
|
17
|
-
externalAddress: e ? await t.getEthereumAddress() : o?.address || "",
|
|
18
|
-
externalActionMetadata: "0x00"
|
|
19
|
-
}, contractTransaction: o, contractToApprove: o, hasAccessToken: e };
|
|
20
|
-
}, G = async (t, e, o) => {
|
|
21
|
-
const a = P(e[0], t.getCurrentChainId());
|
|
1
|
+
import { zeroAddress as T } from "../../constants/protocol.constants.mjs";
|
|
2
|
+
import { getERC20Token as f } from "../../functions/utils/erc20tokenFunctions.mjs";
|
|
3
|
+
import { outputUtxoProcessing as P } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
|
|
4
|
+
import { constructZkProof as C } from "../../functions/snarkjs/constructGeneralZkProof.mjs";
|
|
5
|
+
import { addPaddingToUtxos as U } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
6
|
+
import { transactCallDirect as D } from "../../functions/web3/functionCalls/transactCallDirect.mjs";
|
|
7
|
+
import { Utxo as A } from "../utxo/Utxo.mjs";
|
|
8
|
+
import { transactionErrorCodes as z } from "../../error-handling/error-codes.constants.mjs";
|
|
9
|
+
const k = async (t, n, r) => {
|
|
10
|
+
const a = f(n[0], t.getCurrentChainId());
|
|
22
11
|
if (!a)
|
|
23
12
|
throw Error("Deposit Action: No Token Found");
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
13
|
+
const i = r[0], e = {
|
|
14
|
+
externalActionId: 0n,
|
|
15
|
+
externalAddress: await t.getEthereumAddress(),
|
|
16
|
+
externalActionMetadata: "0x00"
|
|
17
|
+
}, o = [...await U(t, n, r)], m = `swapperM${r.length.toString()}x${o[0].length}x1`, c = [];
|
|
18
|
+
for (let s = 0; s < n.length; s += 1) {
|
|
19
|
+
const { outputUtxos: l } = P(t.userKeys, o[s], r[s]);
|
|
20
|
+
c.push(l);
|
|
28
21
|
}
|
|
29
|
-
const { zkCallData:
|
|
22
|
+
const { zkCallData: u, circomData: p, dimData: x } = await C(
|
|
30
23
|
t.merkleTreeHinkal,
|
|
31
24
|
t.merkleTreeAccessToken,
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
o,
|
|
26
|
+
c,
|
|
34
27
|
t.userKeys,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
t.generateProofRemotely,
|
|
40
|
-
D,
|
|
41
|
-
t.getCurrentChainId(),
|
|
42
|
-
void 0,
|
|
43
|
-
void 0,
|
|
44
|
-
void 0,
|
|
45
|
-
void 0,
|
|
46
|
-
d
|
|
47
|
-
);
|
|
48
|
-
return await I(
|
|
49
|
-
t,
|
|
50
|
-
u,
|
|
51
|
-
a,
|
|
52
|
-
l,
|
|
53
|
-
p,
|
|
28
|
+
m,
|
|
29
|
+
e.externalActionId,
|
|
30
|
+
e.externalAddress,
|
|
31
|
+
e.externalActionMetadata,
|
|
54
32
|
T,
|
|
55
|
-
|
|
56
|
-
n,
|
|
57
|
-
d
|
|
33
|
+
t.getCurrentChainId()
|
|
58
34
|
);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
new
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
35
|
+
return await D(t, i, a, u, p, x);
|
|
36
|
+
}, H = async (t, n, r, a) => {
|
|
37
|
+
const [i, e, o] = a.split(","), m = !i || !e || !o, c = e?.substring(0, 2) !== "0x" || o?.substring(0, 2) !== "0x", u = o?.length !== 66 || e?.length > 66 || e?.length < 64, p = a?.includes('"');
|
|
38
|
+
if (m || c || u || p)
|
|
39
|
+
throw Error(z.RECIPIENT_FORMAT_INCORRECT);
|
|
40
|
+
const x = [BigInt(i)], y = [e], s = n.map((d) => [
|
|
41
|
+
new A({ amount: 0n, erc20TokenAddress: d, shieldedPrivateKey: t.userKeys.getShieldedPrivateKey() }),
|
|
42
|
+
new A({ amount: 0n, erc20TokenAddress: d, shieldedPrivateKey: t.userKeys.getShieldedPrivateKey() })
|
|
43
|
+
]), l = `swapperM${r.length.toString()}x${s[0].length}x1`, E = n.map((d, g) => [
|
|
44
|
+
new A({
|
|
45
|
+
amount: r[g],
|
|
46
|
+
erc20TokenAddress: d,
|
|
47
|
+
randomization: x[g],
|
|
48
|
+
stealthAddress: y[g],
|
|
49
|
+
encryptionKey: o
|
|
73
50
|
})
|
|
74
|
-
]), {
|
|
51
|
+
]), { zkCallData: K, circomData: h, dimData: I } = await C(
|
|
75
52
|
t.merkleTreeHinkal,
|
|
76
53
|
t.merkleTreeAccessToken,
|
|
77
|
-
|
|
78
|
-
|
|
54
|
+
s,
|
|
55
|
+
E,
|
|
79
56
|
t.userKeys,
|
|
57
|
+
l,
|
|
58
|
+
0n,
|
|
59
|
+
await t.getEthereumAddress(),
|
|
60
|
+
"0x00",
|
|
80
61
|
T,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
t.generateProofRemotely,
|
|
85
|
-
D,
|
|
86
|
-
t.getCurrentChainId(),
|
|
87
|
-
void 0,
|
|
88
|
-
void 0,
|
|
89
|
-
void 0,
|
|
90
|
-
void 0,
|
|
91
|
-
f
|
|
92
|
-
), C = P(e[0], t.getCurrentChainId());
|
|
93
|
-
if (!C)
|
|
62
|
+
t.getCurrentChainId()
|
|
63
|
+
), w = f(n[0], t.getCurrentChainId());
|
|
64
|
+
if (!w)
|
|
94
65
|
throw Error("Withdraw Action: No Token Found");
|
|
95
|
-
return await I
|
|
96
|
-
t,
|
|
97
|
-
o[0],
|
|
98
|
-
C,
|
|
99
|
-
U,
|
|
100
|
-
M,
|
|
101
|
-
R,
|
|
102
|
-
E,
|
|
103
|
-
g,
|
|
104
|
-
f
|
|
105
|
-
);
|
|
66
|
+
return await D(t, r[0], w, K, h, I);
|
|
106
67
|
};
|
|
107
68
|
export {
|
|
108
|
-
|
|
109
|
-
|
|
69
|
+
k as hinkalDeposit,
|
|
70
|
+
H as hinkalDepositForOther
|
|
110
71
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("axios");require("../../constants/coingecko.constants.cjs");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("axios");require("../../constants/coingecko.constants.cjs");const i=require("../../API/API.cjs");require("ethers");require("../../types/curve.types.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 a=r=>({async getAccessToken(){const e=r.getCurrentChainId();return i.API.getZkMeAccessToken(e)},async getUserAccounts(){return[await r.getEthereumAddress()]},async delegateTransaction(e){const t=await r.getProviderAdapter(),s={...e,chainId:Number(e.chainId),type:e.type?e.type:void 0,maxPriorityFeePerGas:e.maxPriorityFeePerGas?e.maxPriorityFeePerGas:void 0,maxFeePerGas:e.maxFeePerGas?e.maxFeePerGas:void 0};return(await t.sendTransaction(s)).hash}});exports.getHinkalZkMeProvider=a;
|
|
@@ -5,13 +5,12 @@ import "../../constants/coingecko.constants.mjs";
|
|
|
5
5
|
import { API as s } from "../../API/API.mjs";
|
|
6
6
|
import "ethers";
|
|
7
7
|
import "../../types/curve.types.mjs";
|
|
8
|
-
import "../../constants/token-data/index.mjs";
|
|
9
8
|
import "../../constants/contracts.constants.mjs";
|
|
10
9
|
import "../../constants/kyc.constants.mjs";
|
|
11
10
|
import "../../constants/axelar.constants.mjs";
|
|
12
11
|
import "../../constants/rewards.constants.mjs";
|
|
13
12
|
import "../../constants/reorg-depths.constants.mjs";
|
|
14
|
-
const
|
|
13
|
+
const F = (r) => ({
|
|
15
14
|
async getAccessToken() {
|
|
16
15
|
const e = r.getCurrentChainId();
|
|
17
16
|
return s.getZkMeAccessToken(e);
|
|
@@ -31,5 +30,5 @@ const G = (r) => ({
|
|
|
31
30
|
}
|
|
32
31
|
});
|
|
33
32
|
export {
|
|
34
|
-
|
|
33
|
+
F as getHinkalZkMeProvider
|
|
35
34
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../../constants/chains.constants.cjs"),x=require("../../error-handling/error-codes.constants.cjs");require("ethers");require("axios");require("../../constants/vite.constants.cjs");require("../../types/circom-data.types.cjs");const A=require("../../types/external-action.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/reorg-depths.constants.cjs");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../../constants/chains.constants.cjs"),x=require("../../error-handling/error-codes.constants.cjs");require("ethers");require("axios");require("../../constants/vite.constants.cjs");require("../../types/circom-data.types.cjs");const A=require("../../types/external-action.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/reorg-depths.constants.cjs");const C=require("../../functions/snarkjs/constructEmporiumProof.cjs"),P=require("../../functions/pre-transaction/processAmountChanges.cjs"),R=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),w=require("../../functions/web3/events/getShieldedBalance.cjs"),U=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),I=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),T=async(e,o,r,m,d=[],p,y=!1)=>{const i=o.map(t=>0n);r=P.processAmountChanges({erc20Addresses:o,amountChanges:r,flatFees:i,feeUnit:void 0,externalActionId:A.ExternalActionId.Emporium});const s=[...await w.addPaddingToUtxos(e,o,r)],a=[];for(let t=0;t<o.length;t+=1){const{outputUtxos:E}=R.outputUtxoProcessing(e.userKeys,s[t],r[t]);a.push(E)}const n=await e.getRandomRelay();if(!n)throw Error(x.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const{contractData:g}=f.networkRegistry[e.getCurrentChainId()],{emporiumAddress:c}=g;if(!c)throw Error("No Emporium Address Provided");const{zkCallData:u,circomData:l,dimData:q}=await C.constructEmporiumProof(e.merkleTreeHinkal,e.merkleTreeAccessToken,s,a,e.userKeys,r.length,s[0].length,c,d,n,e.getCurrentChainId(),m,i,p);return y?await U.estimateGasRelayer(e,u,q,l):await I.transactCallRelayer(e.getCurrentChainId(),u,q,l)};exports.hinkalPrivateWallet=T;
|