Base rsETH pool diff (April 2026)

Erstellt Diff läuft nie ab
183 Entfernungen
676 Zeilen
208 Hinzufügungen
687 Zeilen
// SPDX-License-Identifier: BUSL-1.1
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.21;
pragma solidity 0.8.34;


import {
import {
ERC20Upgradeable, IERC20Upgradeable
ERC20Upgradeable,
IERC20Upgradeable
} from "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
} from "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import {
ReentrancyGuardUpgradeable
} from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import { SafeERC20, IERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { SafeERC20, IERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";


import { UtilLib } from "contracts/utils/UtilLib.sol";
import { UtilLib } from "contracts/utils/UtilLib.sol";
import {
import {
IStargatePoolNative,
IStargatePoolNative,
SendParam,
SendParam,
MessagingFee,
MessagingFee,
OFTReceipt,
OFTReceipt,
MessagingReceipt,
MessagingReceipt,
TxReceipt
TxReceipt
} from "contracts/external/layerzero/interfaces/IStargatePoolNative.sol";
} from "contracts/external/layerzero/interfaces/IStargatePoolNative.sol";
import { IL2Messenger } from "contracts/interfaces/L2/IL2Messenger.sol";
import { IL2TokenBridge } from "contracts/interfaces/L2/IL2TokenBridge.sol";
import { IL2TokenBridge } from "contracts/interfaces/L2/IL2TokenBridge.sol";


interface IOracle {
interface IOracle {
function getRate() external view returns (uint256);
function getRate() external view returns (uint256);
}
}


interface IERC20WrsETH is IERC20Upgradeable {
interface IERC20WrsETH is IERC20Upgradeable {
function mint(address to, uint256 amount) external;
function mint(address to, uint256 amount) external;
}
}


interface IRsETHTokenWrapper {
function allowedTokens(address asset) external view returns (bool);
function maxAmountToDepositBridgerAsset(address asset) external view returns (uint256);
}

/// @title RSETHPoolV3ExternalBridge
/// @title RSETHPoolV3ExternalBridge
/// @notice This contract is the pool for swapping ETH for rsETH. It uses external bridges (e.g. LayerZero/Stargate) for
/// @notice This contract is the pool for swapping ETH for rsETH. It uses external bridges (e.g. LayerZero/Stargate) for
/// bridging ETH from L2s to L1 and native bridging for LSTs (e.g. wstETH).
/// bridging ETH from L2s to L1 and native bridging for LSTs (e.g. wstETH).
contract RSETHPoolV3ExternalBridge is ERC20Upgradeable, AccessControlUpgradeable, ReentrancyGuardUpgradeable {
contract RSETHPoolV3ExternalBridge is ERC20Upgradeable, AccessControlUpgradeable, ReentrancyGuardUpgradeable {
using SafeERC20 for IERC20;
using SafeERC20 for IERC20;


IERC20WrsETH public wrsETH;
IERC20WrsETH public wrsETH;
uint256 public feeBps; // Basis points for fees
uint256 public feeBps; // Basis points for fees
uint256 public feeEarnedInETH;
uint256 public feeEarnedInETH;
address public rsETHOracle;
address public rsETHOracle;


bytes32 public constant BRIDGER_ROLE = keccak256("BRIDGER_ROLE");
bytes32 public constant BRIDGER_ROLE = keccak256("BRIDGER_ROLE");
bytes32 public constant TIMELOCK_ROLE = keccak256("TIMELOCK_ROLE");
bytes32 public constant TIMELOCK_ROLE = keccak256("TIMELOCK_ROLE");


/// @notice The corresponding L1Vault contract for the L2 chain
/// @notice The corresponding L1Vault contract for the L2 chain
address public l1VaultETHForL2Chain;
address public l1VaultETHForL2Chain;
/// @notice The StargatePool used for L2 --> L1 bridging
/// @notice The StargatePool used for L2 --> L1 bridging
IStargatePoolNative public stargatePool;
IStargatePoolNative public stargatePool;
/// @notice The LayerZero ID for the ETH mainnet
/// @notice The LayerZero ID for the ETH mainnet
uint32 public dstLzChainId;
uint32 public dstLzChainId;


/// @notice The latest transaction receipt info from the StargatePoolNative
/// @notice The latest transaction receipt info from the StargatePoolNative
TxReceipt public latestTxReceipt;
TxReceipt public latestTxReceipt;


/// @notice New variable added for pausable functionality
/// @notice New variable added for pausable functionality
bool public paused;
bool public paused;


/// @notice THe daily minting limit for rsETH
/// @notice THe daily minting limit for rsETH
uint256 public dailyMintLimit;
uint256 public dailyMintLimit;


/// @notice The amount of rsETH that was minted today
/// @notice The amount of rsETH that was minted today
uint256 public dailyMintAmount;
uint256 public dailyMintAmount;


/// @notice The last day that rsETH was minted
/// @notice The last day that rsETH was minted
uint256 public lastMintDay;
uint256 public lastMintDay;


/// @notice The start timestamp for the daily minting limit
/// @notice The start timestamp for the daily minting limit
uint256 public startTimestamp;
uint256 public startTimestamp;


/// @notice ETH identifier address
/// @notice ETH identifier address
address public constant ETH_IDENTIFIER = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
address public constant ETH_IDENTIFIER = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;


/// @notice The mapping of token addresses to the fee earned in that token
/// @notice The mapping of token addresses to the fee earned in that token
mapping(address token => uint256 feeEarned) public feeEarnedInToken;
mapping(address token => uint256 feeEarned) public feeEarnedInToken;


/// @notice The mapping of token addresses to their respective oracle addresses
/// @notice The mapping of token addresses to their respective oracle addresses
mapping(address token => address oracle) public supportedTokenOracle;
mapping(address token => address oracle) public supportedTokenOracle;


/// @notice The mapping of token addresses to their respective token bridges
/// @notice The mapping of token addresses to their respective token bridges
mapping(address token => address bridge) public tokenBridge;
mapping(address token => address bridge) public tokenBridge;


/// @notice An array of supported token addresses
/// @notice An array of supported token addresses
address[] public supportedTokenList;
address[] public supportedTokenList;


/// @notice The pauser role identifier
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");

/// @notice The address of the L2 bridge contract
address public l2Bridge;

/// @notice The address of the L2 messenger contract
address public messenger;

/// @notice The operator role identifier
bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE");

modifier whenNotPaused() {
modifier whenNotPaused() {
if (paused) revert ContractPaused();
if (paused) revert ContractPaused();
_;
_;
}
}


modifier whenPaused() {
modifier whenPaused() {
if (!paused) revert ContractNotPaused();
if (!paused) revert ContractNotPaused();
_;
_;
}
}


modifier onlySupportedToken(address token) {
modifier onlySupportedToken(address token) {
if (supportedTokenOracle[token] == address(0)) revert UnsupportedToken();
if (supportedTokenOracle[token] == address(0)) revert UnsupportedToken();
_;
_;
}
}