LogoLogo
  • About
    • Introduction
    • Unlockd SDK
    • Partners & Revenue Sharing
  • Getting Started
    • Installation
    • SDK Modules
      • Action Module
      • Auction Module
      • Market Module
      • Buy Now Module
      • Sell Now Module
      • Wallet Module
      • NFT Batch Transfer Module
    • Code Examples
      • Borrowing Assets
      • Fetch prices
      • Login
      • Borrow Signature
      • Minimum Repay
      • Liquidation Price
      • Health Factor
      • Available to borrow
    • UI Snippets
    • Reservoir Integration
  • USE CASES (code examples)
    • Borrow against RWAs
    • 'Buy Now, Pay Later' financing
  • Resources
    • npmJS Package
    • Best Practices
    • Changelog
    • Support & Contact
    • Unlockd V2
    • Product Documentation
    • Protocol Documentation
    • Risk Documentation
    • External Audits
    • Website
    • X (Twitter)
    • Discord
    • Other links
Powered by GitBook
On this page
  • Types
  • Signature
  • ClientOptions
  • Functions
  • Creating a Market Item
  • Canceling a Market Item
  • Bidding a Market Item
  • Claiming a Market Item
  • Cancel Claiming a Market Item
  • Buy Now Market Item
Export as PDF
  1. Getting Started
  2. SDK Modules

Market Module

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

PreviousAuction ModuleNextBuy Now Module

Last updated 12 months ago

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.

Refer to the documentation for more details on the create function.

Refer to the documentation for more details on the marketBid function.

Market flow
Market Module
Market Module