Market Module

The Market module allows you to create, manage, and interact with market items.

Types

export type CreateOrderInput = {
  startAmount: BigInt
  endAmount: BigInt
  startTime: number
  endTime: number
  debtToSell: BigInt
}
export enum OrderTypes {
  ASC = 'ASC',
  DESC = 'DESC',
  NONE = 'none'
}

Signature

export type Signature = {
  data: object
  signature: { v: number; r: string; s: string; deadline: number }
}

/* data object
interface SignMarket {
  loan: SignLoanConfig;
  assetId: string;
  collection: string;
  tokenId: BigInt;
  assetPrice: BigInt;
  assetLtv: BigInt;
  nonce: BigInt;
  deadline: BigInt;
}

interface SignLoanConfig {
  loanId: string;
  aggLoanPrice: BigInt;
  aggLtv: BigInt;
  aggLiquidationThreshold: BigInt;
  totalAssets: BigInt;
  nonce: BigInt;
  deadline: BigInt;
}
*/

ClientOptions

export type ClientOptions = {
  network?: Chain
}

export type Chain = 'mainnet' | 'sepolia' | 'localhost'

Functions

Creating a Market Item

To create a market item, use the create function from the market module:

export const create = async (
        underlyingAsset: Address,
        orderType: OrderType,
        config: CreateOrderInput,
        signature: Signature,
        options?: ClientOptions
    )
const result = await create(underlyingAsset, orderType, config, signature, options?);

Canceling a Market Item

To cancel a market item, use the cancel function from the market module:

export const cancel = async (
        orderId: string, 
        options?: ClientOptions
    )
const result = await cancel(orderId, options?);

Refer to the Market Module documentation for more details on the cancel function.

Bidding a Market Item

To bid on a market item, use the marketBid function from the market module:

export const marketBid = async (
        orderId: string,
        amountToPay: BigInt,
        amountOfDebt: BigInt,
        signature: Signature,
        options?: ClientOptions
    )
const result = await marketBid(orderId, amountToPay, amountOfDebt, signature, options?);

Claiming a Market Item

To claim a market item, use the claim function from the market module:

export const claim = async (
        claimOnUWallet: boolean,
        orderId: string,
        signature: Signature,
        options?: ClientOptions
    )
const result = await claim(claimOnUWallet, orderId, signature, options?);

Refer to the Market Module documentation for more details on the claim function.

Cancel Claiming a Market Item

To cancel a claim on a market item, use the cancelClaim function from the market module:

export const cancelClaim = async (
        orderId: string, 
        signature: Signature, 
        options?: ClientOptions
    )
const result = await cancelClaim(orderId, signature, options?);

Refer to the Market Module documentation for more details on the cancelClaim function.

Buy Now Market Item

To do a buy now on a market item, use the buyNow function from the market module:

export const buyNow = async (
        claimOnUWallet: boolean,
        orderId: string,
        amountToPay: BigInt,
        amountOfDebt: BigInt,
        signature: Signature,
        options?: ClientOptions
    )
const result = await buyNow(claimOnUWallet, orderId, amountToPay, amountOfDebt, signature, options?);

Refer to the Market Module documentation for more details on the buyNow function.

Last updated