Git Product home page Git Product logo

generic4626's Introduction

Tokenized Strategy Mix for Yearn V3 strategies

This repo will allow you to write, test and deploy V3 "Tokenized Strategies" using Foundry.

You will only need to override the three functions in Strategy.sol of _deployFunds, _freeFunds and _harvestAndReport. With the option to also override _tend, _tendTrigger, availableDepositLimit, availableWithdrawLimit and _emegencyWithdraw if desired.

For a more complete overview of how the Tokenized Strategies work please visit the TokenizedStrategy Repo.

How to start

Requirements

First you will need to install Foundry. NOTE: If you are on a windows machine it is recommended to use WSL

Fork this repository

git clone --recursive https://github.com/user/tokenized-strategy-foundry-mix

cd tokenized-strategy-foundry-mix

yarn

Set your environment Variables

Sign up for Infura and generate an API key and copy your RPC url. Store it in the ETH_RPC_URL environment variable. NOTE: you can use other services.

Use .env file

  1. Make a copy of .env.example
  2. Add the values for ETH_RPC_URL, ETHERSCAN_API_KEY and other example vars NOTE: If you set up a global environment variable, that will take precedence.

Build the project

make build

Run tests

make test

Strategy Writing

For a complete guide to creating a Tokenized Strategy please visit: https://docs.yearn.fi/developers/v3/strategy_writing_guide

Testing

Due to the nature of the BaseStrategy utilizing an external contract for the majority of its logic, the default interface for any tokenized strategy will not allow proper testing of all functions. Testing of your Strategy should utilize the pre-built IStrategyInterface to cast any deployed strategy through for testing, as seen in the Setup example. You can add any external functions that you add for your specific strategy to this interface to be able to test all functions with one variable.

Example:

Strategy _strategy = new Strategy(asset, name);
IStrategyInterface strategy =  IStrategyInterface(address(_strategy));

Due to the permissionless nature of the tokenized Strategies, all tests are written without integration with any meta vault funding it. While those tests can be added, all V3 vaults utilize the ERC-4626 standard for deposit/withdraw and accounting, so they can be plugged in easily to any number of different vaults with the same asset.

Tests run in fork environment, you need to complete the full installation and setup to be able to run these commands.

make test

Run tests with traces (very useful)

make trace

Run specific test contract (e.g. test/StrategyOperation.t.sol)

make test-contract contract=StrategyOperationsTest

Run specific test contract with traces (e.g. test/StrategyOperation.t.sol)

make trace-contract contract=StrategyOperationsTest

See here for some tips on testing Testing Tips

When testing on chains other than mainnet you will need to make sure a valid CHAIN_RPC_URL for that chain is set in your .env and that chain's specific api key is set for ETHERSCAN_API_KEY. You will then need to simply adjust the variable that RPC_URL is set to in the Makefile to match your chain.

To update to a new API version of the TokenizeStrategy you will need to simply remove and reinstall the dependency.

Deployment

Contract Verification

Once the Strategy is fully deployed and verified, you will need to verify the TokenizedStrategy functions. To do this, navigate to the /#code page on Etherscan.

  1. Click on the More Options drop-down menu
  2. Click "is this a proxy?"
  3. Click the "Verify" button
  4. Click "Save"

This should add all of the external TokenizedStrategy functions to the contract interface on Etherscan.

See the ApeWorx documentation and GitHub for more information.

CI

This repo uses GitHub Actions for CI. There are three workflows: lint, test and slither for static analysis.

To enable test workflow you need to add ETHERSCAN_API_KEY and ETH_RPC_URL secrets to your repo. For more info see GitHub Actions docs.

If the slither finds some issues that you want to suppress, before the issue add comment: //slither-disable-next-line DETECTOR_NAME. For more info about detectors see Slither docs.

generic4626's People

Contributors

schlagonia avatar spalen0 avatar saltyfacu avatar mergd avatar poolpitako avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.