Contract Relationships
Read Functions
collateralBalance
imLockedTotal
imLockedByPosition
globalImLocked
availableBalance
collateralBalance - imLockedTotal. This is the maximum amount the trader can withdraw or allocate to new positions.
equity
collateralToken
collateralDecimals
Write Functions
deposit
| Name | Type | Description |
|---|---|---|
amount | uint256 | USDC amount to deposit (6 decimals) |
withdraw
| Name | Type | Description |
|---|---|---|
amount | uint256 | USDC amount to withdraw (6 decimals) |
| # | Check | Revert Error |
|---|---|---|
| 1 | amount > 0 | ZeroAmount |
| 2 | amount <= availableBalance | WithdrawalExceedsAvailable |
Protocol Functions
These functions are called by PositionManager and SettlementEngine — not directly by traders.lockMargin
settlePosition
marginToRelease is proportional to the reduction.
transferOut
addMarginToPosition
removeMarginFromPosition
collectFee
collectFeeFromCollateral
Events
| Event | When Emitted |
|---|---|
CollateralDeposited | USDC deposited into margin account |
CollateralWithdrawn | USDC withdrawn from margin account |
MarginLocked | Initial margin locked for a new position |
MarginUnlocked | Margin released on position close |
PnlSettled | PnL applied to account after settlement |
BadDebt | Trader loss exceeds locked margin (pool absorbs shortfall) |
MarginAddedToPosition | Additional margin locked for existing position |
MarginRemovedFromPosition | Margin removed from existing position |
FeeCollected | Fee deducted from account collateral |
Related Pages
Margin Model
IM/MM factors and liquidation thresholds.
Position Manager
Opening positions and margin adjustments.
Settlement Engine
Settlement, liquidation, and PnL flows.