CapSign
  • Home
  • Compliance Framework
  • Interactive Demos
    • Overview
  • Create an Account
  • Identity Verification
  • Investor Qualification
  • Guides for Individuals
    • Invest in an Offering
  • Guides for Corporations
    • Create a Share Class
    • Authorize Shares
    • Issue Shares
    • Upload a Document
    • Create a Document Template
    • Create an Offering
    • Manage Your Offering
    • Add a Trusted Attestor
    • Approve an Investment
  • API Reference
    • Overview
    • Compliance
      • Exemptions
        • FederalExemption.sol
          • FederalExemption
        • RegAExemption.sol
          • RegAExemption
        • RegCFExemption.sol
          • RegCFExemption
        • RegDExemption.sol
          • RegDExemption
        • Rule144Exemption.sol
          • Rule144Exemption
        • Rule701Exemption.sol
          • Rule701Exemption
      • IComplianceModule.sol
        • IComplianceModule
      • Vesting.sol
        • Vesting
    • Currencies
      • WETH.sol
        • WETH
      • CMX.sol
        • CMX
      • USD.sol
        • USD
    • Governance
      • BoardManagement.sol
        • BoardManagement
      • ProxyVoting.sol
        • ProxyVoting
    • Identity
      • AttestationRegistry.sol
        • AttestationRegistry
      • ERC20PaymentResolver.sol
        • ERC20PaymentResolver
      • Roles
        • BaseRoles.sol
          • BaseRoles
        • PrivateOfferingRoles.sol
          • PrivateOfferingRoles
        • PublicOfferingRoles.sol
          • PublicOfferingRoles
      • Whitelist.sol
        • Whitelist
    • Issuance
      • Compensation
        • CompensationFactory.sol
          • CompensationFactory
        • EmployeeStockOptionCompensation.sol
          • EmployeeStockOptionCompensation
        • RestrictedStockAwardCompensation.sol
          • RestrictedStockAwardCompensation
        • StockAppreciationRightsCompensation.sol
          • StockAppreciationRightCompensation
        • WarrantCompensation.sol
          • WarrantCompensation
      • Offering
        • ExemptOffering.sol
          • ExemptOffering
        • InitialPublicOffering.sol
          • InitialPublicOffering
        • Offering.sol
          • Offering
        • OfferingFactory.sol
          • OfferingFactory
        • Rule506bOffering.sol
          • Rule506bOffering
        • Rule506cOffering.sol
          • Rule506cOffering
        • TenderOffer.sol
          • TenderOffer
    • Investor Relations
      • DividendDistributor.sol
        • DividendDistributor
      • SubscriptionManager.sol
        • SubscriptionManager
        • IERC20
    • Ledgers
      • Ledger.sol
        • Ledger
      • LedgerManager.sol
        • LedgerManager
      • SettlementManager.sol
        • SettlementManager
    • Marketplace
      • AuctionMarket.sol
        • AuctionMarket
      • BaseMarket.sol
        • BaseMarket
      • BulletinBoardMarket.sol
        • BulletinBoardMarket
      • Contents
        • BaseCollateral.sol
          • BaseCollateral
        • ERC20Collateral.sol
          • ERC20Collateral
        • NativeCollateral.sol
          • NativeCollateral
      • LiquidityPoolMarket.sol
        • LiquidityPoolMarket
      • Contents
        • BaseMargin.sol
          • BaseMargin
        • MarginAccount.sol
          • MarginAccount
      • MarginOrderBookMarket.sol
        • MarginOrderBookMarket
      • OTCMarket.sol
        • OTCMarket
      • OrderBookMarket.sol
        • OrderBookMarket
      • Contents
        • BrokerNetSettlement.sol
          • BrokerNetSettlement
        • CustodyBridge.sol
          • CustodyBridge
        • DirectSettlement.sol
          • DirectSettlement
        • ListingRegistry.sol
          • ListingRegistry
    • Tokenization
      • Actions
        • CorporateActionManager.sol
          • CorporateActionManager
          • ICapitalAsset
        • ICorporateActionManager.sol
          • ICorporateActionManager
      • Assets
        • Asset.sol
          • Asset
          • Asset
        • ClosedEndFundClass.sol
          • ClosedEndFundClass
        • ClosedEndFundManager.sol
          • ClosedEndFundManager
        • EmployeeStockOption.sol
          • EmployeeStockOption
        • Contents
          • IAsset.sol
            • IAsset
          • IClosedEndFundClass.sol
            • IClosedEndFundClass
          • IIssuedAsset.sol
            • IIssuedAsset
          • IOpenEndFundClass.sol
            • IOpenEndFundClass
          • IShareClass.sol
            • IShareClass
        • IssuedAsset.sol
          • IssuedAsset
        • OpenEndFundClass.sol
          • OpenEndFundClass
        • OpenEndFundManager.sol
          • OpenEndFundManager
        • ShareClass.sol
          • ShareClass
        • StockAppreciationRight.sol
          • StockAppreciationRight
        • Warrant.sol
          • Warrant
      • TokenFactory.sol
        • TokenFactory
    • Utilities
      • PriceFeed.sol
        • SimplePriceFeed
        • IPriceFeed
    • Valuations
      • ValuationRegistry.sol
        • ValuationRegistry
    • Wallet
      • HookedSmartWallet.sol
        • HookedSmartWallet
      • Wallet.sol
        • Wallet
Powered by GitBook
On this page
  • State Variables
  • collateral
  • borrowedAmount
  • collateralFactor
  • Functions
  • constructor
  • openMargin
  • closeMargin
  • addCollateral
  • removeCollateral
  • openPosition
  • closePosition
  • getCollateralBalance

Was this helpful?

  1. API Reference
  2. Marketplace
  3. Contents
  4. MarginAccount.sol

MarginAccount

PreviousMarginAccount.solNextMarginOrderBookMarket.sol

Last updated 3 months ago

Was this helpful?

Inherits:

Implements a margin account, allowing users to borrow against collateral to take leveraged positions.

State Variables

collateral

BaseCollateral public collateral;

borrowedAmount

uint256 public borrowedAmount;

collateralFactor

uint256 public collateralFactor;

Functions

constructor

constructor(address _owner, address _collateral, uint256 _collateralFactor) BaseMargin(_owner);

openMargin

Opens a new margin account by depositing initial collateral.

function openMargin(uint256 initialCollateral) external override;

Parameters

Name
Type
Description

initialCollateral

uint256

The amount of collateral to deposit initially.

closeMargin

Closes the margin account, ensuring all borrowed funds are repaid.

function closeMargin() external override;

addCollateral

Adds additional collateral to the margin account.

function addCollateral(uint256 amount) external override;

Parameters

Name
Type
Description

amount

uint256

The amount of collateral to add.

removeCollateral

Removes collateral from the margin account, ensuring it doesn’t violate the collateral factor.

function removeCollateral(uint256 amount) external override;

Parameters

Name
Type
Description

amount

uint256

The amount of collateral to remove.

openPosition

Opens a leveraged position by borrowing against collateral.

function openPosition(uint256 size) external override;

Parameters

Name
Type
Description

size

uint256

The size of the position to open.

closePosition

Closes a leveraged position by repaying borrowed funds.

function closePosition(uint256 size) external override;

Parameters

Name
Type
Description

size

uint256

The size of the position to close.

getCollateralBalance

Retrieves the current collateral balance.

function getCollateralBalance() public pure returns (uint256);

Returns

Name
Type
Description

<none>

uint256

The collateral balance.

Git Source
BaseMargin