BaseMargin

Git Source

Abstract contract defining the core interface for margin accounts.

State Variables

owner

address public owner;

Functions

constructor

constructor(address _owner);

openMargin

Opens a new margin account with initial collateral.

function openMargin(uint256 initialCollateral) external virtual;

Parameters

Name
Type
Description

initialCollateral

uint256

The amount of collateral to deposit initially.

closeMargin

Closes the margin account, withdrawing remaining collateral.

function closeMargin() external virtual;

addCollateral

Adds collateral to the margin account.

function addCollateral(uint256 amount) external virtual;

Parameters

Name
Type
Description

amount

uint256

The amount of collateral to add.

removeCollateral

Removes collateral from the margin account.

function removeCollateral(uint256 amount) external virtual;

Parameters

Name
Type
Description

amount

uint256

The amount of collateral to remove.

openPosition

Opens a leveraged position.

function openPosition(uint256 size) external virtual;

Parameters

Name
Type
Description

size

uint256

The size of the position to open.

closePosition

Closes a leveraged position.

function closePosition(uint256 size) external virtual;

Parameters

Name
Type
Description

size

uint256

The size of the position to close.

Events

MarginOpened

event MarginOpened(address indexed user, uint256 initialCollateral);

MarginClosed

event MarginClosed(address indexed user);

CollateralAdded

event CollateralAdded(address indexed user, uint256 amount);

CollateralRemoved

event CollateralRemoved(address indexed user, uint256 amount);

PositionOpened

event PositionOpened(address indexed user, uint256 size);

PositionClosed

event PositionClosed(address indexed user, uint256 size);

MarginCall

event MarginCall(address indexed user, uint256 requiredCollateral);

Last updated

Was this helpful?