Skip to main content

IChromaticAccount.sol

IChromaticAccount

Interface for the ChromaticAccount contract, which manages user accounts and positions.

OpenPosition

event OpenPosition(address marketAddress, uint256 positionId, uint256 openVersion, int256 qty, uint256 openTimestamp, uint256 takerMargin, uint256 makerMargin, uint256 tradingFee)

Emitted when a position is opened.

  • Parameters:

    NameTypeDescription
    marketAddressaddressThe address of the market.
    positionIduint256The position identifier
    openVersionuint256The version of the oracle when the position was opened
    qtyint256The quantity of the position
    openTimestampuint256The timestamp when the position was opened
    takerMarginuint256The amount of collateral that a trader must provide
    makerMarginuint256The margin amount provided by the maker.
    tradingFeeuint256The trading fee associated with the position.

ClosePosition

event ClosePosition(address marketAddress, uint256 positionId, uint256 closeVersion, uint256 closeTimestamp)

Emitted when a position is closed.

  • Parameters:

    NameTypeDescription
    marketAddressaddressThe address of the market.
    positionIduint256The position identifier
    closeVersionuint256The version of the oracle when the position was closed
    closeTimestampuint256The timestamp when the position was closed

ClaimPosition

event ClaimPosition(address marketAddress, uint256 positionId, uint256 entryPrice, uint256 exitPrice, int256 realizedPnl, uint256 interest, bytes4 cause)

Emitted when a position is claimed.

  • Parameters:

    NameTypeDescription
    marketAddressaddressThe address of the market.
    positionIduint256The position identifier
    entryPriceuint256The entry price of the position
    exitPriceuint256The exit price of the position
    realizedPnlint256The profit or loss of the claimed position.
    interestuint256The interest paid for the claimed position.
    causebytes4The description of being claimed.

balance

function balance(address token) external view returns (uint256)

Returns the balance of the specified token for the account.

  • Parameters:

    NameTypeDescription
    tokenaddressThe address of the token.
  • Return Values:

    NameTypeDescription
    [0]uint256The balance of the token.

withdraw

function withdraw(address token, uint256 amount) external

Withdraws the specified amount of tokens from the account.

  • Parameters:

    NameTypeDescription
    tokenaddressThe address of the token to withdraw.
    amountuint256The amount of tokens to withdraw.

hasPositionId

function hasPositionId(address marketAddress, uint256 positionId) external view returns (bool)

Checks if the specified market has the specified position ID.

  • Parameters:

    NameTypeDescription
    marketAddressaddressThe address of the market.
    positionIduint256The ID of the position.
  • Return Values:

    NameTypeDescription
    [0]boolA boolean indicating whether the market has the position ID.

getPositionIds

function getPositionIds(address marketAddress) external view returns (uint256[])

Retrieves an array of position IDs owned by this account for the specified market.

  • Parameters:

    NameTypeDescription
    marketAddressaddressThe address of the market.
  • Return Values:

    NameTypeDescription
    [0]uint256[]An array of position IDs.

openPosition

function openPosition(address marketAddress, int256 qty, uint256 takerMargin, uint256 makerMargin, uint256 maxAllowableTradingFee) external returns (struct OpenPositionInfo)

Opens a new position in the specified market.

  • Parameters:

    NameTypeDescription
    marketAddressaddressThe address of the market.
    qtyint256The quantity of the position.
    takerMarginuint256The margin required for the taker.
    makerMarginuint256The margin required for the maker.
    maxAllowableTradingFeeuint256The maximum allowable trading fee.
  • Return Values:

    NameTypeDescription
    [0]struct OpenPositionInfoopenPositionInfo The opened position information.

closePosition

function closePosition(address marketAddress, uint256 positionId) external

Closes the specified position in the specified market.

  • Parameters:

    NameTypeDescription
    marketAddressaddressThe address of the market.
    positionIduint256The ID of the position to close.

claimPosition

function claimPosition(address marketAddress, uint256 positionId) external

Claims the specified position in the specified market.

  • Parameters:

    NameTypeDescription
    marketAddressaddressThe address of the market.
    positionIduint256The ID of the position to claim.