UsdnProtocolConstantsLibrary

Git Source

State Variables

LEVERAGE_DECIMALS

Number of decimals used for a position's leverage.

uint8 internal constant LEVERAGE_DECIMALS = 21;

FUNDING_RATE_DECIMALS

Number of decimals used for the funding rate.

uint8 internal constant FUNDING_RATE_DECIMALS = 18;

TOKENS_DECIMALS

Number of decimals used for tokens within the protocol (excluding the asset).

uint8 internal constant TOKENS_DECIMALS = 18;

LIQUIDATION_MULTIPLIER_DECIMALS

Number of decimals used for the fixed representation of the liquidation multiplier.

uint8 internal constant LIQUIDATION_MULTIPLIER_DECIMALS = 38;

FUNDING_SF_DECIMALS

Number of decimals in the scaling factor of the funding rate.

uint8 internal constant FUNDING_SF_DECIMALS = 3;

REBALANCER_MIN_LEVERAGE

Minimum leverage allowed for the rebalancer to open a position.

In edge cases where the rebalancer holds significantly more assets than the protocol, opening a position with the protocol's minimum leverage could cause a large overshoot of the target, potentially creating an even greater imbalance. To prevent this, the rebalancer can use leverage as low as the technical minimum (10 ** LEVERAGE_DECIMALS + 1).

uint256 internal constant REBALANCER_MIN_LEVERAGE = 10 ** LEVERAGE_DECIMALS + 1;

SDEX_BURN_ON_DEPOSIT_DIVISOR

Divisor for the ratio of USDN to SDEX burned on deposit.

uint256 internal constant SDEX_BURN_ON_DEPOSIT_DIVISOR = 1e8;

BPS_DIVISOR

Divisor for basis point (BPS) values.

uint256 internal constant BPS_DIVISOR = 10_000;

MAX_LIQUIDATION_ITERATION

Maximum number of tick liquidations that can be processed per call.

uint16 internal constant MAX_LIQUIDATION_ITERATION = 10;

NO_POSITION_TICK

Sentinel value indicating a PositionId that represents no position.

int24 internal constant NO_POSITION_TICK = type(int24).min;

DEAD_ADDRESS

Address holding the minimum supply of USDN and the first minimum long position.

address internal constant DEAD_ADDRESS = address(0xdead);

REMOVE_BLOCKED_PENDING_ACTIONS_DELAY

Delay after which a blocked pending action can be removed after _lowLatencyValidatorDeadline + _onChainValidatorDeadline.

uint16 internal constant REMOVE_BLOCKED_PENDING_ACTIONS_DELAY = 5 minutes;

MIN_USDN_SUPPLY

Minimum total supply of USDN allowed.

Upon the first deposit, this amount is sent to the dead address and becomes unrecoverable.

uint256 internal constant MIN_USDN_SUPPLY = 1000;

MIN_LONG_TRADING_EXPO_BPS

Minimum margin between total exposure and long balance.

Ensures the balance long does not increase in a way that causes the trading exposure to fall below this margin. If this occurs, the balance long is clamped to the total exposure minus the margin.

uint256 internal constant MIN_LONG_TRADING_EXPO_BPS = 100;

MIN_ACTIONABLE_PENDING_ACTIONS_ITER

Minimum iterations when searching for actionable pending actions in getActionablePendingActions.

uint256 internal constant MIN_ACTIONABLE_PENDING_ACTIONS_ITER = 20;

MIN_VALIDATION_DEADLINE

Minimum validation deadline for validators.

uint256 internal constant MIN_VALIDATION_DEADLINE = 60;

MAX_VALIDATION_DEADLINE

Maximum validation deadline for validators.

uint256 internal constant MAX_VALIDATION_DEADLINE = 1 days;

MAX_LIQUIDATION_PENALTY

Maximum liquidation penalty allowed.

uint256 internal constant MAX_LIQUIDATION_PENALTY = 1500;

MAX_SAFETY_MARGIN_BPS

Maximum safety margin allowed in basis points.

uint256 internal constant MAX_SAFETY_MARGIN_BPS = 2000;

MAX_EMA_PERIOD

Maximum EMA (Exponential Moving Average) period allowed.

uint256 internal constant MAX_EMA_PERIOD = 90 days;

MAX_POSITION_FEE_BPS

Maximum position fee allowed in basis points.

uint256 internal constant MAX_POSITION_FEE_BPS = 2000;

MAX_VAULT_FEE_BPS

Maximum vault fee allowed in basis points.

uint256 internal constant MAX_VAULT_FEE_BPS = 2000;

MAX_SDEX_REWARDS_RATIO_BPS

Maximum ratio of SDEX rewards allowed in basis points.

uint256 internal constant MAX_SDEX_REWARDS_RATIO_BPS = 1000;

MAX_LEVERAGE

Maximum leverage allowed.

uint256 internal constant MAX_LEVERAGE = 100 * 10 ** LEVERAGE_DECIMALS;

MAX_SECURITY_DEPOSIT

Maximum security deposit allowed.

uint256 internal constant MAX_SECURITY_DEPOSIT = 5 ether;

MAX_PROTOCOL_FEE_BPS

Maximum protocol fee allowed in basis points.

uint16 internal constant MAX_PROTOCOL_FEE_BPS = 3000;

INITIATE_CLOSE_TYPEHASH

EIP712 typehash for initiateClosePosition.

Used within EIP712 messages for domain-specific signing, enabling recovery of the signer via ECDSA-recover.

bytes32 internal constant INITIATE_CLOSE_TYPEHASH = keccak256(
    "InitiateClosePositionDelegation(bytes32 posIdHash,uint128 amountToClose,uint256 userMinPrice,address to,uint256 deadline,address positionOwner,address positionCloser,uint256 nonce)"
);

TRANSFER_POSITION_OWNERSHIP_TYPEHASH

EIP712 typehash for transferPositionOwnership.

Used within EIP712 messages for domain-specific signing, enabling recovery of the signer via ECDSA-recover.

bytes32 internal constant TRANSFER_POSITION_OWNERSHIP_TYPEHASH = keccak256(
    "TransferPositionOwnershipDelegation(bytes32 posIdHash,address positionOwner,address newPositionOwner,address delegatedAddress,uint256 nonce)"
);

SET_EXTERNAL_ROLE

Role signature for setting external contracts.

bytes32 public constant SET_EXTERNAL_ROLE = keccak256("SET_EXTERNAL_ROLE");

CRITICAL_FUNCTIONS_ROLE

Role signature for performing critical protocol actions.

bytes32 public constant CRITICAL_FUNCTIONS_ROLE = keccak256("CRITICAL_FUNCTIONS_ROLE");

SET_PROTOCOL_PARAMS_ROLE

Role signature for setting protocol parameters.

bytes32 public constant SET_PROTOCOL_PARAMS_ROLE = keccak256("SET_PROTOCOL_PARAMS_ROLE");

SET_USDN_PARAMS_ROLE

Role signature for setting USDN parameters.

bytes32 public constant SET_USDN_PARAMS_ROLE = keccak256("SET_USDN_PARAMS_ROLE");

SET_OPTIONS_ROLE

Role signature for configuring protocol options with minimal impact.

bytes32 public constant SET_OPTIONS_ROLE = keccak256("SET_OPTIONS_ROLE");

PROXY_UPGRADE_ROLE

Role signature for upgrading the protocol implementation.

bytes32 public constant PROXY_UPGRADE_ROLE = keccak256("PROXY_UPGRADE_ROLE");

PAUSER_ROLE

Role signature for pausing the protocol.

bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");

UNPAUSER_ROLE

Role signature for unpausing the protocol.

bytes32 public constant UNPAUSER_ROLE = keccak256("UNPAUSER_ROLE");

ADMIN_SET_EXTERNAL_ROLE

Admin role for managing the SET_EXTERNAL_ROLE.

bytes32 public constant ADMIN_SET_EXTERNAL_ROLE = keccak256("ADMIN_SET_EXTERNAL_ROLE");

ADMIN_CRITICAL_FUNCTIONS_ROLE

Admin role for managing the CRITICAL_FUNCTIONS_ROLE.

bytes32 public constant ADMIN_CRITICAL_FUNCTIONS_ROLE = keccak256("ADMIN_CRITICAL_FUNCTIONS_ROLE");

ADMIN_SET_PROTOCOL_PARAMS_ROLE

Admin role for managing the SET_PROTOCOL_PARAMS_ROLE.

bytes32 public constant ADMIN_SET_PROTOCOL_PARAMS_ROLE = keccak256("ADMIN_SET_PROTOCOL_PARAMS_ROLE");

ADMIN_SET_USDN_PARAMS_ROLE

Admin role for managing the SET_USDN_PARAMS_ROLE.

bytes32 public constant ADMIN_SET_USDN_PARAMS_ROLE = keccak256("ADMIN_SET_USDN_PARAMS_ROLE");

ADMIN_SET_OPTIONS_ROLE

Admin role for managing the SET_OPTIONS_ROLE.

bytes32 public constant ADMIN_SET_OPTIONS_ROLE = keccak256("ADMIN_SET_OPTIONS_ROLE");

ADMIN_PROXY_UPGRADE_ROLE

Admin role for managing the PROXY_UPGRADE_ROLE.

bytes32 public constant ADMIN_PROXY_UPGRADE_ROLE = keccak256("ADMIN_PROXY_UPGRADE_ROLE");

ADMIN_PAUSER_ROLE

Admin role for managing the PAUSER_ROLE.

bytes32 public constant ADMIN_PAUSER_ROLE = keccak256("ADMIN_PAUSER_ROLE");

ADMIN_UNPAUSER_ROLE

Admin role for managing the UNPAUSER_ROLE.

bytes32 public constant ADMIN_UNPAUSER_ROLE = keccak256("ADMIN_UNPAUSER_ROLE");