UsdnProtocolCore
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
Name | Type | Description |
---|---|---|
depositAmount | uint128 | The amount of assets to deposit. |
longAmount | uint128 | The amount of assets for the long position. |
desiredLiqPrice | uint128 | The desired liquidation price for the long position, excluding the liquidation penalty. |
currentPriceData | bytes | The 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
Name | Type | Description |
---|---|---|
timestamp | uint128 | The timestamp to use for the computation. |
Returns
Name | Type | Description |
---|---|---|
funding_ | int256 | The funding magnitude (with FUNDING_RATE_DECIMALS decimals) since the last update timestamp. |
fundingPerDay_ | int256 | The funding rate per day (with FUNDING_RATE_DECIMALS decimals). |
oldLongExpo_ | int256 | The long trading exposure recorded at the last state update. |