Strategy Smart Contract
No sense having all that honey without a plan to put it to work.
The Strategy is the entity that interacts with the Masterchef. Since Masterchefs track deposits & rewards per-address, Autocompounders need a single address to manage all the deposited tokens from Beras. While Vaults can be generalized, Strategy contracts contain all the Masterchef specific logic and may change based on the Autocompounder strategy (how often it is compounded, fees, etc). Strategies should only be called by the Vault and the off-chain service.
Strategy smart contracts expose the following:
function deposit(uint256 amount) external;
function harvest() external;
function withdraw(uint256 amount) external;
deposit
and withdraw
just call the underlying deposit/withdrawal functions on the Masterchef. These functions are called whenever the Vault receives a deposit or needs to make a withdrawal.
Harvest
is the core purpose of the Strategy. harvest
is called by the off-chain service (or manually, by individual Beras, who are rewarded with a % of fees) and will do the following:
Claim rewards from the Masterchef
For Masterchef, it’s done by calling deposit with 0 amount
Swapping the received reward tokens into the deposit token using a dex like uniswap, crocswap, etc.
Re-staking the tokens back into the Masterchef
Last updated