This Module is Useful for Understanding the StakeStone and Lido Adapters which are important for Learning about Liquid Staking Adapters. Refer this Repository for Smart Contracts.
StakeStone Adapter
The StakeStoneStakeEth Smart Contract allows users to Stake ETH and Receive STONE Tokens on the StakeStone Platform. This Tutorial provides a Comprehensive Guide to Understanding and using the StakeStoneStakeEth Contract.
Contract Structure - The StakeStoneStakeEth Smart Contract allows users to Stake their ETH in the StakeStone Vault to Receive STONE Tokens. It also supports cross-chain functionality to Deposit received STONE Tokens on another Chain using LayerZero OFT.
a) stone
- The Address of the STONE token.
b) stoneVault
- The Interface to Interact with the StakeStone Vault.
Functions -
a) constructor() - The Constructor initializes the Contract with Native Token, Wrapped Native Token, StakeStone Vault, and STONE Token Addresses.
b) name() - The name function returns the name of the Adapter.
c) execute() - The execute function Performs the Staking Operation by Parsing Input Data, handling ETH Transfers, and Calling the _stake function.
d) _stake() - The _stake function Performs the Actual Staking Operation with the stoneVault and handles cross-chain Operations if needed.
e) depositLzOFT() - The depositLzOFT function handles cross-chain Transfers using LayerZero OFT.
f) parseInputs() - The parseInputs function Decodes the Input Data.
g) receive() - The receive function allows the Contract to Accept ETH Deposits.
Usage - To use the StakeStoneStakeEth Contract -
Deploy the Contract with the Native Token, Wrapped Native Token, stoneVault, and STONE Token Addresses.
Call the execute function with the appropriate Input Data to Stake ETH and Receive STONE Tokens.
Error Handling - The StakeStoneStakeEth Contract uses the Errors library to handle various error Scenarios, such as Insufficient Native Funds.
Conclusion
The StakeStoneStakeEth Smart Contract Simplifies Staking ETH in Exchange for STONE Tokens on the StakeStone Platform. By following this Tutorial, you should be able to Understand and Utilize the Contract effectively.
Lido Adapter
The LidoStakeEth Smart Contract. This Contract allows users to Stake their ETH to Receive stETH on Lido and optionally Bridge the Staked Assets to various Layer 2 Solutions. This Guide will Walk you through the Structure, functionality, and Key Aspects of the Contract.
Contract Structure - The LidoStakeEth Contract enables Staking ETH to Receive stETH via the Lido Protocol on the Ethereum Network. Additionally, it supports Bridging the received stETH to other Layer 2 networks or Sidechains like Arbitrum, Optimism, Base, Linea, Mantle, zkSync, and Scroll.
a) State Variables
- The Contract Defines several State Variables to Manage Addresses of various Bridges, Gateways, and Token Contracts.
b) Chain IDs
- The Contract also Defines Constants for various Chain IDs -
Functions -
a) constructor() - The Constructor initializes the Contract with Addresses for the Native and Wrapped Native Tokens, Lido Token Contracts, various Gateways, and Bridges.
b) name() - Returns the name of the Contract.
c) execute() - Executes the Staking and Bridging Process based on the Input Data.
d) _stake() - Handles the Staking Logic and Determines whether to Bridge the Staked Tokens to another Chain.
e) parseInputs() - Parses the Input Data to extract Recipient Address, Amount, Bridge Chain ID, and Bridge Data.
f) _bridge() - Handles the Bridging Logic for various Chains.
g) _bridgeToArbitrum() - Handles the Bridging Logic to Arbitrum.
h) _bridgeToOptBaseMan() - Handles the Bridging Logic to Optimism, Base, and Mantle.
i) _bridgeToLinea() - Handles the Bridging Logic to Linea.
j) _bridgeToZkSync() - Handles the Bridging Logic to zkSync.
k) _bridgeToScroll() - Handles the Bridging Logic to Scroll.
l) convertToWstEth() - Converts StEth to WstEth.
m) getBridgeFee() - Calculates the Bridge Fee for Different Chains.
n) Fallback Function - The fallback function to Receive ETH.
Usage - To use the DexSpanAdapter, Deploy the Contract with the required Parameters -
Deploy the Contract - Deploy the LidoStakeEth contract on the Ethereum network by providing the required constructor arguments.
Execute Staking and Bridging - Use the Execute function to Stake ETH and Optionally Bridge the resulting StEth to another Chain. The Execute function takes a Data Parameter that includes the ecipient address, amount, Bridge Chain ID, and Bridge-Specific Data.
Bridge Functions - The contract includes functions for bridging to different chains. Each chain-specific bridging function is called internally by the _bridge function based on the provided chain ID.
Conclusion
The LidoStakeEth Contract Provides a Comprehensive Solution for Staking ETH on Lido and Bridging the Resulting StEth to various Layer 2 and Sidechain Networks. By Understanding the Structure and functions of this Contract, Developers can Integrate Lido Staking and Bridging Capabilities into their Decentralized Applications.