-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from PatrickAlphaC/master
Updated for developer experience and config for chain customization
- Loading branch information
Showing
9 changed files
with
120 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export WEB3_INFURA_PROJECT_ID=YourProjectID | ||
export ETHERSCAN_TOKEN=YourApiToken | ||
export PRIVATE_KEY="0xasdfasdfasdfasd..." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ __pycache__ | |
.hypothesis/ | ||
build/ | ||
reports/ | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,17 @@ compiler: | |
solc: | ||
remappings: | ||
- "@openzeppelin=OpenZeppelin/[email protected]" | ||
networks: | ||
default: mainnet-fork | ||
mainnet-fork: | ||
aave_lending_pool_v2: "0xB53C1a33016B2DC2fF3653530bfF1848a515c8c5" | ||
weth: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" | ||
kovan: | ||
aave_lending_pool_v2: "0x88757f2f99175387ab4c6a4b3067c77a695b0349" | ||
weth: "0xd0a1e359811322d97991e03f863a0c30c2cf029c" | ||
mainnet: | ||
aave_lending_pool_v2: "0xB53C1a33016B2DC2fF3653530bfF1848a515c8c5" | ||
weth: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" | ||
wallets: | ||
from_key: ${PRIVATE_KEY} | ||
from_mnemonic: ${MNEMONIC} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
pragma solidity ^0.4.19; | ||
|
||
interface WethInterface { | ||
function allowance(address owner, address spender) external view returns (uint256 remaining); | ||
function approve(address spender, uint256 value) external returns (bool success); | ||
function balanceOf(address owner) external view returns (uint256 balance); | ||
function decimals() external view returns (uint8 decimalPlaces); | ||
function name() external view returns (string memory tokenName); | ||
function symbol() external view returns (string memory tokenSymbol); | ||
function totalSupply() external view returns (uint256 totalTokensIssued); | ||
function transfer(address to, uint256 value) external returns (bool success); | ||
function transferFrom(address from, address to, uint256 value) external returns (bool success); | ||
function deposit() external; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
from brownie import FlashloanV2, accounts | ||
from brownie import FlashloanV2, accounts, config, network | ||
|
||
AAVE_LENDING_POOL_ADDRESS_PROVIDER = "0xB53C1a33016B2DC2fF3653530bfF1848a515c8c5" | ||
# AAVE_LENDING_POOL_ADDRESS_PROVIDER = "0xB53C1a33016B2DC2fF3653530bfF1848a515c8c5" | ||
|
||
|
||
def main(): | ||
""" | ||
Deploy a `FlashloanV2` contract from `accounts[0]`. | ||
""" | ||
|
||
acct = accounts.load() # add your keystore ID as an argument to this call | ||
acct = accounts.add( | ||
config["wallets"]["from_key"] | ||
) # add your keystore ID as an argument to this call | ||
|
||
flashloan = FlashloanV2.deploy(AAVE_LENDING_POOL_ADDRESS_PROVIDER, {"from": acct}) | ||
flashloan = FlashloanV2.deploy( | ||
config["networks"][network.show_active()]["aave_lending_pool_v2"], | ||
{"from": acct}, | ||
) | ||
return flashloan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from brownie import accounts, config, network, interface | ||
|
||
|
||
def main(): | ||
""" | ||
Runs the get_weth function to get WETH | ||
""" | ||
get_weth() | ||
|
||
|
||
def get_weth(): | ||
""" | ||
Mints WETH by depositing ETH. | ||
""" | ||
acct = accounts.add( | ||
config["wallets"]["from_key"] | ||
) # add your keystore ID as an argument to this call | ||
weth = interface.WethInterface(config["networks"][network.show_active()]["weth"]) | ||
tx = weth.deposit({"from": acct, "value": 1000000000000000000}) | ||
print("Received 1 WETH") | ||
return tx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from brownie import FlashloanV2, accounts, config, network, interface | ||
|
||
MINIMUM_FLASHLOAN_WETH_BALANCE = 500000000000000000 | ||
ETHERSCAN_TX_URL = "https://kovan.etherscan.io/tx/{}" | ||
|
||
|
||
def main(): | ||
""" | ||
Executes the funcitonality of the flash loan. | ||
""" | ||
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"]) | ||
# We need to fund it if it doesn't have any token to fund! | ||
if weth.balanceOf(flashloan) < MINIMUM_FLASHLOAN_WETH_BALANCE: | ||
print("Funding Flashloan contract with WETH...") | ||
weth.transfer(flashloan, "1 ether", {"from": acct}) | ||
print("Executing Flashloan...") | ||
tx = flashloan.flashloan(weth, {"from": acct}) | ||
print("You did it! View your tx here: " + ETHERSCAN_TX_URL.format(tx.txid)) | ||
return flashloan |