LRTConfig diff

Creado El diff nunca expira
2 eliminaciones
253 líneas
3 adiciones
255 líneas
// SPDX-License-Identifier: BUSL-1.1
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.21;
pragma solidity 0.8.27;


import { UtilLib } from "./utils/UtilLib.sol";
import { UtilLib } from "./utils/UtilLib.sol";
import { LRTConstants } from "./utils/LRTConstants.sol";
import { LRTConstants } from "./utils/LRTConstants.sol";
import { ILRTConfig } from "./interfaces/ILRTConfig.sol";
import { ILRTConfig } from "./interfaces/ILRTConfig.sol";
import { IStrategy } from "./external/eigenlayer/interfaces/IStrategy.sol";
import { IStrategy } from "./external/eigenlayer/interfaces/IStrategy.sol";
import { ILRTDepositPool } from "./interfaces/ILRTDepositPool.sol";
import { ILRTDepositPool } from "./interfaces/ILRTDepositPool.sol";


import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";


/// @title LRTConfig - LRT Config Contract
/// @title LRTConfig - LRT Config Contract
/// @notice Handles LRT configuration
/// @notice Handles LRT configuration
contract LRTConfig is ILRTConfig, AccessControlUpgradeable {
contract LRTConfig is ILRTConfig, AccessControlUpgradeable {
mapping(bytes32 tokenKey => address tokenAddress) public tokenMap;
mapping(bytes32 tokenKey => address tokenAddress) public tokenMap;
mapping(bytes32 contractKey => address contractAddress) public contractMap;
mapping(bytes32 contractKey => address contractAddress) public contractMap;
mapping(address token => bool isSupported) public isSupportedAsset;
mapping(address token => bool isSupported) public isSupportedAsset;
mapping(address token => uint256 amount) public depositLimitByAsset;
mapping(address token => uint256 amount) public depositLimitByAsset;
mapping(address token => address strategy) public override assetStrategy;
mapping(address token => address strategy) public override assetStrategy;


address[] public supportedAssetList;
address[] public supportedAssetList;
address public rsETH;
address public rsETH;
uint256 public protocolFeeInBPS;
uint256 public protocolFeeInBPS;
address public eigenLayerRewardReceiver;
address public eigenLayerRewardReceiver;
uint256 public maxNegligibleAmount;
uint256 public maxNegligibleAmount;


modifier onlySupportedAsset(address asset) {
modifier onlySupportedAsset(address asset) {
if (!isSupportedAsset[asset]) {
if (!isSupportedAsset[asset]) {
revert AssetNotSupported();
revert AssetNotSupported();
}
}
_;
_;
}
}


/// @custom:oz-upgrades-unsafe-allow constructor
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
constructor() {
_disableInitializers();
_disableInitializers();
}
}


/// @dev Initializes the contract
/// @dev Initializes the contract
/// @param admin Admin address
/// @param admin Admin address
/// @param stETH stETH address
/// @param stETH stETH address
/// @param ethX ETHX address
/// @param ethX ETHX address
/// @param rsETH_ rsETH address
/// @param rsETH_ rsETH address
function initialize(address admin, address stETH, address ethX, address rsETH_) external initializer {
function initialize(address admin, address stETH, address ethX, address rsETH_) external initializer {
UtilLib.checkNonZeroAddress(admin);
UtilLib.checkNonZeroAddress(admin);
UtilLib.checkNonZeroAddress(rsETH_);
UtilLib.checkNonZeroAddress(rsETH_);


__AccessControl_init();
__AccessControl_init();
_setToken(LRTConstants.ST_ETH_TOKEN, stETH);
_setToken(LRTConstants.ST_ETH_TOKEN, stETH);
_setToken(LRTConstants.ETHX_TOKEN, ethX);
_setToken(LRTConstants.ETHX_TOKEN, ethX);
_addNewSupportedAsset(stETH, 100_000 ether);
_addNewSupportedAsset(stETH, 100_000 ether);
_addNewSupportedAsset(ethX, 100_000 ether);
_addNewSupportedAsset(ethX, 100_000 ether);


_grantRole(DEFAULT_ADMIN_ROLE, admin);
_grantRole(DEFAULT_ADMIN_ROLE, admin);


rsETH = rsETH_;
rsETH = rsETH_;
}
}


/// @dev Removes a supported asset
/// @dev Removes a supported asset
/// @param asset The asset address
/// @param asset The asset address
function removeSupportedAsset(
function removeSupportedAsset(
address asset,
address asset,
uint256 tokenIndex
uint256 tokenIndex
)
)
external
external
onlySupportedAsset(asset)
onlySupportedAsset(asset)
onlyRole(DEFAULT_ADMIN_ROLE)
onlyRole(DEFAULT_ADMIN_ROLE)
{
{
UtilLib.checkNonZeroAddress(asset);
UtilLib.checkNonZeroAddress(asset);


if (supportedAssetList[tokenIndex] != asset) {
if (supportedAssetList[tokenIndex] != asset) {
revert TokenNotFoundError();
revert TokenNotFoundError();
}
}

address depositPool = getContract(LRTConstants.LRT_DEPOSIT_POOL);
address depositPool = getContract(LRTConstants.LRT_DEPOSIT_POOL);


if (ILRTDepositPool(depositPool).getTotalAssetDeposits(asset) > maxNegligibleAmount) {
if (ILRTDepositPool(depositPool).getTotalAssetDeposits(asset) > maxNegligibleAmount) {
revert CannotRemoveAssetWithDeposits(asset);
revert CannotRemoveAssetWithDeposits(asset);
}
}


delete isSupportedAsset[asset];
delete isSupportedAsset[asset];
delete assetStrategy[asset];
delete assetStrategy[asset];
depositLimitByAsset[asset] = 0;
depositLimitByAsset[asset] = 0;


supportedAssetList[tokenIndex] = supportedAssetList[supportedAssetList.length - 1];
supportedAssetList[tokenIndex] = supportedAssetList[supportedAssetList.length - 1];
supportedAssetList.pop();
supportedAssetList.pop();

emit RemovedSupportedAsset(asset);
emit RemovedSupportedAsset(asset);
}
}


/// @dev Adds a new supported asset
/// @dev Adds a new supported asset
/// @param asset Asset address
/// @param asset Asset address
/// @param depositLimit Deposit limit for the asset
/// @param depositLimit Deposit limit for the asset
function addNewSupportedAsset(address asset, uint256 depositLimit) external onlyRole(LRTConstants.TIME_LOCK_ROLE) {
function addNewSupportedAsset(address asset, uint256 depositLimit) external onlyRole(LRTConstants.TIME_LOCK_ROLE) {
_addNewSupportedAsset(asset, depositLimit);
_addNewSupportedAsset(asset, depositLimit);
}
}


/// @dev private function to add a new supported asset
/// @dev private function to add a new supported asset
/// @param asset Asset address
/// @param asset Asset address
/// @param depositLimit Deposit limit for the asset
/// @param depositLimit Deposit limit for the asset