Rebalancing

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:

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 ethers signer.sendTransaction as follows:

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

Last updated