BaseYieldSkimmingHealthCheck
Inherits: BaseStrategy, IBaseHealthCheck
Author: Yearn.finance; modified by Golem Foundation
Health check for Yield Skimming strategies preventing unexpected profit/loss recording
Adapted for Yield Skimming with exchange rate monitoring. Reverts if profit/loss exceeds configured limits during harvestAndReport(). Does not prevent loss reporting, but requires manual intervention for unexpected values.
Notes:
-
security-contact: [email protected]
State Variables
doHealthCheck
bool public doHealthCheck = true;
MAX_BPS
uint256 internal constant MAX_BPS = 10_000;
_profitLimitRatio
uint16 private _profitLimitRatio = uint16(MAX_BPS);
_lossLimitRatio
uint16 private _lossLimitRatio;
Functions
constructor
constructor(
address _asset,
string memory _name,
address _management,
address _keeper,
address _emergencyAdmin,
address _donationAddress,
bool _enableBurning,
address _tokenizedStrategyAddress
)
BaseStrategy(
_asset,
_name,
_management,
_keeper,
_emergencyAdmin,
_donationAddress,
_enableBurning,
_tokenizedStrategyAddress
);
profitLimitRatio
Returns the current profit limit ratio.
Use a getter function to keep the variable private.
function profitLimitRatio() public view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | profitLimitRatio Current profit limit ratio |
lossLimitRatio
Returns the current loss limit ratio.
Use a getter function to keep the variable private.
function lossLimitRatio() public view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | lossLimitRatio Current loss limit ratio |
setProfitLimitRatio
Set the profitLimitRatio.
Denominated in basis points. I.E. 1_000 == 10%.
function setProfitLimitRatio(uint256 _newProfitLimitRatio) external onlyManagement;
Parameters
| Name | Type | Description |
|---|---|---|
_newProfitLimitRatio | uint256 | New profit limit ratio |
_setProfitLimitRatio
Internally set the profit limit ratio. Denominated in basis points. I.E. 1_000 == 10%.
function _setProfitLimitRatio(uint256 _newProfitLimitRatio) internal;
Parameters
| Name | Type | Description |
|---|---|---|
_newProfitLimitRatio | uint256 | New profit limit ratio |
getCurrentRateRay
Returns the current exchange rate in RAY format
function getCurrentRateRay() public view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Current exchange rate in RAY format |
setLossLimitRatio
Set the lossLimitRatio.
Denominated in basis points. I.E. 1_000 == 10%.
function setLossLimitRatio(uint256 _newLossLimitRatio) external onlyManagement;
Parameters
| Name | Type | Description |
|---|---|---|
_newLossLimitRatio | uint256 | New loss limit ratio |
_setLossLimitRatio
Internally set the loss limit ratio. Denominated in basis points. I.E. 1_000 == 10%.
function _setLossLimitRatio(uint256 _newLossLimitRatio) internal;
Parameters
| Name | Type | Description |
|---|---|---|
_newLossLimitRatio | uint256 | New loss limit ratio |
setDoHealthCheck
Turns the healthcheck on and off.
If turned off the next report will auto turn it back on.
function setDoHealthCheck(bool _doHealthCheck) public onlyManagement;
Parameters
| Name | Type | Description |
|---|---|---|
_doHealthCheck | bool | Bool if healthCheck should be done. |
harvestAndReport
Overrides the default harvestAndReport to include a healthcheck.
function harvestAndReport() external override onlySelf returns (uint256 _totalAssets);
Returns
| Name | Type | Description |
|---|---|---|
_totalAssets | uint256 | New totalAssets post report. |
_executeHealthCheck
To be called during a report to make sure the profit or loss being recorded is within the acceptable bound.
function _executeHealthCheck(uint256) internal virtual;
Events
HealthCheckUpdated
Emitted when the health check flag is updated
event HealthCheckUpdated(bool doHealthCheck);
Parameters
| Name | Type | Description |
|---|---|---|
doHealthCheck | bool | True if health check is enabled |
ProfitLimitRatioUpdated
Emitted when the profit limit ratio is updated
event ProfitLimitRatioUpdated(uint256 newProfitLimitRatio);
Parameters
| Name | Type | Description |
|---|---|---|
newProfitLimitRatio | uint256 | New profit limit ratio in basis points |
LossLimitRatioUpdated
Emitted when the loss limit ratio is updated
event LossLimitRatioUpdated(uint256 newLossLimitRatio);
Parameters
| Name | Type | Description |
|---|---|---|
newLossLimitRatio | uint256 | New loss limit ratio in basis points |