BaseStrategy
Inherits: Initializable, OwnableUpgradeable, ReentrancyGuardUpgradeable
Author: Sperax Foundation
Contract acts as a single interface for implementing specific yield-earning strategies.
State Variables
vault
withdrawSlippage
depositSlippage
harvestIncentiveRate
assetsMapped
rewardTokenAddress
assetToPToken
gap
Functions
onlyVault
onlyVaultOrOwner
constructor
updateVault
Update the linked vault contract.
Parameters
_newVault
address
Address of the new Vault.
updateHarvestIncentiveRate
Updates the HarvestIncentive rate for the user.
Parameters
_newRate
uint16
new Desired rate.
recoverERC20
A function to recover any erc20 token sent to this strategy mistakenly.
Only callable by owner.
reverts if amount > balance.
Parameters
token
address
Address of the token.
receiver
address
Receiver of the token.
amount
uint256
Amount to be recovered.
deposit
Deposit an amount of asset into the platform.
Parameters
_asset
address
Address for the asset.
_amount
uint256
Units of asset to deposit.
withdraw
Withdraw an amount of asset from the platform.
Parameters
_recipient
address
Address to which the asset should be sent.
_asset
address
Address of the asset.
_amount
uint256
Units of asset to withdraw.
Returns
amountReceived
uint256
The actual amount received.
withdrawToVault
Withdraw an amount of asset from the platform to vault.
Parameters
_asset
address
Address of the asset.
_amount
uint256
Units of asset to withdraw.
collectInterest
Withdraw the interest earned of asset from the platform.
Parameters
_asset
address
Address of the asset.
collectReward
Collect accumulated reward token and send to Vault.
checkBalance
Get the amount of a specific asset held in the strategy, excluding the interest.
Curve: assuming balanced withdrawal.
Parameters
_asset
address
Address of the asset.
Returns
uint256
uint256 Balance of _asset in the strategy.
checkAvailableBalance
Get the amount of a specific asset held in the strategy, excluding the interest and any locked liquidity that is not available for instant withdrawal.
Curve: assuming balanced withdrawal.
Parameters
_asset
address
Address of the asset.
Returns
uint256
uint256 Available balance inside the strategy for _asset.
checkInterestEarned
AAVE: Get the interest earned on a specific asset. Curve: Get the total interest earned.
Curve: to avoid double-counting, _asset has to be of index 'entryTokenIndex'.
Parameters
_asset
address
Address of the asset.
Returns
uint256
uint256 Amount of interest earned.
checkRewardEarned
Get the amount of claimable reward.
Returns
RewardData[]
struct array of type RewardData (address token, uint256 amount).
checkLPTokenBalance
Get the total LP token balance for a asset.
Parameters
_asset
address
Address of the asset.
supportsCollateral
Check if an asset/collateral is supported.
Parameters
_asset
address
Address of the asset.
Returns
bool
bool Whether asset is supported.
updateSlippage
Change to a new depositSlippage & withdrawSlippage.
Parameters
_depositSlippage
uint16
Slippage tolerance for allocation.
_withdrawSlippage
uint16
Slippage tolerance for withdrawal.
_initialize
Initialize the base properties of the strategy.
Parameters
_vault
address
Address of the USDs Vault.
_depositSlippage
uint16
Allowed max slippage for Deposit.
_withdrawSlippage
uint16
Allowed max slippage for withdraw.
_setPTokenAddress
Provide support for asset by passing its pToken address. Add to internal mappings and execute the platform specific, abstract method _abstractSetPToken
.
Parameters
_asset
address
Address for the asset.
_pToken
address
Address for the corresponding platform token.
_removePTokenAddress
Remove a supported asset by passing its index. This method can only be called by the system owner.
Parameters
_assetIndex
uint256
Index of the asset to be removed.
Returns
asset
address
address which is removed.
_splitAndSendReward
Splits and sends the accumulated rewards to harvestor and yield receiver.
Sends the amount to harvestor as per harvestIncentiveRate
and sends the rest to yield receiver.
Parameters
_token
address
Address of the reward token.
_yieldReceiver
address
Address of the yield receiver.
_harvestor
address
Address of the harvestor.
_amount
uint256
to be split and sent.
Returns
uint256
uint256 Harvested amount sent to yield receiver.
_abstractSetPToken
Call the necessary approvals for the underlying strategy.
Parameters
_asset
address
Address of the asset.
_pToken
address
Address of the corresponding receipt token.