IUsdnProtocolVault

Git Source

Interface for the vault layer of the USDN protocol.

Functions

usdnPrice

Calculates the predicted USDN token price based on the given asset price and timestamp.

The effects of the funding and the PnL of the long positions since the last contract state update are taken into account.

function usdnPrice(uint128 currentPrice, uint128 timestamp) external view returns (uint256 price_);

Parameters

NameTypeDescription
currentPriceuint128The current or predicted asset price.
timestampuint128The timestamp corresponding to currentPrice.

Returns

NameTypeDescription
price_uint256The predicted USDN token price.

usdnPrice

Calculates the USDN token price based on the given asset price at the current timestamp.

The effects of the funding and the PnL of the long positions since the last contract state update are taken into account.

function usdnPrice(uint128 currentPrice) external view returns (uint256 price_);

Parameters

NameTypeDescription
currentPriceuint128The asset price at block.timestamp.

Returns

NameTypeDescription
price_uint256The calculated USDN token price.

vaultAssetAvailableWithFunding

Gets the amount of assets in the vault for the given asset price and timestamp.

The effects of the funding, the PnL of the long positions and the accumulated fees since the last contract state update are taken into account, but not liquidations. If the provided timestamp is older than the last state update, the function reverts with UsdnProtocolTimestampTooOld.

function vaultAssetAvailableWithFunding(uint128 currentPrice, uint128 timestamp)
    external
    view
    returns (uint256 available_);

Parameters

NameTypeDescription
currentPriceuint128The current or predicted asset price.
timestampuint128The timestamp corresponding to currentPrice (must not be earlier than _lastUpdateTimestamp).

Returns

NameTypeDescription
available_uint256The available vault balance (cannot be less than 0).