UNPKG

@paxoslabs/earn-sdk

Version:
1,988 lines (1,981 loc) 52.1 kB
import { toChainId } from './chunk-4URQP4CS.mjs'; import { getChainFromConfig, fetchVaults } from './chunk-NTRZGVUA.mjs'; import { createPublicClient, http, erc20Abi } from 'viem'; var clients = /* @__PURE__ */ new Map(); var getClient = async (chainId) => { if (!chainId) { throw new Error("Chain ID is required"); } if (!clients.has(chainId)) { const chain = await getChainFromConfig( toChainId(chainId), await fetchVaults() ); const client2 = createPublicClient({ chain, transport: http(chain.rpcUrls.default.http[0]) }); clients.set(chainId, client2); } const client = clients.get(chainId); if (!client) { throw new Error(`Client not found for chain ID ${chainId}`); } return client; }; // src/api/erc20.ts var getErc20Balance = async ({ chainId, tokenAddress, userAddress }) => { const client = await getClient(chainId); const balance = await client.readContract({ abi: erc20Abi, address: tokenAddress, functionName: "balanceOf", args: [userAddress] }); return balance; }; var getErc20Decimals = async ({ chainId, tokenAddress }) => { const client = await getClient(chainId); const balance = await client.readContract({ abi: erc20Abi, address: tokenAddress, functionName: "decimals" }); return balance; }; var getErc20Allowance = async ({ chainId, tokenAddress, userAddress, spenderAddress }) => { const client = await getClient(chainId); const allowance = await client.readContract({ abi: erc20Abi, address: tokenAddress, functionName: "allowance", args: [userAddress, spenderAddress] }); return allowance; }; var getErc20AllowanceWithDecimals = async ({ chainId, tokenAddress, userAddress, spenderAddress }) => { const client = await getClient(chainId); const allowance = await client.multicall({ contracts: [ { abi: erc20Abi, address: tokenAddress, functionName: "allowance", args: [userAddress, spenderAddress] }, { abi: erc20Abi, address: tokenAddress, functionName: "decimals" } ] }); return allowance; }; // src/contracts/teller-abi.ts var TellerAbi = [ { inputs: [ { internalType: "address", name: "_owner", type: "address" }, { internalType: "address", name: "_vault", type: "address" }, { internalType: "address", name: "_accountant", type: "address" }, { internalType: "address", name: "_endpoint", type: "address" } ], stateMutability: "nonpayable", type: "constructor" }, { inputs: [], name: "InvalidDelegate", type: "error" }, { inputs: [], name: "InvalidEndpointCall", type: "error" }, { inputs: [{ internalType: "uint16", name: "optionType", type: "uint16" }], name: "InvalidOptionType", type: "error" }, { inputs: [], name: "LzTokenUnavailable", type: "error" }, { inputs: [], name: "MultiChainLayerZeroTellerWithMultiAssetSupport_InvalidToken", type: "error" }, { inputs: [], name: "MultiChainTellerBase_DestinationChainReceiverIsZeroAddress", type: "error" }, { inputs: [], name: "MultiChainTellerBase_GasLimitExceeded", type: "error" }, { inputs: [], name: "MultiChainTellerBase_GasTooLow", type: "error" }, { inputs: [{ internalType: "uint32", name: "chainSelector", type: "uint32" }], name: "MultiChainTellerBase_MessagesNotAllowedFrom", type: "error" }, { inputs: [ { internalType: "uint256", name: "chainSelector", type: "uint256" } ], name: "MultiChainTellerBase_MessagesNotAllowedTo", type: "error" }, { inputs: [], name: "MultiChainTellerBase_TargetTellerIsZeroAddress", type: "error" }, { inputs: [], name: "MultiChainTellerBase_ZeroMessageGasLimit", type: "error" }, { inputs: [{ internalType: "uint32", name: "eid", type: "uint32" }], name: "NoPeer", type: "error" }, { inputs: [{ internalType: "uint256", name: "msgValue", type: "uint256" }], name: "NotEnoughNative", type: "error" }, { inputs: [{ internalType: "address", name: "addr", type: "address" }], name: "OnlyEndpoint", type: "error" }, { inputs: [ { internalType: "uint32", name: "eid", type: "uint32" }, { internalType: "bytes32", name: "sender", type: "bytes32" } ], name: "OnlyPeer", type: "error" }, { inputs: [ { internalType: "uint8", name: "bits", type: "uint8" }, { internalType: "uint256", name: "value", type: "uint256" } ], name: "SafeCastOverflowedUintDowncast", type: "error" }, { inputs: [{ internalType: "address", name: "token", type: "address" }], name: "SafeERC20FailedOperation", type: "error" }, { inputs: [], name: "TellerWithMultiAssetSupport__AssetNotSupported", type: "error" }, { inputs: [], name: "TellerWithMultiAssetSupport__BadDepositHash", type: "error" }, { inputs: [], name: "TellerWithMultiAssetSupport__MinimumAssetsNotMet", type: "error" }, { inputs: [], name: "TellerWithMultiAssetSupport__MinimumMintNotMet", type: "error" }, { inputs: [], name: "TellerWithMultiAssetSupport__Paused", type: "error" }, { inputs: [], name: "TellerWithMultiAssetSupport__PermitFailedAndAllowanceTooLow", type: "error" }, { inputs: [], name: "TellerWithMultiAssetSupport__ShareLockPeriodTooLong", type: "error" }, { inputs: [], name: "TellerWithMultiAssetSupport__SharesAreLocked", type: "error" }, { inputs: [], name: "TellerWithMultiAssetSupport__SharesAreUnLocked", type: "error" }, { inputs: [], name: "TellerWithMultiAssetSupport__ZeroAssets", type: "error" }, { inputs: [], name: "TellerWithMultiAssetSupport__ZeroShares", type: "error" }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "asset", type: "address" } ], name: "AssetAdded", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "asset", type: "address" } ], name: "AssetRemoved", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "user", type: "address" }, { indexed: true, internalType: "contract Authority", name: "newAuthority", type: "address" } ], name: "AuthorityUpdated", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "asset", type: "address" }, { indexed: false, internalType: "uint256", name: "depositAmount", type: "uint256" } ], name: "BulkDeposit", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "asset", type: "address" }, { indexed: false, internalType: "uint256", name: "shareAmount", type: "uint256" } ], name: "BulkWithdraw", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "uint256", name: "chainSelector", type: "uint256" }, { indexed: false, internalType: "bool", name: "allowMessagesFrom", type: "bool" }, { indexed: false, internalType: "bool", name: "allowMessagesTo", type: "bool" }, { indexed: false, internalType: "address", name: "targetTeller", type: "address" }, { indexed: false, internalType: "uint64", name: "messageGasLimit", type: "uint64" }, { indexed: false, internalType: "uint64", name: "messageGasMin", type: "uint64" } ], name: "ChainAdded", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "uint256", name: "chainSelector", type: "uint256" }, { indexed: false, internalType: "address", name: "targetTeller", type: "address" } ], name: "ChainAllowMessagesFrom", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "uint256", name: "chainSelector", type: "uint256" }, { indexed: false, internalType: "address", name: "targetTeller", type: "address" } ], name: "ChainAllowMessagesTo", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "uint256", name: "chainSelector", type: "uint256" } ], name: "ChainRemoved", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "uint256", name: "chainSelector", type: "uint256" }, { indexed: false, internalType: "uint64", name: "messageGasLimit", type: "uint64" } ], name: "ChainSetGasLimit", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "uint256", name: "chainSelector", type: "uint256" } ], name: "ChainStopMessagesFrom", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "uint256", name: "chainSelector", type: "uint256" } ], name: "ChainStopMessagesTo", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "uint256", name: "nonce", type: "uint256" }, { indexed: true, internalType: "address", name: "receiver", type: "address" }, { indexed: true, internalType: "address", name: "depositAsset", type: "address" }, { indexed: false, internalType: "uint256", name: "depositAmount", type: "uint256" }, { indexed: false, internalType: "uint256", name: "shareAmount", type: "uint256" }, { indexed: false, internalType: "uint256", name: "depositTimestamp", type: "uint256" }, { indexed: false, internalType: "uint256", name: "shareLockPeriodAtTimeOfDeposit", type: "uint256" } ], name: "Deposit", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "uint256", name: "nonce", type: "uint256" }, { indexed: false, internalType: "bytes32", name: "depositHash", type: "bytes32" }, { indexed: true, internalType: "address", name: "user", type: "address" } ], name: "DepositRefunded", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "bytes32", name: "messageId", type: "bytes32" }, { indexed: false, internalType: "uint256", name: "shareAmount", type: "uint256" }, { indexed: false, internalType: "address", name: "to", type: "address" } ], name: "MessageReceived", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "bytes32", name: "messageId", type: "bytes32" }, { indexed: false, internalType: "uint256", name: "shareAmount", type: "uint256" }, { indexed: false, internalType: "address", name: "to", type: "address" } ], name: "MessageSent", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "user", type: "address" }, { indexed: true, internalType: "address", name: "newOwner", type: "address" } ], name: "OwnershipTransferred", type: "event" }, { anonymous: false, inputs: [], name: "Paused", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "uint32", name: "eid", type: "uint32" }, { indexed: false, internalType: "bytes32", name: "peer", type: "bytes32" } ], name: "PeerSet", type: "event" }, { anonymous: false, inputs: [], name: "Unpaused", type: "event" }, { inputs: [], name: "accountant", outputs: [ { internalType: "contract AccountantWithRateProviders", name: "", type: "address" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "contract ERC20", name: "asset", type: "address" } ], name: "addAsset", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "uint32", name: "chainSelector", type: "uint32" }, { internalType: "bool", name: "allowMessagesFrom", type: "bool" }, { internalType: "bool", name: "allowMessagesTo", type: "bool" }, { internalType: "address", name: "targetTeller", type: "address" }, { internalType: "uint64", name: "messageGasLimit", type: "uint64" }, { internalType: "uint64", name: "messageGasMin", type: "uint64" } ], name: "addChain", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { components: [ { internalType: "uint32", name: "srcEid", type: "uint32" }, { internalType: "bytes32", name: "sender", type: "bytes32" }, { internalType: "uint64", name: "nonce", type: "uint64" } ], internalType: "struct Origin", name: "origin", type: "tuple" } ], name: "allowInitializePath", outputs: [{ internalType: "bool", name: "", type: "bool" }], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "uint32", name: "chainSelector", type: "uint32" }, { internalType: "address", name: "targetTeller", type: "address" } ], name: "allowMessagesFromChain", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "uint32", name: "chainSelector", type: "uint32" }, { internalType: "address", name: "targetTeller", type: "address" }, { internalType: "uint64", name: "messageGasLimit", type: "uint64" } ], name: "allowMessagesToChain", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [], name: "authority", outputs: [ { internalType: "contract Authority", name: "", type: "address" } ], stateMutability: "view", type: "function" }, { inputs: [{ internalType: "address", name: "from", type: "address" }], name: "beforeTransfer", outputs: [], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "uint256", name: "shareAmount", type: "uint256" }, { components: [ { internalType: "uint32", name: "chainSelector", type: "uint32" }, { internalType: "address", name: "destinationChainReceiver", type: "address" }, { internalType: "contract ERC20", name: "bridgeFeeToken", type: "address" }, { internalType: "uint64", name: "messageGas", type: "uint64" }, { internalType: "bytes", name: "data", type: "bytes" } ], internalType: "struct BridgeData", name: "data", type: "tuple" } ], name: "bridge", outputs: [{ internalType: "bytes32", name: "messageId", type: "bytes32" }], stateMutability: "payable", type: "function" }, { inputs: [ { internalType: "contract ERC20", name: "depositAsset", type: "address" }, { internalType: "uint256", name: "depositAmount", type: "uint256" }, { internalType: "uint256", name: "minimumMint", type: "uint256" }, { internalType: "address", name: "to", type: "address" } ], name: "bulkDeposit", outputs: [{ internalType: "uint256", name: "shares", type: "uint256" }], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "contract ERC20", name: "withdrawAsset", type: "address" }, { internalType: "uint256", name: "shareAmount", type: "uint256" }, { internalType: "uint256", name: "minimumAssets", type: "uint256" }, { internalType: "address", name: "to", type: "address" } ], name: "bulkWithdraw", outputs: [{ internalType: "uint256", name: "assetsOut", type: "uint256" }], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "contract ERC20", name: "depositAsset", type: "address" }, { internalType: "uint256", name: "depositAmount", type: "uint256" }, { internalType: "uint256", name: "minimumMint", type: "uint256" } ], name: "deposit", outputs: [{ internalType: "uint256", name: "shares", type: "uint256" }], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "contract ERC20", name: "depositAsset", type: "address" }, { internalType: "uint256", name: "depositAmount", type: "uint256" }, { internalType: "uint256", name: "minimumMint", type: "uint256" }, { components: [ { internalType: "uint32", name: "chainSelector", type: "uint32" }, { internalType: "address", name: "destinationChainReceiver", type: "address" }, { internalType: "contract ERC20", name: "bridgeFeeToken", type: "address" }, { internalType: "uint64", name: "messageGas", type: "uint64" }, { internalType: "bytes", name: "data", type: "bytes" } ], internalType: "struct BridgeData", name: "data", type: "tuple" } ], name: "depositAndBridge", outputs: [], stateMutability: "payable", type: "function" }, { inputs: [], name: "depositNonce", outputs: [{ internalType: "uint96", name: "", type: "uint96" }], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "contract ERC20", name: "depositAsset", type: "address" }, { internalType: "uint256", name: "depositAmount", type: "uint256" }, { internalType: "uint256", name: "minimumMint", 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: "depositWithPermit", outputs: [{ internalType: "uint256", name: "shares", type: "uint256" }], stateMutability: "nonpayable", type: "function" }, { inputs: [], name: "endpoint", outputs: [ { internalType: "contract ILayerZeroEndpointV2", name: "", type: "address" } ], stateMutability: "view", type: "function" }, { inputs: [ { components: [ { internalType: "uint32", name: "srcEid", type: "uint32" }, { internalType: "bytes32", name: "sender", type: "bytes32" }, { internalType: "uint64", name: "nonce", type: "uint64" } ], internalType: "struct Origin", name: "", type: "tuple" }, { internalType: "bytes", name: "", type: "bytes" }, { internalType: "address", name: "_sender", type: "address" } ], name: "isComposeMsgSender", outputs: [{ internalType: "bool", name: "", type: "bool" }], stateMutability: "view", type: "function" }, { inputs: [], name: "isPaused", outputs: [{ internalType: "bool", name: "", type: "bool" }], stateMutability: "view", type: "function" }, { inputs: [{ internalType: "contract ERC20", name: "", type: "address" }], name: "isSupported", outputs: [{ internalType: "bool", name: "", type: "bool" }], stateMutability: "view", type: "function" }, { inputs: [ { components: [ { internalType: "uint32", name: "srcEid", type: "uint32" }, { internalType: "bytes32", name: "sender", type: "bytes32" }, { internalType: "uint64", name: "nonce", type: "uint64" } ], internalType: "struct Origin", name: "_origin", type: "tuple" }, { internalType: "bytes32", name: "_guid", type: "bytes32" }, { internalType: "bytes", name: "_message", type: "bytes" }, { internalType: "address", name: "_executor", type: "address" }, { internalType: "bytes", name: "_extraData", type: "bytes" } ], name: "lzReceive", outputs: [], stateMutability: "payable", type: "function" }, { inputs: [ { internalType: "uint32", name: "", type: "uint32" }, { internalType: "bytes32", name: "", type: "bytes32" } ], name: "nextNonce", outputs: [{ internalType: "uint64", name: "nonce", type: "uint64" }], stateMutability: "view", type: "function" }, { inputs: [], name: "oAppVersion", outputs: [ { internalType: "uint64", name: "senderVersion", type: "uint64" }, { internalType: "uint64", name: "receiverVersion", type: "uint64" } ], stateMutability: "pure", type: "function" }, { inputs: [], name: "owner", outputs: [{ internalType: "address", name: "", type: "address" }], stateMutability: "view", type: "function" }, { inputs: [], name: "pause", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [{ internalType: "uint32", name: "eid", type: "uint32" }], name: "peers", outputs: [{ internalType: "bytes32", name: "peer", type: "bytes32" }], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "uint256", name: "shareAmount", type: "uint256" }, { components: [ { internalType: "uint32", name: "chainSelector", type: "uint32" }, { internalType: "address", name: "destinationChainReceiver", type: "address" }, { internalType: "contract ERC20", name: "bridgeFeeToken", type: "address" }, { internalType: "uint64", name: "messageGas", type: "uint64" }, { internalType: "bytes", name: "data", type: "bytes" } ], internalType: "struct BridgeData", name: "data", type: "tuple" } ], name: "previewFee", outputs: [{ internalType: "uint256", name: "fee", type: "uint256" }], stateMutability: "view", type: "function" }, { inputs: [{ internalType: "uint256", name: "", type: "uint256" }], name: "publicDepositHistory", outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "uint256", name: "nonce", type: "uint256" }, { internalType: "address", name: "receiver", type: "address" }, { internalType: "address", name: "depositAsset", type: "address" }, { internalType: "uint256", name: "depositAmount", type: "uint256" }, { internalType: "uint256", name: "shareAmount", type: "uint256" }, { internalType: "uint256", name: "depositTimestamp", type: "uint256" }, { internalType: "uint256", name: "shareLockUpPeriodAtTimeOfDeposit", type: "uint256" } ], name: "refundDeposit", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "contract ERC20", name: "asset", type: "address" } ], name: "removeAsset", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [{ internalType: "uint32", name: "chainSelector", type: "uint32" }], name: "removeChain", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [{ internalType: "uint32", name: "", type: "uint32" }], name: "selectorToChains", outputs: [ { internalType: "bool", name: "allowMessagesFrom", type: "bool" }, { internalType: "bool", name: "allowMessagesTo", type: "bool" }, { internalType: "address", name: "targetTeller", type: "address" }, { internalType: "uint64", name: "messageGasLimit", type: "uint64" }, { internalType: "uint64", name: "minimumMessageGas", type: "uint64" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "contract Authority", name: "newAuthority", type: "address" } ], name: "setAuthority", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "uint32", name: "chainSelector", type: "uint32" }, { internalType: "uint64", name: "messageGasLimit", type: "uint64" } ], name: "setChainGasLimit", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [{ internalType: "address", name: "_delegate", type: "address" }], name: "setDelegate", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "uint32", name: "_eid", type: "uint32" }, { internalType: "bytes32", name: "_peer", type: "bytes32" } ], name: "setPeer", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "uint64", name: "_shareLockPeriod", type: "uint64" } ], name: "setShareLockPeriod", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [], name: "shareLockPeriod", outputs: [{ internalType: "uint64", name: "", type: "uint64" }], stateMutability: "view", type: "function" }, { inputs: [{ internalType: "address", name: "", type: "address" }], name: "shareUnlockTime", outputs: [{ internalType: "uint256", name: "", type: "uint256" }], stateMutability: "view", type: "function" }, { inputs: [{ internalType: "uint32", name: "chainSelector", type: "uint32" }], name: "stopMessagesFromChain", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [{ internalType: "uint32", name: "chainSelector", type: "uint32" }], name: "stopMessagesToChain", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [{ internalType: "address", name: "newOwner", type: "address" }], name: "transferOwnership", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [], name: "unpause", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [], name: "vault", outputs: [ { internalType: "contract BoringVault", name: "", type: "address" } ], stateMutability: "view", type: "function" } ]; // src/api/teller.ts var getPreviewFee = async ({ shareAmount, bridgeData, contractAddress, chainId }) => { const client = await getClient(chainId); const rate = await client.readContract({ abi: TellerAbi, address: contractAddress, functionName: "previewFee", args: [shareAmount, bridgeData] }); return rate; }; // src/contracts/accountant-abi.ts var AccountantAbi = [ { type: "constructor", inputs: [ { name: "_owner", type: "address", internalType: "address" }, { name: "_vault", type: "address", internalType: "address" }, { name: "payoutAddress", type: "address", internalType: "address" }, { name: "startingExchangeRate", type: "uint96", internalType: "uint96" }, { name: "_base", type: "address", internalType: "address" }, { name: "allowedExchangeRateChangeUpper", type: "uint16", internalType: "uint16" }, { name: "allowedExchangeRateChangeLower", type: "uint16", internalType: "uint16" }, { name: "minimumUpdateDelayInSeconds", type: "uint32", internalType: "uint32" }, { name: "managementFee", type: "uint16", internalType: "uint16" } ], stateMutability: "nonpayable" }, { type: "function", name: "accountantState", inputs: [], outputs: [ { name: "payoutAddress", type: "address", internalType: "address" }, { name: "feesOwedInBase", type: "uint128", internalType: "uint128" }, { name: "totalSharesLastUpdate", type: "uint128", internalType: "uint128" }, { name: "exchangeRate", type: "uint96", internalType: "uint96" }, { name: "allowedExchangeRateChangeUpper", type: "uint16", internalType: "uint16" }, { name: "allowedExchangeRateChangeLower", type: "uint16", internalType: "uint16" }, { name: "lastUpdateTimestamp", type: "uint64", internalType: "uint64" }, { name: "isPaused", type: "bool", internalType: "bool" }, { name: "minimumUpdateDelayInSeconds", type: "uint32", internalType: "uint32" }, { name: "managementFee", type: "uint16", internalType: "uint16" } ], stateMutability: "view" }, { type: "function", name: "authority", inputs: [], outputs: [ { name: "", type: "address", internalType: "contract Authority" } ], stateMutability: "view" }, { type: "function", name: "base", inputs: [], outputs: [{ name: "", type: "address", internalType: "contract ERC20" }], stateMutability: "view" }, { type: "function", name: "claimFees", inputs: [ { name: "feeAsset", type: "address", internalType: "contract ERC20" } ], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "decimals", inputs: [], outputs: [{ name: "", type: "uint8", internalType: "uint8" }], stateMutability: "view" }, { type: "function", name: "getRate", inputs: [], outputs: [{ name: "rate", type: "uint256", internalType: "uint256" }], stateMutability: "view" }, { type: "function", name: "getRateInQuote", inputs: [ { name: "quote", type: "address", internalType: "contract ERC20" } ], outputs: [ { name: "rateInQuote", type: "uint256", internalType: "uint256" } ], stateMutability: "view" }, { type: "function", name: "getRateInQuoteSafe", inputs: [ { name: "quote", type: "address", internalType: "contract ERC20" } ], outputs: [ { name: "rateInQuote", type: "uint256", internalType: "uint256" } ], stateMutability: "view" }, { type: "function", name: "getRateSafe", inputs: [], outputs: [{ name: "rate", type: "uint256", internalType: "uint256" }], stateMutability: "view" }, { type: "function", name: "owner", inputs: [], outputs: [{ name: "", type: "address", internalType: "address" }], stateMutability: "view" }, { type: "function", name: "pause", inputs: [], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "rateProviderData", inputs: [{ name: "", type: "address", internalType: "contract ERC20" }], outputs: [ { name: "isPeggedToBase", type: "bool", internalType: "bool" }, { name: "rateProvider", type: "address", internalType: "contract IRateProvider" } ], stateMutability: "view" }, { type: "function", name: "setAuthority", inputs: [ { name: "newAuthority", type: "address", internalType: "contract Authority" } ], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "setRateProviderData", inputs: [ { name: "asset", type: "address", internalType: "contract ERC20" }, { name: "isPeggedToBase", type: "bool", internalType: "bool" }, { name: "rateProvider", type: "address", internalType: "address" } ], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "transferOwnership", inputs: [{ name: "newOwner", type: "address", internalType: "address" }], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "unpause", inputs: [], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "updateDelay", inputs: [ { name: "minimumUpdateDelayInSeconds", type: "uint32", internalType: "uint32" } ], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "updateExchangeRate", inputs: [ { name: "newExchangeRate", type: "uint96", internalType: "uint96" } ], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "updateLower", inputs: [ { name: "allowedExchangeRateChangeLower", type: "uint16", internalType: "uint16" } ], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "updateManagementFee", inputs: [{ name: "managementFee", type: "uint16", internalType: "uint16" }], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "updatePayoutAddress", inputs: [ { name: "payoutAddress", type: "address", internalType: "address" } ], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "updateUpper", inputs: [ { name: "allowedExchangeRateChangeUpper", type: "uint16", internalType: "uint16" } ], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "vault", inputs: [], outputs: [ { name: "", type: "address", internalType: "contract BoringVault" } ], stateMutability: "view" }, { type: "event", name: "AuthorityUpdated", inputs: [ { name: "user", type: "address", indexed: true, internalType: "address" }, { name: "newAuthority", type: "address", indexed: true, internalType: "contract Authority" } ], anonymous: false }, { type: "event", name: "DelayInSecondsUpdated", inputs: [ { name: "oldDelay", type: "uint32", indexed: false, internalType: "uint32" }, { name: "newDelay", type: "uint32", indexed: false, internalType: "uint32" } ], anonymous: false }, { type: "event", name: "ExchangeRateUpdated", inputs: [ { name: "oldRate", type: "uint96", indexed: false, internalType: "uint96" }, { name: "newRate", type: "uint96", indexed: false, internalType: "uint96" }, { name: "currentTime", type: "uint64", indexed: false, internalType: "uint64" } ], anonymous: false }, { type: "event", name: "FeesClaimed", inputs: [ { name: "feeAsset", type: "address", indexed: true, internalType: "address" }, { name: "amount", type: "uint256", indexed: false, internalType: "uint256" } ], anonymous: false }, { type: "event", name: "LowerBoundUpdated", inputs: [ { name: "oldBound", type: "uint16", indexed: false, internalType: "uint16" }, { name: "newBound", type: "uint16", indexed: false, internalType: "uint16" } ], anonymous: false }, { type: "event", name: "ManagementFeeUpdated", inputs: [ { name: "oldFee", type: "uint16", indexed: false, internalType: "uint16" }, { name: "newFee", type: "uint16", indexed: false, internalType: "uint16" } ], anonymous: false }, { type: "event", name: "OwnershipTransferred", inputs: [ { name: "user", type: "address", indexed: true, internalType: "address" }, { name: "newOwner", type: "address", indexed: true, internalType: "address" } ], anonymous: false }, { type: "event", name: "Paused", inputs: [], anonymous: false }, { type: "event", name: "PayoutAddressUpdated", inputs: [ { name: "oldPayout", type: "address", indexed: false, internalType: "address" }, { name: "newPayout", type: "address", indexed: false, internalType: "address" } ], anonymous: false }, { type: "event", name: "RateProviderUpdated", inputs: [ { name: "asset", type: "address", indexed: false, internalType: "address" }, { name: "isPegged", type: "bool", indexed: false, internalType: "bool" }, { name: "rateProvider", type: "address", indexed: false, internalType: "address" } ], anonymous: false }, { type: "event", name: "Unpaused", inputs: [], anonymous: false }, { type: "event", name: "UpperBoundUpdated", inputs: [ { name: "oldBound", type: "uint16", indexed: false, internalType: "uint16" }, { name: "newBound", type: "uint16", indexed: false, internalType: "uint16" } ], anonymous: false }, { type: "error", name: "AccountantWithRateProviders__LowerBoundTooLarge", inputs: [] }, { type: "error", name: "AccountantWithRateProviders__ManagementFeeTooLarge", inputs: [] }, { type: "error", name: "AccountantWithRateProviders__OnlyCallableByBoringVault", inputs: [] }, { type: "error", name: "AccountantWithRateProviders__Paused", inputs: [] }, { type: "error", name: "AccountantWithRateProviders__UpdateDelayTooLarge", inputs: [] }, { type: "error", name: "AccountantWithRateProviders__UpperBoundTooSmall", inputs: [] }, { type: "error", name: "AccountantWithRateProviders__ZeroFeesOwed", inputs: [] } ]; // src/contracts/boring-vault-abi.ts var BoringVaultAbi = [ { type: "constructor", inputs: [ { name: "_owner", type: "address", internalType: "address" }, { name: "_name", type: "string", internalType: "string" }, { name: "_symbol", type: "string", internalType: "string" }, { name: "_decimals", type: "uint8", internalType: "uint8" } ], stateMutability: "nonpayable" }, { type: "receive", stateMutability: "payable" }, { type: "function", name: "DOMAIN_SEPARATOR", inputs: [], outputs: [{ name: "", type: "bytes32", internalType: "bytes32" }], stateMutability: "view" }, { type: "function", name: "allowance", inputs: [ { name: "", type: "address", internalType: "address" }, { name: "", type: "address", internalType: "address" } ], outputs: [{ name: "", type: "uint256", internalType: "uint256" }], stateMutability: "view" }, { type: "function", name: "approve", inputs: [ { name: "spender", type: "address", internalType: "address" }, { name: "amount", type: "uint256", internalType: "uint256" } ], outputs: [{ name: "", type: "bool", internalType: "bool" }], stateMutability: "nonpayable" }, { type: "function", name: "authority", inputs: [], outputs: [ { name: "", type: "address", internalType: "contract Authority" } ], stateMutability: "view" }, { type: "function", name: "balanceOf", inputs: [{ name: "", type: "address", internalType: "address" }], outputs: [{ name: "", type: "uint256", internalType: "uint256" }], stateMutability: "view" }, { type: "function", name: "decimals", inputs: [], outputs: [{ name: "", type: "uint8", internalType: "uint8" }], stateMutability: "view" }, { type: "function", name: "enter", inputs: [ { name: "from", type: "address", internalType: "address" }, { name: "asset", type: "address", internalType: "contract ERC20" }, { name: "assetAmount", type: "uint256", internalType: "uint256" }, { name: "to", type: "address", internalType: "address" }, { name: "shareAmount", type: "uint256", internalType: "uint256" } ], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "exit", inputs: [ { name: "to", type: "address", internalType: "address" }, { name: "asset", type: "address", internalType: "contract ERC20" }, { name: "assetAmount", type: "uint256", internalType: "uint256" }, { name: "from", type: "address", internalType: "address" }, { name: "shareAmount", type: "uint256", internalType: "uint256" } ], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "hook", inputs: [], outputs: [ { name: "", type: "address", internalType: "contract BeforeTransferHook" } ], stateMutability: "view" }, { type: "function", name: "manage", inputs: [ { name: "targets", type: "address[]", internalType: "address[]" }, { name: "data", type: "bytes[]", internalType: "bytes[]" }, { name: "values", type: "uint256[]", internalType: "uint256[]" } ], outputs: [{ name: "results", type: "bytes[]", internalType: "bytes[]" }], stateMutability: "nonpayable" }, { type: "function", name: "manage", inputs: [ { name: "target", type: "address", internalType: "address" }, { name: "data", type: "bytes", internalType: "bytes" }, { name: "value", type: "uint256", internalType: "uint256" } ], outputs: [{ name: "result", type: "bytes", internalType: "bytes" }], stateMutability: "nonpayable" }, { type: "function", name: "name", inputs: [], outputs: [{ name: "", type: "string", internalType: "string" }], stateMutability: "view" }, { type: "function", name: "nonces", inputs: [{ name: "", type: "address", internalType: "address" }], outputs: [{ name: "", type: "uint256", internalType: "uint256" }], stateMutability: "view" }, { type: "function", name: "onERC1155BatchReceived", inputs: [ { name: "", type: "address", internalType: "address" }, { name: "", type: "address", internalType: "address" }, { name: "", type: "uint256[]", internalType: "uint256[]" }, { name: "", type: "uint256[]", internalType: "uint256[]" }, { name: "", type: "bytes", internalType: "bytes" } ], outputs: [{ name: "", type: "bytes4", internalType: "bytes4" }], stateMutability: "nonpayable" }, { type: "function", name: "onERC1155Received", inputs: [ { name: "", type: "address", internalType: "address" }, { name: "", type: "address", internalType: "address" }, { name: "", type: "uint256", internalType: "uint256" }, { name: "", type: "uint256", internalType: "uint256" }, { name: "", type: "bytes", internalType: "bytes" } ], outputs: [{ name: "", type: "bytes4", internalType: "bytes4" }], stateMutability: "nonpayable" }, { type: "function", name: "onERC721Received", inputs: [ { name: "", type: "address", internalType: "address" }, { name: "", type: "address", internalType: "address" }, { name: "", type: "uint256", internalType: "uint256" }, { name: "", type: "bytes", internalType: "bytes" } ], outputs: [{ name: "", type: "bytes4", internalType: "bytes4" }], stateMutability: "nonpayable" }, { type: "function", name: "owner", inputs: [], outputs: [{ name: "", type: "address", internalType: "address" }], stateMutability: "view" }, { type: "function", name: "permit", inputs: [ { name: "owner", type: "address", internalType: "address" }, { name: "spender", type: "address", internalType: "address" }, { name: "value", type: "uint256", internalType: "uint256" }, { name: "deadline", type: "uint256", internalType: "uint256" }, { name: "v", type: "uint8", internalType: "uint8" }, { name: "r", type: "bytes32", internalType: "bytes32" }, { name: "s", type: "bytes32", internalType: "bytes32" } ], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "setAuthority", inputs: [ { name: "newAuthority", type: "address", internalType: "contract Authority" } ], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "setBeforeTransferHook", inputs: [{ name: "_hook", type: "address", internalType: "address" }], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "supportsInterface", inputs: [{ name: "interfaceId", type: "bytes4", internalType: "bytes4" }], outputs: [{ name: "", type: "bool", internalType: "bool" }], stateMutability: "view" }, { type: "function", name: "symbol", inputs: [], outputs: [{ name: "", type: "string", internalType: "string" }], stateMutability: "view" }, { type: "function", name: "totalSupply", inputs: [], outputs: [{ name: "", type: "uint256", internalType: "uint256" }], stateMutability: "view" }, { type: "function", name: "transfer", inputs: [ { name: "to", type: "address", internalType: "address" }, { name: "amount", type: "uint256", internalType: "uint256" } ], outputs: [{ name: "", type: "bool", internalType: "bool" }], stateMutability: "nonpayable" }, { type: "function", name: "transferFrom", inputs: [ { name: "from", type: "address", internalType: "address" }, { name: "to", type: "address", internalType: "address" }, { name: "amount", type: "uint256", internalType: "uint256" } ], outputs: [{ name: "", type: "bool", internalType: "bool" }], stateMutability: "nonpayable" }, { type: "function", name: "transferOwnership", inputs: [{ name: "newOwner", type: "address", internalType: "address" }], outputs: [], stateMutability: "nonpayable" }, { type: "event", name: "Approval", inputs: [ { name: "owner", type: "address", indexed: true, internalType: "address" }, { name: "spender", type: "address", indexed: true, internalType: "address" }, { name: "amount", type: "uint256", indexed: false, internalType: "uint256" } ], anonymous: false }, { type: "event", name: "AuthorityUpdated", inputs: [ { name: "user", type: "address", indexed: true, internalType: "address" }, { name: "newAuthority", type: "address", indexed: true, internalType: "contract Authority" } ], anonymous: false }, { type: "event", name: "Enter", inputs: [ { name: "from", type: "address", indexed: true, internalType: "address" }, { name: "asset", type: "address", indexed: true, internalType: "address" }, { name: "amount", type: "uint256", indexed: false, internalType: "uint256" }, { name: "to", type: "address", indexed: true, internalType: "address" }, { name: "shares", type: "uint256", indexed: false, internalType: "uint256" } ], anonymous: false }, { type: "event", name: "Exit", inputs: [ { name: "to", type: "address", indexed: true, internalType: "address" }, { name: "asset", type: "address", indexed: true, internalType: "address" }, { name: "amount", type: "uint256", indexed: false, internalType: "uint256" }, { name: "from", type: "address", indexed: true, internalType: "address" }, { name: "shares", type: "uint256", indexed: false, internalType: "uint256" } ], anonymous: false }, { type: "event", name: "OwnershipTransferred", inputs: [ { name: "user", type: "address", indexed: true, internalType: "address" }, { name: "newOwner", type: "address", indexed: true, internalType: "address" } ], anonymous: false }, { type: "event", name: "Transfer", inputs: [ { name: "from", type: "address", indexed: true, internalType: "address" },