Skip to main content

BaseYieldSkimmingHealthCheck

Git Source

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:

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

NameTypeDescription
<none>uint256profitLimitRatio 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

NameTypeDescription
<none>uint256lossLimitRatio Current loss limit ratio

setProfitLimitRatio

Set the profitLimitRatio.

Denominated in basis points. I.E. 1_000 == 10%.

function setProfitLimitRatio(uint256 _newProfitLimitRatio) external onlyManagement;

Parameters

NameTypeDescription
_newProfitLimitRatiouint256New 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

NameTypeDescription
_newProfitLimitRatiouint256New profit limit ratio

getCurrentRateRay

Returns the current exchange rate in RAY format

function getCurrentRateRay() public view returns (uint256);

Returns

NameTypeDescription
<none>uint256Current 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

NameTypeDescription
_newLossLimitRatiouint256New 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

NameTypeDescription
_newLossLimitRatiouint256New 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

NameTypeDescription
_doHealthCheckboolBool if healthCheck should be done.

harvestAndReport

Overrides the default harvestAndReport to include a healthcheck.

function harvestAndReport() external override onlySelf returns (uint256 _totalAssets);

Returns

NameTypeDescription
_totalAssetsuint256New 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

NameTypeDescription
doHealthCheckboolTrue if health check is enabled

ProfitLimitRatioUpdated

Emitted when the profit limit ratio is updated

event ProfitLimitRatioUpdated(uint256 newProfitLimitRatio);

Parameters

NameTypeDescription
newProfitLimitRatiouint256New profit limit ratio in basis points

LossLimitRatioUpdated

Emitted when the loss limit ratio is updated

event LossLimitRatioUpdated(uint256 newLossLimitRatio);

Parameters

NameTypeDescription
newLossLimitRatiouint256New loss limit ratio in basis points