MarginAccount
Last updated
Was this helpful?
Last updated
Was this helpful?
Inherits:
Implements a margin account, allowing users to borrow against collateral to take leveraged positions.
Opens a new margin account by depositing initial collateral.
Parameters
initialCollateral
uint256
The amount of collateral to deposit initially.
Closes the margin account, ensuring all borrowed funds are repaid.
Adds additional collateral to the margin account.
Parameters
amount
uint256
The amount of collateral to add.
Removes collateral from the margin account, ensuring it doesn’t violate the collateral factor.
Parameters
amount
uint256
The amount of collateral to remove.
Opens a leveraged position by borrowing against collateral.
Parameters
size
uint256
The size of the position to open.
Closes a leveraged position by repaying borrowed funds.
Parameters
size
uint256
The size of the position to close.
Retrieves the current collateral balance.
Returns
<none>
uint256
The collateral balance.