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