{"id":15448431,"url":"https://github.com/vasa-develop/yva3crv","last_synced_at":"2025-10-28T16:15:05.101Z","repository":{"id":99739349,"uuid":"334504831","full_name":"vasa-develop/yva3CRV","owner":"vasa-develop","description":null,"archived":false,"fork":false,"pushed_at":"2021-01-30T20:27:50.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-29T05:56:43.238Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vasa-develop.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-30T20:27:46.000Z","updated_at":"2021-01-30T22:35:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"b102e065-571a-461c-a8b4-8c9e24a13f67","html_url":"https://github.com/vasa-develop/yva3CRV","commit_stats":{"total_commits":1,"total_committers":1,"mean_commits":1.0,"dds":0.0,"last_synced_commit":"1022b7b746cd29d5d1075fb364c5fe3b26f12478"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":"yearn/brownie-strategy-mix","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vasa-develop%2Fyva3CRV","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vasa-develop%2Fyva3CRV/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vasa-develop%2Fyva3CRV/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vasa-develop%2Fyva3CRV/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vasa-develop","download_url":"https://codeload.github.com/vasa-develop/yva3CRV/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239903622,"owners_count":19716123,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T20:24:19.006Z","updated_at":"2025-10-28T16:15:04.993Z","avatar_url":"https://github.com/vasa-develop.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Yearn Strategy Brownie Mix\n\n## What you'll find here\n\n- Basic Solidity Smart Contract for creating your own Yearn Strategy ([`contracts/Strategy.sol`](contracts/Strategy.sol))\n\n- Interfaces for some of the most used DeFi protocols on ethereum mainnet. ([`interfaces/`](`interfaces/`))\n\n- Sample test suite that runs on mainnet fork. ([`tests/`](tests))\n\nThis mix is configured for use with [Ganache](https://github.com/trufflesuite/ganache-cli) on a [forked mainnet](https://eth-brownie.readthedocs.io/en/stable/network-management.html#using-a-forked-development-network).\n\n## How does it work for the User\n\nLet's say Alice holds 100 DAI and wants to start earning yield % on them.\n\nFor this Alice needs to `DAI.approve(vault.address, 100)`.\n\nThen Alice will call `Vault.deposit(100)`.\n\nVault will then transfer 100 DAI from Alice to itself, and mint Alice the corresponding shares.\n\nAlice can then redeem those shares using `Vault.withdrawAll()` for the corresponding DAI balance (exchanged at `Vault.pricePerShare()`).\n\n## Installation and Setup\n\n1. [Install Brownie](https://eth-brownie.readthedocs.io/en/stable/install.html) \u0026 [Ganache-CLI](https://github.com/trufflesuite/ganache-cli), if you haven't already.\n\n2. Sign up for [Infura](https://infura.io/) and generate an API key. Store it in the `WEB3_INFURA_PROJECT_ID` environment variable.\n\n```bash\nexport WEB3_INFURA_PROJECT_ID=YourProjectID\n```\n\n3. Sign up for [Etherscan](www.etherscan.io) 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.\n\n```bash\nexport ETHERSCAN_TOKEN=YourApiToken\n```\n\n4. Download the mix.\n\n```bash\nbrownie bake yearn-strategy\n```\n\n## Basic Use\n\nTo deploy the demo Yearn Strategy in a development environment:\n\n1. Open the Brownie console. This automatically launches Ganache on a forked mainnet.\n\n```bash\n$ brownie console\n```\n\n2. Create variables for the Yearn Vault and Want Token addresses. These were obtained from the Yearn Registry. Also, loan the Yearn governance multisig.\n\n```python\n\u003e\u003e\u003e vault = Vault.at(\"0xBFa4D8AA6d8a379aBFe7793399D3DdaCC5bBECBB\")  # yvDAI (v0.2.2)\n\u003e\u003e\u003e token = Token.at(\"0x6b175474e89094c44da98b954eedeac495271d0f\")  # DAI\n\u003e\u003e\u003e gov = \"ychad.eth\"  # ENS for Yearn Governance Multisig\n```\n\n3. Deploy the [`Strategy.sol`](contracts/Strategy.sol) contract.\n\n```python\n\u003e\u003e\u003e strategy = Strategy.deploy(vault, {\"from\": accounts[0]})\nTransaction sent: 0xc8a35b3ecbbed196a344ed6b5c7ee6f50faf9b7eee836044d1c7ffe10093ef45\n  Gas price: 0.0 gwei   Gas limit: 6721975\n  Flashloan.constructor confirmed - Block: 9995378   Gas used: 796934 (11.86%)\n  Flashloan deployed at: 0x3194cBDC3dbcd3E11a07892e7bA5c3394048Cc87\n```\n\n4. Approve the strategy for the Vault. We must do this because we only approved Strategies can pull funding from the Vault.\n\n```python\n# 1000 DAI debt limit, no rate limit, 50 bps strategist fee\n\u003e\u003e\u003e vault.addStrategy(strategy, Wei(\"1000 ether\"), 2 ** 256 - 1, 50, {\"from\": gov})\nTransaction sent: 0xa70b90eb9a9899e8f6e709c53a436976315b4279c4b6797d0a293e169f94d5b4\n  Gas price: 0.0 gwei   Gas limit: 6721975\n  Transaction confirmed - Block: 9995379   Gas used: 21055 (0.31%)\n```\n\n5. Now we are ready to put our strategy into action!\n\n```python\n\u003e\u003e\u003e harvest_tx = strategy.harvest({\"from\": accounts[0]})  # perform as many time as desired...\n```\n\n## Implementing Strategy Logic\n\n[`contracts/Strategy.sol`](contracts/Strategy.sol) is where you implement your own logic for your strategy. In particular:\n\n* Create a descriptive name for your strategy via `Strategy.name()`.\n* Invest your want tokens via `Strategy.adjustPosition()`.\n* Take profits and report losses via `Strategy.prepareReturn()`.\n* Unwind enough of your position to payback withdrawals via `Strategy.liquidatePosition()`.\n* Unwind all of your positions via `Strategy.exitPosition()`.\n* Fill in a way to estimate the total `want` tokens managed by the strategy via `Strategy.estimatedTotalAssets()`.\n* Migrate all the positions managed by your strategy via `Strategy.prepareMigration()`.\n* Make a list of all position tokens that should be protected against movements via `Strategy.protectedTokens()`.\n\n## Testing\n\nTo run the tests:\n\n```\nbrownie test\n```\n\nThe example tests provided in this mix start by deploying and approving your [`Strategy.sol`](contracts/Strategy.sol) contract. This ensures that the loan executes succesfully without any custom logic. Once you have built your own logic, you should edit [`tests/test_flashloan.py`](tests/test_flashloan.py) and remove this initial funding logic.\n\nSee the [Brownie documentation](https://eth-brownie.readthedocs.io/en/stable/tests-pytest-intro.html) for more detailed information on testing your project.\n\n## Debugging Failed Transactions\n\nUse the `--interactive` flag to open a console immediatly after each failing test:\n\n```\nbrownie test --interactive\n```\n\nWithin the console, transaction data is available in the [`history`](https://eth-brownie.readthedocs.io/en/stable/api-network.html#txhistory) container:\n\n```python\n\u003e\u003e\u003e history\n[\u003cTransaction '0x50f41e2a3c3f44e5d57ae294a8f872f7b97de0cb79b2a4f43cf9f2b6bac61fb4'\u003e,\n \u003cTransaction '0xb05a87885790b579982983e7079d811c1e269b2c678d99ecb0a3a5104a666138'\u003e]\n```\n\nExamine the [`TransactionReceipt`](https://eth-brownie.readthedocs.io/en/stable/api-network.html#transactionreceipt) for the failed test to determine what went wrong. For example, to view a traceback:\n\n```python\n\u003e\u003e\u003e tx = history[-1]\n\u003e\u003e\u003e tx.traceback()\n```\n\nTo view a tree map of how the transaction executed:\n\n```python\n\u003e\u003e\u003e tx.call_trace()\n```\n\nSee the [Brownie documentation](https://eth-brownie.readthedocs.io/en/stable/core-transactions.html) for more detailed information on debugging failed transactions.\n\n\u003c!--\n## Deployment\n\nWhen you are finished testing and ready to deploy to the mainnet:\n\n1. [Import a keystore](https://eth-brownie.readthedocs.io/en/stable/account-management.html#importing-from-a-private-key) into Brownie for the account you wish to deploy from.\n2. Edit [`scripts/deployment.py`](scripts/deployment.py) and add your keystore ID according to the comments.\n3. Run the deployment script on the mainnet using the following command:\n\n```bash\n$ brownie run deployment --network mainnet\n```\n\nYou will be prompted to enter your keystore password, and then the contract will be deployed.\n--\u003e\n\n## Known issues\n\n### No access to archive state errors\n\nIf 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 redploy your contracts.\n\n# Resources\n\n- Yearn [Discord channel](https://discord.com/invite/6PNv2nF/)\n- Brownie [Gitter channel](https://gitter.im/eth-brownie/community)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvasa-develop%2Fyva3crv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvasa-develop%2Fyva3crv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvasa-develop%2Fyva3crv/lists"}