UNPKG

ethers-opt

Version:

Collection of heavily optimized functions for ethers.js V6

2,501 lines (2,494 loc) 134 kB
import { EnsResolver as EnsResolver$1, Contract, namehash, ZeroAddress, getAddress, dnsEncode, isError, Interface, isHexString, assertArgument, assert, EventLog, UndecodedEventLog, Log, toQuantity, FeeData, defineProperties, JsonRpcProvider, FetchRequest, Network, AbiCoder, Transaction, parseEther, parseUnits, resolveProperties, VoidSigner, Wallet, HDNodeWallet, BrowserProvider as BrowserProvider$1, JsonRpcSigner, MaxUint256, Signature, formatUnits } from 'ethers'; import { webcrypto } from 'crypto'; const chainNames = {}; const ensRegistries = { // ETH ENS (mainnet, sepolia) 1: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e", 11155111: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e", // Basenames 8453: "0xB94704422c2a1E396835A571837Aa5AE53285a95", 84532: "0x1493b2567056c2181630115660963E13A8E32735" }; const ensUniversalResolvers = { // ETH ENS (mainnet, sepolia) 1: "0xce01f8eee7E479C928F8919abD53E553a36CeF67", 11155111: "0xce01f8eee7E479C928F8919abD53E553a36CeF67" }; const ensStaticResolvers = { // Using universal resolvers because they are also capable of querying custom resolves on behalf // (so that you don't need to know the exact resolver it works like a router contract) ...ensUniversalResolvers, // Known main resolver for ENS like registries where universal resolver isn't available // Basenames 8453: "0xC6d566A56A1aFf6508b41f6c90ff131615583BCD", 84532: "0x6533C94869D28fAA8dF77cc63f9e2b2D6Cf77eBA" }; const ensReverseNode = { // BASE_REVERSE_NODE 8453: ".80002105.reverse", 84532: ".80002105.reverse" }; const wildcardResolvers = /* @__PURE__ */ new Set([ // ETH ENS (mainnet, sepolia) "0xce01f8eee7E479C928F8919abD53E553a36CeF67", // Basenames "0xC6d566A56A1aFf6508b41f6c90ff131615583BCD", "0x6533C94869D28fAA8dF77cc63f9e2b2D6Cf77eBA" ]); class EnsResolver extends EnsResolver$1 { /** * Overrides method to support both ENS & Basename */ async supportsWildcard() { if (wildcardResolvers.has(this.address)) { return true; } return super.supportsWildcard(); } static async getEnsAddress(provider) { const network = await provider.getNetwork(); const chainId = Number(network.chainId); const ensPlugin = network.getPlugin("org.ethers.plugins.network.Ens"); const ensRegistryAddress = ensRegistries[chainId] || ensPlugin?.address; if (!ensRegistryAddress) { throw new Error(`Network ${chainId} doesn't have ENS registry address specified`); } return ensRegistryAddress; } static async #getResolver(provider, name, hash) { const chainId = Number((await provider.getNetwork()).chainId); if (ensStaticResolvers[chainId]) { return ensStaticResolvers[chainId]; } const ensAddr = await EnsResolver.getEnsAddress(provider); try { const contract = new Contract( ensAddr, ["function resolver(bytes32) view returns (address)"], provider ); const addr = await contract.resolver(hash || namehash(name || ""), { enableCcipRead: true }); if (addr === ZeroAddress) { return null; } return addr; } catch (error) { throw error; } } // Override method to fetch resolver from non private method static async fromName(provider, name) { let currentName = name; while (true) { if (currentName === "" || currentName === ".") { return null; } if (name !== "eth" && currentName === "eth") { return null; } const addr = await EnsResolver.#getResolver(provider, currentName); if (addr != null) { const resolver = new EnsResolver(provider, addr, name); if (currentName !== name && !await resolver.supportsWildcard()) { return null; } return resolver; } currentName = currentName.split(".").slice(1).join("."); } } // Reverse name lookup ported from AbstractProvider static async lookupAddress(provider, address, reverseCheck = true) { try { address = getAddress(address); const chainId = Number((await provider.getNetwork()).chainId); const reverseName = address.substring(2).toLowerCase() + (ensReverseNode[chainId] || ".addr.reverse"); const node = namehash(reverseName); const resolverAddress = await EnsResolver.#getResolver(provider, "", node); if (resolverAddress == null || resolverAddress === ZeroAddress) { return null; } const resolverContract = new Contract( resolverAddress, [ "function reverse(bytes) view returns (string memory, address, address, address)", "function name(bytes32) view returns (string)" ], provider ); if (ensUniversalResolvers[chainId]) { const dnsNode = dnsEncode(reverseName); const [name2, nameAddress] = await resolverContract.reverse(dnsNode); if (!name2 || nameAddress !== address) { return null; } return name2; } const name = await resolverContract.name(node); if (!name) { return null; } if (reverseCheck) { const nameAddress = await provider.resolveName(name); if (nameAddress !== address) { return null; } } return name; } catch (error) { if (isError(error, "BAD_DATA") && error.value === "0x") { return null; } if (isError(error, "CALL_EXCEPTION")) { return null; } throw error; } } /** * Method overrides to handle errors if name doesn't exist * (Error: could not decode result data ethers/src.ts/providers/ens-resolver.ts:249:30) * (Cannot be handled by checking if resolver address is null or result is '0x') * (Likely bug on #fetch from EnsResolver with return iface.decodeFunctionResult(fragment, result)[0];) */ async getAddress(coinType) { try { return await super.getAddress(coinType); } catch (error) { if (isError(error, "BAD_DATA") && error.value === "0x") { return null; } throw error; } } async getText(key) { try { return await super.getText(key); } catch (error) { if (isError(error, "BAD_DATA") && error.value === "0x") { return null; } throw error; } } async getContentHash() { try { return await super.getContentHash(); } catch (error) { if (isError(error, "BAD_DATA") && error.value === "0x") { return null; } throw error; } } async getAvatar() { try { return await super.getAvatar(); } catch (error) { if (isError(error, "BAD_DATA") && error.value === "0x") { return null; } throw error; } } } const _abi$7 = [ { inputs: [ { internalType: "address", name: "emitter", type: "address" } ], name: "FailedContractCreation", type: "error" }, { inputs: [ { internalType: "address", name: "emitter", type: "address" }, { internalType: "bytes", name: "revertData", type: "bytes" } ], name: "FailedContractInitialisation", type: "error" }, { inputs: [ { internalType: "address", name: "emitter", type: "address" }, { internalType: "bytes", name: "revertData", type: "bytes" } ], name: "FailedEtherTransfer", type: "error" }, { inputs: [ { internalType: "address", name: "emitter", type: "address" } ], name: "InvalidNonceValue", type: "error" }, { inputs: [ { internalType: "address", name: "emitter", type: "address" } ], name: "InvalidSalt", type: "error" }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "newContract", type: "address" }, { indexed: true, internalType: "bytes32", name: "salt", type: "bytes32" } ], name: "ContractCreation", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "newContract", type: "address" } ], name: "ContractCreation", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "newContract", type: "address" }, { indexed: true, internalType: "bytes32", name: "salt", type: "bytes32" } ], name: "Create3ProxyContractCreation", type: "event" }, { inputs: [ { internalType: "bytes32", name: "salt", type: "bytes32" }, { internalType: "bytes32", name: "initCodeHash", type: "bytes32" } ], name: "computeCreate2Address", outputs: [ { internalType: "address", name: "computedAddress", type: "address" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "bytes32", name: "salt", type: "bytes32" }, { internalType: "bytes32", name: "initCodeHash", type: "bytes32" }, { internalType: "address", name: "deployer", type: "address" } ], name: "computeCreate2Address", outputs: [ { internalType: "address", name: "computedAddress", type: "address" } ], stateMutability: "pure", type: "function" }, { inputs: [ { internalType: "bytes32", name: "salt", type: "bytes32" }, { internalType: "address", name: "deployer", type: "address" } ], name: "computeCreate3Address", outputs: [ { internalType: "address", name: "computedAddress", type: "address" } ], stateMutability: "pure", type: "function" }, { inputs: [ { internalType: "bytes32", name: "salt", type: "bytes32" } ], name: "computeCreate3Address", outputs: [ { internalType: "address", name: "computedAddress", type: "address" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "uint256", name: "nonce", type: "uint256" } ], name: "computeCreateAddress", outputs: [ { internalType: "address", name: "computedAddress", type: "address" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address", name: "deployer", type: "address" }, { internalType: "uint256", name: "nonce", type: "uint256" } ], name: "computeCreateAddress", outputs: [ { internalType: "address", name: "computedAddress", type: "address" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "bytes", name: "initCode", type: "bytes" } ], name: "deployCreate", outputs: [ { internalType: "address", name: "newContract", type: "address" } ], stateMutability: "payable", type: "function" }, { inputs: [ { internalType: "bytes32", name: "salt", type: "bytes32" }, { internalType: "bytes", name: "initCode", type: "bytes" } ], name: "deployCreate2", outputs: [ { internalType: "address", name: "newContract", type: "address" } ], stateMutability: "payable", type: "function" }, { inputs: [ { internalType: "bytes", name: "initCode", type: "bytes" } ], name: "deployCreate2", outputs: [ { internalType: "address", name: "newContract", type: "address" } ], stateMutability: "payable", type: "function" }, { inputs: [ { internalType: "bytes32", name: "salt", type: "bytes32" }, { internalType: "bytes", name: "initCode", type: "bytes" }, { internalType: "bytes", name: "data", type: "bytes" }, { components: [ { internalType: "uint256", name: "constructorAmount", type: "uint256" }, { internalType: "uint256", name: "initCallAmount", type: "uint256" } ], internalType: "struct CreateX.Values", name: "values", type: "tuple" }, { internalType: "address", name: "refundAddress", type: "address" } ], name: "deployCreate2AndInit", outputs: [ { internalType: "address", name: "newContract", type: "address" } ], stateMutability: "payable", type: "function" }, { inputs: [ { internalType: "bytes", name: "initCode", type: "bytes" }, { internalType: "bytes", name: "data", type: "bytes" }, { components: [ { internalType: "uint256", name: "constructorAmount", type: "uint256" }, { internalType: "uint256", name: "initCallAmount", type: "uint256" } ], internalType: "struct CreateX.Values", name: "values", type: "tuple" } ], name: "deployCreate2AndInit", outputs: [ { internalType: "address", name: "newContract", type: "address" } ], stateMutability: "payable", type: "function" }, { inputs: [ { internalType: "bytes", name: "initCode", type: "bytes" }, { internalType: "bytes", name: "data", type: "bytes" }, { components: [ { internalType: "uint256", name: "constructorAmount", type: "uint256" }, { internalType: "uint256", name: "initCallAmount", type: "uint256" } ], internalType: "struct CreateX.Values", name: "values", type: "tuple" }, { internalType: "address", name: "refundAddress", type: "address" } ], name: "deployCreate2AndInit", outputs: [ { internalType: "address", name: "newContract", type: "address" } ], stateMutability: "payable", type: "function" }, { inputs: [ { internalType: "bytes32", name: "salt", type: "bytes32" }, { internalType: "bytes", name: "initCode", type: "bytes" }, { internalType: "bytes", name: "data", type: "bytes" }, { components: [ { internalType: "uint256", name: "constructorAmount", type: "uint256" }, { internalType: "uint256", name: "initCallAmount", type: "uint256" } ], internalType: "struct CreateX.Values", name: "values", type: "tuple" } ], name: "deployCreate2AndInit", outputs: [ { internalType: "address", name: "newContract", type: "address" } ], stateMutability: "payable", type: "function" }, { inputs: [ { internalType: "bytes32", name: "salt", type: "bytes32" }, { internalType: "address", name: "implementation", type: "address" }, { internalType: "bytes", name: "data", type: "bytes" } ], name: "deployCreate2Clone", outputs: [ { internalType: "address", name: "proxy", type: "address" } ], stateMutability: "payable", type: "function" }, { inputs: [ { internalType: "address", name: "implementation", type: "address" }, { internalType: "bytes", name: "data", type: "bytes" } ], name: "deployCreate2Clone", outputs: [ { internalType: "address", name: "proxy", type: "address" } ], stateMutability: "payable", type: "function" }, { inputs: [ { internalType: "bytes", name: "initCode", type: "bytes" } ], name: "deployCreate3", outputs: [ { internalType: "address", name: "newContract", type: "address" } ], stateMutability: "payable", type: "function" }, { inputs: [ { internalType: "bytes32", name: "salt", type: "bytes32" }, { internalType: "bytes", name: "initCode", type: "bytes" } ], name: "deployCreate3", outputs: [ { internalType: "address", name: "newContract", type: "address" } ], stateMutability: "payable", type: "function" }, { inputs: [ { internalType: "bytes32", name: "salt", type: "bytes32" }, { internalType: "bytes", name: "initCode", type: "bytes" }, { internalType: "bytes", name: "data", type: "bytes" }, { components: [ { internalType: "uint256", name: "constructorAmount", type: "uint256" }, { internalType: "uint256", name: "initCallAmount", type: "uint256" } ], internalType: "struct CreateX.Values", name: "values", type: "tuple" } ], name: "deployCreate3AndInit", outputs: [ { internalType: "address", name: "newContract", type: "address" } ], stateMutability: "payable", type: "function" }, { inputs: [ { internalType: "bytes", name: "initCode", type: "bytes" }, { internalType: "bytes", name: "data", type: "bytes" }, { components: [ { internalType: "uint256", name: "constructorAmount", type: "uint256" }, { internalType: "uint256", name: "initCallAmount", type: "uint256" } ], internalType: "struct CreateX.Values", name: "values", type: "tuple" } ], name: "deployCreate3AndInit", outputs: [ { internalType: "address", name: "newContract", type: "address" } ], stateMutability: "payable", type: "function" }, { inputs: [ { internalType: "bytes32", name: "salt", type: "bytes32" }, { internalType: "bytes", name: "initCode", type: "bytes" }, { internalType: "bytes", name: "data", type: "bytes" }, { components: [ { internalType: "uint256", name: "constructorAmount", type: "uint256" }, { internalType: "uint256", name: "initCallAmount", type: "uint256" } ], internalType: "struct CreateX.Values", name: "values", type: "tuple" }, { internalType: "address", name: "refundAddress", type: "address" } ], name: "deployCreate3AndInit", outputs: [ { internalType: "address", name: "newContract", type: "address" } ], stateMutability: "payable", type: "function" }, { inputs: [ { internalType: "bytes", name: "initCode", type: "bytes" }, { internalType: "bytes", name: "data", type: "bytes" }, { components: [ { internalType: "uint256", name: "constructorAmount", type: "uint256" }, { internalType: "uint256", name: "initCallAmount", type: "uint256" } ], internalType: "struct CreateX.Values", name: "values", type: "tuple" }, { internalType: "address", name: "refundAddress", type: "address" } ], name: "deployCreate3AndInit", outputs: [ { internalType: "address", name: "newContract", type: "address" } ], stateMutability: "payable", type: "function" }, { inputs: [ { internalType: "bytes", name: "initCode", type: "bytes" }, { internalType: "bytes", name: "data", type: "bytes" }, { components: [ { internalType: "uint256", name: "constructorAmount", type: "uint256" }, { internalType: "uint256", name: "initCallAmount", type: "uint256" } ], internalType: "struct CreateX.Values", name: "values", type: "tuple" } ], name: "deployCreateAndInit", outputs: [ { internalType: "address", name: "newContract", type: "address" } ], stateMutability: "payable", type: "function" }, { inputs: [ { internalType: "bytes", name: "initCode", type: "bytes" }, { internalType: "bytes", name: "data", type: "bytes" }, { components: [ { internalType: "uint256", name: "constructorAmount", type: "uint256" }, { internalType: "uint256", name: "initCallAmount", type: "uint256" } ], internalType: "struct CreateX.Values", name: "values", type: "tuple" }, { internalType: "address", name: "refundAddress", type: "address" } ], name: "deployCreateAndInit", outputs: [ { internalType: "address", name: "newContract", type: "address" } ], stateMutability: "payable", type: "function" }, { inputs: [ { internalType: "address", name: "implementation", type: "address" }, { internalType: "bytes", name: "data", type: "bytes" } ], name: "deployCreateClone", outputs: [ { internalType: "address", name: "proxy", type: "address" } ], stateMutability: "payable", type: "function" } ]; class CreateX__factory { static abi = _abi$7; static createInterface() { return new Interface(_abi$7); } static connect(address, runner) { return new Contract(address, _abi$7, runner); } } const _abi$6 = [ { inputs: [], name: "aggregator", outputs: [ { internalType: "address", name: "", type: "address" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "decimals", outputs: [ { internalType: "uint8", name: "", type: "uint8" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "description", outputs: [ { internalType: "string", name: "", type: "string" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "uint80", name: "_roundId", type: "uint80" } ], name: "getRoundData", outputs: [ { internalType: "uint80", name: "roundId", type: "uint80" }, { internalType: "int256", name: "answer", type: "int256" }, { internalType: "uint256", name: "startedAt", type: "uint256" }, { internalType: "uint256", name: "updatedAt", type: "uint256" }, { internalType: "uint80", name: "answeredInRound", type: "uint80" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "latestRoundData", outputs: [ { internalType: "uint80", name: "roundId", type: "uint80" }, { internalType: "int256", name: "answer", type: "int256" }, { internalType: "uint256", name: "startedAt", type: "uint256" }, { internalType: "uint256", name: "updatedAt", type: "uint256" }, { internalType: "uint80", name: "answeredInRound", type: "uint80" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "latestAnswer", outputs: [ { internalType: "int256", name: "", type: "int256" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "latestRound", outputs: [ { internalType: "uint256", name: "", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "version", outputs: [ { internalType: "uint256", name: "", type: "uint256" } ], stateMutability: "view", type: "function" } ]; class DataFeed__factory { static abi = _abi$6; static createInterface() { return new Interface(_abi$6); } static connect(address, runner) { return new Contract(address, _abi$6, runner); } } const _abi$5 = [ { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "owner", type: "address" }, { indexed: true, internalType: "address", name: "spender", type: "address" }, { indexed: false, internalType: "uint256", name: "value", type: "uint256" } ], name: "Approval", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "from", type: "address" }, { indexed: true, internalType: "address", name: "to", type: "address" }, { indexed: false, internalType: "uint256", name: "value", type: "uint256" } ], name: "Transfer", type: "event" }, { inputs: [], name: "DOMAIN_SEPARATOR", outputs: [ { internalType: "bytes32", name: "", type: "bytes32" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address", name: "owner", type: "address" }, { internalType: "address", name: "spender", type: "address" } ], name: "allowance", outputs: [ { internalType: "uint256", name: "", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address", name: "spender", type: "address" }, { internalType: "uint256", name: "value", type: "uint256" } ], name: "approve", outputs: [ { internalType: "bool", name: "", type: "bool" } ], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "address", name: "account", type: "address" } ], name: "balanceOf", outputs: [ { internalType: "uint256", name: "", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "decimals", outputs: [ { internalType: "uint8", name: "", type: "uint8" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "name", outputs: [ { internalType: "string", name: "", type: "string" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address", name: "owner", type: "address" } ], name: "nonces", outputs: [ { internalType: "uint256", name: "", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address", name: "owner", type: "address" }, { internalType: "address", name: "spender", type: "address" }, { internalType: "uint256", name: "value", type: "uint256" }, { internalType: "uint256", name: "deadline", type: "uint256" }, { internalType: "uint8", name: "v", type: "uint8" }, { internalType: "bytes32", name: "r", type: "bytes32" }, { internalType: "bytes32", name: "s", type: "bytes32" } ], name: "permit", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [], name: "symbol", outputs: [ { internalType: "string", name: "", type: "string" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "totalSupply", outputs: [ { internalType: "uint256", name: "", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address", name: "to", type: "address" }, { internalType: "uint256", name: "value", type: "uint256" } ], name: "transfer", outputs: [ { internalType: "bool", name: "", type: "bool" } ], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "address", name: "from", type: "address" }, { internalType: "address", name: "to", type: "address" }, { internalType: "uint256", name: "value", type: "uint256" } ], name: "transferFrom", outputs: [ { internalType: "bool", name: "", type: "bool" } ], stateMutability: "nonpayable", type: "function" } ]; class ERC20__factory { static abi = _abi$5; static createInterface() { return new Interface(_abi$5); } static connect(address, runner) { return new Contract(address, _abi$5, runner); } } const _abi$4 = [ { inputs: [ { components: [ { internalType: "address", name: "target", type: "address" }, { internalType: "bytes", name: "callData", type: "bytes" } ], internalType: "struct Multicall3.Call[]", name: "calls", type: "tuple[]" } ], name: "aggregate", outputs: [ { internalType: "uint256", name: "blockNumber", type: "uint256" }, { internalType: "bytes[]", name: "returnData", type: "bytes[]" } ], stateMutability: "payable", type: "function" }, { inputs: [ { components: [ { internalType: "address", name: "target", type: "address" }, { internalType: "bool", name: "allowFailure", type: "bool" }, { internalType: "bytes", name: "callData", type: "bytes" } ], internalType: "struct Multicall3.Call3[]", name: "calls", type: "tuple[]" } ], name: "aggregate3", outputs: [ { components: [ { internalType: "bool", name: "success", type: "bool" }, { internalType: "bytes", name: "returnData", type: "bytes" } ], internalType: "struct Multicall3.Result[]", name: "returnData", type: "tuple[]" } ], stateMutability: "payable", type: "function" }, { inputs: [ { components: [ { internalType: "address", name: "target", type: "address" }, { internalType: "bool", name: "allowFailure", type: "bool" }, { internalType: "uint256", name: "value", type: "uint256" }, { internalType: "bytes", name: "callData", type: "bytes" } ], internalType: "struct Multicall3.Call3Value[]", name: "calls", type: "tuple[]" } ], name: "aggregate3Value", outputs: [ { components: [ { internalType: "bool", name: "success", type: "bool" }, { internalType: "bytes", name: "returnData", type: "bytes" } ], internalType: "struct Multicall3.Result[]", name: "returnData", type: "tuple[]" } ], stateMutability: "payable", type: "function" }, { inputs: [ { components: [ { internalType: "address", name: "target", type: "address" }, { internalType: "bytes", name: "callData", type: "bytes" } ], internalType: "struct Multicall3.Call[]", name: "calls", type: "tuple[]" } ], name: "blockAndAggregate", outputs: [ { internalType: "uint256", name: "blockNumber", type: "uint256" }, { internalType: "bytes32", name: "blockHash", type: "bytes32" }, { components: [ { internalType: "bool", name: "success", type: "bool" }, { internalType: "bytes", name: "returnData", type: "bytes" } ], internalType: "struct Multicall3.Result[]", name: "returnData", type: "tuple[]" } ], stateMutability: "payable", type: "function" }, { inputs: [], name: "getBasefee", outputs: [ { internalType: "uint256", name: "basefee", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "uint256", name: "blockNumber", type: "uint256" } ], name: "getBlockHash", outputs: [ { internalType: "bytes32", name: "blockHash", type: "bytes32" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "getBlockNumber", outputs: [ { internalType: "uint256", name: "blockNumber", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "getChainId", outputs: [ { internalType: "uint256", name: "chainid", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "getCurrentBlockCoinbase", outputs: [ { internalType: "address", name: "coinbase", type: "address" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "getCurrentBlockDifficulty", outputs: [ { internalType: "uint256", name: "difficulty", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "getCurrentBlockGasLimit", outputs: [ { internalType: "uint256", name: "gaslimit", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "getCurrentBlockTimestamp", outputs: [ { internalType: "uint256", name: "timestamp", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address", name: "addr", type: "address" } ], name: "getEthBalance", outputs: [ { internalType: "uint256", name: "balance", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "getLastBlockHash", outputs: [ { internalType: "bytes32", name: "blockHash", type: "bytes32" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "bool", name: "requireSuccess", type: "bool" }, { components: [ { internalType: "address", name: "target", type: "address" }, { internalType: "bytes", name: "callData", type: "bytes" } ], internalType: "struct Multicall3.Call[]", name: "calls", type: "tuple[]" } ], name: "tryAggregate", outputs: [ { components: [ { internalType: "bool", name: "success", type: "bool" }, { internalType: "bytes", name: "returnData", type: "bytes" } ], internalType: "struct Multicall3.Result[]", name: "returnData", type: "tuple[]" } ], stateMutability: "payable", type: "function" }, { inputs: [ { internalType: "bool", name: "requireSuccess", type: "bool" }, { components: [ { internalType: "address", name: "target", type: "address" }, { internalType: "bytes", name: "callData", type: "bytes" } ], internalType: "struct Multicall3.Call[]", name: "calls", type: "tuple[]" } ], name: "tryBlockAndAggregate", outputs: [ { internalType: "uint256", name: "blockNumber", type: "uint256" }, { internalType: "bytes32", name: "blockHash", type: "bytes32" }, { components: [ { internalType: "bool", name: "success", type: "bool" }, { internalType: "bytes", name: "returnData", type: "bytes" } ], internalType: "struct Multicall3.Result[]", name: "returnData", type: "tuple[]" } ], stateMutability: "payable", type: "function" } ]; class Multicall__factory { static abi = _abi$4; static createInterface() { return new Interface(_abi$4); } static connect(address, runner) { return new Contract(address, _abi$4, runner); } } const _abi$3 = [ { inputs: [ { internalType: "contract MultiWrapper", name: "_multiWrapper", type: "address" }, { internalType: "contract IOracle[]", name: "existingOracles", type: "address[]" }, { internalType: "enum OffchainOracle.OracleType[]", name: "oracleTypes", type: "uint8[]" }, { internalType: "contract IERC20[]", name: "existingConnectors", type: "address[]" }, { internalType: "contract IERC20", name: "wBase", type: "address" }, { internalType: "address", name: "owner_", type: "address" } ], stateMutability: "nonpayable", type: "constructor" }, { inputs: [], name: "ArraysLengthMismatch", type: "error" }, { inputs: [], name: "ConnectorAlreadyAdded", type: "error" }, { inputs: [], name: "InvalidOracleTokenKind", type: "error" }, { inputs: [], name: "MathOverflowedMulDiv", type: "error" }, { inputs: [], name: "OracleAlreadyAdded", type: "error" }, { inputs: [ { internalType: "address", name: "owner", type: "address" } ], name: "OwnableInvalidOwner", type: "error" }, { inputs: [ { internalType: "address", name: "account", type: "address" } ], name: "OwnableUnauthorizedAccount", type: "error" }, { inputs: [], name: "SameTokens", type: "error" }, { inputs: [], name: "TooBigThreshold", type: "error" }, { inputs: [], name: "UnknownConnector", type: "error" }, { inputs: [], name: "UnknownOracle", type: "error" }, { anonymous: false, inputs: [ { indexed: false, internalType: "contract IERC20", name: "connector", type: "address" } ], name: "ConnectorAdded", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "contract IERC20", name: "connector", type: "address" } ], name: "ConnectorRemoved", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "contract MultiWrapper", name: "multiWrapper", type: "address" } ], name: "MultiWrapperUpdated", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "contract IOracle", name: "oracle", type: "address" }, { indexed: false, internalType: "enum OffchainOracle.OracleType", name: "oracleType", type: "uint8" } ], name: "OracleAdded", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "contract IOracle", name: "oracle", type: "address" }, { indexed: false, internalType: "enum OffchainOracle.OracleType", name: "oracleType", type: "uint8" } ], name: "OracleRemoved", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "previousOwner", type: "address" }, { indexed: true, internalType: "address", name: "newOwner", type: "address" } ], name: "OwnershipTransferred", type: "event" }, { inputs: [ { internalType: "contract IERC20", name: "connector", type: "address" } ], name: "addConnector", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "contract IOracle", name: "oracle", type: "address" }, { internalType: "enum OffchainOracle.OracleType", name: "oracleKind", type: "uint8" } ], name: "addOracle", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [], name: "connectors", outputs: [ { internalType: "contract IERC20[]", name: "allConnectors", type: "address[]" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "contract IERC20", name: "srcToken", type: "address" }, { internalType: "contract IERC20", name: "dstToken", type: "address" }, { internalType: "bool", name: "useWrappers", type: "bool" } ], name: "getRate", outputs: [ { internalType: "uint256", name: "weightedRate", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "contract IERC20", name: "srcToken", type: "address" }, { internalType: "bool", name: "useSrcWrappers", type: "bool" } ], name: "getRateToEth", outputs: [ { internalType: "uint256", name: "weightedRate", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "contract IERC20", name: "srcToken", type: "address" }, { internalType: "bool", name: "useSrcWrappers", type: "bool" }, { internalType: "contract IERC20[]", name: "customConnectors", type: "address[]" }, { internalType: "uint256", name: "thresholdFilter", type: "uint256" } ], name: "getRateToEthWithCustomConnectors", outputs: [ { internalType: "uint256", name: "weightedRate", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "contract IERC20", name: "srcToken", type: "address" }, { internalType: "bool", name: "useSrcWrappers", type: "bool" }, { internalType: "uint256", name: "thresholdFilter", type: "uint256" } ], name: "getRateToEthWithThreshold", outputs: [ { internalType: "uint256", name: "weightedRate", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "contract IERC20", name: "srcToken", type: "address" }, { internalType: "contract IERC20", name: "dstToken", type: "address" }, { internalType: "bool", name: "useWrappers", type: "bool" }, { internalType: "contract IERC20[]", name: "customConnectors", type: "address[]" }, { internalType: "uint256", name: "thresholdFilter", type: "uint256" } ], name: "getRateWithCustomConnectors", outputs: [ { internalType: "uint256", name: "weightedRate", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "contract IERC20", name: "srcToken", type: "address" }, { internalType: "contract IERC20", name: "dstToken", type: "address" }, { internalType: "bool", name: "useWrappers", type: "bool" }, { internalType: "uint256", name: "thresholdFilter", type: "uint256" } ], name: "getRateWithThreshold", outputs: [ { internalType: "uint256", name: "weightedRate", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "contract IERC20", name: "srcToken", type: "address" }, { internalType: "bool", name: "useSrcWrappers", type: "bool" }, { internalType: "contract IERC20[]", name: "customConnectors", type: "address[]" }, { internalType: "uint256", name: "thresholdFilter", type: "uint256" } ], name: "getRatesAndWeightsToEthWithCustomConnectors", outputs: [ { internalType: "uint256", name: "wrappedPrice", type: "uint256" }, { components: [ { internalType: "uint256", name: "maxOracleWeight", type: "uint256" }, { internalType: "uint256", name: "size", type: "uint256" }, { components: