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
| Name | Type | Description |
|---|---|---|
| oldK | uint16 | The previous value of top-K. |
| newK | uint16 | The 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
| Name | Type | Description |
|---|---|---|
| asset | address | The address of the asset for which the checkpoint is recorded. |
| sharePrice | uint128 | The share price value at the checkpoint. |
| timestamp | uint48 | The 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
| Name | Type | Description |
|---|---|---|
| owner_ | address | Owner of this contract (can update k). |
| config_ | address | OrionConfig address. |
| k_ | uint16 | Initial number of top assets to select. |
| mode_ | enum KBestApyStrategist.WeightingMode | EqualWeighted: 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
| Name | Type | Description |
|---|---|---|
| vault_ | address | The 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
| Name | Type | Description |
|---|---|---|
| kNew | uint16 | The 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)