Calculate a rebalancing by passing a base allocation (tokens + amounts) and a target allocation (tokens + percentages). Additional options are shown in the following request documentation:
Usage example with ethers.js
The API returns a DTO containing the following properties:
exportinterfaceRebalancingResponseDtoextendsBaseEntityModel {... txHandler:Address; // address of deployed BatchTrade txData:string; // calldata containing encoded Trades and BatchTradeConfig txValue:BigNumberDto; // value native currency sent for trading...}
Request a rebalancing for an arbitrary set of tokens
Sell tokens are passed with amounts, buy tokens are passed as percentage allocation
POST/0.1/rebalancing
Header parameters
Body
walletAddress*string
The wallet that is used to execute the rebalancing.
maxDeviationFromTargetnumber
Maximum deviation from the target allocation. (0.01 = 1%)
maxSlippagenumber
Maximum allowed slippage for the calculated trades. (0.01 = 1%)
excludedSourcesarray of string
List of DEXs that should not be used. (Supported DEXs can be queried from the /settings/exchanges endpoint).
automatedMarketMakerEnabled*boolean
Enables AMM trades
rfqtEnabled*boolean
Enables RFQT trades
batchTrade*boolean
Enables batch trading
revertOnError*boolean
Enables reverting the whole batch transaction if one single trade fails. Otherwise the already positive executed trades are settled.
failOnMissingPricePairboolean
If true, an exception is thrown, indicating that no price pair can be found for at least one of the vault 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.
baseEntries*array of RebalancingAmountEntryDto (object)
List of base entries (token and amount)
targetEntries*array of RebalancingAllocationEntryDto (object)
List of target entries (token and allocation)
Response
Body
id*string
Unique ID of the calculated rebalancing.
estimatedResultTvlInUsd*number
Estimated total portfolio value after the rebalancing. (in USD)
minResultTvlInUsd*number
Minimal total portfolio value after the rebalancing. (in USD)
estimatedTvlLossInUsd*number
Estimated loss of total portfolio value. (in USD)
estimatedFees*all of
Estimated network fees for the rebalancing. (in WEI)
estimatedFeesInUsd*number
Estimated network fees for the rebalancing. (in USD)
allowanceNeededAddresses*array of string
List of tokens for which the allowance has to be increased before executing the rebalancing. (List based on the wallet passed in the rebalancing request.)
trades*array of TradeDto (object)
List of trades which will be executed to fulfill the rebalancing.
txHandler*string
[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.
txData*object
[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.)
txValue*all of
Call value to execute the rebalancing. (Must be sent to the txHandler contract address.)
tokensWithoutPricePair*string
List of tokens for which no price pair could be found.
expirationTimestamp*string (date-time)
Currently, this is not a hard expiration timestamp. The rebalancing transaction can still be executed if the timestamp has expired, but there may already be substantial price changes on the market. (With the introduction of RFQ, the timestamp will be a hard deadline for executing the rebalancing transaction at a given quote. If the timestamp expires, a new quote will be issued with a new timestamp.)