Positions
Traders open long or short positions that track the value of a dominance metric. In a long position, traders profit if the price increases. In a short position, they profit if the price decreases.
Traders can open positions larger than the amount of margin (collateral) they supply. A position's size divided by its trader-supplied margin is its leverage. Trade fees and funding rates are proportional to a position's size, not its margin. So for a given amount of collateral, leveraged positions are more expensive to open and maintain.
For example, you can use 100 USDC of margin to open a long BTCDOM position to track the Bitcoin dominance metric with 5.0x leverage. This will create a long position with 500 USDC worth of long exposure to BTCDOM.
Counterparty
Unlike order-matching exchanges where a buyer and seller are trading assets, the liquidity vault is the counterparty to all long and short positions opened.
Liquidity providers deposit into DomFiVault, an ERC4626-compliant yield-bearing vault where depositors can pool collateral to share the platform's risks and rewards
Liquidation
Domination Finance is a margin exchange. When trading on margin in traditional finance, traders borrow money in order to make big trades. The loan is collateralized by the trader's portfolio. If a margin trader loses enough money, they might not be able to pay back the loan. So before the trader would be underwater, the broker makes a "margin call" for more collateral. If the trader cannot pay, the broker seizes and sells their securities to make sure they get paid back. For more information, read about margin in traditional finance.
Liquidations on Domination Finance are similar. If PnL of a position drops below the liquidation threshold, it will be forcibly closed. Half of any remaining margin is sent to the liquidator bot, and the other half is distributed to the usual fee recipients through FeeDistributor. Liquidation threshold is currently -80% of position margin for all products. It must be higher than -100% because liquidators need some incentive to liquidate positions quickly, and the turbulent market conditions that lead to liquidations often result in increased gas prices.
Position management
Adding margin to avoid liquidation
When a position approaches 80% loss, traders can avoid losing the final 20% to liquidation by closing the position.
To avoid liquidation while keeping the position open, they can add a certain amount of collateral by placing an ADD_MARGIN
order. There is no trade fee for this action, which keeps position size () the same by decreasing leverage. Note that Domination Finance does not allow positions below 1x leverage.
Removing margin to increase leverage
To trade more aggressively, users can remove margin from a position with a REMOVE_MARGIN
order. This effectively increases the leverage on the position.
Because PnL changes over time, it can be difficult to predict how much margin can be safely removed from a position without triggering liquidation. To prevent this, REMOVE_MARGIN
orders will calculate within the OrderBook the maximum "safe" removal amount at execution time and remove no more than that amount.
There is no trade fee for this action. After removing margin, the position size () will remain the same.
On-chain
A position is described by its
- product (e.g. BTCDOM) and direction (e.g. short)
- entry point: price, funding, and timestamp. A position's profit or loss is proportional to the change in price between creation and the current time.
- margin: the amount of collateral that has been submitted to create the position
- leverage: allows traders to trade as if they had more collateral at stake than the margin they submitted
- size: a useful quantity defined as
Solidity
Each position is identified by a globally unique bytes32 positionId
based on its owner
and a bytes16 ownerPositionId
chosen by the owner.
A position's financial value is encoded by productId
, isLong
, price
, margin
, leverage
, and funding
, set when the position is first created. When increasing a position's size, price
and funding
are set to the mean of the previous value and the current value, weighted by previous position size and increase size.
Positions are represented on-chain as follows:
mapping(bytes32 => Position) private positions;
struct Position {
address owner;
bytes32 productId;
uint256 margin; // collateral provided for this position
FPUnsigned leverage;
FPUnsigned price; // price when position was increased. weighted average by size
FPUnsigned oraclePrice;
FPSigned funding; // funding + interest when position was last increased
bytes16 ownerPositionId;
uint64 timestamp; // last position increase
bool isLong;
bool isNextPrice;
}
Global Position ID
Each position has a unique position ID. This is computed by ABI encoding the following fields and then hashing them:
- the network's chain ID (e.g. 421613 for Arbitrum Goerli)
- the address of
DomFiPerp
- the address of the position's owner
- a position ID chosen by the position's owner (e.g. "5")
See getPositionId
.