For the complete documentation index, see llms.txt. This page is also available as Markdown.

Wallet

Calculate a rebalancing for a wallet. The minimal params are:

  • signer: Address

  • wallet: Address

  • baseEntries

  • targetEntries

Request a rebalancing for an arbitrary set of tokens

post

Sell tokens are passed with amounts, buy tokens are passed as percentage allocation

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)

Body
signerstringRequired

The wallet that is used to sign the rebalancing and send it on-chain.

Example: 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B
maxDeviationFromTargetnumber · min: 0.001 · max: 1Optional

Maximum deviation from the target allocation. (0.01 = 1%)

Default: 0.005
maxSlippagenumber · max: 1Optional

Maximum allowed slippage for the calculated trades. (0.01 = 1%)

Default: 0.005
maxPriceImpactnumber · max: 1Optional

Max price impact for the calculated basket trade. (0.01 = 1%)

Default: 0.01
priceImpactExceedsErrorbooleanOptional

If true an error is returned if the price impact is exceeded. Otherwise an issue (warning) is added to the response. Defaults to false.

Default: false
minExpirySecnumber · min: 10 · max: 120Optional

Min quote expiry. (in seconds) RFQ/OTC quotes from market makers have hard expiries between 40-90 seconds. If minExpiry is set higher then MM expiries these MMs are excluded. (Keep in mind that MM pricing might be better than DEX pricing, especially if quantity is high)

Default: 35
minTradeValuenumberOptional

Min trade value. (in USD) The smart order router ignores potential trades with a value smaller than minTradeValue. Super small value trades often lead to execution issues, therefore we skip trades smaller than $1 by default.

Default: 1
batchTradebooleanOptional

Describes if batch trading should be enabled (if not trades can be executed one-by-one)

Default: trueExample: true
revertOnErrorbooleanOptional

Describes if the batch execution should revert if one trade fails. Otherwise the already positive executed trades are settled.

Default: true
skipBalanceValidationbooleanOptional

Describes if balance check should be skipped. (Can be useful for testing).

Default: false
failOnMissingPricePairbooleanOptional

If true, an exception is thrown, indicating that no price pair can be found for at least one of the tokens. (Only assets with a balance greater than 0 are considered.) If false, the rebalancing is still calculated without considering the tokens with no pairs.

Default: trueExample: true
asyncbooleanOptional

If true the rebalancing will be calculated asynchronously. The progress can be checked with the responded id

Default: falseExample: true
simulationTxOriginstringRequired

[FOR TENDERLY SIMULATION] Address that should be used instead of signer. Can be useful for Tenderly simulation if simulating an Enzyme vault you're not the owner of.

Example: 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B
walletstringRequired

Wallet for which the rebalancing is calculated.

Example: 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B
Responses
200Success
application/json
idstringRequired

Unique ID of the calculated rebalancing.

Example: 0096124c-19df-4459-8cbb-7615fdc7c157
creationDatestring · date-timeRequired

Rebalancing creation timestamp

baseValueInUsdnumberRequired

Total value of assets in the rebalancing base allocation. (in USD)

Example: 12345.67
sellValueInUsdnumberRequired

The proportion of value that is taken out for trades, meaning sold. (in USD)

Example: 12345.67
estimatedValueLossInUsdnumberRequired

Estimated loss of total portfolio value. (in USD; fees are already included in this value)

Example: 12.34
estimatedTargetValueInUsdnumberRequired

Estimated total value of the rebalancing target allocation. (in USD; fees are already included in this value)

Example: 12345.67
estimatedReceiveValueInUsdnumberRequired

Estimated value of assets received after all trades. (in USD; fees are already included in this value)

Example: 12345.67
minReceiveValueInUsdnumberRequired

Minimal total portfolio value after the rebalancing. (in USD; slippage and fees are included in this value)

Example: 12325.67
estimatedImpactnumberRequired

Estimated impact. (0.01 = 1%; fees are already included in this value)

Example: 0.0023
maxImpactnumberRequired

Maximal impact. (0.01 = 1%; slippage and fees are included in this value)

Example: 0.0027
estimatedGasUnitsinteger · int64Required

Estimated gas units for this trade. (in WEI)

Example: 20000000000000000
suggestedGasPriceinteger · int64Required

Suggested gas price [LOW/MARKET/AGGRESSIVE] fetched from a block explorer (e.g. Etherscan). (in WEI)

Example: 20000000000000000
estimatedGasFeesinteger · int64Required

Estimated gas fees for the rebalancing. (in WEI)

Example: 20000000000000000
estimatedGasFeesInUsdnumberRequired

Estimated gas fees for the rebalancing. (in USD)

Example: 23.45
estimatedProtocolFeesInUsdnumberRequired

Estimated protocol fees for the rebalancing. (in USD)

Example: 23.45
txHandlerstringRequired

[Just if a batch trade is requested, otherwise use txHandler per trade] Address of the contract to send the txData to. It will be our batch trade contract if it is a rebalancing transaction. However, in some special cases, it may also be a different contract, for example, in the case of wrapping ETH into WETH.

txDataobjectRequired

[Just if a batch trade is requested, otherwise use txData per trade] Call data to execute the rebalancing. (Must be sent to the txHandler contract address.)

txValueinteger · int64Required

Call value to execute the rebalancing. (Must be sent to the txHandler contract address.)

tokensWithoutPricePairstringRequired

List of tokens for which no price pair could be found.

Example: ["0x3ed3b47dd13ec9a98b44e6204a523e766b225811"]
executablebooleanRequired

Is executable based on wallet permissions for smart contracts

Example: ["true"]
expirationTimestampstring · date-timeRequired

If the rebalancing contains RFQ/OTC trades this is a hard deadline.If not this can be considered as soft deadline. A new rebalancing should be calculated since after some time market prices might have changed in a way that another composition of trades might be better.

Example: 2025-10-17T08:27:04.604Z
earliestRefreshQuotesTimestampstring · date-timeRequired

Earliest timestamp when quotes for this rebalancing can be refreshed

suggestedRefreshQuotesTimestampstring · date-timeRequired
post/1.3/rebalancing/wallet
POST /1.3/rebalancing/wallet HTTP/1.1
Content-Type: application/json
Accept: */*
Content-Length: 753

{
  "signer": "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B",
  "baseEntries": [
    {
      "tokenAddress": "0xdac17f958d2ee523a2206206994597c13d831ec7",
      "amount": "69500000000000000"
    }
  ],
  "targetEntries": [
    {
      "tokenAddress": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
      "allocation": 0.2
    }
  ],
  "maxDeviationFromTarget": 0.005,
  "maxSlippage": 0.005,
  "maxPriceImpact": 0.01,
  "priceImpactExceedsError": false,
  "minExpirySec": 35,
  "minTradeValue": 1,
  "liquiditySourceConfig": {
    "types": [
      "text"
    ],
    "sources": {
      "include": {
        "source_a": {
          "subSources": {
            "sub_a1": {}
          }
        },
        "source_d": {}
      }
    }
  },
  "batchTrade": true,
  "revertOnError": true,
  "skipBalanceValidation": false,
  "failOnMissingPricePair": true,
  "async": true,
  "simulationTxOrigin": "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B",
  "wallet": "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B"
}
200Success
{
  "id": "0096124c-19df-4459-8cbb-7615fdc7c157",
  "creationDate": "2026-01-01T00:00:00.000Z",
  "baseValueInUsd": 12345.67,
  "sellValueInUsd": 12345.67,
  "estimatedValueLossInUsd": 12.34,
  "estimatedTargetValueInUsd": 12345.67,
  "estimatedReceiveValueInUsd": 12345.67,
  "minReceiveValueInUsd": 12325.67,
  "estimatedImpact": 0.0023,
  "maxImpact": 0.0027,
  "estimatedGasUnits": "20000000000000000",
  "suggestedGasPrice": "20000000000000000",
  "estimatedGasFees": "20000000000000000",
  "estimatedGasFeesInUsd": 23.45,
  "estimatedProtocolFeesInUsd": 23.45,
  "requiredAllowances": [
    {
      "token": {
        "address": "0x95ad61b0a150d79219dcf64e1e6cc01f0b64c4ce",
        "name": "Shiba Inu",
        "symbol": "SHIB",
        "imageUrl": "https://assets.31third.com/images/tokens/SHIB.svg",
        "decimals": 18,
        "sliderColor": "#C47438",
        "chain": {
          "name": "Ethereum",
          "identifier": "0x1",
          "enabled": true,
          "batchTradeSupported": true,
          "batchTradeAddress": "0x1ee8b39f09c5299526db65428ab2a8a23ebf08a7",
          "blockExplorerLink": "https://etherscan.io",
          "nativeTokenAddress": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
          "wrappedNativeTokenAddress": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
          "tokenHelperAddress": "0x6af90502f49E3B4151018F7aE82d10079c29Bc97",
          "portfolioEnabled": true
        },
        "tags": [
          "text"
        ],
        "deflationary": true
      },
      "allowanceTarget": "text",
      "neededAllowance": 1,
      "currentAllowance": 1,
      "resetNeeded": true
    }
  ],
  "trades": [
    {
      "from": "0xdac17f958d2ee523a2206206994597c13d831ec7",
      "to": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
      "fromAmount": "100000000",
      "toAmount": "99500000",
      "minToReceiveBeforeFees": "99000000",
      "minToReceive": "99000000",
      "fromValueInUsd": 100,
      "toValueInUsd": 99.5,
      "minToReceiveBeforeFeesInUsd": 99,
      "minToReceiveInUsd": 99,
      "estimatedPriceImpact": 0.005,
      "maxSlippage": 0.005,
      "price": 0.999955,
      "guaranteedPrice": 0.99,
      "previouslyRequiredTrades": [],
      "allowanceTarget": "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
      "estimatedGasUnits": "5000000000000000",
      "suggestedGasPrice": "5000000000000000",
      "estimatedGasFees": "5000000000000000",
      "expirationTimestamp": "2026-01-01T00:00:00.000Z",
      "transactions": [
        "text"
      ],
      "fill": {
        "liquiditySource": {
          "identifier": "text",
          "readableName": "text",
          "iconUrl": "text",
          "enabled": true
        },
        "proportionInBps": 1,
        "from": {
          "address": "0x95ad61b0a150d79219dcf64e1e6cc01f0b64c4ce",
          "name": "Shiba Inu",
          "symbol": "SHIB",
          "imageUrl": "https://assets.31third.com/images/tokens/SHIB.svg",
          "decimals": 18,
          "sliderColor": "#C47438",
          "chain": {
            "name": "Ethereum",
            "identifier": "0x1",
            "enabled": true,
            "batchTradeSupported": true,
            "batchTradeAddress": "0x1ee8b39f09c5299526db65428ab2a8a23ebf08a7",
            "blockExplorerLink": "https://etherscan.io",
            "nativeTokenAddress": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
            "wrappedNativeTokenAddress": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
            "tokenHelperAddress": "0x6af90502f49E3B4151018F7aE82d10079c29Bc97",
            "portfolioEnabled": true
          },
          "tags": [
            "text"
          ],
          "deflationary": true
        },
        "to": {
          "address": "0x95ad61b0a150d79219dcf64e1e6cc01f0b64c4ce",
          "name": "Shiba Inu",
          "symbol": "SHIB",
          "imageUrl": "https://assets.31third.com/images/tokens/SHIB.svg",
          "decimals": 18,
          "sliderColor": "#C47438",
          "chain": {
            "name": "Ethereum",
            "identifier": "0x1",
            "enabled": true,
            "batchTradeSupported": true,
            "batchTradeAddress": "0x1ee8b39f09c5299526db65428ab2a8a23ebf08a7",
            "blockExplorerLink": "https://etherscan.io",
            "nativeTokenAddress": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
            "wrappedNativeTokenAddress": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
            "tokenHelperAddress": "0x6af90502f49E3B4151018F7aE82d10079c29Bc97",
            "portfolioEnabled": true
          },
          "tags": [
            "text"
          ],
          "deflationary": true
        },
        "subFills": [
          "text"
        ]
      }
    }
  ],
  "txHandler": "text",
  "txData": {},
  "txValue": 1,
  "tokensWithoutPricePair": [
    "0x3ed3b47dd13ec9a98b44e6204a523e766b225811"
  ],
  "executable": [
    "true"
  ],
  "expirationTimestamp": "2025-10-17T08:27:04.604Z",
  "earliestRefreshQuotesTimestamp": "2026-01-01T00:00:00.000Z",
  "suggestedRefreshQuotesTimestamp": "2026-01-01T00:00:00.000Z",
  "tenderlySimulation": {
    "status": true,
    "errorMessage": "text",
    "blockNumber": 313313,
    "gas": "313313",
    "gasUsed": "310313"
  }
}

Last updated