Skip to main content

KBestApyStrategist

KBestApyStrategist

Top-K asset selection by estimated APY with configurable weighting: equal weights or APY-proportional.

SECONDS_PER_YEAR

uint256 SECONDS_PER_YEAR

WAD

uint256 WAD

MIN_WINDOW

uint256 MIN_WINDOW

WeightingMode

How selected tokens are weighted in the intent.

enum WeightingMode {
EqualWeighted,
ApyWeighted
}

Checkpoint

Packed into one storage slot (128 + 48 = 176 bits).

struct Checkpoint {
uint128 sharePrice;
uint48 timestamp;
}

WEIGHTING_MODE

enum KBestApyStrategist.WeightingMode WEIGHTING_MODE

Weighting strategy; fixed at deployment.

CONFIG

contract IOrionConfig CONFIG

The Orion configuration contract.

k

uint16 k

Number of top assets to select.

KUpdated

event KUpdated(uint16 oldK, uint16 newK)

Emitted when updateParameters changes the top-K count.

Parameters

NameTypeDescription
oldKuint16The previous value of top-K.
newKuint16The new value of top-K after the update.

CheckpointRecorded

event CheckpointRecorded(address asset, uint128 sharePrice, uint48 timestamp)

Emitted when a share-price checkpoint is recorded for an asset (end of submitIntent).

Parameters

NameTypeDescription
assetaddressThe address of the asset for which the checkpoint is recorded.
sharePriceuint128The share price value at the checkpoint.
timestampuint48The timestamp when the checkpoint was recorded.

constructor

constructor(address owner_, address config_, uint16 k_, enum KBestApyStrategist.WeightingMode mode_) public

Initializes the KBestApyStrategist contract with owner, config, k, and weighting mode.

Parameters

NameTypeDescription
owner_addressOwner of this contract (can update k).
config_addressOrionConfig address.
k_uint16Initial number of top assets to select.
mode_enum KBestApyStrategist.WeightingModeEqualWeighted: equal split among top-K; ApyWeighted: weights ∝ APY (equal if all APY zero).

setVault

function setVault(address vault_) external

Link this strategist to a vault. Can only be called once per deployment.

Parameters

NameTypeDescription
vault_addressThe vault address to link to this strategist.

supportsInterface

function supportsInterface(bytes4 interfaceId) public view virtual returns (bool)

_Returns true if this contract implements the interface defined by interfaceId. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section] to learn more about how these ids are created.

This function call must use less than 30 000 gas._

submitIntent

function submitIntent() external

Compute the current portfolio intent from on-chain state and submit it to the linked vault.

updateParameters

function updateParameters(uint16 kNew) external

Update the number of top assets to select.

Parameters

NameTypeDescription
kNewuint16The new value for k (number of top assets to select).

_recordCheckpointsForAssets

function _recordCheckpointsForAssets(address[] assets, uint16 n) internal

Records checkpoints for a fixed asset list.

_recordCheckpoint

function _recordCheckpoint(address asset) internal

Skips if the existing checkpoint is less than MIN_WINDOW old.

_getAssetApy

function _getAssetApy(address asset) internal view returns (uint256)

_getAssetApys

function _getAssetApys(address[] assets, uint16 n) internal view returns (uint256[] apys)

_selectTopKByApy

function _selectTopKByApy(address[] assets, uint256[] apys, uint16 n, uint16 kActual) internal pure returns (address[] tokens, uint256[] topApys)

_buildIntent

function _buildIntent(address[] tokens, uint256[] topApys, uint16 kActual) internal view returns (struct IOrionTransparentVault.IntentPosition[] intent)