diff --git a/package.json b/package.json index 4bc08b276..70a6f9031 100644 --- a/package.json +++ b/package.json @@ -27,21 +27,34 @@ "@hop-protocol/sdk": "^0.0.1-beta.535", "@liquity/lib-base": "^3.0.0", "@liquity/lib-ethers": "^3.4.0", + "@near-wallet-selector/core": "^8.5.1", + "@near-wallet-selector/modal-ui": "^8.5.1", + "@near-wallet-selector/near-wallet": "^8.5.1", + "@near-wallet-selector/neth": "^8.5.1", + "@near-wallet-selector/nightly": "^8.5.1", + "@near-wallet-selector/sender": "^8.5.1", "@next/font": "13.1.2", - "@rainbow-me/rainbowkit": "^0.12.0", + "@rainbow-me/rainbowkit": "^1.0.11", "@types/node": "18.11.18", "@types/react": "18.0.27", "@types/react-dom": "18.0.10", "@uniswap/sdk-core": "<=4.0.3 || >4.0.6", "@uniswap/smart-order-router": "^3.11.0", "@uniswap/v3-periphery": "^1.4.3", + "@web3-onboard/injected-wallets": "^2.10.5", + "@web3-onboard/ledger": "^2.5.2", + "@web3-onboard/react": "^2.8.11", + "@web3-onboard/walletconnect": "^2.4.6", "copy-to-clipboard": "^3.3.3", "date-fns": "^2.30.0", "eslint": "8.32.0", "eslint-config-next": "13.1.2", - "ethers": "^5.7.2", + "ethers": "5", "graphql-request": "^6.1.0", "json-bigint": "^1.0.0", + "local-storage": "^2.0.0", + "near-api-js": "^2.1.4", + "near-social-vm": "^2.3.1", "next": "13.1.2", "next-auth": "^4.22.1", "react": "18.2.0", @@ -53,14 +66,15 @@ "react-loading-skeleton": "^3.2.0", "react-markdown": "^8.0.7", "react-query": "^3.39.3", + "react-singleton-hook": "^4.0.1", "react-textarea-autosize": "^8.4.1", "react-toastify": "^9.1.2", "react-use-websocket": "^4.3.1", "siwe": "^2.1.4", "swr": "^2.0.4", "typescript": "^5.2.2", - "viem": "^1.9.3", - "wagmi": "^0.12.0", + "viem": "^1.10.13", + "wagmi": "^1.4.1", "zksync-web3": "^0.14.3" }, "devDependencies": { diff --git a/src/abi/SeaportAbi.json b/src/abi/SeaportAbi.ts similarity index 99% rename from src/abi/SeaportAbi.json rename to src/abi/SeaportAbi.ts index 0eaf60b4e..9f22077f6 100644 --- a/src/abi/SeaportAbi.json +++ b/src/abi/SeaportAbi.ts @@ -1,4 +1,4 @@ -[ +export default[ { "inputs": [ { @@ -2255,4 +2255,4 @@ "name": "OrdersMatched", "type": "event" } -] +] as const diff --git a/src/abi/erc4626ABI.json b/src/abi/erc4626ABI.json deleted file mode 100644 index 94a9a46e0..000000000 --- a/src/abi/erc4626ABI.json +++ /dev/null @@ -1,877 +0,0 @@ -[ - { - "inputs": [ - { - "internalType": "address", - "name": "_daiJoin", - "type": "address" - }, - { - "internalType": "address", - "name": "_pot", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "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": "sender", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "assets", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "shares", - "type": "uint256" - } - ], - "name": "Deposit", - "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" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "receiver", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "assets", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "shares", - "type": "uint256" - } - ], - "name": "Withdraw", - "type": "event" - }, - { - "inputs": [], - "name": "DOMAIN_SEPARATOR", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "PERMIT_TYPEHASH", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "address", - "name": "", - "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": [], - "name": "asset", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "shares", - "type": "uint256" - } - ], - "name": "convertToAssets", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "assets", - "type": "uint256" - } - ], - "name": "convertToShares", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "dai", - "outputs": [ - { - "internalType": "contract DaiLike", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "daiJoin", - "outputs": [ - { - "internalType": "contract DaiJoinLike", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "decimals", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "subtractedValue", - "type": "uint256" - } - ], - "name": "decreaseAllowance", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "deploymentChainId", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "assets", - "type": "uint256" - }, - { - "internalType": "address", - "name": "receiver", - "type": "address" - } - ], - "name": "deposit", - "outputs": [ - { - "internalType": "uint256", - "name": "shares", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "addedValue", - "type": "uint256" - } - ], - "name": "increaseAllowance", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "maxDeposit", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "maxMint", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - } - ], - "name": "maxRedeem", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - } - ], - "name": "maxWithdraw", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "shares", - "type": "uint256" - }, - { - "internalType": "address", - "name": "receiver", - "type": "address" - } - ], - "name": "mint", - "outputs": [ - { - "internalType": "uint256", - "name": "assets", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "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": "bytes", - "name": "signature", - "type": "bytes" - } - ], - "name": "permit", - "outputs": [], - "stateMutability": "nonpayable", - "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": "pot", - "outputs": [ - { - "internalType": "contract PotLike", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "assets", - "type": "uint256" - } - ], - "name": "previewDeposit", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "shares", - "type": "uint256" - } - ], - "name": "previewMint", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "shares", - "type": "uint256" - } - ], - "name": "previewRedeem", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "assets", - "type": "uint256" - } - ], - "name": "previewWithdraw", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "shares", - "type": "uint256" - }, - { - "internalType": "address", - "name": "receiver", - "type": "address" - }, - { - "internalType": "address", - "name": "owner", - "type": "address" - } - ], - "name": "redeem", - "outputs": [ - { - "internalType": "uint256", - "name": "assets", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "totalAssets", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "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" - }, - { - "inputs": [], - "name": "vat", - "outputs": [ - { - "internalType": "contract VatLike", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "version", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "assets", - "type": "uint256" - }, - { - "internalType": "address", - "name": "receiver", - "type": "address" - }, - { - "internalType": "address", - "name": "owner", - "type": "address" - } - ], - "name": "withdraw", - "outputs": [ - { - "internalType": "uint256", - "name": "shares", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - } -] diff --git a/src/abi/erc4626ABI.ts b/src/abi/erc4626ABI.ts new file mode 100644 index 000000000..46eca94fd --- /dev/null +++ b/src/abi/erc4626ABI.ts @@ -0,0 +1,877 @@ +export default [ + { + inputs: [ + { + internalType: 'address', + name: '_daiJoin', + type: 'address', + }, + { + internalType: 'address', + name: '_pot', + type: 'address', + }, + ], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + 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: 'sender', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'owner', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'assets', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'shares', + type: 'uint256', + }, + ], + name: 'Deposit', + 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', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'sender', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'receiver', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'owner', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'assets', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'shares', + type: 'uint256', + }, + ], + name: 'Withdraw', + type: 'event', + }, + { + inputs: [], + name: 'DOMAIN_SEPARATOR', + outputs: [ + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'PERMIT_TYPEHASH', + outputs: [ + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + { + internalType: 'address', + name: '', + 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: [], + name: 'asset', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + name: 'balanceOf', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'shares', + type: 'uint256', + }, + ], + name: 'convertToAssets', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'assets', + type: 'uint256', + }, + ], + name: 'convertToShares', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'dai', + outputs: [ + { + internalType: 'contract DaiLike', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'daiJoin', + outputs: [ + { + internalType: 'contract DaiJoinLike', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'decimals', + outputs: [ + { + internalType: 'uint8', + name: '', + type: 'uint8', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + internalType: 'uint256', + name: 'subtractedValue', + type: 'uint256', + }, + ], + name: 'decreaseAllowance', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'deploymentChainId', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'assets', + type: 'uint256', + }, + { + internalType: 'address', + name: 'receiver', + type: 'address', + }, + ], + name: 'deposit', + outputs: [ + { + internalType: 'uint256', + name: 'shares', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + internalType: 'uint256', + name: 'addedValue', + type: 'uint256', + }, + ], + name: 'increaseAllowance', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + name: 'maxDeposit', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'pure', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + name: 'maxMint', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'pure', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'owner', + type: 'address', + }, + ], + name: 'maxRedeem', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'owner', + type: 'address', + }, + ], + name: 'maxWithdraw', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'shares', + type: 'uint256', + }, + { + internalType: 'address', + name: 'receiver', + type: 'address', + }, + ], + name: 'mint', + outputs: [ + { + internalType: 'uint256', + name: 'assets', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'name', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '', + 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: 'bytes', + name: 'signature', + type: 'bytes', + }, + ], + name: 'permit', + outputs: [], + stateMutability: 'nonpayable', + 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: 'pot', + outputs: [ + { + internalType: 'contract PotLike', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'assets', + type: 'uint256', + }, + ], + name: 'previewDeposit', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'shares', + type: 'uint256', + }, + ], + name: 'previewMint', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'shares', + type: 'uint256', + }, + ], + name: 'previewRedeem', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'assets', + type: 'uint256', + }, + ], + name: 'previewWithdraw', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'shares', + type: 'uint256', + }, + { + internalType: 'address', + name: 'receiver', + type: 'address', + }, + { + internalType: 'address', + name: 'owner', + type: 'address', + }, + ], + name: 'redeem', + outputs: [ + { + internalType: 'uint256', + name: 'assets', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'symbol', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'totalAssets', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + 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', + }, + { + inputs: [], + name: 'vat', + outputs: [ + { + internalType: 'contract VatLike', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'version', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'assets', + type: 'uint256', + }, + { + internalType: 'address', + name: 'receiver', + type: 'address', + }, + { + internalType: 'address', + name: 'owner', + type: 'address', + }, + ], + name: 'withdraw', + outputs: [ + { + internalType: 'uint256', + name: 'shares', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const; diff --git a/src/abi/frxETHMinter.json b/src/abi/frxETHMinter.json deleted file mode 100644 index 8f92aef5f..000000000 --- a/src/abi/frxETHMinter.json +++ /dev/null @@ -1,696 +0,0 @@ -[ - { - "inputs": [ - { - "internalType": "address", - "name": "depositContractAddress", - "type": "address" - }, - { "internalType": "address", "name": "frxETHAddress", "type": "address" }, - { - "internalType": "address", - "name": "sfrxETHAddress", - "type": "address" - }, - { "internalType": "address", "name": "_owner", "type": "address" }, - { - "internalType": "address", - "name": "_timelock_address", - "type": "address" - }, - { - "internalType": "bytes", - "name": "_withdrawalCredential", - "type": "bytes" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bool", - "name": "new_status", - "type": "bool" - } - ], - "name": "DepositEtherPaused", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes", - "name": "pubKey", - "type": "bytes" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "withdrawalCredential", - "type": "bytes" - } - ], - "name": "DepositSent", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "recipient", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "sent_amount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "withheld_amt", - "type": "uint256" - } - ], - "name": "ETHSubmitted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "tokenAddress", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "tokenAmount", - "type": "uint256" - } - ], - "name": "EmergencyERC20Recovered", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "EmergencyEtherRecovered", - "type": "event" - }, - { "anonymous": false, "inputs": [], "name": "KeysCleared", "type": "event" }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "oldOwner", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnerChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnerNominated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bool", - "name": "new_status", - "type": "bool" - } - ], - "name": "SubmitPaused", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "timelock_address", - "type": "address" - } - ], - "name": "TimelockChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes", - "name": "pubKey", - "type": "bytes" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "withdrawalCredential", - "type": "bytes" - } - ], - "name": "ValidatorAdded", - "type": "event" - }, - { - "anonymous": false, - "inputs": [], - "name": "ValidatorArrayCleared", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes", - "name": "pubKey", - "type": "bytes" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "remove_idx", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bool", - "name": "dont_care_about_ordering", - "type": "bool" - } - ], - "name": "ValidatorRemoved", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "times", - "type": "uint256" - } - ], - "name": "ValidatorsPopped", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes", - "name": "from_pubKey", - "type": "bytes" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "to_pubKey", - "type": "bytes" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "from_idx", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "to_idx", - "type": "uint256" - } - ], - "name": "ValidatorsSwapped", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes", - "name": "_withdrawalCredential", - "type": "bytes" - } - ], - "name": "WithdrawalCredentialSet", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "WithheldETHMoved", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "newRatio", - "type": "uint256" - } - ], - "name": "WithholdRatioSet", - "type": "event" - }, - { - "inputs": [], - "name": "DEPOSIT_SIZE", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "RATIO_PRECISION", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "acceptOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }], - "name": "activeValidators", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { "internalType": "bytes", "name": "pubKey", "type": "bytes" }, - { "internalType": "bytes", "name": "signature", "type": "bytes" }, - { - "internalType": "bytes32", - "name": "depositDataRoot", - "type": "bytes32" - } - ], - "internalType": "struct OperatorRegistry.Validator", - "name": "validator", - "type": "tuple" - } - ], - "name": "addValidator", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { "internalType": "bytes", "name": "pubKey", "type": "bytes" }, - { "internalType": "bytes", "name": "signature", "type": "bytes" }, - { - "internalType": "bytes32", - "name": "depositDataRoot", - "type": "bytes32" - } - ], - "internalType": "struct OperatorRegistry.Validator[]", - "name": "validatorArray", - "type": "tuple[]" - } - ], - "name": "addValidators", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "clearValidatorArray", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "currentWithheldETH", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "depositContract", - "outputs": [ - { - "internalType": "contract IDepositContract", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "max_deposits", "type": "uint256" } - ], - "name": "depositEther", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "depositEtherPaused", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "frxETHToken", - "outputs": [ - { "internalType": "contract frxETH", "name": "", "type": "address" } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [{ "internalType": "uint256", "name": "i", "type": "uint256" }], - "name": "getValidator", - "outputs": [ - { "internalType": "bytes", "name": "pubKey", "type": "bytes" }, - { - "internalType": "bytes", - "name": "withdrawalCredentials", - "type": "bytes" - }, - { "internalType": "bytes", "name": "signature", "type": "bytes" }, - { - "internalType": "bytes32", - "name": "depositDataRoot", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "bytes", "name": "pubKey", "type": "bytes" }, - { "internalType": "bytes", "name": "signature", "type": "bytes" }, - { - "internalType": "bytes32", - "name": "depositDataRoot", - "type": "bytes32" - } - ], - "name": "getValidatorStruct", - "outputs": [ - { - "components": [ - { "internalType": "bytes", "name": "pubKey", "type": "bytes" }, - { "internalType": "bytes", "name": "signature", "type": "bytes" }, - { - "internalType": "bytes32", - "name": "depositDataRoot", - "type": "bytes32" - } - ], - "internalType": "struct OperatorRegistry.Validator", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address payable", "name": "to", "type": "address" }, - { "internalType": "uint256", "name": "amount", "type": "uint256" } - ], - "name": "moveWithheldETH", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "_owner", "type": "address" } - ], - "name": "nominateNewOwner", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "nominatedOwner", - "outputs": [{ "internalType": "address", "name": "", "type": "address" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "numValidators", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [{ "internalType": "address", "name": "", "type": "address" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "times", "type": "uint256" } - ], - "name": "popValidators", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "tokenAddress", "type": "address" }, - { "internalType": "uint256", "name": "tokenAmount", "type": "uint256" } - ], - "name": "recoverERC20", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "amount", "type": "uint256" } - ], - "name": "recoverEther", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "remove_idx", "type": "uint256" }, - { - "internalType": "bool", - "name": "dont_care_about_ordering", - "type": "bool" - } - ], - "name": "removeValidator", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_timelock_address", - "type": "address" - } - ], - "name": "setTimelock", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "_new_withdrawal_pubkey", - "type": "bytes" - } - ], - "name": "setWithdrawalCredential", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "newRatio", "type": "uint256" } - ], - "name": "setWithholdRatio", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "sfrxETHToken", - "outputs": [ - { "internalType": "contract IsfrxETH", "name": "", "type": "address" } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "submit", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "recipient", "type": "address" } - ], - "name": "submitAndDeposit", - "outputs": [ - { "internalType": "uint256", "name": "shares", "type": "uint256" } - ], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "address", "name": "recipient", "type": "address" } - ], - "name": "submitAndGive", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [], - "name": "submitPaused", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "from_idx", "type": "uint256" }, - { "internalType": "uint256", "name": "to_idx", "type": "uint256" } - ], - "name": "swapValidator", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "timelock_address", - "outputs": [{ "internalType": "address", "name": "", "type": "address" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "togglePauseDepositEther", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "togglePauseSubmits", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "withholdRatio", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { "stateMutability": "payable", "type": "receive" } -] diff --git a/src/abi/frxETHMinter.ts b/src/abi/frxETHMinter.ts new file mode 100644 index 000000000..c2450ab83 --- /dev/null +++ b/src/abi/frxETHMinter.ts @@ -0,0 +1,676 @@ +export default [ + { + inputs: [ + { + internalType: 'address', + name: 'depositContractAddress', + type: 'address', + }, + { internalType: 'address', name: 'frxETHAddress', type: 'address' }, + { + internalType: 'address', + name: 'sfrxETHAddress', + type: 'address', + }, + { internalType: 'address', name: '_owner', type: 'address' }, + { + internalType: 'address', + name: '_timelock_address', + type: 'address', + }, + { + internalType: 'bytes', + name: '_withdrawalCredential', + type: 'bytes', + }, + ], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'bool', + name: 'new_status', + type: 'bool', + }, + ], + name: 'DepositEtherPaused', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'bytes', + name: 'pubKey', + type: 'bytes', + }, + { + indexed: false, + internalType: 'bytes', + name: 'withdrawalCredential', + type: 'bytes', + }, + ], + name: 'DepositSent', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'sender', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'recipient', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'sent_amount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'withheld_amt', + type: 'uint256', + }, + ], + name: 'ETHSubmitted', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'address', + name: 'tokenAddress', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'tokenAmount', + type: 'uint256', + }, + ], + name: 'EmergencyERC20Recovered', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'EmergencyEtherRecovered', + type: 'event', + }, + { anonymous: false, inputs: [], name: 'KeysCleared', type: 'event' }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'address', + name: 'oldOwner', + type: 'address', + }, + { + indexed: false, + internalType: 'address', + name: 'newOwner', + type: 'address', + }, + ], + name: 'OwnerChanged', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'address', + name: 'newOwner', + type: 'address', + }, + ], + name: 'OwnerNominated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'bool', + name: 'new_status', + type: 'bool', + }, + ], + name: 'SubmitPaused', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'address', + name: 'timelock_address', + type: 'address', + }, + ], + name: 'TimelockChanged', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'bytes', + name: 'pubKey', + type: 'bytes', + }, + { + indexed: false, + internalType: 'bytes', + name: 'withdrawalCredential', + type: 'bytes', + }, + ], + name: 'ValidatorAdded', + type: 'event', + }, + { + anonymous: false, + inputs: [], + name: 'ValidatorArrayCleared', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'bytes', + name: 'pubKey', + type: 'bytes', + }, + { + indexed: false, + internalType: 'uint256', + name: 'remove_idx', + type: 'uint256', + }, + { + indexed: false, + internalType: 'bool', + name: 'dont_care_about_ordering', + type: 'bool', + }, + ], + name: 'ValidatorRemoved', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint256', + name: 'times', + type: 'uint256', + }, + ], + name: 'ValidatorsPopped', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'bytes', + name: 'from_pubKey', + type: 'bytes', + }, + { + indexed: false, + internalType: 'bytes', + name: 'to_pubKey', + type: 'bytes', + }, + { + indexed: false, + internalType: 'uint256', + name: 'from_idx', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'to_idx', + type: 'uint256', + }, + ], + name: 'ValidatorsSwapped', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'bytes', + name: '_withdrawalCredential', + type: 'bytes', + }, + ], + name: 'WithdrawalCredentialSet', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'to', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'WithheldETHMoved', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint256', + name: 'newRatio', + type: 'uint256', + }, + ], + name: 'WithholdRatioSet', + type: 'event', + }, + { + inputs: [], + name: 'DEPOSIT_SIZE', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'RATIO_PRECISION', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'acceptOwnership', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'bytes', name: '', type: 'bytes' }], + name: 'activeValidators', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + components: [ + { internalType: 'bytes', name: 'pubKey', type: 'bytes' }, + { internalType: 'bytes', name: 'signature', type: 'bytes' }, + { + internalType: 'bytes32', + name: 'depositDataRoot', + type: 'bytes32', + }, + ], + internalType: 'struct OperatorRegistry.Validator', + name: 'validator', + type: 'tuple', + }, + ], + name: 'addValidator', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + components: [ + { internalType: 'bytes', name: 'pubKey', type: 'bytes' }, + { internalType: 'bytes', name: 'signature', type: 'bytes' }, + { + internalType: 'bytes32', + name: 'depositDataRoot', + type: 'bytes32', + }, + ], + internalType: 'struct OperatorRegistry.Validator[]', + name: 'validatorArray', + type: 'tuple[]', + }, + ], + name: 'addValidators', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'clearValidatorArray', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'currentWithheldETH', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'depositContract', + outputs: [ + { + internalType: 'contract IDepositContract', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: 'max_deposits', type: 'uint256' }], + name: 'depositEther', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'depositEtherPaused', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'frxETHToken', + outputs: [{ internalType: 'contract frxETH', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: 'i', type: 'uint256' }], + name: 'getValidator', + outputs: [ + { internalType: 'bytes', name: 'pubKey', type: 'bytes' }, + { + internalType: 'bytes', + name: 'withdrawalCredentials', + type: 'bytes', + }, + { internalType: 'bytes', name: 'signature', type: 'bytes' }, + { + internalType: 'bytes32', + name: 'depositDataRoot', + type: 'bytes32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'bytes', name: 'pubKey', type: 'bytes' }, + { internalType: 'bytes', name: 'signature', type: 'bytes' }, + { + internalType: 'bytes32', + name: 'depositDataRoot', + type: 'bytes32', + }, + ], + name: 'getValidatorStruct', + outputs: [ + { + components: [ + { internalType: 'bytes', name: 'pubKey', type: 'bytes' }, + { internalType: 'bytes', name: 'signature', type: 'bytes' }, + { + internalType: 'bytes32', + name: 'depositDataRoot', + type: 'bytes32', + }, + ], + internalType: 'struct OperatorRegistry.Validator', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'pure', + type: 'function', + }, + { + inputs: [ + { internalType: 'address payable', name: 'to', type: 'address' }, + { internalType: 'uint256', name: 'amount', type: 'uint256' }, + ], + name: 'moveWithheldETH', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: '_owner', type: 'address' }], + name: 'nominateNewOwner', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'nominatedOwner', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'numValidators', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'owner', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: 'times', type: 'uint256' }], + name: 'popValidators', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'tokenAddress', type: 'address' }, + { internalType: 'uint256', name: 'tokenAmount', type: 'uint256' }, + ], + name: 'recoverERC20', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: 'amount', type: 'uint256' }], + name: 'recoverEther', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint256', name: 'remove_idx', type: 'uint256' }, + { + internalType: 'bool', + name: 'dont_care_about_ordering', + type: 'bool', + }, + ], + name: 'removeValidator', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: '_timelock_address', + type: 'address', + }, + ], + name: 'setTimelock', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes', + name: '_new_withdrawal_pubkey', + type: 'bytes', + }, + ], + name: 'setWithdrawalCredential', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: 'newRatio', type: 'uint256' }], + name: 'setWithholdRatio', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'sfrxETHToken', + outputs: [{ internalType: 'contract IsfrxETH', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'submit', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'recipient', type: 'address' }], + name: 'submitAndDeposit', + outputs: [{ internalType: 'uint256', name: 'shares', type: 'uint256' }], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'recipient', type: 'address' }], + name: 'submitAndGive', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [], + name: 'submitPaused', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint256', name: 'from_idx', type: 'uint256' }, + { internalType: 'uint256', name: 'to_idx', type: 'uint256' }, + ], + name: 'swapValidator', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'timelock_address', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'togglePauseDepositEther', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'togglePauseSubmits', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'withholdRatio', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { stateMutability: 'payable', type: 'receive' }, +] as const; diff --git a/src/abi/rETH.json b/src/abi/rETH.json deleted file mode 100644 index 9797e0db9..000000000 --- a/src/abi/rETH.json +++ /dev/null @@ -1,231 +0,0 @@ -[ - { - "inputs": [ - { - "internalType": "contract RocketStorageInterface", - "name": "_rocketStorageAddress", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "minipool", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "time", - "type": "uint256" - } - ], - "name": "DepositAssigned", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "time", - "type": "uint256" - } - ], - "name": "DepositReceived", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "time", - "type": "uint256" - } - ], - "name": "DepositRecycled", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "time", - "type": "uint256" - } - ], - "name": "ExcessWithdrawn", - "type": "event" - }, - { - "inputs": [], - "name": "assignDeposits", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "deposit", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [], - "name": "getBalance", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getExcessBalance", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getMaximumDepositAmount", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getNodeBalance", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getUserBalance", - "outputs": [{ "internalType": "int256", "name": "", "type": "int256" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "maybeAssignDeposits", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "_amount", "type": "uint256" } - ], - "name": "nodeCreditWithdrawal", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "_totalAmount", "type": "uint256" } - ], - "name": "nodeDeposit", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [], - "name": "receiveVaultWithdrawalETH", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [], - "name": "recycleDissolvedDeposit", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [], - "name": "recycleExcessCollateral", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [], - "name": "recycleLiquidatedStake", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [], - "name": "version", - "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { "internalType": "uint256", "name": "_amount", "type": "uint256" } - ], - "name": "withdrawExcessBalance", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } -] diff --git a/src/abi/rETH.ts b/src/abi/rETH.ts new file mode 100644 index 000000000..cb5921621 --- /dev/null +++ b/src/abi/rETH.ts @@ -0,0 +1,225 @@ +export default [ + { + inputs: [ + { + internalType: 'contract RocketStorageInterface', + name: '_rocketStorageAddress', + type: 'address', + }, + ], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'minipool', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'time', + type: 'uint256', + }, + ], + name: 'DepositAssigned', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'from', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'time', + type: 'uint256', + }, + ], + name: 'DepositReceived', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'from', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'time', + type: 'uint256', + }, + ], + name: 'DepositRecycled', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'to', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'time', + type: 'uint256', + }, + ], + name: 'ExcessWithdrawn', + type: 'event', + }, + { + inputs: [], + name: 'assignDeposits', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'deposit', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [], + name: 'getBalance', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getExcessBalance', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getMaximumDepositAmount', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getNodeBalance', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getUserBalance', + outputs: [{ internalType: 'int256', name: '', type: 'int256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'maybeAssignDeposits', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: '_amount', type: 'uint256' }], + name: 'nodeCreditWithdrawal', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: '_totalAmount', type: 'uint256' }], + name: 'nodeDeposit', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [], + name: 'receiveVaultWithdrawalETH', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [], + name: 'recycleDissolvedDeposit', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [], + name: 'recycleExcessCollateral', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [], + name: 'recycleLiquidatedStake', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [], + name: 'version', + outputs: [{ internalType: 'uint8', name: '', type: 'uint8' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'uint256', name: '_amount', type: 'uint256' }], + name: 'withdrawExcessBalance', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const; diff --git a/src/abi/steth.json b/src/abi/steth.json deleted file mode 100644 index 3ff38823f..000000000 --- a/src/abi/steth.json +++ /dev/null @@ -1,896 +0,0 @@ -[ - { - "constant": false, - "inputs": [], - "name": "resume", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "name", - "outputs": [{ "name": "", "type": "string" }], - "payable": false, - "stateMutability": "pure", - "type": "function" - }, - { - "constant": false, - "inputs": [], - "name": "stop", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "hasInitialized", - "outputs": [{ "name": "", "type": "bool" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "name": "_spender", "type": "address" }, - { "name": "_amount", "type": "uint256" } - ], - "name": "approve", - "outputs": [{ "name": "", "type": "bool" }], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "STAKING_CONTROL_ROLE", - "outputs": [{ "name": "", "type": "bytes32" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "totalSupply", - "outputs": [{ "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [{ "name": "_ethAmount", "type": "uint256" }], - "name": "getSharesByPooledEth", - "outputs": [{ "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "isStakingPaused", - "outputs": [{ "name": "", "type": "bool" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "name": "_sender", "type": "address" }, - { "name": "_recipient", "type": "address" }, - { "name": "_amount", "type": "uint256" } - ], - "name": "transferFrom", - "outputs": [{ "name": "", "type": "bool" }], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [{ "name": "_script", "type": "bytes" }], - "name": "getEVMScriptExecutor", - "outputs": [{ "name": "", "type": "address" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "name": "_maxStakeLimit", "type": "uint256" }, - { "name": "_stakeLimitIncreasePerBlock", "type": "uint256" } - ], - "name": "setStakingLimit", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "RESUME_ROLE", - "outputs": [{ "name": "", "type": "bytes32" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "name": "_lidoLocator", "type": "address" }, - { "name": "_eip712StETH", "type": "address" } - ], - "name": "finalizeUpgrade_v2", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "decimals", - "outputs": [{ "name": "", "type": "uint8" }], - "payable": false, - "stateMutability": "pure", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getRecoveryVault", - "outputs": [{ "name": "", "type": "address" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "DOMAIN_SEPARATOR", - "outputs": [{ "name": "", "type": "bytes32" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getTotalPooledEther", - "outputs": [{ "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [{ "name": "_newDepositedValidators", "type": "uint256" }], - "name": "unsafeChangeDepositedValidators", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "PAUSE_ROLE", - "outputs": [{ "name": "", "type": "bytes32" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "name": "_spender", "type": "address" }, - { "name": "_addedValue", "type": "uint256" } - ], - "name": "increaseAllowance", - "outputs": [{ "name": "", "type": "bool" }], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getTreasury", - "outputs": [{ "name": "", "type": "address" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "isStopped", - "outputs": [{ "name": "", "type": "bool" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getBufferedEther", - "outputs": [{ "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "name": "_lidoLocator", "type": "address" }, - { "name": "_eip712StETH", "type": "address" } - ], - "name": "initialize", - "outputs": [], - "payable": true, - "stateMutability": "payable", - "type": "function" - }, - { - "constant": false, - "inputs": [], - "name": "receiveELRewards", - "outputs": [], - "payable": true, - "stateMutability": "payable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getWithdrawalCredentials", - "outputs": [{ "name": "", "type": "bytes32" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getCurrentStakeLimit", - "outputs": [{ "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getStakeLimitFullInfo", - "outputs": [ - { "name": "isStakingPaused", "type": "bool" }, - { "name": "isStakingLimitSet", "type": "bool" }, - { "name": "currentStakeLimit", "type": "uint256" }, - { "name": "maxStakeLimit", "type": "uint256" }, - { "name": "maxStakeLimitGrowthBlocks", "type": "uint256" }, - { "name": "prevStakeLimit", "type": "uint256" }, - { "name": "prevStakeBlockNumber", "type": "uint256" } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "name": "_sender", "type": "address" }, - { "name": "_recipient", "type": "address" }, - { "name": "_sharesAmount", "type": "uint256" } - ], - "name": "transferSharesFrom", - "outputs": [{ "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [{ "name": "_account", "type": "address" }], - "name": "balanceOf", - "outputs": [{ "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [], - "name": "resumeStaking", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getFeeDistribution", - "outputs": [ - { "name": "treasuryFeeBasisPoints", "type": "uint16" }, - { "name": "insuranceFeeBasisPoints", "type": "uint16" }, - { "name": "operatorsFeeBasisPoints", "type": "uint16" } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [], - "name": "receiveWithdrawals", - "outputs": [], - "payable": true, - "stateMutability": "payable", - "type": "function" - }, - { - "constant": true, - "inputs": [{ "name": "_sharesAmount", "type": "uint256" }], - "name": "getPooledEthByShares", - "outputs": [{ "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [{ "name": "token", "type": "address" }], - "name": "allowRecoverability", - "outputs": [{ "name": "", "type": "bool" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [{ "name": "owner", "type": "address" }], - "name": "nonces", - "outputs": [{ "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "appId", - "outputs": [{ "name": "", "type": "bytes32" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getOracle", - "outputs": [{ "name": "", "type": "address" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "eip712Domain", - "outputs": [ - { "name": "name", "type": "string" }, - { "name": "version", "type": "string" }, - { "name": "chainId", "type": "uint256" }, - { "name": "verifyingContract", "type": "address" } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getContractVersion", - "outputs": [{ "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getInitializationBlock", - "outputs": [{ "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "name": "_recipient", "type": "address" }, - { "name": "_sharesAmount", "type": "uint256" } - ], - "name": "transferShares", - "outputs": [{ "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "symbol", - "outputs": [{ "name": "", "type": "string" }], - "payable": false, - "stateMutability": "pure", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getEIP712StETH", - "outputs": [{ "name": "", "type": "address" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [{ "name": "", "type": "address" }], - "name": "transferToVault", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { "name": "_sender", "type": "address" }, - { "name": "_role", "type": "bytes32" }, - { "name": "_params", "type": "uint256[]" } - ], - "name": "canPerform", - "outputs": [{ "name": "", "type": "bool" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [{ "name": "_referral", "type": "address" }], - "name": "submit", - "outputs": [{ "name": "", "type": "uint256" }], - "payable": true, - "stateMutability": "payable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "name": "_spender", "type": "address" }, - { "name": "_subtractedValue", "type": "uint256" } - ], - "name": "decreaseAllowance", - "outputs": [{ "name": "", "type": "bool" }], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getEVMScriptRegistry", - "outputs": [{ "name": "", "type": "address" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "name": "_recipient", "type": "address" }, - { "name": "_amount", "type": "uint256" } - ], - "name": "transfer", - "outputs": [{ "name": "", "type": "bool" }], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "name": "_maxDepositsCount", "type": "uint256" }, - { "name": "_stakingModuleId", "type": "uint256" }, - { "name": "_depositCalldata", "type": "bytes" } - ], - "name": "deposit", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "UNSAFE_CHANGE_DEPOSITED_VALIDATORS_ROLE", - "outputs": [{ "name": "", "type": "bytes32" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getBeaconStat", - "outputs": [ - { "name": "depositedValidators", "type": "uint256" }, - { "name": "beaconValidators", "type": "uint256" }, - { "name": "beaconBalance", "type": "uint256" } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [], - "name": "removeStakingLimit", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "name": "_reportTimestamp", "type": "uint256" }, - { "name": "_timeElapsed", "type": "uint256" }, - { "name": "_clValidators", "type": "uint256" }, - { "name": "_clBalance", "type": "uint256" }, - { "name": "_withdrawalVaultBalance", "type": "uint256" }, - { "name": "_elRewardsVaultBalance", "type": "uint256" }, - { "name": "_sharesRequestedToBurn", "type": "uint256" }, - { "name": "_withdrawalFinalizationBatches", "type": "uint256[]" }, - { "name": "_simulatedShareRate", "type": "uint256" } - ], - "name": "handleOracleReport", - "outputs": [{ "name": "postRebaseAmounts", "type": "uint256[4]" }], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getFee", - "outputs": [{ "name": "totalFee", "type": "uint16" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "kernel", - "outputs": [{ "name": "", "type": "address" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getTotalShares", - "outputs": [{ "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "name": "_owner", "type": "address" }, - { "name": "_spender", "type": "address" }, - { "name": "_value", "type": "uint256" }, - { "name": "_deadline", "type": "uint256" }, - { "name": "_v", "type": "uint8" }, - { "name": "_r", "type": "bytes32" }, - { "name": "_s", "type": "bytes32" } - ], - "name": "permit", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { "name": "_owner", "type": "address" }, - { "name": "_spender", "type": "address" } - ], - "name": "allowance", - "outputs": [{ "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "isPetrified", - "outputs": [{ "name": "", "type": "bool" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getLidoLocator", - "outputs": [{ "name": "", "type": "address" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "canDeposit", - "outputs": [{ "name": "", "type": "bool" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "STAKING_PAUSE_ROLE", - "outputs": [{ "name": "", "type": "bytes32" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getDepositableEther", - "outputs": [{ "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [{ "name": "_account", "type": "address" }], - "name": "sharesOf", - "outputs": [{ "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [], - "name": "pauseStaking", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getTotalELRewardsCollected", - "outputs": [{ "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { "payable": true, "stateMutability": "payable", "type": "fallback" }, - { - "anonymous": false, - "inputs": [], - "name": "StakingPaused", - "type": "event" - }, - { - "anonymous": false, - "inputs": [], - "name": "StakingResumed", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { "indexed": false, "name": "maxStakeLimit", "type": "uint256" }, - { - "indexed": false, - "name": "stakeLimitIncreasePerBlock", - "type": "uint256" - } - ], - "name": "StakingLimitSet", - "type": "event" - }, - { - "anonymous": false, - "inputs": [], - "name": "StakingLimitRemoved", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { "indexed": true, "name": "reportTimestamp", "type": "uint256" }, - { "indexed": false, "name": "preCLValidators", "type": "uint256" }, - { "indexed": false, "name": "postCLValidators", "type": "uint256" } - ], - "name": "CLValidatorsUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { "indexed": false, "name": "depositedValidators", "type": "uint256" } - ], - "name": "DepositedValidatorsChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { "indexed": true, "name": "reportTimestamp", "type": "uint256" }, - { "indexed": false, "name": "preCLBalance", "type": "uint256" }, - { "indexed": false, "name": "postCLBalance", "type": "uint256" }, - { "indexed": false, "name": "withdrawalsWithdrawn", "type": "uint256" }, - { - "indexed": false, - "name": "executionLayerRewardsWithdrawn", - "type": "uint256" - }, - { "indexed": false, "name": "postBufferedEther", "type": "uint256" } - ], - "name": "ETHDistributed", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { "indexed": true, "name": "reportTimestamp", "type": "uint256" }, - { "indexed": false, "name": "timeElapsed", "type": "uint256" }, - { "indexed": false, "name": "preTotalShares", "type": "uint256" }, - { "indexed": false, "name": "preTotalEther", "type": "uint256" }, - { "indexed": false, "name": "postTotalShares", "type": "uint256" }, - { "indexed": false, "name": "postTotalEther", "type": "uint256" }, - { "indexed": false, "name": "sharesMintedAsFees", "type": "uint256" } - ], - "name": "TokenRebased", - "type": "event" - }, - { - "anonymous": false, - "inputs": [{ "indexed": false, "name": "lidoLocator", "type": "address" }], - "name": "LidoLocatorSet", - "type": "event" - }, - { - "anonymous": false, - "inputs": [{ "indexed": false, "name": "amount", "type": "uint256" }], - "name": "ELRewardsReceived", - "type": "event" - }, - { - "anonymous": false, - "inputs": [{ "indexed": false, "name": "amount", "type": "uint256" }], - "name": "WithdrawalsReceived", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { "indexed": true, "name": "sender", "type": "address" }, - { "indexed": false, "name": "amount", "type": "uint256" }, - { "indexed": false, "name": "referral", "type": "address" } - ], - "name": "Submitted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [{ "indexed": false, "name": "amount", "type": "uint256" }], - "name": "Unbuffered", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { "indexed": true, "name": "executor", "type": "address" }, - { "indexed": false, "name": "script", "type": "bytes" }, - { "indexed": false, "name": "input", "type": "bytes" }, - { "indexed": false, "name": "returnData", "type": "bytes" } - ], - "name": "ScriptResult", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { "indexed": true, "name": "vault", "type": "address" }, - { "indexed": true, "name": "token", "type": "address" }, - { "indexed": false, "name": "amount", "type": "uint256" } - ], - "name": "RecoverToVault", - "type": "event" - }, - { - "anonymous": false, - "inputs": [{ "indexed": false, "name": "eip712StETH", "type": "address" }], - "name": "EIP712StETHInitialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { "indexed": true, "name": "from", "type": "address" }, - { "indexed": true, "name": "to", "type": "address" }, - { "indexed": false, "name": "sharesValue", "type": "uint256" } - ], - "name": "TransferShares", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { "indexed": true, "name": "account", "type": "address" }, - { "indexed": false, "name": "preRebaseTokenAmount", "type": "uint256" }, - { "indexed": false, "name": "postRebaseTokenAmount", "type": "uint256" }, - { "indexed": false, "name": "sharesAmount", "type": "uint256" } - ], - "name": "SharesBurnt", - "type": "event" - }, - { "anonymous": false, "inputs": [], "name": "Stopped", "type": "event" }, - { "anonymous": false, "inputs": [], "name": "Resumed", "type": "event" }, - { - "anonymous": false, - "inputs": [ - { "indexed": true, "name": "from", "type": "address" }, - { "indexed": true, "name": "to", "type": "address" }, - { "indexed": false, "name": "value", "type": "uint256" } - ], - "name": "Transfer", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { "indexed": true, "name": "owner", "type": "address" }, - { "indexed": true, "name": "spender", "type": "address" }, - { "indexed": false, "name": "value", "type": "uint256" } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [{ "indexed": false, "name": "version", "type": "uint256" }], - "name": "ContractVersionSet", - "type": "event" - } -] diff --git a/src/abi/steth.ts b/src/abi/steth.ts new file mode 100644 index 000000000..0679252b0 --- /dev/null +++ b/src/abi/steth.ts @@ -0,0 +1,894 @@ +export default [ + { + constant: false, + inputs: [], + name: 'resume', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'name', + outputs: [{ name: '', type: 'string' }], + payable: false, + stateMutability: 'pure', + type: 'function', + }, + { + constant: false, + inputs: [], + name: 'stop', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'hasInitialized', + outputs: [{ name: '', type: 'bool' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [ + { name: '_spender', type: 'address' }, + { name: '_amount', type: 'uint256' }, + ], + name: 'approve', + outputs: [{ name: '', type: 'bool' }], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'STAKING_CONTROL_ROLE', + outputs: [{ name: '', type: 'bytes32' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'totalSupply', + outputs: [{ name: '', type: 'uint256' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [{ name: '_ethAmount', type: 'uint256' }], + name: 'getSharesByPooledEth', + outputs: [{ name: '', type: 'uint256' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'isStakingPaused', + outputs: [{ name: '', type: 'bool' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [ + { name: '_sender', type: 'address' }, + { name: '_recipient', type: 'address' }, + { name: '_amount', type: 'uint256' }, + ], + name: 'transferFrom', + outputs: [{ name: '', type: 'bool' }], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [{ name: '_script', type: 'bytes' }], + name: 'getEVMScriptExecutor', + outputs: [{ name: '', type: 'address' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [ + { name: '_maxStakeLimit', type: 'uint256' }, + { name: '_stakeLimitIncreasePerBlock', type: 'uint256' }, + ], + name: 'setStakingLimit', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'RESUME_ROLE', + outputs: [{ name: '', type: 'bytes32' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [ + { name: '_lidoLocator', type: 'address' }, + { name: '_eip712StETH', type: 'address' }, + ], + name: 'finalizeUpgrade_v2', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'decimals', + outputs: [{ name: '', type: 'uint8' }], + payable: false, + stateMutability: 'pure', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'getRecoveryVault', + outputs: [{ name: '', type: 'address' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'DOMAIN_SEPARATOR', + outputs: [{ name: '', type: 'bytes32' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'getTotalPooledEther', + outputs: [{ name: '', type: 'uint256' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [{ name: '_newDepositedValidators', type: 'uint256' }], + name: 'unsafeChangeDepositedValidators', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'PAUSE_ROLE', + outputs: [{ name: '', type: 'bytes32' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [ + { name: '_spender', type: 'address' }, + { name: '_addedValue', type: 'uint256' }, + ], + name: 'increaseAllowance', + outputs: [{ name: '', type: 'bool' }], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'getTreasury', + outputs: [{ name: '', type: 'address' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'isStopped', + outputs: [{ name: '', type: 'bool' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'getBufferedEther', + outputs: [{ name: '', type: 'uint256' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [ + { name: '_lidoLocator', type: 'address' }, + { name: '_eip712StETH', type: 'address' }, + ], + name: 'initialize', + outputs: [], + payable: true, + stateMutability: 'payable', + type: 'function', + }, + { + constant: false, + inputs: [], + name: 'receiveELRewards', + outputs: [], + payable: true, + stateMutability: 'payable', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'getWithdrawalCredentials', + outputs: [{ name: '', type: 'bytes32' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'getCurrentStakeLimit', + outputs: [{ name: '', type: 'uint256' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'getStakeLimitFullInfo', + outputs: [ + { name: 'isStakingPaused', type: 'bool' }, + { name: 'isStakingLimitSet', type: 'bool' }, + { name: 'currentStakeLimit', type: 'uint256' }, + { name: 'maxStakeLimit', type: 'uint256' }, + { name: 'maxStakeLimitGrowthBlocks', type: 'uint256' }, + { name: 'prevStakeLimit', type: 'uint256' }, + { name: 'prevStakeBlockNumber', type: 'uint256' }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [ + { name: '_sender', type: 'address' }, + { name: '_recipient', type: 'address' }, + { name: '_sharesAmount', type: 'uint256' }, + ], + name: 'transferSharesFrom', + outputs: [{ name: '', type: 'uint256' }], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [{ name: '_account', type: 'address' }], + name: 'balanceOf', + outputs: [{ name: '', type: 'uint256' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [], + name: 'resumeStaking', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'getFeeDistribution', + outputs: [ + { name: 'treasuryFeeBasisPoints', type: 'uint16' }, + { name: 'insuranceFeeBasisPoints', type: 'uint16' }, + { name: 'operatorsFeeBasisPoints', type: 'uint16' }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [], + name: 'receiveWithdrawals', + outputs: [], + payable: true, + stateMutability: 'payable', + type: 'function', + }, + { + constant: true, + inputs: [{ name: '_sharesAmount', type: 'uint256' }], + name: 'getPooledEthByShares', + outputs: [{ name: '', type: 'uint256' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [{ name: 'token', type: 'address' }], + name: 'allowRecoverability', + outputs: [{ name: '', type: 'bool' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [{ name: 'owner', type: 'address' }], + name: 'nonces', + outputs: [{ name: '', type: 'uint256' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'appId', + outputs: [{ name: '', type: 'bytes32' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'getOracle', + outputs: [{ name: '', type: 'address' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'eip712Domain', + outputs: [ + { name: 'name', type: 'string' }, + { name: 'version', type: 'string' }, + { name: 'chainId', type: 'uint256' }, + { name: 'verifyingContract', type: 'address' }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'getContractVersion', + outputs: [{ name: '', type: 'uint256' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'getInitializationBlock', + outputs: [{ name: '', type: 'uint256' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [ + { name: '_recipient', type: 'address' }, + { name: '_sharesAmount', type: 'uint256' }, + ], + name: 'transferShares', + outputs: [{ name: '', type: 'uint256' }], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'symbol', + outputs: [{ name: '', type: 'string' }], + payable: false, + stateMutability: 'pure', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'getEIP712StETH', + outputs: [{ name: '', type: 'address' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [{ name: '', type: 'address' }], + name: 'transferToVault', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [ + { name: '_sender', type: 'address' }, + { name: '_role', type: 'bytes32' }, + { name: '_params', type: 'uint256[]' }, + ], + name: 'canPerform', + outputs: [{ name: '', type: 'bool' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [{ name: '_referral', type: 'address' }], + name: 'submit', + outputs: [{ name: '', type: 'uint256' }], + payable: true, + stateMutability: 'payable', + type: 'function', + }, + { + constant: false, + inputs: [ + { name: '_spender', type: 'address' }, + { name: '_subtractedValue', type: 'uint256' }, + ], + name: 'decreaseAllowance', + outputs: [{ name: '', type: 'bool' }], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'getEVMScriptRegistry', + outputs: [{ name: '', type: 'address' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [ + { name: '_recipient', type: 'address' }, + { name: '_amount', type: 'uint256' }, + ], + name: 'transfer', + outputs: [{ name: '', type: 'bool' }], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: false, + inputs: [ + { name: '_maxDepositsCount', type: 'uint256' }, + { name: '_stakingModuleId', type: 'uint256' }, + { name: '_depositCalldata', type: 'bytes' }, + ], + name: 'deposit', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'UNSAFE_CHANGE_DEPOSITED_VALIDATORS_ROLE', + outputs: [{ name: '', type: 'bytes32' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'getBeaconStat', + outputs: [ + { name: 'depositedValidators', type: 'uint256' }, + { name: 'beaconValidators', type: 'uint256' }, + { name: 'beaconBalance', type: 'uint256' }, + ], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [], + name: 'removeStakingLimit', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: false, + inputs: [ + { name: '_reportTimestamp', type: 'uint256' }, + { name: '_timeElapsed', type: 'uint256' }, + { name: '_clValidators', type: 'uint256' }, + { name: '_clBalance', type: 'uint256' }, + { name: '_withdrawalVaultBalance', type: 'uint256' }, + { name: '_elRewardsVaultBalance', type: 'uint256' }, + { name: '_sharesRequestedToBurn', type: 'uint256' }, + { name: '_withdrawalFinalizationBatches', type: 'uint256[]' }, + { name: '_simulatedShareRate', type: 'uint256' }, + ], + name: 'handleOracleReport', + outputs: [{ name: 'postRebaseAmounts', type: 'uint256[4]' }], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'getFee', + outputs: [{ name: 'totalFee', type: 'uint16' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'kernel', + outputs: [{ name: '', type: 'address' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'getTotalShares', + outputs: [{ name: '', type: 'uint256' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [ + { name: '_owner', type: 'address' }, + { name: '_spender', type: 'address' }, + { name: '_value', type: 'uint256' }, + { name: '_deadline', type: 'uint256' }, + { name: '_v', type: 'uint8' }, + { name: '_r', type: 'bytes32' }, + { name: '_s', type: 'bytes32' }, + ], + name: 'permit', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [ + { name: '_owner', type: 'address' }, + { name: '_spender', type: 'address' }, + ], + name: 'allowance', + outputs: [{ name: '', type: 'uint256' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'isPetrified', + outputs: [{ name: '', type: 'bool' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'getLidoLocator', + outputs: [{ name: '', type: 'address' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'canDeposit', + outputs: [{ name: '', type: 'bool' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'STAKING_PAUSE_ROLE', + outputs: [{ name: '', type: 'bytes32' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'getDepositableEther', + outputs: [{ name: '', type: 'uint256' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [{ name: '_account', type: 'address' }], + name: 'sharesOf', + outputs: [{ name: '', type: 'uint256' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [], + name: 'pauseStaking', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'getTotalELRewardsCollected', + outputs: [{ name: '', type: 'uint256' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { payable: true, stateMutability: 'payable', type: 'fallback' }, + { + anonymous: false, + inputs: [], + name: 'StakingPaused', + type: 'event', + }, + { + anonymous: false, + inputs: [], + name: 'StakingResumed', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: false, name: 'maxStakeLimit', type: 'uint256' }, + { + indexed: false, + name: 'stakeLimitIncreasePerBlock', + type: 'uint256', + }, + ], + name: 'StakingLimitSet', + type: 'event', + }, + { + anonymous: false, + inputs: [], + name: 'StakingLimitRemoved', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, name: 'reportTimestamp', type: 'uint256' }, + { indexed: false, name: 'preCLValidators', type: 'uint256' }, + { indexed: false, name: 'postCLValidators', type: 'uint256' }, + ], + name: 'CLValidatorsUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [{ indexed: false, name: 'depositedValidators', type: 'uint256' }], + name: 'DepositedValidatorsChanged', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, name: 'reportTimestamp', type: 'uint256' }, + { indexed: false, name: 'preCLBalance', type: 'uint256' }, + { indexed: false, name: 'postCLBalance', type: 'uint256' }, + { indexed: false, name: 'withdrawalsWithdrawn', type: 'uint256' }, + { + indexed: false, + name: 'executionLayerRewardsWithdrawn', + type: 'uint256', + }, + { indexed: false, name: 'postBufferedEther', type: 'uint256' }, + ], + name: 'ETHDistributed', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, name: 'reportTimestamp', type: 'uint256' }, + { indexed: false, name: 'timeElapsed', type: 'uint256' }, + { indexed: false, name: 'preTotalShares', type: 'uint256' }, + { indexed: false, name: 'preTotalEther', type: 'uint256' }, + { indexed: false, name: 'postTotalShares', type: 'uint256' }, + { indexed: false, name: 'postTotalEther', type: 'uint256' }, + { indexed: false, name: 'sharesMintedAsFees', type: 'uint256' }, + ], + name: 'TokenRebased', + type: 'event', + }, + { + anonymous: false, + inputs: [{ indexed: false, name: 'lidoLocator', type: 'address' }], + name: 'LidoLocatorSet', + type: 'event', + }, + { + anonymous: false, + inputs: [{ indexed: false, name: 'amount', type: 'uint256' }], + name: 'ELRewardsReceived', + type: 'event', + }, + { + anonymous: false, + inputs: [{ indexed: false, name: 'amount', type: 'uint256' }], + name: 'WithdrawalsReceived', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, name: 'sender', type: 'address' }, + { indexed: false, name: 'amount', type: 'uint256' }, + { indexed: false, name: 'referral', type: 'address' }, + ], + name: 'Submitted', + type: 'event', + }, + { + anonymous: false, + inputs: [{ indexed: false, name: 'amount', type: 'uint256' }], + name: 'Unbuffered', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, name: 'executor', type: 'address' }, + { indexed: false, name: 'script', type: 'bytes' }, + { indexed: false, name: 'input', type: 'bytes' }, + { indexed: false, name: 'returnData', type: 'bytes' }, + ], + name: 'ScriptResult', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, name: 'vault', type: 'address' }, + { indexed: true, name: 'token', type: 'address' }, + { indexed: false, name: 'amount', type: 'uint256' }, + ], + name: 'RecoverToVault', + type: 'event', + }, + { + anonymous: false, + inputs: [{ indexed: false, name: 'eip712StETH', type: 'address' }], + name: 'EIP712StETHInitialized', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, name: 'from', type: 'address' }, + { indexed: true, name: 'to', type: 'address' }, + { indexed: false, name: 'sharesValue', type: 'uint256' }, + ], + name: 'TransferShares', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, name: 'account', type: 'address' }, + { indexed: false, name: 'preRebaseTokenAmount', type: 'uint256' }, + { indexed: false, name: 'postRebaseTokenAmount', type: 'uint256' }, + { indexed: false, name: 'sharesAmount', type: 'uint256' }, + ], + name: 'SharesBurnt', + type: 'event', + }, + { anonymous: false, inputs: [], name: 'Stopped', type: 'event' }, + { anonymous: false, inputs: [], name: 'Resumed', type: 'event' }, + { + anonymous: false, + inputs: [ + { indexed: true, name: 'from', type: 'address' }, + { indexed: true, name: 'to', type: 'address' }, + { indexed: false, name: 'value', type: 'uint256' }, + ], + name: 'Transfer', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, name: 'owner', type: 'address' }, + { indexed: true, name: 'spender', type: 'address' }, + { indexed: false, name: 'value', type: 'uint256' }, + ], + name: 'Approval', + type: 'event', + }, + { + anonymous: false, + inputs: [{ indexed: false, name: 'version', type: 'uint256' }], + name: 'ContractVersionSet', + type: 'event', + }, +] as const; diff --git a/src/abi/weth.json b/src/abi/weth.json deleted file mode 100644 index 4827e8723..000000000 --- a/src/abi/weth.json +++ /dev/null @@ -1,153 +0,0 @@ -[ - { - "constant": true, - "inputs": [], - "name": "name", - "outputs": [{ "name": "", "type": "string" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "name": "guy", "type": "address" }, - { "name": "wad", "type": "uint256" } - ], - "name": "approve", - "outputs": [{ "name": "", "type": "bool" }], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "totalSupply", - "outputs": [{ "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "name": "src", "type": "address" }, - { "name": "dst", "type": "address" }, - { "name": "wad", "type": "uint256" } - ], - "name": "transferFrom", - "outputs": [{ "name": "", "type": "bool" }], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [{ "name": "wad", "type": "uint256" }], - "name": "withdraw", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "decimals", - "outputs": [{ "name": "", "type": "uint8" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [{ "name": "", "type": "address" }], - "name": "balanceOf", - "outputs": [{ "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "symbol", - "outputs": [{ "name": "", "type": "string" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { "name": "dst", "type": "address" }, - { "name": "wad", "type": "uint256" } - ], - "name": "transfer", - "outputs": [{ "name": "", "type": "bool" }], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [], - "name": "deposit", - "outputs": [], - "payable": true, - "stateMutability": "payable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { "name": "", "type": "address" }, - { "name": "", "type": "address" } - ], - "name": "allowance", - "outputs": [{ "name": "", "type": "uint256" }], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { "payable": true, "stateMutability": "payable", "type": "fallback" }, - { - "anonymous": false, - "inputs": [ - { "indexed": true, "name": "src", "type": "address" }, - { "indexed": true, "name": "guy", "type": "address" }, - { "indexed": false, "name": "wad", "type": "uint256" } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { "indexed": true, "name": "src", "type": "address" }, - { "indexed": true, "name": "dst", "type": "address" }, - { "indexed": false, "name": "wad", "type": "uint256" } - ], - "name": "Transfer", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { "indexed": true, "name": "dst", "type": "address" }, - { "indexed": false, "name": "wad", "type": "uint256" } - ], - "name": "Deposit", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { "indexed": true, "name": "src", "type": "address" }, - { "indexed": false, "name": "wad", "type": "uint256" } - ], - "name": "Withdrawal", - "type": "event" - } -] diff --git a/src/abi/weth.ts b/src/abi/weth.ts new file mode 100644 index 000000000..1f792c09e --- /dev/null +++ b/src/abi/weth.ts @@ -0,0 +1,153 @@ +export default [ + { + constant: true, + inputs: [], + name: 'name', + outputs: [{ name: '', type: 'string' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [ + { name: 'guy', type: 'address' }, + { name: 'wad', type: 'uint256' }, + ], + name: 'approve', + outputs: [{ name: '', type: 'bool' }], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'totalSupply', + outputs: [{ name: '', type: 'uint256' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [ + { name: 'src', type: 'address' }, + { name: 'dst', type: 'address' }, + { name: 'wad', type: 'uint256' }, + ], + name: 'transferFrom', + outputs: [{ name: '', type: 'bool' }], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: false, + inputs: [{ name: 'wad', type: 'uint256' }], + name: 'withdraw', + outputs: [], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'decimals', + outputs: [{ name: '', type: 'uint8' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [{ name: '', type: 'address' }], + name: 'balanceOf', + outputs: [{ name: '', type: 'uint256' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: true, + inputs: [], + name: 'symbol', + outputs: [{ name: '', type: 'string' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { + constant: false, + inputs: [ + { name: 'dst', type: 'address' }, + { name: 'wad', type: 'uint256' }, + ], + name: 'transfer', + outputs: [{ name: '', type: 'bool' }], + payable: false, + stateMutability: 'nonpayable', + type: 'function', + }, + { + constant: false, + inputs: [], + name: 'deposit', + outputs: [], + payable: true, + stateMutability: 'payable', + type: 'function', + }, + { + constant: true, + inputs: [ + { name: '', type: 'address' }, + { name: '', type: 'address' }, + ], + name: 'allowance', + outputs: [{ name: '', type: 'uint256' }], + payable: false, + stateMutability: 'view', + type: 'function', + }, + { payable: true, stateMutability: 'payable', type: 'fallback' }, + { + anonymous: false, + inputs: [ + { indexed: true, name: 'src', type: 'address' }, + { indexed: true, name: 'guy', type: 'address' }, + { indexed: false, name: 'wad', type: 'uint256' }, + ], + name: 'Approval', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, name: 'src', type: 'address' }, + { indexed: true, name: 'dst', type: 'address' }, + { indexed: false, name: 'wad', type: 'uint256' }, + ], + name: 'Transfer', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, name: 'dst', type: 'address' }, + { indexed: false, name: 'wad', type: 'uint256' }, + ], + name: 'Deposit', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, name: 'src', type: 'address' }, + { indexed: false, name: 'wad', type: 'uint256' }, + ], + name: 'Withdrawal', + type: 'event', + }, +] as const; diff --git a/src/components/cactiComponents/ActionResponse.tsx b/src/components/cactiComponents/ActionResponse.tsx index 074139737..4d1b095de 100644 --- a/src/components/cactiComponents/ActionResponse.tsx +++ b/src/components/cactiComponents/ActionResponse.tsx @@ -1,19 +1,17 @@ +//@ts-nocheck import { useEffect, useMemo, useState } from 'react'; import Skeleton from 'react-loading-skeleton'; -import { TransactionReceipt } from '@ethersproject/abstract-provider'; -import { AddressZero } from '@ethersproject/constants'; import { CheckCircleIcon, ExclamationTriangleIcon } from '@heroicons/react/24/outline'; import { ConnectButton } from '@rainbow-me/rainbowkit'; -import { BigNumber, UnsignedTransaction } from 'ethers'; -import { formatUnits } from 'ethers/lib/utils.js'; import tw from 'tailwind-styled-components'; -import { useAccount } from 'wagmi'; +import { TransactionReceipt, TransactionRequestBase, formatUnits, zeroAddress } from 'viem'; +import { UsePrepareContractWriteConfig, useAccount } from 'wagmi'; import useToken from '@/hooks/useToken'; import { cleanValue } from '@/utils'; import { ActionStepper } from './ActionStepper'; import useApproval, { ApprovalBasicParams } from './hooks/useApproval'; import useBalance from './hooks/useBalance'; -import useSubmitTx, { TxBasicParams } from './hooks/useSubmitTx'; +import useSubmitTx from './hooks/useSubmitTx'; export enum ActionResponseState { LOADING = 'LOADING', // background async checks @@ -50,9 +48,9 @@ type Action = { }; export type ActionResponseProps = { - txParams: TxBasicParams | undefined; - approvalParams: ApprovalBasicParams | undefined; - sendParams?: UnsignedTransaction | undefined; + txParams?: UsePrepareContractWriteConfig; + approvalParams?: ApprovalBasicParams; + sendParams?: TransactionRequestBase; label?: string; // label to show on button description?: string; // tx description (for wallet ) disabled?: boolean; @@ -82,15 +80,15 @@ export const ActionResponse = ({ const _approvalParams = useMemo( () => approvalParams || { - tokenAddress: AddressZero, - spender: AddressZero, - approvalAmount: BigNumber.from(0), + tokenAddress: zeroAddress, + spender: zeroAddress, + approvalAmount: BigInt(0), skipApproval: true, // NOTE: approval is skipped if no approval params are passed in }, [approvalParams] ); const { data: token } = useToken(undefined, _approvalParams.tokenAddress); - const amountFmt = formatUnits(_approvalParams.approvalAmount, token?.decimals); + const amountFmt = formatUnits(_approvalParams.approvalAmount, token!.decimals); /** Check for the approval. If no approvalParams, hasAllowance === true and approveTx == undefined */ const { @@ -144,7 +142,7 @@ export const ActionResponse = ({ // check approval token balance if (balance && _approvalParams?.approvalAmount) - setHasEnoughBalance(balance.gte(_approvalParams.approvalAmount)); + setHasEnoughBalance(balance >= _approvalParams?.approvalAmount); }, [_approvalParams, balance, ethBal, sendParams?.value, skipBalanceCheck]); /** diff --git a/src/components/cactiComponents/hooks/useAllowance.tsx b/src/components/cactiComponents/hooks/useAllowance.tsx index 5609050a9..73cbc79a9 100644 --- a/src/components/cactiComponents/hooks/useAllowance.tsx +++ b/src/components/cactiComponents/hooks/useAllowance.tsx @@ -1,5 +1,5 @@ import { useQuery } from 'react-query'; -import { Address, erc20ABI, useAccount, useContract } from 'wagmi'; +import { Address, erc20ABI, useAccount } from 'wagmi'; import { readContract } from 'wagmi/actions'; import useChainId from '@/hooks/useChainId'; diff --git a/src/components/cactiComponents/hooks/useApproval.tsx b/src/components/cactiComponents/hooks/useApproval.tsx index 127bb46a5..02e710c95 100644 --- a/src/components/cactiComponents/hooks/useApproval.tsx +++ b/src/components/cactiComponents/hooks/useApproval.tsx @@ -1,34 +1,36 @@ +//@ts-nocheck import { useMemo } from 'react'; import { useQuery } from 'react-query'; -import { AddressZero } from '@ethersproject/constants'; -import { BigNumber } from 'ethers'; -import { erc20ABI, useContractWrite, useWaitForTransaction } from 'wagmi'; +import { erc20ABI, useContractWrite, usePrepareContractWrite, useWaitForTransaction } from 'wagmi'; import { prepareWriteContract } from 'wagmi/actions'; import useChainId from '@/hooks/useChainId'; import useToken from '@/hooks/useToken'; import { cleanValue } from '@/utils'; import useAllowance from './useAllowance'; +import { zeroAddress } from 'viem'; export type ApprovalBasicParams = { - approvalAmount: BigNumber; + approvalAmount: bigint; tokenAddress: `0x${string}`; spender: `0x${string}`; skipApproval?: boolean; }; const validateAddress = (addr: `0x${string}`): `0x${string}` | undefined => - addr === AddressZero ? undefined : addr; + addr === zeroAddress ? undefined : addr; const useApproval = (params: ApprovalBasicParams) => { const chainId = useChainId(); const { approvalAmount, tokenAddress: _tokenAddress, spender: _spender } = params; + const tokenAddress = validateAddress(_tokenAddress); const spender = validateAddress(_spender); + const { data: token } = useToken(undefined, tokenAddress); // get token data from address (zero address === ETH) // cleanup the bignumber and convert back to a bignumber to avoid underlow errors; const amountToUse = useMemo( - () => BigNumber.from(cleanValue(approvalAmount.toString(), token?.decimals)), + () => BigInt(cleanValue(approvalAmount.toString(), token?.decimals)!), [approvalAmount, token?.decimals] ); @@ -40,18 +42,19 @@ const useApproval = (params: ApprovalBasicParams) => { // Prepare the approval transaction - doesn't run if address or spender is undefined const { data: config, isError: isPrepareError } = useQuery({ queryKey: ['prepareApprove', tokenAddress, spender, chainId], - queryFn: async () => { + queryFn: async () => { + // case: invalid spender if (!spender) { - console.error(`Spender not found for approval`); + console.warn(`Spender not found for approval`); return; } - - // is eth + // case: Is eth ( null token address ) if (!tokenAddress) { + console.warn(`Null token address - no approval needed`); return; } - const config = await prepareWriteContract({ + const {request} = await prepareWriteContract({ address: tokenAddress, abi: erc20ABI, functionName: 'approve', @@ -59,12 +62,12 @@ const useApproval = (params: ApprovalBasicParams) => { chainId, }); - return config; + return request; }, refetchOnWindowFocus: false, }); - const { write: approveTx, data, isLoading: isWaitingOnUser } = useContractWrite(config); + const { write: approveTx, data, isLoading: isWaitingOnUser } = useContractWrite(config || {}); const { isError, @@ -78,7 +81,7 @@ const useApproval = (params: ApprovalBasicParams) => { const hasAllowance = useMemo(() => { if (!!params.skipApproval) return true; if (!allowanceAmount) return false; - return allowanceAmount.gte(amountToUse); + return allowanceAmount >= amountToUse; }, [allowanceAmount, amountToUse, params.skipApproval]); return { diff --git a/src/components/cactiComponents/hooks/useBalance.ts b/src/components/cactiComponents/hooks/useBalance.ts index d9390beed..b7aa76bd9 100644 --- a/src/components/cactiComponents/hooks/useBalance.ts +++ b/src/components/cactiComponents/hooks/useBalance.ts @@ -1,10 +1,11 @@ +//@ts-nocheck import { useEffect, useState } from 'react'; import { useQuery } from 'react-query'; -import { BigNumber } from 'ethers'; import { useAccount } from 'wagmi'; import { fetchBalance, readContract } from 'wagmi/actions'; import erc1155ABI from '@/abi/erc1155ABI'; import useChainId from '@/hooks/useChainId'; +import { zeroAddress } from 'viem'; /** * @description gets the balance of a an account for a token address, or if no address is specified, get's eth balance @@ -12,7 +13,7 @@ import useChainId from '@/hooks/useChainId'; */ const useBalance = ( tokenAddress?: `0x${string}`, - compareAmount?: BigNumber, + compareAmount?: bigint, erc1155TokenId?: string ) => { const chainId = useChainId(); @@ -26,8 +27,8 @@ const useBalance = ( return; } - // fetch native balance - if (!tokenAddress) { + // fetch native balsance + if (!tokenAddress || tokenAddress === zeroAddress) { return ( await fetchBalance({ address: account, @@ -42,7 +43,7 @@ const useBalance = ( chainId, abi: erc1155ABI, functionName: 'balanceOf', - args: [account, BigNumber.from(erc1155TokenId)], + args: [account, BigInt(erc1155TokenId) ], }); return erc1155Bal; } @@ -64,10 +65,10 @@ const useBalance = ( useEffect(() => { if (compareAmount && data) { setComparisons({ - isZero: data.isZero(), - isGTEcompared: data.gte(compareAmount), - isEQcompared: data.eq(compareAmount), - isLTcompared: data.lt(compareAmount), + isZero: data === BigInt(0), + isGTEcompared: data >= compareAmount, + isEQcompared: data === compareAmount, + isLTcompared: data < compareAmount, }); } }, [compareAmount, data, erc1155TokenId]); diff --git a/src/components/cactiComponents/hooks/useEnsAvatar.tsx b/src/components/cactiComponents/hooks/useEnsAvatar.tsx index 1f4e13a27..5da036cd6 100644 --- a/src/components/cactiComponents/hooks/useEnsAvatar.tsx +++ b/src/components/cactiComponents/hooks/useEnsAvatar.tsx @@ -1,3 +1,4 @@ +//@ts-nocheck import { useQuery } from 'react-query'; import { useAccount } from 'wagmi'; import { fetchEnsAvatar } from 'wagmi/actions'; @@ -12,7 +13,7 @@ const useEnsAvatar = () => { queryFn: async () => address && (await fetchEnsAvatar({ - address, + name: address, // TODO check this! ? chainId, })), refetchOnWindowFocus: false, diff --git a/src/components/cactiComponents/hooks/useSubmitTx.tsx b/src/components/cactiComponents/hooks/useSubmitTx.tsx index 2f44f5377..b4e894ee3 100644 --- a/src/components/cactiComponents/hooks/useSubmitTx.tsx +++ b/src/components/cactiComponents/hooks/useSubmitTx.tsx @@ -1,9 +1,9 @@ -import { useEffect, useState } from 'react'; +import { useEffect } from 'react'; import { toast } from 'react-toastify'; -import { TransactionReceipt } from '@ethersproject/abstract-provider'; import { useAddRecentTransaction } from '@rainbow-me/rainbowkit'; -import { CallOverrides, Overrides, PayableOverrides, UnsignedTransaction } from 'ethers'; +import { TransactionReceipt, TransactionRequestBase, encodeFunctionData } from 'viem'; import { + UsePrepareContractWriteConfig, usePrepareContractWrite, usePrepareSendTransaction, useSendTransaction, @@ -11,15 +11,6 @@ import { } from 'wagmi'; import useBalance from './useBalance'; -export type TxBasicParams = { - address?: `0x${string}`; - abi?: any; - functionName?: string; - args?: any[]; - overrides?: PayableOverrides | Overrides | CallOverrides; - enabled?: boolean; -}; - /** * random UUID for any send transactions -(it is a random UUID so that it is unlikely to clash with any other contract fnName). * TODO: consider security implications of this @@ -36,8 +27,8 @@ export const SEND_ETH_FNNAME = '8bb05f0e-05ed-11ee-be56-0242ac120002'; * @param description description of tx for wallet */ const useSubmitTx = ( - params?: TxBasicParams, - sendParams?: UnsignedTransaction, + params?: UsePrepareContractWriteConfig, + sendParams?: TransactionRequestBase, onSuccess?: (receipt?: TransactionReceipt) => void, onError?: (receipt?: TransactionReceipt) => void, description?: string @@ -52,14 +43,21 @@ const useSubmitTx = ( /* prepare a write transaction */ const { config: writeConfig } = usePrepareContractWrite({ ...params, - onError: (e) => console.log('prepare contract write error', e), + onError: (e) => console.log('Prepare contract write error', e), }); /* prepare a send transaction if the fnName matches the SEND_TRANSACTION unique id */ const { config: sendConfig, isError: isPrepareError } = usePrepareSendTransaction({ - request: { ...(writeConfig.request ?? sendParams), gasLimit: sendParams?.gasLimit || 500000 }, - enabled: true, - onError: (e) => console.log('prepare send error', e), + ...(writeConfig.request + ? { + to: writeConfig.request.address, + data: encodeFunctionData({ + ...writeConfig.request, + }), + value: writeConfig.request.value, + } + : sendParams), + onError: (e) => console.log('Prepare send error', e), }); /* usePrepped data to run write or send transactions */ diff --git a/src/components/current/ChatBox.tsx b/src/components/current/ChatBox.tsx index f4849aa18..175cad938 100644 --- a/src/components/current/ChatBox.tsx +++ b/src/components/current/ChatBox.tsx @@ -6,6 +6,7 @@ import MessageList from './MessageList'; // Use experimental components import ShareChatModal from './ShareChatModal'; import WelcomeMessage from './WelcomeMessage'; +import NearWidget from './widgets/nearBos/NearWidget'; const ChatBox = () => { const { isLoading } = useQueryChats(); @@ -15,6 +16,7 @@ const ChatBox = () => { return (
+ {/* chat sharing modal*/} diff --git a/src/components/current/CustomConnectButton.tsx b/src/components/current/CustomConnectButton.tsx index 6affce287..5881e9acb 100644 --- a/src/components/current/CustomConnectButton.tsx +++ b/src/components/current/CustomConnectButton.tsx @@ -1,6 +1,6 @@ import { PowerIcon } from '@heroicons/react/24/outline'; import { ConnectButton } from '@rainbow-me/rainbowkit'; -import { formatEther } from 'ethers/lib/utils.js'; +import { formatEther } from 'viem'; import { abbreviateHash, cleanValue } from '@/utils'; import useBalance from '../cactiComponents/hooks/useBalance'; import useEnsName from '../cactiComponents/hooks/useEnsName'; diff --git a/src/components/current/MessageTranslator.tsx b/src/components/current/MessageTranslator.tsx index bedf30cb6..6e87baa3c 100644 --- a/src/components/current/MessageTranslator.tsx +++ b/src/components/current/MessageTranslator.tsx @@ -39,6 +39,7 @@ import YieldProtocolLendClose from './widgets/yield-protocol/actions/lend-close/ import YieldProtocolLend from './widgets/yield-protocol/actions/lend/YieldProtocolLend'; import ZKSyncDeposit from './widgets/zksync/ZKSyncDeposit'; import ZKSyncWithdraw from './widgets/zksync/ZKSyncWithdraw'; +import NearWidget from './widgets/nearBos/NearWidget'; /** * This function parses the args passed to a widget, @@ -325,6 +326,9 @@ export const Widget = (props: WidgetProps) => { /> ); + + widgets.set('near-bos', ); + /* If available, return the widget in the widgets map */ if (widgets.has(fnName)) { return widgets.get(fnName)!; diff --git a/src/components/current/containers/MultiStepContainer.tsx b/src/components/current/containers/MultiStepContainer.tsx index 32a0f53c4..d71b5a1d3 100644 --- a/src/components/current/containers/MultiStepContainer.tsx +++ b/src/components/current/containers/MultiStepContainer.tsx @@ -1,6 +1,5 @@ import { useEffect } from 'react'; -import { TransactionReceipt } from '@ethersproject/abstract-provider'; -import { UnsignedTransaction } from 'ethers'; +import { Address, TransactionReceipt, TransactionRequestBase } from 'viem'; import { useChatContext } from '@/contexts/ChatContext'; import { ActionResponse, HeaderResponse } from '../../cactiComponents'; import { WidgetError } from '../widgets/helpers'; @@ -123,11 +122,12 @@ export const UserActionTxType = ({ sendStepResult('error', `Transaction failed`, receipt?.transactionHash || ''); }; - const unsignedTx: UnsignedTransaction = { - to: tx?.to, - data: tx?.data, - value: tx?.value, - gasLimit: tx?.gas, + const unsignedTx: TransactionRequestBase = { + from: tx?.from as Address, + to: tx?.to as Address, + data: tx?.data as Address, + value: BigInt(tx?.value || 0), + gas: BigInt(tx?.gas || 0), }; const stepDescription = diff --git a/src/components/current/containers/SingleStepContainer.tsx b/src/components/current/containers/SingleStepContainer.tsx index 52de20d45..90b1b0055 100644 --- a/src/components/current/containers/SingleStepContainer.tsx +++ b/src/components/current/containers/SingleStepContainer.tsx @@ -1,4 +1,4 @@ -import { UnsignedTransaction } from 'ethers'; +import { Address, TransactionRequestBase } from 'viem'; import useEnsAvatar from '@/components/cactiComponents/hooks/useEnsAvatar'; import useEnsName from '@/components/cactiComponents/hooks/useEnsName'; import { ActionResponse, HeaderResponse } from '../../cactiComponents'; @@ -27,11 +27,12 @@ export const SingleStepContainer = ({ return {errorMsg}; } - const unsignedTx: UnsignedTransaction = { - to: tx?.to, - data: tx?.data, - value: tx?.value, - gasLimit: tx?.gas, + const unsignedTx: TransactionRequestBase = { + from: tx?.from as Address, + to: tx?.to as Address, + data: tx?.data as Address, + value: BigInt(tx?.value || 0), + gas: BigInt(tx?.gas || 0), }; return ( diff --git a/src/components/current/layout/header/HeaderContainer.tsx b/src/components/current/layout/header/HeaderContainer.tsx index 47cc418ac..113a2840b 100644 --- a/src/components/current/layout/header/HeaderContainer.tsx +++ b/src/components/current/layout/header/HeaderContainer.tsx @@ -24,7 +24,6 @@ const HeaderContainer = ({
{children}
-
diff --git a/src/components/current/widgets/4626vault/DepositIntoVault.tsx b/src/components/current/widgets/4626vault/DepositIntoVault.tsx index a0092d055..c893443cc 100644 --- a/src/components/current/widgets/4626vault/DepositIntoVault.tsx +++ b/src/components/current/widgets/4626vault/DepositIntoVault.tsx @@ -1,11 +1,9 @@ import { useMemo } from 'react'; -import { BigNumber } from 'ethers'; -import { parseUnits } from 'ethers/lib/utils.js'; -import { Address, useAccount } from 'wagmi'; -import ERC4626Abi from '@/abi/erc4626ABI.json'; +import { parseUnits } from 'viem'; +import { Address, UsePrepareContractWriteConfig, useAccount } from 'wagmi'; +import ERC4626Abi from '@/abi/erc4626ABI'; import { ActionResponse, HeaderResponse, TextResponse } from '@/components/cactiComponents'; import { ApprovalBasicParams } from '@/components/cactiComponents/hooks/useApproval'; -import { TxBasicParams } from '@/components/cactiComponents/hooks/useSubmitTx'; import useChainId from '@/hooks/useChainId'; import useToken from '@/hooks/useToken'; import { cleanValue } from '@/utils'; @@ -52,12 +50,15 @@ export const DepositVault = ({ depositToken, amount, vault }: DepositVaultProps) //TODO: Get the vault address const inputCleaned = cleanValue(amount.toString(), tokenIn?.decimals); - const amountIn = parseUnits(inputCleaned!, tokenIn?.decimals); + const amountIn = parseUnits(inputCleaned!, tokenIn?.decimals!); - const params: DepositVaultParams = { - assets: amountIn.toString(), - receiver: receiver!, - }; + const params = useMemo( + (): DepositVaultParams => ({ + assets: amountIn.toString(), + receiver: receiver!, + }), + [amountIn, receiver] + ); const vaultAddresss = getVaultAddress(vault, depositToken) as `0x${string}`; @@ -68,17 +69,17 @@ export const DepositVault = ({ depositToken, amount, vault }: DepositVaultProps) approvalAmount: amountIn, spender: vaultAddresss, }), - [amountIn, chainId, tokenIn] + [amountIn, tokenIn?.address, vaultAddresss] ); const tx = useMemo( - (): TxBasicParams => ({ + (): UsePrepareContractWriteConfig => ({ address: vaultAddresss, abi: ERC4626Abi, functionName: 'deposit', args: Object.values(params), }), - [amountIn, chainId, params, tokenOut?.address] + [params, vaultAddresss] ); if (amount === '*' || amount === '{amount}') @@ -94,7 +95,6 @@ export const DepositVault = ({ depositToken, amount, vault }: DepositVaultProps) label={`Deposit ${inputCleaned || ''} ${tokenInSymbol || ''} on vault`} txParams={tx} approvalParams={approval} - // disabled={true} /> ); diff --git a/src/components/current/widgets/4626vault/WithdrawFromVault.tsx b/src/components/current/widgets/4626vault/WithdrawFromVault.tsx index 6cdd29deb..4c5847c13 100644 --- a/src/components/current/widgets/4626vault/WithdrawFromVault.tsx +++ b/src/components/current/widgets/4626vault/WithdrawFromVault.tsx @@ -1,11 +1,9 @@ import { useMemo } from 'react'; -import { BigNumber } from 'ethers'; -import { parseUnits } from 'ethers/lib/utils.js'; -import { Address, useAccount } from 'wagmi'; -import ERC4626Abi from '@/abi/erc4626ABI.json'; +import { parseUnits } from 'viem'; +import { Address, UsePrepareContractWriteConfig, useAccount } from 'wagmi'; +import ERC4626Abi from '@/abi/erc4626ABI'; import { ActionResponse, HeaderResponse, TextResponse } from '@/components/cactiComponents'; import { ApprovalBasicParams } from '@/components/cactiComponents/hooks/useApproval'; -import { TxBasicParams } from '@/components/cactiComponents/hooks/useSubmitTx'; import useChainId from '@/hooks/useChainId'; import useToken from '@/hooks/useToken'; import { cleanValue } from '@/utils'; @@ -52,12 +50,15 @@ export const WithdrawVault = ({ withdrawToken, amount, vault }: WithdrawVaultPro //TODO: Get the vault address const inputCleaned = cleanValue(amount.toString(), tokenIn?.decimals); - const amountIn = parseUnits(inputCleaned!, tokenIn?.decimals); + const amountIn = parseUnits(inputCleaned!, tokenIn?.decimals!); - const params: WithdrawVaultParams = { - assets: amountIn.toString(), - receiver: receiver!, - }; + const params = useMemo( + (): WithdrawVaultParams => ({ + assets: amountIn.toString(), + receiver: receiver!, + }), + [amountIn, receiver] + ); const vaultAddresss = getVaultAddress(vault, withdrawToken) as `0x${string}`; @@ -68,17 +69,17 @@ export const WithdrawVault = ({ withdrawToken, amount, vault }: WithdrawVaultPro approvalAmount: amountIn, spender: vaultAddresss, }), - [amountIn, chainId, tokenIn] + [amountIn, tokenIn?.address, vaultAddresss] ); const tx = useMemo( - (): TxBasicParams => ({ + (): UsePrepareContractWriteConfig => ({ address: vaultAddresss, abi: ERC4626Abi, functionName: 'withdraw', args: Object.values(params), }), - [amountIn, chainId, params, tokenOut?.address] + [params, vaultAddresss] ); if (amount === '*' || amount === '{amount}') @@ -94,7 +95,6 @@ export const WithdrawVault = ({ withdrawToken, amount, vault }: WithdrawVaultPro label={`Withdraw ${inputCleaned || ''} ${tokenInSymbol || ''} on vault`} txParams={tx} approvalParams={approval} - // disabled={true} /> ); diff --git a/src/components/current/widgets/dsr/DepositDSR.tsx b/src/components/current/widgets/dsr/DepositDSR.tsx index bd40c1057..81a90bb84 100644 --- a/src/components/current/widgets/dsr/DepositDSR.tsx +++ b/src/components/current/widgets/dsr/DepositDSR.tsx @@ -1,12 +1,9 @@ import { useMemo } from 'react'; -import { BigNumber } from 'ethers'; -import { parseUnits } from 'ethers/lib/utils.js'; -import { useAccount } from 'wagmi'; -import ERC4626Abi from '@/abi/erc4626ABI.json'; +import { parseUnits } from 'viem'; +import { UsePrepareContractWriteConfig, useAccount } from 'wagmi'; +import ERC4626Abi from '@/abi/erc4626ABI'; import { ActionResponse, HeaderResponse, TextResponse } from '@/components/cactiComponents'; import { ApprovalBasicParams } from '@/components/cactiComponents/hooks/useApproval'; -import { TxBasicParams } from '@/components/cactiComponents/hooks/useSubmitTx'; -import useChainId from '@/hooks/useChainId'; import useToken from '@/hooks/useToken'; import { cleanValue } from '@/utils'; import { ConnectFirst } from '../helpers/ConnectFirst'; @@ -22,7 +19,6 @@ interface DepositDSRParams { // SavingsDAI: https://etherscan.io/address/0x83F20F44975D03b1b09e64809B757c47f942BEeA#code export const DepositDSR = ({ depositAmount }: DepositDSRProps) => { - const chainId = useChainId(); const { address: receiver } = useAccount(); // Here we use DAI as the tokenIn and SavingsDAI as tokenOut @@ -32,12 +28,15 @@ export const DepositDSR = ({ depositAmount }: DepositDSRProps) => { const { data: tokenOut } = useToken(tokenOutSymbol); const inputCleaned = cleanValue(depositAmount.toString(), tokenIn?.decimals); - const amountIn = parseUnits(inputCleaned!, tokenIn?.decimals); + const amountIn = parseUnits(inputCleaned!, tokenIn?.decimals!); - const params: DepositDSRParams = { - assets: amountIn.toString(), - receiver: receiver!, - }; + const params = useMemo( + (): DepositDSRParams => ({ + assets: amountIn.toString(), + receiver: receiver!, + }), + [amountIn, receiver] + ); // Use DAI signatures for approval const approval = useMemo( @@ -46,17 +45,17 @@ export const DepositDSR = ({ depositAmount }: DepositDSRProps) => { approvalAmount: amountIn, spender: tokenOut?.address as `0x${string}`, }), - [amountIn, chainId, tokenIn] + [amountIn, tokenIn, tokenOut] ); const tx = useMemo( - (): TxBasicParams => ({ + (): UsePrepareContractWriteConfig => ({ address: tokenOut?.address as `0x${string}`, abi: ERC4626Abi, functionName: 'deposit', args: Object.values(params), }), - [amountIn, chainId, params, tokenOut?.address] + [params, tokenOut] ); if (depositAmount === '*' || depositAmount === '{amount}') @@ -74,7 +73,6 @@ export const DepositDSR = ({ depositAmount }: DepositDSRProps) => { label={`Deposit ${inputCleaned || ''} ${tokenInSymbol || ''} on MakerDAO DSR`} txParams={tx} approvalParams={approval} - // disabled={true} /> ); diff --git a/src/components/current/widgets/dsr/RedeemDSR.tsx b/src/components/current/widgets/dsr/RedeemDSR.tsx index 44b8dd491..d6e85bd50 100644 --- a/src/components/current/widgets/dsr/RedeemDSR.tsx +++ b/src/components/current/widgets/dsr/RedeemDSR.tsx @@ -1,11 +1,9 @@ import { useMemo } from 'react'; -import { BigNumber } from 'ethers'; -import { parseUnits } from 'ethers/lib/utils.js'; -import { useAccount } from 'wagmi'; -import ERC4626Abi from '@/abi/erc4626ABI.json'; +import { parseUnits } from 'viem'; +import { UsePrepareContractWriteConfig, useAccount } from 'wagmi'; +import ERC4626Abi from '@/abi/erc4626ABI'; import { ActionResponse, HeaderResponse, TextResponse } from '@/components/cactiComponents'; import { ApprovalBasicParams } from '@/components/cactiComponents/hooks/useApproval'; -import { TxBasicParams } from '@/components/cactiComponents/hooks/useSubmitTx'; import useChainId from '@/hooks/useChainId'; import useToken from '@/hooks/useToken'; import { cleanValue } from '@/utils'; @@ -25,7 +23,6 @@ interface RedeemDSRParams { // SavingsDAI: https://etherscan.io/address/0x83F20F44975D03b1b09e64809B757c47f942BEeA#code export const RedeemDSR = ({ shares }: RedeemDSRProps) => { - const chainId = useChainId(); const { address: receiver } = useAccount(); // Here we use DAI as the tokenIn and SavingsDAI as tokenOut @@ -35,13 +32,16 @@ export const RedeemDSR = ({ shares }: RedeemDSRProps) => { const { data: tokenOut } = useToken(tokenOutSymbol); const inputCleaned = cleanValue(shares.toString(), tokenIn?.decimals); - const amountIn = parseUnits(inputCleaned!, tokenIn?.decimals); + const amountIn = parseUnits(inputCleaned!, tokenIn?.decimals!); - const params: RedeemDSRParams = { - assets: amountIn.toString(), - receiver: receiver!, - owner: receiver!, - }; + const params = useMemo( + (): RedeemDSRParams => ({ + assets: amountIn.toString(), + receiver: receiver!, + owner: receiver!, + }), + [amountIn, receiver] + ); // Use DAI signatures for approval const approval = useMemo( @@ -50,17 +50,17 @@ export const RedeemDSR = ({ shares }: RedeemDSRProps) => { approvalAmount: amountIn, spender: tokenOut?.address as `0x${string}`, }), - [amountIn, chainId, tokenIn] + [amountIn, tokenIn, tokenOut] ); const tx = useMemo( - (): TxBasicParams => ({ + (): UsePrepareContractWriteConfig => ({ address: tokenIn?.address as `0x${string}`, abi: ERC4626Abi, functionName: 'redeem', args: Object.values(params), }), - [amountIn, chainId, params, tokenOut?.address] + [params, tokenIn] ); if (shares === '*' || shares === '{amount}') diff --git a/src/components/current/widgets/frax/StakeSfrxETH.tsx b/src/components/current/widgets/frax/StakeSfrxETH.tsx index 32b61c053..68ca77a20 100644 --- a/src/components/current/widgets/frax/StakeSfrxETH.tsx +++ b/src/components/current/widgets/frax/StakeSfrxETH.tsx @@ -1,8 +1,7 @@ -import { parseUnits } from 'ethers/lib/utils.js'; -import { useAccount } from 'wagmi'; -import frxEthMinterAbi from '@/abi/frxETHMinter.json'; +import { parseEther } from 'viem'; +import { UsePrepareContractWriteConfig, useAccount } from 'wagmi'; +import frxEthMinterAbi from '@/abi/frxETHMinter'; import { ActionResponse, HeaderResponse } from '@/components/cactiComponents'; -import { TxBasicParams } from '@/components/cactiComponents/hooks/useSubmitTx'; import { ConnectFirst } from '../helpers/ConnectFirst'; interface StakedFraxEtherProps { @@ -11,16 +10,16 @@ interface StakedFraxEtherProps { } const StakeSfrxEth = ({ receiver, value }: StakedFraxEtherProps) => { - const amount = parseUnits(value, 18); + const amount = parseEther(value); const { address: account } = useAccount(); - const tx: TxBasicParams = { + const tx: UsePrepareContractWriteConfig = { address: '0xbAFA44EFE7901E04E39Dad13167D089C559c1138', // frxETHMinter address abi: frxEthMinterAbi, // frxETHMinter abi functionName: 'submitAndDeposit', args: [receiver ?? account], - overrides: { value: amount }, + value: amount, }; return ( diff --git a/src/components/current/widgets/hop/HopBridge.tsx b/src/components/current/widgets/hop/HopBridge.tsx index 03a673445..93e0d7783 100644 --- a/src/components/current/widgets/hop/HopBridge.tsx +++ b/src/components/current/widgets/hop/HopBridge.tsx @@ -1,7 +1,7 @@ import React, { useEffect, useState } from 'react'; import { Hop } from '@hop-protocol/sdk'; import { CanonicalToken, ChainSlug } from '@hop-protocol/sdk/dist/src/constants'; -import { Interface, UnsignedTransaction } from 'ethers/lib/utils'; +import { TransactionRequestBase, decodeFunctionData } from 'viem'; import { erc20ABI } from 'wagmi'; import { ActionResponse, @@ -11,8 +11,8 @@ import { } from '@/components/cactiComponents'; import { ApprovalBasicParams } from '@/components/cactiComponents/hooks/useApproval'; import useInput from '@/hooks/useInput'; -import useSigner from '@/hooks/useSigner'; import useToken from '@/hooks/useToken'; +import { useEthersSigner } from '@/utils/ethersAdapter'; interface HopBridgeProps { inputString: string; @@ -25,11 +25,11 @@ const HopBridge = ({ inputString, tokenSymbol, toChain, fromChain }: HopBridgePr const _fromChain = fromChain === 'ethereum-mainnet' ? 'mainnet' : fromChain.toLowerCase(); const _toChain = toChain === 'ethereum-mainnet' ? 'mainnet' : toChain.toLowerCase(); - const signer = useSigner(); + const signer = useEthersSigner(); const { data: tokenIn } = useToken(tokenSymbol); const input = useInput(inputString, tokenIn?.symbol!); const [approvalParams, setApprovalParams] = useState(); - const [sendParams, setSendParams] = useState(); + const [sendParams, setSendParams] = useState(); const [error, setError] = useState(null); // TODO simple check to see if the chain is potentially supported; not all chains with chain slugs are supported within hop though (i.e.: zksync is unsupported) @@ -78,11 +78,8 @@ const HopBridge = ({ inputString, tokenSymbol, toChain, fromChain }: HopBridgePr if (needsApproval) { const { data } = await bridge.populateSendApprovalTx(input.value, _fromChain); - - const erc20Interface = new Interface(erc20ABI); - - const parsed = erc20Interface.parseTransaction({ data }); - const spender = parsed.args[0]; + const { args } = decodeFunctionData({ abi: erc20ABI, data }); + const spender = args?.[0]!; setApprovalParams({ approvalAmount: input.value, @@ -92,7 +89,7 @@ const HopBridge = ({ inputString, tokenSymbol, toChain, fromChain }: HopBridgePr } const req = await bridge.populateSendTx(input.value, _fromChain, _toChain); - setSendParams({ ...req, gasLimit: 10_000_000 }); // TODO figure out a better way to handle gas limits on forks + setSendParams({ ...req, gas: BigInt(10_000_000) }); // TODO figure out a better way to handle gas limits on forks } catch (e) { setError((e as Error).message); console.error(e); diff --git a/src/components/current/widgets/lido/LidoDeposit.tsx b/src/components/current/widgets/lido/LidoDeposit.tsx index d3d22b772..4fe71697e 100644 --- a/src/components/current/widgets/lido/LidoDeposit.tsx +++ b/src/components/current/widgets/lido/LidoDeposit.tsx @@ -1,57 +1,49 @@ import { useMemo } from 'react'; -import { parseUnits } from 'ethers/lib/utils.js'; -import { Address } from 'wagmi'; -import stethAbi from '@/abi/steth.json'; +import { zeroAddress } from 'viem'; +import { Address, UsePrepareContractWriteConfig } from 'wagmi'; +import stethAbi from '@/abi/steth'; import { ActionResponse, + ErrorResponse, HeaderResponse, IconResponse, SingleLineResponse, } from '@/components/cactiComponents'; import { ResponseRow } from '@/components/cactiComponents/helpers/layout'; -import { TxBasicParams } from '@/components/cactiComponents/hooks/useSubmitTx'; +import useInput from '@/hooks/useInput'; import useToken from '@/hooks/useToken'; -import { cleanValue } from '@/utils'; interface LidoProps { - inputString: string; + inputString: number; } const LidoDeposit = ({ inputString }: LidoProps) => { const { data: tokenIn } = useToken('ETH'); const { data: tokenOut } = useToken('STETH'); + const input = useInput(inputString.toString(), tokenIn?.symbol!); - const inputCleaned = useMemo( - () => cleanValue(inputString.toString(), tokenIn?.decimals), - [inputString, tokenIn?.decimals] - ); - const value = useMemo(() => { - return parseUnits(inputCleaned!, tokenIn?.decimals); - }, [inputCleaned, tokenIn?.decimals]); - - const tx: TxBasicParams = useMemo( + const tx = useMemo( () => ({ address: tokenOut?.address as Address | undefined, abi: stethAbi, functionName: 'submit', - args: ['0x0000000000000000000000000000000000000000'], - overrides: { - value, - }, + args: [zeroAddress], + value: input?.value, }), - [tokenOut?.address, value] + [input?.value, tokenOut?.address] ); return ( <> + {!input && } - + diff --git a/src/components/current/widgets/lido/LidoWithdraw.tsx b/src/components/current/widgets/lido/LidoWithdraw.tsx index c57c2ea28..3e7168d33 100644 --- a/src/components/current/widgets/lido/LidoWithdraw.tsx +++ b/src/components/current/widgets/lido/LidoWithdraw.tsx @@ -1,15 +1,16 @@ import { useMemo } from 'react'; -import { parseUnits } from 'ethers/lib/utils.js'; -import { Address } from 'wagmi'; -import stethAbi from '@/abi/steth.json'; +import { parseEther, zeroAddress } from 'viem'; +import { Address, UsePrepareContractWriteConfig } from 'wagmi'; +import stethAbi from '@/abi/steth'; import { ActionResponse, + ErrorResponse, HeaderResponse, IconResponse, SingleLineResponse, } from '@/components/cactiComponents'; import { ResponseRow } from '@/components/cactiComponents/helpers/layout'; -import { TxBasicParams } from '@/components/cactiComponents/hooks/useSubmitTx'; +import useInput from '@/hooks/useInput'; import useToken from '@/hooks/useToken'; import { cleanValue } from '@/utils'; @@ -19,37 +20,30 @@ interface LidoProps { const LidoWithdraw = ({ inputString }: LidoProps) => { const { data: tokenIn } = useToken('STETH'); - console.log('🦄 ~ file: LidoWithdraw.tsx:22 ~ LidoWithdraw ~ tokenIn:', tokenIn); - const { data: tokenOut } = useToken('ETH'); + const input = useInput(inputString, tokenIn?.symbol!); - const inputCleaned = useMemo( - () => cleanValue(inputString.toString(), tokenIn?.decimals), - [inputString, tokenIn?.decimals] - ); - const value = useMemo(() => { - return parseUnits(inputCleaned!, tokenIn?.decimals); - }, [inputCleaned, tokenIn?.decimals]); - - const tx: TxBasicParams = useMemo( + const tx = useMemo( () => ({ - address: tokenOut?.address as Address | undefined, + address: tokenIn?.address, abi: stethAbi, - functionName: 'submit', - args: ['0x0000000000000000000000000000000000000000'], + functionName: 'submit', // TODO figure out withdraw function + args: [zeroAddress], + value: input?.value, }), - [tokenOut?.address] + [input?.value, tokenIn?.address] ); return ( <> + {!input && } - + diff --git a/src/components/current/widgets/liquity/borrow/LiquityBorrow.tsx b/src/components/current/widgets/liquity/borrow/LiquityBorrow.tsx index 1120d311f..95c45c78d 100644 --- a/src/components/current/widgets/liquity/borrow/LiquityBorrow.tsx +++ b/src/components/current/widgets/liquity/borrow/LiquityBorrow.tsx @@ -1,15 +1,15 @@ import { useEffect, useState } from 'react'; import { EthersLiquity } from '@liquity/lib-ethers'; -import { UnsignedTransaction } from 'ethers/lib/utils.js'; +import { Address, TransactionRequestBase } from 'viem'; import { ActionResponse, HeaderResponse, ListResponse, SingleLineResponse, } from '@/components/cactiComponents'; -import useSigner from '@/hooks/useSigner'; import useToken from '@/hooks/useToken'; import { cleanValue } from '@/utils'; +import { useEthersSigner } from '@/utils/ethersAdapter'; interface BorrowProps { borrowAmount: string; @@ -17,7 +17,7 @@ interface BorrowProps { } const LiquityBorrow = ({ borrowAmount, collateralAmount }: BorrowProps) => { - const signer = useSigner(); + const signer = useEthersSigner(); const { data: borrowToken } = useToken('LUSD'); const { data: collateralToken } = useToken('ETH'); const borrowCleaned = cleanValue(borrowAmount, borrowToken?.decimals); @@ -25,7 +25,7 @@ const LiquityBorrow = ({ borrowAmount, collateralAmount }: BorrowProps) => { const borrowLUSD = isNaN(+borrowCleaned!) ? 0 : +borrowCleaned!; const depositCollateral = isNaN(+collateralCleaned!) ? 0 : +collateralCleaned!; - const [sendParams, setSendParams] = useState(); + const [sendParams, setSendParams] = useState(); useEffect(() => { (async () => { @@ -35,7 +35,18 @@ const LiquityBorrow = ({ borrowAmount, collateralAmount }: BorrowProps) => { borrowLUSD, depositCollateral, }); - setSendParams(params); + + if (!params.from) { + console.error('No connected address found'); + return; + } + + setSendParams({ + to: params.to as Address | undefined, + data: params.data as Address | undefined, + from: params.from as Address, + value: BigInt(params.value?.toString() || 0), + }); })(); }, [signer, borrowLUSD, depositCollateral]); diff --git a/src/components/current/widgets/liquity/close/LiquityClose.tsx b/src/components/current/widgets/liquity/close/LiquityClose.tsx index 83dba7bc5..91d00fff7 100644 --- a/src/components/current/widgets/liquity/close/LiquityClose.tsx +++ b/src/components/current/widgets/liquity/close/LiquityClose.tsx @@ -1,14 +1,14 @@ import { useEffect, useState } from 'react'; import { EthersLiquity } from '@liquity/lib-ethers'; -import { UnsignedTransaction, formatUnits } from 'ethers/lib/utils.js'; -import { useAccount } from 'wagmi'; +import { Address, TransactionRequestBase, formatEther, formatUnits } from 'viem'; +import { useAccount, useWalletClient } from 'wagmi'; import { ActionResponse, HeaderResponse, ListResponse, SingleLineResponse, } from '@/components/cactiComponents'; -import useSigner from '@/hooks/useSigner'; +import { walletClientToSigner } from '@/utils/ethersAdapter'; interface LiquityCloseData { collateral: string; @@ -17,8 +17,9 @@ interface LiquityCloseData { const LiquityClose = () => { const { address: account } = useAccount(); - const signer = useSigner(); - const [sendParams, setSendParams] = useState(); + const { data: walletClient } = useWalletClient(); + const signer = walletClient ? walletClientToSigner(walletClient) : undefined; + const [sendParams, setSendParams] = useState(); const [data, setData] = useState(); useEffect(() => { @@ -27,11 +28,22 @@ const LiquityClose = () => { const liquity = await EthersLiquity.connect(signer); const trove = await liquity.getTrove(account); const collateral = trove.collateral.bigNumber; - const collateral_ = formatUnits(collateral, 18); // ether decimals + const collateral_ = formatEther(BigInt(collateral.toString())); // ether decimals const debt = trove.debt.bigNumber; - const debt_ = formatUnits(debt, 18); // LUSD decimals + const debt_ = formatUnits(BigInt(debt.toString()), 18); // LUSD decimals const { rawPopulatedTransaction: params } = await liquity.populate.closeTrove(); - setSendParams(params); + if (!params.from) { + console.error('No connected address found'); + return; + } + + setSendParams({ + to: params.to as Address | undefined, + data: params.data as Address | undefined, + from: params.from as Address, + value: BigInt(params.value?.toString() || 0), + }); + setData({ collateral: collateral_, debt: debt_ }); })(); }, [signer, account]); diff --git a/src/components/current/widgets/nearBos/NearWidget.tsx b/src/components/current/widgets/nearBos/NearWidget.tsx new file mode 100644 index 000000000..71a13a0bb --- /dev/null +++ b/src/components/current/widgets/nearBos/NearWidget.tsx @@ -0,0 +1,226 @@ +import React, { useCallback, useEffect, useRef, useState } from 'react'; +import Link from 'next/link'; +// import { sanitizeUrl } from '@braintree/sanitize-url'; +// import { useParams } from "react-router-dom"; +// import { useQuery } from "../hooks/useQuery"; +// import { useHashRouterLegacy } from "../hooks/useHashRouterLegacy"; +import { setupWalletSelector } from '@near-wallet-selector/core'; +import { setupModal } from '@near-wallet-selector/modal-ui'; +import { setupNearWallet } from '@near-wallet-selector/near-wallet'; +// import { setupHereWallet } from "@near-wallet-selector/here-wallet"; +// import { setupMeteorWallet } from "@near-wallet-selector/meteor-wallet"; +import { setupNeth } from '@near-wallet-selector/neth'; +import { setupNightly } from '@near-wallet-selector/nightly'; +import { setupSender } from '@near-wallet-selector/sender'; +import { Widget as BosWidget } from 'near-social-vm'; +import { EthersProviderContext, useAccount, useInitNear, useNear, utils } from 'near-social-vm'; +import { EIP1193Provider, EIP1193ProviderRpcError } from 'viem'; +// import { getProvider, disconnect, watchProvider } from '@wagmi/core' +import { useWalletClient } from 'wagmi'; +import { ResponseWrap } from '@/components/cactiComponents/helpers/layout'; +import { useEthersProviderContext } from './data/web3'; +// import Big from "big.js"; +// import { NavigationWrapper } from "./components/navigation/NavigationWrapper"; +import { NetworkId, Widgets } from './data/widgets'; + +interface NearWidgetProps { + nearUser: string; + nearWidget: string; + nearWidgetProps?: Map; +} + +function NearWidget(props: NearWidgetProps) { + const [widgetProps, setWidgetProps] = useState({}); + const src = `${props.nearUser}/widget/${props.nearWidget}`; // 'aave-v3.near/widget/AAVE'; // widgetSrc || props.widgets.default; + + // useEffect(() => { + // if (props.nearWidgetProps) setWidgetProps( + // [...props.nearWidgetProps.entries()].reduce((props_, [key, value]) => { + // props_[key] = value; + // return props_; + // }, {}) + // ); + // }, [props.nearWidgetProps]); + + const [connected, setConnected] = useState(false); + const [signedIn, setSignedIn] = useState(false); + const [signedAccountId, setSignedAccountId] = useState(null); + const [availableStorage, setAvailableStorage] = useState(null); + const [walletModal, setWalletModal] = useState(null); + const [widgetSrc, setWidgetSrc] = useState(null); + + const { initNear } = useInitNear(); + const near = useNear(); + const account = useAccount(); + + const accountId = account.accountId; + + useEffect(() => { + initNear && + initNear({ + networkId: NetworkId, + selector: setupWalletSelector({ + network: NetworkId, + modules: [ + setupNearWallet(), + // setupMyNearWallet(), + setupSender(), + // setupHereWallet(), + // setupMeteorWallet(), + setupNeth({ + gas: '300000000000000', + bundle: false, + }), + setupNightly(), + ], + }), + customElements: { + Link: (props: any) => { + if (!props.to && props.href) { + props.to = props.href; + delete props.href; + } + // if (props.to) { + // props.to = sanitizeUrl(props.to); + // } + return ; + }, + }, + config: { + defaultFinality: undefined, + }, + }); + }, [initNear]); + + useEffect(() => { + if (!near) { + return; + } + near.selector.then((selector: any) => { + setWalletModal(selector && setupModal(selector, { contractId: near.config.contractName })); + }); + }, [near]); + + const requestSignIn = useCallback( + (e: any) => { + e && e.preventDefault(); + // @ts-ignore + walletModal.show(); + return false; + }, + [walletModal] + ); + + const logOut = useCallback(async () => { + if (!near) { + return; + } + const wallet = await (await near.selector).wallet(); + wallet.signOut(); + near.accountId = null; + setSignedIn(false); + setSignedAccountId(null); + }, [near]); + + const refreshAllowance = useCallback(async () => { + alert("You're out of access key allowance. Need sign in again to refresh it"); + await logOut(); + // requestSignIn(); + }, [logOut, requestSignIn]); + // refreshAllowanceObj.refreshAllowance = refreshAllowance; + + useEffect(() => { + if (!near) { + return; + } + setSignedIn(!!accountId); + setSignedAccountId(accountId); + setConnected(true); + }, [near, accountId]); + + // useEffect(() => { + // setAvailableStorage( + // account.storageBalance + // ? Big(account.storageBalance.available).div(utils.StorageCostPerByte) + // : Big(0) + // ); + // }, [account]); + + const passProps = { + refreshAllowance: () => refreshAllowance(), + setWidgetSrc, + signedAccountId, + signedIn, + connected, + availableStorage, + widgetSrc, + logOut, + requestSignIn, + widgets: [], + documentationHref: 'https://docs.near.org/docs/develop/front-end/near-api-js', + }; + + // const ethersProviderContext = useEthersProviderContext(); + + // const [ethersProvider, setEthersProvider] = useState({ + // useConnectWallet: () => [{}], // [{ wallet, connecting }, connect, disconnect] + // setChain: () => null, + // provider: getProvider(), + // }); + + // interface WalletModule { + // label: string; + // getIcon: () => Promise; + // getInterface: (helpers: any) => Promise; + // } + // type WalletInterface = { + // provider: EIP1193Provider; + // instance?: unknown; + // }; + // const walletModuleShim = (provider: EIP1193Provider): WalletModule => { + // const label = 'lable'; + // return { + // label, + // getIcon: () => Promise.resolve(''), + // getInterface: () => Promise.resolve({ provider }), + // }; + // }; + + const { data: walletClient, isError, isLoading } = useWalletClient(); + + const useConnectWallet = () => [ + { + wallet: { + label: 'default', + getIcon: () => Promise.resolve(''), + getInterface: walletClient, + }, + connecting: false, + }, + () => console.log('connect'), + () => console.log('disconnect'), + ]; // Retun: [{ wallet, connecting }, connect, disconnect] + + const ethersProviderContext = { + provider: walletClient, + useConnectWallet, + setChain: () => null, + }; + + return ( + // + ); +} + +export default NearWidget; diff --git a/src/components/current/widgets/nearBos/data/web3.tsx b/src/components/current/widgets/nearBos/data/web3.tsx new file mode 100644 index 000000000..ac291375d --- /dev/null +++ b/src/components/current/widgets/nearBos/data/web3.tsx @@ -0,0 +1,291 @@ +import { singletonHook } from "react-singleton-hook"; +import { useEffect, useState } from "react"; + +// import ls from "local-storage"; +import icon from "../images/near_social_icon.svg"; + +import { useEthersProvider } from "@/utils/ethersPolyfill"; +// import { JsonRpcProvider } from "near-api-js/lib/providers"; + +// const web3onboardKey = "web3-onboard:connectedWallets"; + +// const wcV1InitOptions = { +// qrcodeModalOptions: { +// mobileLinks: ["metamask", "argent", "trust"], +// }, +// connectFirstChainId: true, +// }; + +// const walletConnect = walletConnectModule(wcV1InitOptions); +// const ledger = ledgerModule(); +// const injected = injectedModule(); + +// // initialize Onboard +// export const onboard = init({ +// wallets: [injected], +// chains: [ +// { +// id: 1, +// token: "ETH", +// label: "Ethereum Mainnet", +// rpcUrl: "https://rpc.ankr.com/eth", +// }, +// { +// id: 3, +// token: "ETH", +// label: "Ropsten - Ethereum Testnet", +// rpcUrl: "https://rpc.ankr.com/eth_ropsten", +// }, +// { +// id: 5, +// token: "ETH", +// label: "Goerli - Ethereum Testnet", +// rpcUrl: "https://rpc.ankr.com/eth_goerli", +// }, +// { +// id: 10, +// token: "ETH", +// label: "Optimism", +// rpcUrl: "https://rpc.ankr.com/optimism", +// }, +// { +// id: 420, +// token: "ETH", +// label: "Optimism Goerli Testnet", +// rpcUrl: "https://optimism-goerli.publicnode.com", +// }, +// { +// id: 56, +// token: "BNB", +// label: "Binance Smart Chain Mainnet", +// rpcUrl: "https://bsc.publicnode.com", +// }, +// { +// id: 97, +// token: "tBNB", +// label: "Binance Smart Chain Testnet", +// rpcUrl: "https://bsc-testnet.publicnode.com", +// }, +// { +// id: 1313161554, +// token: "ETH", +// label: "Aurora Mainnet", +// rpcUrl: "https://mainnet.aurora.dev", +// }, +// { +// id: 1313161555, +// token: "ETH", +// label: "Aurora Testnet", +// rpcUrl: "https://testnet.aurora.dev", +// }, +// { +// id: 137, +// token: "MATIC", +// label: "Polygon Mainnet", +// rpcUrl: "https://rpc.ankr.com/polygon", +// }, +// { +// id: 80001, +// token: "MATIC", +// label: "Polygon Testnet Mumbai", +// rpcUrl: "https://rpc.ankr.com/polygon_mumbai", +// }, +// { +// id: 280, +// token: "ETH", +// label: "zkSync Era Testnet", +// rpcUrl: "https://testnet.era.zksync.dev", +// }, +// { +// id: 324, +// token: "ETH", +// label: "zkSync Era Mainnet", +// rpcUrl: "https://zksync2-mainnet.zksync.io", +// }, +// { +// id: 1101, +// token: "ETH", +// label: "Polygon zkEVM", +// rpcUrl: "https://zkevm-rpc.com", +// }, +// { +// id: 1442, +// token: "ETH", +// label: "Polygon zkEVM Testnet", +// rpcUrl: "https://rpc.public.zkevm-test.net", +// }, +// { +// id: 42161, +// token: "ETH", +// label: "Arbitrum One Mainnet", +// rpcUrl: "https://arb1.arbitrum.io/rpc", +// }, +// { +// id: 42170, +// token: "ETH", +// label: "Arbitrum Nova", +// rpcUrl: "https://nova.arbitrum.io/rpc", +// }, +// { +// id: 421613, +// token: "AGOR", +// label: "Arbitrum Goerli", +// rpcUrl: "https://goerli-rollup.arbitrum.io/rpc", +// }, +// { +// id: 25, +// token: "CRO", +// label: "Cronos Mainnet Beta", +// rpcUrl: "https://evm.cronos.org", +// }, +// { +// id: 338, +// token: "TCRO", +// label: "Cronos Testnet", +// rpcUrl: "https://evm-t3.cronos.org", +// }, +// { +// id: 100, +// token: "XDAI", +// label: "Gnosis", +// rpcUrl: "https://rpc.ankr.com/gnosis", +// }, +// { +// id: 10200, +// token: "XDAI", +// label: "Gnosis Chiado Testnet", +// rpcUrl: "https://rpc.chiadochain.net", +// }, +// { +// id: 42220, +// token: "CELO", +// label: "Celo Mainnet", +// rpcUrl: "https://rpc.ankr.com/celo", +// }, +// { +// id: 44787, +// token: "CELO", +// label: "Celo Alfajores Testnet", +// rpcUrl: "https://alfajores-forno.celo-testnet.org", +// }, +// { +// id: 43114, +// token: "AVAX", +// label: "Avalanche C-Chain", +// rpcUrl: "https://rpc.ankr.com/avalanche", +// }, +// { +// id: 43113, +// token: "AVAX", +// label: "Avalanche Fuji Testnet", +// rpcUrl: "https://rpc.ankr.com/avalanche_fuji", +// }, +// { +// id: 250, +// token: "FTM", +// label: "Fantom Opera", +// rpcUrl: "https://rpc.ankr.com/fantom", +// }, +// { +// id: 4002, +// token: "FTM", +// label: "Fantom Testnet", +// rpcUrl: "https://rpc.ankr.com/fantom_testnet", +// }, +// { +// id: 1284, +// token: "GLMR", +// label: "Moonbeam", +// rpcUrl: "https://rpc.ankr.com/moonbeam", +// }, +// { +// id: 61, +// token: "ETC", +// label: "Ethereum Classic Mainnet", +// rpcUrl: "https://etc.rivet.link", +// }, +// { +// id: 84531, +// token: "ETH", +// label: "Base Goerli Testnet", +// rpcUrl: "https://goerli.base.org", +// }, +// { +// id: 8453, +// token: "ETH", +// label: "Base Mainnet", +// rpcUrl: "https://mainnet.base.org", +// }, +// ], +// appMetadata: { +// name: "NEAR Social", +// icon: './images/near_social_icon.svg', +// description: "NEAR Social", +// }, +// theme: "dark", +// containerElements: { +// // connectModal: '#near-social-navigation-bar', +// // accountCenter: "#near-social-web3-account", +// }, +// }); +interface EthersProviderContext { + provider?: any; + useConnectWallet: any; + setChain:any; +} +const defaultEthersProviderContext: EthersProviderContext = { + useConnectWallet: () => [{}], // [{ wallet, connecting }, connect, disconnect] + setChain: ()=> null, +}; + +// interface WalletModule { +// label: string; +// getIcon: () => Promise; +// getInterface: (helpers: any) => Promise; +// } +// type WalletInterface = { +// provider: EIP1193Provider; +// instance?: unknown; +// }; +// const walletModuleShim = (provider: EIP1193Provider): WalletModule => { +// const label = 'default'; +// return { +// label, +// getIcon: () => Promise.resolve(''), +// getInterface: () => Promise.resolve({ provider }), +// }; +// }; + +export const useEthersProviderContext = singletonHook( + defaultEthersProviderContext, + () => { + // const [{ wallet }] = useConnectWallet(); + const [ethersProvider, setEthersProvider] = useState( + defaultEthersProviderContext + ); + + const provider = useEthersProvider(); + + const useConnectWallet = () => [ + { wallet: + { + label: 'default', + getIcon: () => icon, + getInterface: () => Promise.resolve({ provider }), + }, + connecting: false }, + ()=>console.log('connect'), + ()=>console.log('disconnect'), + ]; // [{ wallet, connecting }, connect, disconnect] + + useEffect(() => { + setEthersProvider({ + provider, + useConnectWallet, + setChain: () => null, + }); + }, [provider]); + + return ethersProvider; + } +); diff --git a/src/components/current/widgets/nearBos/data/widgets.js b/src/components/current/widgets/nearBos/data/widgets.js new file mode 100644 index 000000000..2e67177f7 --- /dev/null +++ b/src/components/current/widgets/nearBos/data/widgets.js @@ -0,0 +1,36 @@ +const TestnetDomains = { + "test.near.social": true, + "127.0.0.1": true, +}; + +export const NetworkId = + window.location.hostname in TestnetDomains ? "testnet" : "mainnet"; +const TestnetWidgets = { + image: "eugenethedream/widget/Image", + default: "eugenethedream/widget/Welcome", + viewSource: "eugenethedream/widget/WidgetSource", + widgetMetadataEditor: "eugenethedream/widget/WidgetMetadataEditor", + widgetMetadata: "eugenethedream/widget/WidgetMetadata", + profileImage: "eugenethedream/widget/ProfileImage", + profilePage: "eugenethedream/widget/Profile", + profileName: "eugenethedream/widget/ProfileName", + notificationButton: "eugenethedream/widget/NotificationButton", +}; + +const MainnetWidgets = { + image: "mob.near/widget/Image", + default: "mob.near/widget/Homepage", + viewSource: "mob.near/widget/WidgetSource", + widgetMetadataEditor: "mob.near/widget/WidgetMetadataEditor", + widgetMetadata: "mob.near/widget/WidgetMetadata", + profileImage: "mob.near/widget/ProfileImage", + notificationButton: "mob.near/widget/NotificationButton", + profilePage: "mob.near/widget/ProfilePage", + profileName: "patrick.near/widget/ProfileName", + editorComponentSearch: "mob.near/widget/Editor.ComponentSearch", + profileInlineBlock: "mob.near/widget/Profile.InlineBlock", + viewHistory: "bozon.near/widget/WidgetHistory", +}; + +export const Widgets = + NetworkId === "testnet" ? TestnetWidgets : MainnetWidgets; diff --git a/src/components/current/widgets/nearBos/images/near_social_icon.svg b/src/components/current/widgets/nearBos/images/near_social_icon.svg new file mode 100644 index 000000000..b1e7b43ce --- /dev/null +++ b/src/components/current/widgets/nearBos/images/near_social_icon.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/components/current/widgets/nft/BuyNft.tsx b/src/components/current/widgets/nft/BuyNft.tsx index 027438a3c..893735546 100644 --- a/src/components/current/widgets/nft/BuyNft.tsx +++ b/src/components/current/widgets/nft/BuyNft.tsx @@ -1,6 +1,5 @@ -import { BigNumber } from 'ethers'; -import { usePrepareContractWrite } from 'wagmi'; -import SeaportAbi from '@/abi/SeaportAbi.json'; +import { UsePrepareContractWriteConfig, usePrepareContractWrite } from 'wagmi'; +import SeaportAbi from '@/abi/SeaportAbi'; import { ActionResponse, HeaderResponse } from '@/components/cactiComponents'; import { ImageVariant } from '@/components/cactiComponents/ImageResponse'; import { ConnectFirst } from '../helpers/ConnectFirst'; @@ -24,7 +23,7 @@ export const BuyNft = ({ protocolAddress, asset, }: BuyNftProps) => { - const tx = { + const tx: UsePrepareContractWriteConfig = { address: protocolAddress as `0x${string}`, abi: SeaportAbi, functionName: 'fulfillOrder', @@ -35,19 +34,13 @@ export const BuyNft = ({ }, '0x0000000000000000000000000000000000000000000000000000000000000000', // fulfillerConduitKey ], - overrides: { - value: BigNumber.from(orderValue || 0), - gasLimit: 500000, - }, + value: BigInt(orderValue), + gas: BigInt(500_000), }; // Simulate tx to re-verify if the NFT is for sale const { isError } = usePrepareContractWrite({ ...tx, - overrides: { - ...tx.overrides, - gasLimit: undefined, - }, }); const notForSale = !isForSale || isError; @@ -55,15 +48,7 @@ export const BuyNft = ({ return ( - + { () => cleanValue(inputString.toString(), tokenIn?.decimals), [inputString, tokenIn?.decimals] ); - const value = useMemo(() => { - return parseUnits(inputCleaned!, tokenIn?.decimals); - }, [inputCleaned, tokenIn?.decimals]); - const tx: TxBasicParams = useMemo( + const tx: UsePrepareContractWriteConfig = useMemo( () => ({ address: '0xDD3f50F8A6CafbE9b31a427582963f465E745AF8', abi: rETHAbi, functionName: 'deposit', args: [], - overrides: { - value, - }, + value: parseEther(inputCleaned!), }), - [value] + [inputCleaned] ); return ( diff --git a/src/components/current/widgets/rocketPool/rocketPoolWithdraw.tsx b/src/components/current/widgets/rocketPool/rocketPoolWithdraw.tsx index e9dc46140..424dd3265 100644 --- a/src/components/current/widgets/rocketPool/rocketPoolWithdraw.tsx +++ b/src/components/current/widgets/rocketPool/rocketPoolWithdraw.tsx @@ -1,7 +1,5 @@ import { useMemo } from 'react'; -import { parseUnits } from 'ethers/lib/utils.js'; -import { Address } from 'wagmi'; -import stethAbi from '@/abi/steth.json'; +import { Address, UsePrepareContractWriteConfig } from 'wagmi'; import { ActionResponse, HeaderResponse, @@ -9,9 +7,9 @@ import { SingleLineResponse, } from '@/components/cactiComponents'; import { ResponseRow } from '@/components/cactiComponents/helpers/layout'; -import { TxBasicParams } from '@/components/cactiComponents/hooks/useSubmitTx'; import useToken from '@/hooks/useToken'; import { cleanValue } from '@/utils'; +import rETHAbi from '@/abi/rETH'; interface RethProps { inputString: string; @@ -25,16 +23,13 @@ const RethWithdraw = ({ inputString }: RethProps) => { () => cleanValue(inputString.toString(), tokenIn?.decimals), [inputString, tokenIn?.decimals] ); - const value = useMemo(() => { - return parseUnits(inputCleaned!, tokenIn?.decimals); - }, [inputCleaned, tokenIn?.decimals]); - const tx: TxBasicParams = useMemo( + const tx: UsePrepareContractWriteConfig = useMemo( () => ({ - address: tokenOut?.address as Address | undefined, - abi: stethAbi, - functionName: 'submit', - args: ['0x0000000000000000000000000000000000000000'], + address: '0xDD3f50F8A6CafbE9b31a427582963f465E745AF8', + abi: rETHAbi, + functionName: 'burn', + args: [], }), [tokenOut?.address] ); diff --git a/src/components/current/widgets/transfer/Transfer.tsx b/src/components/current/widgets/transfer/Transfer.tsx index b804b27a5..3d97cdd74 100644 --- a/src/components/current/widgets/transfer/Transfer.tsx +++ b/src/components/current/widgets/transfer/Transfer.tsx @@ -1,8 +1,7 @@ -import { AddressZero } from '@ethersproject/constants'; -import { parseUnits } from 'ethers/lib/utils.js'; +import { useMemo } from 'react'; +import { parseUnits} from 'viem'; import { erc20ABI, useAccount, useEnsAddress } from 'wagmi'; import { ActionResponse, HeaderResponse } from '@/components/cactiComponents'; -import { SEND_ETH_FNNAME } from '@/components/cactiComponents/hooks/useSubmitTx'; import useToken from '@/hooks/useToken'; import { ConnectFirst } from '../helpers/ConnectFirst'; @@ -13,38 +12,29 @@ interface TransferWidgetProps { } const Transfer = ({ tokenSymbol, amtString, receiver }: TransferWidgetProps) => { + const { address: account } = useAccount(); const { isETH, data: token } = useToken(tokenSymbol); - const amount = parseUnits(amtString, token?.decimals); + const amount = parseUnits(amtString, token?.decimals!); - // Resolve ENS name - const { data: receiverAddress } = useEnsAddress({ - name: receiver, + // Resolve ENS name, if needed + const { data: addressFromName } = useEnsAddress({ + name: receiver.trimStart().slice(2) === '0x' ? undefined : receiver, // only run if string doesnt start with 0x }); - if (!isETH && !token) return null; // if not eth, and there is no token - abort. + const receiverAddress = useMemo(() => { + if (addressFromName) return addressFromName; + return receiver as `0x${string}`; + }, [addressFromName, receiver]); - const approval = { - approvalAmount: amount, - tokenAddress: token!.address as `0x${string}`, - spender: AddressZero as `0x${string}`, - skipApproval: true, - }; + if (!isETH && !token) return null; // if not eth, and there is no token - abort. /* tx parameters to transfer ETH */ - const tx = isETH - ? { - address: undefined, - abi: undefined, - functionName: SEND_ETH_FNNAME, - args: [receiverAddress ? receiverAddress : (receiver as `0x${string}`), amount], - } - : /* tx parameters to transfer an ERC20 token */ - { - address: token!.address as `0x${string}`, - abi: erc20ABI, - functionName: 'transfer', - args: [receiverAddress ? receiverAddress : (receiver as `0x${string}`), amount], - }; + const tx = { + address: token!.address as `0x${string}`, + abi: erc20ABI, + functionName: 'transfer', + args: [receiverAddress, amount], + }; /* TODO Transfer NFT */ /* TODO Transfer ERC721 */ @@ -57,9 +47,9 @@ const Transfer = ({ tokenSymbol, amtString, receiver }: TransferWidgetProps) => /> ); diff --git a/src/components/current/widgets/tx-replay/TransactionReplay.tsx b/src/components/current/widgets/tx-replay/TransactionReplay.tsx index 25ce2120e..222d4b873 100644 --- a/src/components/current/widgets/tx-replay/TransactionReplay.tsx +++ b/src/components/current/widgets/tx-replay/TransactionReplay.tsx @@ -1,7 +1,7 @@ +//@ts-nocheck import React, { useCallback, useEffect, useState } from 'react'; -import { BigNumber, UnsignedTransaction, ethers } from 'ethers'; -import { decodeFunctionData } from 'viem'; -import { Address, useTransaction } from 'wagmi'; +import { TransactionRequestBase, decodeFunctionData, encodeFunctionData, getAddress } from 'viem'; +import { Address, useAccount, useTransaction } from 'wagmi'; import { ActionResponse, HeaderResponse, SingleLineResponse } from '@/components/cactiComponents'; import SkeletonWrap from '@/components/shared/SkeletonWrap'; import useAbi from '@/hooks/useAbi'; @@ -12,16 +12,17 @@ interface TransactionReplayProps { } const TransactionReplay = ({ txHash }: TransactionReplayProps) => { + const { address: account } = useAccount(); const { data, isLoading } = useTransaction({ hash: txHash }); - const { data: abi } = useAbi(data?.to as Address | undefined); - const [sendParams, setSendParams] = useState(); + const { data: abi } = useAbi(data?.to); + const [sendParams, setSendParams] = useState(); const [isError, setIsError] = useState(false); const explorerUrl = `https://etherscan.io/tx/${txHash}`; // State to hold editable fields, stored as strings for simplicity const [decoded, setDecoded] = useState<{ - to?: string; + to: Address; value: string; functionName?: string; args?: { @@ -33,7 +34,7 @@ const TransactionReplay = ({ txHash }: TransactionReplayProps) => { // handle decoding the transaction data const handleDecode = useCallback(() => { - if (!data) return console.log('no data'); + if (!data?.input || !data.to) return console.log('no data'); if (!abi) { console.log('no abi, is possibly an eth/native currency transfer'); return setDecoded({ @@ -48,7 +49,7 @@ const TransactionReplay = ({ txHash }: TransactionReplayProps) => { let functionName: string; try { - const decoded = decodeFunctionData({ abi, data: data.data as Address }); + const decoded = decodeFunctionData({ abi, data: data.input }); args = decoded.args as string[]; functionName = decoded.functionName; } catch (e) { @@ -110,7 +111,7 @@ const TransactionReplay = ({ txHash }: TransactionReplayProps) => { } // handle changing the to param if (name === 'to') { - setDecoded((d) => d && { ...d, to: value }); + setDecoded((d) => d && { ...d, to: getAddress(value) }); return; } @@ -126,16 +127,16 @@ const TransactionReplay = ({ txHash }: TransactionReplayProps) => { }); }; - const getSendParams = useCallback((): UnsignedTransaction | undefined => { + const getSendParams = useCallback((): TransactionRequestBase | undefined => { if (!decoded) { console.error('Decoded data is missing'); return; } // Initialize a transaction object - let transaction: Partial = { + let transaction: Partial = { to: decoded.to, - value: BigNumber.from(decoded.value), + value: BigInt(decoded.value), }; // If it's a simple transfer @@ -155,15 +156,13 @@ const TransactionReplay = ({ txHash }: TransactionReplayProps) => { return arg.value; }) || []; - // Create the function signature - const functionTypes = decoded.args.map((arg) => arg.type).join(','); - const functionSignature = `${decoded.functionName}(${functionTypes})`; - - // Create the encoded data field for contract interaction - const iface = new ethers.utils.Interface(abi); try { // Encode the function data - const data = iface.encodeFunctionData(functionSignature, convertedArgs); + const data = encodeFunctionData({ + abi, + functionName: decoded.functionName, + args: convertedArgs, + }); transaction.data = data; // Now, you can populate the transaction object and pass it to ActionResponse } catch (e) { @@ -171,8 +170,8 @@ const TransactionReplay = ({ txHash }: TransactionReplayProps) => { } } - setSendParams(transaction); - }, [abi, decoded]); + setSendParams({ from: account!, ...transaction }); + }, [abi, account, decoded]); useEffect(() => { getSendParams(); @@ -205,7 +204,7 @@ const TransactionReplay = ({ txHash }: TransactionReplayProps) => { />
))} - {BigNumber.from(decoded.value)?.gt(ethers.constants.Zero) && decoded.to && ( + {BigInt(decoded.value) > BigInt(0) && decoded.to && ( <>