Skip to content

Commit

Permalink
🪡 Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
z0r0z committed Feb 15, 2024
1 parent 5144f5d commit 4807287
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
27 changes: 14 additions & 13 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
IETest:testBalanceInERC20() (gas: 49207)
IETest:testBalanceInETH() (gas: 40311)
IETest:testCommandSendERC0() (gas: 102992)
IETest:testCommandSendETH() (gas: 69474)
IETest:testCommandSendUSDC() (gas: 135722)
IETest:testCommandSwapDAI() (gas: 101799)
IETest:testCommandSwapETH() (gas: 112631)
IETest:testCommandSwapForETH() (gas: 123820)
IETest:testCommandSwapUSDC() (gas: 157152)
IETest:testDeploy() (gas: 2653217)
IETest:testBalanceInETH() (gas: 40333)
IETest:testCommandSendERC0() (gas: 102975)
IETest:testCommandSendETH() (gas: 69457)
IETest:testCommandSendUSDC() (gas: 135705)
IETest:testCommandSwapDAI() (gas: 101758)
IETest:testCommandSwapETH() (gas: 113623)
IETest:testCommandSwapForETH() (gas: 123797)
IETest:testCommandSwapUSDC() (gas: 157117)
IETest:testCommandSwapUSDCForWBTC() (gas: 165063)
IETest:testDeploy() (gas: 2636395)
IETest:testENSNameOwnership() (gas: 84066)
IETest:testIENameSetting() (gas: 8209)
IETest:testPreviewCommandSendDecimals() (gas: 91984)
IETest:testPreviewCommandSendUSDC() (gas: 66091)
IETest:testIENameSetting() (gas: 8142)
IETest:testPreviewCommandSendDecimals() (gas: 91972)
IETest:testPreviewCommandSendUSDC() (gas: 66096)
IETest:testPreviewSend() (gas: 42673)
IETest:testPreviewSendCommand() (gas: 54549)
IETest:testPreviewSendCommand() (gas: 54554)
IETest:testSendETH() (gas: 59695)
IETest:testTotalSupply() (gas: 14844)
4 changes: 2 additions & 2 deletions src/IE.sol
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ contract IE {
{
string memory normalized = _lowercase(intent);
bytes32 action = _extraction(normalized);
if (action == "send" || action == "transfer" || action == "give") {
if (action == "send" || action == "transfer") {
(string memory _to, string memory _amount, string memory _token) =
_extractSend(normalized);
(to, amount, token, callData, executeCallData) = previewSend(_to, _amount, _token);
Expand Down Expand Up @@ -261,7 +261,7 @@ contract IE {
function command(string calldata intent) public payable virtual {
string memory normalized = _lowercase(intent);
bytes32 action = _extraction(normalized);
if (action == "send" || action == "transfer" || action == "give") {
if (action == "send" || action == "transfer") {
(string memory to, string memory amount, string memory token) = _extractSend(normalized);
send(to, amount, token);
} else if (action == "swap" || action == "exchange") {
Expand Down
12 changes: 12 additions & 0 deletions test/IE.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ contract IETest is Test {
address internal constant UNI = 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984;
address internal constant USDT = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
address internal constant OMG = 0xd26114cd6EE289AccF82350c8d8487fedB8A0C07;
address internal constant WBTC = 0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599;

address internal constant VITALIK_DOT_ETH = 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045;
address internal constant Z0R0Z_DOT_ETH = 0x1C0Aa8cCD568d90d61659F060D1bFb1e6f855A20;
Expand Down Expand Up @@ -201,6 +202,17 @@ contract IETest is Test {
vm.prank(USDC_WHALE);
ie.command("swap 100 usdc for weth");
}

function testCommandSwapUSDCForWBTC() public payable {
uint256 startBalUSDC = IERC20(USDC).balanceOf(USDC_WHALE);
uint256 startBalWBTC = IERC20(WBTC).balanceOf(USDC_WHALE);
vm.prank(USDC_WHALE);
IERC20(USDC).approve(address(ie), 100 ether);
vm.prank(USDC_WHALE);
ie.command("swap 100 usdc for wbtc");
assert(startBalWBTC < IERC20(WBTC).balanceOf(USDC_WHALE));
assertEq(startBalUSDC - 100 * 10 ** 6, IERC20(USDC).balanceOf(USDC_WHALE));
}
}

interface IERC20 {
Expand Down

0 comments on commit 4807287

Please sign in to comment.