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
  2. Basket Trade (m:n swap)

async

PreviousBasket Trade (m:n swap)NextWallet

Last updated 1 year ago

The calculation of rebalancings might take some seconds depending on how many assets are involved. Therefore all rebalancing endpoints have the option to calculate them async. If async is set to true you receive an id for your rebalancing and you can then periodically fetch the progress of the rebalancing. If its done, percent will have the value 100 and you will also receive the rebalancing.

/rebalancing/calculation-progress/{id}

Fetch the current progress or receive the final rebalancing if it's done.

/rebalancing/cancel/{id}

Cancel the calculation of a requested rebalancing.

🤝

Get calculation progress

get

Returns progress state of running rebalancing

Path parameters
idstringRequired
Header parameters
x-api-keystringOptional

31Third API key (Request via dev@31third.com)

chain-idstringOptional

Chain ID as hex string. (e.g.: 0x1 for Ethereum mainnet)

accept-languagestringRequired
Responses
200Success
application/json
get
GET /0.1/rebalancing/calculation-progress/{id} HTTP/1.1
Host: 
accept-language: text
Accept: */*
200Success
{
  "percent": 100,
  "message": "Finished",
  "failed": false,
  "rebalancing": {
    "id": "0096124c-19df-4459-8cbb-7615fdc7c157",
    "sellValueInUsd": 12345.67,
    "estimatedValueLossInUsd": 12.34,
    "estimatedReceiveValueInUsd": 12345.67,
    "minReceiveValueInUsd": 12325.67,
    "estimatedGasFees": "20000000000000000",
    "estimatedGasFeesInUsd": 23.45,
    "estimatedProtocolFeesInUsd": 23.45,
    "requiredAllowances": [
      {
        "token": {
          "id": "text",
          "address": "text",
          "name": "text",
          "symbol": "text",
          "imageUrl": "text",
          "decimals": 1,
          "coingeckoId": "text",
          "coinmarketcapId": "text",
          "coincapId": "text",
          "binanceSymbol": "text",
          "tags": [
            "text"
          ],
          "tokenType": 1,
          "allowanceType": 1,
          "enabled": true,
          "chain": {
            "name": "Ethereum",
            "identifier": "0x1",
            "enabled": true,
            "batchTradeSupported": true,
            "batchTradeAddress": "0x1ee8b39f09c5299526db65428ab2a8a23ebf08a7",
            "blockExplorerLink": "https://etherscan.io",
            "nativeTokenAddress": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
            "wrappedNativeTokenAddress": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
            "tokenHelperAddress": "0x6af90502f49E3B4151018F7aE82d10079c29Bc97",
            "portfolioEnabled": true
          },
          "sliderColor": "text",
          "queryPriceFromExchange": true,
          "mappingTokens": [
            "text"
          ],
          "mappingTokensOnly": true,
          "skipTradeValidation": true,
          "autoCreated": true
        },
        "allowanceTarget": "text",
        "neededAllowance": 1,
        "currentAllowance": 1,
        "resetNeeded": true
      }
    ],
    "trades": [
      {
        "id": "0096124c-19df-4459-8cbb-7615fdc7c157",
        "from": "0xdac17f958d2ee523a2206206994597c13d831ec7",
        "to": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
        "fromAmount": "100000000",
        "toAmount": "99500000",
        "minToReceive": "99000000",
        "toValueInEth": "69500000000000000",
        "fromValueInUsd": 100,
        "toValueInUsd": 99.5,
        "minToReceiveInUsd": 99,
        "calculatedLossPercentage": 0.005,
        "maxSlippage": 0.01,
        "price": 0.999955,
        "guaranteedPrice": 0.99,
        "previouslyRequiredTrades": [],
        "allowanceTarget": "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
        "estimatedFees": "5000000000000000",
        "txData": "0x6af479b200000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000005f5e1000000000000000000000000000000000000000000000000000000000005e68d620000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002bdac17f958d2ee523a2206206994597c13d831ec70001f4a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000869584cd00000000000000000000000058ee0e1efcb86ad60d4df3c8a32b398887bb148b0000000000000000000000000000000000000000000000de6f27846963566719",
        "txHandler": "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
        "expirationTimestamp": "2025-05-17T06:38:02.184Z",
        "transactions": [
          "text"
        ]
      }
    ],
    "txHandler": "text",
    "txData": {},
    "txValue": 1,
    "tokensWithoutPricePair": [
      "0x3ed3b47dd13ec9a98b44e6204a523e766b225811"
    ],
    "expirationTimestamp": "2024-04-29T06:40:39.808Z",
    "executable": [
      "true"
    ]
  }
}

Cancel rebalancing

get

Cancel async rebalancing with id

Path parameters
idstringRequired
Query parameters
walletAddressstringRequired
Header parameters
x-api-keystringOptional

31Third API key (Request via dev@31third.com)

chain-idstringOptional

Chain ID as hex string. (e.g.: 0x1 for Ethereum mainnet)

Responses
200Success
get
GET /0.1/rebalancing/cancel/{id}?walletAddress=text HTTP/1.1
Host: 
Accept: */*
200Success

No content

  • /rebalancing/calculation-progress/{id}
  • GETGet calculation progress
  • /rebalancing/cancel/{id}
  • GETCancel rebalancing