@hinkal/common 0.0.104 → 0.0.107
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API/API.js +58 -0
- package/API/HinkalPointsCalls.js +38 -0
- package/API/callBeefyGraphAPI.js +37 -0
- package/API/callCurveAPI.js +156 -0
- package/API/callMonitor.js +30 -0
- package/API/callOdosAPI.js +44 -0
- package/API/callOneInchAPI.js +37 -0
- package/API/callRelayer.js +32 -0
- package/API/checkRisk.js +30 -0
- package/API/dataServerCalls.js +32 -0
- package/API/fetchCommitmentsCache.js +31 -0
- package/API/fetchNullifiers.js +30 -0
- package/API/getAxelarGasEstimate.js +37 -0
- package/API/getCoingeckoPrice.js +27 -0
- package/API/getConnextReceiveFee.js +30 -0
- package/API/getGasEstimates.js +38 -0
- package/API/getRelayerURL.js +32 -0
- package/API/getServerURL.js +67 -0
- package/API/getTokenPrice.js +41 -0
- package/API/kycCalls.js +32 -0
- package/API/passwordCalls.js +36 -0
- package/API/referralProgramCalls.js +58 -0
- package/API/relayCalls.js +30 -0
- package/API/restoreSnapshots.js +32 -0
- package/API/rewardsPointsCalls.js +40 -0
- package/API/userVerifyTransactions.js +45 -0
- package/README.md +116 -1
- package/assets/{snarkjsWorkerLogic-CatB8Hso.js → snarkjsWorkerLogic-Fv0M38Mc.js} +2 -2
- package/assets/{utxoWorkerLogic-DDqTe7hT.js → utxoWorkerLogic-CtFLQiAX.js} +2 -2
- package/assets/{zkProofWorkerLauncher-C-pvCm0b.js → zkProofWorkerLauncher-J3Ts5_Ba.js} +1 -1
- package/assets/{zkProofWorkerLogic-CLpRqNRx.js → zkProofWorkerLogic-CPNuu61R.js} +18 -19
- package/constants/assets.constants.js +16 -0
- package/constants/axelar.constants.js +55 -0
- package/constants/backend.constants.js +18 -0
- package/constants/beefy.registry.js +24 -0
- package/constants/chains.constants.js +204 -0
- package/constants/coingecko.constants.js +53 -0
- package/constants/contracts.constants.js +276 -0
- package/constants/crvCvx.registry.js +636 -0
- package/constants/crvDynamic.registry.js +24 -0
- package/constants/deploy-data/deploy-data-arbMainnet.json.js +7415 -0
- package/constants/deploy-data/deploy-data-avalanche.json.js +7411 -0
- package/constants/deploy-data/deploy-data-axelar1.json.js +4329 -0
- package/constants/deploy-data/deploy-data-axelar2.json.js +4329 -0
- package/constants/deploy-data/deploy-data-base.json.js +8425 -0
- package/constants/deploy-data/deploy-data-blast.json.js +9600 -0
- package/constants/deploy-data/deploy-data-bnbMainnet.json.js +6877 -0
- package/constants/deploy-data/deploy-data-ethMainnet.json.js +11427 -0
- package/constants/deploy-data/deploy-data-localhost.json.js +13283 -0
- package/constants/deploy-data/deploy-data-optimism.json.js +7417 -0
- package/constants/deploy-data/deploy-data-polygon.json.js +7439 -0
- package/constants/fees.constants.js +57 -0
- package/constants/kyc.constants.js +118 -0
- package/constants/lido.constants.js +13 -0
- package/constants/pendle.registry.js +253 -0
- package/constants/protocol.constants.js +26 -0
- package/constants/reorg-depths.constants.js +15 -0
- package/constants/rewards.constants.js +27 -0
- package/constants/server.constants.js +157 -0
- package/constants/token-data/ERC20Registry.js +85 -0
- package/constants/token-data/arbMainnetRegistry.json.js +946 -0
- package/constants/token-data/arbMainnetRegistryFixed.json.js +856 -0
- package/constants/token-data/avalancheRegistry.json.js +591 -0
- package/constants/token-data/avalancheRegistryFixed.json.js +591 -0
- package/constants/token-data/baseRegistry.json.js +490 -0
- package/constants/token-data/baseRegistryFixed.json.js +463 -0
- package/constants/token-data/blastRegistry.json.js +137 -0
- package/constants/token-data/blastRegistryFixed.json.js +137 -0
- package/constants/token-data/bnbMainnetRegistry.json.js +973 -0
- package/constants/token-data/bnbMainnetRegistryFixed.json.js +973 -0
- package/constants/token-data/coingeckoRegistry.json.js +115623 -0
- package/constants/token-data/ethMainnetRegistry.json.js +2700 -0
- package/constants/token-data/ethMainnetRegistryFixed.json.js +2251 -0
- package/constants/token-data/index.js +6 -0
- package/constants/token-data/localhostRegistry.json.js +2768 -0
- package/constants/token-data/optimismRegistry.json.js +1455 -0
- package/constants/token-data/optimismRegistryFixed.json.js +1392 -0
- package/constants/token-data/polygonRegistry.json.js +1327 -0
- package/constants/token-data/polygonRegistryFixed.json.js +1255 -0
- package/constants/token-data/popularTokens.constants.js +14 -0
- package/constants/token-data/tokenPricing.consts.js +8 -0
- package/constants/vite.constants.js +29 -0
- package/crypto/babyJub.js +15 -0
- package/crypto/poseidon.js +26 -0
- package/crypto/preProcessing.js +9 -0
- package/data-structures/Hinkal/Hinkal.js +299 -0
- package/data-structures/Hinkal/hinkalActionBeefy.js +101 -0
- package/data-structures/Hinkal/hinkalActionConvex.js +83 -0
- package/data-structures/Hinkal/hinkalActionCurve.js +112 -0
- package/data-structures/Hinkal/hinkalActionLidoEth.js +91 -0
- package/data-structures/Hinkal/hinkalActionPendle.js +140 -0
- package/data-structures/Hinkal/hinkalActionPendleLP.js +96 -0
- package/data-structures/Hinkal/hinkalActionStake.js +138 -0
- package/data-structures/Hinkal/hinkalActionVolatile.js +112 -0
- package/data-structures/Hinkal/hinkalDeposit.js +95 -0
- package/data-structures/Hinkal/hinkalGetZkMeProvider.js +47 -0
- package/data-structures/Hinkal/hinkalPrivateWallet.js +66 -0
- package/data-structures/Hinkal/hinkalSwap.js +98 -0
- package/data-structures/Hinkal/hinkalTransfer.js +5 -0
- package/data-structures/Hinkal/hinkalWithdraw.js +91 -0
- package/data-structures/Hinkal/resetMerkleTrees.js +49 -0
- package/data-structures/MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.js +83 -0
- package/data-structures/ValueCache/ValueCache.js +25 -0
- package/data-structures/crypto-keys/decodeUTXO.js +40 -0
- package/data-structures/crypto-keys/encryptDecryptUtxo.js +41 -0
- package/data-structures/crypto-keys/keyUtils.js +10 -0
- package/data-structures/crypto-keys/keys.js +90 -0
- package/data-structures/custom-token-registry/CustomTokenRegistry.js +33 -0
- package/data-structures/event-service/AbstractAccessTokenSnapshotService.js +131 -0
- package/data-structures/event-service/AbstractCommitmentsSnapshotService.js +132 -0
- package/data-structures/event-service/AbstractEventService.js +118 -0
- package/data-structures/event-service/AbstractNullifierSnapshotService.js +59 -0
- package/data-structures/event-service/AbstractSnapshotService.js +35 -0
- package/data-structures/merkle-tree/MerkleTree.js +177 -0
- package/data-structures/merkle-tree/MerkleTreeIncompleteError.js +8 -0
- package/data-structures/snapshot/ClientAccessTokenSnapshotService.js +48 -0
- package/data-structures/snapshot/ClientCommitmentsSnapshotService.js +47 -0
- package/data-structures/snapshot/ClientNullifierSnapshotService.js +44 -0
- package/data-structures/token-price-fetcher/TokenChecker.js +29 -0
- package/data-structures/token-price-fetcher/TokenPriceFetcher.js +218 -0
- package/data-structures/transactions-manager/TransactionsManager.js +194 -0
- package/data-structures/transactions-manager/history/getBeefyData.js +68 -0
- package/data-structures/transactions-manager/history/getConvexData.js +57 -0
- package/data-structures/transactions-manager/history/getCurveData.js +97 -0
- package/data-structures/transactions-manager/history/getDepositData.js +36 -0
- package/data-structures/transactions-manager/history/getLidoData.js +44 -0
- package/data-structures/transactions-manager/history/getPendleData.js +59 -0
- package/data-structures/transactions-manager/history/getSwapData.js +43 -0
- package/data-structures/transactions-manager/history/getTxDetails.js +74 -0
- package/data-structures/transactions-manager/history/getVolatileData.js +75 -0
- package/data-structures/transactions-manager/history/history.types.js +62 -0
- package/data-structures/transactions-manager/history/history.utils.js +8 -0
- package/data-structures/utxo/Utxo.js +134 -0
- package/data-structures/volatile-helper/VolatileHelper.js +181 -0
- package/error-handling/customErrors/ErrorWithAmount.js +9 -0
- package/error-handling/customErrors/FeeOverTransactionValueError.js +9 -0
- package/error-handling/customErrors/customErrors.helpers.js +21 -0
- package/error-handling/error-codes.constants.js +184 -0
- package/error-handling/get-error.message.js +53 -0
- package/error-handling/handleErrorRestore.js +35 -0
- package/error-handling/logError.js +7 -0
- package/error-handling/types.js +4 -0
- package/externalABIs/BUSD.js +519 -0
- package/externalABIs/BabPassport.json.js +24 -0
- package/externalABIs/BeefyRouterAbi.json.js +1022 -0
- package/externalABIs/BeefyStrategyAbi.json.js +1423 -0
- package/externalABIs/BeefyVaultAbi.json.js +570 -0
- package/externalABIs/BeefyZapAbi.json.js +208 -0
- package/externalABIs/BeefyZapOneInchAbi.json.js +340 -0
- package/externalABIs/ConvexBoosterAbi.json.js +674 -0
- package/externalABIs/ConvexBoosterAbiMainnet.json.js +1002 -0
- package/externalABIs/ConvexRewardPoolAbi.json.js +883 -0
- package/externalABIs/CurveReadingWrapperAbi.json.js +1422 -0
- package/externalABIs/CurveWrappedMainPool.json.js +1136 -0
- package/externalABIs/CurveZap.json.js +262 -0
- package/externalABIs/CvxCrvUtilities.json.js +264 -0
- package/externalABIs/DAI.js +334 -0
- package/externalABIs/ERC20.json.js +291 -0
- package/externalABIs/GalxePassport.json.js +41 -0
- package/externalABIs/IQuoterV2.json.js +205 -0
- package/externalABIs/ISwapRouter.json.js +568 -0
- package/externalABIs/IUniswapV3Factory.json.js +201 -0
- package/externalABIs/IUniswapV3Pool.json.js +999 -0
- package/externalABIs/LidoStEthAbi.json.js +1603 -0
- package/externalABIs/LidoStMaticAbi.json.js +1764 -0
- package/externalABIs/LidoStakeManagerAbi.json.js +2082 -0
- package/externalABIs/LidoWithdrawalQueueERC721Abi.json.js +2030 -0
- package/externalABIs/LidoWstEthAbi.json.js +480 -0
- package/externalABIs/OptimismGasPriceOracle.json.js +206 -0
- package/externalABIs/PendleRouterAbi.json.js +173 -0
- package/externalABIs/PoLidoNftAbi.json.js +701 -0
- package/externalABIs/SanctionsList.js +89 -0
- package/externalABIs/USDC.js +721 -0
- package/externalABIs/USDR.js +346 -0
- package/externalABIs/USDR3CRV.js +542 -0
- package/externalABIs/USDT.js +393 -0
- package/externalABIs/UniswapV2PoolAbi.json.js +80 -0
- package/externalABIs/WETH.js +156 -0
- package/externalABIs/amToken.js +350 -0
- package/externalABIs/transactionsProver.json.js +39 -0
- package/functions/kyc/authentoHelper.js +42 -0
- package/functions/kyc/passportHelper.js +39 -0
- package/functions/kyc/zkMeHelper.js +56 -0
- package/functions/pre-transaction/getFlatFees.js +203 -0
- package/functions/pre-transaction/interaction-to-action.js +57 -0
- package/functions/pre-transaction/outputUtxoProcessing.js +45 -0
- package/functions/pre-transaction/process-gas-estimates.js +57 -0
- package/functions/pre-transaction/processAmountChanges.js +229 -0
- package/functions/private-wallet/emporium.helpers.js +19 -0
- package/functions/private-wallet/opProducer.js +24 -0
- package/functions/protocols/convex.protocols.js +41 -0
- package/functions/protocols/curve.protocols.js +45 -0
- package/functions/protocols/pendle.helpers.js +108 -0
- package/functions/snarkjs/common.snarkjs.js +96 -0
- package/functions/snarkjs/constant.js +211 -0
- package/functions/snarkjs/constructEmporiumProof.js +105 -0
- package/functions/snarkjs/constructGeneralZkProof.js +129 -0
- package/functions/snarkjs/generateCircomData.js +60 -0
- package/functions/snarkjs/generateZkProof.js +18 -0
- package/functions/snarkjs/getZKFiles.js +30 -0
- package/functions/staking/index.js +40 -0
- package/functions/utils/amounts.utils.js +70 -0
- package/functions/utils/axelar.utils.js +38 -0
- package/functions/utils/cacheFunctions.js +67 -0
- package/functions/utils/caseInsensitive.utils.js +6 -0
- package/functions/utils/convertIntegrationProviderToExternalActionId.js +16 -0
- package/functions/utils/create-provider.js +5 -0
- package/functions/utils/enum.utils.js +14 -0
- package/functions/utils/erc20tokenFunctions.js +20 -0
- package/functions/utils/evmNetworkFunctions.js +29 -0
- package/functions/utils/external-action.utils.js +61 -0
- package/functions/utils/getDataFromTransaction.js +105 -0
- package/functions/utils/memoize.utils.js +14 -0
- package/functions/utils/nickname.utils.js +7 -0
- package/functions/utils/process.utils.js +4 -0
- package/functions/utils/reloadPage.js +4 -0
- package/functions/utils/requireEnv.js +7 -0
- package/functions/utils/resolve-sync.utils.js +22 -0
- package/functions/utils/serialize.utils.js +4 -0
- package/functions/utils/string.utils.js +14 -0
- package/functions/utils/time.utils.js +8 -0
- package/functions/utils/userAgent.js +15 -0
- package/functions/utils/volatile-patcher.utils.js +40 -0
- package/functions/web3/etherFunctions.js +41 -0
- package/functions/web3/events/balanceChangedHandler.js +10 -0
- package/functions/web3/events/getInputUtxoAndBalance.js +72 -0
- package/functions/web3/events/getShieldedBalance.js +107 -0
- package/functions/web3/events/web3RetrieveEvents.js +9 -0
- package/functions/web3/functionCalls/accessTokenCalls.js +48 -0
- package/functions/web3/functionCalls/approveToken.js +153 -0
- package/functions/web3/functionCalls/estimateGasRelayer.js +18 -0
- package/functions/web3/functionCalls/transactCallDirect.js +60 -0
- package/functions/web3/functionCalls/transactCallRelayer.js +42 -0
- package/functions/web3/odosAPI.js +65 -0
- package/functions/web3/oneInchAPI.js +61 -0
- package/functions/web3/runContractFunction.js +95 -0
- package/functions/web3/uniswapAPI.js +97 -0
- package/index.js +644 -0
- package/package.json +5 -4
- package/types/beefy.types.js +21 -0
- package/types/circom-data.types.js +22 -0
- package/types/curve.types.js +25 -0
- package/types/ethereum-network.types.js +4 -0
- package/types/external-action.types.js +4 -0
- package/types/hinkal.stake.types.js +4 -0
- package/types/hinkal.types.js +15 -0
- package/types/kyc.types.js +13 -0
- package/types/pendle.types.js +15 -0
- package/types/rewards.types.js +27 -0
- package/types/slippage.types.js +15 -0
- package/types/time.types.js +58 -0
- package/types/token.types.js +4 -0
- package/types/transactions.types.js +36 -0
- package/webworker/performTaskWithWorker.js +62 -0
- package/webworker/snarkjsWorker/snarkjsWorker.types.js +4 -0
- package/webworker/snarkjsWorker/snarkjsWorkerLogic.js +32 -0
- package/webworker/utxoWorker/utxoWorker.types.js +4 -0
- package/webworker/utxoWorker/utxoWorkerLogic.js +70 -0
- package/webworker/viteWorkerURL.constant.d.ts +3 -3
- package/webworker/worker.registry.js +4 -0
- package/webworker/workerFactory.d.ts +0 -1
- package/webworker/workerFactory.js +42 -0
- package/{workerProxy-BDj498Ht.mjs → webworker/workerProxy.js} +1 -1
- package/webworker/zkProofWorker/zkProofWorker.types.js +4 -0
- package/webworker/zkProofWorker/zkProofWorkerLogic.js +66 -0
- package/assets/viteWorkerURL.constant-DrIQXA2B.js +0 -11
- package/index-DbehuQxV.mjs +0 -398145
- package/index.mjs +0 -457
- package/snarkjsWorkerLogic-BpNWzeoy.mjs +0 -12086
- package/utxoWorkerLogic-D7NuHk_K.mjs +0 -64
- package/viteWorkerURL.constant-Bc7ufzqC.mjs +0 -9
- package/zkProofWorkerLogic-Bnalmuka.mjs +0 -60
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { getNonLocalhostChainId as T, chainIdsByType as y, EthereumNetworkType as S } from "../../constants/chains.constants.js";
|
|
2
|
+
import "../../types/circom-data.types.js";
|
|
3
|
+
import { emptyDecodedTx as k } from "../../types/transactions.types.js";
|
|
4
|
+
import { getCurrentWeek as A } from "../../types/time.types.js";
|
|
5
|
+
import "../../types/curve.types.js";
|
|
6
|
+
import "ethers";
|
|
7
|
+
import { transactionErrorCodes as I } from "../../error-handling/error-codes.constants.js";
|
|
8
|
+
import "circomlibjs";
|
|
9
|
+
import { UserKeys as x } from "../crypto-keys/keys.js";
|
|
10
|
+
import { saveTxsCache as C, loadTxsCache as w } from "../../functions/utils/cacheFunctions.js";
|
|
11
|
+
import "../../functions/web3/events/getShieldedBalance.js";
|
|
12
|
+
import "axios";
|
|
13
|
+
import { decryptUtxo as P } from "../crypto-keys/encryptDecryptUtxo.js";
|
|
14
|
+
import "../../webworker/workerFactory.js";
|
|
15
|
+
import "../../functions/utils/external-action.utils.js";
|
|
16
|
+
import "../custom-token-registry/CustomTokenRegistry.js";
|
|
17
|
+
import "../../functions/utils/convertIntegrationProviderToExternalActionId.js";
|
|
18
|
+
import "../../functions/utils/userAgent.js";
|
|
19
|
+
import { decodeTxInput as v, decodeTxLogs as H } from "../../functions/utils/getDataFromTransaction.js";
|
|
20
|
+
import { generateZkProof as z } from "../../functions/snarkjs/generateZkProof.js";
|
|
21
|
+
import "../../constants/reorg-depths.constants.js";
|
|
22
|
+
import "../../constants/kyc.constants.js";
|
|
23
|
+
import { getTxDetails as E } from "./history/getTxDetails.js";
|
|
24
|
+
import "../volatile-helper/VolatileHelper.js";
|
|
25
|
+
import "../../constants/coingecko.constants.js";
|
|
26
|
+
import "../../constants/vite.constants.js";
|
|
27
|
+
import "libsodium-wrappers";
|
|
28
|
+
import { getHinkalParameters as b } from "../../constants/contracts.constants.js";
|
|
29
|
+
import "../../constants/axelar.constants.js";
|
|
30
|
+
import "../../constants/rewards.constants.js";
|
|
31
|
+
import { API as p } from "../../API/API.js";
|
|
32
|
+
class dt {
|
|
33
|
+
circuitSize = 50;
|
|
34
|
+
hinkalContract;
|
|
35
|
+
init(r) {
|
|
36
|
+
this.hinkalContract = r;
|
|
37
|
+
}
|
|
38
|
+
requireInit() {
|
|
39
|
+
if (!this.hinkalContract)
|
|
40
|
+
throw Error("TransactionsManager not initialized");
|
|
41
|
+
}
|
|
42
|
+
filterOwnTransactions = async (r, e, t, n) => {
|
|
43
|
+
const { transactMethodId: s, transactWithExternalActionMethodId: a, hinkalInterface: o } = b(
|
|
44
|
+
T(r)
|
|
45
|
+
), c = (i) => "decodedInput" in i, l = e.filter(
|
|
46
|
+
(i) => i.methodId === s || i.methodId === a
|
|
47
|
+
).map((i) => c(i) ? i : {
|
|
48
|
+
...i,
|
|
49
|
+
decodedInput: v(o, i.input),
|
|
50
|
+
status: i.isError === "0" ? "SUCCESS" : "FAILURE"
|
|
51
|
+
}), u = t.getShieldedPrivateKey();
|
|
52
|
+
return l.filter((i) => {
|
|
53
|
+
try {
|
|
54
|
+
if (c(i)) {
|
|
55
|
+
if (P(Buffer.from(i.decodedInput.encryptedOutputs[0].slice(2), "hex"), t), !n && i.methodId === s) {
|
|
56
|
+
const { extraRandomization: m, H0: f, H1: g } = i.decodedInput.stealthAddressStructure;
|
|
57
|
+
return x.checkSignature(m, f, g, u);
|
|
58
|
+
}
|
|
59
|
+
return !0;
|
|
60
|
+
}
|
|
61
|
+
return !1;
|
|
62
|
+
} catch {
|
|
63
|
+
return !1;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
saveTxsInStorage = (r, e, t, n) => {
|
|
68
|
+
const s = t.getShieldedPublicKey();
|
|
69
|
+
C(r, e, s, this.hinkalContract.address, n);
|
|
70
|
+
};
|
|
71
|
+
loadTxsFromStorage = (r, e) => {
|
|
72
|
+
const t = e.getShieldedPublicKey();
|
|
73
|
+
return w(r, t, this.hinkalContract.address);
|
|
74
|
+
};
|
|
75
|
+
getAllTransactions = async (r, e, t) => {
|
|
76
|
+
if (t) {
|
|
77
|
+
const { transactions: o } = await p.userGetTransactions(r, t);
|
|
78
|
+
return o;
|
|
79
|
+
}
|
|
80
|
+
const { decodedTxs: n, lastHash: s } = this.loadTxsFromStorage(r, e), { transactions: a } = await p.userGetTransactions(r, t, s);
|
|
81
|
+
return [...a, ...n];
|
|
82
|
+
};
|
|
83
|
+
getHinkalHistoryBase = async (r, e, t, n = !1) => {
|
|
84
|
+
this.requireInit();
|
|
85
|
+
const s = await this.getAllTransactions(r, e, t) ?? [];
|
|
86
|
+
s.sort((o, c) => c.timeStamp - o.timeStamp);
|
|
87
|
+
const a = await this.filterOwnTransactions(r, s, e, n);
|
|
88
|
+
return !t && s.length > 0 && this.saveTxsInStorage(a, r, e, s[0].hash), a;
|
|
89
|
+
};
|
|
90
|
+
getHinkalHistory = async (r, e) => {
|
|
91
|
+
const t = await this.getHinkalHistoryBase(r, e, void 0, !0), n = H(r, t);
|
|
92
|
+
return await Promise.all(
|
|
93
|
+
n.map(async (a) => ({
|
|
94
|
+
...a,
|
|
95
|
+
status: a.status,
|
|
96
|
+
details: await E(r, a.decodedInput, a.utxosArray)
|
|
97
|
+
}))
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
sortInBatches = (r) => {
|
|
101
|
+
const e = [];
|
|
102
|
+
let t = 0, n = 0;
|
|
103
|
+
r.forEach((o) => {
|
|
104
|
+
t === 0 && e.push([]), e[n].push(o), t += 1, t === this.circuitSize && (t = 0, n += 1);
|
|
105
|
+
});
|
|
106
|
+
const s = e[e.length - 1], a = s.length;
|
|
107
|
+
if (a < this.circuitSize) {
|
|
108
|
+
const o = this.circuitSize - a, c = new Array(o).fill(k);
|
|
109
|
+
e[e.length - 1] = s.concat(c);
|
|
110
|
+
}
|
|
111
|
+
return e;
|
|
112
|
+
};
|
|
113
|
+
generateTransactionsProof = async (r, e, t) => {
|
|
114
|
+
const n = this.sortInBatches(e), s = new Array(n.length).fill([]);
|
|
115
|
+
for (let a = 0; a < n.length; a += 1) {
|
|
116
|
+
const o = n[a].map(
|
|
117
|
+
(h) => h.decodedInput.stealthAddressStructure
|
|
118
|
+
), c = o.map((h) => h.extraRandomization), d = o.map((h) => h.stealthAddress);
|
|
119
|
+
console.log({ extraRandomizations: c, stealthAddresses: d });
|
|
120
|
+
const l = {
|
|
121
|
+
shieldedPrivateKey: t,
|
|
122
|
+
extraRandomizations: c,
|
|
123
|
+
stealthAddresses: d
|
|
124
|
+
};
|
|
125
|
+
console.log({ chainId: r, input: l });
|
|
126
|
+
const { zkCallData: u } = await z(r, "transactionsProver", l);
|
|
127
|
+
console.log({ zkCallData: u }), s[a] = u;
|
|
128
|
+
}
|
|
129
|
+
return { zkCallDataArray: s };
|
|
130
|
+
};
|
|
131
|
+
userVerifyTransactions = async (r, e, t, n, s, a) => await p.userVerifyTransactions(
|
|
132
|
+
r,
|
|
133
|
+
e,
|
|
134
|
+
t,
|
|
135
|
+
n,
|
|
136
|
+
s,
|
|
137
|
+
a
|
|
138
|
+
);
|
|
139
|
+
processAndSendTransactionsForVerification = async (r, e, t, n) => {
|
|
140
|
+
this.requireInit();
|
|
141
|
+
const s = A(), a = n ? s - 1 : s;
|
|
142
|
+
console.log("retrieving transactions in processAndSendTransactionsForVerification", { week: a });
|
|
143
|
+
const o = await this.getHinkalHistoryBase(r, e, a);
|
|
144
|
+
console.log("retrieved transactions", o);
|
|
145
|
+
let c = [], d = [];
|
|
146
|
+
o.length > 0 && ({ zkCallDataArray: d } = await this.generateTransactionsProof(
|
|
147
|
+
r,
|
|
148
|
+
o,
|
|
149
|
+
e.getShieldedPrivateKey()
|
|
150
|
+
), c = o.map((f) => f.hash));
|
|
151
|
+
const l = e.getBackendToken(), {
|
|
152
|
+
trade: u,
|
|
153
|
+
transactions: h,
|
|
154
|
+
lockedDeposit: i,
|
|
155
|
+
verification: m
|
|
156
|
+
} = await this.userVerifyTransactions(
|
|
157
|
+
r,
|
|
158
|
+
c,
|
|
159
|
+
d,
|
|
160
|
+
l,
|
|
161
|
+
t,
|
|
162
|
+
a
|
|
163
|
+
);
|
|
164
|
+
return { trade: u, transactions: h, lockedDeposit: i, verification: m };
|
|
165
|
+
};
|
|
166
|
+
multiProcessAndSendTransactionsForVerification = async (r, e) => {
|
|
167
|
+
console.log("Multi Certify Starts");
|
|
168
|
+
const t = y[S.Mainnet];
|
|
169
|
+
let n = !0;
|
|
170
|
+
for (let s = 0; s < t.length; s += 1)
|
|
171
|
+
try {
|
|
172
|
+
const { hasCertified: a } = await p.verificationStartDate(t[s], e);
|
|
173
|
+
if (console.log(`certification status for chain ${t[s]} is ${a}`), a)
|
|
174
|
+
continue;
|
|
175
|
+
const {
|
|
176
|
+
trade: o,
|
|
177
|
+
transactions: c,
|
|
178
|
+
lockedDeposit: d,
|
|
179
|
+
verification: l
|
|
180
|
+
} = await this.processAndSendTransactionsForVerification(t[s], r, e, !0);
|
|
181
|
+
if (console.log({ chainId: t[s], trade: o, totalTransactions: c, lockedDeposit: d, verification: l }), n = n && l, !n)
|
|
182
|
+
break;
|
|
183
|
+
} catch (a) {
|
|
184
|
+
console.log(`current chain ${t[s]} certification error`, { err: a }), n = !1;
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
if (!n)
|
|
188
|
+
throw Error(I.MULTI_VERIFICATION_FAILED);
|
|
189
|
+
return !0;
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
export {
|
|
193
|
+
dt as TransactionsManager
|
|
194
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { utils as k } from "ethers";
|
|
2
|
+
import "../../../constants/chains.constants.js";
|
|
3
|
+
import "../../../types/circom-data.types.js";
|
|
4
|
+
import { BeefyAction as s } from "../../../types/hinkal.types.js";
|
|
5
|
+
import "../../../types/transactions.types.js";
|
|
6
|
+
import "../../../types/curve.types.js";
|
|
7
|
+
import "../../../constants/vite.constants.js";
|
|
8
|
+
import "../../../constants/contracts.constants.js";
|
|
9
|
+
import "../../../constants/kyc.constants.js";
|
|
10
|
+
import "../../../constants/coingecko.constants.js";
|
|
11
|
+
import "../../../constants/axelar.constants.js";
|
|
12
|
+
import "../../../constants/rewards.constants.js";
|
|
13
|
+
import "../../../constants/reorg-depths.constants.js";
|
|
14
|
+
import "circomlibjs";
|
|
15
|
+
import "../../crypto-keys/keys.js";
|
|
16
|
+
import "axios";
|
|
17
|
+
import "../../crypto-keys/encryptDecryptUtxo.js";
|
|
18
|
+
import "../../../functions/web3/events/getShieldedBalance.js";
|
|
19
|
+
import "../../../webworker/workerFactory.js";
|
|
20
|
+
import "../../../functions/utils/external-action.utils.js";
|
|
21
|
+
import { getERC20Token as n } from "../../../functions/utils/erc20tokenFunctions.js";
|
|
22
|
+
import "../../../functions/utils/convertIntegrationProviderToExternalActionId.js";
|
|
23
|
+
import "../../../functions/utils/userAgent.js";
|
|
24
|
+
import { TransactionType as c } from "./history.types.js";
|
|
25
|
+
import "../../volatile-helper/VolatileHelper.js";
|
|
26
|
+
import "../../custom-token-registry/CustomTokenRegistry.js";
|
|
27
|
+
import "libsodium-wrappers";
|
|
28
|
+
const L = (e, d, t) => {
|
|
29
|
+
const r = k.defaultAbiCoder.decode(
|
|
30
|
+
["uint8", "bytes", "bytes", "address"],
|
|
31
|
+
e.externalActionMetadata
|
|
32
|
+
)[0], m = e.amountChanges[0].toBigInt(), o = d[0];
|
|
33
|
+
if (r === s.Deposit || r === s.DepositRegular || r === s.DepositOneInchSingle) {
|
|
34
|
+
const p = {
|
|
35
|
+
token: n(e.erc20TokenAddresses[0], t) ?? {
|
|
36
|
+
erc20TokenAddress: e.erc20TokenAddresses[0]
|
|
37
|
+
},
|
|
38
|
+
balance: m
|
|
39
|
+
}, a = {
|
|
40
|
+
token: n(o.erc20TokenAddress, t) ?? { erc20TokenAddress: o.erc20TokenAddress },
|
|
41
|
+
balance: o.amount
|
|
42
|
+
};
|
|
43
|
+
return {
|
|
44
|
+
erc20Token: p,
|
|
45
|
+
mooToken: a,
|
|
46
|
+
beefyAction: r,
|
|
47
|
+
type: c.BEEFY
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const i = {
|
|
51
|
+
token: n(e.erc20TokenAddresses[1], t) ?? {
|
|
52
|
+
erc20TokenAddress: e.erc20TokenAddresses[1]
|
|
53
|
+
},
|
|
54
|
+
balance: m
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
erc20Token: {
|
|
58
|
+
token: n(o.erc20TokenAddress, t) ?? { erc20TokenAddress: o.erc20TokenAddress },
|
|
59
|
+
balance: o.amount
|
|
60
|
+
},
|
|
61
|
+
mooToken: i,
|
|
62
|
+
beefyAction: r,
|
|
63
|
+
type: c.BEEFY
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
export {
|
|
67
|
+
L as getBeefyData
|
|
68
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { utils as c } from "ethers";
|
|
2
|
+
import "../../../types/circom-data.types.js";
|
|
3
|
+
import { ConvexAction as r } from "../../../types/hinkal.types.js";
|
|
4
|
+
import "../../../types/transactions.types.js";
|
|
5
|
+
import "../../../types/curve.types.js";
|
|
6
|
+
import "../../../constants/chains.constants.js";
|
|
7
|
+
import "../../../constants/vite.constants.js";
|
|
8
|
+
import "../../../constants/contracts.constants.js";
|
|
9
|
+
import "../../../constants/kyc.constants.js";
|
|
10
|
+
import "../../../constants/coingecko.constants.js";
|
|
11
|
+
import "../../../constants/axelar.constants.js";
|
|
12
|
+
import "../../../constants/rewards.constants.js";
|
|
13
|
+
import "../../../constants/reorg-depths.constants.js";
|
|
14
|
+
import "circomlibjs";
|
|
15
|
+
import "../../crypto-keys/keys.js";
|
|
16
|
+
import "axios";
|
|
17
|
+
import "../../crypto-keys/encryptDecryptUtxo.js";
|
|
18
|
+
import "../../../functions/web3/events/getShieldedBalance.js";
|
|
19
|
+
import "../../../webworker/workerFactory.js";
|
|
20
|
+
import "../../../functions/utils/external-action.utils.js";
|
|
21
|
+
import { getERC20Token as m } from "../../../functions/utils/erc20tokenFunctions.js";
|
|
22
|
+
import "../../../functions/utils/convertIntegrationProviderToExternalActionId.js";
|
|
23
|
+
import "../../../functions/utils/userAgent.js";
|
|
24
|
+
import { TransactionType as n } from "./history.types.js";
|
|
25
|
+
import "../../volatile-helper/VolatileHelper.js";
|
|
26
|
+
import "../../custom-token-registry/CustomTokenRegistry.js";
|
|
27
|
+
import "libsodium-wrappers";
|
|
28
|
+
const h = (e, p, i) => {
|
|
29
|
+
const o = c.defaultAbiCoder.decode(
|
|
30
|
+
["uint8", "uint256", "uint256", "uint256"],
|
|
31
|
+
e.externalActionMetadata
|
|
32
|
+
)[0];
|
|
33
|
+
if (o === r.StakeLP || o === r.UnStakeLP) {
|
|
34
|
+
const t = e.erc20TokenAddresses[1];
|
|
35
|
+
return { poolToken: {
|
|
36
|
+
token: m(t, i) ?? { erc20TokenAddress: t },
|
|
37
|
+
balance: e.amountChanges[1].toBigInt()
|
|
38
|
+
}, type: n.CONVEX, convexAction: o };
|
|
39
|
+
}
|
|
40
|
+
if (o === r.ClaimRewardsLP) {
|
|
41
|
+
const t = p[0];
|
|
42
|
+
return {
|
|
43
|
+
poolToken: {
|
|
44
|
+
token: m(t.erc20TokenAddress, i) ?? {
|
|
45
|
+
erc20TokenAddress: t.erc20TokenAddress
|
|
46
|
+
},
|
|
47
|
+
balance: t.amount
|
|
48
|
+
},
|
|
49
|
+
type: n.CONVEX,
|
|
50
|
+
convexAction: o
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return { type: n.CONVEX, convexAction: o };
|
|
54
|
+
};
|
|
55
|
+
export {
|
|
56
|
+
h as getConvexData
|
|
57
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { utils as p } from "ethers";
|
|
2
|
+
import "../../../types/circom-data.types.js";
|
|
3
|
+
import { CurveAction as m } from "../../../types/hinkal.types.js";
|
|
4
|
+
import "../../../types/transactions.types.js";
|
|
5
|
+
import "../../../types/curve.types.js";
|
|
6
|
+
import "../../../constants/chains.constants.js";
|
|
7
|
+
import "../../../constants/vite.constants.js";
|
|
8
|
+
import "../../../constants/contracts.constants.js";
|
|
9
|
+
import "../../../constants/kyc.constants.js";
|
|
10
|
+
import "../../../constants/coingecko.constants.js";
|
|
11
|
+
import "../../../constants/axelar.constants.js";
|
|
12
|
+
import "../../../constants/rewards.constants.js";
|
|
13
|
+
import "../../../constants/reorg-depths.constants.js";
|
|
14
|
+
import "circomlibjs";
|
|
15
|
+
import "../../crypto-keys/keys.js";
|
|
16
|
+
import "axios";
|
|
17
|
+
import "../../crypto-keys/encryptDecryptUtxo.js";
|
|
18
|
+
import "../../../functions/web3/events/getShieldedBalance.js";
|
|
19
|
+
import "../../../webworker/workerFactory.js";
|
|
20
|
+
import "../../../functions/utils/external-action.utils.js";
|
|
21
|
+
import { getERC20Token as c } from "../../../functions/utils/erc20tokenFunctions.js";
|
|
22
|
+
import "../../../functions/utils/convertIntegrationProviderToExternalActionId.js";
|
|
23
|
+
import "../../../functions/utils/userAgent.js";
|
|
24
|
+
import { TransactionType as k } from "./history.types.js";
|
|
25
|
+
import "../../volatile-helper/VolatileHelper.js";
|
|
26
|
+
import "../../custom-token-registry/CustomTokenRegistry.js";
|
|
27
|
+
import "libsodium-wrappers";
|
|
28
|
+
const L = (e, i, s) => {
|
|
29
|
+
const o = p.defaultAbiCoder.decode(
|
|
30
|
+
["uint8", "address", "uint256", "uint256"],
|
|
31
|
+
e.externalActionMetadata
|
|
32
|
+
)[0];
|
|
33
|
+
if (o === m.Deposit) {
|
|
34
|
+
const n = e.erc20TokenAddresses.slice(0, -1).filter((a, t) => e.amountChanges[t].toBigInt() !== 0n).map((a, t) => {
|
|
35
|
+
const d = e.amountChanges[t].toBigInt();
|
|
36
|
+
return { token: c(a, s) ?? { erc20TokenAddress: a }, balance: d };
|
|
37
|
+
}), r = i[i.length - 1], T = {
|
|
38
|
+
token: c(r.erc20TokenAddress, s) ?? {
|
|
39
|
+
erc20TokenAddress: r.erc20TokenAddress
|
|
40
|
+
},
|
|
41
|
+
balance: r.amount
|
|
42
|
+
};
|
|
43
|
+
return { inTokens: n, poolToken: T, type: k.CURVE, curveAction: o };
|
|
44
|
+
}
|
|
45
|
+
if (o === m.WithdrawInt || o === m.WithdrawUint) {
|
|
46
|
+
const n = i.filter((t) => t.amount !== 0n).map((t) => {
|
|
47
|
+
const d = t.amount;
|
|
48
|
+
return { token: c(t.erc20TokenAddress, s) ?? { erc20TokenAddress: t.erc20TokenAddress }, balance: d };
|
|
49
|
+
}), r = e.erc20TokenAddresses[e.erc20TokenAddresses.length - 1], T = e.amountChanges[e.amountChanges.length - 1].toBigInt(), a = {
|
|
50
|
+
token: c(r, s) ?? {
|
|
51
|
+
erc20TokenAddress: r
|
|
52
|
+
},
|
|
53
|
+
balance: T
|
|
54
|
+
};
|
|
55
|
+
return { inTokens: n, poolToken: a, type: k.CURVE, curveAction: o };
|
|
56
|
+
}
|
|
57
|
+
if (o === m.WithdrawImbalance) {
|
|
58
|
+
const n = e.erc20TokenAddresses.slice(0, -1).filter((t, d) => e.amountChanges[d].toBigInt() !== 0n).map((t, d) => {
|
|
59
|
+
const l = e.amountChanges[d].toBigInt();
|
|
60
|
+
return { token: c(t, s) ?? { erc20TokenAddress: t }, balance: l };
|
|
61
|
+
}), r = e.erc20TokenAddresses[e.erc20TokenAddresses.length - 1], T = e.amountChanges[e.amountChanges.length - 1].toBigInt(), a = {
|
|
62
|
+
token: c(r, s) ?? {
|
|
63
|
+
erc20TokenAddress: r
|
|
64
|
+
},
|
|
65
|
+
balance: T
|
|
66
|
+
};
|
|
67
|
+
return { inTokens: n, poolToken: a, type: k.CURVE, curveAction: o };
|
|
68
|
+
}
|
|
69
|
+
if (o === m.Stake || o === m.Unstake)
|
|
70
|
+
return {
|
|
71
|
+
poolToken: {
|
|
72
|
+
token: c(e.erc20TokenAddresses[0], s) ?? {
|
|
73
|
+
erc20TokenAddress: e.erc20TokenAddresses[0]
|
|
74
|
+
},
|
|
75
|
+
balance: e.amountChanges[0].toBigInt()
|
|
76
|
+
},
|
|
77
|
+
type: k.CURVE,
|
|
78
|
+
curveAction: o
|
|
79
|
+
};
|
|
80
|
+
if (o === m.GetCRV) {
|
|
81
|
+
const n = i[0];
|
|
82
|
+
return {
|
|
83
|
+
poolToken: {
|
|
84
|
+
token: c(n.erc20TokenAddress, s) ?? {
|
|
85
|
+
erc20TokenAddress: n.erc20TokenAddress
|
|
86
|
+
},
|
|
87
|
+
balance: n.amount
|
|
88
|
+
},
|
|
89
|
+
type: k.CURVE,
|
|
90
|
+
curveAction: o
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return { type: k.CURVE, curveAction: o };
|
|
94
|
+
};
|
|
95
|
+
export {
|
|
96
|
+
L as getCurveData
|
|
97
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import "../../../constants/chains.constants.js";
|
|
2
|
+
import "../../../types/circom-data.types.js";
|
|
3
|
+
import "../../../types/transactions.types.js";
|
|
4
|
+
import "../../../types/curve.types.js";
|
|
5
|
+
import "../../../constants/vite.constants.js";
|
|
6
|
+
import "../../../constants/contracts.constants.js";
|
|
7
|
+
import "../../../constants/kyc.constants.js";
|
|
8
|
+
import "../../../constants/coingecko.constants.js";
|
|
9
|
+
import "../../../constants/axelar.constants.js";
|
|
10
|
+
import "../../../constants/rewards.constants.js";
|
|
11
|
+
import "../../../constants/reorg-depths.constants.js";
|
|
12
|
+
import "ethers";
|
|
13
|
+
import "circomlibjs";
|
|
14
|
+
import "../../crypto-keys/keys.js";
|
|
15
|
+
import "axios";
|
|
16
|
+
import "../../crypto-keys/encryptDecryptUtxo.js";
|
|
17
|
+
import "../../../functions/web3/events/getShieldedBalance.js";
|
|
18
|
+
import "../../../webworker/workerFactory.js";
|
|
19
|
+
import "../../../functions/utils/external-action.utils.js";
|
|
20
|
+
import { getERC20Token as e } from "../../../functions/utils/erc20tokenFunctions.js";
|
|
21
|
+
import "../../../functions/utils/convertIntegrationProviderToExternalActionId.js";
|
|
22
|
+
import "../../../functions/utils/userAgent.js";
|
|
23
|
+
import { TransactionType as p } from "./history.types.js";
|
|
24
|
+
import "../../volatile-helper/VolatileHelper.js";
|
|
25
|
+
import "../../custom-token-registry/CustomTokenRegistry.js";
|
|
26
|
+
import "libsodium-wrappers";
|
|
27
|
+
const j = (t, m) => {
|
|
28
|
+
const o = t.erc20TokenAddresses[0], r = t.amountChanges[0].toBigInt(), i = {
|
|
29
|
+
token: e(o, m) ?? { erc20TokenAddress: o },
|
|
30
|
+
balance: r
|
|
31
|
+
};
|
|
32
|
+
return r < 0 ? { tokenWithBalance: i, type: p.WITHDRAW } : { tokenWithBalance: i, type: p.DEPOSIT };
|
|
33
|
+
};
|
|
34
|
+
export {
|
|
35
|
+
j as getDepositData
|
|
36
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { utils as a } from "ethers";
|
|
2
|
+
import "../../../constants/chains.constants.js";
|
|
3
|
+
import "../../../types/circom-data.types.js";
|
|
4
|
+
import { ExternalActionId as i } from "../../../types/external-action.types.js";
|
|
5
|
+
import { LidoAction as p } from "../../../types/hinkal.types.js";
|
|
6
|
+
import "../../../types/transactions.types.js";
|
|
7
|
+
import "../../../types/curve.types.js";
|
|
8
|
+
import "circomlibjs";
|
|
9
|
+
import "../../crypto-keys/keys.js";
|
|
10
|
+
import "axios";
|
|
11
|
+
import "../../crypto-keys/encryptDecryptUtxo.js";
|
|
12
|
+
import "../../../functions/web3/events/getShieldedBalance.js";
|
|
13
|
+
import "../../../webworker/workerFactory.js";
|
|
14
|
+
import { getExternalActionIdHash as r } from "../../../functions/utils/external-action.utils.js";
|
|
15
|
+
import { getERC20TokenBySymbol as e } from "../../../functions/utils/erc20tokenFunctions.js";
|
|
16
|
+
import "../../../functions/utils/convertIntegrationProviderToExternalActionId.js";
|
|
17
|
+
import "../../../constants/coingecko.constants.js";
|
|
18
|
+
import "../../../constants/vite.constants.js";
|
|
19
|
+
import "../../../functions/utils/userAgent.js";
|
|
20
|
+
import "../../../constants/reorg-depths.constants.js";
|
|
21
|
+
import "../../../constants/kyc.constants.js";
|
|
22
|
+
import { TransactionType as d } from "./history.types.js";
|
|
23
|
+
import { wstEthSymbol as l, stMaticSymbol as c, ethSymbol as s, maticSymbol as T } from "../../../constants/lido.constants.js";
|
|
24
|
+
import "../../volatile-helper/VolatileHelper.js";
|
|
25
|
+
import "../../custom-token-registry/CustomTokenRegistry.js";
|
|
26
|
+
import "libsodium-wrappers";
|
|
27
|
+
import "../../../constants/contracts.constants.js";
|
|
28
|
+
import "../../../constants/axelar.constants.js";
|
|
29
|
+
import "../../../constants/rewards.constants.js";
|
|
30
|
+
const U = (t, A, o) => {
|
|
31
|
+
const n = a.defaultAbiCoder.decode(["uint8"], t.externalActionMetadata)[0];
|
|
32
|
+
let m;
|
|
33
|
+
return n === p.Request ? m = t.externalActionId.toBigInt() === r(i.LidoETH) || t.externalActionId.toBigInt() === r(i.LidoETHNFT) ? e(l, o) : e(c, o) : m = t.externalActionId.toBigInt() === r(i.LidoETH) || t.externalActionId.toBigInt() === r(i.LidoETHNFT) ? e(s, o) : e(T, o), {
|
|
34
|
+
lidoToken: {
|
|
35
|
+
token: m,
|
|
36
|
+
balance: t.amountChanges[1].toBigInt()
|
|
37
|
+
},
|
|
38
|
+
type: d.LIDO,
|
|
39
|
+
lidoAction: n
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export {
|
|
43
|
+
U as getLidoData
|
|
44
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { TransactionType as P } from "./history.types.js";
|
|
2
|
+
import "../../../types/circom-data.types.js";
|
|
3
|
+
import { ExternalActionId as h } from "../../../types/external-action.types.js";
|
|
4
|
+
import { PendleAction as t } from "../../../types/hinkal.types.js";
|
|
5
|
+
import "../../../types/transactions.types.js";
|
|
6
|
+
import "../../../types/curve.types.js";
|
|
7
|
+
import "../../../constants/chains.constants.js";
|
|
8
|
+
import "../../../constants/vite.constants.js";
|
|
9
|
+
import "../../../constants/contracts.constants.js";
|
|
10
|
+
import "../../../constants/kyc.constants.js";
|
|
11
|
+
import "../../../constants/coingecko.constants.js";
|
|
12
|
+
import "../../../constants/axelar.constants.js";
|
|
13
|
+
import "../../../constants/rewards.constants.js";
|
|
14
|
+
import "../../../constants/reorg-depths.constants.js";
|
|
15
|
+
import "ethers";
|
|
16
|
+
import "circomlibjs";
|
|
17
|
+
import "../../crypto-keys/keys.js";
|
|
18
|
+
import "axios";
|
|
19
|
+
import "../../crypto-keys/encryptDecryptUtxo.js";
|
|
20
|
+
import "../../../functions/web3/events/getShieldedBalance.js";
|
|
21
|
+
import "../../../webworker/workerFactory.js";
|
|
22
|
+
import { getActionFromMetadata as g } from "../../../functions/utils/external-action.utils.js";
|
|
23
|
+
import { getERC20Token as y } from "../../../functions/utils/erc20tokenFunctions.js";
|
|
24
|
+
import "../../../functions/utils/convertIntegrationProviderToExternalActionId.js";
|
|
25
|
+
import "../../../functions/utils/userAgent.js";
|
|
26
|
+
import { toEnumValue as A } from "../../../functions/utils/enum.utils.js";
|
|
27
|
+
import { txHistoryToBigInt as E } from "./history.utils.js";
|
|
28
|
+
import { TokenChecker as m } from "../../token-price-fetcher/TokenChecker.js";
|
|
29
|
+
import "../../volatile-helper/VolatileHelper.js";
|
|
30
|
+
import "../../custom-token-registry/CustomTokenRegistry.js";
|
|
31
|
+
import "libsodium-wrappers";
|
|
32
|
+
const oo = (r, p, T) => {
|
|
33
|
+
const k = g(h.Pendle, E(r)), e = A(t, k), s = [], a = [];
|
|
34
|
+
let c;
|
|
35
|
+
const l = p[0], f = p[1];
|
|
36
|
+
return r.amountChanges.forEach((u, d) => {
|
|
37
|
+
let n = u.toBigInt(), i = 0n;
|
|
38
|
+
(e === t.SwapToYt || e === t.Mint) && (n += l.amount, i = f.amount), e && [
|
|
39
|
+
t.Deposit,
|
|
40
|
+
t.Withdraw,
|
|
41
|
+
t.Redeem,
|
|
42
|
+
t.SwapFromYt,
|
|
43
|
+
t.Checkpoint
|
|
44
|
+
].includes(e) && (i = l.amount);
|
|
45
|
+
const o = y(r.erc20TokenAddresses[d], T) ?? {
|
|
46
|
+
erc20TokenAddress: r.erc20TokenAddresses[d]
|
|
47
|
+
};
|
|
48
|
+
"decimals" in o && m.isPendleToken(o) && !m.isPendleSyToken(o) ? a.push({ token: o, balance: n }) : "decimals" in o && m.isPendleSyToken(o) ? c = { token: o, balance: i } : s.push({ token: o, balance: n });
|
|
49
|
+
}), {
|
|
50
|
+
pendleTokens: a,
|
|
51
|
+
nonPendleTokens: s,
|
|
52
|
+
pendleAction: e,
|
|
53
|
+
syToken: c,
|
|
54
|
+
type: P.PENDLE
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
export {
|
|
58
|
+
oo as getPendleData
|
|
59
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import "../../../constants/chains.constants.js";
|
|
2
|
+
import "../../../types/circom-data.types.js";
|
|
3
|
+
import "../../../types/transactions.types.js";
|
|
4
|
+
import "../../../types/curve.types.js";
|
|
5
|
+
import "../../../constants/vite.constants.js";
|
|
6
|
+
import "../../../constants/contracts.constants.js";
|
|
7
|
+
import "../../../constants/kyc.constants.js";
|
|
8
|
+
import "../../../constants/coingecko.constants.js";
|
|
9
|
+
import "../../../constants/axelar.constants.js";
|
|
10
|
+
import "../../../constants/rewards.constants.js";
|
|
11
|
+
import "../../../constants/reorg-depths.constants.js";
|
|
12
|
+
import "ethers";
|
|
13
|
+
import "circomlibjs";
|
|
14
|
+
import "../../crypto-keys/keys.js";
|
|
15
|
+
import "axios";
|
|
16
|
+
import "../../crypto-keys/encryptDecryptUtxo.js";
|
|
17
|
+
import "../../../functions/web3/events/getShieldedBalance.js";
|
|
18
|
+
import "../../../webworker/workerFactory.js";
|
|
19
|
+
import "../../../functions/utils/external-action.utils.js";
|
|
20
|
+
import { getERC20Token as e } from "../../../functions/utils/erc20tokenFunctions.js";
|
|
21
|
+
import "../../../functions/utils/convertIntegrationProviderToExternalActionId.js";
|
|
22
|
+
import "../../../functions/utils/userAgent.js";
|
|
23
|
+
import { TransactionType as n } from "./history.types.js";
|
|
24
|
+
import "../../volatile-helper/VolatileHelper.js";
|
|
25
|
+
import "../../custom-token-registry/CustomTokenRegistry.js";
|
|
26
|
+
import "libsodium-wrappers";
|
|
27
|
+
const h = (o, m, r) => {
|
|
28
|
+
const p = {
|
|
29
|
+
token: e(o.erc20TokenAddresses[0], r) ?? {
|
|
30
|
+
erc20TokenAddress: o.erc20TokenAddresses[0]
|
|
31
|
+
},
|
|
32
|
+
balance: -1n * o.amountChanges[0].toBigInt()
|
|
33
|
+
}, t = m[0], i = {
|
|
34
|
+
token: e(t.erc20TokenAddress, r) ?? {
|
|
35
|
+
erc20TokenAddress: t.erc20TokenAddress
|
|
36
|
+
},
|
|
37
|
+
balance: t.amount
|
|
38
|
+
};
|
|
39
|
+
return { tokenIn: p, tokenOut: i, type: n.SWAP, protocol: o.externalActionId.toBigInt() };
|
|
40
|
+
};
|
|
41
|
+
export {
|
|
42
|
+
h as getSwapData
|
|
43
|
+
};
|