# Introduction

Reaper.Farm is an auto-compounding yield farm that maximizes users’ yields by automating the power of compound interest.

It does so by offering “Vaults”. Vaults are automated financial strategies, where a user can deposit assets that would otherwise earn yield elsewhere. These vaults redirect the user’s funds to the original source of yield. Reaper Harvest-Bots automatically harvest emissions when profitable, and compound them back into the vault on behalf of the user. The user can then sit back and relax while their position grows, and can withdraw their funds at any time.

<div align="center"><img src="https://2226044781-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M_3DKLtyg_0E-mdery8%2F-MaK623GZyxFSNQD601m%2F-MaLtAW-a-51qFubtVD_%2Fimage.png?alt=media&amp;token=1d14c9c8-d633-4c98-8a1c-3fc26173546c" alt="Reaper Farm"></div>

The purpose of this documentation is to teach you everything you need to know about Reaper Farm in order to safely use the protocol. If you have never used DeFi before or are not confident with basic crypto wallet principles, you can find loads of helpful articles on the [Blockbytes website](https://blockbytes.com/). If ever in doubt, please reach out to our team and we will gladly direct you to additional educational content. We love helping users.

#### Additional resources:

You can learn more about setting up Metamask on the Fantom network [here](https://docs.fantom.foundation/wallet/set-up-metamask).

You can learn more about setting up a Coinbase wallet [here](https://help.coinbase.com/en/wallet/getting-started/what-types-of-crypto-does-wallet-support).

You can learn more about setting up a Clover wallet [here](https://docs.clv.org/intro-to-clv/about-clover).

You can find alternative RPCs for the Fantom network [here](https://ftm.guru/rpc.html).


# Reaper Philosophy

**Reaper Farm** is maintained by the **OATH Foundation**, a development collective pursuing open, secure, and reliable systems focussed on helping users navigate the new web and Decentralized Finance (DeFi).

**Reaper Farm** is not a "black-box” solution. We do not hide the contracts, fluff numbers, or try to confuse anyone with meaningless jargon. All vaults provide custom industry-leading on-chain analytics so you can see how well your assets are performing. We strive for transparency and are actively progressing towards true decentralization. Reaper Farm is designed to be as secure as possible while generating competitive returns with minimal fees.

#### Additional resources:

You can find the Byte Masons website [here](https://www.bytemasons.com/).

You can find the OATH Ecosystem website [here](https://www.oath.eco/).


# Contact Us

We enjoy and empower business and community engagement and hope to learn as much from you as you do from us. You can find us on [Twitter ](https://twitter.com/Reaper_Farm), [Telegram](https://reaper-bytemasons.gitbook.io/reaper-farms/), and [Discord](https://discord.gg/waAg4nV5Ee).


# What is a Vault?

A **vault** is an automated financial strategy, where assets are deposited that could otherwise earn yield elsewhere. Vaults redirect deposited assets to those sources of yield, and Reaper Harvest-Bots automatically harvest earnings when profitable, and compound them back into the vault. The position grows passively and assets remain accessible at all times. At Reaper Farm, you may see vaults colloquially referred to as *'crypts'*.

Each Reaper Vault consists of two smart contracts: a Vault Contract and a Strategy contract. Both exist on the blockchain and can be publicly verified by anyone.

Click the ‘More Info’ button on any vault and you will see links to the specific contracts like so:

{% embed url="<https://youtu.be/7H8fZ2Wv8wA>" %}

## Vault Contracts

The Vault contract secures and manages all deposits and withdrawals for all vault assets. This contract replaces an intermediary or custodian for your deposits. It is like a bank teller and a bank vault rolled into one.

## Strategy Contracts

The Strategy contract handles all the transactions that go into generating yield. It sells the rewards farmed with your assets, creates new LPs or underlying tokens, and re-deposits them into the Vault contract for you. If the Vault contract is the teller, the Strategy contract is your broker. It is the one doing the work of generating value for you.

All the gains on your deposit stay in the vault earning more and more return until you decide to withdraw. In most countries this is tax-efficient because no gain is realized until withdrawal.


# rfTokens

Vault positions are represented by rfTokens.

<div align="center"><figure><img src="https://2226044781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_3DKLtyg_0E-mdery8%2Fuploads%2F3gcbZ1epxMd26Ba9Tc4v%2Fimage.png?alt=media&amp;token=9f45f093-e8f5-44d3-b95a-8aa992f4283d" alt=""><figcaption><p>FTMScan: rfWFTM token issued by the WFTM Multi-Strategy Crypt</p></figcaption></figure></div>

When you deposit assets into a vault, you will receive rfTokens specific to that vault, proportional to your investment size (see Vault Shares below). rfTokens are essentially coupons the smart contracts issue to track your investment. When you withdraw, the contract needs your rfTokens in order to return your funds. You do not need to add them to metamask or send them anywhere. **You never need to interact with these rfTokens directly.** The Reaper Farm contracts will retrieve them from your address automatically. ***If you lose your rfTokens, the Byte Masons cannot help you.***

Because rfTokens represent your vault position, they are treated as an interest-bearing asset. In most countries this is **tax-efficient** because you no longer have to record claims and trades when farming manually.

## Vault Shares

Vault shares can be seen when withdrawing from a vault.

It may be confusing because the number of shares you have will be different to the amount of assets you deposited, but vault shares indicate how big of a share of the total vault your deposit entitles you to. When you withdraw assets, you are reducing your share of the vault and thus your total vault shares (same goes for deposits). They are simply a representation of your stake in the vault.


# Vault Tags

Every vault on Reaper has tags associated with it. These tags serve as objective risk assessment vectors that we hope will help you make informed investment decisions.

<div align="center"><img src="https://2226044781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_3DKLtyg_0E-mdery8%2Fuploads%2Fuv4Hp6bxQMNCaB938Mcn%2FScreenshot%20from%202022-04-26%2022-06-17.png?alt=media&amp;token=cf724426-d1e2-4309-a880-f99424f56c3f" alt="Vault tags"></div>

From left to right in the image above, we will discuss what each tag symbolizes.

## Platform Risk

The longer a platform has been live, the more likely it has been subjected to different attack vectors and withstood the ultimate test; the test of time. If the underlying protocol that the vault's strategy relies on has been in production for more than three months, the platform risk tag will be the clock symbol. Otherwise, it will be the "NEW" symbol.

![Platform risk tag](https://2226044781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_3DKLtyg_0E-mdery8%2Fuploads%2FV0JOhzbkYre8RSUxevTs%2FTAGS-Platform-Time-Test-1.png?alt=media\&token=428c3bc0-b3ce-4b3c-b1f3-7a8711c1e5fd)

## Reaper Risk

At Reaper Farm we write smart contracts on top of other protocols' smart contracts to help you get the most out of your investments. Naturally, our own contracts introduce another layer of smart contract risk. This risk is entirely a function of how complex a vault's strategy is, and we utilize gauges to communicate this intuitively. Most strategies will be low in complexity, with some being medium, and “high” used sparingly.

![Reaper risk tag](https://2226044781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_3DKLtyg_0E-mdery8%2Fuploads%2Fo4HxNMl7nPP47GIVcWSi%2FTAGS-Strategy-Complexity-1.png?alt=media\&token=8ee7d507-9496-4340-872c-5d2059d65cef)

## Asset Risk

Asset risk is subdivided into two categories: market capitalization, and algorithmic risk.

### Market Capitalization

An asset's market capitalization is a common indicator of its volatility. A token with a higher market cap is less likely to experience wild fluctuations in its price due to speculation and macroeconomic events, compared to a token with a lower market cap. We utilize three ranges (denominated in US dollars) to categorize each asset in this regard: less than 50 million, between 50 million and 500 million, and greater than 500 million.

Note that for vaults with multiple underlying assets, the market cap tag will correspond to the asset with the lowest market cap. For instance, if a vault utilizes an LP pair where one asset has $1B market cap and the other has $25M market cap, the asset risk would fall under the "less than 50 Million" category.

![Market capitalization risk tag](https://2226044781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_3DKLtyg_0E-mdery8%2Fuploads%2F5aFD0HWtsTRZhz7EfqER%2FTags-Asset-MC-1.png?alt=media\&token=8567c374-d719-442c-a01c-7cfedd8f6d26)

### Algorithmic Risk

This tag will show up if the vault utilizes an algorithmic token. Algorithmic tokens and stablecoins involve experimental peg-keeping mechanisms and unique layers of risk not found in collateralized or over-collateralized tokens. Such assets are generally more at risk of losing their peg.

![Algorithmic risk tag](https://2226044781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_3DKLtyg_0E-mdery8%2Fuploads%2FeqWAYvt4cE9scIpKTSDb%2FTAGS-Algo-Stable-1.png?alt=media\&token=b111451d-febe-4117-81f6-d7f8bd5c65ed)

Hovering over each tag will display a short tool-tip to explain the tag's significance as shown below.

<figure><img src="https://2226044781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_3DKLtyg_0E-mdery8%2Fuploads%2FtBzwPBs0hFxiahRCjUlx%2Fimage.png?alt=media&amp;token=17ca93a9-a6c4-4390-8b02-4ad7e522293c" alt=""><figcaption><p>Hovering over tags displays tool-tips</p></figcaption></figure>

In addition, the *More Info* page will have the expanded version of each tag near the bottom:

<figure><img src="https://2226044781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_3DKLtyg_0E-mdery8%2Fuploads%2FrcKVgyc4rLuAE8iRZOtI%2Fimage.png?alt=media&amp;token=d8878015-fd32-42d8-8684-885ef7db9472" alt=""><figcaption><p>The <em>More Info</em> page will have the expanded version of each tag near the bottom</p></figcaption></figure>


# Vault Analytics (“More Info”)

Reaper provides custom analytics for users to openly track vault performance.

When you click the ‘More Info’ button on a vault, you will see something like this (but specific to your vault):

<figure><img src="https://2226044781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_3DKLtyg_0E-mdery8%2Fuploads%2FB09jmB4vxHA9BgqahKzn%2F01-more%20info.png?alt=media&amp;token=813b536b-36eb-4358-af8f-6caf19362216" alt=""><figcaption><p>'More Info' window with sections overlayed</p></figcaption></figure>

Let's break this down by section.

### **Section A:** **The Name**

This is the name of the vault as well as a link to the exchange where these LPs are made or assets can be purchased. The link will even fill in the assets for you. In this instance, the link will open up to Velodrome's liquidity management page for creation of LPs. Other vaults may direct you elsewhere.

### **Section B: Your Current Tokens**

This block details information about your current assets in the vault. The first line shows how many LP tokens you currently have deposited in the crypt. The second is the total value of those LP tokens. For most people, that is all you care about and that is fine.

The final three lines are Scully showing his work. Here you can see the price per LP, the number of each token in your LP and their individual values. The contract uses all those numbers to calculate your total vault value.

### **Section C:** Your Future Tokens (Yield)

This section is broken up into three headings.

**Yields & Profit** (depicted above) provides mathematical yield projections based on historical vault performance. If section B is what you currently have, section C is what you will have (based on our APY calculations). Projections are calculated by Day, Week, Month and Year so you can see how powerful compounding is over time.

Yield is calculated on underlying token growth and harvest performance, so may not always match the yield calculated by the external protocol.

Also note that calculations include vault withdrawal fees, which may cause APYs to temporarily spike when large withdrawals occur. These spikes will usually fade after a few additional harvests.

The **Harvests Graph** (shown below) shows the trend in yield data. If the yield projected by the vault seems unlikely, you can check the harvests graph to see if the yield is spiking (possibly due to a recent large withdrawal) or sustained. You can also toggle between APY and Vault Share Price (VSP), although typically APY will be more relevant.

<figure><img src="https://2226044781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_3DKLtyg_0E-mdery8%2Fuploads%2FMKWk1IE6jncNj9DyV87D%2F02-harvest%20graph.png?alt=media&amp;token=31536912-adba-450d-8348-3d67999bdbc6" alt=""><figcaption><p>Harvests Graph</p></figcaption></figure>

Lastly, selecting **Vault Info** (below) shows vault and underlying farm statistics so you can see your share of the vault, and of the underlying farm, as well the age of the vault.

<figure><img src="https://2226044781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_3DKLtyg_0E-mdery8%2Fuploads%2Fm9v7V7CyCNOQRMInD8z1%2F03-vault%20info.png?alt=media&amp;token=c07020df-20d0-4558-a30d-eb9a474cc79a" alt=""><figcaption><p>Vault Info</p></figcaption></figure>

### **Section D: Your Total Profit**

While the last two sections dealt with present and future, this section focuses on the past. Here you can see what you have earned over the lifetime of the vault.

You may notice that in some of your vaults the historical profit can be higher than the amount you have in the vault. Historical profit does not update to reflect when you withdraw from a vault. This field shows ALL of your profit gained from this vault.

### **Section E: Vault Stats**

Here you can see links to [contracts](/crypts/what-is-a-vault#vault-contracts), as well as [vault tags](/crypts/vault-tags).

Of note, some vaults have additional content in this section if it is deemed relevant. For example, multi-strategy vaults include a link to the underlying strategy contracts and allocations (see below). As strategies are included or removed, and allocations change, this information will stay up to date. You can also find [audit reports](/security/audits) for complex vault solutions that have had external auditing.

<figure><img src="https://2226044781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_3DKLtyg_0E-mdery8%2Fuploads%2FuwN0wsvRgvRr1d0w3A5B%2F04-strategies.png?alt=media&amp;token=1361152c-19a7-4a67-a0f5-52493b82fc96" alt=""><figcaption><p>WFTM Multi-Strategy Crypt, strategy contracts and allocations</p></figcaption></figure>

Some vaults may display slightly different information under 'More Info'. As our strategies, analytics, and UI develop, we regularly release new vaults with more refined presentations. If you see something displayed on a vault that you do not understand, please let us know, and we explain it to you, and update our documentation.


# Single Strategy Vaults

Single strategy vaults automatically compound an individual position in an individual protocol on behalf of the user. This may include yield farming in a particular pool on a particular DEx, looping LTV of a single asset on a lending protocol to maximize yield performance, or auto-compounding a single-stake position on a particular protocol.

For security purposes, some single strategy vaults employ a 0.1% withdrawal fee, which is redistributed to vault users. This fee is being phased out in newer vaults. You can read more about it in the Fee Structure or Security sections.

## LPs

On most DExes, users can provide liquidity for trading pairs and stake their LP positions to earn emissions. Users can then regularly harvest those emissions and do with them as they please. Reaper Farm vaults allow users to deposit their LP tokens in exchange for rfTokens. Vault contracts will deposit the LPs to the respective protocol to earn emissions, and compound those emissions back into more LPs on the user’s behalf.

Automatic harvesting occurs whenever it is deemed profitable by the Harvest-Bots (accounting for the value of emissions and gas required to complete all transactions). Depending on network congestion and emissions value, harvesting may occur every few minutes or every few days, but rest assured that Scully is keeping an eye on things.

#### Scully’s additional resources:

You can learn more about auto-compounding in [this article](https://blockbytes.com/2022/06/23/modeling-defi-part-1-compounding/).

## Staking

Some protocols allow users to single-stake assets to earn yield. Reaper Farm allows users to deposit their assets into vaults, which interact directly with respective protocols to stake said assets. Vault contracts will then automatically harvest and compound rewards on the user’s behalf.

Like LP vaults, automatic harvesting occurs whenever it is deemed profitable by the Harvest-Bots (accounting for the value of emissions and gas required to complete all transactions), ranging from every few minutes to every few days.

## Lending

Lending protocols have variable interest rates to manage supply and demand of markets and maintain safe operation. At a minimum, users can deposit assets for lending to earn yield from interest rates. Depending on market conditions, it may be profitable to borrow the same asset and deposit it back into lending, such that the interest rate from borrowing accrues more slowly than the interest rate from the overall lending position. If favourable, this process can be repeated multiple times, and this is called looping. Some protocols even incentivize lending and borrowing, which adds another layer of yield.

The key considerations here are that the borrowed asset is the same as the lending asset, and LTV remains below the liquidation threshold, so the risk of being liquidated is extremely low.

The mathematics to optimize this process while accounting for price movement and emissions can be complicated for individuals to manage. But not for Scully.

Reaper Farm offers vaults that automatically optimize the looping process on behalf of users. Sometimes this means lending only, while other times the vault will leverage the position to optimize yield.

If applicable, harvesting occurs automatically whenever it is deemed profitable by the Harvest-Bots (accounting for the value of emissions and gas required to complete all transactions), ranging from every few minutes to every few days.<br>


# Multi-Strategy Vaults

Multi-strategy vaults are a next-generation technology designed by the Reaper team that automatically redirects and rebalances user funds to a selection of single strategies to maximize yield across the board.

Consider two lending protocols that incentivize borrowing and lending of a particular asset, and for which Reaper provides two separate lending vaults. As users enter and exit vaults and TVLs dilute yield, prices fluctuate, etc., the yield offered by the two respective vaults will continue to fluctuate. If a user enters the most profitable vault today, the other vault might outperform it tomorrow.

Multi-strategy vaults allow the Reaper team to add or remove strategies to capture yield opportunities, and automatically redistribute internal funds to cross-level yield across strategies, maximizing yield of the underlying asset. Multi-strategy vaults are designed with diversification and adaptability in mind, and serve as a one-stop shop for all your asset management needs. These vaults do not utilize a withdrawal fee.

Note that this increases the complexity of the strategy, and exposes funds to a larger number of protocols, so users should research incorporated strategies to ensure they are comfortable with that exposure.

#### Additional resources:

You can learn more about multi-strategy rebalancing in [this article](https://blockbytes.com/2022/08/09/modeling-defi-iv-multi-strategies/).


# Inactive Vaults

Sometimes protocols make changes to their own technology and require migration of funds to new pools. Sometimes protocols shut down entirely. Whatever the case, Reaper will never touch your assets or move funds on your behalf, beyond the automated internal contracts of vaults. If a strategy is no longer supported, the vault will be marked inactive. This means that users will not be able to deposit funds into said vaults, however this does not affect your ability to withdraw your funds. You will always be able to withdraw your funds from inactive vaults.

<figure><img src="https://2226044781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_3DKLtyg_0E-mdery8%2Fuploads%2FXzzncGWaWqHvX4pm0bmx%2Fimage.png?alt=media&amp;token=5d321cf7-2808-49c2-b04a-494899f96cf0" alt=""><figcaption><p>Inactive crypts remain accessible but do not take deposits</p></figcaption></figure>

## Can't find a vault?

Inactive vaults may be removed from the front end. If that is the case, funds remain safe and withdrawals can still be processed via the smart contract.

To do so, search for your wallet address in FTMScan (<https://ftmscan.com/>). Find your vault shares in the Token Holdings dropdown. The token should have a name starting with "rf". Click on it to head to the vault contract. Scroll down and select Contract, then Write Contract, as pictured:

<figure><img src="https://2226044781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_3DKLtyg_0E-mdery8%2Fuploads%2FfqQxqZmv2Dl2gl2rM6Ri%2Fimage.png?alt=media&amp;token=104c7797-bd77-4478-a87b-3cb27d0f5720" alt=""><figcaption><p>Writing to a contract in FTM Scan</p></figcaption></figure>

Find the function named "withdrawAll", click the dropdown, and Write.

This will cost some gas but will withdraw all of your LPs from the vault. You can then go to the relevant DEX and stake or split your LPs as you wish!


# Fee Structure

The Reaper UI has recently been upgraded to display fees. You can hover over the "!" icon on each vault to see deposit, withdrawal, and harvest fees.

<figure><img src="https://2226044781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_3DKLtyg_0E-mdery8%2Fuploads%2FU9RIAxvWXVWVCZpQplxy%2Fimage.png?alt=media&amp;token=54b6626f-af60-4202-a0a5-f17b27376948" alt=""><figcaption><p>Fees displayed in the vault UI</p></figcaption></figure>

## Single-strategy vaults

Single-strategy vaults take a 4.5% fee on the profit earned on each harvest and a 0.1% fee\* on all withdrawals.

* 4.05% is paid to the treasury for maintenance.
* 0.45% of the profit fee is paid to whomever called the Reaper Harvest-Bot function.
* The 0.1% withdrawal fee\* is a security measure and is paid directly back to the vault.

For example, if a single strategy vault has $500,000 worth of assets inside of it, and records a profit of $75 during a harvest, 4.5% of the $75 profit = $3.375 is remitted as fees, while the remaining $71.625 is reinvested on behalf of users.

**\***&#x4E;ote: The 0.1% withdrawal fee is being phased out. All vaults that currently utilise the 0.1% withdrawal fee for security will continue to do so, however all new vaults will incorporate a gated harvest function managed by automated keepers.

Some vaults also have deposit fees but in those cases Reaper.Farm will always display a warning on the Crypt panel.

## Multi-strategy vaults

Multi-strategy vaults take a 10% fee on the profit earned on each harvest. Harvest-calling is whitelisted to automated contracts so there is no allocation of the fee to manual callers. There is no withdrawal fee.

For example, if a multi-strategy vault has $500,000 worth of assets inside of it, and records a profit of $75 during a harvest, 10% of the $75 profit = $7.5 is remitted as fees, while the remaining $67.5 is reinvested on behalf of users.

Multi-strategy vaults do not incorporate strategies with deposit fees.


# How to use Vaults

Now that you know all about Reaper Farm, here is how you can use it to maximize your own compounding interest. Here are the basic steps to enter any vault.

**Step 1:** Acquire relevant tokens (LP, single stake, etc.) from your choice of DEx.

**Step 2:** Deposit relevant tokens (LP, single stake, etc.) into the Reaper vault.

**Step 3:** Relax while Reaper’s Harvest-Bots automatically collect rewards and auto-compound them back into the vault.

**Step 4:** Withdraw your Reaper riches whenever you want.

Note: you can skip step 1 by **zapping-in** to most vaults.

## Zapping

The Reaper team have developed innovative zapper technologies to allow users to enter vaults with any one of the underlying assets and exit into another. Deposit one asset into a vault, and smart contracts will automatically route that asset through the respective exchange and their own smart contracts to produce LPs on your behalf. This means users no longer have to interact with external protocols to make LPs before entering vaults. Users can also withdraw their assets via the zapper to break their LPs and route underlying assets through the exchange to withdraw one type of asset.

For example, a user could zap-in $100 worth of FTM into a FTM-USDC vault, which would route the FTM to produce $100 worth of LPs (less fees and slippage), and deposit those LPs into the vault and start auto-compounding. Should the position grow to a value of $200 worth of LPs, the user could zap-out $200 worth of USDC (less fees and slippage), and the vault will split the LPs and convert the FTM to USDC on the user’s behalf.

## Video Walkthrough

We are developing a video walkthrough of how to use Reaper vaults.

Stay tuned!


# Overview

### Overview

The Reaper engineering team is composed of highly skilled smart-contract developers and front-end developers. We are meticulous in our development practice, and look over every line of code multiple times each before deployment. We take decentralized finance very seriously, and would never release software that we are not 100% sure is safe.

We back this up by putting our own funds into our software alongside yours. We believe wholeheartedly in our ability to deliver bug-free smart contracts, and seek to give you enough high-quality, real-time analytics to see that everything is performing according to our specifications.

We have integrated fail-safes in our contracts to help protect you from 3rd party security failures. If a farm provider decides to exit-scam or is exploited, we can withdraw all funds and return them to the vault so you can remove them from the system without issue. We look over all contracts we integrate to ensure their farms don't have any backdoors, and will alert you of any potential vulnerabilities when we add them to our site.

Our approach in three statements:

1. Be Selective - Only partner with trusted, established protocols.
2. Be Cautious - Do not blindly chase whatever tech or protocol is currently in fashion.
3. Be Thorough - Double, triple, quadruple check your work. Have as many knowledgeable eyes review your code as possible.


# Disclosures

We have secured our contracts tightly against technical attack vectors, but there are still some things you should know before putting your assets in our vaults.

## YearnV1

Reaper v1 was built on Yearn.Finance's battle-tested architecture, which allowed us to start up quickly. This means the original contracts underlying Reaper are exactly the same as Yearn's. Of course, they have since been developed to suit our advanced strategies and integrations.

## Partners

We can design the best vaults in the world but it would not matter if the underlying farm was a scam. We do our best to vet our potential partners to ensure we do not expose Reaper Farm users to unnecessary risks. To this end, we also evaluate the longevity of a partner. We have no interest in integrating protocols that are designed to shut down or fail after one year.

## Strategists

Developers who design new vaults are known as strategists, as they create the strategy contract that will operate inside the vault. Our strategists are committed to the development of secure and functional code. We incentivize this commitment by offering strategists a share of all profits on crypts they have designed. This guarantees that it is in their best interest to produce quality contracts that can stand the test of time.

## Upgradable Strategies

While our vaults are not upgradeable, our strategies use UUPS upgradeable proxies that can make changes behind a 2-day timelock. This timelock is controlled by a multisig managed by the Oath Foundation, with each signer doxed and contracted to perform their duties with the highest standards of security.

Everything we release is reviewed extensively by the Byte Masons, and we strive to get as many high-quality opinions from reputable audit firms as possible. Security is our primary focus when building new systems, so expect the best audits we can afford before we deploy any new contracts.

## Internal Process

The implementation of a new and relatively simple strategy proceeds as follows:

1. Strategist proposes a strategy to the team and it is either approved or denied.
2. Strategist writes the code, adhering to basic guidelines (make sure every function works).
3. A pull request is made and the team conducts asynchronous reviews. This means team members review the code on their own and report findings later.
4. Once the code has been reviewed by four different security researchers it is passed over to our head of security. If he is unsatisfied, he passes it to the CEO.
5. Once everyone is happy, the strategy may be deployed.

For more complicated strategies everything proceeds as above up to step 3:

4\. After asynchronous reviews, the entire team schedules a call to conduct a synchronous review. The code is shared on-screen and everyone goes through the code, line-by-line, together.

5\. Upon the head of security’s approval, the strategy is deployed on Pain.Finance for further production testing.

6\. If there are no problems with the strategy on Pain.Finance, it is moved to the main site. Note that when a strategy is moved to the main site, the crypt stays the same. Only the front-end moved, meaning users do not need to move their funds between Pain.Finance and Reaper Farm because the crypts are the same.

The most complicated strategies, those with entirely novel features, are also subjected to a Certik audit prior to being posted on **Pain.Finance**. We retain Certik on a monthly contract for this express purpose.<br>


# 0.1% Withdrawal Fee

Most single strategy vaults incorporate a 0.1% withdrawal fee that is redistributed to vault users.

Without this fee, it is theoretically possible for an individual to deposit a large quantity of underlying assets, call a vault harvest, and exit the vault with a large share of the vault's rewards. One iteration may not be highly profitable, but consistent, automated attacks can compound, and take yield from well-intentioned users.

Incorporating the fee deters such behaviour, because entering and exiting a crypt with large capital  for the purpose of harvesting would result in a net loss.

The community requested that an alternative solution be developed, so that they would not also have to face a fee when exiting vaults.

Therefore, new vaults utilise a gated harvest function that is automated by keepers. These new vaults no longer utilise a withdrawal fee, but anonymous users can no longer earn harvest-caller rewards and fee distributions.

The Reaper UI has recently been upgraded to display fees. You can hover over the "!" icon on each vault to see deposit, withdrawal, and harvest fees.

<figure><img src="https://2226044781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_3DKLtyg_0E-mdery8%2Fuploads%2F7tYYBOXE8JC8m8pYpA4K%2Fimage.png?alt=media&amp;token=44602e0e-d896-4eb3-8b54-58095df6e0e1" alt=""><figcaption><p>Fees displayed in the vault UI</p></figcaption></figure>


# Reaper Alpha

Reaper Alpha is the home for novel Reaper Farm strategies. Strategies on Alpha use code that is new to DeFi or uses existing code in unique ways. In order to fully test these strategies, they must undergo production testing. That means they have to actually see real use, ergo Alpha.

To make sure users do not deposit too much into these unique vaults we have implemented deposit caps. These deposit caps grow over the lifetime of the vault and are removed entirely when the vault is proven and moved to the main site. We do this as an additional way to mitigate risk when new vaults are introduced.

Alpha is a front-end implementation. This means that when a vault is migrated from Alpha to Reaper Main, users are not required to migrate their funds. The back-end vault remains the same.

You can access Reaper Alpha by clicking this icon in the top right corner of the Reaper site:

<figure><img src="https://2226044781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_3DKLtyg_0E-mdery8%2Fuploads%2FsSP3BV75NxNXzQc97yVu%2Fimage.png?alt=media&amp;token=69b9cbe0-853f-48d1-ba74-e6233b88122d" alt=""><figcaption></figcaption></figure>


# Audits

Beyond the harsh internal scrutiny to which we subject all of our codes, we retain Certik on a monthly contract for the express purpose of auditing our unique code bases. When deemed necessary, we also reach out to external auditing firms to provide additional reassurance.

## 28 May 2021

In developing Reaper Farm, we implemented changes to Yearn's contracts. We added state for profit/loss tracking, support for tokens and deposits that require tax, and deposit caps. These additions were all audited by Solidity.Finance.

They found no vulnerabilities. You can find their report [**here**](https://solidity.finance/audits/ReaperFarm/).

## 08 Nov 2022

Our multi-strategy vaults have undergone an extensive Certik audit with **no critical risks**. All identified risks have been resolved or have been acknowledged and are being actively managed by our team. The full report is available below.

{% file src="/files/naL08W7dpwAGHfekVoth" %}


# Bugs

Reaper Farm has an active [Immunefi Bug Bounty program](https://immunefi.com/bounty/reaperfarm/). We will continue to update and develop the program moving forwards.

If you notice any bugs while using our products, please let us know!


# Overview

Reaper Farm provides advanced technological infrastructure for a number of protocols and businesses operating broadly across DeFi.

The Reaper team is always open to developing infrastructure and integrations with and for responsible businesses. **Feel free to contact the Byte Masons** if you would like to discuss how Reaper can build a product to suit your needs or integrate with your business structure.

This may include vaults for your assets, or underlying infrastructure for your protocol.


# Digit (Reliquary)

The Byte Masons created Reliquary as a DeFi-native solution to the problems introduced by current incentive systems. Reliquary seeks to find a middle-ground between bonding and liquidity mining, with the protocol-level benefits of the former and elasticity of the latter. The result resembles a liquid floating-rate bond that increases in convexity over time, aligning the protocol with its liquidity providers better than ever before. It is an open-ended, audited platform with a plugin system and suite of tools that will supercharge any incentive program.

In Reliquary, rewards are distributed across Maturity Tranches, which represent a length of time for which liquidity must be provided. This is done in a non-dilutive fashion, with the same amount of rewards always being emitted to the pool no matter how many users are in any tranche. That way, the longer you remain in a Relic, the more incentives you will receive.

This maturity system allows developers to program desired holding patterns into each pool, giving them unparalleled control over their incentive structures. Users are issued a custom NFT for use in external protocols: they can lock it, lend it, or sell it on their favorite marketplace to earn a premium on their time spent in the pool. However, locking is not required. Users can withdraw at any time. Though with built in airdrop mechanics, multi-asset rewards, and maturity bonuses, why would they ever want to?

Digit is the protocol-level implementation of Reliquary, that will showcase Reliquary technology while housing Reaper vaults in underlying strategies.

#### Additional resources:

You can learn more about Reliquary in [this article](https://0xbebis.medium.com/defis-new-yield-primitive-52ec6ecfe2af).


# Granary

The Granary is a decentralized, user-driven borrowing and lending liquidity market that is also maintained by the Byte Masons. For this reason, Reaper Farm has first-mover advantage to create highly competitive lending vaults for users to single-stake assets (routed via Granary) and earn rewards, compounded back to the underlying assets.

#### Additional resources:

You can learn more about The Granary in [their documents](https://docs.granary.finance/).<br>


# Ethos Reserve

Ethos Reserve is a decentralized borrowing protocol that allows users to draw interest-free loans against assets used as collateral, paid in Ethos Reserve Notes (ERN).

In addition to the collateral, loans are secured by a Stability Pool containing $ERN and by fellow borrowers collectively acting as guarantors of last resort.

Ethos documentation is currently under development and will be linked here when it is live.

Ethos Reserve is [fully audited](https://docsend.com/view/szchhyvbcbiv3ti9) by Certik, with additional audits and bounties currently live.

### **Managed Collateralized Debt Position (CDP) Vaults** <a href="#id-9541" id="id-9541"></a>

Ethos Reserve is designed to deploy its underlying assets to DeFi yield strategies, as well as manage their risk and liquidity. Users can enjoy highly efficient $ERN loans while deposited assets are put to work in the lowest-risk environment possible. Yield generated by the protocol is directed back to $ERN stakers, who also benefit from liquidation income. This system allows the protocol to take advantage of Ethereum’s low-risk interest rates, resulting in a DeFi system that has the network effects of a liquid staking derivative with highly efficient lending and stable-asset yields built in.

### **Multi-Collateral Debt Management** <a href="#id-0a82" id="id-0a82"></a>

Ethos Reserve manages debt with highly complex data structures that allow the protocol to isolate and liquidate multiple collateral types more efficiently than competitors. Assets can be redeemed directly from the protocol, ensuring that users have a right to their assets no matter the state of market liquidity. This combination of features allows for extremely high LTV ratios and additional yield for users. It also removes the need for market-making, as the protocol will always swap under-peg tokens for collateral.

### **Self-Contained, 0-interest lending** <a href="#e36e" id="e36e"></a>

Ethos Reserve issues interest-free loans denominated in $ERN. Instead of paying interest, users pay a small issuance and redemption fee, which is directed to $bOATH (Bonded $OATH) stakers. This means that users do not need to worry about micro-managing their position and the protocol does not need to worry about bad debt piling up. Issuance and redemption fees also allow $bOATH stakers to derive value from arbitrage and $ERN volatility.

<figure><img src="https://miro.medium.com/max/700/1*9STTydfNMqtsT09pNv7rXg.png" alt=""><figcaption><p>Ethos Reserve’s Managed CDP System</p></figcaption></figure>

### bOATH <a href="#id-4735" id="id-4735"></a>

**Bonded Oath**, or $bOATH, is both OATH and ETH, backed by a Balancer-powered 80/20 liquidity pool. $bOATH earns platform fees and benefits from trading fees generated by Ethos’ incentive buyback and distribution strategies. These strategies create a constant source of demand for $OATH as it buys it back to fund yield.

$bOATH benefits from any Balancer liquidity incentives, trading fees, and Ethos Reserve's issuance and redemption fees.

#### Additional resources:

You can learn more about Ethos Reserve in [this article](https://medium.com/byte-masons/introducing-ethos-reserve-5f08fa6af52a).


# Balancer Technology

## Boosted Pools

Boosted Pools bring the best of both worlds to Liquidity Providers and Swappers. Swappers get access to deep liquidity with near-parity exchange rates while Liquidity Providers have their liquidity positions sent to Reaper crypts to earn additional yield instead of sitting idly in a pool.

These versions of pools don't directly hold the assets themselves, but rather hold the pool tokens of nested Linear Pools, which, for the Reaper Farm, maintain proper balances of assets and their rf-asset counterparts.

You can find our Boosted Pools integration present in some Balancer and BeethovenX pools.

#### Additional resources:

You can learn more about BeethovenX in [their documents](https://docs.beets.fi/).

You can learn more about boosted pools in [this article](https://blockbytes.com/2022/10/20/boosted-pools/).


# Legal Disclaimer

## Information Published is Not Advice

The information provided on Reaper Farm does not constitute investment advice, financial advice, trading advice, or any other sort of advice, and you should not treat any of Reaper Farm's content as such. Our team provides Reaper Farm as a service to the public, and is not responsible for, and expressly disclaims all liability for, damages of any kind arising out of use, reference to, or reliance on any information contained within Reaper Farm. While the information contained within Reaper Farm is periodically updated, no guarantee is given that the information provided in Reaper Farm is correct, complete, and up-to-date.

## Usage Risks

Reaper Farm is not responsible for any losses, damages, or claims arising from events falling within the scope of events such as, but not limited to: mistakes made by the user (e.g. payments sent to wrong addresses), software problems of Reaper Farm or any related software or service (e.g. malware or unsafe cryptographic libraries), technical failures (e.g. hardware wallets malfunction), security problems experienced by the user (e.g. unauthorized access to wallets), actions or inactions of third parties (e.g. bankruptcy of service providers, information security attacks on service providers, and fraud conducted by third parties).

## Investment Risks

Investment in cryptocurrencies can lead to loss of money and prices having large range fluctuations. The information published on Reaper Farm cannot guarantee no money loss. Reaper Farm users are responsible for understanding these risks, doing their own due diligence, and making their own decisions on how to interface with Reaper Farm.

## Compliance with Tax Obligations

The users of Reaper Farm are solely responsible to determine what, if any, taxes apply to their cryptocurrency holdings. The owners of, or contributors to, Reaper Farm are NOT responsible for determining the taxes that apply to user transactions.

## No Warranties

Reaper Farm is provided on an "as is" basis without any warranties of any kind regarding Reaper Farm and/or any content, data, materials and/or services provided on Reaper Farm. Reaper Farm functionality is not guaranteed and could be disabled fully or in part without prior notice.

## Security

Security audits do not eliminate risks completely. Reaper Farm is not guaranteed to be secure or free from bugs or viruses.

## Limitation of Liability

Unless otherwise required by law, in no event shall the owners of, or contributors to, Reaper Farm be liable for any damages of any kind, including, but not limited to, loss of use, loss of profits, or loss of data arising out of or in any way connected with the use of Reaper Farm.

## Arbitration

Users of Reaper Farm agree to arbitrate any dispute arising from or in connection with Reaper Farm or this disclaimer, except for disputes related to copyrights, logos, trademarks, trade names, trade secrets or patents.


# Reaper SDK

#### This documentation is a work in progress.


# Utilities

### Constants

#### `BigGas`

Following up your function arguments with BigGas to set a high gas limit and price so that your transactions are more likely to execute. You can change these values within the ReaperSDK.js file.

`reaper.BigGas === { gasPrice: 100000000000, gasLimit: 5000000 }`

For example:

```javascript
await wrappedFantom.transfer(momAddress, 1000, reaper.BigGas);
```

#### `Addresses.json`

Addresses.json contains the addresses of many popular contracts on the Fantom network, and it's easy to add more. Simply import it from the directory's root with a require statement and use dot notation to reference the addresses within. The object is separated by token addresses, testnet contract addresses, and mainnet contract addresses.

Import them each with the following:

`const { tokens, testnet, mainnet } = require("../Addresses.json");`

```javascript
const { tokens, testnet, mainnet } = require("../Addresses.json");

async function main() {
  
  console.log(tokens.usdc);
  console.log(tokens.wftm);
  console.log(testnet.router);
  console.log(mainnet.spooky.masterChef);

}

> 0x04068DA6C83AFCFA0e13ba15A6696662335D5B75
> 0x21be370D5312f44cB42ce377BC9b8a0cEF1A4C83
> 0xcCAFCf876caB8f9542d6972f87B5D62e1182767d
> 0x2b2929E785374c651a81A63878Ab22742656DcDd
```

### Contract Instantiation

You can create a contract interface and attach it to an address in a single function call with our createContract function. Just make sure you've already compiled your contracts with Hardhat. Refer to the contract title as a string for the first argument and use the target address as the second like so:

`reaper.createContract(contractTitle: string, contractAddress: string);`

```javascript
  let usdc = await reaper.createContract("ERC20", tokens.usdc);
  let usdcSupply = await usdc.totalSupply();
  console.log(usdcSupply);

  let spookyChef = await reaper.createContract("MasterChef", mainnet.spooky.masterChef);
  let farmCount = await spookyChef.poolLength();
  console.log(farmCount);

> BigNumber { _hex: '0x343b58ee24c1', _isBigNumber: true }
> BigNumber { _hex: '0x0911258c64', _isBigNumber: true }
> BigNumber { _hex: '0xc100e8020d8478e62c7e79', _isBigNumber: true }
```

### Decimal Formatting

#### Formatting human-readable inputs with `reaper.parseToken()`

You can turn floating point inputs of any type into a blockchain-readable BigNumber value in parts-per notation with 18 decimal places. An optional tokenAddress argument will automatically format your input using the correct amount of decimal places, such as 6 for USDC or 8 for BTC.

`reaper.parseToken(amount:string or number, { tokenAddress: string });`

```javascript
  let usdcInput = await reaper.parseToken("100", tokens.usdc);
  console.log(usdcInput);
  console.log(usdcInput.toString());
  
  let wbtcInput = await reaper.parseToken("100", tokens.wbtc);
  console.log(wbtcInput);
  console.log(wbtcInput.toString());
  
  let wftmInput = await reaper.parseToken("100", tokens.wftm);
  console.log(wftmInput);
  console.log(wftmInput.toString());

> BigNumber { _hex: '0x05f5e100', _isBigNumber: true }
> 100000000

> BigNumber { _hex: '0x02540be400', _isBigNumber: true }
> 10000000000

> BigNumber { _hex: '0x056bc75e2d63100000', _isBigNumber: true }
> 100000000000000000000
```

#### Formatting big number outputs with `reaper.formatToken()`

Using the format() function, you can turn any bigNumber-ish value into a human readable fixed-point integer. Using the optional tokenAddress input will allow the function to automatically determine the token's decimals and adjust accordingly. See an example of this below - the function automatically adjusts to USDC's 6 decimals and BTC's 8 decimals.

`reaper.formatToken(amount:BigNumber, { tokenAddress: string });`

```javascript
  let usdc = await reaper.createContract("ERC20", tokens.usdc);
  let usdcSupply = await usdc.totalSupply();
  console.log(await reaper.formatToken(usdcSupply, tokens.usdc));
  
  let wbtc = await reaper.createContract("ERC20", tokens.wbtc);
  let wbtcSupply = await wbtc.totalSupply();
  console.log(await reaper.formatToken(wbtcSupply, tokens.wbtc));
  
  let wftm = await reaper.createContract("ERC20", tokens.wftm);
  let wftmSupply = await wftm.totalSupply();
  console.log(await reaper.formatToken(wftmSupply, tokens.wftm));
  
> 58931849.963579

> 398.79588332

> 233007968.40776092
```

### Pausing Execution

Due to its unpredictable nature, blockchain development can be a tricky beast. On Fantom, you may find your transactions failing due to being sent too soon after the preceding transaction. You may also want to manage transaction timing off-chain when running scripts or simulations. You can handle all of this with Reaper's sleep function.

`reaper.sleep(miliseconds:uint)`

```javascript
  let wftm = await reaper.createContract("ERC20", tokens.wftm);
  sleep(5000) //5 second pause to wait for the contract to be deployed
  await wftm.deposit({ value: ethers.utils.parseEther("1") });
```

### Getting a timestamp

Getting the block.timestamp value in Javascript can be kind of tricky, so Reaper took care of that for you. It's so simple I'm not even going to include an example >:^)

`reaper.getTimestamp() => timestamp:uint`


# Test Tokens

Deploy and interact with tokens easily using simple function calls.

### Creating a Test Token

Test tokens are regular ERC20s with a public function that allows the owner to mint them at will.

`reaper.deployTestToken(name: string, symbol: string) => (address:string)`

Example of a Test Token deployment utilizing the BigGas constant to ensure execution:

```javascript
const testToken = await reaper.deployTestToken("Reaper Test Token", "RTT", reaper.BigGas);
console.log("Test Token Address: " +testToken);

> Test Token Address: 0xB19b478543D828131edCdCe33891d09C80e09341
```

{% hint style="info" %}
&#x20;Single-owner mint functions are not recommended for production, as they are highly centralized and generally insecure.
{% endhint %}

### Viewing Your Token's Metadata

Return an object which contains all relevant metadata for your test token or any other ERC20.

`reaper.getTokenMetadata(tokenAddress: string) =>` \
`({`\
&#x20; `name:string,`\
&#x20; `symbol:string,`\
&#x20; `decimals: uint,`\
&#x20; `totalSupply: uint,`\
&#x20; `owner: string`\
`})`

Fetching metadata for the above test token deployment:

```javascript
const metadata = await reaper.getTokenMetadata(testToken);
console.log("Token Name: " +metadata.name);
console.log("Token Supply: " +metadata.totalSupply);

> Token Name: Reaper Test Token
> Token Supply: 0
```

### Minting Test Tokens

ReaperSDK's built-in test token allows the owner to mint infinitely to any address.

`reaper.mintTestToken(tokenAddress: string, userAddress: string, amount: uint) =>`\
`(userBalance:BigNumber)`

Minting to multiple addresses with Reaper's parseToken function and viewing their updated balances:

```javascript
const user1 = "0x8B4441E79151e3fC5264733A3C5da4fF8EAc16c1";
const user2 = "0x66e17197A8e0BE5D3161337Bf881c2364d0c56E8";

let user1Balance = await reaper.mintTestToken(testToken, user1, await reaper.parseToken(100, testToken));
let user2Balance = await reaper.mintTestToken(testToken, user2, await reaper.parseToken(10000, testToken));
console.log("User 1 Balance: " +user1Balance);
console.log("User 2 Balance: " +user2Balance);
  
> User 1 Balance: 100
> User 2 Balance: 10000
```

### Viewing a User's Token Balances

Check any user's Fantom or ERC20 balance with simple inputs.

`reaper.getUserBalance(userAddress:string, [tokenAddress:string]) =>`\
`(userBalance:BigNumber)`

```javascript
  const user1 = "0x8B4441E79151e3fC5264733A3C5da4fF8EAc16c1";

  await reaper.mintTestToken(testToken, user1, await reaper.Ether(450, testToken));

  let fantomBalance = await reaper.getUserBalance(user1);
  let tokenBalance = await reaper.getUserBalance(user1, testToken);
  
  console.log("User One Fantom Balance: " +fantomBalance);
  console.log("User Two Test Token Balance: " +tokenBalance);
  
  > User One Fantom Balance: 102.85817804062937
  > User Two Test Token Balance: 450
```

### Approving Tokens

We took the thinking out of approvals with a simple maximum approval for any token input array. The second input can be a single address or an array of addresses - single addresses will be formatted into an array of length 1.

`reaper.approveMax(spenderAddress:string, tokenAddresses:string[ ]) => "success"`

{% hint style="info" %}
Only use maximum approvals for contracts you trust.
{% endhint %}


# 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.

{% hint style="info" %}
Inserting pauses with `sleep()` after complex transactions  will ensure all your contract interactions have finished execution before you try to interact with them.
{% endhint %}

{% hint style="info" %}
Using `.toString()` makes it easy to to read bigNumber return values in the console
{% endhint %}

```javascript

  const testToken = await reaper.deployTestToken("Reaper.Farm", "R3PR", reaper.BigGas);
  reaper.sleep(5000);

  await reaper.mintTestToken(testToken.address, self, await reaper.parseToken(100000));

  let chef = await reaper.deployMasterChef(self, ethers.utils.parseEther("0.01"), 3, reaper.BigGas);
  console.log(chef.address);
  reaper.sleep(15000);

  await reaper.addFarm(chef.address, testToken.address, 500, reaper.BigGas);
  reaper.sleep(5000);

  await reaper.depositToFarm(chef.address, 0, await reaper.parseToken(500));
  
  let userInfo = await reaper.getUserInfo(chef.address, 0, self);

  console.log({
    "amount": userInfo.amount.toString(),
    "rewardDebt": userInfo.rewardDebt.toString()
  });
  
> { amount: '500000000000000000000', rewardDebt: '0' }
```

### 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.&#x20;

`reaper.getPoolInfo(chefAddress:string, pid:uint) => (poolInfo:object)`

```javascript
  let poolInfo = await reaper.getPoolInfo(chef.address, 0);
  console.log({
    "lpToken": poolInfo.lpToken,
    "allocPoint": poolInfo.allocPoint.toString(),
    "lastRewardTime": poolInfo.lastRewardTime.toString(),
    "accCommPerShare": poolInfo.accCommPerShare.toString()
  });
  
  {
    lpToken: '0xE7411d7F74ea6ff4cF2658eb42232d34aEe9987D',
    allocPoint: '500',
    lastRewardTime: '1627374989',
    accCommPerShare: '0'
  }
```

###


# Uniswap Utilities

### Create your trading route

Pass your input and output tokens to createRoute and it will return an array you can pass into a swap.

`reaper.createRoute(tokenInput:string, tokenOutput:string) => (route:array)`

### Swap

Execute a swap on any Uniswap V2 router

`reaper.swap(routerAddress:string, tokenInput:string, tokenOutput:string, toAddress:string, amountIn:uint, slippage:uint%)`\
`=> (transactionReceipt:object)`

### Add Liquidity

Add Liquidity to a Uniswap V2 pool.

`reaper.addLiquidity(exchangeAddress:string, tokenOne:string, tokenTwo:string,) => (transactionReceipt:object)`

### Retrieve a pair address

Retrieve an existing LP pair address. If the address doesn't exist, it will create one.

`reaper.getPairAddress(factoryAddress:string, tokenOne:string, tokenTwo:string) => (lpAddress:string)`


