Skip to main content

InitializableAbstractStrategy

InitializableAbstractStrategy

PTokenAdded

event PTokenAdded(address _asset, address _pToken)

PTokenRemoved

event PTokenRemoved(address _asset, address _pToken)

Deposit

event Deposit(address _asset, address _pToken, uint256 _amount)

Withdrawal

event Withdrawal(address _asset, address _pToken, uint256 _amount)

RewardTokenCollected

event RewardTokenCollected(address recipient, address rewardToken, uint256 amount)

RewardTokenAddressesUpdated

event RewardTokenAddressesUpdated(address[] _oldAddresses, address[] _newAddresses)

HarvesterAddressesUpdated

event HarvesterAddressesUpdated(address _oldHarvesterAddress, address _newHarvesterAddress)

platformAddress

address platformAddress

Address of the underlying platform

vaultAddress

address vaultAddress

Address of the OToken vault

assetToPToken

mapping(address => address) assetToPToken

asset => pToken (Platform Specific Token Address)

assetsMapped

address[] assetsMapped

Full list of all assets supported by the strategy

harvesterAddress

address harvesterAddress

Address of the Harvester contract allowed to collect reward tokens

rewardTokenAddresses

address[] rewardTokenAddresses

Address of the reward tokens. eg CRV, BAL, CVX, AURA

BaseStrategyConfig

struct BaseStrategyConfig {
address platformAddress;
address vaultAddress;
}

constructor

constructor(struct InitializableAbstractStrategy.BaseStrategyConfig _config) internal

Parameters

NameTypeDescription
_configstruct InitializableAbstractStrategy.BaseStrategyConfigThe platform and OToken vault addresses

_initialize

function _initialize(address[] _rewardTokenAddresses, address[] _assets, address[] _pTokens) internal

Internal initialize function, to set up initial internal state

Parameters

NameTypeDescription
_rewardTokenAddressesaddress[]Address of reward token for platform
_assetsaddress[]Addresses of initial supported assets
_pTokensaddress[]Platform Token corresponding addresses

collectRewardTokens

function collectRewardTokens() external virtual

Collect accumulated reward token and send to Vault.

_collectRewardTokens

function _collectRewardTokens() internal virtual

Default implementation that transfers reward tokens to the Vault. Implementing strategies need to add custom logic to collect the rewards.

onlyVault

modifier onlyVault()

Verifies that the caller is the Vault.

onlyHarvester

modifier onlyHarvester()

Verifies that the caller is the Harvester.

onlyVaultOrGovernor

modifier onlyVaultOrGovernor()

Verifies that the caller is the Vault or Governor.

onlyVaultOrGovernorOrStrategist

modifier onlyVaultOrGovernorOrStrategist()

Verifies that the caller is the Vault, Governor, or Strategist.

setRewardTokenAddresses

function setRewardTokenAddresses(address[] _rewardTokenAddresses) external

Set the reward token addresses. Any old addresses will be overwritten.

Parameters

NameTypeDescription
_rewardTokenAddressesaddress[]Array of reward token addresses

getRewardTokenAddresses

function getRewardTokenAddresses() external view returns (address[])

Get the reward token addresses.

Return Values

NameTypeDescription
[0]address[]address[] the reward token addresses.

setPTokenAddress

function setPTokenAddress(address _asset, address _pToken) external virtual

Provide support for asset by passing its pToken address. This method can only be called by the system Governor

Parameters

NameTypeDescription
_assetaddressAddress for the asset
_pTokenaddressAddress for the corresponding platform token

removePToken

function removePToken(uint256 _assetIndex) external virtual

Remove a supported asset by passing its index. This method can only be called by the system Governor

Parameters

NameTypeDescription
_assetIndexuint256Index of the asset to be removed

_setPTokenAddress

function _setPTokenAddress(address _asset, address _pToken) internal

Provide support for asset by passing its pToken address. Add to internal mappings and execute the platform specific, abstract method _abstractSetPToken

Parameters

NameTypeDescription
_assetaddressAddress for the asset
_pTokenaddressAddress for the corresponding platform token

transferToken

function transferToken(address _asset, uint256 _amount) public

Transfer token to governor. Intended for recovering tokens stuck in strategy contracts, i.e. mistaken sends.

Parameters

NameTypeDescription
_assetaddressAddress for the asset
_amountuint256Amount of the asset to transfer

setHarvesterAddress

function setHarvesterAddress(address _harvesterAddress) external

Set the Harvester contract that can collect rewards.

Parameters

NameTypeDescription
_harvesterAddressaddressAddress of the harvester contract.

_abstractSetPToken

function _abstractSetPToken(address _asset, address _pToken) internal virtual

safeApproveAllTokens

function safeApproveAllTokens() external virtual

deposit

function deposit(address _asset, uint256 _amount) external virtual

Deposit an amount of assets into the platform

Parameters

NameTypeDescription
_assetaddressAddress for the asset
_amountuint256Units of asset to deposit

depositAll

function depositAll() external virtual

Deposit all supported assets in this strategy contract to the platform

withdraw

function withdraw(address _recipient, address _asset, uint256 _amount) external virtual

Withdraw an amount of assets from the platform and send to the _recipient.

Parameters

NameTypeDescription
_recipientaddressAddress to which the asset should be sent
_assetaddressAddress of the asset
_amountuint256Units of asset to withdraw

withdrawAll

function withdrawAll() external virtual

Withdraw all supported assets from platform and sends to the OToken's Vault.

checkBalance

function checkBalance(address _asset) external view virtual returns (uint256 balance)

Get the total asset value held in the platform. This includes any interest that was generated since depositing.

Parameters

NameTypeDescription
_assetaddressAddress of the asset

Return Values

NameTypeDescription
balanceuint256Total value of the asset in the platform

supportsAsset

function supportsAsset(address _asset) public view virtual returns (bool)

Check if an asset is supported.

Parameters

NameTypeDescription
_assetaddressAddress of the asset

Return Values

NameTypeDescription
[0]boolbool Whether asset is supported