Skip to main content

VaultOsToken

Git Source ↗

Inherits: VaultImmutables →, VaultState →, VaultEnterExit →, IVaultOsToken

Defines the functionality for minting OsToken.

Structs

OsTokenPosition

Struct of osToken position

struct OsTokenPosition {
uint128 shares;
uint128 cumulativeFeePerShare;
}

Properties

NameTypeDescription
sharesuint128The total number of minted osToken shares. Will increase based on the treasury fee.
cumulativeFeePerShareuint128The cumulative fee per share

Events

OsTokenMinted

Event emitted on minting osToken

event OsTokenMinted(address indexed caller, address receiver, uint256 assets, uint256 shares, address referrer);

Parameters

NameTypeDescription
calleraddressThe address of the function caller
receiveraddressThe address of the osToken receiver
assetsuint256The amount of minted assets
sharesuint256The amount of minted shares
referreraddressThe address of the referrer

OsTokenBurned

Event emitted on burning OsToken

event OsTokenBurned(address indexed caller, uint256 assets, uint256 shares);

Parameters

NameTypeDescription
calleraddressThe address of the function caller
assetsuint256The amount of burned assets
sharesuint256The amount of burned shares

OsTokenLiquidated

Event emitted on osToken position liquidation

event OsTokenLiquidated(
address indexed caller,
address indexed user,
address receiver,
uint256 osTokenShares,
uint256 shares,
uint256 receivedAssets
);

Parameters

NameTypeDescription
calleraddressThe address of the function caller
useraddressThe address of the user liquidated
receiveraddressThe address of the receiver of the liquidated assets
osTokenSharesuint256The amount of osToken shares to liquidate
sharesuint256The amount of vault shares burned
receivedAssetsuint256The amount of assets received

OsTokenRedeemed

Event emitted on osToken position redemption

event OsTokenRedeemed(
address indexed caller,
address indexed user,
address receiver,
uint256 osTokenShares,
uint256 shares,
uint256 assets
);

Parameters

NameTypeDescription
calleraddressThe address of the function caller
useraddressThe address of the position owner to redeem from
receiveraddressThe address of the receiver of the redeemed assets
osTokenSharesuint256The amount of osToken shares to redeem
sharesuint256The amount of vault shares burned
assetsuint256The amount of assets received

Functions

osTokenPositions

Get total amount of minted osToken shares

function osTokenPositions(address user) public view override returns (uint128 shares);

Parameters

NameTypeDescription
useraddressThe address of the user

Returns

NameTypeDescription
sharesuint128The number of minted osToken shares

mintOsToken

Mints OsToken shares

function mintOsToken(address receiver, uint256 osTokenShares, address referrer)
public
virtual
override
returns (uint256 assets);

Parameters

NameTypeDescription
receiveraddressThe address that will receive the minted OsToken shares
osTokenSharesuint256The number of OsToken shares to mint to the receiver. To mint the maximum amount of shares, use 2^256 - 1.
referreraddressThe address of the referrer

Returns

NameTypeDescription
assetsuint256The number of assets minted to the receiver

burnOsToken

Burns osToken shares

function burnOsToken(uint128 osTokenShares) external override returns (uint256 assets);

Parameters

NameTypeDescription
osTokenSharesuint128The number of shares to burn

Returns

NameTypeDescription
assetsuint256The number of assets burned

liquidateOsToken

Liquidates a user position and returns the number of received assets. Can only be called when health factor is below 1 by the liquidator.

function liquidateOsToken(uint256 osTokenShares, address owner, address receiver) external override;

Parameters

NameTypeDescription
osTokenSharesuint256The number of shares to cover
owneraddressThe address of the position owner to liquidate
receiveraddressThe address of the receiver of the liquidated assets

redeemOsToken

Redeems osToken shares for assets. Can only be called when health factor is above redeemFromHealthFactor by the redeemer.

function redeemOsToken(uint256 osTokenShares, address owner, address receiver) external override;

Parameters

NameTypeDescription
osTokenSharesuint256The number of osToken shares to redeem
owneraddressThe address of the position owner to redeem from
receiveraddressThe address of the receiver of the redeemed assets

transferOsTokenPositionToEscrow

Transfers minted osToken shares to the OsTokenVaultEscrow contract, enters the exit queue for staked assets

function transferOsTokenPositionToEscrow(uint256 osTokenShares) external override returns (uint256 positionTicket);

Parameters

NameTypeDescription
osTokenSharesuint256The number of osToken shares to transfer

Returns

NameTypeDescription
positionTicketuint256The exit position ticket

enterExitQueue

Locks shares to the exit queue. The shares continue earning rewards until they will be burned by the Vault.

function enterExitQueue(uint256 shares, address receiver)
public
virtual
override(IVaultEnterExit, VaultEnterExit)
returns (uint256 positionTicket);

Parameters

NameTypeDescription
sharesuint256The number of shares to lock
receiveraddressThe address that will receive assets upon withdrawal

Returns

NameTypeDescription
positionTicketuint256The position ticket of the exit queue. Returns uint256 max if no ticket created.