def test_assets(client: Uniswap): """ Buy some DAI and USDC to test with. """ tokens = client._get_token_addresses() for token_name, amount in [("DAI", 100 * 10 ** 18), ("USDC", 100 * 10 ** 6)]: token_addr = tokens[token_name] price = client.get_eth_token_output_price(token_addr, amount) logger.info(f"Cost of {amount} {token_name}: {price}") logger.info("Buying...") tx = client.make_trade_output(tokens["ETH"], token_addr, amount) client.w3.eth.waitForTransactionReceipt(tx)
import requests from uniswap import Uniswap from config import PROVIDER address = "0x0000000000000000000000000000000000000000" private_key = None uniswap_wrapper = Uniswap( address, private_key, version=2, provider=PROVIDER) # pass version=2 to use Uniswap v2 eth = "0x0000000000000000000000000000000000000000" gol = "0xF4ecdBa8ba4144Ff3a2d8792Cad9051431Aa4F64" ETH_GGOL_PRICE = uniswap_wrapper.get_eth_token_output_price(gol, 1) / (1 * 10**18) GGOL_SUPPLY = 14_406_844_988_437 / 10**9 def get_data(): return requests.get( 'https://api.coingecko.com/api/v3/coins/ethereum').json() def get_gol_market_data(): resp = get_data() current_price = get_current_price(resp)['current_price'] market_cap = get_market_cap(current_price)['market_cap'] return { "market_data": { "current_price": current_price, "market_cap": market_cap,