IndexZoo
Search…
Rebalance
SingleIndexModule.sol
Module that facilitates rebalances for indices. Manager can set target unit amounts, max trade sizes, the exchange to trade on, and the cool down period between trades (on a per asset basis) for the sake of rebalancing the assets. As currently constructed the module only works for one Set at a time.

Initializes this module to the SetToken. Only callable by the SetToken's manager.
function initialize(ISetToken _index) external
  • _index Address of index being used for this Set

Set new target units, zeroing out any units for components being removed from index. Log position multiplier to adjust target units in case fees are accrued. Validate that weth is not a part of the new allocation and that all components in current allocation are in _components array. Considered administrative function, hence to be called my Manager only
function startRebalance(address[] calldata _newComponents, uint256[] calldata _newComponentsTargetUnits, uint256[] calldata _oldComponentsTargetUnits, uint256 _positionMultiplier) external
  • _newComponents Array of new components to add to allocation
  • _newComponentsTargetUnits Array of target units at end of rebalance for new components, maps to same index of component
  • _oldComponentsTargetUnits Array of target units at end of rebalance for old component, maps to same index of component. Set to 0 if component being removed.
  • _positionMultiplier Position multiplier when target units were calculated, needed in order to adjust target units

Only approved addresses can call if anyoneTrade is false. Determines trade size and direction and swaps into or out of WETH on exchange specified by manager.
function trade(address _component) external
  • _component Component to trade

Only approved addresses can call if anyoneTrade is false. Only callable when
  1. 1.
    There are no more components to be sold (i.e. being on the buying phase of the rebalance).
  2. 2.
    Entire remaining WETH amount can be traded such that resulting inflows won't exceed components maxTradeSize nor overshoot the target unit. To be used near the end of rebalances when a component's calculated trade size is greater in value than remaining WETH.
function tradeRemainingWETH(address _component) external
  • _component Component to trade

Only allowed trader can call this function. For situation where all target units met and SetToken still holds some remaining WETH, uniformly raise targets by same percentage in order to allow further trading. Can be called multiple times if necessary, increase should be small in order to reduce tracking error.
function raiseAssetTargets() external

Set trade maximums for passed components. Only called by Manager.
function setTradeMaximums( address[] calldata _components, uint256[] calldata _tradeMaximums) external
  • _components Array of components
  • _tradeMaximums Array of trade maximums mapping to correct component

Set a uniswap-like decentralized exchanges for passed components. Only called by Manager.
function setExchanges(address[] calldata _components, uint256[] calldata _exchanges) external
  • _components Array of components
  • _exchanges Array of exchanges mapping to correct component, uint256 used to signify exchange

Set the coolOfffPeriod for components. It is needed in order to make sure enough time has elapsed since component's last trade. Only callable by Manager.
function setCoolOffPeriods(address[] calldata _components, uint256[] calldata _coolOffPeriods) external
  • _components Array of components
  • _coolOffPeriods Array of cool off periods to correct component

Toggle ability for passed addresses to trade from current state. Only called by Manager.
function updatetraderstatus(address[] calldata _traders, bool[] calldata _statuses) external
  • _traders Array trader addresses to toggle status
  • _statuses Booleans indicating if matching trader can trade

Toggle whether anyone can trade, bypassing the traderAllowList. Only called by Manager.
function updateAnyoneTrade(bool _status) external
  • _status Boolean indicating if anyone can trade

Get target units for passed components, normalized to current positionMultiplier.
function getTargetUnits(address[] calldata _components) external view returns(uint256[] memory)
  • _components Array of components to get target units for
  • return Array of targetUnits mapping to passed components

Get the target components aimed to be rebalanced (i.e. result of a prior call of startRebalance)
function getRebalanceComponents() external view returns(address[] memory)
Copy link
On this page