Skip to content

Commit

Permalink
revert steth (#331)
Browse files Browse the repository at this point in the history
* Revert "add (un)/wrapping for steth (#317)"

This reverts commit bdb2942.

* Revert "deploy UniversalRouter v1.3 to mainnet and goerli (#320)"

This reverts commit 0250714.

* fix: fixup steth leftovers

* feat: update snaps

* fix: eric comments

* fix: fixed readme

---------

Co-authored-by: Austin Adams <[email protected]>
  • Loading branch information
marktoda and aadams authored Jan 4, 2024
1 parent 7d763cb commit 5060892
Show file tree
Hide file tree
Showing 36 changed files with 12 additions and 372 deletions.
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,7 @@ Each command is a `bytes1` containing the following 8 bits:
├──────┼───────────────────────────────┤
│ 0x22 │ APPROVE_ERC20 │
├──────┼───────────────────────────────┤
│ 0x23 │ WRAP_STETH │
├──────┼───────────────────────────────┤
│ 0x24 │ UNWRAP_STETH │
├──────┼───────────────────────────────┤
│ 0x25-│ ------- │
│ 0x23-│ ------- │
│ 0x3f │ │
└──────┴───────────────────────────────┘
```
Expand Down
6 changes: 1 addition & 5 deletions contracts/UniversalRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ contract UniversalRouter is IUniversalRouter, Dispatcher, RewardsCollector {
UniswapImmutables(
UniswapParameters(params.v2Factory, params.v3Factory, params.pairInitCodeHash, params.poolInitCodeHash)
)
PaymentsImmutables(
PaymentsParameters(
params.permit2, params.weth9, params.steth, params.wsteth, params.openseaConduit, params.sudoswap
)
)
PaymentsImmutables(PaymentsParameters(params.permit2, params.weth9, params.openseaConduit, params.sudoswap))
NFTImmutables(
NFTParameters(
params.seaportV1_5,
Expand Down
18 changes: 1 addition & 17 deletions contracts/base/Dispatcher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -351,24 +351,8 @@ abstract contract Dispatcher is NFTImmutables, Payments, V2SwapRouter, V3SwapRou
spender := calldataload(add(inputs.offset, 0x20))
}
Payments.approveERC20(token, spender);
} else if (command == Commands.WRAP_STETH) {
address recipient;
uint256 amount;
assembly {
recipient := calldataload(inputs.offset)
amount := calldataload(add(inputs.offset, 0x20))
}
Payments.wrapSTETH(map(recipient), amount);
} else if (command == Commands.UNWRAP_STETH) {
address recipient;
uint256 amountMin;
assembly {
recipient := calldataload(inputs.offset)
amountMin := calldataload(add(inputs.offset, 0x20))
}
Payments.unwrapSTETH(map(recipient), amountMin);
} else {
// placeholder area for commands 0x25-0x3f
// placeholder area for commands 0x23-0x3f
revert InvalidCommandType(command);
}
}
Expand Down
2 changes: 0 additions & 2 deletions contracts/base/RouterImmutables.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ pragma solidity ^0.8.17;
struct RouterParameters {
address permit2;
address weth9;
address steth;
address wsteth;
address seaportV1_5;
address seaportV1_4;
address openseaConduit;
Expand Down
9 changes: 0 additions & 9 deletions contracts/interfaces/external/ISTETH.sol

This file was deleted.

24 changes: 0 additions & 24 deletions contracts/interfaces/external/IWSTETH.sol

This file was deleted.

5 changes: 1 addition & 4 deletions contracts/libraries/Commands.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,5 @@ library Commands {
uint256 constant SEAPORT_V1_4 = 0x20;
uint256 constant EXECUTE_SUB_PLAN = 0x21;
uint256 constant APPROVE_ERC20 = 0x22;
uint256 constant WRAP_STETH = 0x23;
uint256 constant UNWRAP_STETH = 0x24;

// COMMAND_PLACEHOLDER for 0x25 to 0x3f (all unused)
// COMMAND_PLACEHOLDER for 0x23 to 0x3f (all unused)
}
43 changes: 1 addition & 42 deletions contracts/modules/Payments.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ abstract contract Payments is PaymentsImmutables {

error InsufficientToken();
error InsufficientETH();
error InsufficientSTETH();
error InvalidBips();
error InvalidSpender();

Expand All @@ -33,6 +32,7 @@ abstract contract Payments is PaymentsImmutables {
if (value == Constants.CONTRACT_BALANCE) {
value = ERC20(token).balanceOf(address(this));
}

ERC20(token).safeTransfer(recipient, value);
}
}
Expand Down Expand Up @@ -137,45 +137,4 @@ abstract contract Payments is PaymentsImmutables {
}
}
}

/// @notice Wrap an amount of stETH into wstETH
/// @param recipient The recipient of the wstETH
/// @param amount The amount of wstETH desired
function wrapSTETH(address recipient, uint256 amount) internal {
if (amount == Constants.CONTRACT_BALANCE) {
amount = STETH.balanceOf(address(this));
} else if (amount > STETH.balanceOf(address(this))) {
revert InsufficientSTETH();
}

if (amount > 0) {
if (STETH.allowance(address(this), address(WSTETH)) < amount) {
STETH.approve(address(WSTETH), type(uint256).max);
}

amount = WSTETH.wrap(amount);

if (recipient != address(this)) {
WSTETH.transfer(recipient, amount);
}
}
}

/// @notice Unwraps all of the contract's wstETH into stETH
/// @param recipient The recipient of the stETH
/// @param amountMinimum The minimum amount of stETH desired
function unwrapSTETH(address recipient, uint256 amountMinimum) internal {
uint256 balanceWSTETH = WSTETH.balanceOf(address(this));
if (balanceWSTETH > 0) {
uint256 amountSTETH = WSTETH.unwrap(balanceWSTETH);

if (amountSTETH < amountMinimum) {
revert InsufficientSTETH();
}

if (recipient != address(this)) {
STETH.transfer(recipient, amountSTETH);
}
}
}
}
12 changes: 0 additions & 12 deletions contracts/modules/PaymentsImmutables.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@
pragma solidity ^0.8.17;

import {IWETH9} from '../interfaces/external/IWETH9.sol';
import {ISTETH} from '../interfaces/external/ISTETH.sol';
import {IWSTETH} from '../interfaces/external/IWSTETH.sol';
import {IAllowanceTransfer} from 'permit2/src/interfaces/IAllowanceTransfer.sol';

struct PaymentsParameters {
address permit2;
address weth9;
address steth;
address wsteth;
address openseaConduit;
address sudoswap;
}
Expand All @@ -19,12 +15,6 @@ contract PaymentsImmutables {
/// @dev WETH9 address
IWETH9 internal immutable WETH9;

/// @dev STETH address
ISTETH internal immutable STETH;

/// @dev WSTETH address
IWSTETH internal immutable WSTETH;

/// @dev Permit2 address
IAllowanceTransfer internal immutable PERMIT2;

Expand All @@ -41,8 +31,6 @@ contract PaymentsImmutables {

constructor(PaymentsParameters memory params) {
WETH9 = IWETH9(params.weth9);
STETH = ISTETH(params.steth);
WSTETH = IWSTETH(params.wsteth);
PERMIT2 = IAllowanceTransfer(params.permit2);
OPENSEA_CONDUIT = params.openseaConduit;
SUDOSWAP = params.sudoswap;
Expand Down
1 change: 0 additions & 1 deletion deploy-addresses/goerli.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"UniversalRouter": "0x4648a43B2C14Da09FdF82B161150d3F634f40491",
"UniversalRouterV1_2": "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD",
"UniversalRouterV1_3": "0x3F6328669a86bef431Dc6F9201A5B90F7975a023",
"UnsupportedProtocol": "0x5302086A3a25d473aAbBd0356eFf8Dd811a4d89B"
}
1 change: 0 additions & 1 deletion deploy-addresses/mainnet.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"UniversalRouter": "0xEf1c6E67703c7BD7107eed8303Fbe6EC2554BF6B",
"UniversalRouterV1_2": "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD",
"UniversalRouterV1_3": "0x3F6328669a86bef431Dc6F9201A5B90F7975a023",
"UnsupportedProtocol": "0x76D631990d505E4e5b432EEDB852A60897824D68"
}
4 changes: 0 additions & 4 deletions script/DeployUniversalRouter.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ abstract contract DeployUniversalRouter is Script {
params = RouterParameters({
permit2: mapUnsupported(params.permit2),
weth9: mapUnsupported(params.weth9),
steth: mapUnsupported(params.steth),
wsteth: mapUnsupported(params.wsteth),
seaportV1_5: mapUnsupported(params.seaportV1_5),
seaportV1_4: mapUnsupported(params.seaportV1_4),
openseaConduit: mapUnsupported(params.openseaConduit),
Expand Down Expand Up @@ -71,8 +69,6 @@ abstract contract DeployUniversalRouter is Script {
function logParams() internal view {
console2.log('permit2:', params.permit2);
console2.log('weth9:', params.weth9);
console2.log('steth:', params.steth);
console2.log('wsteth:', params.wsteth);
console2.log('seaportV1_5:', params.seaportV1_5);
console2.log('seaportV1_4:', params.seaportV1_4);
console2.log('openseaConduit:', params.openseaConduit);
Expand Down
2 changes: 0 additions & 2 deletions script/deployParameters/DeployArbitrum.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ contract DeployArbitrum is DeployUniversalRouter {
params = RouterParameters({
permit2: 0x000000000022D473030F116dDEE9F6B43aC78BA3,
weth9: 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1,
steth: UNSUPPORTED_PROTOCOL,
wsteth: UNSUPPORTED_PROTOCOL,
seaportV1_5: 0x00000000000000ADc04C56Bf30aC9d3c0aAF14dC,
seaportV1_4: 0x00000000000001ad428e4906aE43D8F9852d0dD6,
openseaConduit: 0x1E0049783F008A0085193E00003D00cd54003c71,
Expand Down
2 changes: 0 additions & 2 deletions script/deployParameters/DeployArbitrumGoerli.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ contract DeployArbitrumGoerli is DeployUniversalRouter {
params = RouterParameters({
permit2: 0x000000000022D473030F116dDEE9F6B43aC78BA3,
weth9: 0xe39Ab88f8A4777030A534146A9Ca3B52bd5D43A3,
steth: UNSUPPORTED_PROTOCOL,
wsteth: UNSUPPORTED_PROTOCOL,
seaportV1_5: UNSUPPORTED_PROTOCOL,
seaportV1_4: UNSUPPORTED_PROTOCOL,
openseaConduit: UNSUPPORTED_PROTOCOL,
Expand Down
2 changes: 0 additions & 2 deletions script/deployParameters/DeployAvalanche.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ contract DeployAvalanche is DeployUniversalRouter {
params = RouterParameters({
permit2: 0x000000000022D473030F116dDEE9F6B43aC78BA3,
weth9: 0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7,
steth: UNSUPPORTED_PROTOCOL,
wsteth: UNSUPPORTED_PROTOCOL,
seaportV1_5: 0x00000000000000ADc04C56Bf30aC9d3c0aAF14dC,
seaportV1_4: 0x00000000000001ad428e4906aE43D8F9852d0dD6,
openseaConduit: 0x1E0049783F008A0085193E00003D00cd54003c71,
Expand Down
2 changes: 0 additions & 2 deletions script/deployParameters/DeployBSC.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ contract DeployBSC is DeployUniversalRouter {
params = RouterParameters({
permit2: 0x000000000022D473030F116dDEE9F6B43aC78BA3,
weth9: 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c,
steth: UNSUPPORTED_PROTOCOL,
wsteth: UNSUPPORTED_PROTOCOL,
seaportV1_5: 0x00000000000000ADc04C56Bf30aC9d3c0aAF14dC,
seaportV1_4: 0x00000000000001ad428e4906aE43D8F9852d0dD6,
openseaConduit: 0x1E0049783F008A0085193E00003D00cd54003c71,
Expand Down
2 changes: 0 additions & 2 deletions script/deployParameters/DeployBase.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ contract DeployBase is DeployUniversalRouter {
params = RouterParameters({
permit2: 0x000000000022D473030F116dDEE9F6B43aC78BA3,
weth9: 0x4200000000000000000000000000000000000006,
steth: UNSUPPORTED_PROTOCOL,
wsteth: UNSUPPORTED_PROTOCOL,
seaportV1_5: 0x00000000000000ADc04C56Bf30aC9d3c0aAF14dC,
seaportV1_4: 0x00000000000001ad428e4906aE43D8F9852d0dD6,
openseaConduit: 0x1E0049783F008A0085193E00003D00cd54003c71,
Expand Down
2 changes: 0 additions & 2 deletions script/deployParameters/DeployBaseGoerli.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ contract DeployBaseGoerli is DeployUniversalRouter {
params = RouterParameters({
permit2: 0x000000000022D473030F116dDEE9F6B43aC78BA3,
weth9: 0x44D627f900da8AdaC7561bD73aA745F132450798,
steth: UNSUPPORTED_PROTOCOL,
wsteth: UNSUPPORTED_PROTOCOL,
seaportV1_5: 0x00000000000000ADc04C56Bf30aC9d3c0aAF14dC,
seaportV1_4: 0x00000000000001ad428e4906aE43D8F9852d0dD6,
openseaConduit: 0x1E0049783F008A0085193E00003D00cd54003c71,
Expand Down
2 changes: 0 additions & 2 deletions script/deployParameters/DeployCelo.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ contract DeployCelo is DeployUniversalRouter {
params = RouterParameters({
permit2: 0x000000000022D473030F116dDEE9F6B43aC78BA3,
weth9: UNSUPPORTED_PROTOCOL,
steth: UNSUPPORTED_PROTOCOL,
wsteth: UNSUPPORTED_PROTOCOL,
seaportV1_5: UNSUPPORTED_PROTOCOL,
seaportV1_4: UNSUPPORTED_PROTOCOL,
openseaConduit: UNSUPPORTED_PROTOCOL,
Expand Down
2 changes: 0 additions & 2 deletions script/deployParameters/DeployCeloAlfajores.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ contract DeployCeloAlfajores is DeployUniversalRouter {
params = RouterParameters({
permit2: 0x000000000022D473030F116dDEE9F6B43aC78BA3,
weth9: UNSUPPORTED_PROTOCOL,
steth: UNSUPPORTED_PROTOCOL,
wsteth: UNSUPPORTED_PROTOCOL,
seaportV1_5: UNSUPPORTED_PROTOCOL,
seaportV1_4: UNSUPPORTED_PROTOCOL,
openseaConduit: UNSUPPORTED_PROTOCOL,
Expand Down
2 changes: 0 additions & 2 deletions script/deployParameters/DeployGoerli.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ contract DeployGoerli is DeployUniversalRouter {
params = RouterParameters({
permit2: 0x000000000022D473030F116dDEE9F6B43aC78BA3,
weth9: 0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6,
steth: 0x1643E812aE58766192Cf7D2Cf9567dF2C37e9B7F,
wsteth: 0x6320cD32aA674d2898A68ec82e869385Fc5f7E2f,
seaportV1_5: 0x00000000000000ADc04C56Bf30aC9d3c0aAF14dC,
seaportV1_4: 0x00000000000001ad428e4906aE43D8F9852d0dD6,
openseaConduit: 0x1E0049783F008A0085193E00003D00cd54003c71,
Expand Down
2 changes: 0 additions & 2 deletions script/deployParameters/DeployMainnet.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ contract DeployMainnet is DeployUniversalRouter {
params = RouterParameters({
permit2: 0x000000000022D473030F116dDEE9F6B43aC78BA3,
weth9: 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2,
steth: 0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84,
wsteth: 0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0,
seaportV1_5: 0x00000000000000ADc04C56Bf30aC9d3c0aAF14dC,
seaportV1_4: 0x00000000000001ad428e4906aE43D8F9852d0dD6,
openseaConduit: 0x1E0049783F008A0085193E00003D00cd54003c71,
Expand Down
2 changes: 0 additions & 2 deletions script/deployParameters/DeployOptimism.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ contract DeployOptimism is DeployUniversalRouter {
params = RouterParameters({
permit2: 0x000000000022D473030F116dDEE9F6B43aC78BA3,
weth9: 0x4200000000000000000000000000000000000006,
steth: UNSUPPORTED_PROTOCOL,
wsteth: UNSUPPORTED_PROTOCOL,
seaportV1_5: 0x00000000000000ADc04C56Bf30aC9d3c0aAF14dC,
seaportV1_4: 0x00000000000001ad428e4906aE43D8F9852d0dD6,
openseaConduit: 0x1E0049783F008A0085193E00003D00cd54003c71,
Expand Down
2 changes: 0 additions & 2 deletions script/deployParameters/DeployOptimismGoerli.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ contract DeployOptimismGoerli is DeployUniversalRouter {
params = RouterParameters({
permit2: 0x000000000022D473030F116dDEE9F6B43aC78BA3,
weth9: 0x4200000000000000000000000000000000000006,
steth: UNSUPPORTED_PROTOCOL,
wsteth: UNSUPPORTED_PROTOCOL,
seaportV1_5: UNSUPPORTED_PROTOCOL,
seaportV1_4: UNSUPPORTED_PROTOCOL,
openseaConduit: UNSUPPORTED_PROTOCOL,
Expand Down
2 changes: 0 additions & 2 deletions script/deployParameters/DeployPolygon.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ contract DeployPolygon is DeployUniversalRouter {
permit2: 0x000000000022D473030F116dDEE9F6B43aC78BA3,
weth9: 0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270,
seaportV1_5: 0x00000000000000ADc04C56Bf30aC9d3c0aAF14dC,
steth: UNSUPPORTED_PROTOCOL,
wsteth: UNSUPPORTED_PROTOCOL,
seaportV1_4: 0x00000000000001ad428e4906aE43D8F9852d0dD6,
openseaConduit: 0x1E0049783F008A0085193E00003D00cd54003c71,
nftxZap: UNSUPPORTED_PROTOCOL,
Expand Down
2 changes: 0 additions & 2 deletions script/deployParameters/DeployPolygonMumbai.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ contract DeployPolygonMumbai is DeployUniversalRouter {
params = RouterParameters({
permit2: 0x000000000022D473030F116dDEE9F6B43aC78BA3,
weth9: 0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889,
steth: UNSUPPORTED_PROTOCOL,
wsteth: UNSUPPORTED_PROTOCOL,
seaportV1_5: 0x00000000000000ADc04C56Bf30aC9d3c0aAF14dC,
seaportV1_4: 0x00000000000001ad428e4906aE43D8F9852d0dD6,
openseaConduit: 0x1E0049783F008A0085193E00003D00cd54003c71,
Expand Down
2 changes: 0 additions & 2 deletions script/deployParameters/DeploySepolia.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ contract DeploySepolia is DeployUniversalRouter {
params = RouterParameters({
permit2: 0x000000000022D473030F116dDEE9F6B43aC78BA3,
weth9: 0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14,
steth: UNSUPPORTED_PROTOCOL,
wsteth: UNSUPPORTED_PROTOCOL,
seaportV1_5: 0x00000000000000ADc04C56Bf30aC9d3c0aAF14dC,
seaportV1_4: 0x00000000000001ad428e4906aE43D8F9852d0dD6,
openseaConduit: 0x1E0049783F008A0085193E00003D00cd54003c71,
Expand Down
2 changes: 0 additions & 2 deletions test/foundry-tests/UniswapV2.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ abstract contract UniswapV2Test is Test {
RouterParameters memory params = RouterParameters({
permit2: address(PERMIT2),
weth9: address(WETH9),
steth: address(0),
wsteth: address(0),
seaportV1_5: address(0),
seaportV1_4: address(0),
openseaConduit: address(0),
Expand Down
2 changes: 0 additions & 2 deletions test/foundry-tests/UniversalRouter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ contract UniversalRouterTest is Test {
RouterParameters memory params = RouterParameters({
permit2: address(0),
weth9: address(0),
steth: address(0),
wsteth: address(0),
seaportV1_5: address(0),
seaportV1_4: address(0),
openseaConduit: address(0),
Expand Down
Loading

0 comments on commit 5060892

Please sign in to comment.