Repository files navigation

Getting Started

First rename the .env.example file in this directory to .env. Replace the API keys as needed.

After adding your api keys, run the following command from your terminal.

source .env

This command allows brownie config to access your environment variables.

Scripts to AAVE Token balances

Run the following command to get token balances for all aave tokens in your account.

brownie run scripts/aave/aave_balances.py

Output:

Browniev1.19.1-PythondevelopmentframeworkforEthereumRushProjectistheactiveproject.
Running'scripts/aave/aave_balances.py::main'...
TokensinAccount====================================================================================================indexTokenNamebalanceaddress0AAVE1000000000000000000000x63242B9Bd3C22f18706d5c4E627B4735973f1f071DAI100000000000000000000000xDF1742fE5b0bFc12331D8EAec6b478DfDbD314642LINK10000000000000000000000x07C725d58437504CA5f814AE406e70E21C5e8e9e3EURS10000000xaA63E0C86b531E2eDFE9F91F6436dF20C301963D4USDC100000000000xA2025B15a1757311bfD68cb14eaeFCc237AF5b435USDT100000000000xC2C527C0CACF457746Bd31B2a698Fe89de2b6d496WETH00x2e3A2fb8473316A02b8A297B982498E661E1f6f57WBTC2000000000x8869DFd060c682675c2A8aE5B21F2cF738A0E3CEInterestaTokensinAccount====================================================================================================indexTokenNamebalanceaddress0aAAVE00xC4bf7684e627ee069e9873B70dD0a8a1241bf72c1aDAI00x310839bE20Fc6a8A89f33A59C7D5fC651365068f2aLINK00x6A639d29454287B3cBB632Aa9f93bfB89E3fd18f3aEURS00xc31E63CB07209DFD2c7Edb3FB385331be2a172094aUSDC00x1Ee669290939f8a8864497Af3BC83728715265FF5aUSDT00x73258E6fb96ecAc8a979826d503B45803a382d686aWETH00x27B4692C93959048833f40702b22FE3578E777597aWBTC2000000000xc0ac343EA11A8D05AAC3c5186850A659dD40B81BStableDebtTokensinAccount====================================================================================================indexTokenNamebalanceaddress0stableDebtAAVE00x4a8aF512B73Fd896C8877cE0Ebed19b0a11B593C1stableDebtDAI00xbaBd1C3912713d598CA2E6DE3303fC59b19d0B0F2stableDebtLINK00x4f094AB301C8787F0d06753CA3238bfA9CFB9c913stableDebtEURS00x512ad2D2fb3Bef82ca0A15d4dE6544246e2D32c74stableDebtUSDC00xF04958AeA8b7F24Db19772f84d7c2aC801D9Cf8b5stableDebtUSDT00x7720C270Fa5d8234f0DFfd2523C64FdeB333Fa506stableDebtWBTC00x15FF4188463c69FD18Ea39F68A0C9B730E23dE817stableDebtWETH00xCAF956bD3B3113Db89C0584Ef3B562153faB87D5VariableDebtTokensinAccount====================================================================================================indexTokenNamebalanceaddress0variableDebtAAVE00xad958444c255a71C659f7c30e18AFafdE910EB5a1variableDebtDAI00xEa5A7CB3BDF6b2A8541bd50aFF270453F1505A722variableDebtLINK00x593D1bB0b6052FB6c3423C42FA62275b3D95a9433variableDebtEURS00x257b4a23b3026E04790c39fD3Edd7101E5F311924variableDebtUSDC00x3e491EB1A98cD42F9BBa388076Fd7a74B3470CA05variableDebtUSDT00x45c3965f6FAbf2fB04e3FE019853813B2B7cC3A36variableDebtWBTC00x480B8b39d1465b8049fbf03b8E0a072Ab7C9A4227variableDebtWETH2062701383561597470x2b848bA14583fA79519Ee71E7038D0d1061cd0F1

If you set up your .env you should see this from your terminal.

Deploying Flashloan Contracts

Keep in mind that all the scripts you will be running for this demo are found in /scripts/aave directory. Read through them to see what they are doing.

The following script will deploy two flashloan contracts. One will be used to flashloan one token at a time SimpleFlashLoan, the other will be used to combine multiple tokens in one flashloan transaction FlashLoan.

brownie run scripts/aave/deploy_flashloan.py

Ouput:

Browniev1.19.1-PythondevelopmentframeworkforEthereumRushProjectistheactiveproject.
Running'scripts/aave/deploy_flashloan.py::main'...
DeployingSimpleRushflashloanreceivercontract ...
===============================================Transactionsent: 0x0a39f260819c1e3a9d71010ccc64ba9bddc4f2d677d0d94b67c5fac9939cb520Gasprice: 36.756769064gweiGaslimit: 541641Nonce: 90FlashLoan.constructorconfirmedBlock: 8282174Gasused: 492401 (90.91%)
FlashLoandeployedat: 0xD86bF68ADaf5C6389F1e7379700B01217f3f8129ViewcontractonOptimismGoerli: https://goerli.etherscan.io/address/0xD86bF68ADaf5C6389F1e7379700B01217f3f8129TransactionwasMined---------------------TxHash: 0x0a39f260819c1e3a9d71010ccc64ba9bddc4f2d677d0d94b67c5fac9939cb520From: 0xFE948CB2122FDD87bAf43dCe8aFa254B1242c199NewFlashLoanaddress: 0xD86bF68ADaf5C6389F1e7379700B01217f3f8129Block: 8282174GasUsed: 492401/541641 (90.9%)

Excecuting 1M USDC flashloan transaction

Checout out this transaction. After you deploy your contracts, you are ready to submit transactions. The flashloan contracts will receive and repay your loan. Here's an example:

Run command on terminal.

brownie run scripts/aave/simple_flashloan.py

Output:

Browniev1.19.1-PythondevelopmentframeworkforEthereumRushProjectistheactiveproject.
Running'scripts/aave/simple_flashloan.py::main'...
Transactionsent: 0xe0298379f63293c6bb8ec2bfbd147684c3c73087e5ede19eb7409bcd844fcabbGasprice: 33.986319221gweiGaslimit: 37951Nonce: 93MintableERC20.transferconfirmedBlock: 8282256Gasused: 34501 (90.91%)
Transactionsent: 0x58180124eadc669c23c0cfa28053e0c79496b48713f0f160734710ace2b92577Gasprice: 32.188179381gweiGaslimit: 209116Nonce: 94TransactionconfirmedBlock: 8282267Gasused: 165364 (79.08%)
Congrats! Youhaveflippedaflashloan. Checkitout! https://goerli.etherscan.io/tx/0x58180124eadc669c23c0cfa28053e0c79496b48713f0f160734710ace2b92577

Publish and Verify Contract on Etherscan

Brownie has a simple way to quickly instantly verify your contract on etherscan. Run the following command.

>>>contract=RushFlashLoan.at("0x9db7BcB878E9b3eFDf8FAfcfbbF11a54d80f089c")
>>>contract<RushFlashLoanContract'0x9db7BcB878E9b3eFDf8FAfcfbbF11a54d80f089c'>>>>RushFlashLoan.publish_source(contract)
Verificationsubmittedsuccessfully. Waitingforresult...
Verificationcomplete. Result: Pass-VerifiedTrue

Trasaction breakdown

Here the flashloan contract is requesting 1M from the pool provider.

frombrownieimportaccounts, config, network, interface, RushSimpleFlashLoanfromscripts.aave.helper_functionsimportget_address_provider, get_token, get_accounttx_url="https://goerli.etherscan.io/tx/{}"pool=interface.IPool(get_address_provider().getPool())
flashloan_receiver=RushSimpleFlashLoan[len(RushSimpleFlashLoan) -1]
usdc=get_token("USDC")
usdc_amount=1_000_000*10**usdc.decimals()
defrun_flashloan():
dev=get_account()
receiver=flashloan_receiver.addressassets=usdc.addressamount=usdc_amount# 'flashLoanSimple': "0x42b0b77c"params="0x42b0b77c"referral=0tx=pool.flashLoanSimple(receiver, assets, amount, params, referral, {"from": dev})

Multi Token Flashloans

If you run this command, you can flashloan over 100M+ in tokens. Checkout this transaction.

brownie run scripts/aave/multi_flashloan.py
Browniev1.19.1-PythondevelopmentframeworkforEthereumRushProjectistheactiveproject.
Running'scripts/aave/multi_flashloan.py::main'...
Transactionsent: 0x310974980351e66748421d1ef01b3d940202090525a99630e03150cb9aeae859Gasprice: 4.924637698gweiGaslimit: 1578971Nonce: 83TransactionconfirmedBlock: 8265853Gasused: 1113994 (70.55%)
TransactionconfirmedBlock: 8265853Gasused: 1113994 (70.55%)
Congrats! Youhaveflippedaflashloan. Checkitout! https://goerli.etherscan.io/tx/0x310974980351e66748421d1ef01b3d940202090525a99630e03150cb9aeae859

Go to /scripts/aave/multi_flashloan.py and adjust token amounts. Try it out or yourself.

Support me

If you want to support me, you can. I accept ETH. Currently struggling to find a job.

ETH: msaki.eth 0x04655832bcb0a9a0be8c5ab71e4d311464c97af5

BTC: bc1qafvljh25wxd7ser9vsawzm95aaju883r9twd0p

DOGE: D5y6zYKN4WsWCr4YmnKhAFqCCFC31AN3We

⚠️ WARNING

| I should warn you. You will not make any profits from using flashloans in the current state on this repo.

About

A guide on how to complete flashloan transactions. Runner up winner of Aave Grants Dao Forex Tools 2022, ETHGlobal at ETHOnline 2022.

Topics

Resources

Stars

10 stars

Watchers

2 watching

Forks

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Repository files navigation

Getting Started

First rename the .env.example file in this directory to .env. Replace the API keys as needed.

After adding your api keys, run the following command from your terminal.

source .env

This command allows brownie config to access your environment variables.

Scripts to AAVE Token balances

Run the following command to get token balances for all aave tokens in your account.

brownie run scripts/aave/aave_balances.py

Output:

Browniev1.19.1-PythondevelopmentframeworkforEthereumRushProjectistheactiveproject.
Running'scripts/aave/aave_balances.py::main'...
TokensinAccount====================================================================================================indexTokenNamebalanceaddress0AAVE1000000000000000000000x63242B9Bd3C22f18706d5c4E627B4735973f1f071DAI100000000000000000000000xDF1742fE5b0bFc12331D8EAec6b478DfDbD314642LINK10000000000000000000000x07C725d58437504CA5f814AE406e70E21C5e8e9e3EURS10000000xaA63E0C86b531E2eDFE9F91F6436dF20C301963D4USDC100000000000xA2025B15a1757311bfD68cb14eaeFCc237AF5b435USDT100000000000xC2C527C0CACF457746Bd31B2a698Fe89de2b6d496WETH00x2e3A2fb8473316A02b8A297B982498E661E1f6f57WBTC2000000000x8869DFd060c682675c2A8aE5B21F2cF738A0E3CEInterestaTokensinAccount====================================================================================================indexTokenNamebalanceaddress0aAAVE00xC4bf7684e627ee069e9873B70dD0a8a1241bf72c1aDAI00x310839bE20Fc6a8A89f33A59C7D5fC651365068f2aLINK00x6A639d29454287B3cBB632Aa9f93bfB89E3fd18f3aEURS00xc31E63CB07209DFD2c7Edb3FB385331be2a172094aUSDC00x1Ee669290939f8a8864497Af3BC83728715265FF5aUSDT00x73258E6fb96ecAc8a979826d503B45803a382d686aWETH00x27B4692C93959048833f40702b22FE3578E777597aWBTC2000000000xc0ac343EA11A8D05AAC3c5186850A659dD40B81BStableDebtTokensinAccount====================================================================================================indexTokenNamebalanceaddress0stableDebtAAVE00x4a8aF512B73Fd896C8877cE0Ebed19b0a11B593C1stableDebtDAI00xbaBd1C3912713d598CA2E6DE3303fC59b19d0B0F2stableDebtLINK00x4f094AB301C8787F0d06753CA3238bfA9CFB9c913stableDebtEURS00x512ad2D2fb3Bef82ca0A15d4dE6544246e2D32c74stableDebtUSDC00xF04958AeA8b7F24Db19772f84d7c2aC801D9Cf8b5stableDebtUSDT00x7720C270Fa5d8234f0DFfd2523C64FdeB333Fa506stableDebtWBTC00x15FF4188463c69FD18Ea39F68A0C9B730E23dE817stableDebtWETH00xCAF956bD3B3113Db89C0584Ef3B562153faB87D5VariableDebtTokensinAccount====================================================================================================indexTokenNamebalanceaddress0variableDebtAAVE00xad958444c255a71C659f7c30e18AFafdE910EB5a1variableDebtDAI00xEa5A7CB3BDF6b2A8541bd50aFF270453F1505A722variableDebtLINK00x593D1bB0b6052FB6c3423C42FA62275b3D95a9433variableDebtEURS00x257b4a23b3026E04790c39fD3Edd7101E5F311924variableDebtUSDC00x3e491EB1A98cD42F9BBa388076Fd7a74B3470CA05variableDebtUSDT00x45c3965f6FAbf2fB04e3FE019853813B2B7cC3A36variableDebtWBTC00x480B8b39d1465b8049fbf03b8E0a072Ab7C9A4227variableDebtWETH2062701383561597470x2b848bA14583fA79519Ee71E7038D0d1061cd0F1

If you set up your .env you should see this from your terminal.

Deploying Flashloan Contracts

Keep in mind that all the scripts you will be running for this demo are found in /scripts/aave directory. Read through them to see what they are doing.

The following script will deploy two flashloan contracts. One will be used to flashloan one token at a time SimpleFlashLoan, the other will be used to combine multiple tokens in one flashloan transaction FlashLoan.

brownie run scripts/aave/deploy_flashloan.py

Ouput:

Browniev1.19.1-PythondevelopmentframeworkforEthereumRushProjectistheactiveproject.
Running'scripts/aave/deploy_flashloan.py::main'...
DeployingSimpleRushflashloanreceivercontract ...
===============================================Transactionsent: 0x0a39f260819c1e3a9d71010ccc64ba9bddc4f2d677d0d94b67c5fac9939cb520Gasprice: 36.756769064gweiGaslimit: 541641Nonce: 90FlashLoan.constructorconfirmedBlock: 8282174Gasused: 492401 (90.91%)
FlashLoandeployedat: 0xD86bF68ADaf5C6389F1e7379700B01217f3f8129ViewcontractonOptimismGoerli: https://goerli.etherscan.io/address/0xD86bF68ADaf5C6389F1e7379700B01217f3f8129TransactionwasMined---------------------TxHash: 0x0a39f260819c1e3a9d71010ccc64ba9bddc4f2d677d0d94b67c5fac9939cb520From: 0xFE948CB2122FDD87bAf43dCe8aFa254B1242c199NewFlashLoanaddress: 0xD86bF68ADaf5C6389F1e7379700B01217f3f8129Block: 8282174GasUsed: 492401/541641 (90.9%)

Excecuting 1M USDC flashloan transaction

Checout out this transaction. After you deploy your contracts, you are ready to submit transactions. The flashloan contracts will receive and repay your loan. Here's an example:

Run command on terminal.

brownie run scripts/aave/simple_flashloan.py

Output:

Browniev1.19.1-PythondevelopmentframeworkforEthereumRushProjectistheactiveproject.
Running'scripts/aave/simple_flashloan.py::main'...
Transactionsent: 0xe0298379f63293c6bb8ec2bfbd147684c3c73087e5ede19eb7409bcd844fcabbGasprice: 33.986319221gweiGaslimit: 37951Nonce: 93MintableERC20.transferconfirmedBlock: 8282256Gasused: 34501 (90.91%)
Transactionsent: 0x58180124eadc669c23c0cfa28053e0c79496b48713f0f160734710ace2b92577Gasprice: 32.188179381gweiGaslimit: 209116Nonce: 94TransactionconfirmedBlock: 8282267Gasused: 165364 (79.08%)
Congrats! Youhaveflippedaflashloan. Checkitout! https://goerli.etherscan.io/tx/0x58180124eadc669c23c0cfa28053e0c79496b48713f0f160734710ace2b92577

Publish and Verify Contract on Etherscan

Brownie has a simple way to quickly instantly verify your contract on etherscan. Run the following command.

>>>contract=RushFlashLoan.at("0x9db7BcB878E9b3eFDf8FAfcfbbF11a54d80f089c")
>>>contract<RushFlashLoanContract'0x9db7BcB878E9b3eFDf8FAfcfbbF11a54d80f089c'>>>>RushFlashLoan.publish_source(contract)
Verificationsubmittedsuccessfully. Waitingforresult...
Verificationcomplete. Result: Pass-VerifiedTrue

Trasaction breakdown

Here the flashloan contract is requesting 1M from the pool provider.

frombrownieimportaccounts, config, network, interface, RushSimpleFlashLoanfromscripts.aave.helper_functionsimportget_address_provider, get_token, get_accounttx_url="https://goerli.etherscan.io/tx/{}"pool=interface.IPool(get_address_provider().getPool())
flashloan_receiver=RushSimpleFlashLoan[len(RushSimpleFlashLoan) -1]
usdc=get_token("USDC")
usdc_amount=1_000_000*10**usdc.decimals()
defrun_flashloan():
dev=get_account()
receiver=flashloan_receiver.addressassets=usdc.addressamount=usdc_amount# 'flashLoanSimple': "0x42b0b77c"params="0x42b0b77c"referral=0tx=pool.flashLoanSimple(receiver, assets, amount, params, referral, {"from": dev})

Multi Token Flashloans

If you run this command, you can flashloan over 100M+ in tokens. Checkout this transaction.

brownie run scripts/aave/multi_flashloan.py
Browniev1.19.1-PythondevelopmentframeworkforEthereumRushProjectistheactiveproject.
Running'scripts/aave/multi_flashloan.py::main'...
Transactionsent: 0x310974980351e66748421d1ef01b3d940202090525a99630e03150cb9aeae859Gasprice: 4.924637698gweiGaslimit: 1578971Nonce: 83TransactionconfirmedBlock: 8265853Gasused: 1113994 (70.55%)
TransactionconfirmedBlock: 8265853Gasused: 1113994 (70.55%)
Congrats! Youhaveflippedaflashloan. Checkitout! https://goerli.etherscan.io/tx/0x310974980351e66748421d1ef01b3d940202090525a99630e03150cb9aeae859

Go to /scripts/aave/multi_flashloan.py and adjust token amounts. Try it out or yourself.

Support me

If you want to support me, you can. I accept ETH. Currently struggling to find a job.

ETH: msaki.eth 0x04655832bcb0a9a0be8c5ab71e4d311464c97af5

BTC: bc1qafvljh25wxd7ser9vsawzm95aaju883r9twd0p

DOGE: D5y6zYKN4WsWCr4YmnKhAFqCCFC31AN3We

⚠️ WARNING

| I should warn you. You will not make any profits from using flashloans in the current state on this repo.

About

A guide on how to complete flashloan transactions. Runner up winner of Aave Grants Dao Forex Tools 2022, ETHGlobal at ETHOnline 2022.

Topics

Resources

Stars

10 stars

Watchers

2 watching

Forks

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

Getting Started

First rename the .env.example file in this directory to .env. Replace the API keys as needed.

After adding your api keys, run the following command from your terminal.

source .env

This command allows brownie config to access your environment variables.

Scripts to AAVE Token balances

Run the following command to get token balances for all aave tokens in your account.

brownie run scripts/aave/aave_balances.py

Output:

Browniev1.19.1-PythondevelopmentframeworkforEthereumRushProjectistheactiveproject.
Running'scripts/aave/aave_balances.py::main'...
TokensinAccount====================================================================================================indexTokenNamebalanceaddress0AAVE1000000000000000000000x63242B9Bd3C22f18706d5c4E627B4735973f1f071DAI100000000000000000000000xDF1742fE5b0bFc12331D8EAec6b478DfDbD314642LINK10000000000000000000000x07C725d58437504CA5f814AE406e70E21C5e8e9e3EURS10000000xaA63E0C86b531E2eDFE9F91F6436dF20C301963D4USDC100000000000xA2025B15a1757311bfD68cb14eaeFCc237AF5b435USDT100000000000xC2C527C0CACF457746Bd31B2a698Fe89de2b6d496WETH00x2e3A2fb8473316A02b8A297B982498E661E1f6f57WBTC2000000000x8869DFd060c682675c2A8aE5B21F2cF738A0E3CEInterestaTokensinAccount====================================================================================================indexTokenNamebalanceaddress0aAAVE00xC4bf7684e627ee069e9873B70dD0a8a1241bf72c1aDAI00x310839bE20Fc6a8A89f33A59C7D5fC651365068f2aLINK00x6A639d29454287B3cBB632Aa9f93bfB89E3fd18f3aEURS00xc31E63CB07209DFD2c7Edb3FB385331be2a172094aUSDC00x1Ee669290939f8a8864497Af3BC83728715265FF5aUSDT00x73258E6fb96ecAc8a979826d503B45803a382d686aWETH00x27B4692C93959048833f40702b22FE3578E777597aWBTC2000000000xc0ac343EA11A8D05AAC3c5186850A659dD40B81BStableDebtTokensinAccount====================================================================================================indexTokenNamebalanceaddress0stableDebtAAVE00x4a8aF512B73Fd896C8877cE0Ebed19b0a11B593C1stableDebtDAI00xbaBd1C3912713d598CA2E6DE3303fC59b19d0B0F2stableDebtLINK00x4f094AB301C8787F0d06753CA3238bfA9CFB9c913stableDebtEURS00x512ad2D2fb3Bef82ca0A15d4dE6544246e2D32c74stableDebtUSDC00xF04958AeA8b7F24Db19772f84d7c2aC801D9Cf8b5stableDebtUSDT00x7720C270Fa5d8234f0DFfd2523C64FdeB333Fa506stableDebtWBTC00x15FF4188463c69FD18Ea39F68A0C9B730E23dE817stableDebtWETH00xCAF956bD3B3113Db89C0584Ef3B562153faB87D5VariableDebtTokensinAccount====================================================================================================indexTokenNamebalanceaddress0variableDebtAAVE00xad958444c255a71C659f7c30e18AFafdE910EB5a1variableDebtDAI00xEa5A7CB3BDF6b2A8541bd50aFF270453F1505A722variableDebtLINK00x593D1bB0b6052FB6c3423C42FA62275b3D95a9433variableDebtEURS00x257b4a23b3026E04790c39fD3Edd7101E5F311924variableDebtUSDC00x3e491EB1A98cD42F9BBa388076Fd7a74B3470CA05variableDebtUSDT00x45c3965f6FAbf2fB04e3FE019853813B2B7cC3A36variableDebtWBTC00x480B8b39d1465b8049fbf03b8E0a072Ab7C9A4227variableDebtWETH2062701383561597470x2b848bA14583fA79519Ee71E7038D0d1061cd0F1

If you set up your .env you should see this from your terminal.

Deploying Flashloan Contracts

Keep in mind that all the scripts you will be running for this demo are found in /scripts/aave directory. Read through them to see what they are doing.

The following script will deploy two flashloan contracts. One will be used to flashloan one token at a time SimpleFlashLoan, the other will be used to combine multiple tokens in one flashloan transaction FlashLoan.

brownie run scripts/aave/deploy_flashloan.py

Ouput:

Browniev1.19.1-PythondevelopmentframeworkforEthereumRushProjectistheactiveproject.
Running'scripts/aave/deploy_flashloan.py::main'...
DeployingSimpleRushflashloanreceivercontract ...
===============================================Transactionsent: 0x0a39f260819c1e3a9d71010ccc64ba9bddc4f2d677d0d94b67c5fac9939cb520Gasprice: 36.756769064gweiGaslimit: 541641Nonce: 90FlashLoan.constructorconfirmedBlock: 8282174Gasused: 492401 (90.91%)
FlashLoandeployedat: 0xD86bF68ADaf5C6389F1e7379700B01217f3f8129ViewcontractonOptimismGoerli: https://goerli.etherscan.io/address/0xD86bF68ADaf5C6389F1e7379700B01217f3f8129TransactionwasMined---------------------TxHash: 0x0a39f260819c1e3a9d71010ccc64ba9bddc4f2d677d0d94b67c5fac9939cb520From: 0xFE948CB2122FDD87bAf43dCe8aFa254B1242c199NewFlashLoanaddress: 0xD86bF68ADaf5C6389F1e7379700B01217f3f8129Block: 8282174GasUsed: 492401/541641 (90.9%)

Excecuting 1M USDC flashloan transaction

Checout out this transaction. After you deploy your contracts, you are ready to submit transactions. The flashloan contracts will receive and repay your loan. Here's an example:

Run command on terminal.

brownie run scripts/aave/simple_flashloan.py

Output:

Browniev1.19.1-PythondevelopmentframeworkforEthereumRushProjectistheactiveproject.
Running'scripts/aave/simple_flashloan.py::main'...
Transactionsent: 0xe0298379f63293c6bb8ec2bfbd147684c3c73087e5ede19eb7409bcd844fcabbGasprice: 33.986319221gweiGaslimit: 37951Nonce: 93MintableERC20.transferconfirmedBlock: 8282256Gasused: 34501 (90.91%)
Transactionsent: 0x58180124eadc669c23c0cfa28053e0c79496b48713f0f160734710ace2b92577Gasprice: 32.188179381gweiGaslimit: 209116Nonce: 94TransactionconfirmedBlock: 8282267Gasused: 165364 (79.08%)
Congrats! Youhaveflippedaflashloan. Checkitout! https://goerli.etherscan.io/tx/0x58180124eadc669c23c0cfa28053e0c79496b48713f0f160734710ace2b92577

Publish and Verify Contract on Etherscan

Brownie has a simple way to quickly instantly verify your contract on etherscan. Run the following command.

>>>contract=RushFlashLoan.at("0x9db7BcB878E9b3eFDf8FAfcfbbF11a54d80f089c")
>>>contract<RushFlashLoanContract'0x9db7BcB878E9b3eFDf8FAfcfbbF11a54d80f089c'>>>>RushFlashLoan.publish_source(contract)
Verificationsubmittedsuccessfully. Waitingforresult...
Verificationcomplete. Result: Pass-VerifiedTrue

Trasaction breakdown

Here the flashloan contract is requesting 1M from the pool provider.

frombrownieimportaccounts, config, network, interface, RushSimpleFlashLoanfromscripts.aave.helper_functionsimportget_address_provider, get_token, get_accounttx_url="https://goerli.etherscan.io/tx/{}"pool=interface.IPool(get_address_provider().getPool())
flashloan_receiver=RushSimpleFlashLoan[len(RushSimpleFlashLoan) -1]
usdc=get_token("USDC")
usdc_amount=1_000_000*10**usdc.decimals()
defrun_flashloan():
dev=get_account()
receiver=flashloan_receiver.addressassets=usdc.addressamount=usdc_amount# 'flashLoanSimple': "0x42b0b77c"params="0x42b0b77c"referral=0tx=pool.flashLoanSimple(receiver, assets, amount, params, referral, {"from": dev})

Multi Token Flashloans

If you run this command, you can flashloan over 100M+ in tokens. Checkout this transaction.

brownie run scripts/aave/multi_flashloan.py
Browniev1.19.1-PythondevelopmentframeworkforEthereumRushProjectistheactiveproject.
Running'scripts/aave/multi_flashloan.py::main'...
Transactionsent: 0x310974980351e66748421d1ef01b3d940202090525a99630e03150cb9aeae859Gasprice: 4.924637698gweiGaslimit: 1578971Nonce: 83TransactionconfirmedBlock: 8265853Gasused: 1113994 (70.55%)
TransactionconfirmedBlock: 8265853Gasused: 1113994 (70.55%)
Congrats! Youhaveflippedaflashloan. Checkitout! https://goerli.etherscan.io/tx/0x310974980351e66748421d1ef01b3d940202090525a99630e03150cb9aeae859

Go to /scripts/aave/multi_flashloan.py and adjust token amounts. Try it out or yourself.

Support me

If you want to support me, you can. I accept ETH. Currently struggling to find a job.

ETH: msaki.eth 0x04655832bcb0a9a0be8c5ab71e4d311464c97af5

BTC: bc1qafvljh25wxd7ser9vsawzm95aaju883r9twd0p

DOGE: D5y6zYKN4WsWCr4YmnKhAFqCCFC31AN3We

⚠️ WARNING

| I should warn you. You will not make any profits from using flashloans in the current state on this repo.

About

A guide on how to complete flashloan transactions. Runner up winner of Aave Grants Dao Forex Tools 2022, ETHGlobal at ETHOnline 2022.

Topics

Resources

Stars

10 stars

Watchers

2 watching

Forks

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

Getting Started

First rename the .env.example file in this directory to .env. Replace the API keys as needed.

After adding your api keys, run the following command from your terminal.

source .env

This command allows brownie config to access your environment variables.

Scripts to AAVE Token balances

Run the following command to get token balances for all aave tokens in your account.

brownie run scripts/aave/aave_balances.py

Output:

Browniev1.19.1-PythondevelopmentframeworkforEthereumRushProjectistheactiveproject.
Running'scripts/aave/aave_balances.py::main'...
TokensinAccount====================================================================================================indexTokenNamebalanceaddress0AAVE1000000000000000000000x63242B9Bd3C22f18706d5c4E627B4735973f1f071DAI100000000000000000000000xDF1742fE5b0bFc12331D8EAec6b478DfDbD314642LINK10000000000000000000000x07C725d58437504CA5f814AE406e70E21C5e8e9e3EURS10000000xaA63E0C86b531E2eDFE9F91F6436dF20C301963D4USDC100000000000xA2025B15a1757311bfD68cb14eaeFCc237AF5b435USDT100000000000xC2C527C0CACF457746Bd31B2a698Fe89de2b6d496WETH00x2e3A2fb8473316A02b8A297B982498E661E1f6f57WBTC2000000000x8869DFd060c682675c2A8aE5B21F2cF738A0E3CEInterestaTokensinAccount====================================================================================================indexTokenNamebalanceaddress0aAAVE00xC4bf7684e627ee069e9873B70dD0a8a1241bf72c1aDAI00x310839bE20Fc6a8A89f33A59C7D5fC651365068f2aLINK00x6A639d29454287B3cBB632Aa9f93bfB89E3fd18f3aEURS00xc31E63CB07209DFD2c7Edb3FB385331be2a172094aUSDC00x1Ee669290939f8a8864497Af3BC83728715265FF5aUSDT00x73258E6fb96ecAc8a979826d503B45803a382d686aWETH00x27B4692C93959048833f40702b22FE3578E777597aWBTC2000000000xc0ac343EA11A8D05AAC3c5186850A659dD40B81BStableDebtTokensinAccount====================================================================================================indexTokenNamebalanceaddress0stableDebtAAVE00x4a8aF512B73Fd896C8877cE0Ebed19b0a11B593C1stableDebtDAI00xbaBd1C3912713d598CA2E6DE3303fC59b19d0B0F2stableDebtLINK00x4f094AB301C8787F0d06753CA3238bfA9CFB9c913stableDebtEURS00x512ad2D2fb3Bef82ca0A15d4dE6544246e2D32c74stableDebtUSDC00xF04958AeA8b7F24Db19772f84d7c2aC801D9Cf8b5stableDebtUSDT00x7720C270Fa5d8234f0DFfd2523C64FdeB333Fa506stableDebtWBTC00x15FF4188463c69FD18Ea39F68A0C9B730E23dE817stableDebtWETH00xCAF956bD3B3113Db89C0584Ef3B562153faB87D5VariableDebtTokensinAccount====================================================================================================indexTokenNamebalanceaddress0variableDebtAAVE00xad958444c255a71C659f7c30e18AFafdE910EB5a1variableDebtDAI00xEa5A7CB3BDF6b2A8541bd50aFF270453F1505A722variableDebtLINK00x593D1bB0b6052FB6c3423C42FA62275b3D95a9433variableDebtEURS00x257b4a23b3026E04790c39fD3Edd7101E5F311924variableDebtUSDC00x3e491EB1A98cD42F9BBa388076Fd7a74B3470CA05variableDebtUSDT00x45c3965f6FAbf2fB04e3FE019853813B2B7cC3A36variableDebtWBTC00x480B8b39d1465b8049fbf03b8E0a072Ab7C9A4227variableDebtWETH2062701383561597470x2b848bA14583fA79519Ee71E7038D0d1061cd0F1

If you set up your .env you should see this from your terminal.

Deploying Flashloan Contracts

Keep in mind that all the scripts you will be running for this demo are found in /scripts/aave directory. Read through them to see what they are doing.

The following script will deploy two flashloan contracts. One will be used to flashloan one token at a time SimpleFlashLoan, the other will be used to combine multiple tokens in one flashloan transaction FlashLoan.

brownie run scripts/aave/deploy_flashloan.py

Ouput:

Browniev1.19.1-PythondevelopmentframeworkforEthereumRushProjectistheactiveproject.
Running'scripts/aave/deploy_flashloan.py::main'...
DeployingSimpleRushflashloanreceivercontract ...
===============================================Transactionsent: 0x0a39f260819c1e3a9d71010ccc64ba9bddc4f2d677d0d94b67c5fac9939cb520Gasprice: 36.756769064gweiGaslimit: 541641Nonce: 90FlashLoan.constructorconfirmedBlock: 8282174Gasused: 492401 (90.91%)
FlashLoandeployedat: 0xD86bF68ADaf5C6389F1e7379700B01217f3f8129ViewcontractonOptimismGoerli: https://goerli.etherscan.io/address/0xD86bF68ADaf5C6389F1e7379700B01217f3f8129TransactionwasMined---------------------TxHash: 0x0a39f260819c1e3a9d71010ccc64ba9bddc4f2d677d0d94b67c5fac9939cb520From: 0xFE948CB2122FDD87bAf43dCe8aFa254B1242c199NewFlashLoanaddress: 0xD86bF68ADaf5C6389F1e7379700B01217f3f8129Block: 8282174GasUsed: 492401/541641 (90.9%)

Excecuting 1M USDC flashloan transaction

Checout out this transaction. After you deploy your contracts, you are ready to submit transactions. The flashloan contracts will receive and repay your loan. Here's an example:

Run command on terminal.

brownie run scripts/aave/simple_flashloan.py

Output:

Browniev1.19.1-PythondevelopmentframeworkforEthereumRushProjectistheactiveproject.
Running'scripts/aave/simple_flashloan.py::main'...
Transactionsent: 0xe0298379f63293c6bb8ec2bfbd147684c3c73087e5ede19eb7409bcd844fcabbGasprice: 33.986319221gweiGaslimit: 37951Nonce: 93MintableERC20.transferconfirmedBlock: 8282256Gasused: 34501 (90.91%)
Transactionsent: 0x58180124eadc669c23c0cfa28053e0c79496b48713f0f160734710ace2b92577Gasprice: 32.188179381gweiGaslimit: 209116Nonce: 94TransactionconfirmedBlock: 8282267Gasused: 165364 (79.08%)
Congrats! Youhaveflippedaflashloan. Checkitout! https://goerli.etherscan.io/tx/0x58180124eadc669c23c0cfa28053e0c79496b48713f0f160734710ace2b92577

Publish and Verify Contract on Etherscan

Brownie has a simple way to quickly instantly verify your contract on etherscan. Run the following command.

>>>contract=RushFlashLoan.at("0x9db7BcB878E9b3eFDf8FAfcfbbF11a54d80f089c")
>>>contract<RushFlashLoanContract'0x9db7BcB878E9b3eFDf8FAfcfbbF11a54d80f089c'>>>>RushFlashLoan.publish_source(contract)
Verificationsubmittedsuccessfully. Waitingforresult...
Verificationcomplete. Result: Pass-VerifiedTrue

Trasaction breakdown

Here the flashloan contract is requesting 1M from the pool provider.

frombrownieimportaccounts, config, network, interface, RushSimpleFlashLoanfromscripts.aave.helper_functionsimportget_address_provider, get_token, get_accounttx_url="https://goerli.etherscan.io/tx/{}"pool=interface.IPool(get_address_provider().getPool())
flashloan_receiver=RushSimpleFlashLoan[len(RushSimpleFlashLoan) -1]
usdc=get_token("USDC")
usdc_amount=1_000_000*10**usdc.decimals()
defrun_flashloan():
dev=get_account()
receiver=flashloan_receiver.addressassets=usdc.addressamount=usdc_amount# 'flashLoanSimple': "0x42b0b77c"params="0x42b0b77c"referral=0tx=pool.flashLoanSimple(receiver, assets, amount, params, referral, {"from": dev})

Multi Token Flashloans

If you run this command, you can flashloan over 100M+ in tokens. Checkout this transaction.

brownie run scripts/aave/multi_flashloan.py
Browniev1.19.1-PythondevelopmentframeworkforEthereumRushProjectistheactiveproject.
Running'scripts/aave/multi_flashloan.py::main'...
Transactionsent: 0x310974980351e66748421d1ef01b3d940202090525a99630e03150cb9aeae859Gasprice: 4.924637698gweiGaslimit: 1578971Nonce: 83TransactionconfirmedBlock: 8265853Gasused: 1113994 (70.55%)
TransactionconfirmedBlock: 8265853Gasused: 1113994 (70.55%)
Congrats! Youhaveflippedaflashloan. Checkitout! https://goerli.etherscan.io/tx/0x310974980351e66748421d1ef01b3d940202090525a99630e03150cb9aeae859

Go to /scripts/aave/multi_flashloan.py and adjust token amounts. Try it out or yourself.

Support me

If you want to support me, you can. I accept ETH. Currently struggling to find a job.

ETH: msaki.eth 0x04655832bcb0a9a0be8c5ab71e4d311464c97af5

BTC: bc1qafvljh25wxd7ser9vsawzm95aaju883r9twd0p

DOGE: D5y6zYKN4WsWCr4YmnKhAFqCCFC31AN3We

⚠️ WARNING

| I should warn you. You will not make any profits from using flashloans in the current state on this repo.

About

A guide on how to complete flashloan transactions. Runner up winner of Aave Grants Dao Forex Tools 2022, ETHGlobal at ETHOnline 2022.

Topics

Resources

Stars

10 stars

Watchers

2 watching

Forks

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Repository files navigation

Getting Started

First rename the .env.example file in this directory to .env. Replace the API keys as needed.

After adding your api keys, run the following command from your terminal.

source .env

This command allows brownie config to access your environment variables.

Scripts to AAVE Token balances

Run the following command to get token balances for all aave tokens in your account.

brownie run scripts/aave/aave_balances.py

Output:

Browniev1.19.1-PythondevelopmentframeworkforEthereumRushProjectistheactiveproject.
Running'scripts/aave/aave_balances.py::main'...
TokensinAccount====================================================================================================indexTokenNamebalanceaddress0AAVE1000000000000000000000x63242B9Bd3C22f18706d5c4E627B4735973f1f071DAI100000000000000000000000xDF1742fE5b0bFc12331D8EAec6b478DfDbD314642LINK10000000000000000000000x07C725d58437504CA5f814AE406e70E21C5e8e9e3EURS10000000xaA63E0C86b531E2eDFE9F91F6436dF20C301963D4USDC100000000000xA2025B15a1757311bfD68cb14eaeFCc237AF5b435USDT100000000000xC2C527C0CACF457746Bd31B2a698Fe89de2b6d496WETH00x2e3A2fb8473316A02b8A297B982498E661E1f6f57WBTC2000000000x8869DFd060c682675c2A8aE5B21F2cF738A0E3CEInterestaTokensinAccount====================================================================================================indexTokenNamebalanceaddress0aAAVE00xC4bf7684e627ee069e9873B70dD0a8a1241bf72c1aDAI00x310839bE20Fc6a8A89f33A59C7D5fC651365068f2aLINK00x6A639d29454287B3cBB632Aa9f93bfB89E3fd18f3aEURS00xc31E63CB07209DFD2c7Edb3FB385331be2a172094aUSDC00x1Ee669290939f8a8864497Af3BC83728715265FF5aUSDT00x73258E6fb96ecAc8a979826d503B45803a382d686aWETH00x27B4692C93959048833f40702b22FE3578E777597aWBTC2000000000xc0ac343EA11A8D05AAC3c5186850A659dD40B81BStableDebtTokensinAccount====================================================================================================indexTokenNamebalanceaddress0stableDebtAAVE00x4a8aF512B73Fd896C8877cE0Ebed19b0a11B593C1stableDebtDAI00xbaBd1C3912713d598CA2E6DE3303fC59b19d0B0F2stableDebtLINK00x4f094AB301C8787F0d06753CA3238bfA9CFB9c913stableDebtEURS00x512ad2D2fb3Bef82ca0A15d4dE6544246e2D32c74stableDebtUSDC00xF04958AeA8b7F24Db19772f84d7c2aC801D9Cf8b5stableDebtUSDT00x7720C270Fa5d8234f0DFfd2523C64FdeB333Fa506stableDebtWBTC00x15FF4188463c69FD18Ea39F68A0C9B730E23dE817stableDebtWETH00xCAF956bD3B3113Db89C0584Ef3B562153faB87D5VariableDebtTokensinAccount====================================================================================================indexTokenNamebalanceaddress0variableDebtAAVE00xad958444c255a71C659f7c30e18AFafdE910EB5a1variableDebtDAI00xEa5A7CB3BDF6b2A8541bd50aFF270453F1505A722variableDebtLINK00x593D1bB0b6052FB6c3423C42FA62275b3D95a9433variableDebtEURS00x257b4a23b3026E04790c39fD3Edd7101E5F311924variableDebtUSDC00x3e491EB1A98cD42F9BBa388076Fd7a74B3470CA05variableDebtUSDT00x45c3965f6FAbf2fB04e3FE019853813B2B7cC3A36variableDebtWBTC00x480B8b39d1465b8049fbf03b8E0a072Ab7C9A4227variableDebtWETH2062701383561597470x2b848bA14583fA79519Ee71E7038D0d1061cd0F1

If you set up your .env you should see this from your terminal.

Deploying Flashloan Contracts

Keep in mind that all the scripts you will be running for this demo are found in /scripts/aave directory. Read through them to see what they are doing.

The following script will deploy two flashloan contracts. One will be used to flashloan one token at a time SimpleFlashLoan, the other will be used to combine multiple tokens in one flashloan transaction FlashLoan.

brownie run scripts/aave/deploy_flashloan.py

Ouput:

Browniev1.19.1-PythondevelopmentframeworkforEthereumRushProjectistheactiveproject.
Running'scripts/aave/deploy_flashloan.py::main'...
DeployingSimpleRushflashloanreceivercontract ...
===============================================Transactionsent: 0x0a39f260819c1e3a9d71010ccc64ba9bddc4f2d677d0d94b67c5fac9939cb520Gasprice: 36.756769064gweiGaslimit: 541641Nonce: 90FlashLoan.constructorconfirmedBlock: 8282174Gasused: 492401 (90.91%)
FlashLoandeployedat: 0xD86bF68ADaf5C6389F1e7379700B01217f3f8129ViewcontractonOptimismGoerli: https://goerli.etherscan.io/address/0xD86bF68ADaf5C6389F1e7379700B01217f3f8129TransactionwasMined---------------------TxHash: 0x0a39f260819c1e3a9d71010ccc64ba9bddc4f2d677d0d94b67c5fac9939cb520From: 0xFE948CB2122FDD87bAf43dCe8aFa254B1242c199NewFlashLoanaddress: 0xD86bF68ADaf5C6389F1e7379700B01217f3f8129Block: 8282174GasUsed: 492401/541641 (90.9%)

Excecuting 1M USDC flashloan transaction

Checout out this transaction. After you deploy your contracts, you are ready to submit transactions. The flashloan contracts will receive and repay your loan. Here's an example:

Run command on terminal.

brownie run scripts/aave/simple_flashloan.py

Output:

Browniev1.19.1-PythondevelopmentframeworkforEthereumRushProjectistheactiveproject.
Running'scripts/aave/simple_flashloan.py::main'...
Transactionsent: 0xe0298379f63293c6bb8ec2bfbd147684c3c73087e5ede19eb7409bcd844fcabbGasprice: 33.986319221gweiGaslimit: 37951Nonce: 93MintableERC20.transferconfirmedBlock: 8282256Gasused: 34501 (90.91%)
Transactionsent: 0x58180124eadc669c23c0cfa28053e0c79496b48713f0f160734710ace2b92577Gasprice: 32.188179381gweiGaslimit: 209116Nonce: 94TransactionconfirmedBlock: 8282267Gasused: 165364 (79.08%)
Congrats! Youhaveflippedaflashloan. Checkitout! https://goerli.etherscan.io/tx/0x58180124eadc669c23c0cfa28053e0c79496b48713f0f160734710ace2b92577

Publish and Verify Contract on Etherscan

Brownie has a simple way to quickly instantly verify your contract on etherscan. Run the following command.

>>>contract=RushFlashLoan.at("0x9db7BcB878E9b3eFDf8FAfcfbbF11a54d80f089c")
>>>contract<RushFlashLoanContract'0x9db7BcB878E9b3eFDf8FAfcfbbF11a54d80f089c'>>>>RushFlashLoan.publish_source(contract)
Verificationsubmittedsuccessfully. Waitingforresult...
Verificationcomplete. Result: Pass-VerifiedTrue

Trasaction breakdown

Here the flashloan contract is requesting 1M from the pool provider.

frombrownieimportaccounts, config, network, interface, RushSimpleFlashLoanfromscripts.aave.helper_functionsimportget_address_provider, get_token, get_accounttx_url="https://goerli.etherscan.io/tx/{}"pool=interface.IPool(get_address_provider().getPool())
flashloan_receiver=RushSimpleFlashLoan[len(RushSimpleFlashLoan) -1]
usdc=get_token("USDC")
usdc_amount=1_000_000*10**usdc.decimals()
defrun_flashloan():
dev=get_account()
receiver=flashloan_receiver.addressassets=usdc.addressamount=usdc_amount# 'flashLoanSimple': "0x42b0b77c"params="0x42b0b77c"referral=0tx=pool.flashLoanSimple(receiver, assets, amount, params, referral, {"from": dev})

Multi Token Flashloans

If you run this command, you can flashloan over 100M+ in tokens. Checkout this transaction.

brownie run scripts/aave/multi_flashloan.py
Browniev1.19.1-PythondevelopmentframeworkforEthereumRushProjectistheactiveproject.
Running'scripts/aave/multi_flashloan.py::main'...
Transactionsent: 0x310974980351e66748421d1ef01b3d940202090525a99630e03150cb9aeae859Gasprice: 4.924637698gweiGaslimit: 1578971Nonce: 83TransactionconfirmedBlock: 8265853Gasused: 1113994 (70.55%)
TransactionconfirmedBlock: 8265853Gasused: 1113994 (70.55%)
Congrats! Youhaveflippedaflashloan. Checkitout! https://goerli.etherscan.io/tx/0x310974980351e66748421d1ef01b3d940202090525a99630e03150cb9aeae859

Go to /scripts/aave/multi_flashloan.py and adjust token amounts. Try it out or yourself.

Support me

If you want to support me, you can. I accept ETH. Currently struggling to find a job.

ETH: msaki.eth 0x04655832bcb0a9a0be8c5ab71e4d311464c97af5

BTC: bc1qafvljh25wxd7ser9vsawzm95aaju883r9twd0p

DOGE: D5y6zYKN4WsWCr4YmnKhAFqCCFC31AN3We

⚠️ WARNING

| I should warn you. You will not make any profits from using flashloans in the current state on this repo.

About

A guide on how to complete flashloan transactions. Runner up winner of Aave Grants Dao Forex Tools 2022, ETHGlobal at ETHOnline 2022.

Topics

Resources

Stars

10 stars

Watchers

2 watching

Forks

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

Getting Started

First rename the .env.example file in this directory to .env. Replace the API keys as needed.

After adding your api keys, run the following command from your terminal.

source .env

This command allows brownie config to access your environment variables.

Scripts to AAVE Token balances

Run the following command to get token balances for all aave tokens in your account.

brownie run scripts/aave/aave_balances.py

Output:

Browniev1.19.1-PythondevelopmentframeworkforEthereumRushProjectistheactiveproject.
Running'scripts/aave/aave_balances.py::main'...
TokensinAccount====================================================================================================indexTokenNamebalanceaddress0AAVE1000000000000000000000x63242B9Bd3C22f18706d5c4E627B4735973f1f071DAI100000000000000000000000xDF1742fE5b0bFc12331D8EAec6b478DfDbD314642LINK10000000000000000000000x07C725d58437504CA5f814AE406e70E21C5e8e9e3EURS10000000xaA63E0C86b531E2eDFE9F91F6436dF20C301963D4USDC100000000000xA2025B15a1757311bfD68cb14eaeFCc237AF5b435USDT100000000000xC2C527C0CACF457746Bd31B2a698Fe89de2b6d496WETH00x2e3A2fb8473316A02b8A297B982498E661E1f6f57WBTC2000000000x8869DFd060c682675c2A8aE5B21F2cF738A0E3CEInterestaTokensinAccount====================================================================================================indexTokenNamebalanceaddress0aAAVE00xC4bf7684e627ee069e9873B70dD0a8a1241bf72c1aDAI00x310839bE20Fc6a8A89f33A59C7D5fC651365068f2aLINK00x6A639d29454287B3cBB632Aa9f93bfB89E3fd18f3aEURS00xc31E63CB07209DFD2c7Edb3FB385331be2a172094aUSDC00x1Ee669290939f8a8864497Af3BC83728715265FF5aUSDT00x73258E6fb96ecAc8a979826d503B45803a382d686aWETH00x27B4692C93959048833f40702b22FE3578E777597aWBTC2000000000xc0ac343EA11A8D05AAC3c5186850A659dD40B81BStableDebtTokensinAccount====================================================================================================indexTokenNamebalanceaddress0stableDebtAAVE00x4a8aF512B73Fd896C8877cE0Ebed19b0a11B593C1stableDebtDAI00xbaBd1C3912713d598CA2E6DE3303fC59b19d0B0F2stableDebtLINK00x4f094AB301C8787F0d06753CA3238bfA9CFB9c913stableDebtEURS00x512ad2D2fb3Bef82ca0A15d4dE6544246e2D32c74stableDebtUSDC00xF04958AeA8b7F24Db19772f84d7c2aC801D9Cf8b5stableDebtUSDT00x7720C270Fa5d8234f0DFfd2523C64FdeB333Fa506stableDebtWBTC00x15FF4188463c69FD18Ea39F68A0C9B730E23dE817stableDebtWETH00xCAF956bD3B3113Db89C0584Ef3B562153faB87D5VariableDebtTokensinAccount====================================================================================================indexTokenNamebalanceaddress0variableDebtAAVE00xad958444c255a71C659f7c30e18AFafdE910EB5a1variableDebtDAI00xEa5A7CB3BDF6b2A8541bd50aFF270453F1505A722variableDebtLINK00x593D1bB0b6052FB6c3423C42FA62275b3D95a9433variableDebtEURS00x257b4a23b3026E04790c39fD3Edd7101E5F311924variableDebtUSDC00x3e491EB1A98cD42F9BBa388076Fd7a74B3470CA05variableDebtUSDT00x45c3965f6FAbf2fB04e3FE019853813B2B7cC3A36variableDebtWBTC00x480B8b39d1465b8049fbf03b8E0a072Ab7C9A4227variableDebtWETH2062701383561597470x2b848bA14583fA79519Ee71E7038D0d1061cd0F1

If you set up your .env you should see this from your terminal.

Deploying Flashloan Contracts

Keep in mind that all the scripts you will be running for this demo are found in /scripts/aave directory. Read through them to see what they are doing.

The following script will deploy two flashloan contracts. One will be used to flashloan one token at a time SimpleFlashLoan, the other will be used to combine multiple tokens in one flashloan transaction FlashLoan.

brownie run scripts/aave/deploy_flashloan.py

Ouput:

Browniev1.19.1-PythondevelopmentframeworkforEthereumRushProjectistheactiveproject.
Running'scripts/aave/deploy_flashloan.py::main'...
DeployingSimpleRushflashloanreceivercontract ...
===============================================Transactionsent: 0x0a39f260819c1e3a9d71010ccc64ba9bddc4f2d677d0d94b67c5fac9939cb520Gasprice: 36.756769064gweiGaslimit: 541641Nonce: 90FlashLoan.constructorconfirmedBlock: 8282174Gasused: 492401 (90.91%)
FlashLoandeployedat: 0xD86bF68ADaf5C6389F1e7379700B01217f3f8129ViewcontractonOptimismGoerli: https://goerli.etherscan.io/address/0xD86bF68ADaf5C6389F1e7379700B01217f3f8129TransactionwasMined---------------------TxHash: 0x0a39f260819c1e3a9d71010ccc64ba9bddc4f2d677d0d94b67c5fac9939cb520From: 0xFE948CB2122FDD87bAf43dCe8aFa254B1242c199NewFlashLoanaddress: 0xD86bF68ADaf5C6389F1e7379700B01217f3f8129Block: 8282174GasUsed: 492401/541641 (90.9%)

Excecuting 1M USDC flashloan transaction

Checout out this transaction. After you deploy your contracts, you are ready to submit transactions. The flashloan contracts will receive and repay your loan. Here's an example:

Run command on terminal.

brownie run scripts/aave/simple_flashloan.py

Output:

Browniev1.19.1-PythondevelopmentframeworkforEthereumRushProjectistheactiveproject.
Running'scripts/aave/simple_flashloan.py::main'...
Transactionsent: 0xe0298379f63293c6bb8ec2bfbd147684c3c73087e5ede19eb7409bcd844fcabbGasprice: 33.986319221gweiGaslimit: 37951Nonce: 93MintableERC20.transferconfirmedBlock: 8282256Gasused: 34501 (90.91%)
Transactionsent: 0x58180124eadc669c23c0cfa28053e0c79496b48713f0f160734710ace2b92577Gasprice: 32.188179381gweiGaslimit: 209116Nonce: 94TransactionconfirmedBlock: 8282267Gasused: 165364 (79.08%)
Congrats! Youhaveflippedaflashloan. Checkitout! https://goerli.etherscan.io/tx/0x58180124eadc669c23c0cfa28053e0c79496b48713f0f160734710ace2b92577

Publish and Verify Contract on Etherscan

Brownie has a simple way to quickly instantly verify your contract on etherscan. Run the following command.

>>>contract=RushFlashLoan.at("0x9db7BcB878E9b3eFDf8FAfcfbbF11a54d80f089c")
>>>contract<RushFlashLoanContract'0x9db7BcB878E9b3eFDf8FAfcfbbF11a54d80f089c'>>>>RushFlashLoan.publish_source(contract)
Verificationsubmittedsuccessfully. Waitingforresult...
Verificationcomplete. Result: Pass-VerifiedTrue

Trasaction breakdown

Here the flashloan contract is requesting 1M from the pool provider.

frombrownieimportaccounts, config, network, interface, RushSimpleFlashLoanfromscripts.aave.helper_functionsimportget_address_provider, get_token, get_accounttx_url="https://goerli.etherscan.io/tx/{}"pool=interface.IPool(get_address_provider().getPool())
flashloan_receiver=RushSimpleFlashLoan[len(RushSimpleFlashLoan) -1]
usdc=get_token("USDC")
usdc_amount=1_000_000*10**usdc.decimals()
defrun_flashloan():
dev=get_account()
receiver=flashloan_receiver.addressassets=usdc.addressamount=usdc_amount# 'flashLoanSimple': "0x42b0b77c"params="0x42b0b77c"referral=0tx=pool.flashLoanSimple(receiver, assets, amount, params, referral, {"from": dev})

Multi Token Flashloans

If you run this command, you can flashloan over 100M+ in tokens. Checkout this transaction.

brownie run scripts/aave/multi_flashloan.py
Browniev1.19.1-PythondevelopmentframeworkforEthereumRushProjectistheactiveproject.
Running'scripts/aave/multi_flashloan.py::main'...
Transactionsent: 0x310974980351e66748421d1ef01b3d940202090525a99630e03150cb9aeae859Gasprice: 4.924637698gweiGaslimit: 1578971Nonce: 83TransactionconfirmedBlock: 8265853Gasused: 1113994 (70.55%)
TransactionconfirmedBlock: 8265853Gasused: 1113994 (70.55%)
Congrats! Youhaveflippedaflashloan. Checkitout! https://goerli.etherscan.io/tx/0x310974980351e66748421d1ef01b3d940202090525a99630e03150cb9aeae859

Go to /scripts/aave/multi_flashloan.py and adjust token amounts. Try it out or yourself.

Support me

If you want to support me, you can. I accept ETH. Currently struggling to find a job.

ETH: msaki.eth 0x04655832bcb0a9a0be8c5ab71e4d311464c97af5

BTC: bc1qafvljh25wxd7ser9vsawzm95aaju883r9twd0p

DOGE: D5y6zYKN4WsWCr4YmnKhAFqCCFC31AN3We

⚠️ WARNING

| I should warn you. You will not make any profits from using flashloans in the current state on this repo.

About

A guide on how to complete flashloan transactions. Runner up winner of Aave Grants Dao Forex Tools 2022, ETHGlobal at ETHOnline 2022.

Topics

Resources

Stars

10 stars

Watchers

2 watching

Forks

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

Getting Started

First rename the .env.example file in this directory to .env. Replace the API keys as needed.

After adding your api keys, run the following command from your terminal.

source .env

This command allows brownie config to access your environment variables.

Scripts to AAVE Token balances

Run the following command to get token balances for all aave tokens in your account.

brownie run scripts/aave/aave_balances.py

Output:

Browniev1.19.1-PythondevelopmentframeworkforEthereumRushProjectistheactiveproject.
Running'scripts/aave/aave_balances.py::main'...
TokensinAccount====================================================================================================indexTokenNamebalanceaddress0AAVE1000000000000000000000x63242B9Bd3C22f18706d5c4E627B4735973f1f071DAI100000000000000000000000xDF1742fE5b0bFc12331D8EAec6b478DfDbD314642LINK10000000000000000000000x07C725d58437504CA5f814AE406e70E21C5e8e9e3EURS10000000xaA63E0C86b531E2eDFE9F91F6436dF20C301963D4USDC100000000000xA2025B15a1757311bfD68cb14eaeFCc237AF5b435USDT100000000000xC2C527C0CACF457746Bd31B2a698Fe89de2b6d496WETH00x2e3A2fb8473316A02b8A297B982498E661E1f6f57WBTC2000000000x8869DFd060c682675c2A8aE5B21F2cF738A0E3CEInterestaTokensinAccount====================================================================================================indexTokenNamebalanceaddress0aAAVE00xC4bf7684e627ee069e9873B70dD0a8a1241bf72c1aDAI00x310839bE20Fc6a8A89f33A59C7D5fC651365068f2aLINK00x6A639d29454287B3cBB632Aa9f93bfB89E3fd18f3aEURS00xc31E63CB07209DFD2c7Edb3FB385331be2a172094aUSDC00x1Ee669290939f8a8864497Af3BC83728715265FF5aUSDT00x73258E6fb96ecAc8a979826d503B45803a382d686aWETH00x27B4692C93959048833f40702b22FE3578E777597aWBTC2000000000xc0ac343EA11A8D05AAC3c5186850A659dD40B81BStableDebtTokensinAccount====================================================================================================indexTokenNamebalanceaddress0stableDebtAAVE00x4a8aF512B73Fd896C8877cE0Ebed19b0a11B593C1stableDebtDAI00xbaBd1C3912713d598CA2E6DE3303fC59b19d0B0F2stableDebtLINK00x4f094AB301C8787F0d06753CA3238bfA9CFB9c913stableDebtEURS00x512ad2D2fb3Bef82ca0A15d4dE6544246e2D32c74stableDebtUSDC00xF04958AeA8b7F24Db19772f84d7c2aC801D9Cf8b5stableDebtUSDT00x7720C270Fa5d8234f0DFfd2523C64FdeB333Fa506stableDebtWBTC00x15FF4188463c69FD18Ea39F68A0C9B730E23dE817stableDebtWETH00xCAF956bD3B3113Db89C0584Ef3B562153faB87D5VariableDebtTokensinAccount====================================================================================================indexTokenNamebalanceaddress0variableDebtAAVE00xad958444c255a71C659f7c30e18AFafdE910EB5a1variableDebtDAI00xEa5A7CB3BDF6b2A8541bd50aFF270453F1505A722variableDebtLINK00x593D1bB0b6052FB6c3423C42FA62275b3D95a9433variableDebtEURS00x257b4a23b3026E04790c39fD3Edd7101E5F311924variableDebtUSDC00x3e491EB1A98cD42F9BBa388076Fd7a74B3470CA05variableDebtUSDT00x45c3965f6FAbf2fB04e3FE019853813B2B7cC3A36variableDebtWBTC00x480B8b39d1465b8049fbf03b8E0a072Ab7C9A4227variableDebtWETH2062701383561597470x2b848bA14583fA79519Ee71E7038D0d1061cd0F1

If you set up your .env you should see this from your terminal.

Deploying Flashloan Contracts

Keep in mind that all the scripts you will be running for this demo are found in /scripts/aave directory. Read through them to see what they are doing.

The following script will deploy two flashloan contracts. One will be used to flashloan one token at a time SimpleFlashLoan, the other will be used to combine multiple tokens in one flashloan transaction FlashLoan.

brownie run scripts/aave/deploy_flashloan.py

Ouput:

Browniev1.19.1-PythondevelopmentframeworkforEthereumRushProjectistheactiveproject.
Running'scripts/aave/deploy_flashloan.py::main'...
DeployingSimpleRushflashloanreceivercontract ...
===============================================Transactionsent: 0x0a39f260819c1e3a9d71010ccc64ba9bddc4f2d677d0d94b67c5fac9939cb520Gasprice: 36.756769064gweiGaslimit: 541641Nonce: 90FlashLoan.constructorconfirmedBlock: 8282174Gasused: 492401 (90.91%)
FlashLoandeployedat: 0xD86bF68ADaf5C6389F1e7379700B01217f3f8129ViewcontractonOptimismGoerli: https://goerli.etherscan.io/address/0xD86bF68ADaf5C6389F1e7379700B01217f3f8129TransactionwasMined---------------------TxHash: 0x0a39f260819c1e3a9d71010ccc64ba9bddc4f2d677d0d94b67c5fac9939cb520From: 0xFE948CB2122FDD87bAf43dCe8aFa254B1242c199NewFlashLoanaddress: 0xD86bF68ADaf5C6389F1e7379700B01217f3f8129Block: 8282174GasUsed: 492401/541641 (90.9%)

Excecuting 1M USDC flashloan transaction

Checout out this transaction. After you deploy your contracts, you are ready to submit transactions. The flashloan contracts will receive and repay your loan. Here's an example:

Run command on terminal.

brownie run scripts/aave/simple_flashloan.py

Output:

Browniev1.19.1-PythondevelopmentframeworkforEthereumRushProjectistheactiveproject.
Running'scripts/aave/simple_flashloan.py::main'...
Transactionsent: 0xe0298379f63293c6bb8ec2bfbd147684c3c73087e5ede19eb7409bcd844fcabbGasprice: 33.986319221gweiGaslimit: 37951Nonce: 93MintableERC20.transferconfirmedBlock: 8282256Gasused: 34501 (90.91%)
Transactionsent: 0x58180124eadc669c23c0cfa28053e0c79496b48713f0f160734710ace2b92577Gasprice: 32.188179381gweiGaslimit: 209116Nonce: 94TransactionconfirmedBlock: 8282267Gasused: 165364 (79.08%)
Congrats! Youhaveflippedaflashloan. Checkitout! https://goerli.etherscan.io/tx/0x58180124eadc669c23c0cfa28053e0c79496b48713f0f160734710ace2b92577

Publish and Verify Contract on Etherscan

Brownie has a simple way to quickly instantly verify your contract on etherscan. Run the following command.

>>>contract=RushFlashLoan.at("0x9db7BcB878E9b3eFDf8FAfcfbbF11a54d80f089c")
>>>contract<RushFlashLoanContract'0x9db7BcB878E9b3eFDf8FAfcfbbF11a54d80f089c'>>>>RushFlashLoan.publish_source(contract)
Verificationsubmittedsuccessfully. Waitingforresult...
Verificationcomplete. Result: Pass-VerifiedTrue

Trasaction breakdown

Here the flashloan contract is requesting 1M from the pool provider.

frombrownieimportaccounts, config, network, interface, RushSimpleFlashLoanfromscripts.aave.helper_functionsimportget_address_provider, get_token, get_accounttx_url="https://goerli.etherscan.io/tx/{}"pool=interface.IPool(get_address_provider().getPool())
flashloan_receiver=RushSimpleFlashLoan[len(RushSimpleFlashLoan) -1]
usdc=get_token("USDC")
usdc_amount=1_000_000*10**usdc.decimals()
defrun_flashloan():
dev=get_account()
receiver=flashloan_receiver.addressassets=usdc.addressamount=usdc_amount# 'flashLoanSimple': "0x42b0b77c"params="0x42b0b77c"referral=0tx=pool.flashLoanSimple(receiver, assets, amount, params, referral, {"from": dev})

Multi Token Flashloans

If you run this command, you can flashloan over 100M+ in tokens. Checkout this transaction.

brownie run scripts/aave/multi_flashloan.py
Browniev1.19.1-PythondevelopmentframeworkforEthereumRushProjectistheactiveproject.
Running'scripts/aave/multi_flashloan.py::main'...
Transactionsent: 0x310974980351e66748421d1ef01b3d940202090525a99630e03150cb9aeae859Gasprice: 4.924637698gweiGaslimit: 1578971Nonce: 83TransactionconfirmedBlock: 8265853Gasused: 1113994 (70.55%)
TransactionconfirmedBlock: 8265853Gasused: 1113994 (70.55%)
Congrats! Youhaveflippedaflashloan. Checkitout! https://goerli.etherscan.io/tx/0x310974980351e66748421d1ef01b3d940202090525a99630e03150cb9aeae859

Go to /scripts/aave/multi_flashloan.py and adjust token amounts. Try it out or yourself.

Support me

If you want to support me, you can. I accept ETH. Currently struggling to find a job.

ETH: msaki.eth 0x04655832bcb0a9a0be8c5ab71e4d311464c97af5

BTC: bc1qafvljh25wxd7ser9vsawzm95aaju883r9twd0p

DOGE: D5y6zYKN4WsWCr4YmnKhAFqCCFC31AN3We

⚠️ WARNING

| I should warn you. You will not make any profits from using flashloans in the current state on this repo.

About

A guide on how to complete flashloan transactions. Runner up winner of Aave Grants Dao Forex Tools 2022, ETHGlobal at ETHOnline 2022.

Topics

Resources

Stars

10 stars

Watchers

2 watching

Forks

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Repository files navigation

Getting Started

First rename the .env.example file in this directory to .env. Replace the API keys as needed.

After adding your api keys, run the following command from your terminal.

source .env

This command allows brownie config to access your environment variables.

Scripts to AAVE Token balances

Run the following command to get token balances for all aave tokens in your account.

brownie run scripts/aave/aave_balances.py

Output:

Browniev1.19.1-PythondevelopmentframeworkforEthereumRushProjectistheactiveproject.
Running'scripts/aave/aave_balances.py::main'...
TokensinAccount====================================================================================================indexTokenNamebalanceaddress0AAVE1000000000000000000000x63242B9Bd3C22f18706d5c4E627B4735973f1f071DAI100000000000000000000000xDF1742fE5b0bFc12331D8EAec6b478DfDbD314642LINK10000000000000000000000x07C725d58437504CA5f814AE406e70E21C5e8e9e3EURS10000000xaA63E0C86b531E2eDFE9F91F6436dF20C301963D4USDC100000000000xA2025B15a1757311bfD68cb14eaeFCc237AF5b435USDT100000000000xC2C527C0CACF457746Bd31B2a698Fe89de2b6d496WETH00x2e3A2fb8473316A02b8A297B982498E661E1f6f57WBTC2000000000x8869DFd060c682675c2A8aE5B21F2cF738A0E3CEInterestaTokensinAccount====================================================================================================indexTokenNamebalanceaddress0aAAVE00xC4bf7684e627ee069e9873B70dD0a8a1241bf72c1aDAI00x310839bE20Fc6a8A89f33A59C7D5fC651365068f2aLINK00x6A639d29454287B3cBB632Aa9f93bfB89E3fd18f3aEURS00xc31E63CB07209DFD2c7Edb3FB385331be2a172094aUSDC00x1Ee669290939f8a8864497Af3BC83728715265FF5aUSDT00x73258E6fb96ecAc8a979826d503B45803a382d686aWETH00x27B4692C93959048833f40702b22FE3578E777597aWBTC2000000000xc0ac343EA11A8D05AAC3c5186850A659dD40B81BStableDebtTokensinAccount====================================================================================================indexTokenNamebalanceaddress0stableDebtAAVE00x4a8aF512B73Fd896C8877cE0Ebed19b0a11B593C1stableDebtDAI00xbaBd1C3912713d598CA2E6DE3303fC59b19d0B0F2stableDebtLINK00x4f094AB301C8787F0d06753CA3238bfA9CFB9c913stableDebtEURS00x512ad2D2fb3Bef82ca0A15d4dE6544246e2D32c74stableDebtUSDC00xF04958AeA8b7F24Db19772f84d7c2aC801D9Cf8b5stableDebtUSDT00x7720C270Fa5d8234f0DFfd2523C64FdeB333Fa506stableDebtWBTC00x15FF4188463c69FD18Ea39F68A0C9B730E23dE817stableDebtWETH00xCAF956bD3B3113Db89C0584Ef3B562153faB87D5VariableDebtTokensinAccount====================================================================================================indexTokenNamebalanceaddress0variableDebtAAVE00xad958444c255a71C659f7c30e18AFafdE910EB5a1variableDebtDAI00xEa5A7CB3BDF6b2A8541bd50aFF270453F1505A722variableDebtLINK00x593D1bB0b6052FB6c3423C42FA62275b3D95a9433variableDebtEURS00x257b4a23b3026E04790c39fD3Edd7101E5F311924variableDebtUSDC00x3e491EB1A98cD42F9BBa388076Fd7a74B3470CA05variableDebtUSDT00x45c3965f6FAbf2fB04e3FE019853813B2B7cC3A36variableDebtWBTC00x480B8b39d1465b8049fbf03b8E0a072Ab7C9A4227variableDebtWETH2062701383561597470x2b848bA14583fA79519Ee71E7038D0d1061cd0F1

If you set up your .env you should see this from your terminal.

Deploying Flashloan Contracts

Keep in mind that all the scripts you will be running for this demo are found in /scripts/aave directory. Read through them to see what they are doing.

The following script will deploy two flashloan contracts. One will be used to flashloan one token at a time SimpleFlashLoan, the other will be used to combine multiple tokens in one flashloan transaction FlashLoan.

brownie run scripts/aave/deploy_flashloan.py

Ouput:

Browniev1.19.1-PythondevelopmentframeworkforEthereumRushProjectistheactiveproject.
Running'scripts/aave/deploy_flashloan.py::main'...
DeployingSimpleRushflashloanreceivercontract ...
===============================================Transactionsent: 0x0a39f260819c1e3a9d71010ccc64ba9bddc4f2d677d0d94b67c5fac9939cb520Gasprice: 36.756769064gweiGaslimit: 541641Nonce: 90FlashLoan.constructorconfirmedBlock: 8282174Gasused: 492401 (90.91%)
FlashLoandeployedat: 0xD86bF68ADaf5C6389F1e7379700B01217f3f8129ViewcontractonOptimismGoerli: https://goerli.etherscan.io/address/0xD86bF68ADaf5C6389F1e7379700B01217f3f8129TransactionwasMined---------------------TxHash: 0x0a39f260819c1e3a9d71010ccc64ba9bddc4f2d677d0d94b67c5fac9939cb520From: 0xFE948CB2122FDD87bAf43dCe8aFa254B1242c199NewFlashLoanaddress: 0xD86bF68ADaf5C6389F1e7379700B01217f3f8129Block: 8282174GasUsed: 492401/541641 (90.9%)

Excecuting 1M USDC flashloan transaction

Checout out this transaction. After you deploy your contracts, you are ready to submit transactions. The flashloan contracts will receive and repay your loan. Here's an example:

Run command on terminal.

brownie run scripts/aave/simple_flashloan.py

Output:

Browniev1.19.1-PythondevelopmentframeworkforEthereumRushProjectistheactiveproject.
Running'scripts/aave/simple_flashloan.py::main'...
Transactionsent: 0xe0298379f63293c6bb8ec2bfbd147684c3c73087e5ede19eb7409bcd844fcabbGasprice: 33.986319221gweiGaslimit: 37951Nonce: 93MintableERC20.transferconfirmedBlock: 8282256Gasused: 34501 (90.91%)
Transactionsent: 0x58180124eadc669c23c0cfa28053e0c79496b48713f0f160734710ace2b92577Gasprice: 32.188179381gweiGaslimit: 209116Nonce: 94TransactionconfirmedBlock: 8282267Gasused: 165364 (79.08%)
Congrats! Youhaveflippedaflashloan. Checkitout! https://goerli.etherscan.io/tx/0x58180124eadc669c23c0cfa28053e0c79496b48713f0f160734710ace2b92577

Publish and Verify Contract on Etherscan

Brownie has a simple way to quickly instantly verify your contract on etherscan. Run the following command.

>>>contract=RushFlashLoan.at("0x9db7BcB878E9b3eFDf8FAfcfbbF11a54d80f089c")
>>>contract<RushFlashLoanContract'0x9db7BcB878E9b3eFDf8FAfcfbbF11a54d80f089c'>>>>RushFlashLoan.publish_source(contract)
Verificationsubmittedsuccessfully. Waitingforresult...
Verificationcomplete. Result: Pass-VerifiedTrue

Trasaction breakdown

Here the flashloan contract is requesting 1M from the pool provider.

frombrownieimportaccounts, config, network, interface, RushSimpleFlashLoanfromscripts.aave.helper_functionsimportget_address_provider, get_token, get_accounttx_url="https://goerli.etherscan.io/tx/{}"pool=interface.IPool(get_address_provider().getPool())
flashloan_receiver=RushSimpleFlashLoan[len(RushSimpleFlashLoan) -1]
usdc=get_token("USDC")
usdc_amount=1_000_000*10**usdc.decimals()
defrun_flashloan():
dev=get_account()
receiver=flashloan_receiver.addressassets=usdc.addressamount=usdc_amount# 'flashLoanSimple': "0x42b0b77c"params="0x42b0b77c"referral=0tx=pool.flashLoanSimple(receiver, assets, amount, params, referral, {"from": dev})

Multi Token Flashloans

If you run this command, you can flashloan over 100M+ in tokens. Checkout this transaction.

brownie run scripts/aave/multi_flashloan.py
Browniev1.19.1-PythondevelopmentframeworkforEthereumRushProjectistheactiveproject.
Running'scripts/aave/multi_flashloan.py::main'...
Transactionsent: 0x310974980351e66748421d1ef01b3d940202090525a99630e03150cb9aeae859Gasprice: 4.924637698gweiGaslimit: 1578971Nonce: 83TransactionconfirmedBlock: 8265853Gasused: 1113994 (70.55%)
TransactionconfirmedBlock: 8265853Gasused: 1113994 (70.55%)
Congrats! Youhaveflippedaflashloan. Checkitout! https://goerli.etherscan.io/tx/0x310974980351e66748421d1ef01b3d940202090525a99630e03150cb9aeae859

Go to /scripts/aave/multi_flashloan.py and adjust token amounts. Try it out or yourself.

Support me

If you want to support me, you can. I accept ETH. Currently struggling to find a job.

ETH: msaki.eth 0x04655832bcb0a9a0be8c5ab71e4d311464c97af5

BTC: bc1qafvljh25wxd7ser9vsawzm95aaju883r9twd0p

DOGE: D5y6zYKN4WsWCr4YmnKhAFqCCFC31AN3We

⚠️ WARNING

| I should warn you. You will not make any profits from using flashloans in the current state on this repo.

About

A guide on how to complete flashloan transactions. Runner up winner of Aave Grants Dao Forex Tools 2022, ETHGlobal at ETHOnline 2022.

Topics

Resources

Stars

10 stars

Watchers

2 watching

Forks

Used by

Contributors

Languages