Skip to content

Instantly share code, notes, and snippets.

@michwill
Created June 1, 2023 13:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michwill/ad8da86fa81317b883218cb081e554d1 to your computer and use it in GitHub Desktop.
Save michwill/ad8da86fa81317b883218cb081e554d1 to your computer and use it in GitHub Desktop.
from brownie import config, Contract, accounts, chain
config['autofetch_sources'] = True
def main():
convex = accounts.at("0x989AEb4d175e16225E39E87d0D97A3360524AD80", force=True)
aragon = Contract("0xe478de485ad2fe566d49342cbd03e49ed7db3356")
# New AMM and Controller implementations
aragon.vote(346, True, False, {'from': convex})
# wstETH market
aragon.vote(347, True, False, {'from': convex})
chain.sleep(7 * 86400)
aragon.executeVote(346, {'from': convex})
print('Controller and AMM upgraded')
aragon.executeVote(347, {'from': convex})
print('wstETH market created')
# Now let's borrow something
# First, hack aave to do it
aave = accounts.at("0x0B925eD163218f6662a35e0f0371Ac234f9E9371", force=True)
wsteth = Contract("0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0")
wsteth.transfer(convex, 100 * 10**18, {'from': aave})
# Initiate new market objects
factory = Contract("0xC9332fdCB1C491Dcc683bAe86Fe3cb70360738BC")
assert factory.n_collaterals() == 2
sfrxeth_controller = Contract(factory.controllers(0))
sfrxeth_amm = Contract(factory.amms(0))
wsteth_controller = Contract.from_abi('Controller', factory.controllers(1), sfrxeth_controller.abi)
wsteth_amm = Contract.from_abi('AMM', factory.amms(1), sfrxeth_amm.abi)
crvusd = Contract('0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E')
assert wsteth_amm.coins(0) == crvusd.address # crvUSD
assert wsteth_amm.coins(1) == wsteth.address
assert wsteth_controller.amm() == wsteth_amm.address
assert wsteth_controller.collateral_token() == wsteth.address
print('wstETH price:', wsteth_amm.price_oracle() / 1e18)
# Borrow and check crvUSD amount
wsteth.approve(wsteth_controller, 2**256-1, {'from': convex})
wsteth_controller.create_loan(100 * 10**18, 10000 * 10**18, 10, {'from': convex})
assert crvusd.balanceOf(convex) == 10000 * 10**18
@Niazi1992
Copy link

I like it 🤠

@Niazi1992
Copy link

Good luck with your time look like this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment