Skip to content

Latest commit

 

History

History
111 lines (65 loc) · 6.42 KB

Harvesting farm rewards and withdrawing SLP tokens from Masterchef(Minichef) contracts.md

File metadata and controls

111 lines (65 loc) · 6.42 KB

Harvesting farm rewards and withdrawing SLP tokens from Masterchef(Minichef) contracts

Harvesting farm rewards from MasterchefV1

With MasterchefV1 there is no “harvest” function, but users can still harvest their rewards.
To do so we simply "deposit" 0 SLP token, passing the corresponding pool ID:

  1. Go to MasterchefV1 address on the block explorer and click "Contract"->“Write Conteract” (https://etherscan.io/address/0xc2EdaD668740f1aA35E4D8f227fB8E17dcA888Cd#writeContract)

  2. Connect your wallet (Connect to Web3)

  3. Scroll to 2. deposit()

  4. Under “_pid (uint256)” input the farm's pool ID*

  • * The pool ID is a unique identifier, mapping the pool token to its allotment in the farm contract.
    These can be found in the transaction for staking the SLP token.
    • While on the page with transaction details press “+ Click to show more” image
    • Then click on “Decode Input Data” image
    • This will reveal the pid of the given farm image
  1. Under the “_amount (uint256)” field, input 0

  2. Click “Write” image

Harvesting farm rewards from MasterchefV2 and Minichefs contracts

  1. Go to the MasterchefV2 (Minichef) address on the block explorer and click "Contract"->“Write Conteract” (https://arbiscan.io/address/0xf4d73326c13a4fc5fd7a064217e12780e9bd62c3#writeContract) - Arbitrum example

  2. Connect your wallet (Connect to Web3)

  3. Scroll to 6. harvest()

  4. For “pid (uint256)”, input the farms unique identifier (pool ID) In this example: 12

  5. In the “to (address)” field, input the user’s address - In this example: 0x54962fb1ba5229413777fbadd4d826319e68c065

  6. Click “Write” image

Withdrawing SLP from MasterchefV1 (unstaking from a farm)

  1. Go to MasterchefV1 address on the block explorer and click "Contract"->“Read Conteract” (https://etherscan.io/address/0xc2EdaD668740f1aA35E4D8f227fB8E17dcA888Cd#readContract)

  2. Scroll down to 14. userInfo()

  3. In “ (uint256)” put the pid number * Here, it is 12, in another case it will be different. See above how to obtain PID number

  4. In “ (address)” put the user address - 0x7887056691765941ada17fdeb59e41cbe18b340f

  5. Click “query”

  6. Copy “amount” value
    image

  7. Click on “Write Contract” (https://etherscan.io/address/0xc2EdaD668740f1aA35E4D8f227fB8E17dcA888Cd#writeContract)

  8. Connect your wallet (Connect to Web3)

  9. Scroll down to 12. withdraw()

  10. In “_pid (uint256)” put the farm pid - 12

  11. In “_amount (uint256)” put the copied amount - 14134925891883420137

  12. Click “Write”

  • The transaction will unstake user’s SLP and also will automatically harvest the user’s farm rewards. image

NOTE: There is also the “Emergency withdraw” function, that can be found under 4. emergencyWithdraw().
But if this function is called the user will lose the pending farm rewards! To call this function the user must enter just the pid number and click “write”. Should be used only if the user needs to unstake in emergency!

Withdrawing SLP from MasterchefV2/Minichefs (unstaking from a farm)

Unlike MasterchefV1, for MasterchefV2 and Minichefs users have the option to select either “Withdraw and harvest”, or just “Withdraw” (unstaking SLP without harvesting the farm rewards. This can be useful if a reward contracts is out of the reward token, and the user still needs to unstake (Note this is not needed for v1 as reward is minted per block and cannot run out there). Where using wthdraw() without "harvest", users can harvest their rewards later, when rewarder contracts are refilled. Inputs are absolutely the same for both functions - Here is an Arbitrum example with calling “Withdraw” function.

NOTE: For MasterchefV2, the functions are under numbers 16. withdraw(), and 17. withdrawAndHarvest(), while for Minichefs, these are under numbers 15 withdraw(), and 16. withdrawAndHarvest() respectively.

  1. Navigate to the Minichef address with a block explorer and click "Contract"->“Read Conteract” (https://arbiscan.io/address/0xf4d73326c13a4fc5fd7a064217e12780e9bd62c3#readContract)

  2. Scroll down to 12. userInfo() (Note it is 14. userInfo() for MasterchefV2)

  3. For the first field “ (uint256)”, enter the pid number - In this example: 17

NOTE: Can see above how to obtain a farms PID

  1. For the second “ (address)”, in put the user address - In this example: 0x54962fb1ba5229413777fbadd4d826319e68c065

  2. Click “query”

  3. Copy “amount” value image

  4. Click on “Write Contract” (https://arbiscan.io/address/0xf4d73326c13a4fc5fd7a064217e12780e9bd62c3#writeContract)

  5. Connect your wallet (Connect to Web3)

  6. Scroll down to 15. withdraw()

  7. For “_pid (uint256)” input the farm pid - 17

  8. Under “_amount (uint256)” input the copied amount - 110874089890529377

  9. In the “to (address)” field, input user’s address - 0x54962fb1ba5229413777fbadd4d826319e68c065

  10. Click “Write” image