Skip to main content

OsTokenVaultEscrow

Git Source ↗

Inherits: Ownable2Step ↗, Multicall, IOsTokenVaultEscrow

Used for initiating assets exits from the vault without burning osToken

State Variables​

_maxPercent​

uint256 private constant _maxPercent = 1e18

_wad​

uint256 private constant _wad = 1e18

_hfLiqThreshold​

uint256 private constant _hfLiqThreshold = 1e18

_osTokenVaultController​

IOsTokenVaultController private immutable _osTokenVaultController

_osTokenConfig​

IOsTokenConfig private immutable _osTokenConfig

_positions​

mapping(address vault => mapping(uint256 positionTicket => Position)) private _positions

liqBonusPercent​

The liquidation bonus percent

uint256 public override liqBonusPercent

authenticator​

The address of the authenticator

address public override authenticator

liqThresholdPercent​

The liquidation threshold percent

uint64 public override liqThresholdPercent

Functions​

constructor​

Constructor

constructor(
address osTokenVaultController,
address osTokenConfig,
address initialOwner,
address _authenticator,
uint64 _liqThresholdPercent,
uint256 _liqBonusPercent
) Ownable(msg.sender);

Parameters

NameTypeDescription
osTokenVaultControlleraddressThe address of the OsTokenVaultController contract
osTokenConfigaddressThe address of the OsTokenConfig contract
initialOwneraddressThe address of the contract owner
_authenticatoraddressThe address of the OsTokenVaultEscrowAuth contract
_liqThresholdPercentuint64The liquidation threshold percent
_liqBonusPercentuint256The liquidation bonus percent

getPosition​

Get the position details

function getPosition(address vault, uint256 positionTicket) external view returns (address, uint256, uint256);

Parameters

NameTypeDescription
vaultaddressThe address of the vault
positionTicketuint256The exit position ticket

Returns

NameTypeDescription
<none>addressowner The address of the assets owner
<none>uint256exitedAssets The amount of assets exited and ready to be claimed
<none>uint256osTokenShares The amount of osToken shares

register​

Registers the new escrow position

function register(address owner, uint256 exitPositionTicket, uint256 osTokenShares, uint256 cumulativeFeePerShare)
external
override;

Parameters

NameTypeDescription
owneraddressThe address of the exited assets owner
exitPositionTicketuint256The exit position ticket
osTokenSharesuint256The amount of osToken shares
cumulativeFeePerShareuint256The cumulative fee per share used to calculate the osToken fee

processExitedAssets​

Claims exited assets from the vault to the escrow

function processExitedAssets(address vault, uint256 exitPositionTicket, uint256 timestamp, uint256 exitQueueIndex)
external
override;

Parameters

NameTypeDescription
vaultaddressThe address of the vault
exitPositionTicketuint256The exit position ticket
timestampuint256The timestamp of the exit
exitQueueIndexuint256The index of the exit in the queue

claimExitedAssets​

Claims the exited assets from the escrow to the owner. Can only be called by the position owner.

function claimExitedAssets(address vault, uint256 exitPositionTicket, uint256 osTokenShares)
external
override
returns (uint256 claimedAssets);

Parameters

NameTypeDescription
vaultaddressThe address of the vault
exitPositionTicketuint256The exit position ticket
osTokenSharesuint256The amount of osToken shares to burn

Returns

NameTypeDescription
claimedAssetsuint256The amount of assets claimed

liquidateOsToken​

Liquidates the osToken shares

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

Parameters

NameTypeDescription
vaultaddressThe address of the vault
exitPositionTicketuint256The exit position ticket
osTokenSharesuint256The amount of osToken shares to liquidate
receiveraddressThe address of the receiver of the liquidated assets

redeemOsToken​

Redeems the osToken shares. Can only be called by the osToken redeemer.

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

Parameters

NameTypeDescription
vaultaddressThe address of the vault
exitPositionTicketuint256The exit position ticket
osTokenSharesuint256The amount of osToken shares to redeem
receiveraddressThe address of the receiver of the redeemed assets

setAuthenticator​

Updates the authenticator. Can only be called by the owner.

function setAuthenticator(address newAuthenticator) public override onlyOwner;

Parameters

NameTypeDescription
newAuthenticatoraddressThe address of the new authenticator

updateLiqConfig​

Updates the liquidation configuration. Can only be called by the owner.

function updateLiqConfig(uint64 _liqThresholdPercent, uint256 _liqBonusPercent) public override onlyOwner;

Parameters

NameTypeDescription
_liqThresholdPercentuint64The liquidation threshold percent
_liqBonusPercentuint256The liquidation bonus percent

_redeemOsToken​

Internal function for redeeming osToken shares

function _redeemOsToken(
address vault,
uint256 exitPositionTicket,
address receiver,
uint256 osTokenShares,
bool isLiquidation
) private returns (uint256 receivedAssets);

Parameters

NameTypeDescription
vaultaddressThe address of the vault
exitPositionTicketuint256The position ticket of the exit queue
receiveraddressThe address of the receiver of the redeemed assets
osTokenSharesuint256The amount of osToken shares to redeem
isLiquidationboolWhether the redeem is a liquidation

Returns

NameTypeDescription
receivedAssetsuint256The amount of assets received

_syncPositionFee​

Internal function for syncing the osToken fee

function _syncPositionFee(Position memory position) private view;

Parameters

NameTypeDescription
positionPositionThe position to sync the fee for

_transferAssets​

Internal function for transferring assets from the Vault to the receiver

IMPORTANT: because control is transferred to the receiver, care must be taken to not create reentrancy vulnerabilities. The Vault must follow the checks-effects-interactions pattern: https://docs.soliditylang.org/en/v0.8.22/security-considerations.html#use-the-checks-effects-interactions-pattern

function _transferAssets(address receiver, uint256 assets) internal virtual;

Parameters

NameTypeDescription
receiveraddressThe address that will receive the assets
assetsuint256The number of assets to transfer