Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

WeightStrategy

Git Source

Title: WeightStrategy

Abstract contract for weight strategies that determine the target weights of assets in a basket.

This contract should be implemented by strategies that provide specific logic for calculating target weights. Use cases include:

  • AutomaticWeightStrategy.sol: Calculates weights based on external market data or other on-chain data sources.
  • ManagedWeightStrategy.sol: Allows manual setting of target weights by an authorized manager. The sum of the weights returned by getTargetWeights should be 1e18.

Functions

getTargetWeights

Returns the target weights for the assets in the basket that the rebalancing process aims to achieve.

function getTargetWeights(uint256 bitFlag) public view virtual returns (uint64[] memory targetWeights);

Parameters

NameTypeDescription
bitFlaguint256The bit flag representing a list of assets.

Returns

NameTypeDescription
targetWeightsuint64[]The target weights of the assets in the basket. The weights should sum to 1e18.

supportsBitFlag

Checks whether the strategy supports the given bit flag, representing a list of assets.

function supportsBitFlag(uint256 bitFlag) public view virtual returns (bool supported);

Parameters

NameTypeDescription
bitFlaguint256The bit flag representing a list of assets.

Returns

NameTypeDescription
supportedboolA boolean indicating whether the strategy supports the given bit flag.