RioLRTCoordinator

Git Source

Inherits: IRioLRTCoordinator, OwnableUpgradeable, UUPSUpgradeable, PausableUpgradeable, EIP712, RioLRTCore

State Variables

DEPOSIT_ROOT_TYPEHASH

EIP-712 typehash for DepositRoot message

bytes32 public constant DEPOSIT_ROOT_TYPEHASH = keccak256('DepositRoot(bytes32 root)');

ethPOS

The Ethereum POS deposit contract address.

IETHPOSDeposit public immutable ethPOS;

rebalanceDelay

The required delay between rebalances.

uint24 public rebalanceDelay;

guardianSigner

The guardian signer address.

address public guardianSigner;

assetNextRebalanceAfter

Tracks the timestamp from which each asset is eligible for rebalancing, inclusive of the defined timestamp.

mapping(address asset => uint40 timestamp) public assetNextRebalanceAfter;

Functions

checkDeposit

Require that the coordinator is not paused, the asset is supported, the deposit amount is non-zero, and the deposit cap has not been reached.

modifier checkDeposit(address asset, uint256 amountIn);

Parameters

NameTypeDescription

asset

address

The asset being deposited.

amountIn

uint256

The amount of the asset being deposited.

checkWithdrawal

Require that the coordinator is not paused, the asset is supported, and the withdrawal amount is non-zero.

modifier checkWithdrawal(address asset, uint256 amountIn);

Parameters

NameTypeDescription

asset

address

The asset being deposited.

amountIn

uint256

The amount of the asset being deposited.

checkRebalance

Require that the coordinator is not paused and the rebalance delay has been met.

modifier checkRebalance(address asset);

Parameters

NameTypeDescription

asset

address

The asset being rebalanced.

constructor

constructor(address issuer_, address ethPOS_) RioLRTCore(issuer_);

Parameters

NameTypeDescription

issuer_

address

The LRT issuer that's authorized to deploy this contract.

ethPOS_

address

The Ethereum POS deposit contract address.

initialize

Initializes the contract.

function initialize(address initialOwner, address token_) external initializer;

Parameters

NameTypeDescription

initialOwner

address

The owner of the contract.

token_

address

The address of the liquid restaking token.

getTVL

Returns the total value of all underlying assets in the unit of account.

function getTVL() public view returns (uint256 value);

depositERC20

Deposits ERC20 tokens and mints restaking token(s) to the caller.

Reentrancy protection is omitted as tokens with transfer hooks are not supported. Future inclusion of such tokens could risk reentrancy attacks. Developers should remain vigilant and consider safeguards if this assumption changes.

function depositERC20(address asset, uint256 amountIn)
    external
    checkDeposit(asset, amountIn)
    returns (uint256 amountOut);

Parameters

NameTypeDescription

asset

address

The asset being deposited.

amountIn

uint256

The amount of the asset being deposited.

depositETH

Deposits ETH and mints restaking token(s) to the caller.

function depositETH() external payable returns (uint256);

requestWithdrawal

Requests a withdrawal to asset for amountIn restaking tokens.

function requestWithdrawal(address asset, uint256 amountIn) external checkWithdrawal(asset, amountIn);

Parameters

NameTypeDescription

asset

address

The asset being withdrawn.

amountIn

uint256

The amount of restaking tokens being redeemed.

rebalanceETH

Rebalances ETH by processing outstanding withdrawals and depositing remaining ETH into EigenLayer.

This function requires a guardian signature prior to depositing ETH into EigenLayer. If the guardian doesn't provide a signature within 24 hours, then the rebalance will be allowed without a signature, but only for withdrawals. In the future, this may be extended to allow a rebalance without a guardian signature without waiting 24 hours if withdrawals outnumber deposits.

function rebalanceETH(bytes32 root, bytes calldata signature) external checkRebalance(ETH_ADDRESS);

Parameters

NameTypeDescription

root

bytes32

The deposit merkle root.

signature

bytes

The guardian signature.

rebalanceERC20

Rebalances the provided ERC20 token by processing outstanding withdrawals and depositing remaining tokens into EigenLayer.

function rebalanceERC20(address token) external checkRebalance(token);

Parameters

NameTypeDescription

token

address

The token to rebalance.

setRebalanceDelay

Sets the rebalance delay.

function setRebalanceDelay(uint24 newRebalanceDelay) external onlyOwner;

Parameters

NameTypeDescription

newRebalanceDelay

uint24

The new rebalance delay, in seconds.

setGuardianSigner

Set the guardian signer address.

Only callable by the owner.

function setGuardianSigner(address newGuardianSigner) external onlyOwner;

Parameters

NameTypeDescription

newGuardianSigner

address

The address of the new guardian signer.

emergencyPauseOperatorUndelegated

Pauses the coordinator if any operator has forcefully undelegated one of our delegators.

Anyone can call this function.

function emergencyPauseOperatorUndelegated() external;

pause

Pauses deposits, withdrawals, and rebalances.

function pause() external onlyOwner;

unpause

Unpauses deposits, withdrawals, and rebalances.

function unpause() external onlyOwner;

convertFromUnitOfAccountToRestakingTokens

Converts the unit of account value to its equivalent in restaking tokens. The unit of account is the price feed's quote asset.

function convertFromUnitOfAccountToRestakingTokens(uint256 value) public view returns (uint256);

Parameters

NameTypeDescription

value

uint256

The restaking token's value in the unit of account.

convertToUnitOfAccountFromRestakingTokens

Converts an amount of restaking tokens to its equivalent value in the unit of account. The unit of account is the price feed's quote asset.

function convertToUnitOfAccountFromRestakingTokens(uint256 amount) public view returns (uint256);

Parameters

NameTypeDescription

amount

uint256

The amount of restaking tokens to convert.

convertFromAssetToRestakingTokens

Converts an asset amount to its equivalent value in restaking tokens.

function convertFromAssetToRestakingTokens(address asset, uint256 amount) public view returns (uint256);

Parameters

NameTypeDescription

asset

address

The address of the asset to convert.

amount

uint256

The amount of the asset to convert.

convertToAssetFromRestakingTokens

Converts an amount of restaking tokens to the equivalent in the asset.

function convertToAssetFromRestakingTokens(address asset, uint256 amount) public view returns (uint256);

Parameters

NameTypeDescription

asset

address

The address of the asset to convert to.

amount

uint256

The amount of restaking tokens to convert.

convertToSharesFromRestakingTokens

Converts an amount of restaking tokens to the equivalent in the provided asset's EigenLayer shares.

function convertToSharesFromRestakingTokens(address asset, uint256 amount) public view returns (uint256 shares);

Parameters

NameTypeDescription

asset

address

The address of the asset whose EigenLayer shares to convert to.

amount

uint256

The amount of restaking tokens to convert.

hashTypedData

EIP-712 helper.

function hashTypedData(bytes32 structHash) external view returns (bytes32);

Parameters

NameTypeDescription

structHash

bytes32

The hash of the struct.

receive

Deposits ETH and mints restaking token(s) to the caller.

receive() external payable;

_depositETH

Deposits ETH and mints restaking token(s) to the caller.

This function assumes that the quote asset is ETH.

function _depositETH() internal checkDeposit(ETH_ADDRESS, msg.value) returns (uint256 amountOut);

_setRebalanceDelay

Sets the rebalance delay.

function _setRebalanceDelay(uint24 newRebalanceDelay) internal;

Parameters

NameTypeDescription

newRebalanceDelay

uint24

The new rebalance delay, in seconds.

_processUserWithdrawalsForCurrentEpoch

Processes user withdrawals for the provided asset by transferring available assets from the deposit pool and queueing any remaining amount for withdrawal from EigenLayer.

function _processUserWithdrawalsForCurrentEpoch(address asset, uint256 amountOutstanding) internal;

Parameters

NameTypeDescription

asset

address

The asset being withdrawn.

amountOutstanding

uint256

The amount restaking tokens requested for withdrawal in the current epoch.

_domainNameAndVersion

Returns the domain name and version for EIP-712 guardian signatures.

function _domainNameAndVersion() internal pure override returns (string memory, string memory);

_verifyGuardianSignature

Verify EIP-712 DepositDataRoot signature.

function _verifyGuardianSignature(bytes32 root, bytes calldata signature) internal view returns (bool);

Parameters

NameTypeDescription

root

bytes32

The deposit data merkle root to verify.

signature

bytes

The guardian signature to verify.

_requireAssetSupported

Reverts if the asset is not supported.

function _requireAssetSupported(address asset) internal view;

Parameters

NameTypeDescription

asset

address

The address of the asset.

_requireAmountGreaterThanZero

Reverts if the provided amount is zero.

function _requireAmountGreaterThanZero(uint256 amount) internal pure;

Parameters

NameTypeDescription

amount

uint256

The amount being checked.

_requireDepositCapNotReached

Reverts if the deposit cap for the asset has been reached.

function _requireDepositCapNotReached(address asset, uint256 amountIn) internal view;

Parameters

NameTypeDescription

asset

address

The address of the asset.

amountIn

uint256

The amount of the asset being deposited.

_requireRebalanceDelayMet

Reverts if the rebalance delay has not been met.

function _requireRebalanceDelayMet(address asset) internal view;

Parameters

NameTypeDescription

asset

address

The asset being rebalanced.

_authorizeUpgrade

Allows the owner to upgrade the gateway implementation.

function _authorizeUpgrade(address newImplementation) internal override onlyOwner;

Parameters

NameTypeDescription

newImplementation

address

The implementation to upgrade to.

Last updated