GithubHelp home page GithubHelp logo

brownie-mix / aave-flashloan-mix Goto Github PK

View Code? Open in Web Editor NEW
396.0 17.0 266.0 360 KB

A Brownie mix containing all you need to get started with developing flash loans

License: GNU Affero General Public License v3.0

Solidity 78.91% Python 20.81% Shell 0.28%
brownie web3

aave-flashloan-mix's People

Contributors

emilianobonassi avatar iamdefinitelyahuman avatar molecula451 avatar mrdavey avatar patrickalphac avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aave-flashloan-mix's Issues

Insufficient funds error message after running get_weth.py

error: raise ValueError(exc["message"]) from None
ValueError: Insufficient funds. The account you tried to send transaction from does not have enough funds. Required 1000049572000396576 and got: 0.
Does this script fund the wallet or do I have to fund it seperately via Metamask. Please advise.
Thanks
EF

VirtualMachineError: revert

I tried running brownie run scripts/deployment_v2.py

But got this error

Running 'scripts/deployment_v2.py::main'...
Transaction sent: 0x0737917f12b9853ad747ba7c649107b4d019ea0725d4f0160de68eb54268d959
  Gas price: 0.0 gwei   Gas limit: 6721975   Nonce: 5
  FlashloanV2.constructor confirmed (reverted) - Block: 11   Gas used: 122628 (1.82%)

  File "brownie/_cli/run.py", line 49, in main
    return_value, frame = run(
  File "brownie/project/scripts.py", line 103, in run
    return_value = f_locals[method_name](*args, **kwargs)
  File "./scripts/deployment_v2.py", line 17, in main
    flashloan = FlashloanV2.deploy(
  File "brownie/network/contract.py", line 593, in __call__
    return tx["from"].deploy(
  File "brownie/network/account.py", line 505, in deploy
    receipt._raise_if_reverted(exc)
  File "brownie/network/transaction.py", line 393, in _raise_if_reverted
    raise exc._with_attr(
VirtualMachineError: revert

Gas estimation failed: If you wish to broadcast, you must set the gas limit manually.

Hi there,

First of all, thank you for the template!

I was running into an error executing run_flash_loan_v2.py after successfully deploying the contract on Kovan (see message below).

The error message asks to set the gas limit manually - I did this in the brownie-config.yaml using gas_limit: 100000000000 but the error persists.

Any ideas how to resolve this?

Many thanks

Running 'scripts/run_flash_loan_v2.py::main'...
Getting Flashloan contract...
Executing Flashloan...
File "brownie/_cli/run.py", line 49, in main
return_value, frame = run(
File "brownie/project/scripts.py", line 103, in run
return_value = f_locals[method_name](*args, **kwargs)
File "./scripts/run_flash_loan_v2.py", line 20, in main
tx = flashloan.flashloan(weth, {"from": acct})
File "brownie/network/contract.py", line 1323, in call
return fn(*args) # type: ignore
File "brownie/network/contract.py", line 1676, in call
return self.transact(*args)
File "brownie/network/contract.py", line 1550, in transact
return tx["from"].transfer(
File "brownie/network/account.py", line 600, in transfer
gas_limit = Wei(gas_limit) or self._gas_limit(to, amount, gas_price, gas_buffer, data)
File "brownie/network/account.py", line 367, in _gas_limit
gas_limit = self.estimate_gas(to, amount, gas_price, data or "")
File "brownie/network/account.py", line 560, in estimate_gas
raise ValueError(
ValueError: Gas estimation failed: 'The execution failed due to an exception.'. This transaction will likely revert. If you wish to broadcast, you must set the gas limit manually.

New Brownie Mix for Gitlab

I have a working implementation of brownie/ganache/docker for use with Gitlab's CI/CD that I think would make a great Mix.

I'm fully aware that this is definitely the wrong place for this question, but I couldn't see anywhere in the Github organization on how to contribute a new Mix. @iamdefinitelyahuman if this is something you think would be beneficial, could you reach out with how to get it added? thank you!

Increasing the loan amount

Increasing the amount from 1 ether (to any of 2, 5, 10 ether) in FlashloanV2.sol:89 leads to the following error:

ValueError: Gas estimation failed: 'execution reverted'. This transaction will likely revert. If you wish to broadcast, you must set the gas limit manually.

Trying to interact with the overloaded flashloan function in the run_flash_loan_v2.py script via

tx = flashloan.flashloan([weth], [5 * 1e18], {"from": acct})

also leads to the same error. Everything works fine as long as I only flash 1 ether.

What is the correct way to increase the loan amount?

ValueError: invalid literal for int() with base 16: '0x'

I'm trying to run the example code in the README and I'm running into an error when I try to execute the following line:

>>> WETH = Contract("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2")

Here's my traceback:

  File "<console>", line 1, in <module>
  File "brownie/network/contract.py", line 923, in __init__
    contract = self.from_explorer(address, owner=owner, silent=True)
  File "brownie/network/contract.py", line 1102, in from_explorer
    if int(implementation_eip1967.hex(), 16):
ValueError: invalid literal for int() with base 16: '0x'

Is it expecting an int?

Thanks in advance for the help.

Error when I run the get WETH command: brownie run scripts/get_weth.py --network kovan

After setting up the environment and when I run the get WETH command: brownie run scripts/get_weth.py --network kovan i get the following error:
INFO: Could not find files for the given pattern(s).
Brownie v1.17.2 - Python development framework for Ethereum

File "..local\pipx\venvs\eth-brownie\lib\site-packages\brownie_cli_main_.py", line 64, in main
importlib.import_module(f"brownie._cli.{cmd}").main()
File "..local\pipx\venvs\eth-brownie\lib\site-packages\brownie_cli\run.py", line 44, in main
network.connect(CONFIG.argv["network"])
File "..local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\main.py", line 40, in connect
web3.connect(host, active.get("timeout", 30))
File "..local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\web3.py", line 52, in connect
uri = _expand_environment_vars(uri)
File "..local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\web3.py", line 183, in _expand_environment_vars
raise ValueError(f"Unable to expand environment variable in host setting: '{uri}'")
ValueError: Unable to expand environment variable in host setting: 'https://kovan.infura.io/v3/$WEB3_INFURA_PROJECT_ID'
PS C:\Users\Ash> brownie run scripts/run_flash_loan_v2.py --network kovan
INFO: Could not find files for the given pattern(s).
Brownie v1.17.2 - Python development framework for Ethereum

File "..local\pipx\venvs\eth-brownie\lib\site-packages\brownie_cli_main_.py", line 64, in main
importlib.import_module(f"brownie._cli.{cmd}").main()
File "..local\pipx\venvs\eth-brownie\lib\site-packages\brownie_cli\run.py", line 44, in main
network.connect(CONFIG.argv["network"])
File "..local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\main.py", line 40, in connect
web3.connect(host, active.get("timeout", 30))
File "..local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\web3.py", line 52, in connect
uri = _expand_environment_vars(uri)
File "..local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\web3.py", line 183, in expand_environment_vars
raise ValueError(f"Unable to expand environment variable in host setting: '{uri}'")
rownie_cli_main
.py", line 64, in main
importlib.import_module(f"brownie._cli.{cmd}").main()
File "..local\pipx\venvs\eth-brownie\lib\site-packages\brownie_cli\run.py", line 44, in main
network.connect(CONFIG.argv["network"])
File "..local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\main.py", line 40, in connect
web3.connect(host, active.get("timeout", 30))
File "..local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\web3.py", line 52, in connect
uri = _expand_environment_vars(uri)
File "..local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\web3.py", line 183, in _expand_environment_vars
raise ValueError(f"Unable to expand environment variable in host setting: '{uri}'")
ValueError: Unable to expand environment variable in host setting: 'https://kovan.infura.io/v3/$WEB3_INFURA_PROJECT_ID'
PS C:\Users\Ash> brownie --version
INFO: Could not find files for the given pattern(s).
Brownie v1.17.2 - Python development framework for Ethereum

Unable to publish and verify contract

Adding publish_source=True as an argument to the deploy function inside deployment_v2.py does still deploy the contract, but the contract is always unable to verify. I have tried publishing the contract through this method, as well as using the brownie console but it never seems to work for me.

image

Thanks for the repo, by the way. Very useful.

ConnectionError: Status 404 when retrieving repo brownie-mix/aave-flash information from GHAPI: 'Not Found'

When I was installing aave-flash by running brownie bake aave-flash, I have this error.
I've updated the GitHub token and still getting this error

aave-flashloan-mix git/main*  26s
(flashloan) ❯ brownie bake aave-flash
Brownie v1.17.1 - Python development framework for Ethereum

  File "brownie/_cli/__main__.py", line 64, in main
    importlib.import_module(f"brownie._cli.{cmd}").main()
  File "brownie/_cli/bake.py", line 26, in main
    path = project.from_brownie_mix(args["<mix>"], args["<path>"], args["--force"])
  File "brownie/project/main.py", line 608, in from_brownie_mix
    default_branch = _get_mix_default_branch(project_name, headers)
  File "brownie/project/main.py", line 1036, in _get_mix_default_branch
    raise ConnectionError(msg)
ConnectionError: Status 404 when retrieving repo brownie-mix/aave-flash information from GHAPI: 'Not Found'

Missing or forbidden.
If this issue persists, generate a Github API token and store it as the environment variable `GITHUB_TOKEN`:
https://github.blog/2013-05-16-personal-api-tokens/

Unable to expand environment variable in host setting: 'https://kovan.infura.io/v3/$WEB3_INFURA_PROJECT_ID'

On executing brownie run scripts/get_weth.py --network kovan the below error occurs:

"INFO: Could not find files for the given pattern(s).
Brownie v1.14.6 - Python development framework for Ethereum

AaveFlashloanMixProject is the active project.
File "c:\users\ajith\appdata\local\programs\python\python39\lib\site-packages\brownie_cli_main_.py", line 64, in main
importlib.import_module(f"brownie._cli.{cmd}").main()
File "c:\users\ajith\appdata\local\programs\python\python39\lib\site-packages\brownie_cli\run.py", line 43, in main
network.connect(CONFIG.argv["network"])
File "c:\users\ajith\appdata\local\programs\python\python39\lib\site-packages\brownie\network\main.py", line 40, in connect
web3.connect(host, active.get("timeout", 30))
File "c:\users\ajith\appdata\local\programs\python\python39\lib\site-packages\brownie\network\web3.py", line 52, in connect
uri = _expand_environment_vars(uri)
File "c:\users\ajith\appdata\local\programs\python\python39\lib\site-packages\brownie\network\web3.py", line 183, in _expand_environment_vars
raise ValueError(f"Unable to expand environment variable in host setting: '{uri}'")
ValueError: Unable to expand environment variable in host setting: 'https://kovan.infura.io/v3/$WEB3_INFURA_PROJECT_ID'"

gas required exceeds allowance (12487735) or always failing transaction

Hi, Thank you for this repo. Very nice.

I deployed a contract, on the mainnet, based on your kit with my own parts added. When I try to call the flashloan function I get the following error.

Any advice ?

acct
<LocalAccount '0x513E95Eec3bAC74802b4b2D859e802f17eAE57a9'>
flashloan
<MyFlashloanContract Contract '0x80be9fBea39Ae56d090148c4EF96f7f7f4Dc9Aa1'>
tx = flashloan.flashloan(eth_reserve,10000000000000000,chai_reserve, {"from": acct})
File "", line 1, in
File "c:\users\alexander, line line, in in
return self.transact(*args)
File "c:\users\alexander, line line, in in
return tx["from"].transfer(
File "c:\users\alexander, line line, in in
"gas": Wei(gas_limit) or self._gas_limit(to, amount, gas_buffer, data),
File "c:\users\alexander, line line, in in
gas_limit = self.estimate_gas(to, amount, data or "")
File "c:\users\alexander, line line, in in
return web3.eth.estimateGas(
File "c:\users\alexander, line line, in in
return self.web3.manager.request_blocking(
File "c:\users\alexander, line line, in in
raise ValueError(response["error"])
ValueError: {'code': -32000, 'message': 'gas required exceeds allowance (12463323) or always failing transaction'}

Best,
Alexander

How to withdraw from the smart contract to the wallet

Hi Everyone,

I managed to deploy the smart contract and perform the flash loans. However, I don't know how to withdraw the funds from the smart contract.
Let's talk with the case on hand:

To do the flashloan, funds are transferred from wallet to the contract with transaction https://kovan.etherscan.io/tx/0x9c3d95bd9ddb14e7debfe9153724f7b3aaf0d981b4657d1a000e2d70860eff44 to cover the fees. Then I'm able to execute the flashloan correctly.

However, now the contract has a balance, that should be transferred back to my wallet. So my doubt is:

  • How do I transfer the balance on the contract back to my wallet?
  • Could be that the code is effectively transferring the profit back to the wallet, but I am not seeing it because there is no profit in the transaction I did? It was only the flashloan, so there is a loss for the fees.

Thanks for who can clarify me this.

flashloan.flashloan() got an unexpected argument 'block_identifier'

Hello, I have gone through all the steps however cannot run the last step of tx = flashloan.flashloan(WETH, {"from": accounts[2]})
It returns an error of
File "<console>", line 1, in <module> File "eth_brownie-1.17.2-py3.9.egg/brownie/network/contract.py", line 1303, in __call__ return fn(*args, block_identifier=block_identifier, override=override) # type: ignore TypeError: __call__() got an unexpected keyword argument 'block_identifier'

private key must be exactly 32 bytes long

Hey there,

I am currently experiencing the issue that i can not use my MetaMask Private key.
Brownie is able to detect the Private Key but is not able to preceed and exiting with following error:

ValueError: The private key must be exactly 32 bytes long, instead of 67 bytes.

"0x" ist set
0xisset

brownie-config.yaml includes "dotenv: .env"

Am not really sure how to resolve this issue and would be very thankful for help!

Cheers,
Kevin

[Quickstart Kovan] ValueError: Gas estimation failed: 'The execution failed due to an exception.'

Hi, while following the steps to test the repo on the Kovan test network I ran into this issue : **. get_weth.py works well, I can see the ETH being replaced by WETH on Metamask, deployement_v2 works fine too (the contract is visible on etherscan). The issue resides in run_flash_loan_v2.py at line 20 : tx = flashloan.flashloan(weth, {"from": acct}). Could you help me out. Thx in advance

** : brownie run scripts/run_flash_loan_v2.py --network kovan
Brownie v1.15.2 - Python development framework for Ethereum

AaveFlashloanMixProject is the active project.

Running 'scripts/run_flash_loan_v2.py::main'...
Getting Flashloan contract...
Funding Flashloan contract with WETH...
Transaction sent: 0x1e9e940aacbbf711e8e406078c17b2bf7a6a787828ef85f596e6007dcd4a6241
Gas price: 1.1 gwei Gas limit: 56934 Nonce: 150
WethInterface.transfer confirmed - Block: 26576860 Gas used: 51759 (90.91%)

Executing Flashloan...
File "brownie/_cli/run.py", line 49, in main
return_value, frame = run(
File "brownie/project/scripts.py", line 103, in run
return_value = f_locals[method_name](*args, **kwargs)
File "./scripts/run_flash_loan_v2.py", line 20, in main
tx = flashloan.flashloan(weth, {"from": acct})
File "brownie/network/contract.py", line 1338, in call
return fn(*args) # type: ignore
File "brownie/network/contract.py", line 1691, in call
return self.transact(*args)
File "brownie/network/contract.py", line 1565, in transact
return tx["from"].transfer(
File "brownie/network/account.py", line 658, in transfer
gas_limit = Wei(gas_limit) or self._gas_limit(to, amount, gas_price, gas_buffer, data)
File "brownie/network/account.py", line 425, in _gas_limit
gas_limit = self.estimate_gas(to, amount, gas_price, data or "")
File "brownie/network/account.py", line 618, in estimate_gas
raise ValueError(
ValueError: Gas estimation failed: 'The execution failed due to an exception.'. This transaction will likely revert. If you wish to broadcast, you must set the gas limit manually.

aave v3 flash loan

The implementation changes slightly from AAVE V2 to V3. Would it be interesting to have a V3 implementation as well?
Thanks for your amazing work!

Gas fees issue

i have run the flashloan contract for the first time it went well but the second time it gives me this error Gas estimation failed: 'execution reverted'. This transaction will likely revert. If you wish to broadcast, you must set the gas limit manually.
and i do have testnet eth and everything
can someone help me please

"ConnectionError" with "api-kovan.etherscan.io". Why? pls!

raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api-kovan.etherscan.io', port=443): Max retries exceeded with url: /api?module=contract&action=getsourcecode&address=0x8c43d532314f05C1807f606771CE4d2cb006cA3a&apiKey=ANBNBT6PU6QT5979R7NS61641GH31GEAA3 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fc8c121cbe0>: Failed to establish a new connection: [Errno 110] Connection timed out'))

Something wrong with "flashloan = FlashloanV2[len(FlashloanV2) - 1]".

brownie run scripts/run_flash_loan_v2.py --network kovan

File "./scripts/run_flash_loan_v2.py", line 18, in main
print(FlashloanV2[-1])
File "brownie/network/contract.py", line 158, in getitem
return self._contracts[i]
IndexError: list index out of range

Here is some of the code:

def main(): 
    acct = accounts.add(config["wallets"]["from_key"])
    print("Getting Flashloan contract...")
    flashloan = FlashloanV2[len(FlashloanV2) - 1]
    weth = interface.WethInterface(config["networks"][network.show_active()]["weth"])<br class="Apple-interchange-newline">

So I print(len(FlashLoanV2)) and get 0.
seems like it can't read FlashLoanV2 object as an array, so I can't get the address in it through FlashLoanV2[...].
How to solve this, it's because of my python version or something else?
Thanks!

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.