GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Getting started
  • Uniswap v4
  • API Reference
  • Command line interface
  • Examples
  • Supported deployments

This view

  • Original page
  • New address

GeezerVison is showing uniswap-python.com — Command line interface — uniswap-python

  • Repository
  • Suggest edit
  • .rst

Command line interface

Contents

Command line interface#

uniswap-python provides a basic command line interface named unipy, to let you easier query the chain for things like the current price and token metadata.

Example usage#

Note: uniswap-python contains a small database of token contract addresses for convenience. You can always provide a contract address in place of a shorthand, and need to do so for all tokens not in the bundled database, or if you’re not on mainnet.

# Get price for 1 WETH quoted in DAI
$ unipy price WETH DAI
3350.883387688622

# Get price for 1 WETH quoted in DAI, skip decimal normalization
$ unipy price --raw WETH DAI
3350883387688622003541

# Get price for 1 WETH quoted in USDT
$ unipy price WETH 0xdac17f958d2ee523a2206206994597c13d831ec7
3348.128969

# Get token metadata from its ERC20 contract
$ unipy token 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
{'name': 'Wrapped Ether', 'symbol': 'WETH', 'decimals': 18}

# List known/hardcoded tokens, with metadata
$ unipy tokendb --metadata
{'name': 'Wrapped Ether', 'symbol': 'WETH', 'decimals': 18}
{'name': 'Dai Stablecoin', 'symbol': 'DAI', 'decimals': 18}
{'name': 'Wrapped BTC', 'symbol': 'WBTC', 'decimals': 8}
...

Usage#

unipy#

unipy [OPTIONS] COMMAND [ARGS]...

Options

-v, --verbose#
--version <version>#
Options:

1 | 2 | 3

price#

Returns the price of quantity tokens of token_in quoted in token_out.

unipy price [OPTIONS] TOKEN_IN TOKEN_OUT

Options

--raw#

Don’t normalize the quoted price to the output token’s decimals

--quantity <quantity>#

Quantity of output tokens to get price of. Falls back to one full unit of the input token by default (10**18 for WETH, for example).

Arguments

TOKEN_IN#

Required argument

TOKEN_OUT#

Required argument

token#

Show metadata for token

unipy token [OPTIONS] TOKEN

Arguments

TOKEN#

Required argument

tokendb#

List known token addresses

unipy tokendb [OPTIONS]

Options

--metadata#

Also get metadata for tokens

Contents
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.