Reaper deals a lot with Master Chef contracts, so ways to easily deploy and manage a lot of them is important
Create and deploy a MasterChef contract with a single function. Input the administrator address and emissions per second, and instead of putting the starting timestamp simply input the delay until emissions begin in seconds and the proper timestamp will be created for you.
reaper.deployMasterChef(adminAddress: string, emissions:bigNumber, delay:uint-seconds) => (contract:object)
Add farms to your Master Chef contract using the addFarm function. Pass in the address of your target Chef contract along with the supported token and number of allocation points. You can put a sleep after deployment to make sure the contract is finished constructing before your next call.
reaper.addFarm(masterchefAddress: string, tokenAddress: string, allocation: uint) => (transactionReceipt:object)
After you add farms to your Master Chef, you can approve and deposit in one function with depositToFarm. Pass in the MasterChef address, the Pool ID, and the amount you're depositing.
reaper.depositToFarm(chefAddress: string, pid: uint, amount: uint) => transactionReceipt:object
In the below example, I deploy a test token, mint it to my wallet, then deploy my Master Chef, add a farm, and deposit into it
You can view your account information struct with getUserInfo.
reaper.getUserInfo(chefAddress: string, pid: uint, userAddress: string) => (userInfo:object)
In the example below, I create a test token and mint it, then deploy my Master Chef, add a farm, deposit into it, and check on my position.
Inserting pauses with
sleep()after complex transactions will ensure all your contract interactions have finished execution before you try to interact with them.
.toString()makes it easy to to read bigNumber return values in the console
const testToken = await reaper.deployTestToken("Reaper.Farm", "R3PR", reaper.BigGas);
await reaper.mintTestToken(testToken.address, self, await reaper.parseToken(100000));
let chef = await reaper.deployMasterChef(self, ethers.utils.parseEther("0.01"), 3, reaper.BigGas);
await reaper.addFarm(chef.address, testToken.address, 500, reaper.BigGas);