Skip to content

Instantly share code, notes, and snippets.

@yuyasugano
Created February 23, 2021 09:47
Show Gist options
  • Save yuyasugano/63900a61f659e0fdbeb45e9521fe1026 to your computer and use it in GitHub Desktop.
Save yuyasugano/63900a61f659e0fdbeb45e9521fe1026 to your computer and use it in GitHub Desktop.
Aave V1 flashloan test
import pytest
import click
# isolation fixture for each function, takes a snapshot of the chain
@pytest.fixture(scope='function', autouse=True)
def isolation(fn_isolation):
pass
def test_flashloan_aave1(accounts, interface, chain, Flashloan):
# prepare accounts
user = accounts[0]
amount = 10 * 1e18
flashloan = Flashloan.deploy({'from': user})
user.transfer(flashloan.address, "1 ether", gas_price=0)
beforeBalance = flashloan.balance()
tx = flashloan.flashloan(
"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
amount
)
tx.info()
afterBalance = flashloan.balance()
print(click.style(f'remained eth in wei: {afterBalance}', fg='green', bold=True))
# Flashloan fee is 0.09% of the borrowed amount
assert afterBalance == beforeBalance - 9000000000000000, 'Aave V1 Flashloan did not run correctly'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment