Skip to main content

OsTokenVaultController

Git Source ↗

Inherits: Ownable2Step ↗, IOsTokenVaultController

Over-collateralized staked token controller

State Variables​

_wad​

uint256 private constant _wad = 1e18

_maxFeePercent​

uint256 private constant _maxFeePercent = 10_000

_registry​

address private immutable _registry

_osToken​

address private immutable _osToken

keeper​

The address that can update avgRewardPerSecond

address public override keeper

capacity​

The OsToken capacity

uint256 public override capacity

avgRewardPerSecond​

The average reward per second used to mint OsToken rewards

uint256 public override avgRewardPerSecond

treasury​

The DAO treasury address that receives OsToken fees

address public override treasury

feePercent​

The fee percent (multiplied by 100)

uint64 public override feePercent

_cumulativeFeePerShare​

uint192 private _cumulativeFeePerShare = uint192(_wad)

_lastUpdateTimestamp​

uint64 private _lastUpdateTimestamp

_totalShares​

uint128 private _totalShares

_totalAssets​

uint128 private _totalAssets

Functions​

constructor​

Constructor

constructor(
address _keeper,
address registry,
address osToken,
address _treasury,
address _owner,
uint16 _feePercent,
uint256 _capacity
) Ownable(msg.sender);

Parameters

NameTypeDescription
_keeperaddressThe address of the Keeper contract
registryaddressThe address of the VaultsRegistry contract
osTokenaddressThe address of the OsToken contract
_treasuryaddressThe address of the DAO treasury
_owneraddressThe address of the owner of the contract
_feePercentuint16The fee percent applied on the rewards
_capacityuint256The amount after which the osToken stops accepting deposits

totalShares​

The total number of shares controlled by the OsToken

function totalShares() external view override returns (uint256);

Returns

NameTypeDescription
<none>uint256The total number of shares

totalAssets​

Total assets controlled by the OsToken

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

Returns

NameTypeDescription
<none>uint256The total amount of the underlying asset that is "managed" by OsToken

convertToShares​

Converts assets to shares

function convertToShares(uint256 assets) public view override returns (uint256 shares);

Parameters

NameTypeDescription
assetsuint256The amount of assets to convert to shares

Returns

NameTypeDescription
sharesuint256The amount of OsToken shares obtained when exchanging with the amount of assets provided

convertToAssets​

Converts shares to assets

function convertToAssets(uint256 shares) public view override returns (uint256 assets);

Parameters

NameTypeDescription
sharesuint256The amount of shares to convert to assets

Returns

NameTypeDescription
assetsuint256The amount of assets obtained when exchanging with the amount of OsToken shares provided

mintShares​

Mint OsToken shares. Can only be called by the registered vault.

function mintShares(address receiver, uint256 shares) external override returns (uint256 assets);

Parameters

NameTypeDescription
receiveraddressThe address that will receive the shares
sharesuint256The amount of shares to mint

Returns

NameTypeDescription
assetsuint256The amount of assets minted

burnShares​

Burn shares for withdrawn assets. Can only be called by the registered vault.

function burnShares(address owner, uint256 shares) external override returns (uint256 assets);

Parameters

NameTypeDescription
owneraddressThe address that owns the shares
sharesuint256The amount of shares to burn

Returns

NameTypeDescription
assetsuint256The amount of assets withdrawn

setCapacity​

Update capacity. Can only be called by the owner.

function setCapacity(uint256 _capacity) public override onlyOwner;

Parameters

NameTypeDescription
_capacityuint256The amount after which the OsToken stops accepting deposits

setTreasury​

Update treasury address. Can only be called by the owner.

function setTreasury(address _treasury) public override onlyOwner;

Parameters

NameTypeDescription
_treasuryaddressThe new treasury address

setFeePercent​

Update fee percent. Can only be called by the owner. Cannot be larger than 10 000 (100%).

function setFeePercent(uint16 _feePercent) public override onlyOwner;

Parameters

NameTypeDescription
_feePercentuint16The new fee percent

setAvgRewardPerSecond​

Updates average reward per second. Can only be called by the keeper.

function setAvgRewardPerSecond(uint256 _avgRewardPerSecond) external override;

Parameters

NameTypeDescription
_avgRewardPerSeconduint256The new average reward per second

setKeeper​

Update keeper address. Can only be called by the owner.

function setKeeper(address _keeper) external override onlyOwner;

Parameters

NameTypeDescription
_keeperaddressThe new keeper address

cumulativeFeePerShare​

The fee per share used for calculating the fee for every position

function cumulativeFeePerShare() external view override returns (uint256);

Returns

NameTypeDescription
<none>uint256The cumulative fee per share

updateState​

Updates rewards and treasury fee checkpoint for the OsToken

function updateState() public override;

_convertToShares​

Internal conversion function (from assets to shares) with support for rounding direction.

function _convertToShares(uint256 assets, uint256 totalShares_, uint256 totalAssets_, Math.Rounding rounding)
internal
pure
returns (uint256 shares);

_convertToAssets​

Internal conversion function (from shares to assets) with support for rounding direction.

function _convertToAssets(uint256 shares, uint256 totalShares_, uint256 totalAssets_, Math.Rounding rounding)
internal
pure
returns (uint256);

_unclaimedAssets​

Internal function for calculating assets accumulated since last update

function _unclaimedAssets() internal view returns (uint256);