31Third.
  • 👋Introduction
    • About 31Third
    • Use cases
    • 0x Labs Collaboration
    • Architecture
    • Team
  • 🤝31Third API
    • Overview
    • Healthcheck
    • Assets
      • Wallet
      • Enzyme
    • Swap
      • Get started
      • price
      • quote
    • Basket Trade (m:n swap)
      • async
      • Wallet
      • Enzyme
      • SetProtocol
    • Refresh Quotes
    • RFQ
  • ⛓️Protocol
    • Overview
    • Contracts
      • BatchTrade
      • Owner Privilege
    • Prohibition
    • Audit
    • Statistics
      • Gas cost analysis
    • Fees
  • 📚Resources
    • FAQ
    • Start trading
    • Discord
    • Twitter
Powered by GitBook
On this page
  1. 31Third API

Basket Trade (m:n swap)

PreviousquoteNextasync

Last updated 26 days ago

Basket trades or m:n swaps allow you to rebalance a portfolio of assets in one go. This means you can specify a base allocation (m) consisting of one or many assets and a target allocation (n) with one or many assets. M and n can be the same assets in a different percentual allocation but also completely different assets.

For specific use-case specific descriptions see:

  • Wallet

  • Enzyme

  • SetProtocol

Usage example with ethers.js

The API returns a DTO containing the following properties:

export interface RebalancingResponseDto extends BaseEntityModel {
  ...
  txHandler: Address;    // address of deployed BatchTrade
  txData: string;        // calldata containing encoded Trades and BatchTradeConfig
  txValue: BigNumberDto; // value native currency sent for trading
  ...
}

which can be passed into as follows:

signer.sendTransaction({
  to: rebalancing.txHandler,
  data: rebalancing.txData,
  value: rebalancing.txValue,
});
🤝
ethers signer.sendTransaction