Skip to main content

DomFiPerp

DomFiPerp

Perpetual long/short levered instruments for Domination Finance

The heart of Domination Finance exchange. Tracks positions per user. Prevents positions from being changed in ways that would violate vault-level risk management constraints.

Addresses

ChainAddress
Arbitrum Sepolia0x4F68Fd7e7115eCD543ef8FFda8085f3FFb773717

Functions

constructor

Initialize a new DomFiPerp.

constructor(
contract IPriceFeed _priceFeed,
contract IFeeCalculator _feeCalculator,
contract IFundingManager _fundingManager,
contract IDomFiVault _domFiVault,
contract IFeeDistributor _feeDistributor
) public
Dev note

owner, guardian, and gov are all initialized to msg.sender

Parameters

NameTypeDescription
_priceFeedcontract IPriceFeedSource of price data. See priceFeed
_feeCalculatorcontract IFeeCalculatorfeeCalculator
_fundingManagercontract IFundingManagerfundingManager
_domFiVaultcontract IDomFiVaultdomFiVault
_feeDistributorcontract IFeeDistributorfeeDistributor

asset

Collateral token of this perp, e.g. USDC or wETH

function asset() external view returns (contract IERC20 assetToken)

Return Values

NameTypeDescription
assetTokencontract IERC20assetToken Address of token

increasePosition

Increase (or create) a position.

function increasePosition(
address user,
PositionLabel positionLabel,
bytes32 productId,
uint256 margin,
bool isLong,
FPUnsigned leverage
) external

Parameters

NameTypeDescription
useraddressOwner of the position. msg.sender must be user or their manager.
positionLabelPositionLabelUser-defined ID of position to increase or create. See getPositionId().
productIdbytes32Product of this position. Ignored in favor of stored value if position already exists.
marginuint256Margin to increase this position by.
isLongboolDirection of this position. Ignored in favor of stored value if position already exists.
leverageFPUnsignedLeverage of this increase's margin. After increase, resulting position must have valid leverage.

_computeIncreasePosition

Compute, and optionally store, an increased or new position

function _computeIncreasePosition(
bool isLong,
PositionLabel positionLabel,
bool store,
address user,
FPUnsigned leverage,
bytes32 productId,
uint256 margin
) internal returns (
struct IDomFiPerp.IncreasePreview increase
)
Dev note

Leverage of final position must be in range [1,product.maxLeverage][1, \text{product.maxLeverage}].

Parameters

NameTypeDescription
isLongboolWhether position is long. Optional and ignored ONLY if modifying an existing position.
positionLabelPositionLabel
storeboolIf true, increase (or create) position. Otherwise calculate the preview increase.
useraddress
leverageFPUnsigned
productIdbytes32Product for this position. Optional and ignored ONLY if modifying an existing position.
marginuint256

previewIncrease

Preview results of an increase

function previewIncrease(
address user,
PositionLabel positionLabel,
bytes32 productId,
uint256 margin,
bool isLong,
FPUnsigned leverage
) external returns (
struct IDomFiPerp.IncreasePreview increasePreview
)
Dev note

May revert if the increase would revert.

Parameters

NameTypeDescription
useraddressOwner of the position
positionLabelPositionLabelUser-defined label of the position
productIdbytes32Product for this position. Required for new positions; ignored ONLY if modifying an existing position.
marginuint256Collateral added to the position by the increase
isLongboolWhether position is long. Required for new positions; ignored ONLY if modifying an existing position.
leverageFPUnsignedLeverage at which margin will be added to the position

Return Values

NameTypeDescription
increasePreviewstruct IDomFiPerp.IncreasePreviewComputed IncreasePreview for the position

removeMargin

Remove margin from a position (increasing leverage). Caller must be the position's owner or their manager.

function removeMargin(PositionId positionId, uint256 marginToRemove, address recipient) external
Dev note

Reverts if

  • resulting position is liquidatable
  • resulting position has leverage<1 or leverage>product.maxLeverage
  • resulting position has margin < minMargin
  • removeMargin > position.margin

Parameters

NameTypeDescription
positionIdPositionIdPosition to remove margin from
marginToRemoveuint256Collateral to remove from margin
recipientaddressSend removed collateral to this address

canRemove

Whether a position can have margin withdrawn without liquidation or overleverage, and if so how much. See removeMargin().

function canRemove(PositionId positionId) public returns (bool canRemove_, int256 removeableMargin)

Parameters

NameTypeDescription
positionIdPositionIdGlobal ID of Position to check

Return Values

NameTypeDescription
canRemove_boolWhether it has margin available to withdraw
removeableMarginint256Available removal. Negative if !canRemove_

decreasePositions

Decrease (or close) multiple positions simultaneously. Fails unless all succeed.

function decreasePositions(struct IDomFiPerp.DecreasePositionParams[] params) external

Parameters

NameTypeDescription
paramsstruct IDomFiPerp.DecreasePositionParams[]List of decreases. See DecreasePositionParams

_computeDecrease

function _computeDecrease(
struct IDomFiPerp.Position position,
uint256 margin,
bool store
) internal returns (
struct IDomFiPerp.DecreasePreview decrease
)

previewDecrease

Preview results of a decrease

function previewDecrease(
PositionId positionId,
uint256 decreaseMargin
) external returns (
struct IDomFiPerp.DecreasePreview decreasePreview
)

Parameters

NameTypeDescription
positionIdPositionIdGlobal ID of position to be decreased. Must exist.
decreaseMarginuint256Margin amount to decrease by. May be greater than position margin

Return Values

NameTypeDescription
decreasePreviewstruct IDomFiPerp.DecreasePreviewComputed DecreasePreview for the position

decreasePositionWithId

Decrease (or close) a position, and claim proportional share of position margin + PnL. Unlike removing margin, leverage remains the same.

function decreasePositionWithId(PositionId positionId, uint256 margin, address recipient) public
Dev note

If margin >= position.margin, close position.

Parameters

NameTypeDescription
positionIdPositionIdTarget position. msg.sender must be its owner or their manager.
marginuint256Margin units to decrease
recipientaddressWhere to send reclaimed share of position value + PnL

liquidatePositions

Liquidate positionIds and send any bounty to feeReceiver

function liquidatePositions(PositionId[] positionIds, address feeReceiver) external
Dev note

Reverts if any positions are not liquidatable. Reverts if public liquidation is disabled but msg.sender is not a registered liquidator.

Parameters

NameTypeDescription
positionIdsPositionId[]Positions to liquidate
feeReceiveraddressRecipient of any liquidator rewards

canLiquidate

Liquidation information for each position in positionIds

function canLiquidate(
PositionId[] positionIds
) external returns (
FPSigned[] pnl,
FPSigned[] funding,
bool[] isLiquidatable
)

Parameters

NameTypeDescription
positionIdsPositionId[]Positions to compute liquidation info for

Return Values

NameTypeDescription
pnlFPSigned[]Position PnL. See getPositionPnlAndFunding
fundingFPSigned[]Position funding. See getPositionPnlAndFunding
isLiquidatablebool[]Whether this position is liquidatable

getPositionPnlAndFunding

Get the Pnl of a position, including funding

function getPositionPnlAndFunding(
bytes32 productId,
bool isLong,
FPUnsigned leverage,
FPUnsigned positionPrice,
uint256 margin,
FPSigned funding,
FPUnsigned price
) public returns (
FPSigned pnl,
FPSigned fundingDebt
)

Parameters

NameTypeDescription
productIdbytes32productId of position to evaluate
isLongboolisLong of position to evaluate
leverageFPUnsignedleverage of position to evaluate
positionPriceFPUnsignedprice of position to evaluate
marginuint256margin of position to evaluate
fundingFPSignedfunding of position to evaluate
priceFPUnsignedCurrent price of the position's product

Return Values

NameTypeDescription
pnlFPSignedIncrease in position value since creation, minus funding
fundingDebtFPSignedAccrued funding (and interest) which was subtracted from this position's PnL. A positive value reduces position value.

getPositionPnlRate

Compute the current PnL rate (PnL / margin) of a position at the most recent price.

function getPositionPnlRate(PositionId positionId) public returns (FPSigned pnlRate)

Parameters

NameTypeDescription
positionIdPositionIdGlobally-unique ID of the position in question

Return Values

NameTypeDescription
pnlRateFPSignedPnL rate of this position. 100% = 1.0

_canLiquidate

Liquidation information for a position

function _canLiquidate(
struct IDomFiPerp.Position position,
FPUnsigned price
) internal returns (
FPSigned pnl,
FPSigned funding,
bool isLiquidatable
)

Parameters

NameTypeDescription
positionstruct IDomFiPerp.PositionStored position to evaluate
priceFPUnsignedCurrent price of position's product

Return Values

NameTypeDescription
pnlFPSignedPnL of this position, including funding
fundingFPSignedAccrued funding cost (+) or payment (-)
isLiquidatableboolWhether PnL has reached the liquidation threshold

isManagerFor

Whether manager is a registered manager approved by account .

function isManagerFor(address manager, address account) public view returns (bool isManager)

Parameters

NameTypeDescription
manageraddressPossible manager (for instance, an OrderBook)
accountaddressUser that may have approved manager

Return Values

NameTypeDescription
isManagerboolWhether manager is a registered manager approved by account .

validateOI

Revert if balance times utilizationMultiplier is less than OI

function validateOI(uint256 balance) external view
Dev note

Triggers after each transfer of DOMD

Parameters

NameTypeDescription
balanceuint256Balance of DomFiVault

getTotalPnl

Compute total trader PnL across all positions, ignoring maxPositionProfit

function getTotalPnl() external returns (FPSigned totalPnl)
Dev note

Used for withdraw delays. Computed with composite positions.

Return Values

NameTypeDescription
totalPnlFPSignedtotalPnl Sum of all position PnLs if there was no maxPositionProfit

getProduct

Get product details. See IDomFiPerp.Product.

function getProduct(bytes32 productId) external view returns (struct IDomFiPerp.Product product)

Parameters

NameTypeDescription
productIdbytes32ID of this product

Return Values

NameTypeDescription
productstruct IDomFiPerp.ProductSaved parameters for this product

getPositionId

Compute the global position ID of a user's position

function getPositionId(
address account,
PositionLabel positionLabel
) public view returns (
PositionId positionId
)

Parameters

NameTypeDescription
accountaddressowner of this position
positionLabelPositionLabelUser-defined label for this position

Return Values

NameTypeDescription
positionIdPositionIdGlobally unique position ID

getPosition

Get details of a position. See IDomFiPerp.Position

function getPosition(PositionId positionId) external view returns (struct IDomFiPerp.Position position)

Parameters

NameTypeDescription
positionIdPositionId

Return Values

NameTypeDescription
positionstruct IDomFiPerp.PositionSaved position

getPosition

Get details of a user position. See IDomFiPerp.Position

function getPosition(
address account,
PositionLabel positionLabel
) external view returns (
struct IDomFiPerp.Position position
)

Parameters

NameTypeDescription
accountaddressOwner of the position
positionLabelPositionLabelUser-defined label for this position

Return Values

NameTypeDescription
positionstruct IDomFiPerp.PositionSaved position

getPositions

Get details for many positions. See IDomFiPerp.Position

function getPositions(PositionId[] positionIds) external view returns (struct IDomFiPerp.Position[] _positions)

Parameters

NameTypeDescription
positionIdsPositionId[]Globally-unique position IDs

Return Values

NameTypeDescription
_positionsstruct IDomFiPerp.Position[]Saved positions. May be uninitialized

getMaxExposure

Get max exposure for a product: the highest permitted value of |long open interest - short open interest|

function getMaxExposure(
FPUnsigned productWeight,
FPUnsigned productExposureMultiplier
) public view returns (
FPUnsigned maxExposure
)

Parameters

NameTypeDescription
productWeightFPUnsignedproduct.weight; determines vault balance allocated to this product
productExposureMultiplierFPUnsignedmultiple of product's vault share allowed for exposure

Return Values

NameTypeDescription
maxExposureFPUnsignedpermitted max exposure

_getMaxSafeWithdrawableMargin

Max margin that can be withdrawn from this position without reverting or liquidating

function _getMaxSafeWithdrawableMargin(
FPSigned fundingPayment,
struct IDomFiPerp.Position position,
FPUnsigned maxLeverage,
FPUnsigned liquidationThreshold
) internal view returns (
int256
)
Dev note

If positive, removing this much liquidity should not

  • revert due to exposure/OI limits
  • revert due to out-of-bounds leverage
  • result in a liquidatable position

Parameters

NameTypeDescription
fundingPaymentFPSignedFunding payment owed by this position
positionstruct IDomFiPerp.PositionPosition to be withdrawn from
maxLeverageFPUnsignedMax leverage of this position's product
liquidationThresholdFPUnsignedLiquidation threshold for this product, e.g. 0.7

Return Values

NameTypeDescription
[0]int256int256 Removable margin (+) or required margin add (-)

addProduct

Add a new product

function addProduct(struct IDomFiPerp.ProductParams _product) external

Parameters

NameTypeDescription
_productstruct IDomFiPerp.ProductParamsSee IDomFiPerp.ProductParams

updateProductMaxLeverage

Update the max leverage of a product

function updateProductMaxLeverage(bytes32 _productId, FPUnsigned _maxLeverage) external

Parameters

NameTypeDescription
_productIdbytes32Product to change
_maxLeverageFPUnsignedSee IDomFiPerp.Product.maxLeverage

updateProductFee

Update the base trade fee for a product

function updateProductFee(bytes32 _productId, FPUnsigned _fee) external

Parameters

NameTypeDescription
_productIdbytes32Product to change
_feeFPUnsignedSee IDomFiPerp.Product.fee

updateProductActive

Enable or disable a product

function updateProductActive(bytes32 _productId, bool _isActive) external

Parameters

NameTypeDescription
_productIdbytes32Product to (de)activate
_isActiveboolIDomFiPerp.Product.isActive

updateProductMinPriceChange

Update the minimum price change for positions on a product.

function updateProductMinPriceChange(bytes32 _productId, FPUnsigned _minPriceChange) external

Parameters

NameTypeDescription
_productIdbytes32Product to change
_minPriceChangeFPUnsignedSee IDomFiPerp.Product.minPriceChange

updateProductLiquidationBounty

Update the liquidation bounty for positions on a product

function updateProductLiquidationBounty(bytes32 _productId, FPUnsigned _liquidationBounty) external

Parameters

NameTypeDescription
_productIdbytes32Product to change
_liquidationBountyFPUnsignedSee IDomFiPerp.Product.liquidationBounty

updateProductExposureMultiplier

Update a product's exposure multiplier

function updateProductExposureMultiplier(bytes32 _productId, FPUnsigned _exposureMultiplier) external

Parameters

NameTypeDescription
_productIdbytes32Product to change
_exposureMultiplierFPUnsignedSee IDomFiPerp.Product.exposureMultiplier

updateProductReserveMultiplier

Update a product's reserve multiplier

function updateProductReserveMultiplier(bytes32 _productId, FPUnsigned _reserveMultiplier) external

Parameters

NameTypeDescription
_productIdbytes32Product to change
_reserveMultiplierFPUnsignedSee IDomFiPerp.Product.reserveMultiplier

updateProductWeight

Update a product's weight for exposure calculations

function updateProductWeight(bytes32 _productId, FPUnsigned _weight) external

Parameters

NameTypeDescription
_productIdbytes32Product to change
_weightFPUnsignedSee IDomFiPerp.Product.weight

updateProductLiquidationThreshold

Update the liquidation threshold for positions on a product

function updateProductLiquidationThreshold(bytes32 _productId, FPUnsigned _liquidationThreshold) external

Parameters

NameTypeDescription
_productIdbytes32Product to change
_liquidationThresholdFPUnsignedSee IDomFiPerp.Product.liquidationThreshold

updateProductFundingExponent

Set product funding exponent. Funding rate is (productExposure / maxExposure) ^ fundingExponent * fundingMultiplier

function updateProductFundingExponent(bytes32 _productId, FPUnsigned _fundingExponent) external
Dev note

Set to 1 to "disable".

Parameters

NameTypeDescription
_productIdbytes32ID of product to change funding exponent
_fundingExponentFPUnsignedNew funding exponent. Must be > 0

updatePrice

Emit a PriceUpdate event for easy off-chain data access

function updatePrice(bytes32 productId, FPUnsigned value, uint64 timestamp, address oracle) external
Dev note

This allows order bots to get price events without tracking oracle changes.

Parameters

NameTypeDescription
productIdbytes32ID of product with price update
valueFPUnsignedNew price
timestampuint64Timestamp at which price was generated
oracleaddressSource of price update

setManager

(De)register an address as a manager. With permission, managers can change positions on behalf of other addresses.

function setManager(address _manager, bool _isActive) external

Parameters

NameTypeDescription
_manageraddressAddress to affect
_isActiveboolWhether this address should be a manager.

setAccountManager

Permit or prohibit another address from changing the sender's positions

function setAccountManager(address _manager, bool _isActive) external

Parameters

NameTypeDescription
_manageraddressAddress to approve or remove, e.g. OrderBook
_isActiveboolWhether this address may change the sender's positions.

setMinMargin

Set the minimum margin increment for all positions

function setMinMargin(uint256 _minMargin) external
Dev note

USD value of minMargin liquidationThreshold liquidationBounty should be greater than the typical USD value of gas to call liquidatePosition when the network is congested.

Parameters

NameTypeDescription
_minMarginuint256Prevent actions that would create a position with less than this much collateral

setTradeEnabled

Enable or disable trading

function setTradeEnabled(bool _isTradeEnabled) external

Parameters

NameTypeDescription
_isTradeEnabledboolWhether positions can be created/increased or not

setMaxShift

Set max exposure-balancing slippage. See maxShift

function setMaxShift(FPUnsigned _maxShift) external

Parameters

NameTypeDescription
_maxShiftFPUnsignedNew value for maxShift. 0-1%

setMinProfitTime

Set delay before positions with <minProfit can be cashed out

function setMinProfitTime(uint256 _minProfitTime) external

Parameters

NameTypeDescription
_minProfitTimeuint256New value for minProfitTime

setAllowPublicLiquidator

Allow anybody to liquidate positions, or restrict it to approved addresses only

function setAllowPublicLiquidator(bool _allowPublicLiquidator) external

Parameters

NameTypeDescription
_allowPublicLiquidatorboolNew value for allowPublicLiquidator

setIsManagerOnlyForOpen

Restrict position increases to approved addresses, or open to all

function setIsManagerOnlyForOpen(bool _isManagerOnlyForOpen) external

Parameters

NameTypeDescription
_isManagerOnlyForOpenboolNew value for isManagerOnlyForOpen

setIsManagerOnlyForClose

Restrict position decreases to approved addresses, or open to all

function setIsManagerOnlyForClose(bool _isManagerOnlyForClose) external

Parameters

NameTypeDescription
_isManagerOnlyForCloseboolNew value for isManagerOnlyForClose

setUtilizationMultiplier

Set the utilization multiplier. Open interest is restricted to utilizationMultiplier times the vault balance

function setUtilizationMultiplier(FPUnsigned _utilizationMultiplier) external

Parameters

NameTypeDescription
_utilizationMultiplierFPUnsignedNew value for utilizationMultiplier

setMaxExposureMultiplier

Set the max exposure multiplier. Exposure in any product is limited to maxExposureMultiplier times its share of the vault-level max exposure.

function setMaxExposureMultiplier(FPUnsigned _maxExposureMultiplier) external

Parameters

NameTypeDescription
_maxExposureMultiplierFPUnsignedNew value, > 0, for maxExposureMultiplier.

setHelpfulShiftScaler

Set helpfulShiftScaler. Prices are shifted in proportion to exposure. For "helpful" orders that reduce exposure, scale price shift.

function setHelpfulShiftScaler(FPUnsigned _helpfulShiftScaler) external
Dev note

This should be <1. Set to 1 to disable.

Parameters

NameTypeDescription
_helpfulShiftScalerFPUnsignedNew value, >0, for helpfulShiftScaler.

setAddresses

Update satellite contract addresses

function setAddresses(
contract IPriceFeed _priceFeed,
contract IFeeCalculator _feeCalculator,
contract IFundingManager _fundingManager,
contract IFeeDistributor _feeDistributor
) external

Parameters

NameTypeDescription
_priceFeedcontract IPriceFeedNew price feed contract
_feeCalculatorcontract IFeeCalculatorNew fee calculator
_fundingManagercontract IFundingManagerNew funding manager
_feeDistributorcontract IFeeDistributorNew fee distributor

setMaxPositionProfit

function setMaxPositionProfit(FPUnsigned _maxPositionProfit) external

setLiquidator

Register or deregister an address as an active liquidator

function setLiquidator(address _liquidator, bool _isActive) external

Parameters

NameTypeDescription
_liquidatoraddressAddress to (de)activate as a liquidator
_isActiveboolWhether it can liquidate when !allowPublicLiquidators

setliquidationRegistry

Set an ILiquidationRegistry to be notified whenever a position is created.

function setliquidationRegistry(contract ILiquidationRegistry _liquidationRegistry) external

Parameters

NameTypeDescription
_liquidationRegistrycontract ILiquidationRegistryNew ILiquidationRegistry. 0x00 to disable.

setOwner

Set the owner, able to do anything but set other roles

function setOwner(address _owner) external

Parameters

NameTypeDescription
_owneraddressNew owner address

setGuardian

Set the guardian, address able to pause (but not resume) trading

function setGuardian(address _guardian) external

Parameters

NameTypeDescription
_guardianaddressNew guardian address

transferGov

Transfer governance permissions to another address. Recipient must call acceptGov.

function transferGov(address newGov) external
Dev note

Must be called by existing governance address

Parameters

NameTypeDescription
newGovaddressNew address

acceptGov

Complete transfer of governance permissions to the sender.

function acceptGov() public

pauseTrading

Pause trading, preventing anyone from opening new positions or increasing existing ones. Guardian only.

function pauseTrading() external

Events

AddressesSet

event AddressesSet(
contract IPriceFeed priceFeed,
contract IFeeCalculator feeCalculator,
contract IFundingManager fundingManager,
contract IFeeDistributor feeDistributor
)

PriceUpdate

event PriceUpdate(bytes32 productId, FPUnsigned value, uint64 timestamp, address oracle)

Errors

InvalidProduct

Could not change product parameter because the supplied productId refers to an uninitialized product.

error InvalidProduct()

InvalidProductId

The supplied productId was 0x0.

error InvalidProductId()

InvalidProductLiquidationThreshold

error InvalidProductLiquidationThreshold()

InvalidProductWeight

error InvalidProductWeight()

InvalidProductExposureMultiplier

error InvalidProductExposureMultiplier()

InvalidProductFundingExponent

Attempted to set a product's funding exponent to zero, which would lead to constant slippage of fundingMultiplier%. To disable funding exponent, set it to 1.

error InvalidProductFundingExponent()

ZeroRemainingMargin

Attempted to remove margin from a position, but no margin would be left.

error ZeroRemainingMargin()

MarginBelowMin

Attempted to remove margin from a position, but the position would be left with less than the minimum margin amount.

error MarginBelowMin()

InvalidPosition

error InvalidPosition()

RemoveCallerNotAllowed

Attempted to remove margin from a position, but the caller does not own the position and isn't a registered manager of the owner.

error RemoveCallerNotAllowed()

DecreaseCallerNotAllowed

Attempted to decrease a position, but the caller does not own the position and isn't a registered manager of the owner.

error DecreaseCallerNotAllowed()

LeverageBelowMin

error LeverageBelowMin()

LeverageAboveMax

error LeverageAboveMax()

PriceFeedOnly

error PriceFeedOnly()

DuplicatedProduct

error DuplicatedProduct()

InactiveProduct

error InactiveProduct()

LiquidatorOnly

error LiquidatorOnly()

NotLiquidatable

error NotLiquidatable()

Liquidatable

error Liquidatable()

MaxOpenInterestExceeded

error MaxOpenInterestExceeded()

MaxExposureExceeded

error MaxExposureExceeded()

MaxUtilizationExceeded

error MaxUtilizationExceeded()

ProductExposureExceeded

error ProductExposureExceeded(bool isLong)

NoRemovableMargin

error NoRemovableMargin()

TradeDisabled

error TradeDisabled()

IncreaseCallerNotAllowed

error IncreaseCallerNotAllowed()

OwnerOnly

error OwnerOnly()

GovOnly

error GovOnly()

PendingGovOnly

error PendingGovOnly()

GuardianOnly

error GuardianOnly()

Variables

owner

Manages vault parameters, products, and managers; toggles trading.

guardian

Can pause (but not resume) trading.

gov

Can set owner, guardian, and gov.

priceFeed

feeCalculator

fundingManager

domFiVault

feeDistributor

distributes trade/liquidity fees to vault LPs

managers

Managers may make trades on behalf of other addresses, e.g. OrderBook

approvedManagers

Managers must be approved by users

isManagerOnlyForOpen

allow only managers to increase positions

isManagerOnlyForClose

allow only managers to decrease positions

minProfitTime

Wait before trades can be cashed out with < minProfit

minMargin

Minimum margin increment.

Dev note

Prevents the creation of very small positions, which would be unprofitable to liquidate after gas fees.

maxShift

Dev note

scaling factor for price shift that balances long and short exposure

helpfulShiftScaler

Dev note

scale price shift to 1/3 (giving more favorable prices) for orders that reduce net exposure

allowPublicLiquidator

liquidators

maxPositionProfit

max profit as multiple of margin. default 900%

totalWeight

total exposure weights of all products

totalOpenInterest

total size (margin * leverage) of all outstanding positions in token wei

utilizationMultiplier

Total open interest (long + short) is limited to 10x the vault balance.

maxExposureMultiplier

Open interest of a product is limited to 3x its proportional share of getMaxExposure().

liquidationRegistry