Skip to main content

IChromaticRouter.sol

IChromaticRouter

Interface for the ChromaticRouter contract.

OpenPosition

event OpenPosition(address marketAddress, address trader, address account, uint256 tradingFee, uint256 tradingFeeUSD)

Emitted when a position is opened.

  • Parameters:

    NameTypeDescription
    marketAddressaddressThe address of the market.
    traderaddressThe owner of The account
    accountaddressThe account The address of the account opening the position.
    tradingFeeuint256The trading fee associated with the position.
    tradingFeeUSDuint256The trading fee in USD

AccountCreated

event AccountCreated(address account, address owner)

Emitted when a new account is created.

  • Parameters:

    NameTypeDescription
    accountaddressThe address of the created account.
    owneraddressThe address of the owner of the created account.

openPosition

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

Opens a new position in a ChromaticMarket contract.

  • Parameters:

    NameTypeDescription
    marketaddressThe address of the ChromaticMarket contract.
    qtyint256The quantity of the position.
    takerMarginuint256The margin amount for the taker.
    makerMarginuint256The margin amount for the maker.
    maxAllowableTradingFeeuint256The maximum allowable trading fee.
  • Return Values:

    NameTypeDescription
    [0]struct OpenPositionInfoposition The new position.

closePosition

function closePosition(address market, uint256 positionId) external

Closes a position in a ChromaticMarket contract.

  • Parameters:

    NameTypeDescription
    marketaddressThe address of the ChromaticMarket contract.
    positionIduint256The ID of the position to close.

claimPosition

function claimPosition(address market, uint256 positionId) external

Claims a position from a ChromaticMarket contract.

  • Parameters:

    NameTypeDescription
    marketaddressThe address of the ChromaticMarket contract.
    positionIduint256The ID of the position to claim.

addLiquidity

function addLiquidity(address market, int16 feeRate, uint256 amount, address recipient) external returns (struct LpReceipt)

Adds liquidity to a ChromaticMarket contract.

  • Parameters:

    NameTypeDescription
    marketaddressThe address of the ChromaticMarket contract.
    feeRateint16The fee rate of the liquidity bin.
    amountuint256The amount to add as liquidity.
    recipientaddressThe recipient address.
  • Return Values:

    NameTypeDescription
    [0]struct LpReceiptreceipt The LP receipt.

claimLiquidity

function claimLiquidity(address market, uint256 receiptId) external

Claims liquidity from a ChromaticMarket contract.

  • Parameters:

    NameTypeDescription
    marketaddressThe address of the ChromaticMarket contract.
    receiptIduint256The ID of the LP receipt.

removeLiquidity

function removeLiquidity(address market, int16 feeRate, uint256 clbTokenAmount, address recipient) external returns (struct LpReceipt)

Removes liquidity from a ChromaticMarket contract.

  • Parameters:

    NameTypeDescription
    marketaddressThe address of the ChromaticMarket contract.
    feeRateint16The fee rate of the liquidity bin.
    clbTokenAmountuint256The amount of CLB tokens to remove as liquidity.
    recipientaddressThe recipient address.
  • Return Values:

    NameTypeDescription
    [0]struct LpReceiptreceipt The LP receipt.

withdrawLiquidity

function withdrawLiquidity(address market, uint256 receiptId) external

Withdraws liquidity from a ChromaticMarket contract.

  • Parameters:

    NameTypeDescription
    marketaddressThe address of the ChromaticMarket contract.
    receiptIduint256The ID of the LP receipt.

createAccount

function createAccount() external

Creates a new user account.

Only one account can be created per user. Emits an AccountCreated event upon successful creation.

getAccount

function getAccount() external view returns (address)

Retrieves the account of the caller.

  • Return Values:

    NameTypeDescription
    [0]addressThe account address.

getLpReceiptIds

function getLpReceiptIds(address market) external view returns (uint256[])

Retrieves the LP receipt IDs of the caller for the specified market.

  • Parameters:

    NameTypeDescription
    marketaddressThe address of the ChromaticMarket contract.
  • Return Values:

    NameTypeDescription
    [0]uint256[]An array of LP receipt IDs.

getLpReceiptIds

function getLpReceiptIds(address market, address owner) external view returns (uint256[])

Get the LP receipt IDs associated with a specific market and owner.

  • Parameters:

    NameTypeDescription
    marketaddressThe address of the ChromaticMarket contract.
    owneraddressThe address of the owner.
  • Return Values:

    NameTypeDescription
    [0]uint256[]An array of LP receipt IDs.

addLiquidityBatch

function addLiquidityBatch(address market, address recipient, int16[] feeRates, uint256[] amounts) external returns (struct LpReceipt[] lpReceipts)

Adds liquidity to multiple liquidity bins of ChromaticMarket contract in a batch.

  • Parameters:

    NameTypeDescription
    marketaddressThe address of the ChromaticMarket contract.
    recipientaddressThe address of the recipient for each liquidity bin.
    feeRatesint16[]An array of fee rates for each liquidity bin.
    amountsuint256[]An array of amounts to add as liquidity for each bin.
  • Return Values:

    NameTypeDescription
    lpReceiptsstruct LpReceipt[]An array of LP receipts.

claimLiquidityBatch

function claimLiquidityBatch(address market, uint256[] receiptIds) external

Claims liquidity from multiple ChromaticMarket contracts in a batch.

  • Parameters:

    NameTypeDescription
    marketaddressThe address of the ChromaticMarket contract.
    receiptIdsuint256[]An array of LP receipt IDs to claim liquidity from.

removeLiquidityBatch

function removeLiquidityBatch(address market, address recipient, int16[] feeRates, uint256[] clbTokenAmounts) external returns (struct LpReceipt[] lpReceipts)

Removes liquidity from multiple ChromaticMarket contracts in a batch.

  • Parameters:

    NameTypeDescription
    marketaddressThe address of the ChromaticMarket contract.
    recipientaddressThe address of the recipient for each liquidity bin.
    feeRatesint16[]An array of fee rates for each liquidity bin.
    clbTokenAmountsuint256[]An array of CLB token amounts to remove as liquidity for each bin.
  • Return Values:

    NameTypeDescription
    lpReceiptsstruct LpReceipt[]An array of LP receipts.

withdrawLiquidityBatch

function withdrawLiquidityBatch(address market, uint256[] receiptIds) external

Withdraws liquidity from multiple ChromaticMarket contracts in a batch.

  • Parameters:

    NameTypeDescription
    marketaddressThe address of the ChromaticMarket contract.
    receiptIdsuint256[]An array of LP receipt IDs to withdraw liquidity from.