UsdnProtocolCore

Git Source

Inherits: IUsdnProtocolCore, InitializableReentrancyGuard, AccessControlDefaultAdminRulesUpgradeable

Functions

initialize

Initializes the protocol by making an initial deposit and creating the first long position.

This function can only be called once. No other user actions can be performed until the protocol is initialized.

function initialize(uint128 depositAmount, uint128 longAmount, uint128 desiredLiqPrice, bytes calldata currentPriceData)
    external
    payable
    protocolInitializer
    onlyRole(DEFAULT_ADMIN_ROLE);

Parameters

NameTypeDescription
depositAmountuint128The amount of assets to deposit.
longAmountuint128The amount of assets for the long position.
desiredLiqPriceuint128The desired liquidation price for the long position, excluding the liquidation penalty.
currentPriceDatabytesThe encoded current price data.

funding

Computes the predicted funding value since the last state update for the specified timestamp.

The funding value, when multiplied by the long trading exposure, represents the asset balance to be transferred to the vault side, or to the long side if the value is negative. Reverts with UsdnProtocolTimestampTooOld if the given timestamp is older than the last state update.

function funding(uint128 timestamp)
    external
    view
    returns (int256 funding_, int256 fundingPerDay_, int256 oldLongExpo_);

Parameters

NameTypeDescription
timestampuint128The timestamp to use for the computation.

Returns

NameTypeDescription
funding_int256The funding magnitude (with FUNDING_RATE_DECIMALS decimals) since the last update timestamp.
fundingPerDay_int256The funding rate per day (with FUNDING_RATE_DECIMALS decimals).
oldLongExpo_int256The long trading exposure recorded at the last state update.