{"id":19498147,"url":"https://github.com/patrickalphac/defi_py_mix","last_synced_at":"2025-10-25T06:34:04.441Z","repository":{"id":46887140,"uuid":"380875219","full_name":"PatrickAlphaC/defi_py_mix","owner":"PatrickAlphaC","description":null,"archived":false,"fork":false,"pushed_at":"2021-06-28T20:49:10.000Z","size":502,"stargazers_count":36,"open_issues_count":0,"forks_count":16,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-17T00:46:03.988Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PatrickAlphaC.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}},"created_at":"2021-06-28T01:39:36.000Z","updated_at":"2025-03-07T13:00:00.000Z","dependencies_parsed_at":"2022-09-23T07:52:08.481Z","dependency_job_id":null,"html_url":"https://github.com/PatrickAlphaC/defi_py_mix","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/PatrickAlphaC/defi_py_mix","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PatrickAlphaC%2Fdefi_py_mix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PatrickAlphaC%2Fdefi_py_mix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PatrickAlphaC%2Fdefi_py_mix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PatrickAlphaC%2Fdefi_py_mix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PatrickAlphaC","download_url":"https://codeload.github.com/PatrickAlphaC/defi_py_mix/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PatrickAlphaC%2Fdefi_py_mix/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267785856,"owners_count":24144122,"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","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-11-10T21:49:22.283Z","updated_at":"2025-10-06T12:18:35.001Z","avatar_url":"https://github.com/PatrickAlphaC.png","language":"Solidity","readme":"\n\n# defi_py_mix\n\nFor all your DeFi needs\n\n[You can see a smaller version of this here. ](https://github.com/PatrickAlphaC/aave_brownie_py)\n\nIn our `aave_borrow.py` script, we do the following:\n\n1. Approve our `ETH` to be swapped for `WETH`\n2. Swap an `amount` of `ETH` for `WETH`\n3. Using `deposit_to_aave` we deposit the `WETH` as collateral\n4. We use that collateral to borrow `DAI` with `borrow_erc20`\n5. Then, we pay it back! \n6. We can view the txs on etherscan to see what's going on under the hood. \n\nIn our `short_sell.py` script, we do the following:\n\n1. Approve our `ETH` to be swapped for `WETH`\n2. Swap an `amount` of `ETH` for `WETH`\n3. Using `deposit_to_aave` we deposit the `WETH` as collateral\n4. We use that collateral to borrow `DAI` with `borrow_erc20`\n5. We then sell that `DAI` on the `Uniswap` DEX\nThis is essentailly a short sell on DAI!\n\n# Setup\n\nYou'll need python, pipx, and eth-brownie installed. \n\nIdeally you'd install with pipx\n```bash\npip install --user pipx\npipx ensurepath\n# restart your terminal\npipx install eth-brownie\n```\nOr, you could try it with pip. \n```\npip install -r requirements.txt\n```\nOr, if you run into issues use pipx:\n\n\nYou'll need the following [environment variables](https://www.twilio.com/blog/2017/01/how-to-set-environment-variables.html). If you're unfamiliar with environment variables, you can set them all in your `.env` file:\n\n```\nexport WEB3_INFURA_PROJECT_ID=YourProjectID\nexport PRIVATE_KEY=\"0xasdfasdfasdfasd...\"\n```\n\n- `PRIVATE_KEY`: Your Private Key from your Wallet. *Note: If using metamask, you'll have to add a 0x to the start of your private key.\n- `WEB3_INFURA_PROJECT_ID`: Your connection to the blockchain. You can get a URL from a service like [Infura](https://infura.io/)]. Right now it is hard coded to work with infura, but you can modify it however you want using `brownie networks modify`. \n\n\u003e Note: DO NOT SEND THESE TO GITHUB!!!\n\nAnd last, be sure to check the aave_dai_token if you're using a [testnet DAI token](https://docs.aave.com/developers/deployed-contracts/deployed-contracts0).  Aave sometimes changes the token they use on testnet to keep liquidity, [please check here for reference](https://aave.github.io/aave-addresses/kovan.json). \nAlso, feel free to check the [Aave docs](https://docs.aave.com/developers/the-core-protocol/lendingpool) as well, to learn more about the tools we are using. \n\n# Quickstart - kovan\n\n1. [Get some kovan ETH](https://faucet.kovan.network/)\n\n2. Get some WETH\n\n```\nbrownie run scripts/get_weth.py --network kovan\n```\n\n3. Run the script!\n\n```\nbrownie run scripts/aave_borrow.py --network kovan\n```\n\n\n# Quickstart - mainnet-fork\n\n\nOptional for running locally:\nIf you want to run locally, you can install `ganache-cli` and `yarn`. Here is where you can [install yarn.](https://classic.yarnpkg.com/en/docs/install/#mac-stable)\n\n```\nyarn global add ganache-cli\n```\n\nThen, you can run `ganache-cli --fork YOUR_INFURA_URL_HERE`, or just `brownie run \u003cYOUR_SCRIPT\u003e --network mainnet-fork`\n\n1. Get some WETH, borrow, and repay!\n\n```\nbrownie run scripts/aave/aave_borrow.py\n```\n\nOr, to test short selling:\n\n```\nbrownie run scripts/swap/short_sell.py \n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrickalphac%2Fdefi_py_mix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpatrickalphac%2Fdefi_py_mix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrickalphac%2Fdefi_py_mix/lists"}