Position modes
- Separate — each open creates an independent position with its own collateral and health. A market limits how many separate position buckets one wallet can hold (between 1 and 5, set per market).
- Full — same-direction opens merge into a single long or short bucket for your wallet. A merge can change the bucket’s effective entry price and leverage, and it does not consume another position slot.
- CrossSeparate — like Separate, but the position is held by your margin account and shares collateral with your other cross positions.
- CrossFull — like Full, but inside your margin account: same-pool, same-direction opens merge into one cross position.
Margin accounts
A margin account (UserMarginAccount) is a user-owned contract that holds collateral and a set of cross-margined positions, so profit on one position can support another instead of each position being collateralized in isolation.
- You create one with
MarginAccountFactory.createAccount(collateral). The account address is deterministic and the call is idempotent — calling again returns your existing account. The collateral must be a configured, enabled token. - An account is bound to one owner and one collateral token. If you trade in more than one collateral, you get a separate account per collateral.
- An account can hold up to a configured number of positions (capped at 32).
claimSettlement step like there is for ordinary positions.
Free collateral, equity, and margin
- Free collateral is the account’s unallocated balance — collateral you have deposited that is not committed to a position. Deposit it with
deposit; tokens sent to the account by other means are not counted until you callsyncExcessCollateral. - Equity is your free collateral plus the current value of every active position:
equity = free collateral + Σ position adjusted value. A losing position’s value is floored at zero, so it can drag equity down but never below zero on its own. - Each position adds an initial and a maintenance requirement, scaled from its exposure. Your account must keep
equity ≥ initial requirementto open more or to withdraw, and it becomes liquidatable whenequity < maintenance requirement.
Account-level liquidation
Cross positions are not liquidated one-by-one through the pool. Instead the whole account is liquidated whenequity < maintenance requirement. Anyone can trigger it through one of three permissionless entry points:
liquidate— fully close positions (newest first) until the account is healthy again.liquidatePositions— fully close a specific set of the account’s positions.liquidateToTarget— partially close selected positions just until equity recovers to a target margin level.
Rescue collateral
If you deposit (or sync) collateral while the account is already liquidatable, that top-up is recorded as rescue collateral and excluded from the next liquidation’s incentive budget. This protects a last-second margin add from being handed straight to liquidators. The protection resets once the account is healthy again.Trading through an app
Most users interact with their account through an app that routes calls via TACO’s trusted router. Before that works, the account owner must approve the router on the account once (setRouterApproval, called directly by the owner). LP lots held by the account are tracked for management but do not count toward account equity or margin — their value only re-enters the account when you remove the liquidity back to free collateral.
