@hinkal/common 0.2.4 → 0.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API/API.cjs +1 -1
- package/API/API.d.ts +2 -2
- package/API/API.mjs +22 -22
- package/API/duneAPI.cjs +1 -1
- package/API/duneAPI.mjs +2 -3
- package/API/userVerifyTransactions.cjs +1 -1
- package/API/userVerifyTransactions.d.ts +7 -6
- package/API/userVerifyTransactions.mjs +14 -13
- package/constants/chains.constants.cjs +1 -1
- package/constants/chains.constants.mjs +2 -2
- package/constants/contracts.constants.cjs +1 -1
- package/constants/contracts.constants.mjs +134 -138
- package/constants/deploy-data/deploy-data-arbMainnet.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-arbMainnet.json.mjs +11 -846
- package/constants/deploy-data/deploy-data-avalanche.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-avalanche.json.mjs +13 -848
- package/constants/deploy-data/deploy-data-base.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-base.json.mjs +17 -852
- package/constants/deploy-data/deploy-data-bnbMainnet.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-bnbMainnet.json.mjs +20 -855
- package/constants/deploy-data/deploy-data-ethMainnet.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-ethMainnet.json.mjs +15 -850
- package/constants/deploy-data/deploy-data-localhost.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-localhost.json.mjs +100 -935
- package/constants/deploy-data/deploy-data-optimism.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-optimism.json.mjs +18 -849
- package/constants/deploy-data/deploy-data-polygon.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-polygon.json.mjs +9 -844
- package/constants/kyc.constants.cjs +1 -1
- package/constants/kyc.constants.mjs +18 -30
- package/constants/server.constants.cjs +1 -1
- package/constants/server.constants.d.ts +2 -3
- package/constants/server.constants.mjs +6 -7
- package/constants/token-data/ERC20Registry.cjs +1 -1
- package/constants/token-data/ERC20Registry.mjs +48 -48
- package/constants/token-data/arbMainnetRegistry.json.cjs +1 -1
- package/constants/token-data/arbMainnetRegistry.json.mjs +1 -4
- package/constants/token-data/arbMainnetRegistryFixed.json.cjs +1 -1
- package/constants/token-data/arbMainnetRegistryFixed.json.mjs +1 -4
- package/constants/token-data/avalancheRegistry.json.cjs +1 -1
- package/constants/token-data/avalancheRegistry.json.mjs +1 -4
- package/constants/token-data/avalancheRegistryFixed.json.cjs +1 -1
- package/constants/token-data/avalancheRegistryFixed.json.mjs +1 -4
- package/constants/token-data/baseRegistry.json.cjs +1 -1
- package/constants/token-data/baseRegistry.json.mjs +1 -4
- package/constants/token-data/baseRegistryFixed.json.cjs +1 -1
- package/constants/token-data/baseRegistryFixed.json.mjs +1 -4
- package/constants/token-data/bnbMainnetRegistry.json.cjs +1 -1
- package/constants/token-data/bnbMainnetRegistry.json.mjs +1 -4
- package/constants/token-data/bnbMainnetRegistryFixed.json.cjs +1 -1
- package/constants/token-data/bnbMainnetRegistryFixed.json.mjs +1 -4
- package/constants/token-data/ethMainnetRegistry.json.cjs +1 -1
- package/constants/token-data/ethMainnetRegistry.json.mjs +1 -4
- package/constants/token-data/ethMainnetRegistryFixed.json.cjs +1 -1
- package/constants/token-data/ethMainnetRegistryFixed.json.mjs +1 -4
- package/constants/token-data/index.d.ts +15 -972
- package/constants/token-data/localhostRegistry.json.cjs +1 -1
- package/constants/token-data/localhostRegistry.json.mjs +1 -4
- package/constants/token-data/optimismRegistry.json.cjs +1 -1
- package/constants/token-data/optimismRegistry.json.mjs +1 -4
- package/constants/token-data/optimismRegistryFixed.json.cjs +1 -1
- package/constants/token-data/optimismRegistryFixed.json.mjs +1 -4
- package/constants/token-data/polygonRegistry.json.cjs +1 -1
- package/constants/token-data/polygonRegistry.json.mjs +1 -4
- package/constants/token-data/polygonRegistryFixed.json.cjs +1 -1
- package/constants/token-data/polygonRegistryFixed.json.mjs +1 -4
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.d.ts +0 -2
- package/data-structures/Hinkal/Hinkal.mjs +32 -38
- package/data-structures/Hinkal/IHinkal.d.ts +0 -2
- package/data-structures/Hinkal/hinkalActionBeefy.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionBeefy.mjs +20 -21
- package/data-structures/Hinkal/hinkalActionConvex.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionConvex.mjs +12 -13
- package/data-structures/Hinkal/hinkalActionCurve.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionCurve.mjs +14 -15
- package/data-structures/Hinkal/hinkalActionLidoEth.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionLidoEth.mjs +16 -17
- package/data-structures/Hinkal/hinkalActionPendle.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionPendle.d.ts +1 -1
- package/data-structures/Hinkal/hinkalActionPendle.mjs +23 -24
- package/data-structures/Hinkal/hinkalActionPendleLP.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionPendleLP.mjs +20 -21
- package/data-structures/Hinkal/hinkalActionStake.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionStake.d.ts +1 -1
- package/data-structures/Hinkal/hinkalActionStake.mjs +5 -6
- package/data-structures/Hinkal/hinkalActionVolatile.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionVolatile.d.ts +1 -1
- package/data-structures/Hinkal/hinkalActionVolatile.mjs +8 -9
- package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalDeposit.d.ts +2 -2
- package/data-structures/Hinkal/hinkalDeposit.mjs +54 -93
- package/data-structures/Hinkal/hinkalGetZkMeProvider.cjs +1 -1
- package/data-structures/Hinkal/hinkalGetZkMeProvider.mjs +2 -3
- package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.mjs +4 -5
- package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSwap.mjs +22 -23
- package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdraw.d.ts +1 -1
- package/data-structures/Hinkal/hinkalWithdraw.mjs +12 -13
- package/data-structures/merkle-tree/MerkleTree.cjs +1 -1
- package/data-structures/merkle-tree/MerkleTree.d.ts +0 -2
- package/data-structures/merkle-tree/MerkleTree.mjs +25 -38
- package/data-structures/merkle-tree/index.d.ts +0 -1
- package/data-structures/transactions-manager/TransactionsManager.cjs +1 -1
- package/data-structures/transactions-manager/TransactionsManager.d.ts +5 -6
- package/data-structures/transactions-manager/TransactionsManager.mjs +111 -118
- package/error-handling/error-codes.constants.cjs +1 -1
- package/error-handling/error-codes.constants.d.ts +0 -4
- package/error-handling/error-codes.constants.mjs +2 -6
- package/externalABIs/BabPassport.json.cjs +1 -1
- package/externalABIs/BabPassport.json.mjs +3 -8
- package/externalABIs/BeefyRouterAbi.json.cjs +1 -1
- package/externalABIs/BeefyRouterAbi.json.mjs +2 -5
- package/externalABIs/BeefyStrategyAbi.json.cjs +1 -1
- package/externalABIs/BeefyStrategyAbi.json.mjs +2 -5
- package/externalABIs/BeefyVaultAbi.json.cjs +1 -1
- package/externalABIs/BeefyVaultAbi.json.mjs +2 -5
- package/externalABIs/BeefyZapAbi.json.cjs +1 -1
- package/externalABIs/BeefyZapAbi.json.mjs +2 -5
- package/externalABIs/BeefyZapOneInchAbi.json.cjs +1 -1
- package/externalABIs/BeefyZapOneInchAbi.json.mjs +2 -5
- package/externalABIs/ConvexBoosterAbi.json.cjs +1 -1
- package/externalABIs/ConvexBoosterAbi.json.mjs +2 -5
- package/externalABIs/ConvexBoosterAbiMainnet.json.cjs +1 -1
- package/externalABIs/ConvexBoosterAbiMainnet.json.mjs +2 -5
- package/externalABIs/ConvexRewardPoolAbi.json.cjs +1 -1
- package/externalABIs/ConvexRewardPoolAbi.json.mjs +2 -5
- package/externalABIs/CurveReadingWrapperAbi.json.cjs +1 -1
- package/externalABIs/CurveReadingWrapperAbi.json.mjs +2 -5
- package/externalABIs/CurveWrappedMainPool.json.cjs +1 -1
- package/externalABIs/CurveWrappedMainPool.json.mjs +2 -5
- package/externalABIs/CurveZap.json.cjs +1 -1
- package/externalABIs/CurveZap.json.mjs +2 -5
- package/externalABIs/CvxCrvUtilities.json.cjs +1 -1
- package/externalABIs/CvxCrvUtilities.json.mjs +2 -5
- package/externalABIs/ERC20.json.cjs +1 -1
- package/externalABIs/ERC20.json.mjs +3 -20
- package/externalABIs/GalxePassport.json.cjs +1 -1
- package/externalABIs/GalxePassport.json.mjs +3 -8
- package/externalABIs/IQuoterV2.json.cjs +1 -1
- package/externalABIs/IQuoterV2.json.mjs +3 -20
- package/externalABIs/ISwapRouter.json.cjs +1 -1
- package/externalABIs/ISwapRouter.json.mjs +2 -5
- package/externalABIs/IUniswapV3Factory.json.cjs +1 -1
- package/externalABIs/IUniswapV3Factory.json.mjs +3 -20
- package/externalABIs/IUniswapV3Pool.json.cjs +1 -1
- package/externalABIs/IUniswapV3Pool.json.mjs +3 -20
- package/externalABIs/PendleRouterAbi.json.cjs +1 -1
- package/externalABIs/PendleRouterAbi.json.mjs +2 -5
- package/externalABIs/UniswapV2PoolAbi.json.cjs +1 -1
- package/externalABIs/UniswapV2PoolAbi.json.mjs +3 -16
- package/externalABIs/index.d.ts +11 -307
- package/externalABIs/transactionsProver.json.cjs +1 -1
- package/externalABIs/transactionsProver.json.mjs +3 -20
- package/functions/kyc/zkMeHelper.cjs +1 -1
- package/functions/kyc/zkMeHelper.d.ts +1 -0
- package/functions/kyc/zkMeHelper.mjs +11 -8
- package/functions/pre-transaction/process-gas-estimates.cjs +1 -1
- package/functions/pre-transaction/process-gas-estimates.mjs +2 -3
- package/functions/private-wallet/emporium.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.helpers.d.ts +8 -3
- package/functions/private-wallet/emporium.helpers.mjs +23 -11
- package/functions/private-wallet/index.d.ts +1 -0
- package/functions/private-wallet/opProducer.cjs +1 -1
- package/functions/private-wallet/opProducer.mjs +10 -9
- package/functions/private-wallet/smartContractWalletCalculator.cjs +1 -0
- package/functions/private-wallet/smartContractWalletCalculator.d.ts +1 -0
- package/functions/private-wallet/smartContractWalletCalculator.mjs +20 -0
- package/functions/protocols/convex.protocols.cjs +1 -1
- package/functions/protocols/convex.protocols.mjs +2 -3
- package/functions/protocols/pendle.helpers.cjs +1 -1
- package/functions/protocols/pendle.helpers.mjs +13 -14
- package/functions/snarkjs/constant.cjs +1 -1
- package/functions/snarkjs/constant.d.ts +0 -1
- package/functions/snarkjs/constant.mjs +5 -6
- package/functions/snarkjs/constructEmporiumProof.cjs +1 -1
- package/functions/snarkjs/constructEmporiumProof.d.ts +1 -1
- package/functions/snarkjs/constructEmporiumProof.mjs +31 -31
- package/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
- package/functions/snarkjs/constructGeneralZkProof.d.ts +1 -1
- package/functions/snarkjs/constructGeneralZkProof.mjs +75 -76
- package/functions/snarkjs/generateZkProof.cjs +1 -1
- package/functions/snarkjs/generateZkProof.d.ts +1 -1
- package/functions/snarkjs/generateZkProof.mjs +15 -4
- package/functions/utils/axelar.utils.cjs +1 -1
- package/functions/utils/axelar.utils.mjs +2 -3
- package/functions/utils/cacheDevice.utils.cjs +1 -1
- package/functions/utils/cacheDevice.utils.mjs +8 -9
- package/functions/utils/erc20tokenFunctions.cjs +1 -1
- package/functions/utils/erc20tokenFunctions.mjs +7 -8
- package/functions/utils/evmNetworkFunctions.cjs +1 -1
- package/functions/utils/evmNetworkFunctions.mjs +3 -4
- package/functions/utils/string.utils.cjs +1 -1
- package/functions/utils/string.utils.d.ts +1 -0
- package/functions/utils/string.utils.mjs +16 -6
- package/functions/utils/userAgent.cjs +1 -1
- package/functions/utils/userAgent.mjs +8 -8
- package/functions/web3/functionCalls/accessTokenCalls.cjs +1 -1
- package/functions/web3/functionCalls/accessTokenCalls.mjs +8 -8
- package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/functions/web3/functionCalls/transactCallDirect.d.ts +1 -1
- package/functions/web3/functionCalls/transactCallDirect.mjs +29 -43
- package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.mjs +8 -10
- package/functions/web3/odosAPI.cjs +1 -1
- package/functions/web3/odosAPI.d.ts +2 -1
- package/functions/web3/odosAPI.mjs +18 -19
- package/functions/web3/oneInchAPI.cjs +1 -1
- package/functions/web3/oneInchAPI.d.ts +2 -1
- package/functions/web3/oneInchAPI.mjs +15 -17
- package/functions/web3/uniswapAPI.cjs +1 -1
- package/functions/web3/uniswapAPI.d.ts +4 -4
- package/functions/web3/uniswapAPI.mjs +43 -54
- package/index.cjs +1 -1
- package/index.mjs +641 -617
- package/package.json +2 -3
- package/providers/EthersProviderAdapter.cjs +1 -1
- package/providers/EthersProviderAdapter.d.ts +0 -1
- package/providers/EthersProviderAdapter.mjs +37 -26
- package/providers/WagmiProviderAdapter.cjs +1 -1
- package/providers/WagmiProviderAdapter.d.ts +0 -1
- package/providers/WagmiProviderAdapter.mjs +56 -45
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.mjs +2 -4
- package/providers/prepareWagmiHinkal.cjs +1 -1
- package/providers/prepareWagmiHinkal.mjs +2 -4
- package/types/ethereum-network.types.cjs +1 -1
- package/types/ethereum-network.types.d.ts +61 -62
- package/types/ethereum-network.types.mjs +1 -1
- package/types/hinkal.types.d.ts +0 -4
- package/types/kyc.types.cjs +1 -1
- package/types/kyc.types.d.ts +1 -1
- package/types/kyc.types.mjs +1 -1
- package/types/rewards.types.d.ts +0 -5
- package/types/time.types.cjs +1 -1
- package/types/time.types.mjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
- package/constants/token-data/index.cjs +0 -1
- package/constants/token-data/index.mjs +0 -34
- package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.cjs +0 -1
- package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.d.ts +0 -3
- package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.mjs +0 -9
- package/externalABIs/index.cjs +0 -1
- package/externalABIs/index.mjs +0 -23
- package/functions/snarkjs/generateZkProofEnclave.cjs +0 -1
- package/functions/snarkjs/generateZkProofEnclave.d.ts +0 -5
- package/functions/snarkjs/generateZkProofEnclave.mjs +0 -33
- package/functions/snarkjs/generateZkProofSelf.cjs +0 -1
- package/functions/snarkjs/generateZkProofSelf.d.ts +0 -5
- package/functions/snarkjs/generateZkProofSelf.mjs +0 -17
- package/functions/web3/getContractMetadata.cjs +0 -1
- package/functions/web3/getContractMetadata.d.ts +0 -5
- package/functions/web3/getContractMetadata.mjs +0 -30
- package/types/remote-proof.types.d.ts +0 -15
|
@@ -1,14 +1,24 @@
|
|
|
1
|
-
function
|
|
1
|
+
function s(t) {
|
|
2
2
|
return t?.toLowerCase().split(" ").map((r) => r.charAt(0).toUpperCase() + r.substring(1)).join(" ");
|
|
3
3
|
}
|
|
4
|
-
function
|
|
4
|
+
function u(t) {
|
|
5
5
|
return t.charAt(0).toUpperCase() + t.slice(1);
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function c(t) {
|
|
8
8
|
return !t || t === null || Array.isArray(t) && t.length === 0 ? !0 : Object.keys(t).length === 0 && t.constructor === Object;
|
|
9
9
|
}
|
|
10
|
+
const o = (t) => {
|
|
11
|
+
t.startsWith("0x") && (t = t.slice(2));
|
|
12
|
+
const r = [];
|
|
13
|
+
for (let e = 0; e < t.length; e += 2) {
|
|
14
|
+
const n = parseInt(t.slice(e, e + 2), 16);
|
|
15
|
+
r.push(n);
|
|
16
|
+
}
|
|
17
|
+
return new TextDecoder("utf-8").decode(new Uint8Array(r));
|
|
18
|
+
};
|
|
10
19
|
export {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
20
|
+
u as capitalizeFirstLetter,
|
|
21
|
+
o as hexToUtf8,
|
|
22
|
+
c as isNullOrEmpty,
|
|
23
|
+
s as toTitleCase
|
|
14
24
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("ua-parser-js"),a=new s.UAParser,o=17,n=()=>{const{name:e,version:r}=a.getBrowser(),t=
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("ua-parser-js"),a=new s.UAParser,o=["17"],n=()=>{const{name:e,version:r}=a.getBrowser(),t=r?.substring(0,2);return!(e==="Safari"&&t&&!o.includes(t))},u={mpcVault:"MPCVault - Multisig Wallet",utila:"UtilaWallet"},l=e=>{const r=e?.session?.peer?.metadata?.name;return!Object.values(u).includes(r)};exports.browserSupported=n;exports.walletSupported=l;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { UAParser as s } from "ua-parser-js";
|
|
2
|
-
const a = new s(), n = 17,
|
|
3
|
-
const { name: e, version:
|
|
4
|
-
return !(e === "Safari" &&
|
|
2
|
+
const a = new s(), n = ["17"], u = () => {
|
|
3
|
+
const { name: e, version: r } = a.getBrowser(), t = r?.substring(0, 2);
|
|
4
|
+
return !(e === "Safari" && t && !n.includes(t));
|
|
5
5
|
}, o = {
|
|
6
6
|
mpcVault: "MPCVault - Multisig Wallet",
|
|
7
7
|
utila: "UtilaWallet"
|
|
8
|
-
},
|
|
9
|
-
const
|
|
10
|
-
return !Object.values(o).includes(
|
|
8
|
+
}, i = (e) => {
|
|
9
|
+
const r = e?.session?.peer?.metadata?.name;
|
|
10
|
+
return !Object.values(o).includes(r);
|
|
11
11
|
};
|
|
12
12
|
export {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
u as browserSupported,
|
|
14
|
+
i as walletSupported
|
|
15
15
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../../constants/chains.constants.cjs");require("../../../types/circom-data.types.cjs");const r=require("../../../types/ethereum-network.types.cjs");require("../../../types/transactions.types.cjs");require("../../../types/curve.types.cjs");const T=require("../etherFunctions.cjs"),g=async e=>(await e.getContractWithFetcher(r.ContractType.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../../constants/chains.constants.cjs");require("../../../types/circom-data.types.cjs");const r=require("../../../types/ethereum-network.types.cjs");require("../../../types/transactions.types.cjs");require("../../../types/curve.types.cjs");const T=require("../etherFunctions.cjs"),g=async e=>(await e.getContractWithFetcher(r.ContractType.CrossChainAccessTokenContract).functions.hasToken(e.userKeys.getAccessKey()))[0],y=async(e,n)=>{const t=e.getContractWithSigner(r.ContractType.CrossChainAccessTokenContract),s=i.networkRegistry[e.getCurrentChainId()].accessTokenMintingFee??"0",c={value:T.ethToWei(s)};return await t.addToken(n,c)},d=async(e,n,t)=>{const s=e.getContractWithSigner(r.ContractType.CrossChainAccessTokenContract),a=i.networkRegistry[e.getCurrentChainId()].accessTokenMintingFee??"0",c=T.ethToWei(a),o=t.reduce((k,h)=>k+h.messageFee,0n),u={chains:t,totalMessageFees:o},C={value:c+o};return await s.addTokenCrossChain(n,u,C)};exports.checkHinkalAccessToken=g;exports.mintAccessToken=y;exports.mintTokenCrossChain=d;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { networkRegistry as i } from "../../../constants/chains.constants.mjs";
|
|
2
2
|
import "../../../types/circom-data.types.mjs";
|
|
3
|
-
import { ContractType as
|
|
3
|
+
import { ContractType as r } from "../../../types/ethereum-network.types.mjs";
|
|
4
4
|
import "../../../types/transactions.types.mjs";
|
|
5
5
|
import "../../../types/curve.types.mjs";
|
|
6
6
|
import { ethToWei as C } from "../etherFunctions.mjs";
|
|
7
|
-
const y = async (e) => (await e.getContractWithFetcher(
|
|
8
|
-
const t = e.getContractWithSigner(
|
|
9
|
-
value: C(
|
|
7
|
+
const y = async (e) => (await e.getContractWithFetcher(r.CrossChainAccessTokenContract).functions.hasToken(e.userKeys.getAccessKey()))[0], W = async (e, s) => {
|
|
8
|
+
const t = e.getContractWithSigner(r.CrossChainAccessTokenContract), n = i[e.getCurrentChainId()].accessTokenMintingFee ?? "0", o = {
|
|
9
|
+
value: C(n)
|
|
10
10
|
};
|
|
11
|
-
return await t.addToken(
|
|
12
|
-
}, A = async (e,
|
|
13
|
-
const
|
|
11
|
+
return await t.addToken(s, o);
|
|
12
|
+
}, A = async (e, s, t) => {
|
|
13
|
+
const n = e.getContractWithSigner(r.CrossChainAccessTokenContract), a = i[e.getCurrentChainId()].accessTokenMintingFee ?? "0", o = C(a), c = t.reduce(
|
|
14
14
|
(k, g) => k + g.messageFee,
|
|
15
15
|
0n
|
|
16
16
|
), T = {
|
|
@@ -19,7 +19,7 @@ const y = async (e) => (await e.getContractWithFetcher(a.CrossChainAccessTokenMa
|
|
|
19
19
|
}, u = {
|
|
20
20
|
value: o + c
|
|
21
21
|
};
|
|
22
|
-
return await
|
|
22
|
+
return await n.addTokenCrossChain(s, T, u);
|
|
23
23
|
};
|
|
24
24
|
export {
|
|
25
25
|
y as checkHinkalAccessToken,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../../../constants/protocol.constants.cjs"),T=require("../../../types/ethereum-network.types.cjs"),A=require("./approveToken.cjs"),q=require("../../utils/time.utils.cjs"),S=async(s,e,o,t,i,n,l,h)=>{const a=s.getContractWithSigner(T.ContractType.HinkalContract),p=await s.getEthereumAddress(),v=l??a,d=h??a,g="transact";e>0n&&o.erc20TokenAddress!==u.zeroAddress&&await A.approveTokenToHinkal(s,v,e,o);const c={value:e>0n&&o.erc20TokenAddress===u.zeroAddress?BigInt(e).toString():void 0};let r;try{r=(await d.estimateGas[g](t[0],t[1],t[2],n,i,{...c,from:p})).toNumber()}catch(y){console.log("hinkalDeposit: gas estimation error: ",{err:y})}const m=r&&r>=0?Math.ceil(r*12/10):void 0;return c.gasLimit=m,await q.waitLittle(),await d[g](t[0],t[1],t[2],n,i,c)};exports.transactCallDirect=S;
|
|
@@ -3,4 +3,4 @@ import { IHinkal } from '../../../data-structures/Hinkal/IHinkal';
|
|
|
3
3
|
import { CircomDataType, DimDataType } from '../../../types/circom-data.types';
|
|
4
4
|
import { ERC20Token } from '../../../types/token.types';
|
|
5
5
|
import { NewZkCallDataType } from '../../../types/snark.types';
|
|
6
|
-
export declare const transactCallDirect: (hinkal: IHinkal, amount: bigint, tokenToApprove: ERC20Token, newZkCallData: NewZkCallDataType, circomData: CircomDataType, dimData: DimDataType,
|
|
6
|
+
export declare const transactCallDirect: (hinkal: IHinkal, amount: bigint, tokenToApprove: ERC20Token, newZkCallData: NewZkCallDataType, circomData: CircomDataType, dimData: DimDataType, contractApporval?: ethers.Contract, contractTransaction?: ethers.Contract) => Promise<ethers.ContractTransaction>;
|
|
@@ -1,50 +1,36 @@
|
|
|
1
|
-
import { zeroAddress as
|
|
2
|
-
import { ContractType as
|
|
3
|
-
import { approveTokenToHinkal as
|
|
4
|
-
import { waitLittle as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import "ethers";
|
|
11
|
-
import "../../../types/curve.types.mjs";
|
|
12
|
-
import "../../../constants/token-data/index.mjs";
|
|
13
|
-
import "../../../constants/contracts.constants.mjs";
|
|
14
|
-
import "../../../constants/kyc.constants.mjs";
|
|
15
|
-
import "../../../constants/axelar.constants.mjs";
|
|
16
|
-
import "../../../constants/rewards.constants.mjs";
|
|
17
|
-
import "../../../constants/reorg-depths.constants.mjs";
|
|
18
|
-
const Q = async (t, r, s, i, u, A, C, y, c = !0) => {
|
|
19
|
-
const T = t.getCurrentChainId(), n = t.getContractWithSigner(x.HinkalContract), m = await t.getEthereumAddress(), h = C ?? n, d = y ?? n, v = t.userKeys.getAccessKey(), p = c ? "transact" : "addTokenAndTransact";
|
|
20
|
-
r > 0n && s.erc20TokenAddress !== f && await I(t, h, r, s);
|
|
21
|
-
const g = {
|
|
22
|
-
value: r > 0n && s.erc20TokenAddress === f ? BigInt(r).toString() : void 0
|
|
1
|
+
import { zeroAddress as g } from "../../../constants/protocol.constants.mjs";
|
|
2
|
+
import { ContractType as T } from "../../../types/ethereum-network.types.mjs";
|
|
3
|
+
import { approveTokenToHinkal as y } from "./approveToken.mjs";
|
|
4
|
+
import { waitLittle as u } from "../../utils/time.utils.mjs";
|
|
5
|
+
const S = async (s, r, e, t, c, n, p, f) => {
|
|
6
|
+
const a = s.getContractWithSigner(T.HinkalContract), h = await s.getEthereumAddress(), v = p ?? a, d = f ?? a, m = "transact";
|
|
7
|
+
r > 0n && e.erc20TokenAddress !== g && await y(s, v, r, e);
|
|
8
|
+
const i = {
|
|
9
|
+
value: r > 0n && e.erc20TokenAddress === g ? BigInt(r).toString() : void 0
|
|
23
10
|
};
|
|
24
11
|
let o;
|
|
25
|
-
const l = [
|
|
26
|
-
i[0],
|
|
27
|
-
i[1],
|
|
28
|
-
i[2],
|
|
29
|
-
A,
|
|
30
|
-
u,
|
|
31
|
-
{ ...g, from: m }
|
|
32
|
-
];
|
|
33
|
-
let e = [];
|
|
34
|
-
if (c)
|
|
35
|
-
e = l;
|
|
36
|
-
else {
|
|
37
|
-
const { signatureData: a } = await S.getAccessTokenSignature(T, m, v);
|
|
38
|
-
e = [a, ...l];
|
|
39
|
-
}
|
|
40
12
|
try {
|
|
41
|
-
o = (await d.estimateGas[
|
|
42
|
-
|
|
43
|
-
|
|
13
|
+
o = (await d.estimateGas[m](
|
|
14
|
+
t[0],
|
|
15
|
+
t[1],
|
|
16
|
+
t[2],
|
|
17
|
+
n,
|
|
18
|
+
c,
|
|
19
|
+
{ ...i, from: h }
|
|
20
|
+
)).toNumber();
|
|
21
|
+
} catch (A) {
|
|
22
|
+
console.log("hinkalDeposit: gas estimation error: ", { err: A });
|
|
44
23
|
}
|
|
45
|
-
const
|
|
46
|
-
return
|
|
24
|
+
const x = o && o >= 0 ? Math.ceil(o * 12 / 10) : void 0;
|
|
25
|
+
return i.gasLimit = x, await u(), await d[m](
|
|
26
|
+
t[0],
|
|
27
|
+
t[1],
|
|
28
|
+
t[2],
|
|
29
|
+
n,
|
|
30
|
+
c,
|
|
31
|
+
i
|
|
32
|
+
);
|
|
47
33
|
};
|
|
48
34
|
export {
|
|
49
|
-
|
|
35
|
+
S as transactCallDirect
|
|
50
36
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../../API/callRelayer.cjs");require("../../../constants/chains.constants.cjs");require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("../../../constants/vite.constants.cjs");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../../API/callRelayer.cjs");require("../../../constants/chains.constants.cjs");require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("../../../constants/vite.constants.cjs");const n=require("../../snarkjs/common.snarkjs.cjs");require("../../../types/circom-data.types.cjs");require("../../utils/external-action.utils.cjs");const u=async(a,r,s,c,t)=>{const i=n.serializeCircomData(c),e=await o.callRelayerTransactAPI(a,{a:r[0],b:r[1],c:r[2],dimData:s,circomData:i,withPrivateMempool:t});if(e.status==="success")return e.message;throw new Error(e.error)};exports.transactCallRelayer=u;
|
|
@@ -1,27 +1,25 @@
|
|
|
1
|
-
import { callRelayerTransactAPI as
|
|
1
|
+
import { callRelayerTransactAPI as e } from "../../../API/callRelayer.mjs";
|
|
2
2
|
import "../../../constants/chains.constants.mjs";
|
|
3
3
|
import "ethers";
|
|
4
4
|
import "circomlibjs-hinkal-fork";
|
|
5
5
|
import "libsodium-wrappers";
|
|
6
6
|
import "../../../constants/vite.constants.mjs";
|
|
7
|
-
import { serializeCircomData as
|
|
7
|
+
import { serializeCircomData as m } from "../../snarkjs/common.snarkjs.mjs";
|
|
8
8
|
import "../../../types/circom-data.types.mjs";
|
|
9
9
|
import "../../utils/external-action.utils.mjs";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const x = async (t, r, i, m, s) => {
|
|
13
|
-
const a = e(m), o = await c(t, {
|
|
10
|
+
const h = async (t, r, s, a, i) => {
|
|
11
|
+
const c = m(a), o = await e(t, {
|
|
14
12
|
a: r[0],
|
|
15
13
|
b: r[1],
|
|
16
14
|
c: r[2],
|
|
17
|
-
dimData:
|
|
18
|
-
circomData:
|
|
19
|
-
withPrivateMempool:
|
|
15
|
+
dimData: s,
|
|
16
|
+
circomData: c,
|
|
17
|
+
withPrivateMempool: i
|
|
20
18
|
});
|
|
21
19
|
if (o.status === "success")
|
|
22
20
|
return o.message;
|
|
23
21
|
throw new Error(o.error);
|
|
24
22
|
};
|
|
25
23
|
export {
|
|
26
|
-
|
|
24
|
+
h as transactCallRelayer
|
|
27
25
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../API/callOdosAPI.cjs")
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../API/callOdosAPI.cjs"),n=require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const d=require("../../constants/protocol.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const a=require("../../error-handling/error-codes.constants.cjs"),q=require("./etherFunctions.cjs");require("axios");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const A=async(r,e,o,u)=>{try{const t={chainId:r.getCurrentChainId()!==31337?r.getCurrentChainId():n.localhostNetwork,inputTokens:[{tokenAddress:e?.wrappedErc20TokenAddress??e.erc20TokenAddress,amount:q.getAmountInWei(e,u).toString()}],outputTokens:[{tokenAddress:o?.wrappedErc20TokenAddress??o.erc20TokenAddress,proportion:1}],userAddr:n.networkRegistry[r.getCurrentChainId()].contractData.odosExternalActionInstanceAddress||d.zeroAddress,slippageLimitPercent:10,disableRFQs:!0},{odosResponse:s,status:i}=await c.callOdosAPI(r.getCurrentChainId(),t);if(i!=="success")throw Error("Odos API Fetch Error");return{outSwapAmountValue:BigInt(s.outputTokens[0].amount),odosDataValue:s.transaction.data}}catch(t){throw console.log({error:t}),Error(a.transactionErrorCodes.NO_ODOS_PRICE)}};exports.getOdosPrice=A;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { IHinkal } from '../../data-structures';
|
|
1
2
|
import { ERC20Token } from '../../types';
|
|
2
|
-
export declare const getOdosPrice: (
|
|
3
|
+
export declare const getOdosPrice: (hinkal: IHinkal, inSwapToken: ERC20Token, outSwapToken: ERC20Token, inSwapAmount: string) => Promise<{
|
|
3
4
|
outSwapAmountValue: bigint;
|
|
4
5
|
odosDataValue: string;
|
|
5
6
|
}>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { callOdosAPI as
|
|
2
|
-
import "../../constants/
|
|
3
|
-
import { localhostNetwork as n, networkRegistry as d } from "../../constants/chains.constants.mjs";
|
|
1
|
+
import { callOdosAPI as d } from "../../API/callOdosAPI.mjs";
|
|
2
|
+
import { localhostNetwork as p, networkRegistry as m } from "../../constants/chains.constants.mjs";
|
|
4
3
|
import "../../constants/vite.constants.mjs";
|
|
5
4
|
import "../../constants/contracts.constants.mjs";
|
|
6
5
|
import "../../constants/kyc.constants.mjs";
|
|
@@ -20,40 +19,40 @@ import "circomlibjs-hinkal-fork";
|
|
|
20
19
|
import "libsodium-wrappers";
|
|
21
20
|
import "process";
|
|
22
21
|
import "buffer";
|
|
23
|
-
const
|
|
22
|
+
const b = async (r, t, e, i) => {
|
|
24
23
|
try {
|
|
25
|
-
const
|
|
26
|
-
chainId: r !== 31337 ? r :
|
|
24
|
+
const o = {
|
|
25
|
+
chainId: r.getCurrentChainId() !== 31337 ? r.getCurrentChainId() : p,
|
|
27
26
|
inputTokens: [
|
|
28
27
|
{
|
|
29
|
-
tokenAddress:
|
|
30
|
-
amount: u(
|
|
28
|
+
tokenAddress: t?.wrappedErc20TokenAddress ?? t.erc20TokenAddress,
|
|
29
|
+
amount: u(t, i).toString()
|
|
31
30
|
}
|
|
32
31
|
],
|
|
33
32
|
outputTokens: [
|
|
34
33
|
{
|
|
35
|
-
tokenAddress:
|
|
34
|
+
tokenAddress: e?.wrappedErc20TokenAddress ?? e.erc20TokenAddress,
|
|
36
35
|
proportion: 1
|
|
37
36
|
}
|
|
38
37
|
],
|
|
39
|
-
userAddr:
|
|
38
|
+
userAddr: m[r.getCurrentChainId()].contractData.odosExternalActionInstanceAddress || a,
|
|
40
39
|
slippageLimitPercent: 10,
|
|
41
40
|
disableRFQs: !0
|
|
42
41
|
// sometimes swap fails because of RFQs
|
|
43
|
-
}, { odosResponse:
|
|
44
|
-
r,
|
|
45
|
-
|
|
42
|
+
}, { odosResponse: s, status: n } = await d(
|
|
43
|
+
r.getCurrentChainId(),
|
|
44
|
+
o
|
|
46
45
|
);
|
|
47
|
-
if (
|
|
46
|
+
if (n !== "success")
|
|
48
47
|
throw Error("Odos API Fetch Error");
|
|
49
48
|
return {
|
|
50
|
-
outSwapAmountValue: BigInt(
|
|
51
|
-
odosDataValue:
|
|
49
|
+
outSwapAmountValue: BigInt(s.outputTokens[0].amount),
|
|
50
|
+
odosDataValue: s.transaction.data
|
|
52
51
|
};
|
|
53
|
-
} catch (
|
|
54
|
-
throw console.log({ error:
|
|
52
|
+
} catch (o) {
|
|
53
|
+
throw console.log({ error: o }), Error(c.NO_ODOS_PRICE);
|
|
55
54
|
}
|
|
56
55
|
};
|
|
57
56
|
export {
|
|
58
|
-
|
|
57
|
+
b as getOdosPrice
|
|
59
58
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../API/callOneInchAPI.cjs");require("../../constants/
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../API/callOneInchAPI.cjs");require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const e=require("../../constants/protocol.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const u=require("../../error-handling/error-codes.constants.cjs"),d=require("./etherFunctions.cjs");require("axios");require("../../types/circom-data.types.cjs");const a=require("../../types/ethereum-network.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const q=async(s,t,n,c)=>{try{const o={fromTokenAddress:t.erc20TokenAddress!==e.zeroAddress?t.erc20TokenAddress:e.oneInchZeroAddress,toTokenAddress:n.erc20TokenAddress!==e.zeroAddress?n.erc20TokenAddress:e.oneInchZeroAddress,fromAddress:e.zeroAddress,destReceiver:s.getContractMetadata(a.ContractType.OneInchExternalActionContract).address,amount:d.getAmountInWei(t,c),slippage:10,disableEstimate:!0,allowPartialFill:!1},r=await i.callOneInchAPI(s.getCurrentChainId(),o);if(!r||!r.tx)throw Error("OneInch API price fetch error");return{outSwapAmountValue:BigInt(r.toAmount),oneInchDataValue:r.tx.data}}catch(o){throw console.log({error:o}),Error(u.transactionErrorCodes.NO_ONEINCH_PRICE)}};exports.getOneInchPrice=q;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { IHinkal } from '../../data-structures/Hinkal/IHinkal';
|
|
1
2
|
import { ERC20Token } from '../../types';
|
|
2
|
-
export declare const getOneInchPrice: (
|
|
3
|
+
export declare const getOneInchPrice: (hinkal: IHinkal, inSwapToken: ERC20Token, outSwapToken: ERC20Token, inSwapAmount: string) => Promise<{
|
|
3
4
|
outSwapAmountValue: bigint;
|
|
4
5
|
oneInchDataValue: string;
|
|
5
6
|
}>;
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import { callOneInchAPI as
|
|
2
|
-
import "../../constants/token-data/index.mjs";
|
|
1
|
+
import { callOneInchAPI as a } from "../../API/callOneInchAPI.mjs";
|
|
3
2
|
import "../../constants/chains.constants.mjs";
|
|
4
3
|
import "../../constants/vite.constants.mjs";
|
|
5
4
|
import "../../constants/contracts.constants.mjs";
|
|
6
5
|
import "../../constants/kyc.constants.mjs";
|
|
7
|
-
import { zeroAddress as e, oneInchZeroAddress as
|
|
6
|
+
import { zeroAddress as e, oneInchZeroAddress as m } from "../../constants/protocol.constants.mjs";
|
|
8
7
|
import "../../constants/coingecko.constants.mjs";
|
|
9
8
|
import "../../constants/axelar.constants.mjs";
|
|
10
9
|
import "../../constants/rewards.constants.mjs";
|
|
11
10
|
import "../../constants/reorg-depths.constants.mjs";
|
|
12
|
-
import { transactionErrorCodes as
|
|
13
|
-
import { getAmountInWei as
|
|
11
|
+
import { transactionErrorCodes as c } from "../../error-handling/error-codes.constants.mjs";
|
|
12
|
+
import { getAmountInWei as d } from "./etherFunctions.mjs";
|
|
14
13
|
import "axios";
|
|
15
14
|
import "../../types/circom-data.types.mjs";
|
|
16
|
-
import { ContractType as
|
|
15
|
+
import { ContractType as p } from "../../types/ethereum-network.types.mjs";
|
|
17
16
|
import "../../types/transactions.types.mjs";
|
|
18
17
|
import "../../types/curve.types.mjs";
|
|
19
18
|
import "ethers";
|
|
@@ -21,16 +20,15 @@ import "circomlibjs-hinkal-fork";
|
|
|
21
20
|
import "libsodium-wrappers";
|
|
22
21
|
import "process";
|
|
23
22
|
import "buffer";
|
|
24
|
-
|
|
25
|
-
const D = async (m, o, i, n) => {
|
|
23
|
+
const v = async (s, t, i, n) => {
|
|
26
24
|
try {
|
|
27
|
-
const
|
|
28
|
-
fromTokenAddress:
|
|
29
|
-
toTokenAddress: i.erc20TokenAddress !== e ? i.erc20TokenAddress :
|
|
25
|
+
const o = {
|
|
26
|
+
fromTokenAddress: t.erc20TokenAddress !== e ? t.erc20TokenAddress : m,
|
|
27
|
+
toTokenAddress: i.erc20TokenAddress !== e ? i.erc20TokenAddress : m,
|
|
30
28
|
fromAddress: e,
|
|
31
29
|
// we user zero address here because this paramater is not relevant to us, only destReceiver is
|
|
32
|
-
destReceiver:
|
|
33
|
-
amount:
|
|
30
|
+
destReceiver: s.getContractMetadata(p.OneInchExternalActionContract).address,
|
|
31
|
+
amount: d(t, n),
|
|
34
32
|
slippage: 10,
|
|
35
33
|
disableEstimate: !0,
|
|
36
34
|
// disable gas estimation, we don't need it
|
|
@@ -39,7 +37,7 @@ const D = async (m, o, i, n) => {
|
|
|
39
37
|
// and returning leftover tokens to fromAddress
|
|
40
38
|
// this is not what we want
|
|
41
39
|
allowPartialFill: !1
|
|
42
|
-
}, r = await
|
|
40
|
+
}, r = await a(s.getCurrentChainId(), o);
|
|
43
41
|
if (!r || !r.tx)
|
|
44
42
|
throw Error("OneInch API price fetch error");
|
|
45
43
|
return {
|
|
@@ -47,10 +45,10 @@ const D = async (m, o, i, n) => {
|
|
|
47
45
|
oneInchDataValue: r.tx.data
|
|
48
46
|
// calldata to use
|
|
49
47
|
};
|
|
50
|
-
} catch (
|
|
51
|
-
throw console.log({ error:
|
|
48
|
+
} catch (o) {
|
|
49
|
+
throw console.log({ error: o }), Error(c.NO_ONEINCH_PRICE);
|
|
52
50
|
}
|
|
53
51
|
};
|
|
54
52
|
export {
|
|
55
|
-
|
|
53
|
+
v as getOneInchPrice
|
|
56
54
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("ethers"),d=require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const C=require("../../constants/protocol.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const l=require("../../error-handling/error-codes.constants.cjs"),y=require("./etherFunctions.cjs");require("axios");require("../../types/circom-data.types.cjs");const u=require("../../types/ethereum-network.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const h=require("../../error-handling/logError.cjs"),w=async(t,s,r,o)=>{const c=(await Promise.all([100,500,3e3,1e4].map(async e=>({poolAddress:await s.getPool(r,o,e),fee:e})))).filter(({poolAddress:e})=>e!==C.zeroAddress),n=await Promise.all(c.map(async e=>({poolAddress:e.poolAddress,fee:e.fee,token1Balance:(await t.balanceOf(e.poolAddress)).toBigInt()}))),i=n.map(e=>e.token1Balance).reduce((e,p)=>p>=e?p:e,0n);if(i===0n)throw new Error(l.transactionErrorCodes.UNISWAP_NOT_ENOUGH_LIQUIDITY);return n.find(e=>e.token1Balance===i)},q=async(t,s,r,o,c)=>{try{if(!d.networkRegistry[t.getCurrentChainId()].quoterV2Address)throw Error("No Quoter Contract Provided");return(await t.getContractWithFetcher(u.ContractType.UniswapV3QuoterContract,d.networkRegistry[t.getCurrentChainId()].quoterV2Address).callStatic.quoteExactInputSingle({tokenIn:s.wrappedErc20TokenAddress??s.erc20TokenAddress,tokenOut:r.wrappedErc20TokenAddress??r.erc20TokenAddress,fee:o,amountIn:c,sqrtPriceLimitX96:0})).amountOut.toBigInt()}catch(n){throw h.logError(n),n}},g=async(t,s,r)=>{try{const o=t.getCurrentChainId(),c=t.getContractWithFetcher(u.ContractType.UniswapV3FactoryContract,d.networkRegistry[o].uniswapV3FactoryAddress),n=t.getContractWithFetcher(u.ContractType.ERC20Contract,r.wrappedErc20TokenAddress??r.erc20TokenAddress),{fee:a}=await w(n,c,s.wrappedErc20TokenAddress??s.erc20TokenAddress,r.wrappedErc20TokenAddress??r.erc20TokenAddress);return a}catch(o){throw console.log("Error in getUniswapFee",o),o}},P=async(t,s,r,o)=>{try{const c=await g(t,r,o),n=A.utils.defaultAbiCoder.encode(["uint24"],[c]),a=y.getAmountInWei(r,s);return{tokenPrice:await q(t,r,o,c,a),poolFee:n}}catch{throw Error(l.transactionErrorCodes.NO_UNISWAP_PRICE)}};exports.getUniswapFee=g;exports.getUniswapPrice=P;exports.getUniswapPriceHelper=q;exports.searchPoolAndFee=w;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Contract } from 'ethers';
|
|
2
|
+
import { IHinkal } from '../../data-structures';
|
|
2
3
|
import { ERC20Token } from '../../types';
|
|
3
|
-
import { IHinkal } from '../../data-structures/Hinkal/IHinkal';
|
|
4
4
|
interface PoolAndFee {
|
|
5
5
|
poolAddress: string;
|
|
6
6
|
fee: number;
|
|
7
7
|
token1Balance: bigint;
|
|
8
8
|
}
|
|
9
9
|
export declare const searchPoolAndFee: (token1Contract: Contract, factory: Contract, token0Address: string, token1Address: string) => Promise<PoolAndFee>;
|
|
10
|
-
export declare const getUniswapPriceHelper: (hinkal: IHinkal,
|
|
11
|
-
export declare const getUniswapFee: (hinkal: IHinkal,
|
|
12
|
-
export declare const getUniswapPrice: (hinkal: IHinkal,
|
|
10
|
+
export declare const getUniswapPriceHelper: (hinkal: IHinkal, token0: ERC20Token, token1: ERC20Token, fee: number, inSwapAmount: bigint) => Promise<bigint>;
|
|
11
|
+
export declare const getUniswapFee: (hinkal: IHinkal, token0: ERC20Token, token1: ERC20Token) => Promise<number>;
|
|
12
|
+
export declare const getUniswapPrice: (hinkal: IHinkal, inSwapAmount: string, inSwapToken: ERC20Token, outSwapToken: ERC20Token) => Promise<{
|
|
13
13
|
tokenPrice: bigint;
|
|
14
14
|
poolFee: string;
|
|
15
15
|
}>;
|
|
@@ -1,98 +1,87 @@
|
|
|
1
|
-
import { utils as
|
|
2
|
-
import "../../constants/
|
|
3
|
-
import { networkRegistry as p } from "../../constants/chains.constants.mjs";
|
|
1
|
+
import { utils as w } from "ethers";
|
|
2
|
+
import { networkRegistry as d } from "../../constants/chains.constants.mjs";
|
|
4
3
|
import "../../constants/vite.constants.mjs";
|
|
5
4
|
import "../../constants/contracts.constants.mjs";
|
|
6
5
|
import "../../constants/kyc.constants.mjs";
|
|
7
|
-
import { zeroAddress as
|
|
6
|
+
import { zeroAddress as A } from "../../constants/protocol.constants.mjs";
|
|
8
7
|
import "../../constants/coingecko.constants.mjs";
|
|
9
8
|
import "../../constants/axelar.constants.mjs";
|
|
10
9
|
import "../../constants/rewards.constants.mjs";
|
|
11
10
|
import "../../constants/reorg-depths.constants.mjs";
|
|
12
|
-
import { transactionErrorCodes as
|
|
13
|
-
import { getAmountInWei as
|
|
11
|
+
import { transactionErrorCodes as u } from "../../error-handling/error-codes.constants.mjs";
|
|
12
|
+
import { getAmountInWei as l } from "./etherFunctions.mjs";
|
|
14
13
|
import "axios";
|
|
15
14
|
import "../../types/circom-data.types.mjs";
|
|
16
|
-
import { ContractType as
|
|
15
|
+
import { ContractType as p } from "../../types/ethereum-network.types.mjs";
|
|
17
16
|
import "../../types/transactions.types.mjs";
|
|
18
17
|
import "../../types/curve.types.mjs";
|
|
19
18
|
import "circomlibjs-hinkal-fork";
|
|
20
19
|
import "libsodium-wrappers";
|
|
21
20
|
import "process";
|
|
22
21
|
import "buffer";
|
|
23
|
-
import { logError as
|
|
24
|
-
const
|
|
25
|
-
const
|
|
22
|
+
import { logError as C } from "../../error-handling/logError.mjs";
|
|
23
|
+
const f = async (e, s, t, o) => {
|
|
24
|
+
const c = (await Promise.all(
|
|
26
25
|
[100, 500, 3e3, 1e4].map(async (r) => ({
|
|
27
|
-
poolAddress: await
|
|
26
|
+
poolAddress: await s.getPool(t, o, r),
|
|
28
27
|
fee: r
|
|
29
28
|
}))
|
|
30
|
-
)).filter(({ poolAddress: r }) => r !==
|
|
31
|
-
|
|
29
|
+
)).filter(({ poolAddress: r }) => r !== A), n = await Promise.all(
|
|
30
|
+
c.map(async (r) => ({
|
|
32
31
|
poolAddress: r.poolAddress,
|
|
33
32
|
fee: r.fee,
|
|
34
|
-
token1Balance: (await
|
|
33
|
+
token1Balance: (await e.balanceOf(r.poolAddress)).toBigInt()
|
|
35
34
|
}))
|
|
36
35
|
), i = n.map((r) => r.token1Balance).reduce((r, m) => m >= r ? m : r, 0n);
|
|
37
36
|
if (i === 0n)
|
|
38
|
-
throw new Error(
|
|
37
|
+
throw new Error(u.UNISWAP_NOT_ENOUGH_LIQUIDITY);
|
|
39
38
|
return n.find((r) => r.token1Balance === i);
|
|
40
|
-
}, g = async (
|
|
39
|
+
}, g = async (e, s, t, o, c) => {
|
|
41
40
|
try {
|
|
42
|
-
if (!
|
|
41
|
+
if (!d[e.getCurrentChainId()].quoterV2Address)
|
|
43
42
|
throw Error("No Quoter Contract Provided");
|
|
44
|
-
return (await
|
|
45
|
-
|
|
46
|
-
d.
|
|
47
|
-
p[o].quoterV2Address
|
|
43
|
+
return (await e.getContractWithFetcher(
|
|
44
|
+
p.UniswapV3QuoterContract,
|
|
45
|
+
d[e.getCurrentChainId()].quoterV2Address
|
|
48
46
|
).callStatic.quoteExactInputSingle({
|
|
49
|
-
tokenIn:
|
|
47
|
+
tokenIn: s.wrappedErc20TokenAddress ?? s.erc20TokenAddress,
|
|
50
48
|
tokenOut: t.wrappedErc20TokenAddress ?? t.erc20TokenAddress,
|
|
51
|
-
fee:
|
|
52
|
-
amountIn:
|
|
49
|
+
fee: o,
|
|
50
|
+
amountIn: c,
|
|
53
51
|
sqrtPriceLimitX96: 0
|
|
54
52
|
})).amountOut.toBigInt();
|
|
55
|
-
} catch (
|
|
56
|
-
throw
|
|
53
|
+
} catch (n) {
|
|
54
|
+
throw C(n), n;
|
|
57
55
|
}
|
|
58
|
-
},
|
|
56
|
+
}, I = async (e, s, t) => {
|
|
59
57
|
try {
|
|
60
|
-
const e =
|
|
61
|
-
|
|
62
|
-
d.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
o,
|
|
66
|
-
d.ERC20Contract,
|
|
58
|
+
const o = e.getCurrentChainId(), c = e.getContractWithFetcher(
|
|
59
|
+
p.UniswapV3FactoryContract,
|
|
60
|
+
d[o].uniswapV3FactoryAddress
|
|
61
|
+
), n = e.getContractWithFetcher(
|
|
62
|
+
p.ERC20Contract,
|
|
67
63
|
t.wrappedErc20TokenAddress ?? t.erc20TokenAddress
|
|
68
|
-
), { fee:
|
|
64
|
+
), { fee: a } = await f(
|
|
69
65
|
n,
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
c,
|
|
67
|
+
s.wrappedErc20TokenAddress ?? s.erc20TokenAddress,
|
|
72
68
|
t.wrappedErc20TokenAddress ?? t.erc20TokenAddress
|
|
73
69
|
);
|
|
74
|
-
return
|
|
75
|
-
} catch (
|
|
76
|
-
throw console.log("Error in getUniswapFee",
|
|
70
|
+
return a;
|
|
71
|
+
} catch (o) {
|
|
72
|
+
throw console.log("Error in getUniswapFee", o), o;
|
|
77
73
|
}
|
|
78
|
-
},
|
|
74
|
+
}, D = async (e, s, t, o) => {
|
|
79
75
|
try {
|
|
80
|
-
const
|
|
81
|
-
return { tokenPrice: await g(
|
|
82
|
-
s,
|
|
83
|
-
o,
|
|
84
|
-
t,
|
|
85
|
-
e,
|
|
86
|
-
n,
|
|
87
|
-
i
|
|
88
|
-
), poolFee: c };
|
|
76
|
+
const c = await I(e, t, o), n = w.defaultAbiCoder.encode(["uint24"], [c]), a = l(t, s);
|
|
77
|
+
return { tokenPrice: await g(e, t, o, c, a), poolFee: n };
|
|
89
78
|
} catch {
|
|
90
|
-
throw Error(
|
|
79
|
+
throw Error(u.NO_UNISWAP_PRICE);
|
|
91
80
|
}
|
|
92
81
|
};
|
|
93
82
|
export {
|
|
94
|
-
|
|
95
|
-
|
|
83
|
+
I as getUniswapFee,
|
|
84
|
+
D as getUniswapPrice,
|
|
96
85
|
g as getUniswapPriceHelper,
|
|
97
|
-
|
|
86
|
+
f as searchPoolAndFee
|
|
98
87
|
};
|