@sabaaa1/common 0.0.1
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/.env.example +5 -0
- package/.eslintrc.json +18 -0
- package/README.md +164 -0
- package/copyPackageJson.js +81 -0
- package/handleCDNWorkers.js +92 -0
- package/jest.config.ts +10 -0
- package/package.json +101 -0
- package/polyfillWorker.ts +15 -0
- package/project.json +32 -0
- package/src/API/API.ts +203 -0
- package/src/API/admin-calls.ts +8 -0
- package/src/API/ai-calls.ts +48 -0
- package/src/API/brotherhoodCalls.ts +184 -0
- package/src/API/callLifiAPI.ts +41 -0
- package/src/API/callMonitor.ts +9 -0
- package/src/API/callOdosAPI.ts +89 -0
- package/src/API/callOneInchAPI.ts +47 -0
- package/src/API/callRelayer.ts +23 -0
- package/src/API/checkRisk.ts +7 -0
- package/src/API/duneAPI.ts +26 -0
- package/src/API/enclaveCalls.ts +23 -0
- package/src/API/fetchCommitmentsCache.ts +63 -0
- package/src/API/generate-trading-points.ts +77 -0
- package/src/API/get-token-data.ts +12 -0
- package/src/API/getBridgeProtocols.ts +16 -0
- package/src/API/getCoingeckoPrice.ts +59 -0
- package/src/API/getGasEstimates.ts +30 -0
- package/src/API/getLifiStatus.ts +35 -0
- package/src/API/getRelayerURL.ts +27 -0
- package/src/API/getServerURL.ts +116 -0
- package/src/API/getTokenPrice.ts +39 -0
- package/src/API/getWebsiteURL.ts +58 -0
- package/src/API/index.ts +19 -0
- package/src/API/is-tx-stateless.ts +32 -0
- package/src/API/kycCalls.ts +81 -0
- package/src/API/leaderboardCalls.ts +32 -0
- package/src/API/mysteryBoxesCalls.ts +141 -0
- package/src/API/passwordCalls.ts +34 -0
- package/src/API/proxyAccountsCalls.ts +40 -0
- package/src/API/referralsCalls.ts +52 -0
- package/src/API/relayCalls.ts +14 -0
- package/src/API/restoreSnapshots.ts +7 -0
- package/src/API/rewardsUserCalls.ts +124 -0
- package/src/API/send-telegram-callback.ts +17 -0
- package/src/API/simulate-batch-tx.ts +19 -0
- package/src/API/tenderly.api.ts +96 -0
- package/src/API/token-calls.ts +19 -0
- package/src/API/weeklyAnalyticCalls.ts +43 -0
- package/src/constants/activity.constants.ts +10 -0
- package/src/constants/addresses.constants.ts +74 -0
- package/src/constants/assets.constants.ts +15 -0
- package/src/constants/backend.constants.ts +16 -0
- package/src/constants/balance.constants.ts +1 -0
- package/src/constants/bridging.constants.ts +5 -0
- package/src/constants/chains.constants.ts +194 -0
- package/src/constants/coingecko.constants.ts +67 -0
- package/src/constants/contracts.constants.ts +106 -0
- package/src/constants/conversion.constants.ts +1 -0
- package/src/constants/deploy-data/deploy-data-arbMainnet.json +5685 -0
- package/src/constants/deploy-data/deploy-data-arcTestnet.json +6157 -0
- package/src/constants/deploy-data/deploy-data-avalanche.json +5921 -0
- package/src/constants/deploy-data/deploy-data-base.json +5695 -0
- package/src/constants/deploy-data/deploy-data-bnbMainnet.json +5921 -0
- package/src/constants/deploy-data/deploy-data-ethMainnet.json +5922 -0
- package/src/constants/deploy-data/deploy-data-localhost.json +5921 -0
- package/src/constants/deploy-data/deploy-data-optimism.json +5687 -0
- package/src/constants/deploy-data/deploy-data-polygon.json +5695 -0
- package/src/constants/deploy-data/index.ts +21 -0
- package/src/constants/events.constants.ts +10 -0
- package/src/constants/fees.constants.ts +4 -0
- package/src/constants/function-signatures.constants.ts +6 -0
- package/src/constants/index.ts +30 -0
- package/src/constants/kyc.constants.ts +202 -0
- package/src/constants/lifi.constants.ts +1 -0
- package/src/constants/mediaUrls.constants.ts +25 -0
- package/src/constants/mystery-boxes.constants.ts +402 -0
- package/src/constants/oauthUrls.constants.ts +7 -0
- package/src/constants/permit2.constants.ts +28 -0
- package/src/constants/presale.constants.ts +503 -0
- package/src/constants/protocol.constants.ts +65 -0
- package/src/constants/reorg-depths.constants.ts +13 -0
- package/src/constants/rewards.constants.ts +27 -0
- package/src/constants/save-depths.ts +13 -0
- package/src/constants/server.constants.ts +233 -0
- package/src/constants/tasks.constants.ts +205 -0
- package/src/constants/token-data/ERC20Registry.ts +90 -0
- package/src/constants/token-data/arbMainnetRegistry.json +1841 -0
- package/src/constants/token-data/arbMainnetRegistryFixed.json +1841 -0
- package/src/constants/token-data/arcTestnetRegistry.json +436 -0
- package/src/constants/token-data/avalancheRegistry.json +729 -0
- package/src/constants/token-data/avalancheRegistryFixed.json +729 -0
- package/src/constants/token-data/baseRegistry.json +1134 -0
- package/src/constants/token-data/baseRegistryFixed.json +1134 -0
- package/src/constants/token-data/bnbMainnetRegistry.json +900 -0
- package/src/constants/token-data/bnbMainnetRegistryFixed.json +900 -0
- package/src/constants/token-data/ethMainnetRegistry.json +4298 -0
- package/src/constants/token-data/ethMainnetRegistryFixed.json +4298 -0
- package/src/constants/token-data/index.ts +60 -0
- package/src/constants/token-data/localhostRegistry.json +2784 -0
- package/src/constants/token-data/optimismRegistry.json +701 -0
- package/src/constants/token-data/optimismRegistryFixed.json +701 -0
- package/src/constants/token-data/polygonRegistry.json +2309 -0
- package/src/constants/token-data/polygonRegistryFixed.json +2309 -0
- package/src/constants/token-data/popularTokens.constants.ts +11 -0
- package/src/constants/token-data/tokenPricing.consts.ts +2 -0
- package/src/constants/token.limits.constants.ts +31 -0
- package/src/constants/vite.constants.ts +74 -0
- package/src/constants/wallet.constants.ts +9 -0
- package/src/crypto/babyJub.ts +31 -0
- package/src/crypto/index.ts +3 -0
- package/src/crypto/poseidon.ts +36 -0
- package/src/crypto/preProcessing.ts +20 -0
- package/src/data-structures/ApprovalDBs/EventsPublicApprovalsDB.ts +288 -0
- package/src/data-structures/ApprovalDBs/index.ts +1 -0
- package/src/data-structures/Hinkal/Hinkal.ts +746 -0
- package/src/data-structures/Hinkal/IHinkal.ts +315 -0
- package/src/data-structures/Hinkal/handleAutoDepositBack.ts +138 -0
- package/src/data-structures/Hinkal/hinkalActionFundApproveAndTransact.ts +64 -0
- package/src/data-structures/Hinkal/hinkalActionReceive.ts +65 -0
- package/src/data-structures/Hinkal/hinkalActionStake.ts +152 -0
- package/src/data-structures/Hinkal/hinkalApprove.ts +170 -0
- package/src/data-structures/Hinkal/hinkalCheckTokenRegistry.ts +26 -0
- package/src/data-structures/Hinkal/hinkalDeposit.ts +199 -0
- package/src/data-structures/Hinkal/hinkalGetRecipientInfo.ts +12 -0
- package/src/data-structures/Hinkal/hinkalGetZkMeProvider.ts +31 -0
- package/src/data-structures/Hinkal/hinkalInsideTransact.ts +190 -0
- package/src/data-structures/Hinkal/hinkalMultiSend.ts +26 -0
- package/src/data-structures/Hinkal/hinkalPrivateWallet.ts +198 -0
- package/src/data-structures/Hinkal/hinkalProoflessDeposit.ts +91 -0
- package/src/data-structures/Hinkal/hinkalProxySwap.ts +91 -0
- package/src/data-structures/Hinkal/hinkalSignSubAccount.ts +28 -0
- package/src/data-structures/Hinkal/hinkalSwap.ts +157 -0
- package/src/data-structures/Hinkal/hinkalTransfer.ts +171 -0
- package/src/data-structures/Hinkal/hinkalWithdraw.ts +161 -0
- package/src/data-structures/Hinkal/index.ts +9 -0
- package/src/data-structures/Hinkal/resetMerkleTrees.ts +64 -0
- package/src/data-structures/IndexedDB/activity-db.ts +204 -0
- package/src/data-structures/IndexedDB/balances-db.ts +97 -0
- package/src/data-structures/IndexedDB/contact-db.ts +81 -0
- package/src/data-structures/IndexedDB/index.ts +6 -0
- package/src/data-structures/IndexedDB/prices-db.ts +89 -0
- package/src/data-structures/IndexedDB/private-balances-db.ts +31 -0
- package/src/data-structures/IndexedDB/signatures-db.ts +62 -0
- package/src/data-structures/MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.ts +152 -0
- package/src/data-structures/TokenDBs/AlchemyPublicTokensDB.ts +224 -0
- package/src/data-structures/TokenDBs/ArcPublicTokensDB.ts +198 -0
- package/src/data-structures/TokenDBs/EventsPublicTokensDB.ts +216 -0
- package/src/data-structures/TokenDBs/IPublicTokensDB.ts +7 -0
- package/src/data-structures/TokenDBs/PrivateTokensDB.ts +96 -0
- package/src/data-structures/TokenDBs/PublicTokensDB.ts +49 -0
- package/src/data-structures/TokenDBs/index.ts +4 -0
- package/src/data-structures/TokenDBs/token-visibility-db.ts +154 -0
- package/src/data-structures/ValueCache/ValueCache.ts +29 -0
- package/src/data-structures/ValueCache/index.ts +1 -0
- package/src/data-structures/cacheDevices/AttachableMemoryCacheDevice.ts +33 -0
- package/src/data-structures/cacheDevices/BaseCacheDevice.ts +30 -0
- package/src/data-structures/cacheDevices/FileCacheDevice.ts +59 -0
- package/src/data-structures/cacheDevices/LocalStorageCacheDevice.ts +36 -0
- package/src/data-structures/cacheDevices/index.ts +2 -0
- package/src/data-structures/crypto-keys/decodeUTXO.ts +60 -0
- package/src/data-structures/crypto-keys/encryptDecryptUtxo.ts +74 -0
- package/src/data-structures/crypto-keys/index.ts +4 -0
- package/src/data-structures/crypto-keys/keyUtils.ts +8 -0
- package/src/data-structures/crypto-keys/keys.ts +203 -0
- package/src/data-structures/custom-token-registry/CustomTokenRegistry.ts +49 -0
- package/src/data-structures/event-service/AbstractAccessTokenSnapshotService.ts +142 -0
- package/src/data-structures/event-service/AbstractApprovalsSnapshotService.ts +152 -0
- package/src/data-structures/event-service/AbstractCommitmentsSnapshotService.ts +116 -0
- package/src/data-structures/event-service/AbstractEventService.ts +44 -0
- package/src/data-structures/event-service/AbstractNullifierSnapshotService.ts +76 -0
- package/src/data-structures/event-service/AbstractSnapshotService.ts +63 -0
- package/src/data-structures/event-service/BlockchainEventEmitter.ts +132 -0
- package/src/data-structures/event-service/index.ts +7 -0
- package/src/data-structures/index.ts +18 -0
- package/src/data-structures/merkle-tree/MerkleTree.test.ts +77 -0
- package/src/data-structures/merkle-tree/MerkleTree.ts +253 -0
- package/src/data-structures/merkle-tree/MerkleTreeIncompleteError.ts +6 -0
- package/src/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.ts +24 -0
- package/src/data-structures/merkle-tree/index.ts +3 -0
- package/src/data-structures/presale/PresaleContractWrapper.ts +80 -0
- package/src/data-structures/presale/index.ts +1 -0
- package/src/data-structures/provider-adapter/IProviderAdapter.ts +43 -0
- package/src/data-structures/snapshot/ClientAccessTokenSnapshotService.ts +41 -0
- package/src/data-structures/snapshot/ClientApprovalsSnapshotService.ts +36 -0
- package/src/data-structures/snapshot/ClientCommitmentsSnapshotService.ts +30 -0
- package/src/data-structures/snapshot/ClientNullifierSnapshotService.ts +28 -0
- package/src/data-structures/snapshot/SnapshotFetcherService.ts +68 -0
- package/src/data-structures/snapshot/index.ts +1 -0
- package/src/data-structures/token-price-fetcher/TokenChecker.ts +45 -0
- package/src/data-structures/token-price-fetcher/index.ts +1 -0
- package/src/data-structures/tor/HttpClient.ts +118 -0
- package/src/data-structures/tor/TorAdapter.ts +94 -0
- package/src/data-structures/tor/TorClient.ts +283 -0
- package/src/data-structures/tor/WebSocketDuplex.ts +32 -0
- package/src/data-structures/tor/index.ts +3 -0
- package/src/data-structures/transactions-manager/history/history.types.ts +14 -0
- package/src/data-structures/transactions-manager/index.ts +1 -0
- package/src/data-structures/utxo/Utxo.ts +189 -0
- package/src/error-handling/customErrors/ErrorWithAmount.ts +8 -0
- package/src/error-handling/customErrors/ErrorWithTx.ts +10 -0
- package/src/error-handling/customErrors/FeeOverTransactionValueError.ts +16 -0
- package/src/error-handling/customErrors/SimulationFailureError.ts +9 -0
- package/src/error-handling/customErrors/customErrors.helpers.ts +39 -0
- package/src/error-handling/customErrors/index.ts +5 -0
- package/src/error-handling/error-codes.constants.ts +214 -0
- package/src/error-handling/get-error.message.ts +149 -0
- package/src/error-handling/handleErrorRestore.ts +25 -0
- package/src/error-handling/index.ts +7 -0
- package/src/error-handling/logError.ts +8 -0
- package/src/error-handling/logger.ts +21 -0
- package/src/error-handling/types.ts +10 -0
- package/src/externalABIs/BUSD.ts +516 -0
- package/src/externalABIs/BabPassport.json +24 -0
- package/src/externalABIs/DAI.ts +331 -0
- package/src/externalABIs/ERC1155.json +316 -0
- package/src/externalABIs/ERC20.json +297 -0
- package/src/externalABIs/ERC20.ts +1 -0
- package/src/externalABIs/ERC721.json +205 -0
- package/src/externalABIs/GalxePassport.json +23 -0
- package/src/externalABIs/IQuoterV2.json +211 -0
- package/src/externalABIs/ISwapRouter.json +568 -0
- package/src/externalABIs/IUniswapV3Factory.json +207 -0
- package/src/externalABIs/IUniswapV3Pool.json +999 -0
- package/src/externalABIs/NodeInterfaceABI.json +1 -0
- package/src/externalABIs/OptimismGasPriceOracle.json +1 -0
- package/src/externalABIs/PoLidoNftAbi.json +307 -0
- package/src/externalABIs/SanctionsList.ts +86 -0
- package/src/externalABIs/USDC.ts +718 -0
- package/src/externalABIs/USDR.ts +343 -0
- package/src/externalABIs/USDR3CRV.ts +539 -0
- package/src/externalABIs/USDT.ts +390 -0
- package/src/externalABIs/UniswapV2PoolAbi.json +66 -0
- package/src/externalABIs/WETH.ts +153 -0
- package/src/externalABIs/amToken.ts +347 -0
- package/src/externalABIs/index.ts +53 -0
- package/src/externalABIs/swapAbi.ts +442 -0
- package/src/externalABIs/transactionsProver.json +45 -0
- package/src/functions/index.ts +16 -0
- package/src/functions/kyc/aiPriseHelper.ts +0 -0
- package/src/functions/kyc/authentoHelper.ts +44 -0
- package/src/functions/kyc/index.ts +3 -0
- package/src/functions/kyc/openDefaultPassportWindow.ts +9 -0
- package/src/functions/kyc/passportHelper.ts +13 -0
- package/src/functions/kyc/zkMeHelper.ts +69 -0
- package/src/functions/pre-transaction/constructAdminData.ts +21 -0
- package/src/functions/pre-transaction/getExternalSwapAddress.ts +30 -0
- package/src/functions/pre-transaction/getFeeStructure.ts +44 -0
- package/src/functions/pre-transaction/getFlatFees.ts +88 -0
- package/src/functions/pre-transaction/getSignatureDataForTransact.ts +16 -0
- package/src/functions/pre-transaction/getVolatileTransferAmount.ts +56 -0
- package/src/functions/pre-transaction/index.ts +7 -0
- package/src/functions/pre-transaction/interaction-to-action.ts +17 -0
- package/src/functions/pre-transaction/merge-with-fee-structure-emporium.ts +50 -0
- package/src/functions/pre-transaction/merge-with-fee-structure.ts +35 -0
- package/src/functions/pre-transaction/outputApprovalDataProcessing.ts +95 -0
- package/src/functions/pre-transaction/outputUtxoProcessing.ts +52 -0
- package/src/functions/pre-transaction/process-gas-estimates.ts +36 -0
- package/src/functions/pre-transaction/shouldPatchAccessTokenMerkleTree.ts +15 -0
- package/src/functions/private-wallet/emporium.helpers.ts +296 -0
- package/src/functions/private-wallet/emporium.swap.helpers.ts +284 -0
- package/src/functions/private-wallet/index.ts +3 -0
- package/src/functions/private-wallet/opProducer.ts +33 -0
- package/src/functions/snarkjs/common.snarkjs.ts +377 -0
- package/src/functions/snarkjs/constant.ts +490 -0
- package/src/functions/snarkjs/constructEmporiumProof.ts +301 -0
- package/src/functions/snarkjs/constructGeneralZkProof.ts +281 -0
- package/src/functions/snarkjs/generateCircomData.ts +81 -0
- package/src/functions/snarkjs/generateZkProof.ts +21 -0
- package/src/functions/snarkjs/generateZkProofEnclave.ts +45 -0
- package/src/functions/snarkjs/generateZkProofSelf.ts +29 -0
- package/src/functions/snarkjs/getOriginalSender.ts +4 -0
- package/src/functions/snarkjs/getZKFiles.ts +29 -0
- package/src/functions/snarkjs/index.ts +4 -0
- package/src/functions/staking/index.ts +78 -0
- package/src/functions/utils/addresses.ts +37 -0
- package/src/functions/utils/amounts.utils.test.ts +91 -0
- package/src/functions/utils/amounts.utils.ts +119 -0
- package/src/functions/utils/arraysMatch.ts +4 -0
- package/src/functions/utils/cacheDevice.utils.ts +21 -0
- package/src/functions/utils/cacheFunctions.ts +154 -0
- package/src/functions/utils/caseInsensitive.utils.ts +10 -0
- package/src/functions/utils/convertEmporiumOpToCallInfo.ts +19 -0
- package/src/functions/utils/convertIntegrationProviderToExternalActionId.ts +14 -0
- package/src/functions/utils/create-provider.ts +11 -0
- package/src/functions/utils/encodeTokenWithId.ts +4 -0
- package/src/functions/utils/encryptInputForEnclave.ts +119 -0
- package/src/functions/utils/enum.utils.ts +30 -0
- package/src/functions/utils/erc20tokenFunctions.ts +110 -0
- package/src/functions/utils/ethers-formatter.utils.ts +32 -0
- package/src/functions/utils/evmNetworkFunctions.ts +9 -0
- package/src/functions/utils/external-action.utils.ts +15 -0
- package/src/functions/utils/fees.utils.ts +26 -0
- package/src/functions/utils/get-hinkal-approvals.ts +36 -0
- package/src/functions/utils/get-signature-header.ts +5 -0
- package/src/functions/utils/getBlockExplorerUrl.ts +14 -0
- package/src/functions/utils/getDataFromTransaction.ts +79 -0
- package/src/functions/utils/getRecipientInfoFromUserKeys.ts +28 -0
- package/src/functions/utils/inLogicMetadata.ts +9 -0
- package/src/functions/utils/index.ts +43 -0
- package/src/functions/utils/involves-permit2-op.ts +17 -0
- package/src/functions/utils/ipfs.ts +74 -0
- package/src/functions/utils/is-valid-url.ts +5 -0
- package/src/functions/utils/lifi.utils.ts +3 -0
- package/src/functions/utils/memoize.utils.ts +23 -0
- package/src/functions/utils/merkleTree.utils.ts +27 -0
- package/src/functions/utils/mutexes.utils.ts +3 -0
- package/src/functions/utils/mystery-box-auction.utils.ts +61 -0
- package/src/functions/utils/networks.utils.ts +6 -0
- package/src/functions/utils/nftTokenFunctions.ts +25 -0
- package/src/functions/utils/nickname.utils.ts +4 -0
- package/src/functions/utils/postToOffscreen.ts +6 -0
- package/src/functions/utils/prepareHinkal.ts +78 -0
- package/src/functions/utils/process.utils.ts +23 -0
- package/src/functions/utils/processUseApprovalUtxoData.ts +26 -0
- package/src/functions/utils/publicBalance.utils.ts +131 -0
- package/src/functions/utils/reloadPage.ts +1 -0
- package/src/functions/utils/replaceAddressInCalldata.ts +6 -0
- package/src/functions/utils/requireEnv.ts +10 -0
- package/src/functions/utils/resolve-sync.utils.ts +40 -0
- package/src/functions/utils/rpc-int-encode.ts +7 -0
- package/src/functions/utils/serialize.utils.ts +12 -0
- package/src/functions/utils/string.utils.ts +92 -0
- package/src/functions/utils/time.utils.ts +80 -0
- package/src/functions/utils/token-check.utils.ts +12 -0
- package/src/functions/utils/trimFieldValues.ts +24 -0
- package/src/functions/utils/upToDateState.ts +12 -0
- package/src/functions/utils/userAgent.ts +26 -0
- package/src/functions/utils/walletBalances.utils.ts +117 -0
- package/src/functions/web3/EIP-712.test.ts +302 -0
- package/src/functions/web3/EIP-712.ts +243 -0
- package/src/functions/web3/etherFunctions.test.ts +129 -0
- package/src/functions/web3/etherFunctions.ts +84 -0
- package/src/functions/web3/events/balanceChangedCustomHandler.ts +13 -0
- package/src/functions/web3/events/balanceChangedHandler.ts +10 -0
- package/src/functions/web3/events/getApprovedBalance.ts +154 -0
- package/src/functions/web3/events/getInputUtxoAndBalance.ts +305 -0
- package/src/functions/web3/events/getInputUtxosEnclave.ts +40 -0
- package/src/functions/web3/events/getShieldedBalance.ts +163 -0
- package/src/functions/web3/events/getTransactionLogEvents.ts +55 -0
- package/src/functions/web3/events/index.ts +7 -0
- package/src/functions/web3/events/web3RetrieveEvents.ts +33 -0
- package/src/functions/web3/functionCalls/accessTokenCalls.ts +27 -0
- package/src/functions/web3/functionCalls/approveToken.ts +180 -0
- package/src/functions/web3/functionCalls/approveTokensToHinkal.ts +21 -0
- package/src/functions/web3/functionCalls/estimateGasRelayer.ts +40 -0
- package/src/functions/web3/functionCalls/getRootHash.ts +7 -0
- package/src/functions/web3/functionCalls/inHinkalApprovalCalls.ts +60 -0
- package/src/functions/web3/functionCalls/relayFunctions.ts +12 -0
- package/src/functions/web3/functionCalls/transactCallDirect.ts +71 -0
- package/src/functions/web3/functionCalls/transactCallRelayer.ts +57 -0
- package/src/functions/web3/getContractMetadata.ts +43 -0
- package/src/functions/web3/getPublicAddressBalance.ts +17 -0
- package/src/functions/web3/getTokenHolder.ts +53 -0
- package/src/functions/web3/index.ts +9 -0
- package/src/functions/web3/lifiAPI.ts +41 -0
- package/src/functions/web3/odosAPI.ts +50 -0
- package/src/functions/web3/oneInchAPI.ts +47 -0
- package/src/functions/web3/runContractFunction.ts +116 -0
- package/src/functions/web3/uniswapAPI.ts +156 -0
- package/src/index.ts +9 -0
- package/src/mutexes/index.ts +1 -0
- package/src/mutexes/mutex.ts +3 -0
- package/src/providers/EthersProviderAdapter.ts +230 -0
- package/src/providers/TorExternalProvider.ts +36 -0
- package/src/providers/WagmiProviderAdapter.ts +311 -0
- package/src/providers/exportProviers.ts +11 -0
- package/src/providers/prepareEthersHinkal.ts +18 -0
- package/src/providers/prepareWagmiHinkal.ts +16 -0
- package/src/types/API.types.ts +23 -0
- package/src/types/ICacheDevice.ts +5 -0
- package/src/types/IMultiThreadedUtxoUtils.ts +16 -0
- package/src/types/RewardUserEnums.ts +12 -0
- package/src/types/TransactionSimulator.types.ts +30 -0
- package/src/types/WeeklyAnalytics.types.ts +44 -0
- package/src/types/activities.types.ts +90 -0
- package/src/types/admin.types.ts +30 -0
- package/src/types/all-points.types.ts +8 -0
- package/src/types/approvals.types.ts +45 -0
- package/src/types/balances.types.ts +20 -0
- package/src/types/big-intable.types.ts +3 -0
- package/src/types/bridging.types.ts +30 -0
- package/src/types/brotherhood-user.types.ts +13 -0
- package/src/types/cache.types.ts +42 -0
- package/src/types/circom-data.types.ts +120 -0
- package/src/types/coingecko.types.ts +216 -0
- package/src/types/commitments.types.ts +39 -0
- package/src/types/confirmation-request.types.ts +10 -0
- package/src/types/contacts.types.ts +6 -0
- package/src/types/crypto.types.ts +8 -0
- package/src/types/duneAPI.types.ts +9 -0
- package/src/types/eip5792.types.ts +31 -0
- package/src/types/ethereum-network.types.ts +70 -0
- package/src/types/external-action.types.ts +19 -0
- package/src/types/fee.types.ts +11 -0
- package/src/types/generatePoints.ts +14 -0
- package/src/types/hinkal.stake.types.ts +12 -0
- package/src/types/hinkal.types.ts +150 -0
- package/src/types/index.ts +50 -0
- package/src/types/kyc.types.ts +49 -0
- package/src/types/merch-order.types.ts +18 -0
- package/src/types/message.types.ts +6 -0
- package/src/types/mystery-boxes.types.ts +50 -0
- package/src/types/new-rewards.type.ts +181 -0
- package/src/types/offscreen.types.ts +8 -0
- package/src/types/presaleReferral.types.ts +4 -0
- package/src/types/proxy.types.ts +11 -0
- package/src/types/referral.types.ts +13 -0
- package/src/types/relayer.types.ts +16 -0
- package/src/types/remote-proof.types.ts +18 -0
- package/src/types/rewards.types.ts +53 -0
- package/src/types/routing.types.ts +7 -0
- package/src/types/sandbox.types.ts +246 -0
- package/src/types/session.types.ts +12 -0
- package/src/types/signature.types.ts +11 -0
- package/src/types/slippage.types.ts +3 -0
- package/src/types/snark.types.ts +43 -0
- package/src/types/tenderly.api.types.ts +200 -0
- package/src/types/token-prices.types.ts +8 -0
- package/src/types/token-with-id.types.ts +4 -0
- package/src/types/token.types.ts +86 -0
- package/src/types/transactions.types.ts +120 -0
- package/src/types/wc.types.ts +83 -0
- package/src/types/with-id.types.ts +1 -0
- package/src/webworker/performTaskWithWorker.ts +50 -0
- package/src/webworker/snarkjsWorker/snarkjs.d.ts +2 -0
- package/src/webworker/snarkjsWorker/snarkjsWorker.types.ts +18 -0
- package/src/webworker/snarkjsWorker/snarkjsWorkerLauncher.ts +19 -0
- package/src/webworker/snarkjsWorker/snarkjsWorkerLogic.ts +90 -0
- package/src/webworker/utxoWorker/utxoWorker.types.ts +41 -0
- package/src/webworker/utxoWorker/utxoWorkerLauncher.ts +19 -0
- package/src/webworker/utxoWorker/utxoWorkerLogic.ts +107 -0
- package/src/webworker/viteWorkerURL.constant.ts +25 -0
- package/src/webworker/worker.registry.ts +11 -0
- package/src/webworker/worker.types.ts +35 -0
- package/src/webworker/workerErrorHandler.ts +10 -0
- package/src/webworker/workerFactory.ts +47 -0
- package/src/webworker/workerProxy.ts +88 -0
- package/src/webworker/zkProofWorker/zkProofWorker.types.ts +52 -0
- package/src/webworker/zkProofWorker/zkProofWorkerLauncher.ts +19 -0
- package/src/webworker/zkProofWorker/zkProofWorkerLogic.ts +84 -0
- package/tsconfig.json +23 -0
- package/tsconfig.lib.json +10 -0
- package/tsconfig.spec.json +15 -0
- package/vite.config.ts +97 -0
- package/vite.config.workers.ts +51 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { DATA_SERVER_URL } from './getServerURL';
|
|
2
|
+
import { DATA_SERVER_CONFIG } from '../constants/server.constants';
|
|
3
|
+
import { AllPoints, BrotherhoodWeeklyAnalytic, UserWeeklyAnalytic } from '../types';
|
|
4
|
+
import { httpClient } from '../data-structures/tor';
|
|
5
|
+
|
|
6
|
+
interface GetUserAnalyticsProps {
|
|
7
|
+
ethereumAddress: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface GetUserAnalyticsRes {
|
|
11
|
+
success: boolean;
|
|
12
|
+
currentWeek: UserWeeklyAnalytic;
|
|
13
|
+
previousWeeks: UserWeeklyAnalytic[];
|
|
14
|
+
allTime: AllPoints;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const getUserAnalytics = async ({ ethereumAddress }: GetUserAnalyticsProps): Promise<GetUserAnalyticsRes> => {
|
|
18
|
+
const data = await httpClient.get(`${DATA_SERVER_URL}${DATA_SERVER_CONFIG.getUserAnalytics}`, {
|
|
19
|
+
params: { ethereumAddress },
|
|
20
|
+
});
|
|
21
|
+
return data;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
interface GetBrotherhoodAnalyticsRes {
|
|
25
|
+
success: boolean;
|
|
26
|
+
currentWeek: BrotherhoodWeeklyAnalytic | undefined;
|
|
27
|
+
allTime: AllPoints | undefined;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface GetBrotherhoodAnalyticsProps {
|
|
31
|
+
brotherhoodId?: number;
|
|
32
|
+
ethereumAddress?: string | undefined | null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const getBrotherhoodAnalytics = async ({
|
|
36
|
+
brotherhoodId,
|
|
37
|
+
ethereumAddress,
|
|
38
|
+
}: GetBrotherhoodAnalyticsProps): Promise<GetBrotherhoodAnalyticsRes> => {
|
|
39
|
+
const data = await httpClient.get(`${DATA_SERVER_URL}${DATA_SERVER_CONFIG.getBrotherhoodAnalytics}`, {
|
|
40
|
+
params: { brotherhoodId, ethereumAddress },
|
|
41
|
+
});
|
|
42
|
+
return data;
|
|
43
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ActivityTypes } from '../types';
|
|
2
|
+
|
|
3
|
+
export const TVL_CHANGER_ACTIVITY_TYPES = [
|
|
4
|
+
ActivityTypes.SHIELD,
|
|
5
|
+
ActivityTypes.RECIEVE,
|
|
6
|
+
ActivityTypes.ONBOARDING_DEPOSIT,
|
|
7
|
+
ActivityTypes.SEND,
|
|
8
|
+
ActivityTypes.UNSHIELD,
|
|
9
|
+
ActivityTypes.DAPP_INTERACTION,
|
|
10
|
+
];
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ExternalActionId } from '../types';
|
|
2
|
+
import { chainIds } from './chains.constants';
|
|
3
|
+
|
|
4
|
+
export const HETH_ERC20_TOKEN_ADDRESS = '0x270B7748CdF8243bFe68FaCE7230ef0fCE695389';
|
|
5
|
+
export const WETH_ERC20_TOKEN_ADDRESS = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
|
|
6
|
+
|
|
7
|
+
export const SWAP_ROUTER_ADDRESSES = {
|
|
8
|
+
[ExternalActionId.Uniswap]: {
|
|
9
|
+
[chainIds.ethMainnet]: '0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45',
|
|
10
|
+
[chainIds.polygon]: '0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45',
|
|
11
|
+
[chainIds.optimism]: '0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45',
|
|
12
|
+
[chainIds.arbMainnet]: '0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45',
|
|
13
|
+
[chainIds.bnbMainnet]: '0xB971eF87ede563556b2ED4b1C0b0019111Dd85d2',
|
|
14
|
+
[chainIds.avalanche]: '0xbb00FF08d01D300023C629E8fFfFcb65A5a578cE', // not this:0x5615CDAb10dc425a742d643d949a7F474C01abc4 ?
|
|
15
|
+
[chainIds.base]: '0x2626664c2603336E57B271c5C0b26F421741e481',
|
|
16
|
+
},
|
|
17
|
+
[ExternalActionId.Odos]: {
|
|
18
|
+
[chainIds.ethMainnet]: '0xCf5540fFFCdC3d510B18bFcA6d2b9987b0772559', // ToDo: routers need to be updated to version 3
|
|
19
|
+
[chainIds.polygon]: '0x4E3288c9ca110bCC82bf38F09A7b425c095d92Bf',
|
|
20
|
+
[chainIds.optimism]: '0xCa423977156BB05b13A2BA3b76Bc5419E2fE9680',
|
|
21
|
+
[chainIds.arbMainnet]: '0xa669e7A0d4b3e4Fa48af2dE86BD4CD7126Be4e13',
|
|
22
|
+
[chainIds.bnbMainnet]: '0x89b8AA89FDd0507a99d334CBe3C808fAFC7d850E',
|
|
23
|
+
[chainIds.avalanche]: '0x88de50B233052e4Fb783d4F6db78Cc34fEa3e9FC', // not this:0x88de50B233052e4Fb783d4F6db78Cc34fEa3e9FC ?
|
|
24
|
+
[chainIds.base]: '0x19cEeAd7105607Cd444F5ad10dd51356436095a1',
|
|
25
|
+
},
|
|
26
|
+
[ExternalActionId.OneInch]: {
|
|
27
|
+
[chainIds.ethMainnet]: '0x1111111254EEB25477B68fb85Ed929f73A960582',
|
|
28
|
+
[chainIds.polygon]: '0x1111111254EEB25477B68fb85Ed929f73A960582',
|
|
29
|
+
[chainIds.optimism]: '0x1111111254EEB25477B68fb85Ed929f73A960582',
|
|
30
|
+
[chainIds.arbMainnet]: '0x1111111254EEB25477B68fb85Ed929f73A960582',
|
|
31
|
+
[chainIds.bnbMainnet]: '0x1111111254EEB25477B68fb85Ed929f73A960582',
|
|
32
|
+
[chainIds.avalanche]: '0x1111111254EEB25477B68fb85Ed929f73A960582',
|
|
33
|
+
[chainIds.base]: '0x1111111254EEB25477B68fb85Ed929f73A960582',
|
|
34
|
+
},
|
|
35
|
+
[ExternalActionId.Lifi]: {
|
|
36
|
+
[chainIds.ethMainnet]: '0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE',
|
|
37
|
+
[chainIds.polygon]: '0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE',
|
|
38
|
+
[chainIds.optimism]: '0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE',
|
|
39
|
+
[chainIds.arbMainnet]: '0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE',
|
|
40
|
+
[chainIds.bnbMainnet]: '0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE',
|
|
41
|
+
[chainIds.avalanche]: '0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE',
|
|
42
|
+
[chainIds.base]: '0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE',
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const NATIVE_TOKEN_WRAPPER_ADDRESSES = {
|
|
47
|
+
[chainIds.ethMainnet]: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
48
|
+
[chainIds.polygon]: '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270',
|
|
49
|
+
[chainIds.optimism]: '0x4200000000000000000000000000000000000006',
|
|
50
|
+
[chainIds.arbMainnet]: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1',
|
|
51
|
+
[chainIds.bnbMainnet]: '0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c',
|
|
52
|
+
[chainIds.avalanche]: '0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7',
|
|
53
|
+
[chainIds.base]: '0x4200000000000000000000000000000000000006',
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const WRAPPER_TOKEN_EXCHANGE_ADDRESSES = {
|
|
57
|
+
[chainIds.ethMainnet]: '0xdaC7Fb8AC2e47F412e8556Fd13256D90FBae08CD',
|
|
58
|
+
[chainIds.polygon]: '0x9759Baf5eEfa817E3FdF4C488ED51a334e948C05',
|
|
59
|
+
[chainIds.optimism]: '0xDe6A7d13c7E01582F5989b14cdf64d4bc6608364',
|
|
60
|
+
[chainIds.arbMainnet]: '0xF43D84490c6A155f2DDDF501db378D77151590f4',
|
|
61
|
+
[chainIds.bnbMainnet]: '0x5fa6773A7dC2CA3fB411f9Ef157F30e91aa1e53d',
|
|
62
|
+
[chainIds.avalanche]: '0xD201f9ae495b23805C12ed74a816AE4ef0c00b05',
|
|
63
|
+
[chainIds.base]: '0x86B9e7F2698C0776b988085b5Ca8d7D6A1Dff74b',
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const SWAP_FEE_TAKER_ADDRESSES = {
|
|
67
|
+
[chainIds.ethMainnet]: '0x1D69943ea7D9874b43f9FbcC2B6a4f0f433F602d',
|
|
68
|
+
[chainIds.polygon]: '0x5181606B45302Bb7b83e03DC7c5390ec9e4d973f',
|
|
69
|
+
[chainIds.optimism]: '0x0720a259A8CaBb9ef0F6a6334fEB4da5f45a8579',
|
|
70
|
+
[chainIds.arbMainnet]: '0x7ae4AD3f4D2df012807C3CC50fc0d4bB19Cc9800',
|
|
71
|
+
[chainIds.bnbMainnet]: '0x4200000000000000000000000000000000000000', // add after deployment
|
|
72
|
+
[chainIds.avalanche]: '0x4200000000000000000000000000000000000000', // add after deployment
|
|
73
|
+
[chainIds.base]: '0xB69B207994506697196E5C1Ce40233c06040BB79',
|
|
74
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const S3_BASE_URL = 'https://d1nvbznp963lfd.cloudfront.net/assets/';
|
|
2
|
+
|
|
3
|
+
export const IMAGE_PATHS = {
|
|
4
|
+
CHEVRON: `${S3_BASE_URL}Chevron.svg`,
|
|
5
|
+
MOON: `${S3_BASE_URL}Moon.svg`,
|
|
6
|
+
SUN: `${S3_BASE_URL}Sun.svg`,
|
|
7
|
+
ARROW_LEFT: `${S3_BASE_URL}ArrowLeft.svg`,
|
|
8
|
+
AUTHENTO_LIGHT: `${S3_BASE_URL}AuthentoLogoLight.png`,
|
|
9
|
+
AUTHENTO_DARK: `${S3_BASE_URL}AuthentoLogoDark.png`,
|
|
10
|
+
KING: `${S3_BASE_URL}King.svg`,
|
|
11
|
+
CIRCLE_STRIKETHROUGH: `${S3_BASE_URL}CircleStrikethrough.svg`,
|
|
12
|
+
RIGHT_SQUARE: `${S3_BASE_URL}RightSquare.svg`,
|
|
13
|
+
COINBASE_DARK: `${S3_BASE_URL}CoinbaseDark.png`,
|
|
14
|
+
COINBASE_LIGHT: `${S3_BASE_URL}CoinbaseLight.png`,
|
|
15
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const NETWORKS = {
|
|
2
|
+
polygon: 'polygon',
|
|
3
|
+
bnbMainnet: 'bnbMainnet',
|
|
4
|
+
arbMainnet: 'arbMainnet',
|
|
5
|
+
ethMainnet: 'ethMainnet',
|
|
6
|
+
avalanche: 'avalanche',
|
|
7
|
+
optimism: 'optimism',
|
|
8
|
+
base: 'base',
|
|
9
|
+
arcTestnet: 'arcTestnet',
|
|
10
|
+
localhost: 'localhost',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const getGasStationUrl = (network: string) => {
|
|
14
|
+
if (network === NETWORKS.polygon) return 'https://gasstation.polygon.technology/v1';
|
|
15
|
+
return undefined;
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const MAX_DISPLAY_DECIMALS = 6;
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { EthereumNetwork } from '../types/ethereum-network.types';
|
|
2
|
+
import {
|
|
3
|
+
arbMainnetData,
|
|
4
|
+
arcTestnetData,
|
|
5
|
+
avalancheData,
|
|
6
|
+
baseData,
|
|
7
|
+
bnbMainnetData,
|
|
8
|
+
ethMainnetData,
|
|
9
|
+
localhostData,
|
|
10
|
+
optimismData,
|
|
11
|
+
polygonData,
|
|
12
|
+
} from './deploy-data';
|
|
13
|
+
import { isDevelopment, isNotProduction } from './vite.constants';
|
|
14
|
+
|
|
15
|
+
export const chainIds = {
|
|
16
|
+
polygon: 137,
|
|
17
|
+
arbMainnet: 42161,
|
|
18
|
+
ethMainnet: 1,
|
|
19
|
+
avalanche: 43114,
|
|
20
|
+
bnbMainnet: 56,
|
|
21
|
+
optimism: 10,
|
|
22
|
+
base: 8453,
|
|
23
|
+
bnbTestnet: 97,
|
|
24
|
+
polygonMumbai: 80001,
|
|
25
|
+
mainnetSepolia: 11155111,
|
|
26
|
+
optimismSepolia: 11155420,
|
|
27
|
+
localhost: 31337,
|
|
28
|
+
hardhat: 31337,
|
|
29
|
+
arcTestnet: 5042002,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/*
|
|
33
|
+
@notice: ethMainnet is priority due to most tests rely on it
|
|
34
|
+
*/
|
|
35
|
+
export const localhostNetwork = chainIds.ethMainnet;
|
|
36
|
+
|
|
37
|
+
export const isLocalNetwork = (chainId: number): boolean => {
|
|
38
|
+
if ([chainIds.localhost].includes(chainId)) return true;
|
|
39
|
+
return false;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const getNonLocalhostChainId = (chainId: number | undefined) => {
|
|
43
|
+
if (chainId) {
|
|
44
|
+
return isLocalNetwork(chainId) ? localhostNetwork : chainId;
|
|
45
|
+
}
|
|
46
|
+
return localhostNetwork;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const ALCHEMY_TEST_KEY = 'X4IiEZsSzGOrJq8tzq7Y3';
|
|
50
|
+
export const ALCHEMY_API_KEY = isNotProduction ? ALCHEMY_TEST_KEY : 'XzUgeU8YiIIzkD7j2GWnTsFUck7wGgK9';
|
|
51
|
+
|
|
52
|
+
export const networkRegistry: Record<number, EthereumNetwork> = {
|
|
53
|
+
[chainIds.ethMainnet]: {
|
|
54
|
+
name: 'Ethereum',
|
|
55
|
+
chainId: chainIds.ethMainnet,
|
|
56
|
+
rpcUrl: 'https://rpc.ankr.com/eth',
|
|
57
|
+
fetchRpcUrl: `https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}`,
|
|
58
|
+
supported: true,
|
|
59
|
+
contractData: ethMainnetData,
|
|
60
|
+
quoterV2Address: '0x61fFE014bA17989E743c5F6cB21bF9697530B21e',
|
|
61
|
+
uniswapV3FactoryAddress: '0x1F98431c8aD98523631AE4a59f267346ea31F984',
|
|
62
|
+
priority: 1,
|
|
63
|
+
privateMempoolRpcUrl: 'https://relay.flashbots.net',
|
|
64
|
+
},
|
|
65
|
+
[chainIds.arbMainnet]: {
|
|
66
|
+
name: 'Arbitrum',
|
|
67
|
+
chainId: chainIds.arbMainnet,
|
|
68
|
+
rpcUrl: 'https://endpoints.omniatech.io/v1/arbitrum/one/public',
|
|
69
|
+
fetchRpcUrl: `https://arb-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}`,
|
|
70
|
+
supported: true,
|
|
71
|
+
contractData: arbMainnetData,
|
|
72
|
+
quoterV2Address: '0x61fFE014bA17989E743c5F6cB21bF9697530B21e',
|
|
73
|
+
uniswapV3FactoryAddress: '0x1F98431c8aD98523631AE4a59f267346ea31F984',
|
|
74
|
+
priority: 2,
|
|
75
|
+
},
|
|
76
|
+
[chainIds.optimism]: {
|
|
77
|
+
name: 'Optimism',
|
|
78
|
+
chainId: chainIds.optimism,
|
|
79
|
+
rpcUrl: 'https://optimism-mainnet.infura.io/v3/c26b99456bb6464bb498926ff5162903',
|
|
80
|
+
fetchRpcUrl: `https://opt-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}`,
|
|
81
|
+
supported: true,
|
|
82
|
+
contractData: optimismData,
|
|
83
|
+
quoterV2Address: '0x61fFE014bA17989E743c5F6cB21bF9697530B21e',
|
|
84
|
+
uniswapV3FactoryAddress: '0x1F98431c8aD98523631AE4a59f267346ea31F984',
|
|
85
|
+
priority: 3,
|
|
86
|
+
},
|
|
87
|
+
[chainIds.polygon]: {
|
|
88
|
+
name: 'Polygon',
|
|
89
|
+
chainId: chainIds.polygon,
|
|
90
|
+
rpcUrl: 'https://polygon-rpc.com',
|
|
91
|
+
fetchRpcUrl: `https://polygon-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}`,
|
|
92
|
+
supported: true,
|
|
93
|
+
contractData: polygonData,
|
|
94
|
+
quoterV2Address: '0x61fFE014bA17989E743c5F6cB21bF9697530B21e',
|
|
95
|
+
uniswapV3FactoryAddress: '0x1F98431c8aD98523631AE4a59f267346ea31F984',
|
|
96
|
+
priority: 4,
|
|
97
|
+
},
|
|
98
|
+
[chainIds.avalanche]: {
|
|
99
|
+
name: 'Avalanche',
|
|
100
|
+
chainId: chainIds.avalanche,
|
|
101
|
+
rpcUrl: 'https://api.avax.network/ext/bc/C/rpc',
|
|
102
|
+
fetchRpcUrl: `https://avax-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}`,
|
|
103
|
+
supported: true,
|
|
104
|
+
contractData: avalancheData,
|
|
105
|
+
quoterV2Address: '0xbe0F5544EC67e9B3b2D979aaA43f18Fd87E6257F',
|
|
106
|
+
uniswapV3FactoryAddress: '0x740b1c1de25031C31FF4fC9A62f554A55cdC1baD',
|
|
107
|
+
priority: 5,
|
|
108
|
+
},
|
|
109
|
+
[chainIds.bnbMainnet]: {
|
|
110
|
+
name: 'BNB Chain',
|
|
111
|
+
chainId: chainIds.bnbMainnet,
|
|
112
|
+
rpcUrl: 'https://bsc-dataseed.binance.org',
|
|
113
|
+
// maxPageSize: 1000,
|
|
114
|
+
fetchRpcUrl: `https://bnb-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}`,
|
|
115
|
+
supported: true,
|
|
116
|
+
contractData: bnbMainnetData,
|
|
117
|
+
quoterV2Address: '0x78D78E420Da98ad378D7799bE8f4AF69033EB077',
|
|
118
|
+
uniswapV3FactoryAddress: '0xdB1d10011AD0Ff90774D0C6Bb92e5C5c8b4461F7',
|
|
119
|
+
priority: 6,
|
|
120
|
+
},
|
|
121
|
+
[chainIds.base]: {
|
|
122
|
+
name: 'Base',
|
|
123
|
+
chainId: chainIds.base,
|
|
124
|
+
rpcUrl: 'https://mainnet.base.org/',
|
|
125
|
+
// maxPageSize: 1000,
|
|
126
|
+
fetchRpcUrl: `https://base-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}`,
|
|
127
|
+
supported: true,
|
|
128
|
+
contractData: baseData,
|
|
129
|
+
quoterV2Address: '0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a',
|
|
130
|
+
uniswapV3FactoryAddress: '0x33128a8fC17869897dcE68Ed026d694621f6FDfD',
|
|
131
|
+
priority: 7,
|
|
132
|
+
},
|
|
133
|
+
[chainIds.arcTestnet]: {
|
|
134
|
+
name: 'Arc Testnet',
|
|
135
|
+
chainId: chainIds.arcTestnet,
|
|
136
|
+
rpcUrl: `https://arc-testnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}`,
|
|
137
|
+
fetchRpcUrl: `https://arc-testnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}`,
|
|
138
|
+
supported: true,
|
|
139
|
+
contractData: arcTestnetData,
|
|
140
|
+
priority: 8,
|
|
141
|
+
maxPageSize: 9999,
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
...(isDevelopment ? {} : {}),
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const localNetwork = {
|
|
148
|
+
name: 'Localhost',
|
|
149
|
+
chainId: chainIds.localhost,
|
|
150
|
+
rpcUrl: 'http://127.0.0.1:8545',
|
|
151
|
+
fetchRpcUrl: 'http://127.0.0.1:8545',
|
|
152
|
+
supported: true,
|
|
153
|
+
contractData: localhostData,
|
|
154
|
+
quoterV2Address: networkRegistry[localhostNetwork].quoterV2Address,
|
|
155
|
+
uniswapV3FactoryAddress: networkRegistry[localhostNetwork].uniswapV3FactoryAddress,
|
|
156
|
+
priority: 7,
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
if (isDevelopment) {
|
|
160
|
+
networkRegistry[chainIds.localhost] = localNetwork;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export enum EthereumNetworkType {
|
|
164
|
+
Mainnet = 'Mainnet',
|
|
165
|
+
Testnet = 'Testnet',
|
|
166
|
+
Local = 'Local',
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export const chainIdsByType = {
|
|
170
|
+
[EthereumNetworkType.Mainnet]: [
|
|
171
|
+
chainIds.polygon,
|
|
172
|
+
chainIds.arbMainnet,
|
|
173
|
+
chainIds.ethMainnet,
|
|
174
|
+
chainIds.bnbMainnet,
|
|
175
|
+
chainIds.optimism,
|
|
176
|
+
chainIds.avalanche,
|
|
177
|
+
chainIds.base,
|
|
178
|
+
],
|
|
179
|
+
[EthereumNetworkType.Testnet]: [chainIds.bnbTestnet, chainIds.polygonMumbai, chainIds.arcTestnet],
|
|
180
|
+
[EthereumNetworkType.Local]: [chainIds.localhost],
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export const isOptimismLike = (chainId: number) => [chainIds.optimism, chainIds.base].includes(chainId);
|
|
184
|
+
|
|
185
|
+
export const WALLET_INITIAL_CHAIN_ID = chainIds.ethMainnet;
|
|
186
|
+
|
|
187
|
+
export const WALLET_SUPPORTED_CHAINS = [
|
|
188
|
+
chainIds.ethMainnet,
|
|
189
|
+
chainIds.optimism,
|
|
190
|
+
chainIds.base,
|
|
191
|
+
chainIds.polygon,
|
|
192
|
+
chainIds.arbMainnet,
|
|
193
|
+
chainIds.arcTestnet,
|
|
194
|
+
];
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { chainIds, getNonLocalhostChainId } from './chains.constants';
|
|
2
|
+
|
|
3
|
+
const baseCoingeckoUrl = 'https://api.coingecko.com/api/v3';
|
|
4
|
+
export const proCoingeckoUrl = 'https://pro-api.coingecko.com/api/v3';
|
|
5
|
+
// eslint-disable-next-line prefer-destructuring, @typescript-eslint/dot-notation
|
|
6
|
+
export const COINGECKO_API_KEY = typeof window !== 'undefined' ? '' : process.env['COINGECKO_API_KEY'];
|
|
7
|
+
export const proHeader = `x-cg-pro-api-key`;
|
|
8
|
+
const link = COINGECKO_API_KEY ? proCoingeckoUrl : baseCoingeckoUrl;
|
|
9
|
+
|
|
10
|
+
export const coingeckoPriceUrl = (tokenId: string) => {
|
|
11
|
+
return `${link}/simple/price?ids=${tokenId}&vs_currencies=USD,ETH`;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const coingeckoPriceUrl2 = (tokenAddress: string, platform: string) => {
|
|
15
|
+
return `${link}/simple/token_price/${platform}?contract_addresses=${tokenAddress}&vs_currencies=USD`;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const getCoinById = (tokenId: string) => `${link}/coins/${tokenId}`;
|
|
19
|
+
export const searchBySymbol = (tokenSymbol: string) => `${link}/search?query=${encodeURIComponent(tokenSymbol)}`;
|
|
20
|
+
export const getCoinByAddress = (currentNetwork: string, tokenAddress: string) =>
|
|
21
|
+
`${baseCoingeckoUrl}/coins/${currentNetwork}/contract/${tokenAddress}`;
|
|
22
|
+
|
|
23
|
+
export const coingeckoTokenListUrl = `${proCoingeckoUrl}/coins/list`;
|
|
24
|
+
|
|
25
|
+
export const getCoingeckoIdForNativeTokens = {
|
|
26
|
+
[chainIds.arbMainnet]: 'ethereum',
|
|
27
|
+
[chainIds.localhost]: 'ethereum',
|
|
28
|
+
[chainIds.ethMainnet]: 'ethereum',
|
|
29
|
+
[chainIds.optimism]: 'ethereum',
|
|
30
|
+
[chainIds.avalanche]: 'avalanche-2',
|
|
31
|
+
[chainIds.polygon]: 'matic-network',
|
|
32
|
+
[chainIds.bnbMainnet]: 'binancecoin',
|
|
33
|
+
[chainIds.base]: 'ethereum',
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const getCoingeckoPlatform = (chainId: number) => {
|
|
37
|
+
const nonLocalhostChainId = getNonLocalhostChainId(chainId);
|
|
38
|
+
switch (nonLocalhostChainId) {
|
|
39
|
+
case chainIds.ethMainnet:
|
|
40
|
+
return 'ethereum';
|
|
41
|
+
case chainIds.polygon:
|
|
42
|
+
return 'polygon-pos';
|
|
43
|
+
case chainIds.bnbMainnet:
|
|
44
|
+
return 'binance-smart-chain';
|
|
45
|
+
case chainIds.optimism:
|
|
46
|
+
return 'optimistic-ethereum';
|
|
47
|
+
case chainIds.arbMainnet:
|
|
48
|
+
return 'arbitrum-one';
|
|
49
|
+
case chainIds.avalanche:
|
|
50
|
+
return 'avalanche';
|
|
51
|
+
case chainIds.base:
|
|
52
|
+
return 'base';
|
|
53
|
+
default:
|
|
54
|
+
return 'ethereum';
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const CoinGeckoChainLabels = {
|
|
59
|
+
[chainIds.polygon]: 'polygon-pos',
|
|
60
|
+
[chainIds.arbMainnet]: 'arbitrum-one',
|
|
61
|
+
[chainIds.ethMainnet]: 'ethereum',
|
|
62
|
+
[chainIds.avalanche]: 'avalanche',
|
|
63
|
+
[chainIds.bnbMainnet]: 'binance-smart-chain',
|
|
64
|
+
[chainIds.optimism]: 'optimistic-ethereum',
|
|
65
|
+
[chainIds.base]: 'base',
|
|
66
|
+
};
|
|
67
|
+
// Arc Testnet is not on Coingecko
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { ethers, utils } from 'ethers';
|
|
2
|
+
import { ERC1155ABI, ERC721ABI } from '../externalABIs';
|
|
3
|
+
import ERC20ABI from '../externalABIs/ERC20.json';
|
|
4
|
+
import IQuoterV2ABI from '../externalABIs/IQuoterV2.json';
|
|
5
|
+
import uniswapV3FactoryABI from '../externalABIs/IUniswapV3Factory.json';
|
|
6
|
+
import uniswapV3PoolABI from '../externalABIs/IUniswapV3Pool.json';
|
|
7
|
+
import uniswapV2PoolABI from '../externalABIs/UniswapV2PoolAbi.json';
|
|
8
|
+
import { getNonLocalhostChainId, networkRegistry } from './chains.constants';
|
|
9
|
+
import { ContractData, ContractMetadata, ContractType } from '../types/ethereum-network.types';
|
|
10
|
+
|
|
11
|
+
// INISWAP INTERFACES
|
|
12
|
+
export const uniswapV3FactoryData = {
|
|
13
|
+
abi: uniswapV3FactoryABI.abi,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const uniswapV3PoolData = {
|
|
17
|
+
abi: uniswapV3PoolABI.abi,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const uniswapV2PoolData = {
|
|
21
|
+
abi: uniswapV2PoolABI.abi,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const uniswapV3QuoterData = {
|
|
25
|
+
abi: IQuoterV2ABI.abi,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const contractMetadataMapping: Record<ContractType, (contractData: ContractData) => ContractMetadata> = {
|
|
29
|
+
[ContractType.HinkalContract]: (contractData) => ({
|
|
30
|
+
abi: contractData.hinkalABI,
|
|
31
|
+
address: contractData.hinkalAddress,
|
|
32
|
+
}),
|
|
33
|
+
[ContractType.HinkalHelperContract]: (contractData) => ({
|
|
34
|
+
abi: contractData.hinkalHelperABI,
|
|
35
|
+
address: contractData.hinkalHelperAddress,
|
|
36
|
+
}),
|
|
37
|
+
[ContractType.AccessTokenContract]: (contractData) => ({
|
|
38
|
+
abi: contractData.accessTokenABI,
|
|
39
|
+
address: contractData.accessTokenAddress,
|
|
40
|
+
}),
|
|
41
|
+
[ContractType.MerkleTreeContract]: () => ({
|
|
42
|
+
abi: new ethers.utils.Interface(['function getRootHash() public view returns (uint256)']),
|
|
43
|
+
}),
|
|
44
|
+
[ContractType.UniswapV3FactoryContract]: () => ({
|
|
45
|
+
abi: uniswapV3FactoryData.abi,
|
|
46
|
+
}),
|
|
47
|
+
[ContractType.UniswapV3PoolContract]: () => ({
|
|
48
|
+
abi: uniswapV3PoolData.abi,
|
|
49
|
+
}),
|
|
50
|
+
[ContractType.UniswapV2PoolContract]: () => ({
|
|
51
|
+
abi: uniswapV2PoolData.abi,
|
|
52
|
+
}),
|
|
53
|
+
[ContractType.UniswapV3QuoterContract]: () => ({
|
|
54
|
+
abi: uniswapV3QuoterData.abi,
|
|
55
|
+
}),
|
|
56
|
+
[ContractType.ERC20Contract]: () => ({
|
|
57
|
+
abi: ERC20ABI.abi,
|
|
58
|
+
}),
|
|
59
|
+
[ContractType.ERC721Contract]: () => ({
|
|
60
|
+
abi: ERC721ABI,
|
|
61
|
+
}),
|
|
62
|
+
[ContractType.ERC1155Contract]: () => ({
|
|
63
|
+
abi: ERC1155ABI,
|
|
64
|
+
}),
|
|
65
|
+
[ContractType.WATokenContract]: (contractData) => ({
|
|
66
|
+
abi: contractData.waTokenABI,
|
|
67
|
+
}),
|
|
68
|
+
|
|
69
|
+
[ContractType.ContractWithNonces]: () => ({
|
|
70
|
+
abi: new ethers.utils.Interface(['function nonces(address owner) external view returns (uint)']),
|
|
71
|
+
}),
|
|
72
|
+
[ContractType.PermitterContract]: (contractData) => ({
|
|
73
|
+
abi: contractData.permitterABI,
|
|
74
|
+
address: contractData.permitterAddress,
|
|
75
|
+
}),
|
|
76
|
+
[ContractType.OneInchExternalActionContract]: (contractData) => ({
|
|
77
|
+
address: contractData.oneInchExternalActionInstanceAddress,
|
|
78
|
+
}),
|
|
79
|
+
[ContractType.HinkalWrapper]: (contractData) => ({
|
|
80
|
+
abi: contractData.HinkalWrapperABI,
|
|
81
|
+
address: contractData.hinkalWrapperAddress,
|
|
82
|
+
}),
|
|
83
|
+
[ContractType.HinkalWrapper2]: (contractData) => ({
|
|
84
|
+
// return old one if new one isn't available
|
|
85
|
+
abi: contractData.HinkalWrapper2ABI ?? contractData.HinkalWrapperABI,
|
|
86
|
+
address: contractData.hinkalWrapper2Address ?? contractData.hinkalWrapperAddress,
|
|
87
|
+
}),
|
|
88
|
+
[ContractType.HinkalStakeExternalAction]: (contractData) => ({
|
|
89
|
+
abi: contractData.HinkalStakeExternalActionABI,
|
|
90
|
+
address: contractData.hinkalStakeExternalActionAddress,
|
|
91
|
+
}),
|
|
92
|
+
[ContractType.HToken]: (contractData) => ({
|
|
93
|
+
abi: contractData.HTokenABI,
|
|
94
|
+
}),
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export const getHinkalParameters = (chainId: number) => {
|
|
98
|
+
const { contractData } = networkRegistry[getNonLocalhostChainId(chainId)];
|
|
99
|
+
const hinkalABI = JSON.stringify(contractData.hinkalABI);
|
|
100
|
+
const hinkalInterface = new utils.Interface(hinkalABI);
|
|
101
|
+
const transactMethodId = hinkalInterface.getSighash('transact');
|
|
102
|
+
const transactWithExternalActionMethodId = hinkalInterface.getSighash('transactWithExternalAction');
|
|
103
|
+
const NewCommitment = 'NewCommitment';
|
|
104
|
+
const NewCommitmentTopic = '0xc2e3bd2d00c3cf4d09298e5a0cfd317cf7a6e5bf15d467cfa805a91e1a4a221d';
|
|
105
|
+
return { hinkalInterface, transactMethodId, transactWithExternalActionMethodId, NewCommitment, NewCommitmentTopic };
|
|
106
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const APPROVED_UTXO_CONVERSION_COUNT = 3;
|