watcher-ts/packages/uniswap
Ashwin Phatak 69f4cf3513
Uniswap queries/mapping analysis (#91)
* List down view method in uniswap core contracts.

* List queries used in uniswap subgraph frontend.

* Analyse uniswap subgraph entities with mappings.

* Generate schema graphql file for uniswap subgraph.

* Schema graphql for queries used in subgraph frontend.

Co-authored-by: nikugogoi <95nikass@gmail.com>
2021-06-29 10:39:32 +05:30
..
frontend-schema.graphql Uniswap queries/mapping analysis (#91) 2021-06-29 10:39:32 +05:30
package.json Uniswap queries/mapping analysis (#91) 2021-06-29 10:39:32 +05:30
queries.md Uniswap queries/mapping analysis (#91) 2021-06-29 10:39:32 +05:30
README.md Uniswap queries/mapping analysis (#91) 2021-06-29 10:39:32 +05:30
schema.graphql Uniswap queries/mapping analysis (#91) 2021-06-29 10:39:32 +05:30

Uniswap

Scripts

  • generate:schema

    Generate schema for uniswap subgraph in graphql format. The get-graphql-schema tool is used to generate the schema (https://github.com/prisma-labs/get-graphql-schema). The uniswap subgraph graphql endpoint is provided in the script to generate the schema.

  • lint:schema

    Lint schema graphql files.

    $ yarn lint:schema frontend-schema.graphql
    

View Methods in Uniswap V3 Core

Queries in Uniswap subgraph frontend

Actual queries are listed in queries file.

Mapping Event handlers in Uniswap subgraph

  • handlePoolCreated (Factory contract - PoolCreated event)

    • Data from event
    • Entities
      • Factory
      • Bundle
      • Pool
      • Token
    • Contract calls
      • ERC20 (symbol, name, totalSupply, decimals)
      • ERC20SymbolBytes (symbol)
      • ERC20NameBytes (name)
    • Create new Template contract (Pool)
  • NonfungiblePositionManager contract

    • Handlers (Similar code)
      • handleIncreaseLiquidity (IncreaseLiquidity event)
      • handleDecreaseLiquidity (DecreaseLiquidity event)
      • handleCollect (Collect event)
      • handleTransfer (Transfer event)
    • Data from event
    • Entities
      • Position
      • Transaction
      • Token
    • Contract calls
      • NonfungiblePositionManager (positions)
      • Factory (getPool)
  • handleInitialize (Pool contract - Initialize event)

    • Data from event
    • Entities
      • Pool
      • Token
      • Bundle
      • PoolDayData
      • PoolHourData
  • handleSwap (Pool contract - Swap event)

    • Data from event
    • Entities
      • Bundle
      • Factory
      • Pool
      • Token
      • Transaction
      • Swap
      • UniswapDayData
      • PoolDayData
      • PoolHourData
      • TokenDayData
      • TokenHourData
    • Contract calls
      • Pool (feeGrowthGlobal0X128, feeGrowthGlobal1X128)
  • handleMint (Pool contract - Mint event)

    • Data from event
    • Entities
      • Bundle
      • Pool
      • Factory
      • Token
      • Transaction
      • Mint
      • Tick
      • UniswapDayData
      • PoolDayData
      • PoolHourData
      • TokenDayData
      • TokenHourData
  • handleBurn (Pool contract - Burn event)

    • Data from event
    • Entities
      • Bundle
      • Pool
      • Factory
      • Token
      • Burn
      • Tick
      • UniswapDayData
      • PoolDayData
      • PoolHourData
      • TokenDayData
      • TokenHourData
    • Extra methods
      • store.remove (remove Tick entity)

References