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.
- Gets prices from PriceFeed
- Gets trade fee amounts from FeeCalculator and sends them to FeeDistributor
- Gets PnLs from FundingManager and PerpLib
- Stores collateral in DomFiVault
Addresses
Chain | Address |
---|---|
Arbitrum Sepolia | 0x4F68Fd7e7115eCD543ef8FFda8085f3FFb773717 |
Zircuit | 0xAE68DF62713f4337fbd63a97EC625f8B927A154a |
Functions
constructor
Initialize a new DomFiPerp.
constructor(
contract IPriceFeed _priceFeed,
contract IFeeCalculator _feeCalculator,
contract IFundingManager _fundingManager,
contract IDomFiVault _domFiVault,
contract IFeeDistributor _feeDistributor
) public
Parameters
Name | Type | Description |
---|---|---|
_priceFeed | contract IPriceFeed | Source of price data. See priceFeed |
_feeCalculator | contract IFeeCalculator | feeCalculator |
_fundingManager | contract IFundingManager | fundingManager |
_domFiVault | contract IDomFiVault | domFiVault |
_feeDistributor | contract IFeeDistributor | feeDistributor |
asset
Collateral token of this perp, e.g. USDC or wETH
function asset() external view returns (contract IERC20 assetToken)
Return Values
Name | Type | Description |
---|---|---|
assetToken | contract IERC20 | assetToken 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
Name | Type | Description |
---|---|---|
user | address | Owner of the position. msg.sender must be user or their manager. |
positionLabel | PositionLabel | User-defined ID of position to increase or create. See getPositionId(). |
productId | bytes32 | Product of this position. Ignored in favor of stored value if position already exists. |
margin | uint256 | Margin to increase this position by. |
isLong | bool | Direction of this position. Ignored in favor of stored value if position already exists. |
leverage | FPUnsigned | Leverage 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
)
Leverage of final position must be in range .
Parameters
Name | Type | Description |
---|---|---|
isLong | bool | Whether position is long. Optional and ignored ONLY if modifying an existing position. |
positionLabel | PositionLabel | |
store | bool | If true, increase (or create) position. Otherwise calculate the preview increase. |
user | address | |
leverage | FPUnsigned | |
productId | bytes32 | Product for this position. Optional and ignored ONLY if modifying an existing position. |
margin | uint256 |
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
)
May revert if the increase would revert.
Parameters
Name | Type | Description |
---|---|---|
user | address | Owner of the position |
positionLabel | PositionLabel | User-defined label of the position |
productId | bytes32 | Product for this position. Required for new positions; ignored ONLY if modifying an existing position. |
margin | uint256 | Collateral added to the position by the increase |
isLong | bool | Whether position is long. Required for new positions; ignored ONLY if modifying an existing position. |
leverage | FPUnsigned | Leverage at which margin will be added to the position |
Return Values
Name | Type | Description |
---|---|---|
increasePreview | struct IDomFiPerp.IncreasePreview | Computed 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
Reverts if
- resulting position is liquidatable
- resulting position has
leverage<1
orleverage>product.maxLeverage
- resulting position has margin < minMargin
- removeMargin > position.margin
Parameters
Name | Type | Description |
---|---|---|
positionId | PositionId | Position to remove margin from |
marginToRemove | uint256 | Collateral to remove from margin |
recipient | address | Send 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
Name | Type | Description |
---|---|---|
positionId | PositionId | Global ID of Position to check |
Return Values
Name | Type | Description |
---|---|---|
canRemove_ | bool | Whether it has margin available to withdraw |
removeableMargin | int256 | Available removal. Negative if !canRemove_ |
decreasePositions
Decrease (or close) multiple positions simultaneously. Fails unless all succeed.
function decreasePositions(struct IDomFiPerp.DecreasePositionParams[] params) external
Parameters
Name | Type | Description |
---|---|---|
params | struct 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
Name | Type | Description |
---|---|---|
positionId | PositionId | Global ID of position to be decreased. Must exist. |
decreaseMargin | uint256 | Margin amount to decrease by. May be greater than position margin |
Return Values
Name | Type | Description |
---|---|---|
decreasePreview | struct IDomFiPerp.DecreasePreview | Computed 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
If margin >= position.margin
, close position.
Parameters
Name | Type | Description |
---|---|---|
positionId | PositionId | Target position. msg.sender must be its owner or their manager. |
margin | uint256 | Margin units to decrease |
recipient | address | Where to send reclaimed share of position value + PnL |
liquidatePositions
Liquidate positionIds
and send any bounty to feeReceiver
function liquidatePositions(PositionId[] positionIds, address feeReceiver) external
Reverts if any positions are not liquidatable. Reverts if public liquidation is disabled but msg.sender is not a registered liquidator.
Parameters
Name | Type | Description |
---|---|---|
positionIds | PositionId[] | Positions to liquidate |
feeReceiver | address | Recipient 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
Name | Type | Description |
---|---|---|
positionIds | PositionId[] | Positions to compute liquidation info for |
Return Values
Name | Type | Description |
---|---|---|
pnl | FPSigned[] | Position PnL. See getPositionPnlAndFunding |
funding | FPSigned[] | Position funding. See getPositionPnlAndFunding |
isLiquidatable | bool[] | 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
Name | Type | Description |
---|---|---|
productId | bytes32 | productId of position to evaluate |
isLong | bool | isLong of position to evaluate |
leverage | FPUnsigned | leverage of position to evaluate |
positionPrice | FPUnsigned | price of position to evaluate |
margin | uint256 | margin of position to evaluate |
funding | FPSigned | funding of position to evaluate |
price | FPUnsigned | Current price of the position's product |
Return Values
Name | Type | Description |
---|---|---|
pnl | FPSigned | Increase in position value since creation, minus funding |
fundingDebt | FPSigned | Accrued 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
Name | Type | Description |
---|---|---|
positionId | PositionId | Globally-unique ID of the position in question |
Return Values
Name | Type | Description |
---|---|---|
pnlRate | FPSigned | PnL 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
Name | Type | Description |
---|---|---|
position | struct IDomFiPerp.Position | Stored position to evaluate |
price | FPUnsigned | Current price of position's product |
Return Values
Name | Type | Description |
---|---|---|
pnl | FPSigned | PnL of this position, including funding |
funding | FPSigned | Accrued funding cost (+) or payment (-) |
isLiquidatable | bool | Whether 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
Name | Type | Description |
---|---|---|
manager | address | Possible manager (for instance, an OrderBook) |
account | address | User that may have approved manager |
Return Values
Name | Type | Description |
---|---|---|
isManager | bool | Whether manager is a registered manager approved by account . |
validateOI
Revert if balance
times utilizationMultiplier is less than OI
function validateOI(uint256 balance) external view
Triggers after each transfer of DOMD
Parameters
Name | Type | Description |
---|---|---|
balance | uint256 | Balance of DomFiVault |
getTotalPnl
Compute total trader PnL across all positions, ignoring maxPositionProfit
function getTotalPnl() external returns (FPSigned totalPnl)
Used for withdraw delays. Computed with composite positions.
Return Values
Name | Type | Description |
---|---|---|
totalPnl | FPSigned | totalPnl 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
Name | Type | Description |
---|---|---|
productId | bytes32 | ID of this product |
Return Values
Name | Type | Description |
---|---|---|
product | struct IDomFiPerp.Product | Saved 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
Name | Type | Description |
---|---|---|
account | address | owner of this position |
positionLabel | PositionLabel | User-defined label for this position |
Return Values
Name | Type | Description |
---|---|---|
positionId | PositionId | Globally unique position ID |
getPosition
Get details of a position. See IDomFiPerp.Position
function getPosition(PositionId positionId) external view returns (struct IDomFiPerp.Position position)
Parameters
Name | Type | Description |
---|---|---|
positionId | PositionId |
Return Values
Name | Type | Description |
---|---|---|
position | struct IDomFiPerp.Position | Saved 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
Name | Type | Description |
---|---|---|
account | address | Owner of the position |
positionLabel | PositionLabel | User-defined label for this position |
Return Values
Name | Type | Description |
---|---|---|
position | struct IDomFiPerp.Position | Saved position |
getPositions
Get details for many positions. See IDomFiPerp.Position
function getPositions(PositionId[] positionIds) external view returns (struct IDomFiPerp.Position[] _positions)
Parameters
Name | Type | Description |
---|---|---|
positionIds | PositionId[] | Globally-unique position IDs |
Return Values
Name | Type | Description |
---|---|---|
_positions | struct 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
Name | Type | Description |
---|---|---|
productWeight | FPUnsigned | product.weight ; determines vault balance allocated to this product |
productExposureMultiplier | FPUnsigned | multiple of product's vault share allowed for exposure |
Return Values
Name | Type | Description |
---|---|---|
maxExposure | FPUnsigned | permitted 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
)
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
Name | Type | Description |
---|---|---|
fundingPayment | FPSigned | Funding payment owed by this position |
position | struct IDomFiPerp.Position | Position to be withdrawn from |
maxLeverage | FPUnsigned | Max leverage of this position's product |
liquidationThreshold | FPUnsigned | Liquidation threshold for this product, e.g. 0.7 |
Return Values
Name | Type | Description |
---|---|---|
[0] | int256 | int256 Removable margin (+) or required margin add (-) |
addProduct
Add a new product
function addProduct(struct IDomFiPerp.ProductParams _product) external
Parameters
Name | Type | Description |
---|---|---|
_product | struct IDomFiPerp.ProductParams | See IDomFiPerp.ProductParams |
updateProductMaxLeverage
Update the max leverage of a product
function updateProductMaxLeverage(bytes32 _productId, FPUnsigned _maxLeverage) external
Parameters
Name | Type | Description |
---|---|---|
_productId | bytes32 | Product to change |
_maxLeverage | FPUnsigned | See IDomFiPerp.Product.maxLeverage |
updateProductFee
Update the base trade fee for a product
function updateProductFee(bytes32 _productId, FPUnsigned _fee) external
Parameters
Name | Type | Description |
---|---|---|
_productId | bytes32 | Product to change |
_fee | FPUnsigned | See IDomFiPerp.Product.fee |
updateProductActive
Enable or disable a product
function updateProductActive(bytes32 _productId, bool _isActive) external
Parameters
Name | Type | Description |
---|---|---|
_productId | bytes32 | Product to (de)activate |
_isActive | bool | IDomFiPerp.Product.isActive |
updateProductMinPriceChange
Update the minimum price change for positions on a product.
function updateProductMinPriceChange(bytes32 _productId, FPUnsigned _minPriceChange) external
Parameters
Name | Type | Description |
---|---|---|
_productId | bytes32 | Product to change |
_minPriceChange | FPUnsigned | See IDomFiPerp.Product.minPriceChange |
updateProductLiquidationBounty
Update the liquidation bounty for positions on a product
function updateProductLiquidationBounty(bytes32 _productId, FPUnsigned _liquidationBounty) external
Parameters
Name | Type | Description |
---|---|---|
_productId | bytes32 | Product to change |
_liquidationBounty | FPUnsigned | See IDomFiPerp.Product.liquidationBounty |
updateProductExposureMultiplier
Update a product's exposure multiplier
function updateProductExposureMultiplier(bytes32 _productId, FPUnsigned _exposureMultiplier) external
Parameters
Name | Type | Description |
---|---|---|
_productId | bytes32 | Product to change |
_exposureMultiplier | FPUnsigned | See IDomFiPerp.Product.exposureMultiplier |
updateProductReserveMultiplier
Update a product's reserve multiplier
function updateProductReserveMultiplier(bytes32 _productId, FPUnsigned _reserveMultiplier) external
Parameters
Name | Type | Description |
---|---|---|
_productId | bytes32 | Product to change |
_reserveMultiplier | FPUnsigned | See IDomFiPerp.Product.reserveMultiplier |
updateProductWeight
Update a product's weight for exposure calculations
function updateProductWeight(bytes32 _productId, FPUnsigned _weight) external
Parameters
Name | Type | Description |
---|---|---|
_productId | bytes32 | Product to change |
_weight | FPUnsigned | See IDomFiPerp.Product.weight |
updateProductLiquidationThreshold
Update the liquidation threshold for positions on a product
function updateProductLiquidationThreshold(bytes32 _productId, FPUnsigned _liquidationThreshold) external
Parameters
Name | Type | Description |
---|---|---|
_productId | bytes32 | Product to change |
_liquidationThreshold | FPUnsigned | See IDomFiPerp.Product.liquidationThreshold |
updateProductFundingExponent
Set product funding exponent. Funding rate is (productExposure / maxExposure) ^ fundingExponent * fundingMultiplier
function updateProductFundingExponent(bytes32 _productId, FPUnsigned _fundingExponent) external
Set to 1 to "disable".
Parameters
Name | Type | Description |
---|---|---|
_productId | bytes32 | ID of product to change funding exponent |
_fundingExponent | FPUnsigned | New 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
This allows order bots to get price events without tracking oracle changes.
Parameters
Name | Type | Description |
---|---|---|
productId | bytes32 | ID of product with price update |
value | FPUnsigned | New price |
timestamp | uint64 | Timestamp at which price was generated |
oracle | address | Source 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
Name | Type | Description |
---|---|---|
_manager | address | Address to affect |
_isActive | bool | Whether 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
Name | Type | Description |
---|---|---|
_manager | address | Address to approve or remove, e.g. OrderBook |
_isActive | bool | Whether this address may change the sender's positions. |
setMinMargin
Set the minimum margin increment for all positions
function setMinMargin(uint256 _minMargin) external
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
Name | Type | Description |
---|---|---|
_minMargin | uint256 | Prevent actions that would create a position with less than this much collateral |
setTradeEnabled
Enable or disable trading
function setTradeEnabled(bool _isTradeEnabled) external
Parameters
Name | Type | Description |
---|---|---|
_isTradeEnabled | bool | Whether positions can be created/increased or not |
setMaxShift
Set max exposure-balancing slippage. See maxShift
function setMaxShift(FPUnsigned _maxShift) external
Parameters
Name | Type | Description |
---|---|---|
_maxShift | FPUnsigned | New value for maxShift. 0-1% |
setMinProfitTime
Set delay before positions with <minProfit can be cashed out
function setMinProfitTime(uint256 _minProfitTime) external
Parameters
Name | Type | Description |
---|---|---|
_minProfitTime | uint256 | New value for minProfitTime |
setAllowPublicLiquidator
Allow anybody to liquidate positions, or restrict it to approved addresses only
function setAllowPublicLiquidator(bool _allowPublicLiquidator) external
Parameters
Name | Type | Description |
---|---|---|
_allowPublicLiquidator | bool | New value for allowPublicLiquidator |
setIsManagerOnlyForOpen
Restrict position increases to approved addresses, or open to all
function setIsManagerOnlyForOpen(bool _isManagerOnlyForOpen) external
Parameters
Name | Type | Description |
---|---|---|
_isManagerOnlyForOpen | bool | New value for isManagerOnlyForOpen |
setIsManagerOnlyForClose
Restrict position decreases to approved addresses, or open to all
function setIsManagerOnlyForClose(bool _isManagerOnlyForClose) external
Parameters
Name | Type | Description |
---|---|---|
_isManagerOnlyForClose | bool | New value for isManagerOnlyForClose |
setUtilizationMultiplier
Set the utilization multiplier. Open interest is restricted to utilizationMultiplier times the vault balance
function setUtilizationMultiplier(FPUnsigned _utilizationMultiplier) external
Parameters
Name | Type | Description |
---|---|---|
_utilizationMultiplier | FPUnsigned | New 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
Name | Type | Description |
---|---|---|
_maxExposureMultiplier | FPUnsigned | New 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
This should be <1. Set to 1 to disable.
Parameters
Name | Type | Description |
---|---|---|
_helpfulShiftScaler | FPUnsigned | New 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
Name | Type | Description |
---|---|---|
_priceFeed | contract IPriceFeed | New price feed contract |
_feeCalculator | contract IFeeCalculator | New fee calculator |
_fundingManager | contract IFundingManager | New funding manager |
_feeDistributor | contract IFeeDistributor | New 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
Name | Type | Description |
---|---|---|
_liquidator | address | Address to (de)activate as a liquidator |
_isActive | bool | Whether it can liquidate when !allowPublicLiquidators |
setliquidationRegistry
Set an ILiquidationRegistry to be notified whenever a position is created.
function setliquidationRegistry(contract ILiquidationRegistry _liquidationRegistry) external
Parameters
Name | Type | Description |
---|---|---|
_liquidationRegistry | contract ILiquidationRegistry | New ILiquidationRegistry. 0x00 to disable. |
setOwner
Set the owner, able to do anything but set other roles
function setOwner(address _owner) external
Parameters
Name | Type | Description |
---|---|---|
_owner | address | New owner address |
setGuardian
Set the guardian, address able to pause (but not resume) trading
function setGuardian(address _guardian) external
Parameters
Name | Type | Description |
---|---|---|
_guardian | address | New guardian address |
transferGov
Transfer governance permissions to another address. Recipient must call acceptGov.
function transferGov(address newGov) external
Must be called by existing governance address
Parameters
Name | Type | Description |
---|---|---|
newGov | address | New 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.
Prevents the creation of very small positions, which would be unprofitable to liquidate after gas fees.
maxShift
scaling factor for price shift that balances long and short exposure
helpfulShiftScaler
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().