Borrowing
How the protocol opens, services, repays, and closes a margin position.
Each supported denomination has a dedicated Liquidity Providers' Pool (LPP) instance that handles all borrow requests and repayments in that currency. The LPP calculates a fixed interest rate for each loan, tracks total principal and interest due, and maintains records of all active loans. An LPP operates exclusively in its native currency, called the Liquidity Pool's Native (LPN) denomination, and does not interact with other assets.
A factory contract creates all margin positions, with one factory deployed per integrated market. Each factory is connected to a single LPP - and by extension, to a single LPN. The LPN can be a stablecoin or a volatile token. For instance, if a user wants to borrow USDC to go long, they submit a request to the factory linked to the LPP whose LPN is USDC.
Factory configuration
The factory smart contract is configured with parameters that define the behavior and constraints of every position it creates.
| Parameter | Definition |
|---|---|
| Code ID | The identifier of the margin-position contract used to initialize new positions. |
| LPP Address | The LPP smart contract tied to this factory instance. |
| Protocol Interest Rate | The fixed interest portion collected by the protocol (e.g., 3%); 100% is used for buybacks. |
| Max Liability | Maximum allowed liability ratio. Crossing this triggers liquidation eligibility (e.g., 90%). |
| Healthy Liability | Target liability after a liquidation restores the position (e.g., 83%). |
| Initial Liability | Maximum LTV at position creation. Must be lower than the healthy liability (e.g., 60%). |
| Minimum Position Size | Minimum value, in LPN, that a position must maintain to stay alive (e.g., 15 USDC). |
| Minimum Transaction Amount | Smallest allowable amount for any transaction within the position (e.g., 0.01 USDC). |
| Interest Due Period | Window in which outstanding interest must be repaid. Past the deadline, owed interest is deducted via partial liquidation. |
| Liability Reevaluation Interval | How often (in seconds) the "liability covered" invariant is checked (e.g., every 2 seconds). |
| First / Second / Third Liquidation Warning Threshold | Three warning levels that signal escalating liquidation risk (e.g., 83.5% / 85% / 87.5%). Each must be strictly lower than the next, and all below the max liability. |
The "liability covered" invariant a position must satisfy at every check:
Current Liability < Max Liability × Position Value (in LPN)Worked example
- Borrowed amount (loan): 150 USDC
- Initial position value: 250 USDC
- Liability: 150 / 250 = 0.60
- Max allowed liability: 0.90
If the position value drops to 200 USDC, liability becomes 150 / 200 = 0.75 - still within the limit. If it drops further to 165 USDC, liability becomes 150 / 165 ≈ 0.91, exceeding the 0.90 cap and breaking the invariant. Once breached, the position is flagged for liquidation.
Walk through the flow
Opening a position
Collateral deposit, position creation, loan request, cross-chain setup, settlement states.
Querying a position
Observable states and the full set of returned fields.
Quoting a position
Preview what a position would look like under current LPP utilization.
Repaying and closing
Manual repayment, market close (full), and partial close flows.