yearn / brownie-strategy-mix Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU Affero General Public License v3.0
License: GNU Affero General Public License v3.0
Currently, the README has the following instruction:
...
token = Token("0x6b175474e89094c44da98b954eedeac495271d0f")
...
When I run this, I see the error TypeError: 'ContractContainer' object is not callable
because we are trying to invoke call the Token
object which is of type >>> type(Token) <class 'brownie.network.contract.ContractContainer'>
.
We should really be calling the method Token.at
like:
token = Token.at("0x6b175474e89094c44da98b954eedeac495271d0f")
I tried following the instructions to install ganache at the url in the README:
https://github.com/trufflesuite/ganache-cli
If you click on the link you'll see that it takes you to trufflesuite/ganache. I believe truffle consolidated their products.
If you install the package there, brownie will be unsuccessful in starting a node as the parameters have different names (i.e. instead of chainId
it is now chain.chainId
etc.
The package that yearn was referring to was this package, which has been deprecated in favor of the above package.
https://www.npmjs.com/package/ganache-cli
The quick fix is to change the link to this package, the longer fix would be to change things around to work with the newer package.
I think the testing code should be updated to facilitate the usage.
All the tests now are doing some asserts on token.balanceOf(new_strategy.address)
I suggest using strategy.estimatedTotalAssets()
combined with pytest.approx
@fubuloubu toughts?
Spec:
Update to use vaults repo 0.3.2
Example:
#21
Should sync with vault PRs:
NOTE: additional work is to create tags for previous 0.3.x releases to sync to vaults since we have to support all vaults across 0.3.x spectrum as well. Strategist should be able to switch tags to target as specific version using this repo.
From discussion in #14
Strategist need to target live vaults with different versions, e.g: 0.3.0, 0.3.5 0.4.2
We need to add matching tags version like v0.3.0 that strategist forking this repo can quickly
build the strategy with all test working on them as expected.
v0.3.0 in brownie mix should point to v0.3.0-1 in yearn-vaults to make the version simpler and avoid anyone deploying new strategies without health checks.
All code needs to be adjusted so its compatible with each vault version release.
Important releases to have matching tags for:
v0.3.0
v0.3.2
v0.3.3
v0.3.5
v0.4.2
(rest are not as critical since we don't have live vaults for those)
See https://github.com/crytic/slither
More info:
Copied from yearn/yearn-protocol#28 by milkyklim and comment by Macarse
This has to be optional so anyone can choose if they want to use it or not.
Every time a test suite is run:
This is based on an issue we found on strategy logic not handling the case when somebody airdrops want tokens or any token related with balance calculations and can cause issues with withdrawals
should be based on this test:
brownie-strategy-mix/scripts/deploy.py
Line 42 in cdc942e
I'm looking into ways to import the deploy script from Yearn-Vaults into the Strategy Mix, I can import contracts but I can't find a way to import scripts.
Can you give me an intuition for how to make that work?
I'd be happy to add this functionality if you can point me in the right direction
The readme omits the debtRatio
argument to addStrategy:
>>> v.addStrategy(strategy, Wei("1000 ether"), 2 ** 256 - 1, 50, {"from": gov})
File "<console>", line 1, in <module>
File "brownie/network/contract.py", line 1692, in __call__
return self.transact(*args)
File "brownie/network/contract.py", line 1575, in transact
data=self.encode_input(*args),
File "brownie/network/contract.py", line 1610, in encode_input
data = format_input(self.abi, args)
File "brownie/convert/normalize.py", line 20, in format_input
raise type(e)(f"{abi['name']} {e}") from None
ValueError: addStrategy Sequence has incorrect length, expected 5 but got 4
related #69
Add generic test to be able to tell if basic functionality is working fine.
This can be used as the base scripts needed: https://github.com/Macarse/yhegic/tree/master/tests/development
Add an integration test suite that strategist can use to test their code that works as a smoke test for the minimum features they need to implement and ensures the strategy is working correctly for normal conditions and emergency mode.
This test suite should help ensure the vault and strategy interactions work correctly.
Covers at least the following scenarios:
CI seems to be faling since this commit:
When I run brownie console
per the readme I get an error-
Launching 'ganache-cli --accounts 10 --hardfork istanbul --fork https://mainnet.infura.io/v3/[snip]--gasLimit 12000000 --mnemonic brownie --port 8545 --chainId 1'...
File "brownie/_cli/__main__.py", line 64, in main
importlib.import_module(f"brownie._cli.{cmd}").main()
File "brownie/_cli/console.py", line 58, in main
network.connect(CONFIG.argv["network"])
File "brownie/network/main.py", line 50, in connect
rpc.launch(active["cmd"], **active["cmd_settings"])
File "brownie/network/rpc/__init__.py", line 93, in launch
raise RPCProcessError(cmd, uri)
RPCProcessError: Unable to launch local RPC client.
Command: ganache-cli
URI: http://127.0.0.1:8545
Running that command directly shows that the --chainId command isn't allowed anymore:
$ ganache-cli --accounts 10 --hardfork istanbul --fork https://mainnet.infura.io/v3/[snip]--gasLimit 12000000 --mnemonic brownie --port 8545 --chainId 1'
Unknown argument: chainId
This is using ganache v7.0.0-alpha.1 and Brownie v1.16.0.
When I downgrade to ganache v6.12.2 it works as expected:
$ npm install [email protected] --global
$ brownie console
...
Launching 'ganache-cli --accounts 10 --hardfork istanbul --fork https://mainnet.infura.io/v3/[snip] --gasLimit 12000000 --mnemonic brownie --port 8545 --chainId 1'...
Brownie environment is ready.
I'm trying to follow the readme to create a new strategy. I did the following but i'm getting an error:
>>> from pathlib import Path
>>> vault = interface.VaultAPI("0xdA816459F1AB5631232FE5e97a05BBBb94970c95")
>>> token = interface.IERC20("0x6b175474e89094c44da98b954eedeac495271d0f")
>>> gov = "ychad.eth"
>>> strategy = Strategy.deploy(vault, {"from": accounts[0]})
Transaction sent: 0x87d571cf69e58c3032a0cc4bd056a30b65279d602305853bcb6a44b91b1af230
Gas price: 0.0 gwei Gas limit: 12000000 Nonce: 2
Strategy.constructor confirmed Block: 13611222 Gas used: 2540922 (21.17%)
Strategy deployed at: 0xE7eD6747FaC5360f88a2EFC03E00d25789F69291
>>> vault.addStrategy(strategy, Wei("1000 ether"), 2 ** 256 - 1, 50, {"from": gov})
File "<console>", line 1, in <module>
File "brownie/network/contract.py", line 831, in __getattribute__
raise AttributeError(f"Contract '{self._name}' object has no attribute '{name}'")
AttributeError: Contract 'VaultAPI' object has no attribute 'addStrategy'
The vault object has plenty of methods, but none of them are addStrategy...
>>> dir(vault)
[abi, address, alias, allowance, apiVersion, approve, balance, balanceOf, bytecode, creditAvailable, debtOutstanding, decimals, decode_input, deposit, depositLimit, expectedReturn, from_abi, from_ethpm, from_explorer, get_method, get_method_object, governance, guardian, info, management, maxAvailableShares, name, permit, pricePerShare, report, revokeStrategy, selectors, set_alias, signatures, strategies, symbol, token, topics, totalAssets, totalSupply, transfer, transferFrom, tx, withdraw]
Am I doing something wrong, or is the readme out of date?
I just did a fresh clone of this repo and followed the README. This step doesn't work for me and I had to use these steps instead. If it helps, the error I received was:
>>> vault.addStrategy(strategy, 1000, 0, 2 ** 256 - 1, 1_000, {"from": gov})
File "<console>", line 1, in <module>
File "brownie/network/contract.py", line 832, in __getattribute__
raise AttributeError(f"Contract '{self._name}' object has no attribute '{name}'")
AttributeError: Contract 'VaultAPI' object has no attribute 'addStrategy'
when trying to add the strategy using the local ABIs.
following changes on:
yearn/yearn-vaults#326
We need to update the tests to ensure they still work.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.