All packages

uniswap_v3

StreamingFast
This is not the latest version — go to v0.2.11
v0.2.10/1.4K downloads

Package ref

uniswap-v3@v0.2.10

Run package

CLI

Run graph_out from the command line.

substreams run uniswap-v3@v0.2.10 graph_out -e mainnet
Authenticate by running substreams auth or directly on thegraph.market (see docs).

README

Official StreamingFast implementation of Uniswap v3 Substreams. Underlying Substreams modules allow for composability. This Substreams contains 22 modules. Mappers are used to extract key structures which are either passed down to other modules or used to emit entity changes. Stores are used as temporary storage to hold/pass down key data to mappers, such as ETH price in USD. These substreams modules compose all the things to build up the Uniswap v3 Substreams. See individual modules docs for more information.

Modules

Execution graph

23 modules
mapMain

graph_out

`EntityChanges` emitted out for all the entities defined in the `schema.graphql` for the Uniswap v3 Subgraph.

from #12369621

Output

sf.substreams.entity.v1.EntityChanges

Show 22 dependencies
map

uni_v0_2_9:graph_out

`EntityChanges` emitted out for all the entities defined in the `schema.graphql` for the Uniswap v3 Subgraph.

from #12369621

Output

sf.substreams.entity.v1.EntityChanges

map

uni_v0_2_9:map_extract_data_types

Chunky module which emits multiple types of `Events`. Looping over every transaction to filter out `Events`. For some events, we have to loop over `StorageChanges` to be able to fetch certain changes such as liquidity increases and decreases. For more information on what the `Event` contains, check proto/uniswap/v1/uniswap.proto. Try with ``` substreams gui substreams.yaml map_extract_data_types -t +1000 ```

from #12369621
map

uni_v0_2_9:map_pools_created

This module will loop over block transactions and detect pools created events. Once the pool created events have been detected, `Pools` structs will be emitted out of the module. Try with ``` substreams gui substreams.yaml map_pools_created -t +1000 ```

from #12369621
map

uni_v0_2_9:map_tokens_whitelist_pools

This modules loops over the pools created and emits `ERC20Tokens` structs out of the module. Tokens part of the pair of a pool are checked against the `WHITELIST_TOKENS` constant to see if they are part of the list. If so push the address of the pool in the field `whitelist_pools` of the token. Try with ``` substreams gui substreams.yaml map_tokens_whitelist_pools -t +1000 ```

from #12369621
store

uni_v0_2_9:store_derived_factory_tvl

`BigDecimal` accumulator store for the derived `total_value_locked` in `USD`, `ETH`, `USDUntracked` and `ETHUntracked` for the factory.

from #12369621

Store value

bigdecimal

Update policy

add

Inputs

sf.substreams.v1.Clockuni_v0_2_9:store_derived_tvl
store

uni_v0_2_9:store_eth_prices

`BigDecimal` setter store for the `eth_price`. This module uses a multiple stores and `map_extract_data_types` to find the `eth_price` of any given token. If a pool contains a token which has a pair with a _well-known_ token, the `eth_price` is easily found. Stores the USD price of ETH. For example: - Pool: DAI <> WBTC -> we check if there is a pool with DAI <> ETH and easily derive the price - Pool: ANYTOKEN0 <> DAI -> we can derive the price by finding the pool DAI <> ETH - Pool: ANYTOKEN0 <> ANYTOKEN1 -> more complicated case where we have to check on either side of the pool and try to find a path to reach a `whitelisted_token` which has a pool with ETH to be able to derive the price

from #12369621

Store value

bigdecimal

Update policy

set

store

uni_v0_2_9:store_max_windows

`BigDecimal` maximum store for the price of `eth` and token prices for `open` and `low` for daily and hourly.

from #12369621

Store value

bigdecimal

Update policy

max

store

uni_v0_2_9:store_min_windows

`BigDecimal` minimum store for the price of `eth` and token prices for `open` and `low` for daily and hourly.

from #12369621

Store value

bigdecimal

Update policy

min

store

uni_v0_2_9:store_native_amounts

`BigDecimal` setter store for the native amounts out of any `Event` type: `Mint`, `Swap` and `Burn` amounts (amount0 and amount1).

from #12369621

Store value

bigdecimal

Update policy

set

store

uni_v0_2_9:store_pool_count

`BigInt` store accumulator for each time a pool is created.

from #12369621

Store value

bigint

Update policy

add

store

uni_v0_2_9:store_pool_liquidities

`BigInt` store setter for storing pool liquidites which were extracted from `map_extract_data_types`.

from #12369621

Store value

bigint

Update policy

set

Inputs

sf.substreams.v1.Clockuni_v0_2_9:map_extract_data_types
store

uni_v0_2_9:store_prices

`BigDecimal` store setter for storing the price of token0 <> token1 and vice versa. Also store the Daily and Hourly prices. For example: Pool: TOKEN0 <> TOKEN1 - pool:{pool_address}:{token0_addr}:token0 -> 100 - pool:{pool_address}:{token1_addr}:token1 -> 1 This means that the price of TOKEN0 is 100 for 1 TOKEN1

from #12369621

Store value

bigdecimal

Update policy

set

store

uni_v0_2_9:store_ticks_liquidities

`BigInt` accumulator store for the liquidities of the pools. Tracking `liquidityGross` and `liquidityNet` for pool values at all times, daily and hourly for `Mint` and `Burn` events.

from #12369621

Store value

bigint

Update policy

add

Inputs

sf.substreams.v1.Clockuni_v0_2_9:map_extract_data_types
store

uni_v0_2_9:store_token_tvl

`BigDecimal` accumulator store for the `total_value_locked` for tokens.

from #12369621

Store value

bigdecimal

Update policy

add

store

uni_v0_2_9:store_tokens

`Int64` store accumulator for each time a token is used for any combination for a pool.

from #12369621

Store value

int64

Update policy

add

store

uni_v0_2_9:store_tokens_whitelist_pools

`String` appender store which stores the `whitelist_pools` field of a token.

from #12369621

Store value

string

Update policy

append

store

uni_v0_2_9:store_total_tx_counts

`BigInt` accumulator store for the total transaction counts for pools, tokens, factory, daily factory, daily and hourly for token and pool data.

from #12369621

Store value

bigint

Update policy

add

Inputs

sf.substreams.v1.Clockuni_v0_2_9:map_extract_data_types