Yield Farms
Reaper deals a lot with Master Chef contracts, so ways to easily deploy and manage a lot of them is important
Deploying your Master Chef
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)
Adding a new farm
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)
Depositing into your farms
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
Retrieving User Info
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.
Using .toString()
makes it easy to to read bigNumber return values in the console
See how many farms you've started
Read the length of your Master Chef contract's poolInfo array with getPoolLength.
reaper.getPoolLength(chefAddress) => (uint)
Retrieving farm information
Use getPoolInfo to return the PoolInfo struct for whatever Pool ID you pass in.
reaper.getPoolInfo(chefAddress:string, pid:uint) => (poolInfo:object)
Last updated