-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zap wsteth bridge #73
Open
RoseRompkxm
wants to merge
4
commits into
lidofinance:main
Choose a base branch
from
Manta-Network:feat/zap-wsteth-bridge
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Detailed info: https://github.com/lidofinance/lido-l2#Project-Configuration | ||
|
||
# ############################ | ||
# RPCs | ||
# ############################ | ||
|
||
RPC_ETH_SEPOLIA=https://rpc.ankr.com/eth_sepolia | ||
RPC_OPT_SEPOLIA=https://manta-sepolia.rpc.caldera.xyz/http | ||
RPC_MANTA_SEPOLIA=https://manta-sepolia.rpc.caldera.xyz/http | ||
|
||
# ############################ | ||
# Etherscan | ||
# ############################ | ||
|
||
ETHERSCAN_API_KEY_ETH= | ||
ETHERSCAN_API_KEY_OPT= | ||
ETHERSCAN_API_KEY_MANTA= | ||
|
||
# ############################ | ||
# Bridge/Gateway Deployment | ||
# ############################ | ||
|
||
# Address of the token to deploy the bridge/gateway for | ||
TOKEN=0xB82381A3fBD3FaFA77B3a7bE693342618240067b | ||
|
||
# Name of the network environments used by deployment scripts. | ||
# Might be one of: "mainnet", "sepolia". | ||
NETWORK=sepolia | ||
|
||
# Private key of the deployer account used for deployment process | ||
ETH_DEPLOYER_PRIVATE_KEY=090cf6a293b034926caf9bb6ac41390be6bb4aa7f7cd3ea3ec2118a6784f0230 | ||
OPT_DEPLOYER_PRIVATE_KEY=090cf6a293b034926caf9bb6ac41390be6bb4aa7f7cd3ea3ec2118a6784f0230 | ||
|
||
# 0x32A0E5828B62AAb932362a4816ae03b860b65e83 is the Lido DAO Agent | ||
L1_PROXY_ADMIN=0x32A0E5828B62AAb932362a4816ae03b860b65e83 | ||
L1_BRIDGE_ADMIN=0x32A0E5828B62AAb932362a4816ae03b860b65e83 | ||
L1_DEPOSITS_ENABLED=true | ||
L1_WITHDRAWALS_ENABLED=true | ||
L1_DEPOSITS_ENABLERS=["0x32A0E5828B62AAb932362a4816ae03b860b65e83"] | ||
L1_DEPOSITS_DISABLERS="["0x32A0E5828B62AAb932362a4816ae03b860b65e83", "0xAf5B6AE540fCf3BD76f1b4C83fC87143932AAd09"]" | ||
L1_WITHDRAWALS_ENABLERS=["0x32A0E5828B62AAb932362a4816ae03b860b65e83"] | ||
L1_WITHDRAWALS_DISABLERS="["0x32A0E5828B62AAb932362a4816ae03b860b65e83", "0xAf5B6AE540fCf3BD76f1b4C83fC87143932AAd09"]" | ||
|
||
L2_PROXY_ADMIN=0xA74Eb604b0995409F7203BDc3Ae2c7a001873eEb | ||
L2_BRIDGE_ADMIN=0xA74Eb604b0995409F7203BDc3Ae2c7a001873eEb | ||
L2_DEPOSITS_ENABLED=true | ||
L2_WITHDRAWALS_ENABLED=true | ||
L2_DEPOSITS_ENABLERS=["0xA74Eb604b0995409F7203BDc3Ae2c7a001873eEb"] | ||
L2_DEPOSITS_DISABLERS="["0xA74Eb604b0995409F7203BDc3Ae2c7a001873eEb", "0xAf5B6AE540fCf3BD76f1b4C83fC87143932AAd09"]" | ||
L2_WITHDRAWALS_ENABLERS=["0xA74Eb604b0995409F7203BDc3Ae2c7a001873eEb"] | ||
L2_WITHDRAWALS_DISABLERS="["0xA74Eb604b0995409F7203BDc3Ae2c7a001873eEb", "0xAf5B6AE540fCf3BD76f1b4C83fC87143932AAd09"]" | ||
|
||
# ############################ | ||
# Integration & E2E Testing | ||
# ############################ | ||
|
||
TESTING_OPT_NETWORK=sepolia | ||
TESTING_OPT_L1_TOKEN=0xB82381A3fBD3FaFA77B3a7bE693342618240067b | ||
TESTING_OPT_L2_TOKEN=0x24B47cd3A74f1799b32B2de11073764Cb1bb318B | ||
TESTING_OPT_L1_ERC20_TOKEN_BRIDGE=0x4Abf633d9c0F4aEebB4C2E3213c7aa1b8505D332 | ||
TESTING_OPT_L2_ERC20_TOKEN_BRIDGE=0xdBA2760246f315203F8B716b3a7590F0FFdc704a | ||
|
||
# ############################ | ||
# Integration Testing | ||
# ############################ | ||
|
||
TESTING_USE_DEPLOYED_CONTRACTS=true | ||
TESTING_L1_TOKENS_HOLDER= | ||
|
||
# ############################ | ||
# E2E Testing | ||
# ############################ | ||
|
||
TESTING_PRIVATE_KEY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// SPDX-FileCopyrightText: 2022 Lido <[email protected]> | ||
// SPDX-License-Identifier: GPL-3.0 | ||
|
||
pragma solidity 0.8.10; | ||
|
||
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol"; | ||
import {IERC20Bridged} from "../token/interfaces/IERC20Bridged.sol"; | ||
|
||
|
||
interface IL1TokenBridge { | ||
function depositERC20To( | ||
address l1Token_, | ||
address l2Token_, | ||
address to_, | ||
uint256 amount_, | ||
uint32 l2Gas_, | ||
bytes calldata data_ | ||
) external; | ||
} | ||
|
||
error ZeroAddress(); | ||
|
||
error WrapETHFailed(); | ||
|
||
error ZeroAmount(); | ||
|
||
error InsufficientWstETHReceived(); | ||
|
||
contract StakeHelper is ReentrancyGuard { | ||
IERC20 public immutable l1Token; | ||
|
||
address public immutable l2Token; | ||
|
||
IL1TokenBridge public immutable l1TokenBridge; | ||
|
||
event Stake(address indexed staker, uint256 indexed amount); | ||
|
||
constructor( | ||
address l1Token_, | ||
address l2Token_, | ||
address l1TokenBridge_ | ||
) { | ||
l1Token = IERC20(l1Token_); | ||
l2Token = l2Token_; | ||
l1TokenBridge = IL1TokenBridge(l1TokenBridge_); | ||
} | ||
|
||
// Wrap sender's ETH to wstETH and bridge to L2 | ||
function stakeETH( | ||
address to, | ||
uint32 l2Gas_, | ||
bytes calldata data_ | ||
) external payable nonReentrant { | ||
if (to == address(0)) { | ||
revert ZeroAddress(); | ||
} | ||
uint256 amount = msg.value; | ||
if (amount == 0) { | ||
revert ZeroAmount(); | ||
} | ||
// wstETH on L1 will automatically wrap sent Ether in `receive` function | ||
(bool success, ) = address(l1Token).call{value: msg.value}(""); | ||
if (!success) { | ||
revert WrapETHFailed(); | ||
} | ||
// double check amount | ||
if (l1Token.balanceOf(address(this)) < amount) { | ||
revert InsufficientWstETHReceived(); | ||
} | ||
// now the wstETH is at this contract, bridge to L2 in behalf of the sender | ||
// 1. approve token bridge to use `l1Token` of this contract | ||
l1Token.approve(address(l1TokenBridge), amount); | ||
// 2. actual cross bridge transfer | ||
l1TokenBridge.depositERC20To(address(l1Token), l2Token, msg.sender, amount, l2Gas_, data_); | ||
|
||
emit Stake(msg.sender, amount); | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wstETH
(wstETH balance is defined by the stETH shares https://docs.lido.fi/guides/lido-tokens-integration-guide#wsteth)