Skip to content

BarnBridge/BarnBridge-YieldFarmContinuous

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BarnBridge YieldFarm-Continuous

Implements single and multi-token rewards pools with continuous rewards

Any questions? Please contact us on Discord or read our Developer Guides for more information.

Contracts

single-reward-token/PoolSingle.sol

Allows users to deposit, withdraw, claim, and withdrawAndClaim from the single-token reward pools

single-reward-token/PoolFactorySingle.sol

Used to Deploy single-token rewards pools

single-reward-token/GovernedSingle.sol

Allows Owner to set reward source address and reward rates per second

multi-reward-token/PoolMulti.sol

Allows users to deposit, withdraw, claim, and withdrawAndClaim from the multi-token reward pools

multi-reward-token/PoolFactoryMulti.sol

Used to Deploy multi-token rewards pools

multi-reward-token/GovernedMulti.sol

Allows Owner to approve new reward tokens, set the reward source address and reward rates per second

Smart Contract Architecture

Overview

Junior Pool

Check out more detailed smart contract Slither graphs with all the dependencies: YieldFarm-Continuous Slither Graphs.

Initial Setup

Install NVM and the latest version of NodeJS 12.x

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash 
# Restart terminal and/or run commands given at the end of the installation script
nvm install 12
nvm use 12

Use Git to pull down the BarnBridge-SmartYieldBonds repository from GitHub

git clone https://github.com/BarnBridge/BarnBridge-DAO.git
cd BarnBridge-YieldFarming

Updating the config.ts file

Create an API key with a Provider such as Infura to deploy to Ethereum Public Testnet. In this guide, we are using Kovan.

  1. Navigate to Infura.io and create an account
  2. Log in and select "Get started and create your first project to access the Ethereum network"
  3. Create a project and name it appropriately; switch the Network to Kovan
  4. Copy the URL from the settings page and paste it into the section labeled PROVIDER in the .env file

Create an API key with Etherscan

  1. Navigate to EtherScan and create an account
  2. Log in and navigate to MyAPIKey
  3. Use the Add button to create an API key, and paste it into the section labeled ETHERSCAN in the .env file

Update the .env file with your test wallet information

  1. Finally, insert the mnemonic phrase for your testing wallet. You can use a MetaMask instance, and switch the network to Kovan on the upper right. DO NOT USE YOUR PERSONAL METAMASK SEED PHRASE; USE A DIFFERENT BROWSER WITH AN INDEPENDENT METAMASK INSTALLATION
  2. You'll need some Kovan-ETH (it is free) in order to pay the gas costs of deploying the contracts on the TestNet; you can use your GitHub account to authenticate to the KovanFaucet and receive 2 Kovan-ETH for free every 24 hours

Installing

Install NodeJS dependencies which include HardHat

npm install

Compile the contracts

npm run compile

Running Tests

npm run test

Note: The result of tests is readily available here.

Running Code Coverage Tests

npm run coverage

Deploying to Kovan

npm run deploy-from-env

Use additional scripts to change setup parameters and query functions

With the addresses given by the previous deployment, you can use the calculate-next-address.ts, calculate-rate.ts, and query-contracts.ts scripts to gather data, and use the setup.ts script to update parameters.

Audits

Deployed contracts

Mainnet

PoolFactory deployed at: 0x2e93403C675Ccb9C564edf2dC6001233d0650582
SY cUSDC pool deployed at: 0x68af34129755091e22f91899ceac48657e5a5062

Known issues

Pool reactivation

Severity: low

After a pool has exhausted its allowance on the rewardSource, it will not attempt to pull any more tokens.

The problem with the above is that lastSoftPullTs is not updated anymore due to 0 allowance.

If, at a later time, the pool is given more allowance on the rewardSource, it will calculate the amount to pull as if it was never stopped which will trigger it to pull tokens for the whole period it was paused at the same rate.

The following actions would act as a workaround for the above issue:

  1. set the allowance to a very small number like 1
  2. trigger a softPullReward() -- this would effectively pull only the allowance given and update the lastSoftPullTs
  3. set the allowance to the desired value

Discussion

For any concerns with the platform, open an issue on GitHub or visit us on Discord to discuss. For security concerns, please email [email protected].

Copyright 2021 BarnBridge DAO

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published