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