@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,15 +1,15 @@
|
|
|
1
1
|
import { UAParser as s } from "ua-parser-js";
|
|
2
|
-
const a = new s(), n =
|
|
3
|
-
const { name: e, version:
|
|
4
|
-
return !(e === "Safari" &&
|
|
2
|
+
const a = new s(), n = 17, i = () => {
|
|
3
|
+
const { name: e, version: t } = a.getBrowser(), r = parseInt(t?.split(".")[0] ?? "0", 10);
|
|
4
|
+
return !(e === "Safari" && r && n > r);
|
|
5
5
|
}, o = {
|
|
6
6
|
mpcVault: "MPCVault - Multisig Wallet",
|
|
7
7
|
utila: "UtilaWallet"
|
|
8
|
-
},
|
|
9
|
-
const
|
|
10
|
-
return !Object.values(o).includes(
|
|
8
|
+
}, u = (e) => {
|
|
9
|
+
const t = e?.session?.peer?.metadata?.name;
|
|
10
|
+
return !Object.values(o).includes(t);
|
|
11
11
|
};
|
|
12
12
|
export {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
i as browserSupported,
|
|
14
|
+
u 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.CrossChainAccessTokenManagerContract).functions.hasToken(e.userKeys.getAccessKey()))[0],y=async(e,n)=>{const t=e.getContractWithSigner(r.ContractType.CrossChainAccessTokenManagerContract),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 a } 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(a.CrossChainAccessTokenManagerContract).functions.hasToken(e.userKeys.getAccessKey()))[0], W = async (e, n) => {
|
|
8
|
+
const t = e.getContractWithSigner(a.CrossChainAccessTokenManagerContract), s = i[e.getCurrentChainId()].accessTokenMintingFee ?? "0", o = {
|
|
9
|
+
value: C(s)
|
|
10
10
|
};
|
|
11
|
-
return await t.addToken(
|
|
12
|
-
}, A = async (e,
|
|
13
|
-
const
|
|
11
|
+
return await t.addToken(n, o);
|
|
12
|
+
}, A = async (e, n, t) => {
|
|
13
|
+
const s = e.getContractWithSigner(a.CrossChainAccessTokenContract), r = i[e.getCurrentChainId()].accessTokenMintingFee ?? "0", o = C(r), 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(r.CrossChainAccessTokenCo
|
|
|
19
19
|
}, u = {
|
|
20
20
|
value: o + c
|
|
21
21
|
};
|
|
22
|
-
return await
|
|
22
|
+
return await s.addTokenCrossChain(n, 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 m=require("../../../constants/protocol.constants.cjs"),I=require("../../../types/ethereum-network.types.cjs"),S=require("./approveToken.cjs"),f=require("../../utils/time.utils.cjs");require("../../../constants/chains.constants.cjs");require("../../../constants/vite.constants.cjs");require("axios");require("../../../constants/coingecko.constants.cjs");const b=require("../../../API/API.cjs");require("ethers");require("../../../types/curve.types.cjs");require("../../../constants/token-data/index.cjs");require("../../../constants/contracts.constants.cjs");require("../../../constants/kyc.constants.cjs");require("../../../constants/axelar.constants.cjs");require("../../../constants/rewards.constants.cjs");require("../../../constants/reorg-depths.constants.cjs");const x=async(e,t,o,i,A,y,C,T,n=!0)=>{const p=e.getCurrentChainId(),a=e.getContractWithSigner(I.ContractType.HinkalContract),u=await e.getEthereumAddress(),v=C??a,d=T??a,h=e.userKeys.getAccessKey(),g=n?"transact":"addTokenAndTransact";t>0n&&o.erc20TokenAddress!==m.zeroAddress&&await S.approveTokenToHinkal(e,v,t,o);const q={value:t>0n&&o.erc20TokenAddress===m.zeroAddress?BigInt(t).toString():void 0};let r;const l=[i[0],i[1],i[2],y,A,{...q,from:u}];let s=[];if(n)s=l;else{const{signatureData:c}=await b.API.getAccessTokenSignature(p,u,h);s=[c,...l]}try{r=(await d.estimateGas[g](...s)).toNumber()}catch(c){console.log("hinkalDeposit: gas estimation error",{err:c})}const w=r&&r>=0?Math.ceil(r*12/10):void 0;return q.gasLimit=w,await f.waitLittle(),await d[g](...s)};exports.transactCallDirect=x;
|
|
@@ -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, contractApproval?: ethers.Contract, contractTransaction?: ethers.Contract, hasAccessToken?: boolean) => Promise<any>;
|
|
@@ -1,36 +1,50 @@
|
|
|
1
|
-
import { zeroAddress as
|
|
2
|
-
import { ContractType as
|
|
3
|
-
import { approveTokenToHinkal as
|
|
4
|
-
import { waitLittle as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { zeroAddress as f } from "../../../constants/protocol.constants.mjs";
|
|
2
|
+
import { ContractType as x } from "../../../types/ethereum-network.types.mjs";
|
|
3
|
+
import { approveTokenToHinkal as I } from "./approveToken.mjs";
|
|
4
|
+
import { waitLittle as K } from "../../utils/time.utils.mjs";
|
|
5
|
+
import "../../../constants/chains.constants.mjs";
|
|
6
|
+
import "../../../constants/vite.constants.mjs";
|
|
7
|
+
import "axios";
|
|
8
|
+
import "../../../constants/coingecko.constants.mjs";
|
|
9
|
+
import { API as S } from "../../../API/API.mjs";
|
|
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
|
|
10
23
|
};
|
|
11
24
|
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
|
+
}
|
|
12
40
|
try {
|
|
13
|
-
o = (await d.estimateGas[
|
|
14
|
-
|
|
15
|
-
|
|
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 });
|
|
41
|
+
o = (await d.estimateGas[p](...e)).toNumber();
|
|
42
|
+
} catch (a) {
|
|
43
|
+
console.log("hinkalDeposit: gas estimation error", { err: a });
|
|
23
44
|
}
|
|
24
|
-
const
|
|
25
|
-
return
|
|
26
|
-
t[0],
|
|
27
|
-
t[1],
|
|
28
|
-
t[2],
|
|
29
|
-
n,
|
|
30
|
-
c,
|
|
31
|
-
i
|
|
32
|
-
);
|
|
45
|
+
const w = o && o >= 0 ? Math.ceil(o * 12 / 10) : void 0;
|
|
46
|
+
return g.gasLimit = w, await K(), await d[p](...e);
|
|
33
47
|
};
|
|
34
48
|
export {
|
|
35
|
-
|
|
49
|
+
Q as transactCallDirect
|
|
36
50
|
};
|
|
@@ -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 u=require("../../snarkjs/common.snarkjs.cjs");require("../../../types/circom-data.types.cjs");require("../../utils/external-action.utils.cjs");require("node-forge");require("axios");const n=async(a,r,s,c,t)=>{const i=u.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=n;
|
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
import { callRelayerTransactAPI as
|
|
1
|
+
import { callRelayerTransactAPI as c } 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 e } from "../../snarkjs/common.snarkjs.mjs";
|
|
8
8
|
import "../../../types/circom-data.types.mjs";
|
|
9
9
|
import "../../utils/external-action.utils.mjs";
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
import "node-forge";
|
|
11
|
+
import "axios";
|
|
12
|
+
const x = async (t, r, i, m, s) => {
|
|
13
|
+
const a = e(m), o = await c(t, {
|
|
12
14
|
a: r[0],
|
|
13
15
|
b: r[1],
|
|
14
16
|
c: r[2],
|
|
15
|
-
dimData:
|
|
16
|
-
circomData:
|
|
17
|
-
withPrivateMempool:
|
|
17
|
+
dimData: i,
|
|
18
|
+
circomData: a,
|
|
19
|
+
withPrivateMempool: s
|
|
18
20
|
});
|
|
19
21
|
if (o.status === "success")
|
|
20
22
|
return o.message;
|
|
21
23
|
throw new Error(o.error);
|
|
22
24
|
};
|
|
23
25
|
export {
|
|
24
|
-
|
|
26
|
+
x as transactCallRelayer
|
|
25
27
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../../constants/contracts.constants.cjs"),a=require("../../constants/chains.constants.cjs"),g=require("../../error-handling/error-codes.constants.cjs"),c=require("ethers"),s=(t,o)=>{const r=a.networkRegistry[o];if(!r)throw new Error(g.transactionErrorCodes.UNSUPPORTED_NETWORK);const e=d.contractMetadataMapping[t];if(!e)throw new Error(`Unsupported contractType: ${t}`);return e(r.contractData)},i=(t,o,r)=>{const e=s(t,o);if(!e.abi)throw new Error(`No ABI configured for contractType: ${t}`);if(e.address&&r)throw new Error(`Overriding address is not supported for contractType: ${t}`);const n=e.address??r;if(!n)throw new Error(`No contractAddress configured for contractType: ${t}`);return new c.ethers.Contract(n,e.abi)},h=(t,o,r=void 0)=>i(o,t,r).connect(new c.ethers.providers.StaticJsonRpcProvider(a.networkRegistry[t].fetchRpcUrl));exports.getContract=i;exports.getContractMetadata=s;exports.getContractWithFetcherByChainId=h;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ContractMetadata, ContractType } from '../../types/ethereum-network.types';
|
|
2
|
+
import { ethers } from 'ethers';
|
|
3
|
+
export declare const getContractMetadata: (contractType: ContractType, chainId: number) => ContractMetadata;
|
|
4
|
+
export declare const getContract: (contractType: ContractType, chainId: number, contractAddress?: string) => ethers.Contract;
|
|
5
|
+
export declare const getContractWithFetcherByChainId: (chainId: number, contractType: ContractType, contractAddress?: undefined) => ethers.Contract;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { contractMetadataMapping as s } from "../../constants/contracts.constants.mjs";
|
|
2
|
+
import { networkRegistry as a } from "../../constants/chains.constants.mjs";
|
|
3
|
+
import { transactionErrorCodes as i } from "../../error-handling/error-codes.constants.mjs";
|
|
4
|
+
import { ethers as c } from "ethers";
|
|
5
|
+
const d = (r, e) => {
|
|
6
|
+
const t = a[e];
|
|
7
|
+
if (!t)
|
|
8
|
+
throw new Error(i.UNSUPPORTED_NETWORK);
|
|
9
|
+
const o = s[r];
|
|
10
|
+
if (!o)
|
|
11
|
+
throw new Error(`Unsupported contractType: ${r}`);
|
|
12
|
+
return o(t.contractData);
|
|
13
|
+
}, f = (r, e, t) => {
|
|
14
|
+
const o = d(r, e);
|
|
15
|
+
if (!o.abi)
|
|
16
|
+
throw new Error(`No ABI configured for contractType: ${r}`);
|
|
17
|
+
if (o.address && t)
|
|
18
|
+
throw new Error(`Overriding address is not supported for contractType: ${r}`);
|
|
19
|
+
const n = o.address ?? t;
|
|
20
|
+
if (!n)
|
|
21
|
+
throw new Error(`No contractAddress configured for contractType: ${r}`);
|
|
22
|
+
return new c.Contract(n, o.abi);
|
|
23
|
+
}, m = (r, e, t = void 0) => f(e, r, t).connect(
|
|
24
|
+
new c.providers.StaticJsonRpcProvider(a[r].fetchRpcUrl)
|
|
25
|
+
);
|
|
26
|
+
export {
|
|
27
|
+
f as getContract,
|
|
28
|
+
d as getContractMetadata,
|
|
29
|
+
m as getContractWithFetcherByChainId
|
|
30
|
+
};
|
|
@@ -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");require("../../constants/token-data/index.cjs");const n=require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const a=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 d=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 l=async(r,e,t,u)=>{try{const o={chainId:r!==31337?r:n.localhostNetwork,inputTokens:[{tokenAddress:e?.wrappedErc20TokenAddress??e.erc20TokenAddress,amount:q.getAmountInWei(e,u).toString()}],outputTokens:[{tokenAddress:t?.wrappedErc20TokenAddress??t.erc20TokenAddress,proportion:1}],userAddr:n.networkRegistry[r].contractData.odosExternalActionInstanceAddress||a.zeroAddress,slippageLimitPercent:10,disableRFQs:!0},{odosResponse:s,status:i}=await c.callOdosAPI(r,o);if(i!=="success")throw Error("Odos API Fetch Error");return{outSwapAmountValue:BigInt(s.outputTokens[0].amount),odosDataValue:s.transaction.data}}catch(o){throw console.log({error:o}),Error(d.transactionErrorCodes.NO_ODOS_PRICE)}};exports.getOdosPrice=l;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { IHinkal } from '../../data-structures';
|
|
2
1
|
import { ERC20Token } from '../../types';
|
|
3
|
-
export declare const getOdosPrice: (
|
|
2
|
+
export declare const getOdosPrice: (chainId: number, inSwapToken: ERC20Token, outSwapToken: ERC20Token, inSwapAmount: string) => Promise<{
|
|
4
3
|
outSwapAmountValue: bigint;
|
|
5
4
|
odosDataValue: string;
|
|
6
5
|
}>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { callOdosAPI as
|
|
2
|
-
import
|
|
1
|
+
import { callOdosAPI as m } from "../../API/callOdosAPI.mjs";
|
|
2
|
+
import "../../constants/token-data/index.mjs";
|
|
3
|
+
import { localhostNetwork as n, networkRegistry as d } from "../../constants/chains.constants.mjs";
|
|
3
4
|
import "../../constants/vite.constants.mjs";
|
|
4
5
|
import "../../constants/contracts.constants.mjs";
|
|
5
6
|
import "../../constants/kyc.constants.mjs";
|
|
@@ -19,40 +20,40 @@ import "circomlibjs-hinkal-fork";
|
|
|
19
20
|
import "libsodium-wrappers";
|
|
20
21
|
import "process";
|
|
21
22
|
import "buffer";
|
|
22
|
-
const
|
|
23
|
+
const z = async (r, o, s, i) => {
|
|
23
24
|
try {
|
|
24
|
-
const
|
|
25
|
-
chainId: r
|
|
25
|
+
const t = {
|
|
26
|
+
chainId: r !== 31337 ? r : n,
|
|
26
27
|
inputTokens: [
|
|
27
28
|
{
|
|
28
|
-
tokenAddress:
|
|
29
|
-
amount: u(
|
|
29
|
+
tokenAddress: o?.wrappedErc20TokenAddress ?? o.erc20TokenAddress,
|
|
30
|
+
amount: u(o, i).toString()
|
|
30
31
|
}
|
|
31
32
|
],
|
|
32
33
|
outputTokens: [
|
|
33
34
|
{
|
|
34
|
-
tokenAddress:
|
|
35
|
+
tokenAddress: s?.wrappedErc20TokenAddress ?? s.erc20TokenAddress,
|
|
35
36
|
proportion: 1
|
|
36
37
|
}
|
|
37
38
|
],
|
|
38
|
-
userAddr:
|
|
39
|
+
userAddr: d[r].contractData.odosExternalActionInstanceAddress || a,
|
|
39
40
|
slippageLimitPercent: 10,
|
|
40
41
|
disableRFQs: !0
|
|
41
42
|
// sometimes swap fails because of RFQs
|
|
42
|
-
}, { odosResponse:
|
|
43
|
-
r
|
|
44
|
-
|
|
43
|
+
}, { odosResponse: e, status: p } = await m(
|
|
44
|
+
r,
|
|
45
|
+
t
|
|
45
46
|
);
|
|
46
|
-
if (
|
|
47
|
+
if (p !== "success")
|
|
47
48
|
throw Error("Odos API Fetch Error");
|
|
48
49
|
return {
|
|
49
|
-
outSwapAmountValue: BigInt(
|
|
50
|
-
odosDataValue:
|
|
50
|
+
outSwapAmountValue: BigInt(e.outputTokens[0].amount),
|
|
51
|
+
odosDataValue: e.transaction.data
|
|
51
52
|
};
|
|
52
|
-
} catch (
|
|
53
|
-
throw console.log({ error:
|
|
53
|
+
} catch (t) {
|
|
54
|
+
throw console.log({ error: t }), Error(c.NO_ODOS_PRICE);
|
|
54
55
|
}
|
|
55
56
|
};
|
|
56
57
|
export {
|
|
57
|
-
|
|
58
|
+
z as getOdosPrice
|
|
58
59
|
};
|
|
@@ -1 +1 @@
|
|
|
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"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../API/callOneInchAPI.cjs");require("../../constants/token-data/index.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"),a=require("./etherFunctions.cjs");require("axios");require("../../types/circom-data.types.cjs");const d=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=require("./getContractMetadata.cjs"),l=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:q.getContractMetadata(d.ContractType.OneInchExternalActionContract,s).address,amount:a.getAmountInWei(t,c),slippage:10,disableEstimate:!0,allowPartialFill:!1},r=await i.callOneInchAPI(s,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=l;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { IHinkal } from '../../data-structures/Hinkal/IHinkal';
|
|
2
1
|
import { ERC20Token } from '../../types';
|
|
3
|
-
export declare const getOneInchPrice: (
|
|
2
|
+
export declare const getOneInchPrice: (chainId: number, inSwapToken: ERC20Token, outSwapToken: ERC20Token, inSwapAmount: string) => Promise<{
|
|
4
3
|
outSwapAmountValue: bigint;
|
|
5
4
|
oneInchDataValue: string;
|
|
6
5
|
}>;
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { callOneInchAPI as
|
|
1
|
+
import { callOneInchAPI as p } from "../../API/callOneInchAPI.mjs";
|
|
2
|
+
import "../../constants/token-data/index.mjs";
|
|
2
3
|
import "../../constants/chains.constants.mjs";
|
|
3
4
|
import "../../constants/vite.constants.mjs";
|
|
4
5
|
import "../../constants/contracts.constants.mjs";
|
|
5
6
|
import "../../constants/kyc.constants.mjs";
|
|
6
|
-
import { zeroAddress as e, oneInchZeroAddress as
|
|
7
|
+
import { zeroAddress as e, oneInchZeroAddress as s } from "../../constants/protocol.constants.mjs";
|
|
7
8
|
import "../../constants/coingecko.constants.mjs";
|
|
8
9
|
import "../../constants/axelar.constants.mjs";
|
|
9
10
|
import "../../constants/rewards.constants.mjs";
|
|
10
11
|
import "../../constants/reorg-depths.constants.mjs";
|
|
11
|
-
import { transactionErrorCodes as
|
|
12
|
-
import { getAmountInWei as
|
|
12
|
+
import { transactionErrorCodes as a } from "../../error-handling/error-codes.constants.mjs";
|
|
13
|
+
import { getAmountInWei as c } from "./etherFunctions.mjs";
|
|
13
14
|
import "axios";
|
|
14
15
|
import "../../types/circom-data.types.mjs";
|
|
15
|
-
import { ContractType as
|
|
16
|
+
import { ContractType as d } from "../../types/ethereum-network.types.mjs";
|
|
16
17
|
import "../../types/transactions.types.mjs";
|
|
17
18
|
import "../../types/curve.types.mjs";
|
|
18
19
|
import "ethers";
|
|
@@ -20,15 +21,16 @@ import "circomlibjs-hinkal-fork";
|
|
|
20
21
|
import "libsodium-wrappers";
|
|
21
22
|
import "process";
|
|
22
23
|
import "buffer";
|
|
23
|
-
|
|
24
|
+
import { getContractMetadata as l } from "./getContractMetadata.mjs";
|
|
25
|
+
const D = async (m, o, i, n) => {
|
|
24
26
|
try {
|
|
25
|
-
const
|
|
26
|
-
fromTokenAddress:
|
|
27
|
-
toTokenAddress: i.erc20TokenAddress !== e ? i.erc20TokenAddress :
|
|
27
|
+
const t = {
|
|
28
|
+
fromTokenAddress: o.erc20TokenAddress !== e ? o.erc20TokenAddress : s,
|
|
29
|
+
toTokenAddress: i.erc20TokenAddress !== e ? i.erc20TokenAddress : s,
|
|
28
30
|
fromAddress: e,
|
|
29
31
|
// we user zero address here because this paramater is not relevant to us, only destReceiver is
|
|
30
|
-
destReceiver:
|
|
31
|
-
amount:
|
|
32
|
+
destReceiver: l(d.OneInchExternalActionContract, m).address,
|
|
33
|
+
amount: c(o, n),
|
|
32
34
|
slippage: 10,
|
|
33
35
|
disableEstimate: !0,
|
|
34
36
|
// disable gas estimation, we don't need it
|
|
@@ -37,7 +39,7 @@ const v = async (s, t, i, n) => {
|
|
|
37
39
|
// and returning leftover tokens to fromAddress
|
|
38
40
|
// this is not what we want
|
|
39
41
|
allowPartialFill: !1
|
|
40
|
-
}, r = await
|
|
42
|
+
}, r = await p(m, t);
|
|
41
43
|
if (!r || !r.tx)
|
|
42
44
|
throw Error("OneInch API price fetch error");
|
|
43
45
|
return {
|
|
@@ -45,10 +47,10 @@ const v = async (s, t, i, n) => {
|
|
|
45
47
|
oneInchDataValue: r.tx.data
|
|
46
48
|
// calldata to use
|
|
47
49
|
};
|
|
48
|
-
} catch (
|
|
49
|
-
throw console.log({ error:
|
|
50
|
+
} catch (t) {
|
|
51
|
+
throw console.log({ error: t }), Error(a.NO_ONEINCH_PRICE);
|
|
50
52
|
}
|
|
51
53
|
};
|
|
52
54
|
export {
|
|
53
|
-
|
|
55
|
+
D as getOneInchPrice
|
|
54
56
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("ethers");require("../../constants/token-data/index.cjs");const 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"),P=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(s,t,c,r)=>{const o=(await Promise.all([100,500,3e3,1e4].map(async e=>({poolAddress:await t.getPool(c,r,e),fee:e})))).filter(({poolAddress:e})=>e!==C.zeroAddress),n=await Promise.all(o.map(async e=>({poolAddress:e.poolAddress,fee:e.fee,token1Balance:(await s.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(s,t,c,r,o,n)=>{try{if(!d.networkRegistry[t].quoterV2Address)throw Error("No Quoter Contract Provided");return(await s.getContractWithFetcherByChainId(t,u.ContractType.UniswapV3QuoterContract,d.networkRegistry[t].quoterV2Address).callStatic.quoteExactInputSingle({tokenIn:c.wrappedErc20TokenAddress??c.erc20TokenAddress,tokenOut:r.wrappedErc20TokenAddress??r.erc20TokenAddress,fee:o,amountIn:n,sqrtPriceLimitX96:0})).amountOut.toBigInt()}catch(a){throw h.logError(a),a}},A=async(s,t,c,r)=>{try{const o=s.getContractWithFetcherByChainId(t,u.ContractType.UniswapV3FactoryContract,d.networkRegistry[t].uniswapV3FactoryAddress),n=s.getContractWithFetcherByChainId(t,u.ContractType.ERC20Contract,r.wrappedErc20TokenAddress??r.erc20TokenAddress),{fee:a}=await w(n,o,c.wrappedErc20TokenAddress??c.erc20TokenAddress,r.wrappedErc20TokenAddress??r.erc20TokenAddress);return a}catch(o){throw console.log("Error in getUniswapFee",o),o}},E=async(s,t,c,r,o)=>{try{const n=await A(s,t,r,o),a=g.utils.defaultAbiCoder.encode(["uint24"],[n]),i=P.getAmountInWei(r,c);return{tokenPrice:await q(s,t,r,o,n,i),poolFee:a}}catch{throw Error(l.transactionErrorCodes.NO_UNISWAP_PRICE)}};exports.getUniswapFee=A;exports.getUniswapPrice=E;exports.getUniswapPriceHelper=q;exports.searchPoolAndFee=w;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Contract } from 'ethers';
|
|
2
|
-
import { IHinkal } from '../../data-structures';
|
|
3
2
|
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, 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<{
|
|
10
|
+
export declare const getUniswapPriceHelper: (hinkal: IHinkal, chainId: number, token0: ERC20Token, token1: ERC20Token, fee: number, inSwapAmount: bigint) => Promise<bigint>;
|
|
11
|
+
export declare const getUniswapFee: (hinkal: IHinkal, chainId: number, token0: ERC20Token, token1: ERC20Token) => Promise<number>;
|
|
12
|
+
export declare const getUniswapPrice: (hinkal: IHinkal, chainId: number, inSwapAmount: string, inSwapToken: ERC20Token, outSwapToken: ERC20Token) => Promise<{
|
|
13
13
|
tokenPrice: bigint;
|
|
14
14
|
poolFee: string;
|
|
15
15
|
}>;
|
|
@@ -1,87 +1,98 @@
|
|
|
1
|
-
import { utils as
|
|
2
|
-
import
|
|
1
|
+
import { utils as A } from "ethers";
|
|
2
|
+
import "../../constants/token-data/index.mjs";
|
|
3
|
+
import { networkRegistry as p } from "../../constants/chains.constants.mjs";
|
|
3
4
|
import "../../constants/vite.constants.mjs";
|
|
4
5
|
import "../../constants/contracts.constants.mjs";
|
|
5
6
|
import "../../constants/kyc.constants.mjs";
|
|
6
|
-
import { zeroAddress as
|
|
7
|
+
import { zeroAddress as u } from "../../constants/protocol.constants.mjs";
|
|
7
8
|
import "../../constants/coingecko.constants.mjs";
|
|
8
9
|
import "../../constants/axelar.constants.mjs";
|
|
9
10
|
import "../../constants/rewards.constants.mjs";
|
|
10
11
|
import "../../constants/reorg-depths.constants.mjs";
|
|
11
|
-
import { transactionErrorCodes as
|
|
12
|
-
import { getAmountInWei as
|
|
12
|
+
import { transactionErrorCodes as l } from "../../error-handling/error-codes.constants.mjs";
|
|
13
|
+
import { getAmountInWei as f } from "./etherFunctions.mjs";
|
|
13
14
|
import "axios";
|
|
14
15
|
import "../../types/circom-data.types.mjs";
|
|
15
|
-
import { ContractType as
|
|
16
|
+
import { ContractType as d } from "../../types/ethereum-network.types.mjs";
|
|
16
17
|
import "../../types/transactions.types.mjs";
|
|
17
18
|
import "../../types/curve.types.mjs";
|
|
18
19
|
import "circomlibjs-hinkal-fork";
|
|
19
20
|
import "libsodium-wrappers";
|
|
20
21
|
import "process";
|
|
21
22
|
import "buffer";
|
|
22
|
-
import { logError as
|
|
23
|
-
const
|
|
24
|
-
const
|
|
23
|
+
import { logError as y } from "../../error-handling/logError.mjs";
|
|
24
|
+
const C = async (s, o, a, t) => {
|
|
25
|
+
const e = (await Promise.all(
|
|
25
26
|
[100, 500, 3e3, 1e4].map(async (r) => ({
|
|
26
|
-
poolAddress: await
|
|
27
|
+
poolAddress: await o.getPool(a, t, r),
|
|
27
28
|
fee: r
|
|
28
29
|
}))
|
|
29
|
-
)).filter(({ poolAddress: r }) => r !==
|
|
30
|
-
|
|
30
|
+
)).filter(({ poolAddress: r }) => r !== u), n = await Promise.all(
|
|
31
|
+
e.map(async (r) => ({
|
|
31
32
|
poolAddress: r.poolAddress,
|
|
32
33
|
fee: r.fee,
|
|
33
|
-
token1Balance: (await
|
|
34
|
+
token1Balance: (await s.balanceOf(r.poolAddress)).toBigInt()
|
|
34
35
|
}))
|
|
35
36
|
), i = n.map((r) => r.token1Balance).reduce((r, m) => m >= r ? m : r, 0n);
|
|
36
37
|
if (i === 0n)
|
|
37
|
-
throw new Error(
|
|
38
|
+
throw new Error(l.UNISWAP_NOT_ENOUGH_LIQUIDITY);
|
|
38
39
|
return n.find((r) => r.token1Balance === i);
|
|
39
|
-
}, g = async (
|
|
40
|
+
}, g = async (s, o, a, t, e, n) => {
|
|
40
41
|
try {
|
|
41
|
-
if (!
|
|
42
|
+
if (!p[o].quoterV2Address)
|
|
42
43
|
throw Error("No Quoter Contract Provided");
|
|
43
|
-
return (await
|
|
44
|
-
|
|
45
|
-
d
|
|
44
|
+
return (await s.getContractWithFetcherByChainId(
|
|
45
|
+
o,
|
|
46
|
+
d.UniswapV3QuoterContract,
|
|
47
|
+
p[o].quoterV2Address
|
|
46
48
|
).callStatic.quoteExactInputSingle({
|
|
47
|
-
tokenIn:
|
|
49
|
+
tokenIn: a.wrappedErc20TokenAddress ?? a.erc20TokenAddress,
|
|
48
50
|
tokenOut: t.wrappedErc20TokenAddress ?? t.erc20TokenAddress,
|
|
49
|
-
fee:
|
|
50
|
-
amountIn:
|
|
51
|
+
fee: e,
|
|
52
|
+
amountIn: n,
|
|
51
53
|
sqrtPriceLimitX96: 0
|
|
52
54
|
})).amountOut.toBigInt();
|
|
53
|
-
} catch (
|
|
54
|
-
throw
|
|
55
|
+
} catch (c) {
|
|
56
|
+
throw y(c), c;
|
|
55
57
|
}
|
|
56
|
-
},
|
|
58
|
+
}, E = async (s, o, a, t) => {
|
|
57
59
|
try {
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
d
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
const e = s.getContractWithFetcherByChainId(
|
|
61
|
+
o,
|
|
62
|
+
d.UniswapV3FactoryContract,
|
|
63
|
+
p[o].uniswapV3FactoryAddress
|
|
64
|
+
), n = s.getContractWithFetcherByChainId(
|
|
65
|
+
o,
|
|
66
|
+
d.ERC20Contract,
|
|
63
67
|
t.wrappedErc20TokenAddress ?? t.erc20TokenAddress
|
|
64
|
-
), { fee:
|
|
68
|
+
), { fee: c } = await C(
|
|
65
69
|
n,
|
|
66
|
-
|
|
67
|
-
|
|
70
|
+
e,
|
|
71
|
+
a.wrappedErc20TokenAddress ?? a.erc20TokenAddress,
|
|
68
72
|
t.wrappedErc20TokenAddress ?? t.erc20TokenAddress
|
|
69
73
|
);
|
|
70
|
-
return
|
|
71
|
-
} catch (
|
|
72
|
-
throw console.log("Error in getUniswapFee",
|
|
74
|
+
return c;
|
|
75
|
+
} catch (e) {
|
|
76
|
+
throw console.log("Error in getUniswapFee", e), e;
|
|
73
77
|
}
|
|
74
|
-
},
|
|
78
|
+
}, G = async (s, o, a, t, e) => {
|
|
75
79
|
try {
|
|
76
|
-
const
|
|
77
|
-
return { tokenPrice: await g(
|
|
80
|
+
const n = await E(s, o, t, e), c = A.defaultAbiCoder.encode(["uint24"], [n]), i = f(t, a);
|
|
81
|
+
return { tokenPrice: await g(
|
|
82
|
+
s,
|
|
83
|
+
o,
|
|
84
|
+
t,
|
|
85
|
+
e,
|
|
86
|
+
n,
|
|
87
|
+
i
|
|
88
|
+
), poolFee: c };
|
|
78
89
|
} catch {
|
|
79
|
-
throw Error(
|
|
90
|
+
throw Error(l.NO_UNISWAP_PRICE);
|
|
80
91
|
}
|
|
81
92
|
};
|
|
82
93
|
export {
|
|
83
|
-
|
|
84
|
-
|
|
94
|
+
E as getUniswapFee,
|
|
95
|
+
G as getUniswapPrice,
|
|
85
96
|
g as getUniswapPriceHelper,
|
|
86
|
-
|
|
97
|
+
C as searchPoolAndFee
|
|
87
98
|
};
|