dsa-connectors-2.0/contracts/mainnet/connectors/eeth/main.sol

72 lines
2.3 KiB
Solidity
Raw Normal View History

2024-04-15 08:41:37 +00:00
//SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import "./helpers.sol";
import "./events.sol";
import {Basic} from "../../common/basic.sol";
contract EETHContract is Helpers, Basic, Events {
/**
2024-04-15 09:54:44 +00:00
* @dev deposit wETH into Etherfi.
* @notice unwrap wETH and stake ETH in Etherfi, users receive eETH tokens on a 1:1 basis representing their staked ETH.
2024-04-15 11:22:20 +00:00
* @param wethAmount The amount of wETH to deposit. (For max: `uint256(-1)`)
2024-04-15 09:54:44 +00:00
* @param getId ID to retrieve amt.
* @param setId ID stores the amount of ETH deposited.
*/
function depositWeth(
2024-04-15 11:22:20 +00:00
uint256 wethAmount,
2024-04-15 09:54:44 +00:00
uint256 getId,
uint256 setId
) public returns (string memory _eventName, bytes memory _eventParam) {
2024-04-15 11:22:20 +00:00
uint256 _amount = getUint(getId, wethAmount);
2024-04-15 09:54:44 +00:00
_amount = _amount == type(uint256).max
? WETH_CONTRACT.balanceOf(address(this))
: _amount;
uint256 _ethBeforeBalance = address(this).balance;
WETH_CONTRACT.withdraw(_amount);
uint256 _ethAfterBalance = address(this).balance;
2024-04-15 11:22:20 +00:00
uint256 _ethAmount = _ethAfterBalance - _ethBeforeBalance;
2024-04-15 09:54:44 +00:00
ETHERFI_POOL.deposit{value: _ethAmount}();
setUint(setId, _ethAmount);
_eventName = "LogDepositWeth(uint256,uint256,uint256)";
_eventParam = abi.encode(_amount, getId, setId);
}
/**
* @dev deposit ETH into Etherfi.
* @notice stake ETH in Etherfi, users receive eETH tokens on a 1:1 basis representing their staked ETH.
* @param amount The amount of ETH to deposit. (For max: `uint256(-1)`)
* @param getId ID to retrieve amt.
* @param setId ID stores the amount of ETH deposited.
*/
2024-04-15 08:41:37 +00:00
function deposit(
uint256 amount,
uint256 getId,
uint256 setId
)
public
payable
returns (string memory _eventName, bytes memory _eventParam)
{
uint256 _amount = getUint(getId, amount);
_amount = _amount == type(uint256).max
? address(this).balance
: _amount;
2024-04-15 09:54:44 +00:00
2024-04-15 09:00:09 +00:00
ETHERFI_POOL.deposit{value: _amount}();
2024-04-15 08:41:37 +00:00
setUint(setId, _amount);
_eventName = "LogDeposit(uint256,uint256,uint256)";
_eventParam = abi.encode(_amount, getId, setId);
}
}
contract ConnectV2EETH is EETHContract {
string public name = "EETH-v1.0";
}