yearn / zaps

Repository for v2 Vaults Zaps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Yearn Zaps

What you'll find here

  • Useful Contracts to interact with the Yearn Protocol Smart Contracts (contracts/)

  • Interfaces for some of the most used DeFi protocols on ethereum mainnet. (interfaces/)

  • Sample test suite that runs on mainnet fork. (tests/)

This mix is configured for use with Ganache on a forked mainnet.

How does it work for the User

Let's say Alice holds 100 DAI and wants to start earning yield % on them.

For this Alice needs to DAI.approve(zap.address, 100).

Then Alice will call the Zap Contract e.g Zap.deposit(100).

Vault will then transfer 100 DAI from Alice to itself, and mint Alice the corresponding shares.

Alice can then redeem those shares using Vault.withdrawAll() for the corresponding DAI balance (exchanged at Vault.pricePerShare()).

Installation and Setup

  1. Install Brownie & Ganache-CLI, if you haven't already.

  2. Sign up for Infura and generate an API key. Store it in the WEB3_INFURA_PROJECT_ID environment variable.

export WEB3_INFURA_PROJECT_ID=YourProjectID
  1. Sign up for Etherscan and generate an API key. This is required for fetching source codes of the mainnet contracts we will be interacting with. Store the API key in the ETHERSCAN_TOKEN environment variable.
export ETHERSCAN_TOKEN=YourApiToken
  1. Download the mix.
brownie bake yearn-strategy

Basic Use

TODO: steps for Common Zap usage

Testing

To run the tests:

brownie test

The example tests provided in this mix start by deploying and approving your Zap.sol contract. This ensures that the loan executes successfully without any custom logic. Once you have built your own logic, you should edit tests/ and remove this initial funding logic.

See the Brownie documentation for more detailed information on testing your project.

Debugging Failed Transactions

Use the --interactive flag to open a console immediately after each failing test:

brownie test --interactive

Within the console, transaction data is available in the history container:

>>> history
[<Transaction '0x50f41e2a3c3f44e5d57ae294a8f872f7b97de0cb79b2a4f43cf9f2b6bac61fb4'>,
 <Transaction '0xb05a87885790b579982983e7079d811c1e269b2c678d99ecb0a3a5104a666138'>]

Examine the TransactionReceipt for the failed test to determine what went wrong. For example, to view a traceback:

>>> tx = history[-1]
>>> tx.traceback()

To view a tree map of how the transaction executed:

>>> tx.call_trace()

See the Brownie documentation for more detailed information on debugging failed transactions.

Known issues

No access to archive state errors

If you are using Ganache to fork a network, then you may have issues with the blockchain archive state every 30 minutes. This is due to your node provider (i.e. Infura) only allowing free users access to 30 minutes of archive state. To solve this, upgrade to a paid plan, or simply restart your ganache instance and redeploy your contracts.

Resources

About

Repository for v2 Vaults Zaps

License:GNU Affero General Public License v3.0


Languages

Language:Solidity 74.4%Language:Python 25.5%Language:Shell 0.0%Language:JavaScript 0.0%