@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 { EventType as
|
|
1
|
+
import { EventType as o } from "../../types/hinkal.types.mjs";
|
|
2
2
|
import { ContractType as c } from "../../types/ethereum-network.types.mjs";
|
|
3
3
|
import { checkHinkalAccessToken as g, mintAccessToken as u, mintTokenCrossChain as v } from "../../functions/web3/functionCalls/accessTokenCalls.mjs";
|
|
4
4
|
import { getShieldedBalance as k } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
5
|
-
import { UserKeys as
|
|
6
|
-
import { hinkalActionBeefy as
|
|
7
|
-
import { hinkalActionConvex as
|
|
5
|
+
import { UserKeys as s } from "../crypto-keys/keys.mjs";
|
|
6
|
+
import { hinkalActionBeefy as A } from "./hinkalActionBeefy.mjs";
|
|
7
|
+
import { hinkalActionConvex as y } from "./hinkalActionConvex.mjs";
|
|
8
8
|
import { hinkalActionCurve as C } from "./hinkalActionCurve.mjs";
|
|
9
9
|
import { hinkalActionPendle as f } from "./hinkalActionPendle.mjs";
|
|
10
|
-
import { hinkalDeposit as
|
|
10
|
+
import { hinkalDeposit as w, hinkalDepositForOther as P } from "./hinkalDeposit.mjs";
|
|
11
11
|
import { hinkalSwap as T } from "./hinkalSwap.mjs";
|
|
12
12
|
import { hinkalWithdraw as S } from "./hinkalWithdraw.mjs";
|
|
13
13
|
import { resetMerkleTrees as E } from "./resetMerkleTrees.mjs";
|
|
@@ -17,9 +17,9 @@ import "circomlibjs-hinkal-fork";
|
|
|
17
17
|
import "libsodium-wrappers";
|
|
18
18
|
import "process";
|
|
19
19
|
import "buffer";
|
|
20
|
-
import { networkRegistry as
|
|
20
|
+
import { networkRegistry as H } from "../../constants/chains.constants.mjs";
|
|
21
21
|
import { transactionErrorCodes as p } from "../../error-handling/error-codes.constants.mjs";
|
|
22
|
-
import { monitor as
|
|
22
|
+
import { monitor as F } from "../../API/callMonitor.mjs";
|
|
23
23
|
import { hinkalActionLido as I } from "./hinkalActionLidoEth.mjs";
|
|
24
24
|
import "../../constants/vite.constants.mjs";
|
|
25
25
|
import "axios";
|
|
@@ -28,27 +28,25 @@ import { getAxelarGasEstimate as R } from "../../API/getAxelarGasEstimate.mjs";
|
|
|
28
28
|
import { API as l } from "../../API/API.mjs";
|
|
29
29
|
import "ethers";
|
|
30
30
|
import "../../types/curve.types.mjs";
|
|
31
|
-
import "../../constants/token-data/index.mjs";
|
|
32
31
|
import "../../constants/contracts.constants.mjs";
|
|
33
|
-
import { supportedPassportLinks as
|
|
32
|
+
import { supportedPassportLinks as L } from "../../constants/kyc.constants.mjs";
|
|
34
33
|
import "../../constants/axelar.constants.mjs";
|
|
35
34
|
import "../../constants/rewards.constants.mjs";
|
|
36
35
|
import "../../constants/reorg-depths.constants.mjs";
|
|
37
|
-
import { TransactionsManager as
|
|
36
|
+
import { TransactionsManager as M } from "../transactions-manager/TransactionsManager.mjs";
|
|
38
37
|
import "../../functions/utils/external-action.utils.mjs";
|
|
39
38
|
import "../../types/circom-data.types.mjs";
|
|
40
39
|
import "../../types/transactions.types.mjs";
|
|
41
|
-
import { reloadPage as
|
|
40
|
+
import { reloadPage as W } from "../../functions/utils/reloadPage.mjs";
|
|
42
41
|
import { hinkalActionVolatile as N } from "./hinkalActionVolatile.mjs";
|
|
43
|
-
import { hinkalActionPendleLP as
|
|
44
|
-
import { getConnextReceiveFee as
|
|
45
|
-
import { hinkalActionStake as
|
|
42
|
+
import { hinkalActionPendleLP as K, hinkalGetPendleLPClaimableParams as x } from "./hinkalActionPendleLP.mjs";
|
|
43
|
+
import { getConnextReceiveFee as O } from "../../API/getConnextReceiveFee.mjs";
|
|
44
|
+
import { hinkalActionStake as B } from "./hinkalActionStake.mjs";
|
|
46
45
|
import { MultiThreadedUtxoUtils as D } from "../MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.mjs";
|
|
47
46
|
import { hinkalPrivateWallet as U } from "./hinkalPrivateWallet.mjs";
|
|
48
47
|
import { resetCache as b } from "../../functions/utils/cacheFunctions.mjs";
|
|
49
48
|
import { createCacheDevice as G } from "../../functions/utils/cacheDevice.utils.mjs";
|
|
50
|
-
|
|
51
|
-
class be {
|
|
49
|
+
class Be {
|
|
52
50
|
providerAdapter;
|
|
53
51
|
userKeys;
|
|
54
52
|
signingMessage = "Login to Hinkal Protocol";
|
|
@@ -62,9 +60,8 @@ class be {
|
|
|
62
60
|
transactionsManager;
|
|
63
61
|
utxoUtils;
|
|
64
62
|
cacheDevice;
|
|
65
|
-
generateProofRemotely;
|
|
66
63
|
constructor(e) {
|
|
67
|
-
this.userKeys = new
|
|
64
|
+
this.userKeys = new s(void 0), this.merkleTreeHinkal = h.create(d, 25n, 0n), this.merkleTreeAccessToken = h.create(d, 25n, 0n), this.nullifiers = /* @__PURE__ */ new Set(), this.encryptedOutputs = [], this.transactionsManager = new M(), this.utxoUtils = new D(), this.cacheDevice = G(e);
|
|
68
65
|
}
|
|
69
66
|
async initProviderAdapter(e, t) {
|
|
70
67
|
await this.updateProviderAdapter(t), this.providerAdapter?.initConnector(e);
|
|
@@ -72,10 +69,10 @@ class be {
|
|
|
72
69
|
await t.init(r), await this.setListeners();
|
|
73
70
|
}
|
|
74
71
|
async initUserKeys() {
|
|
75
|
-
this.userKeys = new
|
|
72
|
+
this.userKeys = new s(await this.getProviderAdapter().signMessage(this.signingMessage));
|
|
76
73
|
}
|
|
77
74
|
async initUserKeysWithPassword(e) {
|
|
78
|
-
this.userKeys = new
|
|
75
|
+
this.userKeys = new s(e);
|
|
79
76
|
}
|
|
80
77
|
async resetMerkle() {
|
|
81
78
|
this.isSelectedNetworkSupported() && await E(this);
|
|
@@ -94,9 +91,6 @@ class be {
|
|
|
94
91
|
getContract(e, t = void 0, r) {
|
|
95
92
|
return this.getProviderAdapter().getContract(e, t, r);
|
|
96
93
|
}
|
|
97
|
-
getContractWithFetcherByChainId(e, t, r = void 0) {
|
|
98
|
-
return _(e, t, r);
|
|
99
|
-
}
|
|
100
94
|
async signMessage(e) {
|
|
101
95
|
return await this.getProviderAdapter().signMessage(e);
|
|
102
96
|
}
|
|
@@ -113,7 +107,7 @@ class be {
|
|
|
113
107
|
return this.getProviderAdapter().getContractWithFetcherForEthereum(e, t);
|
|
114
108
|
}
|
|
115
109
|
isSelectedNetworkSupported() {
|
|
116
|
-
return !!
|
|
110
|
+
return !!H[this.getCurrentChainId()];
|
|
117
111
|
}
|
|
118
112
|
async switchNetwork(e) {
|
|
119
113
|
try {
|
|
@@ -159,25 +153,25 @@ class be {
|
|
|
159
153
|
}
|
|
160
154
|
async onAccountChanged() {
|
|
161
155
|
await this.getProviderAdapter().onAccountChanged();
|
|
162
|
-
const e =
|
|
156
|
+
const e = o.AccountChanged;
|
|
163
157
|
typeof document < "u" ? document?.dispatchEvent(new Event(e)) : process?.emit("message", e, void 0);
|
|
164
158
|
}
|
|
165
159
|
async onChainChanged(e) {
|
|
166
160
|
if (e) {
|
|
167
161
|
await this.getProviderAdapter().onChainChanged(e);
|
|
168
|
-
const t =
|
|
162
|
+
const t = o.NetworkChange;
|
|
169
163
|
typeof document < "u" ? document.dispatchEvent(new Event(t)) : process?.emit("message", t, void 0);
|
|
170
164
|
} else
|
|
171
|
-
await this.disconnectFromConnector(),
|
|
165
|
+
await this.disconnectFromConnector(), W();
|
|
172
166
|
}
|
|
173
167
|
async monitorConnectedAddress() {
|
|
174
|
-
|
|
168
|
+
F(await this.getEthereumAddress(), this.getCurrentChainId());
|
|
175
169
|
}
|
|
176
170
|
async getBalances() {
|
|
177
171
|
return k(this);
|
|
178
172
|
}
|
|
179
173
|
getSupportedPassportLinks() {
|
|
180
|
-
return
|
|
174
|
+
return L;
|
|
181
175
|
}
|
|
182
176
|
checkAccessToken() {
|
|
183
177
|
return g(this);
|
|
@@ -192,7 +186,7 @@ class be {
|
|
|
192
186
|
);
|
|
193
187
|
}
|
|
194
188
|
async getConnextReceiveFee(e, t) {
|
|
195
|
-
return
|
|
189
|
+
return O(this.getCurrentChainId(), e, t);
|
|
196
190
|
}
|
|
197
191
|
async mintHinkalAccessToken(e) {
|
|
198
192
|
return u(this, e);
|
|
@@ -243,10 +237,10 @@ class be {
|
|
|
243
237
|
this.commitmentsSnapshotService?.intervalClear(), this.accessTokenSnapshotService?.intervalClear(), this.nullifierSnapshotService?.intervalClear();
|
|
244
238
|
}
|
|
245
239
|
async deposit(e, t) {
|
|
246
|
-
return
|
|
240
|
+
return w(this, e, t);
|
|
247
241
|
}
|
|
248
242
|
async depositForOther(e, t, r) {
|
|
249
|
-
return
|
|
243
|
+
return P(this, e, t, r);
|
|
250
244
|
}
|
|
251
245
|
// async transfer(token: ERC20Token, amount: bigint, recipientAddress: string): Promise<ethers.ContractTransaction> {
|
|
252
246
|
// return hinkalTransfer(this, token, amount, recipientAddress);
|
|
@@ -269,10 +263,10 @@ class be {
|
|
|
269
263
|
return C(this, e, t, r, i, n, a);
|
|
270
264
|
}
|
|
271
265
|
async actionConvex(e, t, r, i, n = !1) {
|
|
272
|
-
return
|
|
266
|
+
return y(this, e, t, r, i, n);
|
|
273
267
|
}
|
|
274
268
|
async actionBeefy(e, t, r, i, n, a, m = !1) {
|
|
275
|
-
return
|
|
269
|
+
return A(
|
|
276
270
|
this,
|
|
277
271
|
e,
|
|
278
272
|
t,
|
|
@@ -290,7 +284,7 @@ class be {
|
|
|
290
284
|
return f(this, e, t, r, i, n);
|
|
291
285
|
}
|
|
292
286
|
async actionPendleLP(e, t, r, i, n = !1) {
|
|
293
|
-
return
|
|
287
|
+
return K(
|
|
294
288
|
this,
|
|
295
289
|
e,
|
|
296
290
|
t,
|
|
@@ -303,15 +297,15 @@ class be {
|
|
|
303
297
|
return N(this, e, t, r, i);
|
|
304
298
|
}
|
|
305
299
|
async actionStake(e, t, r, i) {
|
|
306
|
-
return
|
|
300
|
+
return B(this, e, t, r, i);
|
|
307
301
|
}
|
|
308
302
|
async actionPrivateWallet(e, t, r, i = [], n, a = !1) {
|
|
309
303
|
return U(this, e, t, r, i, n, a);
|
|
310
304
|
}
|
|
311
305
|
async getPendleLPClaimableParams(e, t) {
|
|
312
|
-
return
|
|
306
|
+
return x(this, e, t);
|
|
313
307
|
}
|
|
314
308
|
}
|
|
315
309
|
export {
|
|
316
|
-
|
|
310
|
+
Be as Hinkal
|
|
317
311
|
};
|
|
@@ -31,7 +31,6 @@ export interface IHinkal<ConnectorType = unknown> {
|
|
|
31
31
|
nullifierSnapshotService?: ClientNullifierSnapshotService;
|
|
32
32
|
accessTokenSnapshotService?: ClientAccessTokenSnapshotService;
|
|
33
33
|
transactionsManager: TransactionsManager;
|
|
34
|
-
generateProofRemotely: boolean;
|
|
35
34
|
utxoUtils: IMultiThreadedUtxoUtils;
|
|
36
35
|
cacheDevice: ICacheDevice;
|
|
37
36
|
getBalances(): Promise<TokenBalance[]>;
|
|
@@ -70,7 +69,6 @@ export interface IHinkal<ConnectorType = unknown> {
|
|
|
70
69
|
getContract(contract: ContractType, contractAddress?: string, chainId?: number): ethers.Contract;
|
|
71
70
|
getContractWithSigner(contract: ContractType, contractAddress?: string): ethers.Contract;
|
|
72
71
|
getContractWithFetcher(contract: ContractType, contractAddress?: string): ethers.Contract;
|
|
73
|
-
getContractWithFetcherByChainId(chainId: number, contractType: ContractType, contractAddress?: string): ethers.Contract;
|
|
74
72
|
getContractWithFetcherForEthereum(contract: ContractType, contractAddress?: string): ethers.Contract;
|
|
75
73
|
isSelectedNetworkSupported(): boolean;
|
|
76
74
|
switchNetwork(network: EthereumNetwork): Promise<unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("ethers"),S=require("../../constants/chains.constants.cjs"),I=require("../../error-handling/error-codes.constants.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("ethers"),S=require("../../constants/chains.constants.cjs"),I=require("../../error-handling/error-codes.constants.cjs"),k=require("../../functions/pre-transaction/getFlatFees.cjs"),M=require("../../functions/pre-transaction/processAmountChanges.cjs"),N=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),P=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),T=require("../../functions/web3/events/getShieldedBalance.cjs"),U=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),_=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),F=require("../../types/hinkal.types.cjs"),i=require("../../types/external-action.types.cjs"),G=(e,r,t,n,l,d)=>{let a;return l===i.ExternalActionId.BeefyStake?(a=u.utils.defaultAbiCoder.encode(["uint8","address","uint256","uint256"],[Number(n),d,e[0][0].amount,e[0][0].timeStamp]),a):(r.length===1?a=u.utils.defaultAbiCoder.encode(["uint8","bytes","bytes","address"],[Number(n),r[0],"0x00",t]):r.length===2?a=u.utils.defaultAbiCoder.encode(["uint8","bytes","bytes","address"],[Number(n),r[0],r[1],t]):a=u.utils.defaultAbiCoder.encode(["uint8","bytes","bytes","address"],[Number(n),"0x00","0x00",t]),a)},O=(e,r,t)=>r===i.ExternalActionId.BeefyStake?t===F.BeefyAction.GetRewards?[!1,!0]:[!1,!1,!0]:e.map(n=>n>0n),L=async(e,r,t,n,l,d,a,E=!1)=>{const c=[...await T.addPaddingToUtxos(e,r,t)],p=`swapper${a?"MO":"M"}${t.length.toString()}x${c[0].length}x1`,s=a?i.ExternalActionId.BeefyStake:i.ExternalActionId.Beefy,{flatFees:f,feeUnit:q}=await k.getFlatFees(e.getCurrentChainId(),r,s,t,n);t=M.processAmountChanges({erc20Addresses:r,amountChanges:t,flatFees:f,feeUnit:q,externalActionId:s,action:n});const b=O(t,s,n),x=[];for(let o=0;o<r.length;o+=1){const{outputUtxos:R}=N.outputUtxoProcessing(e.userKeys,c[o],t[o]);x.push(R)}const{contractData:y}=S.networkRegistry[e.getCurrentChainId()],w=s===i.ExternalActionId.BeefyStake?y.beefyStakeExternalActionInstanceAddress:y.beefyExternalActionInstanceAddress,B=G(c,l,d,n,s,a),g=await e.getRandomRelay();if(!g)throw Error(I.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const{zkCallData:A,circomData:C,dimData:m}=await P.constructZkProof(e.merkleTreeHinkal,e.merkleTreeAccessToken,c,x,e.userKeys,p,s,w,B,g,e.getCurrentChainId(),b,f);return E?await U.estimateGasRelayer(e,A,m,C):await _.transactCallRelayer(e.getCurrentChainId(),A,m,C)};exports.hinkalActionBeefy=L;
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { utils as
|
|
1
|
+
import { utils as m } from "ethers";
|
|
2
2
|
import { networkRegistry as N } from "../../constants/chains.constants.mjs";
|
|
3
3
|
import { transactionErrorCodes as I } from "../../error-handling/error-codes.constants.mjs";
|
|
4
4
|
import { getFlatFees as M } from "../../functions/pre-transaction/getFlatFees.mjs";
|
|
5
5
|
import { processAmountChanges as T } from "../../functions/pre-transaction/processAmountChanges.mjs";
|
|
6
6
|
import { outputUtxoProcessing as U } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
|
|
7
|
-
import { constructZkProof as
|
|
7
|
+
import { constructZkProof as k } from "../../functions/snarkjs/constructGeneralZkProof.mjs";
|
|
8
8
|
import { addPaddingToUtxos as F } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
9
9
|
import { estimateGasRelayer as L } from "../../functions/web3/functionCalls/estimateGasRelayer.mjs";
|
|
10
10
|
import { transactCallRelayer as O } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
11
|
-
import { BeefyAction as
|
|
11
|
+
import { BeefyAction as P } from "../../types/hinkal.types.mjs";
|
|
12
12
|
import { ExternalActionId as s } from "../../types/external-action.types.mjs";
|
|
13
|
-
const
|
|
13
|
+
const $ = (t, r, e, o, u, f) => {
|
|
14
14
|
let a;
|
|
15
|
-
return
|
|
15
|
+
return u === s.BeefyStake ? (a = m.defaultAbiCoder.encode(
|
|
16
16
|
["uint8", "address", "uint256", "uint256"],
|
|
17
|
-
[Number(o),
|
|
18
|
-
), a) : (r.length === 1 ? a =
|
|
17
|
+
[Number(o), f, t[0][0].amount, t[0][0].timeStamp]
|
|
18
|
+
), a) : (r.length === 1 ? a = m.defaultAbiCoder.encode(
|
|
19
19
|
["uint8", "bytes", "bytes", "address"],
|
|
20
20
|
[Number(o), r[0], "0x00", e]
|
|
21
|
-
) : r.length === 2 ? a =
|
|
21
|
+
) : r.length === 2 ? a = m.defaultAbiCoder.encode(
|
|
22
22
|
["uint8", "bytes", "bytes", "address"],
|
|
23
23
|
[Number(o), r[0], r[1], e]
|
|
24
|
-
) : a =
|
|
24
|
+
) : a = m.defaultAbiCoder.encode(
|
|
25
25
|
["uint8", "bytes", "bytes", "address"],
|
|
26
26
|
[Number(o), "0x00", "0x00", e]
|
|
27
27
|
), a);
|
|
28
|
-
}, G = (t, r, e) => r === s.BeefyStake ? e ===
|
|
29
|
-
const
|
|
28
|
+
}, G = (t, r, e) => r === s.BeefyStake ? e === P.GetRewards ? [!1, !0] : [!1, !1, !0] : t.map((o) => o > 0n), X = async (t, r, e, o, u, f, a, A = !1) => {
|
|
29
|
+
const c = [...await F(t, r, e)], E = `swapper${a ? "MO" : "M"}${e.length.toString()}x${c[0].length}x1`, n = a ? s.BeefyStake : s.Beefy, { flatFees: l, feeUnit: w } = await M(
|
|
30
30
|
t.getCurrentChainId(),
|
|
31
31
|
r,
|
|
32
32
|
n,
|
|
@@ -41,35 +41,34 @@ const k = (t, r, e, o, f, u) => {
|
|
|
41
41
|
externalActionId: n,
|
|
42
42
|
action: o
|
|
43
43
|
});
|
|
44
|
-
const
|
|
44
|
+
const b = G(e, n, o), d = [];
|
|
45
45
|
for (let i = 0; i < r.length; i += 1) {
|
|
46
|
-
const { outputUtxos: S } = U(t.userKeys,
|
|
46
|
+
const { outputUtxos: S } = U(t.userKeys, c[i], e[i]);
|
|
47
47
|
d.push(S);
|
|
48
48
|
}
|
|
49
|
-
const { contractData: p } = N[t.getCurrentChainId()],
|
|
50
|
-
|
|
51
|
-
f,
|
|
49
|
+
const { contractData: p } = N[t.getCurrentChainId()], B = n === s.BeefyStake ? p.beefyStakeExternalActionInstanceAddress : p.beefyExternalActionInstanceAddress, R = $(
|
|
50
|
+
c,
|
|
52
51
|
u,
|
|
52
|
+
f,
|
|
53
53
|
o,
|
|
54
54
|
n,
|
|
55
55
|
a
|
|
56
56
|
), x = await t.getRandomRelay();
|
|
57
57
|
if (!x)
|
|
58
58
|
throw Error(I.RELAYER_NOT_AVAILABLE);
|
|
59
|
-
const { zkCallData: y, circomData: g, dimData: C } = await
|
|
59
|
+
const { zkCallData: y, circomData: g, dimData: C } = await k(
|
|
60
60
|
t.merkleTreeHinkal,
|
|
61
61
|
t.merkleTreeAccessToken,
|
|
62
|
-
|
|
62
|
+
c,
|
|
63
63
|
d,
|
|
64
64
|
t.userKeys,
|
|
65
65
|
E,
|
|
66
66
|
n,
|
|
67
|
-
b,
|
|
68
67
|
B,
|
|
69
|
-
|
|
68
|
+
R,
|
|
70
69
|
x,
|
|
71
70
|
t.getCurrentChainId(),
|
|
72
|
-
|
|
71
|
+
b,
|
|
73
72
|
l
|
|
74
73
|
);
|
|
75
74
|
return A ? await L(t, y, C, g) : await O(t.getCurrentChainId(), y, C, g);
|
|
@@ -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"),s=require("../../constants/chains.constants.cjs"),R=require("../../error-handling/error-codes.constants.cjs"),P=require("../../functions/pre-transaction/getFlatFees.cjs"),U=require("../../functions/pre-transaction/processAmountChanges.cjs"),L=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),S=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),T=require("../../functions/web3/events/getShieldedBalance.cjs"),_=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),F=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),y=require("../../types/hinkal.types.cjs"),M=require("../../types/external-action.types.cjs"),O=async(t,o,e,A,a,f=!1)=>{const n=[...await T.addPaddingToUtxos(t,o,e)],p=`swapperMO${e.length.toString()}x${n[0].length}x1`,c=s.getNonLocalhostChainId(t.getCurrentChainId()),i=M.ExternalActionId.Convex,{flatFees:u,feeUnit:I}=await P.getFlatFees(t.getCurrentChainId(),o,i,e,a);e=U.processAmountChanges({erc20Addresses:o,amountChanges:e,flatFees:u,feeUnit:I,externalActionId:i,action:a});const h=[y.ConvexAction.StakeLP,y.ConvexAction.UnStakeLP].includes(a)?[!1,!1,...c===s.chainIds.ethMainnet?[!0,!0]:[!0]]:[!1,...c===s.chainIds.ethMainnet?[!0,!0]:[!0]],l=[];for(let r=0;r<o.length;r+=1){const{outputUtxos:w}=L.outputUtxoProcessing(t.userKeys,n[r],e[r]);l.push(w)}const m=s.networkRegistry[t.getCurrentChainId()].contractData.convexExternalActionInstanceAddress,q=E.utils.defaultAbiCoder.encode(["uint8","uint256","uint256","uint256"],[Number(a),A,n[0][0].amount,n[0][0].timeStamp]),d=await t.getRandomRelay();if(!d)throw Error(R.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const{zkCallData:C,circomData:g,dimData:x}=await S.constructZkProof(t.merkleTreeHinkal,t.merkleTreeAccessToken,n,l,t.userKeys,p,i,m,q,d,t.getCurrentChainId(),h,u);return f?await _.estimateGasRelayer(t,C,x,g):await F.transactCallRelayer(t.getCurrentChainId(),C,x,g)};exports.hinkalActionConvex=O;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { utils as
|
|
2
|
-
import { getNonLocalhostChainId as U, networkRegistry as
|
|
3
|
-
import { transactionErrorCodes as
|
|
4
|
-
import { getFlatFees as
|
|
1
|
+
import { utils as R } from "ethers";
|
|
2
|
+
import { getNonLocalhostChainId as U, networkRegistry as h, chainIds as d } from "../../constants/chains.constants.mjs";
|
|
3
|
+
import { transactionErrorCodes as P } from "../../error-handling/error-codes.constants.mjs";
|
|
4
|
+
import { getFlatFees as T } from "../../functions/pre-transaction/getFlatFees.mjs";
|
|
5
5
|
import { processAmountChanges as D } from "../../functions/pre-transaction/processAmountChanges.mjs";
|
|
6
6
|
import { outputUtxoProcessing as M } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
|
|
7
7
|
import { constructZkProof as N } from "../../functions/snarkjs/constructGeneralZkProof.mjs";
|
|
@@ -10,8 +10,8 @@ import { estimateGasRelayer as S } from "../../functions/web3/functionCalls/esti
|
|
|
10
10
|
import { transactCallRelayer as F } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
11
11
|
import { ConvexAction as C } from "../../types/hinkal.types.mjs";
|
|
12
12
|
import { ExternalActionId as b } from "../../types/external-action.types.mjs";
|
|
13
|
-
const Q = async (t, n, e,
|
|
14
|
-
const r = [...await O(t, n, e)], A = `swapperMO${e.length.toString()}x${r[0].length}x1`, s = U(t.getCurrentChainId()), i = b.Convex, { flatFees: c, feeUnit: I } = await
|
|
13
|
+
const Q = async (t, n, e, x, a, g = !1) => {
|
|
14
|
+
const r = [...await O(t, n, e)], A = `swapperMO${e.length.toString()}x${r[0].length}x1`, s = U(t.getCurrentChainId()), i = b.Convex, { flatFees: c, feeUnit: I } = await T(
|
|
15
15
|
t.getCurrentChainId(),
|
|
16
16
|
n,
|
|
17
17
|
i,
|
|
@@ -28,15 +28,15 @@ const Q = async (t, n, e, g, a, x = !1) => {
|
|
|
28
28
|
});
|
|
29
29
|
const y = [C.StakeLP, C.UnStakeLP].includes(a) ? [!1, !1, ...s === d.ethMainnet ? [!0, !0] : [!0]] : [!1, ...s === d.ethMainnet ? [!0, !0] : [!0]], m = [];
|
|
30
30
|
for (let o = 0; o < n.length; o += 1) {
|
|
31
|
-
const { outputUtxos:
|
|
32
|
-
m.push(
|
|
31
|
+
const { outputUtxos: L } = M(t.userKeys, r[o], e[o]);
|
|
32
|
+
m.push(L);
|
|
33
33
|
}
|
|
34
|
-
const w =
|
|
34
|
+
const w = h[t.getCurrentChainId()].contractData.convexExternalActionInstanceAddress, E = R.defaultAbiCoder.encode(
|
|
35
35
|
["uint8", "uint256", "uint256", "uint256"],
|
|
36
|
-
[Number(a),
|
|
36
|
+
[Number(a), x, r[0][0].amount, r[0][0].timeStamp]
|
|
37
37
|
), u = await t.getRandomRelay();
|
|
38
38
|
if (!u)
|
|
39
|
-
throw Error(
|
|
39
|
+
throw Error(P.RELAYER_NOT_AVAILABLE);
|
|
40
40
|
const { zkCallData: f, circomData: l, dimData: p } = await N(
|
|
41
41
|
t.merkleTreeHinkal,
|
|
42
42
|
t.merkleTreeAccessToken,
|
|
@@ -47,13 +47,12 @@ const Q = async (t, n, e, g, a, x = !1) => {
|
|
|
47
47
|
i,
|
|
48
48
|
w,
|
|
49
49
|
E,
|
|
50
|
-
t.generateProofRemotely,
|
|
51
50
|
u,
|
|
52
51
|
t.getCurrentChainId(),
|
|
53
52
|
y,
|
|
54
53
|
c
|
|
55
54
|
);
|
|
56
|
-
return
|
|
55
|
+
return g ? await S(t, f, p, l) : await F(t.getCurrentChainId(), f, p, l);
|
|
57
56
|
};
|
|
58
57
|
export {
|
|
59
58
|
Q as hinkalActionConvex
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("ethers"),V=require("../../constants/protocol.constants.cjs"),S=require("../../constants/crvDynamic.registry.cjs"),m=require("../../constants/chains.constants.cjs"),U=require("../../error-handling/error-codes.constants.cjs"),_=require("../../functions/protocols/curve.protocols.cjs"),L=require("../../functions/pre-transaction/getFlatFees.cjs"),T=require("../../functions/pre-transaction/processAmountChanges.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("ethers"),V=require("../../constants/protocol.constants.cjs"),S=require("../../constants/crvDynamic.registry.cjs"),m=require("../../constants/chains.constants.cjs"),U=require("../../error-handling/error-codes.constants.cjs"),_=require("../../functions/protocols/curve.protocols.cjs"),L=require("../../functions/pre-transaction/getFlatFees.cjs"),T=require("../../functions/pre-transaction/processAmountChanges.cjs"),k=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),F=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),M=require("../../functions/web3/events/getShieldedBalance.cjs"),G=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),P=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),a=require("../../types/hinkal.types.cjs"),s=require("../../types/external-action.types.cjs"),b=(t,n,e,o)=>n?o?s.ExternalActionId.CurveCRVRewards:s.ExternalActionId.CurveCRV:S.getCalcTokenAmountWithDynamicArray(t).includes(e.toLowerCase())?s.ExternalActionId.CurveDynamic:s.ExternalActionId.Curve,W=(t,n)=>{const{contractData:e}=m.networkRegistry[t.getCurrentChainId()];switch(n){case s.ExternalActionId.Curve:return e.curveExternalActionInstanceAddress;case s.ExternalActionId.CurveDynamic:return e.curveExternalActionDynamicInstanceAddress;case s.ExternalActionId.CurveCRV:return e.curveExternalActionInstanceAddress;case s.ExternalActionId.CurveCRVRewards:return e.curveStakeExternalActionInstanceAddress;default:return e.curveExternalActionInstanceAddress}},N=(t,n,e)=>D.utils.defaultAbiCoder.encode(["uint8","address","uint256","uint256"],[Number(t),n,e[0][0].amount,e[0][0].timeStamp]),O=(t,n,e,o)=>{if([a.CurveAction.Deposit,a.CurveAction.WithdrawInt,a.CurveAction.WithdrawUint].includes(o))return t.map(r=>r>0n);if(o===a.CurveAction.WithdrawImbalance)return t.map(()=>!1);if([a.CurveAction.Stake,a.CurveAction.Unstake,a.CurveAction.GetCRV].includes(o)){let r=!1;return n.map(l=>(l.toLowerCase()===_.getCRV(e).toLowerCase()&&(r=!0),r))}return t.map(r=>r>0n)},$=async(t,n,e,o,r,l,p=!1)=>{const c=[...await M.addPaddingToUtxos(t,n,e)];let d=`swapperM${e.length.toString()}x${c[0].length}x1`;const C=r===a.CurveAction.GetCRV||r===a.CurveAction.Stake||r===a.CurveAction.Unstake;C&&(d=`swapperMO${e.length.toString()}x${c[0].length}x1`);const A=m.getNonLocalhostChainId(t.getCurrentChainId()),u=b(A,C,o,l),{flatFees:x,feeUnit:w}=await L.getFlatFees(t.getCurrentChainId(),n,u,e,r,V.curveWithdrawGasTokenAddress?.current);e=T.processAmountChanges({erc20Addresses:n,amountChanges:e,flatFees:x,feeUnit:w,externalActionId:u,action:r});const R=O(e,n,A,r),g=[];for(let i=0;i<n.length;i+=1){const{outputUtxos:h}=k.outputUtxoProcessing(t.userKeys,c[i],e[i]);g.push(h)}const f=W(t,u),q=N(r,o,c),I=await t.getRandomRelay();if(!I)throw Error(U.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const{zkCallData:y,circomData:v,dimData:E}=await F.constructZkProof(t.merkleTreeHinkal,t.merkleTreeAccessToken,c,g,t.userKeys,d,u,f,q,I,t.getCurrentChainId(),R,x);return p?await G.estimateGasRelayer(t,y,E,v):await P.transactCallRelayer(t.getCurrentChainId(),y,E,v)};exports.hinkalActionCurve=$;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { utils as V } from "ethers";
|
|
2
2
|
import { curveWithdrawGasTokenAddress as L } from "../../constants/protocol.constants.mjs";
|
|
3
3
|
import { getCalcTokenAmountWithDynamicArray as U } from "../../constants/crvDynamic.registry.mjs";
|
|
4
|
-
import { getNonLocalhostChainId as
|
|
4
|
+
import { getNonLocalhostChainId as h, networkRegistry as T } from "../../constants/chains.constants.mjs";
|
|
5
5
|
import { transactionErrorCodes as M } from "../../error-handling/error-codes.constants.mjs";
|
|
6
6
|
import { getCRV as S } from "../../functions/protocols/curve.protocols.mjs";
|
|
7
7
|
import { getFlatFees as F } from "../../functions/pre-transaction/getFlatFees.mjs";
|
|
8
8
|
import { processAmountChanges as W } from "../../functions/pre-transaction/processAmountChanges.mjs";
|
|
9
|
-
import { outputUtxoProcessing as
|
|
10
|
-
import { constructZkProof as
|
|
11
|
-
import { addPaddingToUtxos as
|
|
9
|
+
import { outputUtxoProcessing as k } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
|
|
10
|
+
import { constructZkProof as G } from "../../functions/snarkjs/constructGeneralZkProof.mjs";
|
|
11
|
+
import { addPaddingToUtxos as N } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
12
12
|
import { estimateGasRelayer as $ } from "../../functions/web3/functionCalls/estimateGasRelayer.mjs";
|
|
13
13
|
import { transactCallRelayer as b } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
14
14
|
import { CurveAction as a } from "../../types/hinkal.types.mjs";
|
|
15
15
|
import { ExternalActionId as s } from "../../types/external-action.types.mjs";
|
|
16
|
-
const
|
|
17
|
-
const { contractData: e } =
|
|
16
|
+
const O = (t, n, e, o) => n ? o ? s.CurveCRVRewards : s.CurveCRV : U(t).includes(e.toLowerCase()) ? s.CurveDynamic : s.Curve, P = (t, n) => {
|
|
17
|
+
const { contractData: e } = T[t.getCurrentChainId()];
|
|
18
18
|
switch (n) {
|
|
19
19
|
case s.Curve:
|
|
20
20
|
return e.curveExternalActionInstanceAddress;
|
|
@@ -40,12 +40,12 @@ const k = (t, n, e, o) => n ? o ? s.CurveCRVRewards : s.CurveCRV : U(t).includes
|
|
|
40
40
|
return n.map((u) => (u.toLowerCase() === S(e).toLowerCase() && (r = !0), r));
|
|
41
41
|
}
|
|
42
42
|
return t.map((r) => r > 0n);
|
|
43
|
-
}, st = async (t, n, e, o, r, u,
|
|
44
|
-
const i = [...await
|
|
43
|
+
}, st = async (t, n, e, o, r, u, I = !1) => {
|
|
44
|
+
const i = [...await N(t, n, e)];
|
|
45
45
|
let d = `swapperM${e.length.toString()}x${i[0].length}x1`;
|
|
46
46
|
const l = r === a.GetCRV || r === a.Stake || r === a.Unstake;
|
|
47
47
|
l && (d = `swapperMO${e.length.toString()}x${i[0].length}x1`);
|
|
48
|
-
const C =
|
|
48
|
+
const C = h(t.getCurrentChainId()), m = O(C, l, o, u), { flatFees: f, feeUnit: R } = await F(
|
|
49
49
|
t.getCurrentChainId(),
|
|
50
50
|
n,
|
|
51
51
|
m,
|
|
@@ -57,19 +57,19 @@ const k = (t, n, e, o) => n ? o ? s.CurveCRVRewards : s.CurveCRV : U(t).includes
|
|
|
57
57
|
erc20Addresses: n,
|
|
58
58
|
amountChanges: e,
|
|
59
59
|
flatFees: f,
|
|
60
|
-
feeUnit:
|
|
60
|
+
feeUnit: R,
|
|
61
61
|
externalActionId: m,
|
|
62
62
|
action: r
|
|
63
63
|
});
|
|
64
64
|
const y = _(e, n, C, r), p = [];
|
|
65
65
|
for (let c = 0; c < n.length; c += 1) {
|
|
66
|
-
const { outputUtxos: v } =
|
|
66
|
+
const { outputUtxos: v } = k(t.userKeys, i[c], e[c]);
|
|
67
67
|
p.push(v);
|
|
68
68
|
}
|
|
69
|
-
const E =
|
|
69
|
+
const E = P(t, m), D = K(r, o, i), x = await t.getRandomRelay();
|
|
70
70
|
if (!x)
|
|
71
71
|
throw Error(M.RELAYER_NOT_AVAILABLE);
|
|
72
|
-
const { zkCallData: A, circomData: w, dimData: g } = await
|
|
72
|
+
const { zkCallData: A, circomData: w, dimData: g } = await G(
|
|
73
73
|
t.merkleTreeHinkal,
|
|
74
74
|
t.merkleTreeAccessToken,
|
|
75
75
|
i,
|
|
@@ -79,13 +79,12 @@ const k = (t, n, e, o) => n ? o ? s.CurveCRVRewards : s.CurveCRV : U(t).includes
|
|
|
79
79
|
m,
|
|
80
80
|
E,
|
|
81
81
|
D,
|
|
82
|
-
t.generateProofRemotely,
|
|
83
82
|
x,
|
|
84
83
|
t.getCurrentChainId(),
|
|
85
84
|
y,
|
|
86
85
|
f
|
|
87
86
|
);
|
|
88
|
-
return
|
|
87
|
+
return I ? await $(t, A, g, w) : await b(t.getCurrentChainId(), A, g, w);
|
|
89
88
|
};
|
|
90
89
|
export {
|
|
91
90
|
st as hinkalActionCurve
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("ethers"),F=require("../../constants/chains.constants.cjs"),M=require("../../error-handling/error-codes.constants.cjs"),P=require("../../functions/web3/events/getShieldedBalance.cjs"),U=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),h=require("../../functions/pre-transaction/getFlatFees.cjs"),S=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),_=require("../../functions/pre-transaction/processAmountChanges.cjs"),N=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),b=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),i=require("../../types/external-action.types.cjs"),o=require("../../types/hinkal.types.cjs"),D=(t,a)=>{if(t===o.LidoVariant.Ethereum)return a===o.LidoAction.Stake?i.ExternalActionId.LidoETH:i.ExternalActionId.LidoETHNFT;if(t===o.LidoVariant.Polygon)return a===o.LidoAction.Stake?i.ExternalActionId.LidoMATIC:i.ExternalActionId.LidoMATICNFT;throw new Error("Invalid LidoVariant used")},k=t=>R.ethers.utils.defaultAbiCoder.encode(["uint8"],[Number(t)]),v=async(t,a,n,s,r,d,p=!1)=>{const c=[...await P.addPaddingToUtxos(t,s,r,6,d)],g=c[0].length,C=`${n===o.LidoAction.Stake?"swapperM":"swapperToken"}2x${g}x1`,u=D(a,n),{flatFees:l,feeUnit:f}=await h.getFlatFees(t.getCurrentChainId(),s,u,r,n);r=_.processAmountChanges({erc20Addresses:s,amountChanges:r,flatFees:l,feeUnit:f,externalActionId:u,action:n});const w=n===o.LidoAction.Request?r.map(()=>!1):r.map(e=>e>0n),x=[];for(let e=0;e<s.length;e+=1){const{outputUtxos:T}=S.outputUtxoProcessing(t.userKeys,c[e],r[e],void 0,d[e]);x.push(T)}if(!await t.getRandomRelay())throw Error(M.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const{lidoExternalActionEthAddress:m,lidoExternalActionMaticAddress:q}=F.networkRegistry[t.getCurrentChainId()].contractData,A=a===o.LidoVariant.Ethereum?m:q;if(!A)throw new Error("Can't find external action address");const I=k(n),{zkCallData:E,circomData:y,dimData:L}=await U.constructZkProof(t.merkleTreeHinkal,t.merkleTreeAccessToken,c,x,t.userKeys,C,u,A,I,await t.getRandomRelay(),t.getCurrentChainId(),w,l);return p?await N.estimateGasRelayer(t,E,L,y):await b.transactCallRelayer(t.getCurrentChainId(),E,L,y)};exports.hinkalActionLido=v;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ethers as M } from "ethers";
|
|
2
2
|
import { networkRegistry as U } from "../../constants/chains.constants.mjs";
|
|
3
3
|
import { transactionErrorCodes as N } from "../../error-handling/error-codes.constants.mjs";
|
|
4
|
-
import { addPaddingToUtxos as
|
|
5
|
-
import { constructZkProof as
|
|
4
|
+
import { addPaddingToUtxos as D } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
5
|
+
import { constructZkProof as P } from "../../functions/snarkjs/constructGeneralZkProof.mjs";
|
|
6
6
|
import { getFlatFees as H } from "../../functions/pre-transaction/getFlatFees.mjs";
|
|
7
7
|
import { outputUtxoProcessing as S } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
|
|
8
8
|
import { processAmountChanges as b } from "../../functions/pre-transaction/processAmountChanges.mjs";
|
|
@@ -16,8 +16,8 @@ const _ = (t, a) => {
|
|
|
16
16
|
if (t === d.Polygon)
|
|
17
17
|
return a === s.Stake ? i.LidoMATIC : i.LidoMATICNFT;
|
|
18
18
|
throw new Error("Invalid LidoVariant used");
|
|
19
|
-
}, $ = (t) => M.utils.defaultAbiCoder.encode(["uint8"], [Number(t)]),
|
|
20
|
-
const c = [...await
|
|
19
|
+
}, $ = (t) => M.utils.defaultAbiCoder.encode(["uint8"], [Number(t)]), X = async (t, a, o, n, e, p, A = !1) => {
|
|
20
|
+
const c = [...await D(t, n, e, 6, p)], y = c[0].length, C = `${o === s.Stake ? "swapperM" : "swapperToken"}2x${y}x1`, m = _(a, o), { flatFees: u, feeUnit: L } = await H(
|
|
21
21
|
t.getCurrentChainId(),
|
|
22
22
|
n,
|
|
23
23
|
m,
|
|
@@ -27,45 +27,44 @@ const _ = (t, a) => {
|
|
|
27
27
|
e = b({
|
|
28
28
|
erc20Addresses: n,
|
|
29
29
|
amountChanges: e,
|
|
30
|
-
flatFees:
|
|
30
|
+
flatFees: u,
|
|
31
31
|
feeUnit: L,
|
|
32
32
|
externalActionId: m,
|
|
33
33
|
action: o
|
|
34
34
|
});
|
|
35
|
-
const
|
|
35
|
+
const T = o === s.Request ? e.map(() => !1) : e.map((r) => r > 0n), f = [];
|
|
36
36
|
for (let r = 0; r < n.length; r += 1) {
|
|
37
37
|
const { outputUtxos: F } = S(
|
|
38
38
|
t.userKeys,
|
|
39
39
|
c[r],
|
|
40
40
|
e[r],
|
|
41
41
|
void 0,
|
|
42
|
-
|
|
42
|
+
p[r]
|
|
43
43
|
);
|
|
44
|
-
|
|
44
|
+
f.push(F);
|
|
45
45
|
}
|
|
46
46
|
if (!await t.getRandomRelay())
|
|
47
47
|
throw Error(N.RELAYER_NOT_AVAILABLE);
|
|
48
|
-
const { lidoExternalActionEthAddress:
|
|
48
|
+
const { lidoExternalActionEthAddress: g, lidoExternalActionMaticAddress: I } = U[t.getCurrentChainId()].contractData, x = a === d.Ethereum ? g : I;
|
|
49
49
|
if (!x)
|
|
50
50
|
throw new Error("Can't find external action address");
|
|
51
|
-
const
|
|
51
|
+
const R = $(o), { zkCallData: E, circomData: l, dimData: w } = await P(
|
|
52
52
|
t.merkleTreeHinkal,
|
|
53
53
|
t.merkleTreeAccessToken,
|
|
54
54
|
c,
|
|
55
|
-
|
|
55
|
+
f,
|
|
56
56
|
t.userKeys,
|
|
57
57
|
C,
|
|
58
58
|
m,
|
|
59
59
|
x,
|
|
60
|
-
|
|
61
|
-
t.generateProofRemotely,
|
|
60
|
+
R,
|
|
62
61
|
await t.getRandomRelay(),
|
|
63
62
|
t.getCurrentChainId(),
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
T,
|
|
64
|
+
u
|
|
66
65
|
);
|
|
67
|
-
return
|
|
66
|
+
return A ? await v(t, E, w, l) : await K(t.getCurrentChainId(), E, w, l);
|
|
68
67
|
};
|
|
69
68
|
export {
|
|
70
|
-
|
|
69
|
+
X as hinkalActionLido
|
|
71
70
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("ethers"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("ethers"),q=require("../../constants/protocol.constants.cjs"),Y=require("../../constants/chains.constants.cjs"),g=require("../../functions/utils/erc20tokenFunctions.cjs"),b=require("../../functions/pre-transaction/getFlatFees.cjs"),O=require("../../functions/pre-transaction/processAmountChanges.cjs"),U=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),W=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),H=require("../../functions/web3/events/getShieldedBalance.cjs"),G=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),N=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),x=require("../../functions/web3/functionCalls/transactCallDirect.cjs"),m=require("../../types/ethereum-network.types.cjs"),v=require("../../types/circom-data.types.cjs"),z=require("../../types/external-action.types.cjs"),t=require("../../types/hinkal.types.cjs"),L=require("../../error-handling/error-codes.constants.cjs"),$=e=>{let r=[];return e===t.PendleAction.Deposit?r=[!1,!0]:e===t.PendleAction.Withdraw?r=[!1,!0]:e===t.PendleAction.SwapFromYt?r=[!1,!0,!0]:e===t.PendleAction.SwapToYt?r=[!1,!1,!0]:e===t.PendleAction.SwapPt?r=[!1,!0]:e===t.PendleAction.Mint?r=[!1,!0,!1,!0]:e===t.PendleAction.Redeem?r=[!1,!1,!0,!0]:e===t.PendleAction.Checkpoint&&(r=[!1,!0]),r},B=(e,r)=>{const{pendleAction:o,ytAddress:c,userAddress:a,evmData:P}=e,i=P??"0x00",s=a??q.zeroAddress;if([t.PendleAction.Deposit,t.PendleAction.Withdraw,t.PendleAction.SwapFromYt,t.PendleAction.SwapToYt,t.PendleAction.SwapPt,t.PendleAction.Mint,t.PendleAction.Redeem,t.PendleAction.Checkpoint].includes(e.pendleAction))return F.utils.defaultAbiCoder.encode(["uint8","address","uint256","uint256","address","bool","bytes"],[o,c,r[0][0].amount,r[0][0].timeStamp,s,!0,i]);throw new Error("Not implemented")},K=async(e,r,o,c,a,P=!1)=>{const i=z.ExternalActionId.Pendle,{pendleAction:s}=c,l=[...await H.addPaddingToUtxos(e,r,o)],R=`swapperMO${o.length.toString()}x${l[0].length}x1`,{flatFees:y,feeUnit:T}=await b.getFlatFees(e.getCurrentChainId(),r,i,o,s,a);o=O.processAmountChanges({erc20Addresses:r,amountChanges:o,flatFees:y,feeUnit:T,externalActionId:i,action:s,gasTokenAddress:a});const p=[];for(let n=0;n<r.length;n+=1){const{outputUtxos:A}=W.outputUtxoProcessing(e.userKeys,l[n],o[n]);p.push(A)}const D=$(s),{contractData:E}=Y.networkRegistry[e.getCurrentChainId()],S=E?.pendleExternalActionInstanceAddress,h=B(c,l),C=s===t.PendleAction.Deposit||c.isRelayerOff?q.zeroAddress:await e.getRandomRelay();if(!C)throw Error(L.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const I=`0x0${s.toString(16)}`,k={...v.defaultHookData,preHookMetadata:I},{zkCallData:u,circomData:d,dimData:f}=await U.constructZkProof(e.merkleTreeHinkal,e.merkleTreeAccessToken,l,p,e.userKeys,R,i,S,h,C,e.getCurrentChainId(),D,y,k);if(P)return await G.estimateGasRelayer(e,u,f,d);const w=e.getCurrentChainId();if(s===t.PendleAction.Deposit){const n=g.getERC20Token(c.ytAddress,w);if(!n)throw Error("Yt Token not found");const A=e.getContractWithSigner(m.ContractType.PendleGeneralExternalAction),_=e.getContractWithSigner(m.ContractType.HinkalWrapper);return await x.transactCallDirect(e,o[0],n,u,d,f,A,_)}if(s===t.PendleAction.Withdraw&&c.isRelayerOff){const n=g.getERC20Token(c.ytAddress,w);if(!n)throw Error("Yt Token not found");return await x.transactCallDirect(e,o[0],n,u,d,f)}return await N.transactCallRelayer(e.getCurrentChainId(),u,f,d)};exports.hinkalActionPendle=K;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { PendleMetadata } from '../../types/pendle.types';
|
|
2
2
|
import { IHinkal } from './IHinkal';
|
|
3
|
-
export declare const hinkalActionPendle: (hinkal: IHinkal, erc20Addresses: string[], amountChanges: bigint[], pendleMetadata: PendleMetadata, gasTokenAddress?: string, onlyGasEstimate?: boolean) => Promise<
|
|
3
|
+
export declare const hinkalActionPendle: (hinkal: IHinkal, erc20Addresses: string[], amountChanges: bigint[], pendleMetadata: PendleMetadata, gasTokenAddress?: string, onlyGasEstimate?: boolean) => Promise<bigint | import('../../index.ts').RelayerTransaction | import("ethers").ContractTransaction>;
|