Skip to Content
Stacks Market

Market Trait

Purpose: Interface definition for market contracts. Defines core lending protocol operations.

market-trait

Interface implemented by market.clar for core lending operations.

Trait Definition

market-trait

Interface implemented by market.clar for core lending operations.

Functions:

collateral-add

Add collateral to position.

Parameters:

  • ft: Asset token
  • amount: Amount to add
  • price-feeds: Optional Pyth feed updates (up to 3)

Returns:

  • Updated collateral amount

collateral-remove

Remove collateral from position.

Parameters:

  • ft: Asset token
  • amount: Amount to remove
  • receiver: Optional recipient (defaults to caller)
  • price-feeds: Optional Pyth feed updates

Returns:

  • Remaining collateral amount

borrow

Borrow assets against collateral.

Parameters:

  • ft: Asset to borrow
  • amount: Amount to borrow
  • receiver: Optional recipient (defaults to caller)
  • price-feeds: Optional Pyth feed updates

Returns:

  • Success or error (boolean and code)

repay

Repay borrowed debt.

Parameters:

  • ft: Asset to repay
  • amount: Amount to repay
  • on-behalf-of: Optional account to repay for (defaults to caller)

Returns:

  • Actual amount repaid

liquidate

Liquidate unhealthy position.

Parameters:

  • borrower: Position to liquidate
  • collateral-ft: Collateral to seize
  • debt-ft: Debt to repay
  • debt-amount: Amount of debt to repay
  • min-collateral-expected: Minimum collateral (slippage protection)
  • receiver: Optional recipient
  • price-feeds: Optional Pyth feed updates

Returns:

  • Debt repaid and collateral received

liquidate-multi

Batch liquidate multiple positions.

Parameters:

  • positions: List of liquidation specs

Returns:

  • List of results per position

Note: Price feeds are not supported in batch mode (liquidate-multi).

Last updated on