Skip to main content

CompoundStrategy

CompoundStrategy​

SkippedWithdrawal​

event SkippedWithdrawal(address asset, uint256 amount)

constructor​

constructor(struct InitializableAbstractStrategy.BaseStrategyConfig _stratConfig) public

initialize​

function initialize(address[] _rewardTokenAddresses, address[] _assets, address[] _pTokens) external

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 COMP and send to Harvester.

deposit​

function deposit(address _asset, uint256 _amount) external

Deposit asset into the underlying platform

Parameters​

NameTypeDescription
_assetaddressAddress of asset to deposit
_amountuint256Amount of assets to deposit

_deposit​

function _deposit(address _asset, uint256 _amount) internal

Deposit an asset into the underlying platform

Parameters​

NameTypeDescription
_assetaddressAddress of the asset to deposit
_amountuint256Amount of assets to deposit

depositAll​

function depositAll() external

Deposit the entire balance of any supported asset in the strategy into the underlying platform

withdraw​

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

Withdraw an asset from the underlying platform

Parameters​

NameTypeDescription
_recipientaddressAddress to receive withdrawn assets
_assetaddressAddress of the asset to withdraw
_amountuint256Amount of assets to withdraw

_abstractSetPToken​

function _abstractSetPToken(address _asset, address _pToken) internal

Internal method to respond to the addition of new asset / cTokens We need to approve the cToken and give it permission to spend the asset

Parameters​

NameTypeDescription
_assetaddressAddress of the asset to approve. eg DAI
_pTokenaddressThe pToken for the approval. eg cDAI or fDAI

withdrawAll​

function withdrawAll() external

Remove all supported assets from the underlying platform and send them to Vault contract.

checkBalance​

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

Get the total asset value held in the underlying platform This includes any interest that was generated since depositing. The exchange rate between the cToken and asset gradually increases, causing the cToken to be worth more corresponding asset.

Parameters​

NameTypeDescription
_assetaddressAddress of the asset

Return Values​

NameTypeDescription
balanceuint256Total value of the asset in the platform

_checkBalance​

function _checkBalance(contract ICERC20 _cToken) internal view returns (uint256 balance)

Get the total asset value held in the platform underlying = (cTokenAmt * exchangeRate) / 1e18

Parameters​

NameTypeDescription
_cTokencontract ICERC20cToken for which to check balance

Return Values​

NameTypeDescription
balanceuint256Total value of the asset in the platform

safeApproveAllTokens​

function safeApproveAllTokens() external

Approve the spending of all assets by their corresponding cToken, if for some reason is it necessary.