uniswap_v3.liquidity
Documentation for eth_defi.uniswap_v3.liquidity Python module.
Uniswap v3 liquidity events and depth estimation.
Functions
|
Create tick csv based on tick delta |
|
Create intermediate tick delta csv based on mint and burn events |
|
Calculate the liquidity at multiple depths of a pool at a given block |
|
Get a pool state (current liquidity, tick, ticks) at a given block using Uniswap V3 subgraph data. |
|
Construct tick deltas from burn event |
|
Construct tick deltas from mint event |
Classes
A dictionary of a tick delta, where liquidity of a tick changes |
- class TickDelta
Bases:
TypedDictA dictionary of a tick delta, where liquidity of a tick changes
- __init__(*args, **kwargs)
- __new__(**kwargs)
- clear() None. Remove all items from D.
- copy() a shallow copy of D
- fromkeys(value=None, /)
Create a new dictionary with keys from iterable and values set to value.
- get(key, default=None, /)
Return the value for key if key is in the dictionary, else default.
- items() a set-like object providing a view on D's items
- keys() a set-like object providing a view on D's keys
- pop(k[, d]) v, remove specified key and return the corresponding value.
If the key is not found, return the default if given; otherwise, raise a KeyError.
- popitem()
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
- setdefault(key, default=None, /)
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- update([E, ]**F) None. Update D from mapping/iterable E and F.
If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- values() an object providing a view on D's values
- handle_mint_event(event)
Construct tick deltas from mint event
- Parameters
event (dict) – Mint event
- Returns
Tick deltas for lower tick and upper tick
- Return type
- handle_burn_event(event)
Construct tick deltas from burn event
- Parameters
event (dict) – Mint event
- Returns
Tick deltas for lower tick and upper tick
- Return type
- create_tick_delta_csv(mints_csv, burns_csv, output_folder='/tmp')
Create intermediate tick delta csv based on mint and burn events
- create_tick_csv(tick_delta_csv, output_folder='/tmp')
Create tick csv based on tick delta
- get_pool_state_at_block(pool_address, block_number, api_key, chain=1)
Get a pool state (current liquidity, tick, ticks) at a given block using Uniswap V3 subgraph data. Needs thegraph api key to work, default ethereum chain - Mainnet (1)
- Parameters
pool_address (eth_typing.evm.HexAddress) –
block_number (int) –
api_key (str) –
chain (int) –
- estimate_liquidity_depth_at_block(pool_address, block_number, *, depths=[- 5, - 2, - 1, - 0.5, - 0.2, - 0.1, 0.1, 0.2, 0.5, 1, 2, 5], verbose=False)
Calculate the liquidity at multiple depths of a pool at a given block
See this StackExchange question for commentary
- Parameters
pool_address (eth_typing.evm.HexAddress) – Uniswap v3 pool address
block_number (int) – Block number when the liquidity should be measured
depths (list[float]) – A list of depths in percentage where liquidity should be measured, default: 12 depth range from -5% to +%5
verbose (bool) – Print out information to console if True, default: False
- Returns
A list of liquidity depth in form of tuple: depth, amount of token needed to buy to reach current depth, adjusted amount of token (based on token decimals)
- Return type