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:
Name Type Description marketAddress address The address of the market. trader address The owner of The account account address The account The address of the account opening the position. tradingFee uint256 The trading fee associated with the position. tradingFeeUSD uint256 The trading fee in USD
AccountCreated
event AccountCreated(address account, address owner)
Emitted when a new account is created.
Parameters:
Name Type Description account address The address of the created account. owner address The 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:
Name Type Description market address The address of the ChromaticMarket contract. qty int256 The quantity of the position. takerMargin uint256 The margin amount for the taker. makerMargin uint256 The margin amount for the maker. maxAllowableTradingFee uint256 The maximum allowable trading fee. Return Values:
Name Type Description [0] struct OpenPositionInfo position The new position.
closePosition
function closePosition(address market, uint256 positionId) external
Closes a position in a ChromaticMarket contract.
Parameters:
Name Type Description market address The address of the ChromaticMarket contract. positionId uint256 The ID of the position to close.
claimPosition
function claimPosition(address market, uint256 positionId) external
Claims a position from a ChromaticMarket contract.
Parameters:
Name Type Description market address The address of the ChromaticMarket contract. positionId uint256 The 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:
Name Type Description market address The address of the ChromaticMarket contract. feeRate int16 The fee rate of the liquidity bin. amount uint256 The amount to add as liquidity. recipient address The recipient address. Return Values:
Name Type Description [0] struct LpReceipt receipt The LP receipt.
claimLiquidity
function claimLiquidity(address market, uint256 receiptId) external
Claims liquidity from a ChromaticMarket contract.
Parameters:
Name Type Description market address The address of the ChromaticMarket contract. receiptId uint256 The 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:
Name Type Description market address The address of the ChromaticMarket contract. feeRate int16 The fee rate of the liquidity bin. clbTokenAmount uint256 The amount of CLB tokens to remove as liquidity. recipient address The recipient address. Return Values:
Name Type Description [0] struct LpReceipt receipt The LP receipt.
withdrawLiquidity
function withdrawLiquidity(address market, uint256 receiptId) external
Withdraws liquidity from a ChromaticMarket contract.
Parameters:
Name Type Description market address The address of the ChromaticMarket contract. receiptId uint256 The 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:
Name Type Description [0] address The account address.
getLpReceiptIds
function getLpReceiptIds(address market) external view returns (uint256[])
Retrieves the LP receipt IDs of the caller for the specified market.
Parameters:
Name Type Description market address The address of the ChromaticMarket contract. Return Values:
Name Type Description [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:
Name Type Description market address The address of the ChromaticMarket contract. owner address The address of the owner. Return Values:
Name Type Description [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:
Name Type Description market address The address of the ChromaticMarket contract. recipient address The address of the recipient for each liquidity bin. feeRates int16[] An array of fee rates for each liquidity bin. amounts uint256[] An array of amounts to add as liquidity for each bin. Return Values:
Name Type Description lpReceipts struct LpReceipt[] An array of LP receipts.
claimLiquidityBatch
function claimLiquidityBatch(address market, uint256[] receiptIds) external
Claims liquidity from multiple ChromaticMarket contracts in a batch.
Parameters:
Name Type Description market address The address of the ChromaticMarket contract. receiptIds uint256[] 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:
Name Type Description market address The address of the ChromaticMarket contract. recipient address The address of the recipient for each liquidity bin. feeRates int16[] An array of fee rates for each liquidity bin. clbTokenAmounts uint256[] An array of CLB token amounts to remove as liquidity for each bin. Return Values:
Name Type Description lpReceipts struct LpReceipt[] An array of LP receipts.
withdrawLiquidityBatch
function withdrawLiquidityBatch(address market, uint256[] receiptIds) external
Withdraws liquidity from multiple ChromaticMarket contracts in a batch.
Parameters:
Name Type Description market address The address of the ChromaticMarket contract. receiptIds uint256[] An array of LP receipt IDs to withdraw liquidity from.