WrappedVault

Git Source

Inherits: ERC4626

A wrapper vault built on ERC4626 to facilitate staking operations and reward distribution through the Infrared protocol. Each staking token has a corresponding wrapped vault.

deploy 1 wrapped vault per staking token

State Variables

rewardDistributor

Address of the reward distributor, typically a multisig.

address public immutable rewardDistributor;

iVault

Instance of the associated InfraredVault for staking.

InfraredVault public immutable iVault;

deadShares

Inflation attack prevention

uint256 internal constant deadShares = 1e3;

Functions

constructor

Initializes a new WrappedVault contract for a specific staking token.

constructor(
    address _rewardDistributor,
    address _infrared,
    address _stakingToken,
    string memory _name,
    string memory _symbol
) ERC4626(ERC20(_stakingToken), _name, _symbol);

Parameters

NameTypeDescription
_rewardDistributoraddressAddress of the reward distributor (e.g., multisig).
_infraredaddressAddress of the Infrared protocol.
_stakingTokenaddressAddress of the ERC20 staking token.
_namestringName of the wrapped vault token (ERC4626).
_symbolstringSymbol of the wrapped vault token (ERC4626).

totalAssets

Returns the total assets managed by the wrapped vault.

Overrides the ERC4626 totalAssets function to integrate with the InfraredVault balance.

function totalAssets() public view virtual override returns (uint256);

Returns

NameTypeDescription
<none>uint256The total amount of staking tokens held by the InfraredVault.

beforeWithdraw

Hook called before withdrawal operations.

This function ensures that the requested amount of staking tokens is withdrawn from the InfraredVault before being transferred to the user.

function beforeWithdraw(uint256 assets, uint256) internal virtual override;

Parameters

NameTypeDescription
assetsuint256The amount of assets to withdraw.
<none>uint256

afterDeposit

Hook called after deposit operations.

This function stakes the deposited tokens into the InfraredVault.

function afterDeposit(uint256 assets, uint256) internal virtual override;

Parameters

NameTypeDescription
assetsuint256The amount of assets being deposited.
<none>uint256

claimRewards

Claims rewards from the InfraredVault and transfers them to the reward distributor.

Only rewards other than the staking token itself are transferred.

function claimRewards() external;

Events

RewardClaimed

Event emitted when reward tokens claimed

event RewardClaimed(address indexed token, uint256 amount);