Skip to main content

MarketAddLiquidityFacet.sol

MarketAddLiquidityFacet

Contract for adding and claiming liquidity in a market.

addLiquidity

function addLiquidity(address recipient, int16 tradingFeeRate, bytes data) external returns (struct LpReceipt receipt)

Adds liquidity to the market.

  • Parameters:

    NameTypeDescription
    recipientaddressThe address to receive the liquidity tokens.
    tradingFeeRateint16The trading fee rate for the liquidity.
    databytesAdditional data for the liquidity callback.
  • Return Values:

    NameTypeDescription
    receiptstruct LpReceiptThe liquidity receipt.

addLiquidityBatch

function addLiquidityBatch(address recipient, int16[] tradingFeeRates, uint256[] amounts, bytes data) external returns (struct LpReceipt[] receipts)

Adds liquidity to multiple liquidity bins of the market in a batch.

Throws an InvalidTransferredTokenAmount error if the transferred amount does not match the sum of amounts param.

  • Parameters:

    NameTypeDescription
    recipientaddressThe address of the recipient for each liquidity bin.
    tradingFeeRatesint16[]An array of fee rates for each liquidity bin.
    amountsuint256[]An array of amounts to add as liquidity for each bin.
    databytesAdditional data for the liquidity callback.
  • Return Values:

    NameTypeDescription
    receiptsstruct LpReceipt[]An array of LP receipts.

claimLiquidity

function claimLiquidity(uint256 receiptId, bytes data) external

Throws a NotExistLpReceipt error if the liquidity receipt does not exist. Throws an InvalidLpReceiptAction error if the action of liquidity receipt is not ADD_LIQUIDITY. Throws a NotClaimableLpReceipt error if the liquidity receipt is not claimable in the current oracle version.

  • Parameters:

    NameTypeDescription
    receiptIduint256The ID of the liquidity receipt.
    databytesAdditional data for the liquidity callback.

claimLiquidityBatch

function claimLiquidityBatch(uint256[] receiptIds, bytes data) external

Throws a NotExistLpReceipt error if the liquidity receipt does not exist. Throws an InvalidLpReceiptAction error if the action of liquidity receipt is not ADD_LIQUIDITY. Throws a NotClaimableLpReceipt error if the liquidity receipt is not claimable in the current oracle version.

  • Parameters:

    NameTypeDescription
    receiptIdsuint256[]The array of the liquidity receipt IDs.
    databytesAdditional data for the liquidity callback.

distributeEarningToBins

function distributeEarningToBins(uint256 earning, uint256 marketBalance) external

Distributes earning to the liquidity bins.

  • Parameters:

    NameTypeDescription
    earninguint256The amount of earning to distribute.
    marketBalanceuint256The balance of the market.

_requireAddLiquidityEnabled

function _requireAddLiquidityEnabled(struct MarketStorage ms) internal view virtual

Throws if add liquidity is disabled.