Module 7 - Understanding Stader Adapter Contract
Here’s the Stader Adapter Contract -
The StaderStakeEth
Contract allows users to Stake ETH on the Stader Protocol to Receive EthX in return. It is Designed Specifically for the Ethereum Chain and extends the RouterIntentEoaAdapterWithoutDataProvider
to Implement Staking functionality. This Contract Integrates with the Stader Pool to facilitate the Staking Process.
Contract StaderStakeEth.sol
The StaderStakeEth
Contract is an Adapter that enables Users to Stake their ETH on Stader and receive EthX in return. The Contract extends RouterIntentEoaAdapterWithoutDataProvider
and overrides the execute
function to implement the Core Staking Logic.
Inheritance
RouterIntentEoaAdapterWithoutDataProvider
: The Base Contract for EOAs (Externally Owned Accounts) without a Data Provider.EoaExecutorWithoutDataProvider
: Provides theexecute
function, which is overridden in this Contract.
Constructor
The Constructor Initializes the Contract with essential Addresses, including the Native Token, Wrapped Native Token, EthX Token, and the Stader Pool Address.
- Parameters -
__native
: Address of the Native Token (e.g., ETH).__wnative
: Address of the Wrapped Native Token (e.g., WETH).__ethx
: Address of the EthX Token on Stader.__staderPool
: Address of the Stader Pool Contract where Staking is Performed.
Functions
- name(): Returns the Name of the Adapter. It returns a String representing the name of the Adapter,
StaderStakeEth
.
- execute(): Executes the Staking Logic by Calling the
execute
function of the Adapter. This function Decodes the Input Data, checks for Sufficient Native Funds, and Performs the Staking Action.
-
Parameters -
a)
data
: Encoded Input Data containing the Recipient Address and the amount of ETH to be Staked. -
Returns -
a)
tokens
: An array of Token Addresses involved in the Transaction (Native Token and EthX). -
Functionality -
a) Decodes the Input Data to Retrieve the Recipient Address and Staking Amount.
b) Verifies if the Contract is called using
call
and Checks if the Correct Amount of Native funds is Passed.c) Executes the
_stake
function to Stake ETH on the Stader Pool.
- _stake(): Handles the Core Staking Logic. It Deposits the Specified amount of ETH to the Stader Pool and returns the involved Tokens and Log Data.
-
Parameters -
a)
_recipient
: The Address that will Receive the EthX Tokens. b)_amount
: The Amount of ETH to be Staked. -
Returns -
a)
tokens
: An array of Token Addresses involved in the Transaction (Native Token and EthX). b)logData
: Encoded Log Data containing the Execution Event. -
Functionality -
a) Deposits ETH into the Stader Pool using the provided Recipient Address.
b) Constructs an array of Token Addresses (Native Token and EthX).
c) Encodes Log Data containing the Recipient and Amount.
- parseInputs(): Parses the Input Data to Extract the Recipient Address and the Amount of ETH to be Staked.
-
Parameters -
a)
data
: Encoded Input Data containing the Recipient Address and Staking Amount. -
Returns - A Tuple Containing -
a)
address
: The Recepient Address. b)uint256
: The Amount of ETH to be Staked.
Conclusion
Before Going on to the Next Module Let’s Understand Two More Adapters -
- Nitro Adapter: This is used to Bridge the Assets or Send Message or do Both from One Chain to another.
- Dexspan Adapter: This is used to Swap one Asset to another on the Same Chain.