From f061f69f55a660146bbc3247dded252faef04a99 Mon Sep 17 00:00:00 2001 From: ross <92001561+z0r0z@users.noreply.github.com> Date: Thu, 28 Mar 2024 08:51:11 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9C=B5=201.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gas-snapshot | 18 +- README.md | 42 +- abi/DeploymentV1.json | 539 -------- abi/IE.json | 1240 +++++++++--------- docs/src/README.md | 28 +- docs/src/src/IE.sol/contract.IE.md | 44 +- docs/src/src/IE.sol/interface.IExecutor.md | 2 +- docs/src/src/IE.sol/interface.INAMI.md | 2 +- docs/src/src/IE.sol/interface.ISwapRouter.md | 2 +- docs/src/src/IE.sol/interface.IToken.md | 2 +- docs/src/src/NAMI.sol/contract.NAMI.md | 2 +- docs/src/src/NAMI.sol/interface.IToken.md | 2 +- src/IE.sol | 21 - test/IE.t.sol | 2 - 14 files changed, 664 insertions(+), 1282 deletions(-) delete mode 100644 abi/DeploymentV1.json diff --git a/.gas-snapshot b/.gas-snapshot index 129862d..c0fa0d3 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -1,14 +1,14 @@ -IETest:testCommandDepositETH() (gas: 154672) +IETest:testCommandDepositETH() (gas: 155598) IETest:testCommandSendETH() (gas: 75320) IETest:testCommandSendETHRawAddr() (gas: 75755) -IETest:testCommandStakeETH() (gas: 147764) -IETest:testCommandSwapDAI() (gas: 137475) -IETest:testCommandSwapETH() (gas: 168371) -IETest:testCommandSwapForETH() (gas: 144376) -IETest:testCommandSwapUSDC() (gas: 171415) -IETest:testCommandSwapUSDCForWBTC() (gas: 196380) -IETest:testCommandUnstakeETH() (gas: 261654) -IETest:testCommandWithdrawETH() (gas: 264357) +IETest:testCommandStakeETH() (gas: 147756) +IETest:testCommandSwapDAI() (gas: 138503) +IETest:testCommandSwapETH() (gas: 138209) +IETest:testCommandSwapForETH() (gas: 145404) +IETest:testCommandSwapUSDC() (gas: 171497) +IETest:testCommandSwapUSDCForWBTC() (gas: 196200) +IETest:testCommandUnstakeETH() (gas: 263506) +IETest:testCommandWithdrawETH() (gas: 266209) IETest:testDeploy() (gas: 2563979) IETest:testENSNameOwnership() (gas: 48424) IETest:testIENameSetting() (gas: 11105) diff --git a/README.md b/README.md index acdac9c..7910b4a 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,18 @@ -# [IE](https://github.com/NaniDAO/IE) [![License: AGPL-3.0-only](https://img.shields.io/badge/License-AGPL-black.svg)](https://opensource.org/license/agpl-v3/) [![solidity](https://img.shields.io/badge/solidity-%5E0.8.25-black)](https://docs.soliditylang.org/en/v0.8.25/) [![Foundry](https://img.shields.io/badge/Built%20with-Foundry-000000.svg)](https://getfoundry.sh/) ![tests](https://github.com/z0r0z/zenplate/actions/workflows/ci.yml/badge.svg) +# [`IE`](https://github.com/NaniDAO/IE) [![License: AGPL-3.0-only](https://img.shields.io/badge/License-AGPL-black.svg)](https://opensource.org/license/agpl-v3/) [![solidity](https://img.shields.io/badge/solidity-%5E0.8.25-black)](https://docs.soliditylang.org/en/v0.8.25/) [![Foundry](https://img.shields.io/badge/Built%20with-Foundry-000000.svg)](https://getfoundry.sh/) ![tests](https://github.com/z0r0z/zenplate/actions/workflows/ci.yml/badge.svg) -The **Intents Engine** (IE): A Basic *Text-to-tx* Simulator Contract. +The **Intents Engine** (`IE`): A Basic *Text-to-tx* Simulator Contract. -<<<<<<< HEAD ## Deployments ### Mainnet -V1: [`0x1E00000000Cf8ba83e0005c59c1Bf1C4682C8E00`](https://etherscan.io/address/0x1e00000000cf8ba83e0005c59c1bf1c4682c8e00#code) +`V1:` [`0x1E00000000Cf8ba83e0005c59c1Bf1C4682C8E00`](https://etherscan.io/address/0x1e00000000cf8ba83e0005c59c1bf1c4682c8e00#code) ### Arbitrum -V1.2: [`0x1e00003a669bb466d6B49800000099E1abDD6600`](https://arbiscan.io/address/0x1e00003a669bb466d6b49800000099e1abdd6600#code) +`V1.2:` [`0x1e00003a669bb466d6B49800000099E1abDD6600`](https://arbiscan.io/address/0x1e00003a669bb466d6b49800000099e1abdd6600#code) -`Note:` L2 will be used to rapidly prototype a stable and sufficient IE for common crypto commands. Many dev resources here will cater to the current L2 prototype until the release of V2 on L1. -======= -## Deployment - -### IE V1 - -#### Ethereum Mainnet (L1) - -[`0x1E00000000Cf8ba83e0005c59c1Bf1C4682C8E00`](https://etherscan.io/address/0x1e00000000cf8ba83e0005c59c1bf1c4682c8e00#code) - -##### Deployed Bytecode - -[`QmZVdxJyTCJBF7gfE5BrSavCHtMDScZjpLYH5qaMExhW49`](https://content.wrappr.wtf/ipfs/QmZVdxJyTCJBF7gfE5BrSavCHtMDScZjpLYH5qaMExhW49) ->>>>>>> main +`Note:` L2 will be used to rapidly prototype a stable and sufficient `IE` for common crypto commands. Many dev resources here will cater to the current L2 prototype until the release of `V2` on L1. ## Uses @@ -36,13 +22,13 @@ From natural language: - Security checkpoint (forbid tx) - Command translation (make tx) -IE should deterministically and transparently operate to provide these utilities in an uncensorable medium like a Solidity smart contract. +`IE` should deterministically and transparently operate to provide these utilities in an uncensorable medium like a Solidity smart contract. [`V1`](./src/IE.sol) is a POC of this. [*Short demo and explainer thread on X.*](https://x.com/z0r0zzz/status/1758392014737920209?s=20) ## Command Syntax (⌘) -IE is approaching things from first-principles and a "show" rather than "tell" approach. There will be some experimentation. +`IE` is approaching things from first-principles and a "show" rather than "tell" approach. There will be some experimentation. Some things in `V1` are likely very underoptimized for this particular use case. @@ -86,21 +72,21 @@ aliases: *exchange* aliases: *exchange* -Note: In `V1.1` on Arbitrum, a `minOutputAmount` can be specified for swaps. It ensures that you receive a minimum output amount of `object` at the end of the swap, otherwise the transaction will revert. The default value is set to `0`. +`Note:` In `V1.2` on Arbitrum, a `minOutputAmount` can be specified for swaps. It ensures that you receive a minimum output amount of `object` at the end of the swap, otherwise the transaction will revert. The default value is set to `0`. ------------------------------------ -Phrases are provided in the order in which they are most expected. They are "naturalized" to lower case. The IE contract automatically does this, but front-ends should nonetheless try and format as close as possible (*i.e.*, through a simple LLM trained or prompted on these examples below). +Phrases are provided in the order in which they are most expected. They are "naturalized" to lower case. The `IE` contract automatically does this, but front-ends should nonetheless try and format as close as possible (*i.e.*, through a simple LLM trained or prompted on these examples below). -In terms of usual English, we assume the subject of each command is the user account which is more explicit in the case of checking an ERC4337 userOp (where `sender` is the user). And the `object` receives assets or contract calls. `value` is the token or ETH amount involved in the action and the `asset` is the particular item sent or issued from (initially ETH or ERC20 to cover fungibles and most immediate security needs that could benefit from IE). +In terms of usual English, we assume the subject of each command is the user account which is more explicit in the case of checking an ERC4337 userOp (where `sender` is the user). And the `object` receives assets or contract calls. `value` is the token or ETH amount involved in the action and the `asset` is the particular item sent or issued from (initially ETH or ERC20 to cover fungibles and most immediate security needs that could benefit from `IE`). -You MUST include spaces in the string provided to IE in order for it to understand word separation. +You **MUST** include spaces in the string provided to `IE` in order for it to understand word separation. -Note: `to/for` is an identified filler word common to most of the transactions we will cover so it is highlighted. +`Note:` `to/for` is an identified filler word common to most of the transactions we will cover so it is highlighted. As you might notice, there are patterns. Because after all this is typical language and logic we are talking about here. For example, `value` will precede `asset`. `object` will either follow the `action` or be at the end. If at the end, there will be a filler of `for/to`. (Yeah I know this is what people learn in grammar schools but the exercise will likely yield good results.) -Also, let's try and be as helpful as possible at the top of the command funnel. E.g., if there is `msg.value` in a command, then we should assume ETH is involved. +Also, let's try and be as helpful as possible at the top of the command funnel. *E.g.*, if there is `msg.value` in a command, then we should assume ETH is involved. Actions should also have aliases to catch more cases. Though it will be cheaper to use the primary word (for example, 'send' or 'swap' with preference to familiarity, and if there indecision, the shorter), it is helpful to do more and catch different ways of phrasing transactional commands, like "send" can equate to "transfer" when it comes to onchain assets. Adhering to Solidity and smart contract functions themselves in word choice makes the most sense as well (*e.g.*, ETH.*send*/*transfer*, IERC20.*transfer*, UNI.*swap*, CURVE.*exchange*). @@ -110,7 +96,7 @@ Run: `curl -L https://foundry.paradigm.xyz | bash && source ~/.bashrc && foundry Build the foundry project with `forge build`. Run tests with `forge test`. Measure gas with `forge snapshot`. Format with `forge fmt`. -*Note:* Tests currently run on a fork of mainnet to check ENS properly. +`Note:` Tests currently run on a virtual blockchain fork to check ENS properly. ## Blueprint diff --git a/abi/DeploymentV1.json b/abi/DeploymentV1.json deleted file mode 100644 index 23d0bf4..0000000 --- a/abi/DeploymentV1.json +++ /dev/null @@ -1,539 +0,0 @@ -{ - "contracts": [ - { - "name": "IE", - "address": "0x1E00000000Cf8ba83e0005c59c1Bf1C4682C8E00", - "version": "1.0.0", - "abi": [ - { - "type": "constructor", - "inputs": [], - "stateMutability": "payable" - }, - { - "type": "fallback", - "stateMutability": "payable" - }, - { - "type": "receive", - "stateMutability": "payable" - }, - { - "type": "function", - "name": "checkPackedUserOp", - "inputs": [ - { - "name": "intent", - "type": "string", - "internalType": "string" - }, - { - "name": "userOp", - "type": "tuple", - "internalType": "struct IE.PackedUserOperation", - "components": [ - { - "name": "sender", - "type": "address", - "internalType": "address" - }, - { - "name": "nonce", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "initCode", - "type": "bytes", - "internalType": "bytes" - }, - { - "name": "callData", - "type": "bytes", - "internalType": "bytes" - }, - { - "name": "accountGasLimits", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "preVerificationGas", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "gasFees", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "paymasterAndData", - "type": "bytes", - "internalType": "bytes" - }, - { - "name": "signature", - "type": "bytes", - "internalType": "bytes" - } - ] - } - ], - "outputs": [ - { - "name": "", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "checkUserOp", - "inputs": [ - { - "name": "intent", - "type": "string", - "internalType": "string" - }, - { - "name": "userOp", - "type": "tuple", - "internalType": "struct IE.UserOperation", - "components": [ - { - "name": "sender", - "type": "address", - "internalType": "address" - }, - { - "name": "nonce", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "initCode", - "type": "bytes", - "internalType": "bytes" - }, - { - "name": "callData", - "type": "bytes", - "internalType": "bytes" - }, - { - "name": "callGasLimit", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "verificationGasLimit", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "preVerificationGas", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "maxFeePerGas", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "maxPriorityFeePerGas", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "paymasterAndData", - "type": "bytes", - "internalType": "bytes" - }, - { - "name": "signature", - "type": "bytes", - "internalType": "bytes" - } - ] - } - ], - "outputs": [ - { - "name": "", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "command", - "inputs": [ - { - "name": "intent", - "type": "string", - "internalType": "string" - } - ], - "outputs": [], - "stateMutability": "payable" - }, - { - "type": "function", - "name": "previewCommand", - "inputs": [ - { - "name": "intent", - "type": "string", - "internalType": "string" - } - ], - "outputs": [ - { - "name": "to", - "type": "address", - "internalType": "address" - }, - { - "name": "amount", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "token", - "type": "address", - "internalType": "address" - }, - { - "name": "callData", - "type": "bytes", - "internalType": "bytes" - }, - { - "name": "executeCallData", - "type": "bytes", - "internalType": "bytes" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "previewSend", - "inputs": [ - { - "name": "to", - "type": "string", - "internalType": "string" - }, - { - "name": "amount", - "type": "string", - "internalType": "string" - }, - { - "name": "token", - "type": "string", - "internalType": "string" - } - ], - "outputs": [ - { - "name": "_to", - "type": "address", - "internalType": "address" - }, - { - "name": "_amount", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "_token", - "type": "address", - "internalType": "address" - }, - { - "name": "callData", - "type": "bytes", - "internalType": "bytes" - }, - { - "name": "executeCallData", - "type": "bytes", - "internalType": "bytes" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "previewSwap", - "inputs": [ - { - "name": "amountIn", - "type": "string", - "internalType": "string" - }, - { - "name": "tokenIn", - "type": "string", - "internalType": "string" - }, - { - "name": "tokenOut", - "type": "string", - "internalType": "string" - } - ], - "outputs": [ - { - "name": "_amountIn", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "_tokenIn", - "type": "address", - "internalType": "address" - }, - { - "name": "_tokenOut", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "send", - "inputs": [ - { - "name": "to", - "type": "string", - "internalType": "string" - }, - { - "name": "amount", - "type": "string", - "internalType": "string" - }, - { - "name": "token", - "type": "string", - "internalType": "string" - } - ], - "outputs": [], - "stateMutability": "payable" - }, - { - "type": "function", - "name": "setName", - "inputs": [ - { - "name": "token", - "type": "address", - "internalType": "address" - }, - { - "name": "name", - "type": "string", - "internalType": "string" - } - ], - "outputs": [], - "stateMutability": "payable" - }, - { - "type": "function", - "name": "setNameAndTicker", - "inputs": [ - { - "name": "token", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "payable" - }, - { - "type": "function", - "name": "swap", - "inputs": [ - { - "name": "amountIn", - "type": "string", - "internalType": "string" - }, - { - "name": "tokenIn", - "type": "string", - "internalType": "string" - }, - { - "name": "tokenOut", - "type": "string", - "internalType": "string" - } - ], - "outputs": [], - "stateMutability": "payable" - }, - { - "type": "function", - "name": "tokens", - "inputs": [ - { - "name": "name", - "type": "string", - "internalType": "string" - } - ], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "whatIsTheAddressOf", - "inputs": [ - { - "name": "name", - "type": "string", - "internalType": "string" - } - ], - "outputs": [ - { - "name": "owner", - "type": "address", - "internalType": "address" - }, - { - "name": "receiver", - "type": "address", - "internalType": "address" - }, - { - "name": "node", - "type": "bytes32", - "internalType": "bytes32" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "whatIsTheBalanceOf", - "inputs": [ - { - "name": "name", - "type": "string", - "internalType": "string" - }, - { - "name": "token", - "type": "string", - "internalType": "string" - } - ], - "outputs": [ - { - "name": "balance", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "balanceAdjusted", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "whatIsTheTotalSupplyOf", - "inputs": [ - { - "name": "token", - "type": "string", - "internalType": "string" - } - ], - "outputs": [ - { - "name": "supply", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "supplyAdjusted", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "event", - "name": "NameSet", - "inputs": [ - { - "name": "token", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "name", - "type": "string", - "indexed": false, - "internalType": "string" - } - ], - "anonymous": false - }, - { - "type": "error", - "name": "InvalidCharacter", - "inputs": [] - }, - { - "type": "error", - "name": "InvalidSwap", - "inputs": [] - }, - { - "type": "error", - "name": "InvalidSyntax", - "inputs": [] - }, - { - "type": "error", - "name": "Overflow", - "inputs": [] - }, - { - "type": "error", - "name": "Unauthorized", - "inputs": [] - } - ] - } - ] - } - \ No newline at end of file diff --git a/abi/IE.json b/abi/IE.json index 6c2e6d0..da2aad5 100644 --- a/abi/IE.json +++ b/abi/IE.json @@ -1,621 +1,621 @@ [ - { - "type": "constructor", - "inputs": [], - "stateMutability": "payable" - }, - { - "type": "fallback", - "stateMutability": "payable" - }, - { - "type": "receive", - "stateMutability": "payable" - }, - { - "type": "function", - "name": "checkPackedUserOp", - "inputs": [ - { - "name": "intent", - "type": "string", - "internalType": "string" - }, - { - "name": "userOp", - "type": "tuple", - "internalType": "struct IE.PackedUserOperation", - "components": [ - { - "name": "sender", - "type": "address", - "internalType": "address" - }, - { - "name": "nonce", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "initCode", - "type": "bytes", - "internalType": "bytes" - }, - { - "name": "callData", - "type": "bytes", - "internalType": "bytes" - }, - { - "name": "accountGasLimits", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "preVerificationGas", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "gasFees", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "paymasterAndData", - "type": "bytes", - "internalType": "bytes" - }, - { - "name": "signature", - "type": "bytes", - "internalType": "bytes" - } - ] - } - ], - "outputs": [ - { - "name": "", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "checkUserOp", - "inputs": [ - { - "name": "intent", - "type": "string", - "internalType": "string" - }, - { - "name": "userOp", - "type": "tuple", - "internalType": "struct IE.UserOperation", - "components": [ - { - "name": "sender", - "type": "address", - "internalType": "address" - }, - { - "name": "nonce", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "initCode", - "type": "bytes", - "internalType": "bytes" - }, - { - "name": "callData", - "type": "bytes", - "internalType": "bytes" - }, - { - "name": "callGasLimit", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "verificationGasLimit", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "preVerificationGas", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "maxFeePerGas", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "maxPriorityFeePerGas", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "paymasterAndData", - "type": "bytes", - "internalType": "bytes" - }, - { - "name": "signature", - "type": "bytes", - "internalType": "bytes" - } - ] - } - ], - "outputs": [ - { - "name": "", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "command", - "inputs": [ - { - "name": "intent", - "type": "string", - "internalType": "string" - } - ], - "outputs": [], - "stateMutability": "payable" - }, - { - "type": "function", - "name": "pairs", - "inputs": [ - { - "name": "token0", - "type": "address", - "internalType": "address" - }, - { - "name": "token1", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "previewCommand", - "inputs": [ - { - "name": "intent", - "type": "string", - "internalType": "string" - } - ], - "outputs": [ - { - "name": "to", - "type": "address", - "internalType": "address" - }, - { - "name": "amount", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "minAmountOut", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "token", - "type": "address", - "internalType": "address" - }, - { - "name": "callData", - "type": "bytes", - "internalType": "bytes" - }, - { - "name": "executeCallData", - "type": "bytes", - "internalType": "bytes" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "previewSend", - "inputs": [ - { - "name": "to", - "type": "string", - "internalType": "string" - }, - { - "name": "amount", - "type": "string", - "internalType": "string" - }, - { - "name": "token", - "type": "string", - "internalType": "string" - } - ], - "outputs": [ - { - "name": "_to", - "type": "address", - "internalType": "address" - }, - { - "name": "_amount", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "_token", - "type": "address", - "internalType": "address" - }, - { - "name": "callData", - "type": "bytes", - "internalType": "bytes" - }, - { - "name": "executeCallData", - "type": "bytes", - "internalType": "bytes" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "previewSwap", - "inputs": [ - { - "name": "amountIn", - "type": "string", - "internalType": "string" - }, - { - "name": "amountOutMinimum", - "type": "string", - "internalType": "string" - }, - { - "name": "tokenIn", - "type": "string", - "internalType": "string" - }, - { - "name": "tokenOut", - "type": "string", - "internalType": "string" - } - ], - "outputs": [ - { - "name": "_amountIn", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "_amountOut", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "_tokenIn", - "type": "address", - "internalType": "address" - }, - { - "name": "_tokenOut", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "send", - "inputs": [ - { - "name": "to", - "type": "string", - "internalType": "string" - }, - { - "name": "amount", - "type": "string", - "internalType": "string" - }, - { - "name": "token", - "type": "string", - "internalType": "string" - } - ], - "outputs": [], - "stateMutability": "payable" - }, - { - "type": "function", - "name": "setName", - "inputs": [ - { - "name": "token", - "type": "address", - "internalType": "address" - }, - { - "name": "name", - "type": "string", - "internalType": "string" - } - ], - "outputs": [], - "stateMutability": "payable" - }, - { - "type": "function", - "name": "setNameAndTicker", - "inputs": [ - { - "name": "token", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "payable" - }, - { - "type": "function", - "name": "setPair", - "inputs": [ - { - "name": "tokenA", - "type": "address", - "internalType": "address" - }, - { - "name": "tokenB", - "type": "address", - "internalType": "address" - }, - { - "name": "pair", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "payable" - }, - { - "type": "function", - "name": "swap", - "inputs": [ - { - "name": "amountIn", - "type": "string", - "internalType": "string" - }, - { - "name": "amountOutMinimum", - "type": "string", - "internalType": "string" - }, - { - "name": "tokenIn", - "type": "string", - "internalType": "string" - }, - { - "name": "tokenOut", - "type": "string", - "internalType": "string" - } - ], - "outputs": [], - "stateMutability": "payable" - }, - { - "type": "function", - "name": "tokens", - "inputs": [ - { - "name": "name", - "type": "string", - "internalType": "string" - } - ], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "whatIsTheAddressOf", - "inputs": [ - { - "name": "name", - "type": "string", - "internalType": "string" - } - ], - "outputs": [ - { - "name": "owner", - "type": "address", - "internalType": "address" - }, - { - "name": "receiver", - "type": "address", - "internalType": "address" - }, - { - "name": "node", - "type": "bytes32", - "internalType": "bytes32" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "whatIsTheBalanceOf", - "inputs": [ - { - "name": "name", - "type": "string", - "internalType": "string" - }, - { - "name": "token", - "type": "string", - "internalType": "string" - } - ], - "outputs": [ - { - "name": "balance", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "balanceAdjusted", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "whatIsTheTotalSupplyOf", - "inputs": [ - { - "name": "token", - "type": "string", - "internalType": "string" - } - ], - "outputs": [ - { - "name": "supply", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "supplyAdjusted", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "event", - "name": "NameSet", - "inputs": [ - { - "name": "token", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "name", - "type": "string", - "indexed": false, - "internalType": "string" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "PairSet", - "inputs": [ - { - "name": "token0", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "token1", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "pair", - "type": "address", - "indexed": false, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "error", - "name": "InsufficientSwap", - "inputs": [] - }, - { - "type": "error", - "name": "InvalidCharacter", - "inputs": [] - }, - { - "type": "error", - "name": "InvalidSwap", - "inputs": [] - }, - { - "type": "error", - "name": "InvalidSyntax", - "inputs": [] - }, - { - "type": "error", - "name": "Overflow", - "inputs": [] - } - ] \ No newline at end of file + { + "type": "constructor", + "inputs": [], + "stateMutability": "payable" + }, + { + "type": "fallback", + "stateMutability": "payable" + }, + { + "type": "receive", + "stateMutability": "payable" + }, + { + "type": "function", + "name": "checkPackedUserOp", + "inputs": [ + { + "name": "intent", + "type": "string", + "internalType": "string" + }, + { + "name": "userOp", + "type": "tuple", + "internalType": "struct IE.PackedUserOperation", + "components": [ + { + "name": "sender", + "type": "address", + "internalType": "address" + }, + { + "name": "nonce", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "initCode", + "type": "bytes", + "internalType": "bytes" + }, + { + "name": "callData", + "type": "bytes", + "internalType": "bytes" + }, + { + "name": "accountGasLimits", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "preVerificationGas", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "gasFees", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "paymasterAndData", + "type": "bytes", + "internalType": "bytes" + }, + { + "name": "signature", + "type": "bytes", + "internalType": "bytes" + } + ] + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "checkUserOp", + "inputs": [ + { + "name": "intent", + "type": "string", + "internalType": "string" + }, + { + "name": "userOp", + "type": "tuple", + "internalType": "struct IE.UserOperation", + "components": [ + { + "name": "sender", + "type": "address", + "internalType": "address" + }, + { + "name": "nonce", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "initCode", + "type": "bytes", + "internalType": "bytes" + }, + { + "name": "callData", + "type": "bytes", + "internalType": "bytes" + }, + { + "name": "callGasLimit", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "verificationGasLimit", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "preVerificationGas", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "maxFeePerGas", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "maxPriorityFeePerGas", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "paymasterAndData", + "type": "bytes", + "internalType": "bytes" + }, + { + "name": "signature", + "type": "bytes", + "internalType": "bytes" + } + ] + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "command", + "inputs": [ + { + "name": "intent", + "type": "string", + "internalType": "string" + } + ], + "outputs": [], + "stateMutability": "payable" + }, + { + "type": "function", + "name": "pairs", + "inputs": [ + { + "name": "token0", + "type": "address", + "internalType": "address" + }, + { + "name": "token1", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "previewCommand", + "inputs": [ + { + "name": "intent", + "type": "string", + "internalType": "string" + } + ], + "outputs": [ + { + "name": "to", + "type": "address", + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "minAmountOut", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "token", + "type": "address", + "internalType": "address" + }, + { + "name": "callData", + "type": "bytes", + "internalType": "bytes" + }, + { + "name": "executeCallData", + "type": "bytes", + "internalType": "bytes" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "previewSend", + "inputs": [ + { + "name": "to", + "type": "string", + "internalType": "string" + }, + { + "name": "amount", + "type": "string", + "internalType": "string" + }, + { + "name": "token", + "type": "string", + "internalType": "string" + } + ], + "outputs": [ + { + "name": "_to", + "type": "address", + "internalType": "address" + }, + { + "name": "_amount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "_token", + "type": "address", + "internalType": "address" + }, + { + "name": "callData", + "type": "bytes", + "internalType": "bytes" + }, + { + "name": "executeCallData", + "type": "bytes", + "internalType": "bytes" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "previewSwap", + "inputs": [ + { + "name": "amountIn", + "type": "string", + "internalType": "string" + }, + { + "name": "amountOutMinimum", + "type": "string", + "internalType": "string" + }, + { + "name": "tokenIn", + "type": "string", + "internalType": "string" + }, + { + "name": "tokenOut", + "type": "string", + "internalType": "string" + } + ], + "outputs": [ + { + "name": "_amountIn", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "_amountOut", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "_tokenIn", + "type": "address", + "internalType": "address" + }, + { + "name": "_tokenOut", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "send", + "inputs": [ + { + "name": "to", + "type": "string", + "internalType": "string" + }, + { + "name": "amount", + "type": "string", + "internalType": "string" + }, + { + "name": "token", + "type": "string", + "internalType": "string" + } + ], + "outputs": [], + "stateMutability": "payable" + }, + { + "type": "function", + "name": "setName", + "inputs": [ + { + "name": "token", + "type": "address", + "internalType": "address" + }, + { + "name": "name", + "type": "string", + "internalType": "string" + } + ], + "outputs": [], + "stateMutability": "payable" + }, + { + "type": "function", + "name": "setNameAndTicker", + "inputs": [ + { + "name": "token", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "payable" + }, + { + "type": "function", + "name": "setPair", + "inputs": [ + { + "name": "tokenA", + "type": "address", + "internalType": "address" + }, + { + "name": "tokenB", + "type": "address", + "internalType": "address" + }, + { + "name": "pair", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "payable" + }, + { + "type": "function", + "name": "swap", + "inputs": [ + { + "name": "amountIn", + "type": "string", + "internalType": "string" + }, + { + "name": "amountOutMinimum", + "type": "string", + "internalType": "string" + }, + { + "name": "tokenIn", + "type": "string", + "internalType": "string" + }, + { + "name": "tokenOut", + "type": "string", + "internalType": "string" + } + ], + "outputs": [], + "stateMutability": "payable" + }, + { + "type": "function", + "name": "tokens", + "inputs": [ + { + "name": "name", + "type": "string", + "internalType": "string" + } + ], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "whatIsTheAddressOf", + "inputs": [ + { + "name": "name", + "type": "string", + "internalType": "string" + } + ], + "outputs": [ + { + "name": "owner", + "type": "address", + "internalType": "address" + }, + { + "name": "receiver", + "type": "address", + "internalType": "address" + }, + { + "name": "node", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "whatIsTheBalanceOf", + "inputs": [ + { + "name": "name", + "type": "string", + "internalType": "string" + }, + { + "name": "token", + "type": "string", + "internalType": "string" + } + ], + "outputs": [ + { + "name": "balance", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "balanceAdjusted", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "whatIsTheTotalSupplyOf", + "inputs": [ + { + "name": "token", + "type": "string", + "internalType": "string" + } + ], + "outputs": [ + { + "name": "supply", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "supplyAdjusted", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "event", + "name": "NameSet", + "inputs": [ + { + "name": "token", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "name", + "type": "string", + "indexed": false, + "internalType": "string" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "PairSet", + "inputs": [ + { + "name": "token0", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "token1", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "pair", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "error", + "name": "InsufficientSwap", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidCharacter", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidSwap", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidSyntax", + "inputs": [] + }, + { + "type": "error", + "name": "Overflow", + "inputs": [] + } +] \ No newline at end of file diff --git a/docs/src/README.md b/docs/src/README.md index c2742b7..7910b4a 100644 --- a/docs/src/README.md +++ b/docs/src/README.md @@ -1,18 +1,18 @@ -# [IE](https://github.com/NaniDAO/IE) [![License: AGPL-3.0-only](https://img.shields.io/badge/License-AGPL-black.svg)](https://opensource.org/license/agpl-v3/) [![solidity](https://img.shields.io/badge/solidity-%5E0.8.25-black)](https://docs.soliditylang.org/en/v0.8.25/) [![Foundry](https://img.shields.io/badge/Built%20with-Foundry-000000.svg)](https://getfoundry.sh/) ![tests](https://github.com/z0r0z/zenplate/actions/workflows/ci.yml/badge.svg) +# [`IE`](https://github.com/NaniDAO/IE) [![License: AGPL-3.0-only](https://img.shields.io/badge/License-AGPL-black.svg)](https://opensource.org/license/agpl-v3/) [![solidity](https://img.shields.io/badge/solidity-%5E0.8.25-black)](https://docs.soliditylang.org/en/v0.8.25/) [![Foundry](https://img.shields.io/badge/Built%20with-Foundry-000000.svg)](https://getfoundry.sh/) ![tests](https://github.com/z0r0z/zenplate/actions/workflows/ci.yml/badge.svg) -The **Intents Engine** (IE): A Basic *Text-to-tx* Simulator Contract. +The **Intents Engine** (`IE`): A Basic *Text-to-tx* Simulator Contract. ## Deployments ### Mainnet -V1: [`0x1E00000000Cf8ba83e0005c59c1Bf1C4682C8E00`](https://etherscan.io/address/0x1e00000000cf8ba83e0005c59c1bf1c4682c8e00#code) +`V1:` [`0x1E00000000Cf8ba83e0005c59c1Bf1C4682C8E00`](https://etherscan.io/address/0x1e00000000cf8ba83e0005c59c1bf1c4682c8e00#code) ### Arbitrum -V1.2: [`0x1e00003a669bb466d6B49800000099E1abDD6600`](https://arbiscan.io/address/0x1e00003a669bb466d6b49800000099e1abdd6600#code) +`V1.2:` [`0x1e00003a669bb466d6B49800000099E1abDD6600`](https://arbiscan.io/address/0x1e00003a669bb466d6b49800000099e1abdd6600#code) -Note: L2 will be used to rapidly prototype a stable and sufficient IE for common crypto commands. Many dev resources here will cater to the current L2 prototype until the release of V2 on L1. +`Note:` L2 will be used to rapidly prototype a stable and sufficient `IE` for common crypto commands. Many dev resources here will cater to the current L2 prototype until the release of `V2` on L1. ## Uses @@ -22,13 +22,13 @@ From natural language: - Security checkpoint (forbid tx) - Command translation (make tx) -IE should deterministically and transparently operate to provide these utilities in an uncensorable medium like a Solidity smart contract. +`IE` should deterministically and transparently operate to provide these utilities in an uncensorable medium like a Solidity smart contract. [`V1`](./src/IE.sol) is a POC of this. [*Short demo and explainer thread on X.*](https://x.com/z0r0zzz/status/1758392014737920209?s=20) ## Command Syntax (⌘) -IE is approaching things from first-principles and a "show" rather than "tell" approach. There will be some experimentation. +`IE` is approaching things from first-principles and a "show" rather than "tell" approach. There will be some experimentation. Some things in `V1` are likely very underoptimized for this particular use case. @@ -72,21 +72,21 @@ aliases: *exchange* aliases: *exchange* -Note: In `V1.1` on Arbitrum, a `minOutputAmount` can be specified for swaps. It ensures that you receive a minimum output amount of `object` at the end of the swap, otherwise the transaction will revert. The default value is set to `0`. +`Note:` In `V1.2` on Arbitrum, a `minOutputAmount` can be specified for swaps. It ensures that you receive a minimum output amount of `object` at the end of the swap, otherwise the transaction will revert. The default value is set to `0`. ------------------------------------ -Phrases are provided in the order in which they are most expected. They are "naturalized" to lower case. The IE contract automatically does this, but front-ends should nonetheless try and format as close as possible (*i.e.*, through a simple LLM trained or prompted on these examples below). +Phrases are provided in the order in which they are most expected. They are "naturalized" to lower case. The `IE` contract automatically does this, but front-ends should nonetheless try and format as close as possible (*i.e.*, through a simple LLM trained or prompted on these examples below). -In terms of usual English, we assume the subject of each command is the user account which is more explicit in the case of checking an ERC4337 userOp (where `sender` is the user). And the `object` receives assets or contract calls. `value` is the token or ETH amount involved in the action and the `asset` is the particular item sent or issued from (initially ETH or ERC20 to cover fungibles and most immediate security needs that could benefit from IE). +In terms of usual English, we assume the subject of each command is the user account which is more explicit in the case of checking an ERC4337 userOp (where `sender` is the user). And the `object` receives assets or contract calls. `value` is the token or ETH amount involved in the action and the `asset` is the particular item sent or issued from (initially ETH or ERC20 to cover fungibles and most immediate security needs that could benefit from `IE`). -You MUST include spaces in the string provided to IE in order for it to understand word separation. +You **MUST** include spaces in the string provided to `IE` in order for it to understand word separation. -Note: `to/for` is an identified filler word common to most of the transactions we will cover so it is highlighted. +`Note:` `to/for` is an identified filler word common to most of the transactions we will cover so it is highlighted. As you might notice, there are patterns. Because after all this is typical language and logic we are talking about here. For example, `value` will precede `asset`. `object` will either follow the `action` or be at the end. If at the end, there will be a filler of `for/to`. (Yeah I know this is what people learn in grammar schools but the exercise will likely yield good results.) -Also, let's try and be as helpful as possible at the top of the command funnel. E.g., if there is `msg.value` in a command, then we should assume ETH is involved. +Also, let's try and be as helpful as possible at the top of the command funnel. *E.g.*, if there is `msg.value` in a command, then we should assume ETH is involved. Actions should also have aliases to catch more cases. Though it will be cheaper to use the primary word (for example, 'send' or 'swap' with preference to familiarity, and if there indecision, the shorter), it is helpful to do more and catch different ways of phrasing transactional commands, like "send" can equate to "transfer" when it comes to onchain assets. Adhering to Solidity and smart contract functions themselves in word choice makes the most sense as well (*e.g.*, ETH.*send*/*transfer*, IERC20.*transfer*, UNI.*swap*, CURVE.*exchange*). @@ -96,7 +96,7 @@ Run: `curl -L https://foundry.paradigm.xyz | bash && source ~/.bashrc && foundry Build the foundry project with `forge build`. Run tests with `forge test`. Measure gas with `forge snapshot`. Format with `forge fmt`. -*Note:* Tests currently run on a fork of mainnet to check ENS properly. +`Note:` Tests currently run on a virtual blockchain fork to check ENS properly. ## Blueprint diff --git a/docs/src/src/IE.sol/contract.IE.md b/docs/src/src/IE.sol/contract.IE.md index 38d9db4..dd5a7e3 100644 --- a/docs/src/src/IE.sol/contract.IE.md +++ b/docs/src/src/IE.sol/contract.IE.md @@ -1,5 +1,5 @@ # IE -[Git Source](https://github.com/NaniDAO/ie/blob/f31f555ae821c0432ed1c7cd6e93b1e7bba98a37/src/IE.sol) +[Git Source](https://github.com/NaniDAO/ie/blob/6d1168cdd42d680ba733a4cce0562383696cbd44/src/IE.sol) **Author:** nani.eth (https://github.com/NaniDAO/ie) @@ -209,7 +209,6 @@ function previewCommand(string calldata intent) address to, uint256 amount, uint256 minAmountOut, - uint256 minAmountOut, address token, bytes memory callData, bytes memory executeCallData @@ -241,12 +240,6 @@ function previewSend(string memory to, string memory amount, string memory token ```solidity -function previewSwap( - string memory amountIn, - string memory amountOutMinimum, - string memory tokenIn, - string memory tokenOut -) function previewSwap( string memory amountIn, string memory amountOutMinimum, @@ -257,7 +250,6 @@ function previewSwap( view virtual returns (uint256 _amountIn, uint256 _amountOut, address _tokenIn, address _tokenOut); - returns (uint256 _amountIn, uint256 _amountOut, address _tokenIn, address _tokenOut); ``` ### checkUserOp @@ -344,12 +336,6 @@ function swap( string memory tokenIn, string memory tokenOut ) public payable virtual; -function swap( - string memory amountIn, - string memory amountOutMinimum, - string memory tokenIn, - string memory tokenOut -) public payable virtual; ``` ### fallback @@ -556,12 +542,6 @@ function _extractSwap(string memory normalizedIntent) string memory tokenIn, string memory tokenOut ); - returns ( - string memory amountIn, - string memory amountOutMinimum, - string memory tokenIn, - string memory tokenOut - ); ``` ### _split @@ -681,14 +661,6 @@ error InvalidCharacter(); *Insufficient swap output.* -```solidity -error InsufficientSwap(); -``` - -### InsufficientSwap -*Insufficient swap output.* - - ```solidity error InsufficientSwap(); ``` @@ -734,20 +706,6 @@ struct PackedUserOperation { } ``` -### SwapDetails -*The `swap` command details.* - - -```solidity -struct SwapDetails { - address tokenIn; - address tokenOut; - uint256 amountIn; - bool ETHIn; - bool ETHOut; -} -``` - ### SwapInfo *The `swap` command information struct.* diff --git a/docs/src/src/IE.sol/interface.IExecutor.md b/docs/src/src/IE.sol/interface.IExecutor.md index e544b52..8d076ca 100644 --- a/docs/src/src/IE.sol/interface.IExecutor.md +++ b/docs/src/src/IE.sol/interface.IExecutor.md @@ -1,5 +1,5 @@ # IExecutor -[Git Source](https://github.com/NaniDAO/ie/blob/f31f555ae821c0432ed1c7cd6e93b1e7bba98a37/src/IE.sol) +[Git Source](https://github.com/NaniDAO/ie/blob/6d1168cdd42d680ba733a4cce0562383696cbd44/src/IE.sol) Simple calldata executor interface. diff --git a/docs/src/src/IE.sol/interface.INAMI.md b/docs/src/src/IE.sol/interface.INAMI.md index a2ef0b7..b8935d6 100644 --- a/docs/src/src/IE.sol/interface.INAMI.md +++ b/docs/src/src/IE.sol/interface.INAMI.md @@ -1,5 +1,5 @@ # INAMI -[Git Source](https://github.com/NaniDAO/ie/blob/f31f555ae821c0432ed1c7cd6e93b1e7bba98a37/src/IE.sol) +[Git Source](https://github.com/NaniDAO/ie/blob/6d1168cdd42d680ba733a4cce0562383696cbd44/src/IE.sol) *Simple NAMI names interface for resolving L2 ENS ownership.* diff --git a/docs/src/src/IE.sol/interface.ISwapRouter.md b/docs/src/src/IE.sol/interface.ISwapRouter.md index 7276427..fd48cf8 100644 --- a/docs/src/src/IE.sol/interface.ISwapRouter.md +++ b/docs/src/src/IE.sol/interface.ISwapRouter.md @@ -1,5 +1,5 @@ # ISwapRouter -[Git Source](https://github.com/NaniDAO/ie/blob/f31f555ae821c0432ed1c7cd6e93b1e7bba98a37/src/IE.sol) +[Git Source](https://github.com/NaniDAO/ie/blob/6d1168cdd42d680ba733a4cce0562383696cbd44/src/IE.sol) *Simple Uniswap V3 swapping interface.* diff --git a/docs/src/src/IE.sol/interface.IToken.md b/docs/src/src/IE.sol/interface.IToken.md index 4f4b72f..d1732e5 100644 --- a/docs/src/src/IE.sol/interface.IToken.md +++ b/docs/src/src/IE.sol/interface.IToken.md @@ -1,5 +1,5 @@ # IToken -[Git Source](https://github.com/NaniDAO/ie/blob/f31f555ae821c0432ed1c7cd6e93b1e7bba98a37/src/IE.sol) +[Git Source](https://github.com/NaniDAO/ie/blob/6d1168cdd42d680ba733a4cce0562383696cbd44/src/IE.sol) *Simple token transfer interface.* diff --git a/docs/src/src/NAMI.sol/contract.NAMI.md b/docs/src/src/NAMI.sol/contract.NAMI.md index c91d21c..aa4975f 100644 --- a/docs/src/src/NAMI.sol/contract.NAMI.md +++ b/docs/src/src/NAMI.sol/contract.NAMI.md @@ -1,5 +1,5 @@ # NAMI -[Git Source](https://github.com/NaniDAO/ie/blob/f31f555ae821c0432ed1c7cd6e93b1e7bba98a37/src/NAMI.sol) +[Git Source](https://github.com/NaniDAO/ie/blob/6d1168cdd42d680ba733a4cce0562383696cbd44/src/NAMI.sol) **Author:** nani.eth (https://github.com/NaniDAO/ie) diff --git a/docs/src/src/NAMI.sol/interface.IToken.md b/docs/src/src/NAMI.sol/interface.IToken.md index 1baf29f..76ff225 100644 --- a/docs/src/src/NAMI.sol/interface.IToken.md +++ b/docs/src/src/NAMI.sol/interface.IToken.md @@ -1,5 +1,5 @@ # IToken -[Git Source](https://github.com/NaniDAO/ie/blob/f31f555ae821c0432ed1c7cd6e93b1e7bba98a37/src/NAMI.sol) +[Git Source](https://github.com/NaniDAO/ie/blob/6d1168cdd42d680ba733a4cce0562383696cbd44/src/NAMI.sol) *Simple token balance & supply interface.* diff --git a/src/IE.sol b/src/IE.sol index 530f66b..7b857de 100644 --- a/src/IE.sol +++ b/src/IE.sol @@ -37,9 +37,6 @@ contract IE { /// @dev Insufficient swap output. error InsufficientSwap(); - /// @dev Insufficient swap output. - error InsufficientSwap(); - /// =========================== EVENTS =========================== /// /// @dev Logs the registration of a token name. @@ -171,7 +168,6 @@ contract IE { address to, // Receiver address. uint256 amount, // Formatted amount. uint256 minAmountOut, // Formatted amount. - uint256 minAmountOut, // Formatted amount. address token, // Asset to send `to`. bytes memory callData, // Raw calldata for send transaction. bytes memory executeCallData // Anticipates common execute API. @@ -225,12 +221,6 @@ contract IE { } /// @dev Previews a `swap` command from the parts of a matched intent string. - function previewSwap( - string memory amountIn, - string memory amountOutMinimum, - string memory tokenIn, - string memory tokenOut - ) function previewSwap( string memory amountIn, string memory amountOutMinimum, @@ -241,7 +231,6 @@ contract IE { view virtual returns (uint256 _amountIn, uint256 _amountOut, address _tokenIn, address _tokenOut) - returns (uint256 _amountIn, uint256 _amountOut, address _tokenIn, address _tokenOut) { uint256 decimalsIn; uint256 decimalsOut; @@ -261,7 +250,6 @@ contract IE { virtual returns (bool) { - (,,,,, bytes memory executeCallData) = previewCommand(intent); (,,,,, bytes memory executeCallData) = previewCommand(intent); if (executeCallData.length != userOp.callData.length) return false; return keccak256(executeCallData) == keccak256(userOp.callData); @@ -274,7 +262,6 @@ contract IE { virtual returns (bool) { - (,,,,, bytes memory executeCallData) = previewCommand(intent); (,,,,, bytes memory executeCallData) = previewCommand(intent); if (executeCallData.length != userOp.callData.length) return false; return keccak256(executeCallData) == keccak256(userOp.callData); @@ -688,18 +675,10 @@ contract IE { string memory tokenIn, string memory tokenOut ) - returns ( - string memory amountIn, - string memory amountOutMinimum, - string memory tokenIn, - string memory tokenOut - ) { string[] memory parts = _split(normalizedIntent, " "); if (parts.length == 5) return (parts[1], "", parts[2], parts[4]); if (parts.length == 6) return (parts[1], parts[4], parts[2], parts[5]); - if (parts.length == 5) return (parts[1], "", parts[2], parts[4]); - if (parts.length == 6) return (parts[1], parts[4], parts[2], parts[5]); else revert InvalidSyntax(); // Command is not formatted. } diff --git a/test/IE.t.sol b/test/IE.t.sol index 6481647..2b6a1e8 100644 --- a/test/IE.t.sol +++ b/test/IE.t.sol @@ -98,7 +98,6 @@ contract IETest is Test { function testPreviewCommandSendUSDC() public payable { string memory command = "send z0r0z 20 usdc"; (address to, uint256 amount,, address asset,,) = ie.previewCommand(command); - (address to, uint256 amount,, address asset,,) = ie.previewCommand(command); assertEq(to, Z0R0Z_DOT_ETH); assertEq(amount, 20000000); assertEq(asset, USDC); @@ -185,7 +184,6 @@ contract IETest is Test { IERC20(USDC).approve(address(ie), 100 ether); vm.prank(USDC_WHALE); ie.command("swap 100 usdc for 0.025 weth"); - ie.command("swap 100 usdc for 0.025 weth"); } function testCommandSwapUSDCForWBTC() public payable {