User actions
Description of all user-facing and internal auxiliary functions available inside the Marginly protocol
Function | Parameter | Description |
---|---|---|
deposit base | account_id qty longQty | deposit ETH:
|
deposit quote | account_id qty shortQty | deposit USDC:
|
withdraw base | account_id qty | withdraw ETH:
|
withdraw quote | account_id qty | withdraw USDC:
|
Long | account_id qty (L) | This is an atomic sequence of actions: if one of the steps fails, all of the transaction is reverted:
|
Short | account_id qty (L) | This is an atomic sequence of actions: if one of the steps fails, all of the transaction is reverted:
|
close position | account_id | This is an atomic sequence of actions: if one of the steps fails, all of the transaction is reverted:
|
reinit |
| Accrue interest rates, syncs balances and liquidate riskiest position if needed: Marginly tracks leverages of user long and short positions sorted from highest to lowest (using heaps), each time interest rates are accrued, system checks if the leverage of the most risky position (heap root) is above max leverage it gets liquidated automatically. All of the collateral is sold and the liquidated user effectively pays a penalty of <=5%. All the penalty is distributed to liquidity providers This function is free for any user to call as it's in the best interest of the pool participants to call it to collect liquidation fees. This function is called automatically inside any user facing function. |
Receive position | account_id | Provide liquidity and absorb liquidated position, effectively realising its net position value. This function is useful when there is no collateral to sell in the system, but liquidations still need to happen. |
Emergency withdraw |
| Available when the system parameter mode is EmergencyShort or EmergencyLong. Theses scenarios are only possible in the system when there is not enough ETH collateral to cover USDC debt and vice versa: not enough USDC collateral to cover ETH debt. Emergency Short mode: There is no liquidity in the system and the insurance pool to liquidate bad short positions. In that mode all positions of type Lend and Long could withdraw their collateral minus amounts needed to reduce short positions debts. Emergency Long mode: There is no liquidity in the system and the insurance pool to liquidate bad long positions. In that mode all positions of type Lend and Short could withdraw their collateral minus amounts needed to reduce short positions debts. |
Last updated