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.

initialize

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

startRebalance

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
1
function startRebalance(address[] calldata _newComponents, uint256[] calldata _newComponentsTargetUnits, uint256[] calldata _oldComponentsTargetUnits, uint256 _positionMultiplier) external
Copied!
  • _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

trade

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.
1
function trade(address _component) external
Copied!
  • _component Component to trade

tradeRemainingWETH

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.
1
function tradeRemainingWETH(address _component) external
Copied!
  • _component Component to trade

raiseAssetTargets

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.
1
function raiseAssetTargets() external
Copied!

setTradeMaximums

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

setExchanges

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

setCoolOffPeriods

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.
1
function setCoolOffPeriods(address[] calldata _components, uint256[] calldata _coolOffPeriods) external
Copied!
  • _components Array of components
  • _coolOffPeriods Array of cool off periods to correct component

updatetraderstatus

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

updateAnyoneTrade

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

getTargetUnits

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

getRebalanceComponents

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