Giter Club home page Giter Club logo

aave_web3_py's Introduction


Python + Aave Python + Aave


aave_web3_py

Put down collateral, Borrow, and repay a loan from Aave! Use this to short assets and accrue interest.

You can see a brownie version of this here.

In our aave_borrow_web3.py script, we do the following:

  1. Approve our ETH to be swapped for WETH
  2. Swap an amount of ETH for WETH
  3. Using deposit_to_aave we deposit the WETH as collateral
  4. We use that collateral to borrow LINK with borrow_erc20
  5. Then, we pay it back!
  6. We can view the txs on etherscan to see what's going on under the hood.

Setup

You'll need python installed.

pip install -r requirements.txt

You'll need the following environment variables. You can set them all in your .env file:

export MY_ADDRESS=<YOUR_WALLET_ADDRESS>
export PRIVATE_KEY=<YOUR_PRIVATE_KEY> # Remember to start it with "0x"
export KOVAN_RPC_URL='URL'

# Optional... But can be very helpful
export MAINNET_RPC_URL='URL'
  • MY_ADDRESS: Your Wallet Address
  • PRIVATE_KEY: Your Private Key from your Wallet
  • KOVAN_RPC_URL: Your Kovan connection to the blockchain. You can get a URL from a service like Infura or ]Alchemy. An example would be https://kovan.infura.io/v3/fffffffffffffffffffff
  • MAINNET_RPC_URL: Same as above, but for mainnet.

And last, be sure to check the aave_link_token if you're using a testnet LINK token. Aave sometimes changes the token they use on testnet to keep liquidity. Also, feel free to check the Aave docs as well, to learn more about the tools we are using.

Quickstart - kovan

  1. Get some kovan ETH

  2. Get some WETH

python get_weth.py
  1. Run the script!
python aave_borrow_web3.py

Quickstart - mainnet-fork

Optional for running locally: If you want to run locally, you can install ganache-cli and yarn. Here is where you can install yarn.

yarn global add ganache-cli

Then, you can run ganache-cli --fork $MAINNET_RPC_URL and set the active network in the config.yaml to mainnet-fork.

You'll need to set your private key to a private key from your forked mainnet.

  1. Get some WETH
python get_weth.py
  1. Run the script!
python aave_borrow_web3.py

aave_web3_py's People

Contributors

jeshli avatar patrickalphac 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.