Skip to content

Instantly share code, notes, and snippets.

@banteg
Last active April 18, 2022 22:34
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save banteg/7d391171fbeaff5735028851b2f51f35 to your computer and use it in GitHub Desktop.
Save banteg/7d391171fbeaff5735028851b2f51f35 to your computer and use it in GitHub Desktop.
from brownie import accounts, chain, Contract, Wei
from eth_abi.packed import encode_abi_packed
user = accounts[0]
weth = Contract('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', owner=user)
dai = '0x6B175474E89094C44Da98b954EedeAC495271d0F'
rai = '0x03ab458634910AaD20eF5f1C8ee96F1D6ac54919'
# https://github.com/Uniswap/uniswap-v3-periphery/blob/main/deploys.md
quoter = Contract('0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6')
router = Contract('0xE592427A0AEce92De3Edee1F18E0157C05861564', owner=user)
amount = Wei('1 ether')
weth.deposit({'amount': amount})
weth.approve(router, amount)
path = encode_abi_packed(['address', 'uint24', 'address', 'uint24', 'address'], [str(weth), 3000, dai, 500, rai])
quote = quoter.quoteExactInput.call(path, amount)
deadline = chain.time() + 600
tx = router.exactInput((path, user, deadline, amount, quote * 0.99))
tx.info()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment