Code Monkey home page Code Monkey logo

v2-subgraph's Introduction

Uniswap V2 Subgraph

Uniswap is a decentralized protocol for automated token exchange on Ethereum.

This subgraph dynamically tracks any pair created by the uniswap factory. It tracks of the current state of Uniswap contracts, and contains derived stats for things like historical data and USD prices.

  • aggregated data across pairs and tokens,
  • data on individual pairs and tokens,
  • data on transactions
  • data on liquidity providers
  • historical data on Uniswap, pairs or tokens, aggregated by day

Running Locally

Make sure to update package.json settings to point to your own graph account.

Queries

Below are a few ways to show how to query the uniswap-subgraph for data. The queries show most of the information that is queryable, but there are many other filtering options that can be used, just check out the querying api. These queries can be used locally or in The Graph Explorer playground.

Key Entity Overviews

UniswapFactory

Contains data across all of Uniswap V2. This entity tracks important things like total liquidity (in ETH and USD, see below), all time volume, transaction count, number of pairs and more.

Token

Contains data on a specific token. This token specific data is aggregated across all pairs, and is updated whenever there is a transaction involving that token.

Pair

Contains data on a specific pair.

Transaction

Every transaction on Uniswap is stored. Each transaction contains an array of mints, burns, and swaps that occured within it.

Mint, Burn, Swap

These contain specifc information about a transaction. Things like which pair triggered the transaction, amounts, sender, recipient, and more. Each is linked to a parent Transaction entity.

Example Queries

Querying Aggregated Uniswap Data

This query fetches aggredated data from all uniswap pairs and tokens, to give a view into how much activity is happening within the whole protocol.

{
  uniswapFactories(first: 1) {
    pairCount
    totalVolumeUSD
    totalLiquidityUSD
  }
}

v2-subgraph's People

Contributors

chpiatt avatar dependabot[bot] avatar fubhy avatar ianlapham avatar jfrankfurt avatar lutter avatar macalinao avatar mr-uniswap avatar mtahon avatar noahzinsmeister avatar paulrberg avatar rbval avatar xgreenx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

v2-subgraph's Issues

How to fetch PairHourData?

Hey there,

I've been trying to fetch PairHourData using the graph explorer - https://thegraph.com/explorer/subgraph/uniswap/uniswap-v2

My understanding is that I should be able to pass a pair id and receive information about that pair. For example -

{
  pairHourData(id:"0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852") {
    hourStartUnix
  }
}

Am I missing something here?

What would be the best way to fetch pairHourData each hour for the last 12 hours?

Add Burn.from & Mint.from to track user EOA

Hi Ian!

This is a follow-up to #15, where Swap.from was added.

Adding the from field to Burn and Mint will allow access to the EOA initiating the transaction for LP interactions. As an example, Unspent uses those to calculate realized/unrealized PnL for LP positions.

Outdated data for HLH (Hot Lips Houlihan) ERC-20

While the subgraph returns the pool reserves of ~3.13 ETH and ~1563 HLH, the actual uniswap/sdk and etherscan show the pool reserves of ~5.29 ETH and ~2350 HLH. Also it misses trades 13 days from the time this github issue is raised.

As a result, on NIFTEX.com, we cannot get the proper chart.

May we know what causes this and whether subgraph plans to resolve this issue. Thanks in advance!

Attached are the reference links:
ERC-20 address: 0xfb925821eef8dfabe2788b322f436088650551cc
Pair address (HLH/WETH): 0xc999fbb8f9e7f0bba13c9e1b31d71e0996b44f48
Etherscan of https://etherscan.io/address/0xc999fbb8f9e7f0bba13c9e1b31d71e0996b44f48

Graphql query: query {
pairs(where: {
token1_in: ["0xfb925821eef8dfabe2788b322f436088650551cc"]
}) {
id
token0 {
name
symbol
id
}
token1 {
name
symbol
id
}
token1Price
volumeToken1
volumeToken0
reserve0
reserve1
createdAtBlockNumber
}
}

USD conversions - tracked vs untracked volume

For tokenA, we get its price in USD by searching for a tokenA <->WETH pair, finding tokenA per WETH, and then multiplying by USD price of WETH (which we get from an avergae of DAI and USDC pairs with WETH).

This becomes an issue for pairs that have goofy amounts of liquidity leading to unrealistic price. So if pair has 0.001 tokenB reserve, and 0.000000000000001 WETH, the USD price of tokenB will be unrealistically high.

This causes the biggest problems when calculating total volume across Uniswap. If someone goes into this pool and swaps 0.000001 tokenB, theyve just swapped millions of USD wroth of value.

Obviously we don't want to track this as a contribution to global volume. As an immediate fix the current volume-changes branch only counts tracked volume. This is just volume for pairs that include WETH, DAI, or USDC right now.

Tracked volume is only from pairs with USDC, DAI or WETH in the pair.

Derived volume is volume calculated using the derived USD price.

We use tracked volume for calculating global volume across Uniswap, we use derived volume for calculating per pair volume.

The issue is finding a safer way to get "derived" volume, so that ultimately we don't use tracked volume at all. Can we use some threshold of WETH for calculating USD prcies for tokens? Return a price of 0 on tokens where the WETH reserve in the token<->WETH pair is very small?

Use price0CumulativeLast/price1CumulativeLast

As far as I understand from the core.ts:

  pair.token0Price = pair.reserve0.div(pair.reserve1)
  pair.token1Price = pair.reserve1.div(pair.reserve0)

The current price data is not using priceXCumulativeLast from the uniswap v2 pair abi. Is there any particular reason?

Thanks for the work!

How to query TokenDayData ?

Could you please give me an example how to query tokendaydata api from uniswap-v2-subgraph?

There is a required parameter id. I found that it is token address concatenated with day id (day start timestamp in unix / 86400) from Docs. I tried the query like this:
{
tokenDayData(id:"0xd46ba6d942050d489dbd938a2c909a5d5039a16118486"){
id
token{
id
symbol
name
}
dailyTxns
dailyVolumeUSD
priceUSD
}
}
But cannot get correct response.

Fallback to Token Lists when name, symbol or decimals revert

Hello,

In the ERC-20 standard the following functions are optional:

  • name()
  • symbol()
  • decimals()

The current implementation relies heavily on these methods to determine the values, but some tokens do not have it implemented which result in broken values being updated in The Graph and tools using it.

In particular here:

  // try types string and bytes32 for name
  let nameValue = 'unknown'
  let nameResult = contract.try_name()
  if (nameResult.reverted) {
    let nameResultBytes = contractNameBytes.try_name()
    if (!nameResultBytes.reverted) {
      // for broken exchanges that have no name function exposed
      if (!isNullEthValue(nameResultBytes.value.toHexString())) {
        nameValue = nameResultBytes.value.toString()
      }
    }
  } else {
    nameValue = nameResult.value
  }

Graph Query:

{
  tokens(where: {name:"unknown"} ) {
    id
    symbol
    name
    decimals
  }
}

Answer:

{
  "data": {
    "tokens": [
      {
        "decimals": "0",
        "id": "0x1f0d3048b3d49de0ed6169a443dbb049e6daa6ce",
        "name": "unknown",
        "symbol": "BET99"
      },
      {
        "decimals": "0",
        "id": "0xeb9951021698b42e4399f9cbb6267aa35f82d59d",
        "name": "unknown",
        "symbol": "unknown"
      },
     [...]
    ]
  }
}

Uniswap.info pages broken:

However since the Token List standard allows to specify the token name, decimals and symbol, I would propose to fallback to a few common token lists (eg: Kleros, Coingecko) to determine the missing values.

Please let me know if you agree with this approach and I can propose a Pull Request.

Best Regards,
Mathieu

invalid access-token

Graph node "9b24cdd8e8484e78a17c34f9131fcdd9" is invalid: Invalid URL: 9b24cdd8e8484e78a17c34f9131fcdd9Graph node "9b24cdd8e8484e78a17c34f9131fcdd9" is invalid: Invalid URL: 9b24cdd8e8484e78a17c34f9131fcdd9

โœ– Failed to deploy to Graph node https://api.thegraph.com/deploy/: Invalid account name or access token
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

How to get a valid access-token??? thank you .

How do I get the real time token price data in pair

Hi!

I've deployed the service to my subgraph while I found the pair token price doesn't seem to be the real time data. May I ask how can I get the real time token price data instead?

I tried with the following query to get the first 5 pairs and checked the token0Price & token1Price, the timestamp shows it's not the current data. Should I use some other endpoint instead?

curl -i -d "{ \"query\": \"query { pairs(first: 5) { token0 { symbol } token1 { symbol } token0Price token1Price createdAtTimestamp }}\"}" https://api.thegraph.com/subgraphs/name/ilovelili/min-ju-graph

Thank you!
Min

Pool deposit amounts for LPs

Would be convienent to get deposit amounts per LP with one query. Would be nice to add deposit size in token0 and token1 for the LP position.

On the DAI/WETH pair an LP should be able to query how much of each token they have deposited.

poolOwnership is incorrect

{user (id:"0x84f1969784b38769c5ebb23db879e9eefdb26ea0")
{
  id,
  liquidityPositions {
    id,
    pair {
      id,
      reserve0,
      reserve1
    },
    poolOwnership,
    liquidityTokenBalance
  }
}}

returns

{ "data": { "user": { "id": "0x84f1969784b38769c5ebb23db879e9eefdb26ea0", "liquidityPositions": [ { "id": "0x1b8409c18b56fe081f0184535b0449289bdabcac-0x84f1969784b38769c5ebb23db879e9eefdb26ea0", "liquidityTokenBalance": "0.000005", "pair": { "id": "0x1b8409c18b56fe081f0184535b0449289bdabcac", "reserve0": "5738.9310355", "reserve1": "49.688136034685851761" }, "poolOwnership": "0.999999999800000000039999999992"

where actual pool ownership is 0.03% as shown on the UI

Please, explain why this is happening and if there is an error

tokenDayData is not returning data

{
  tokenDayData (id: "0x8400d94a5cb0fa0d041a3788e395285d61c9ee5e"){
    token {
      symbol
      name
    }
    priceUSD
    dailyTxns
  }
}

returns

{
  "data": {
    "tokenDayData": null
  }
}

Many consecutive snapshots with 0 LP token balance

Hello,
I have stumbled upon a weird behavior. For the following query I get multiple consecutive snapshots with 0 LP token balance. Shouldn't the snapshots be created only when there is a change in the user's position?

The query:

{
  liquidityPositionSnapshots(first: 1000, where: {user: "0x79d93cbf3583e62dd3edbddd1ee1121f8b07af81", pair:"0xce84867c3c02b05dc570d0135103d3fb9cc19433"}, orderBy: block, orderDirection: asc) {
    liquidityTokenBalance
    block
  }
}

The relevant part of the response:

      {
        "block": 10776948,
        "liquidityTokenBalance": "0"
      },
      {
        "block": 10777492,
        "liquidityTokenBalance": "0"
      },
      {
        "block": 10778660,
        "liquidityTokenBalance": "0"
      },

Thank you

Include staked LP tokens

Currently, the user page only shows liquidity & fees for LP tokens that are held by the user account. If a user adds liquidity, then stakes their LP tokens to earn UNI, the data will not be displayed.

The graph should query the balance of staked tokens as well.

liquidityProviderCount always return zero

{
  pairs (where: 
    {
      id: "0xb27de0ba2abfbfdf15667a939f041b52118af5ba"
    })
  {
    id
    volumeUSD
    reserveUSD
    liquidityProviderCount
    token0{
      name
    }
    token1{
      name
    }
  }
}

returns:

{
  "data": {
    "pairs": [
      {
        "id": "0xb27de0ba2abfbfdf15667a939f041b52118af5ba",
        "liquidityProviderCount": "0",
        "reserveUSD": "1282434.946265527871383145050837446",
        "token0": {
          "name": "UniBright"
        },
        "token1": {
          "name": "Wrapped Ether"
        },
        "volumeUSD": "21305032.79579640774783455801998891"
      }
    ]
  }
}

Missing Swap When Querying User Swaps

Hello,

I am currently trying to query for all swaps made under my account but am running into a situation where it does not seem possible for me to retrieve transactions with just an ETH address.

This is the TX which I am unable to retrieve:
https://etherscan.io/tx/0xd4a59c72cc2e32db55724907fd1171d9b7c4f907b8086ce030debeb9592b80a9

Inside the subgraph's playground, this swap was not included when filtering on a simple clause like this:
swaps(where: { to: $address })

I was only able to fetch this swap after looking through all transactions included in that same block and got this response json:

        "swaps": [
          {
            "amount0In": "2680.069038095470019237",
            "amount0Out": "0",
            "amount1In": "0",
            "amount1Out": "5",
            "pair": {
              "token0": {
                "symbol": "PIE"
              },
              "token1": {
                "symbol": "WETH"
              }
            },
            "timestamp": "1597256972",
            "sender": "0x7a250d5630b4cf539739df2c5dacb4c659f2488d",
            "to": "0x7a250d5630b4cf539739df2c5dacb4c659f2488d"
          }
        ]

In this response, both the sender and to addresses are the Uniswap contract address and my own ETH address is not included inside the swap response at all.

I am pretty new to the graph protocol, but it appears to me either the sender or to address should match my address so it can be queried and filtered on.

If this is not an issue, how is it possible to query this swap from only having an ETH address?

Improvement Request: totalSupply on pairHourData

Could we get totalSupply on the hourly pair data?
It looks like the data is available and you just need the corollary to this line
pairDayData.totalSupply = pair.totalSupply in updatePairDayData to updatePairHourData and whatever other bookkeeping is needed for a new attribute.

I don't have this running locally or I'd do a pull request,

Caching issue in subgraph - token name not updated

Hi team!

On uniswap, our token name remains unchanged as NRGT (https://info.uniswap.org/pair/0x5cd0dba2365c35620d6cb938385a029199a9a293) although the contract address have been updated to NRGE (https://etherscan.io/address/0x1416946162b1c2c871a73b07e932d2fb6c932069).

Could you please have a look and resolve this issue as we want to announce the token but want to make sure that everything is set up properly.

Thanks a lot for your time on this
Vi

Issue building the subgraph

Hi,

I'm simply trying to deploy my own clone of this and build ontop of it.

My attempt is failing after the following actions:

I cloned the repo,

ran yarn
ran: graph codegen --output-dir src/types/
// Runs successfully

then i ran "graph build"

and i get a huge list of missing types like the following:

Compile data source: Factory => build/Factory/Factory.wasm
โ ‹ Compile subgraphERROR TS2305: Module '~lib/@graphprotocol/graph-ts' has no exported member 'ethereum'.

ethereum,

in src/types/Factory/Factory.ts(4,2)

ERROR TS2305: Module '~lib/@graphprotocol/graph-ts' has no exported member 'DataSourceContext'.

DataSourceContext

in src/types/templates.ts(6,2)

ERROR TS2305: Module '~lib/@graphprotocol/graph-ts' has no exported member 'ethereum'.

ethereum,

in src/types/Factory/ERC20.ts(4,2)

ERROR TS2305: Module '~lib/@graphprotocol/graph-ts' has no exported member 'ethereum'.

ethereum,

in src/types/Factory/ERC20SymbolBytes.ts(4,2)

ERROR TS2305: Module '~lib/@graphprotocol/graph-ts' has no exported member 'ethereum'.

ethereum,

in src/types/Factory/ERC20NameBytes.ts(4,2)

ERROR TS2305: Module '~lib/@graphprotocol/graph-ts' has no exported member 'ethereum'.

ethereum,

in src/types/templates/Pair/Factory.ts(4,2)

ERROR TS2304: Cannot find name 'ethereum'.

export class PairCreated extends ethereum.Event {
~~~~~~~~
in src/types/Factory/Factory.ts(13,33)

ERROR TS2304: Cannot find name 'ethereum'.

export class Factory extends ethereum.SmartContract {
~~~~~~~~
in src/types/Factory/Factory.ts(43,29)

ERROR TS2304: Cannot find name 'ethereum'.

export class ConstructorCall extends ethereum.Call {
~~~~~~~~
in src/types/Factory/Factory.ts(165,37)

ERROR TS2304: Cannot find name 'ethereum'.

...

And it goes on

What am i missing?

I have made other graphs and have not had this issue.

Can't run the demo localhost

chrome show error
Access to fetch at 'https://thegraph.com/explorer/subgraph/uniswap/uniswap-v2' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Uniswap v2 subgraph has failed

Hi team,
I think subgraph of Uniswap v2 is dead, because I read log from Uniswap V2 subgraph and I saw the error:
Subgraph instance failed to run: Failed to invoke handler 'handleTransfer': Mapping aborted at ~lib/@graphprotocol/graph-ts/index.ts, line 1356, column 4, with message: Call reverted, probably because an assert or require in the contract failed, consider using try_totalSupply to handle this in the mapping. wasm backtrace: 0: 0x1647 - !<wasm function 62> 1: 0x1ea3 - !<wasm function 128> , code: SubgraphSyncingFailure, id: QmXKwSEMirgWVn41nRzkT3hpUBw29cp619Gx58XW6mPhZP

Failed to get entities from store: canceling statement due to conflict with recover

hi,
I'm trying to do a time-traveler query, to retrieve some info from uniswap subgraph.
i need to retrieve the historical state of that contract, to achieving this i run a while len(results_query["swaps"]) > 0:,
at every iteration the last block get fetched from the query and added to the next query that need to be executed.
after 2580 row, Failed to get entities from store: canceling statement due to conflict with recovery.
I'm asking for some explanation of the error or some troubleshooting technics.
i have another question about the subgraph, it have rate limit?
thanks, have a good day

QUERY: query trades($blockNum: Int=11814699) { swaps(where:{pair: "0xa478c2975ab1ea89e8196811f51a7b7ade33eb11"}, orderBy: timestamp, orderDirection: desc, first:15, block: {number:$blockNum}) { id timestamp amount0In amount1In amount0Out amount1Out } transaction { blockNumber } } }

Compiling Properly

Hello,
Do you run yarn version 1 or 2 ?
I tryed with version 2 :
yarn
yarn install
and I code errors :

โžค YN0000: โ”‚ UnhandledPromiseRejectionWarning: Error: assemblyscript@git+https://github.com/AssemblyScript/assemblyscript.git#36040d5b5312f19a025782b5e36663823494c2f3: Listing the refs for https://github.com/AssemblyScript/assemblyscript.git failed at r (C:\Users\mike\Documents\uniswap-v2-subgraph\uniswap-v2-subgraph\.yarn\releases\yarn-berry.cjs:17:22267) at A (C:\Users\mike\Documents\uniswap-v2-subgraph\uniswap-v2-subgraph\.yarn\releases\yarn-berry.cjs:17:22438) at ChildProcess.e.emit (C:\Users\mike\Documents\uniswap-v2-subgraph\uniswap-v2-subgraph\.yarn\releases\yarn-berry.cjs:17:22579) at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12) โžค YN0000: โ”‚ UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) โžค YN0000: โ”‚ DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. โžค YN0000: โ”‚ UnhandledPromiseRejectionWarning: Error: assemblyscript@git+https://github.com/AssemblyScript/assemblyscript.git#36040d5b5312f19a025782b5e36663823494c2f3: Listing the refs for https://github.com/AssemblyScript/assemblyscript.git failed at r (C:\Users\mike\Documents\uniswap-v2-subgraph\uniswap-v2-subgraph\.yarn\releases\yarn-berry.cjs:17:22267) at A (C:\Users\mike\Documents\uniswap-v2-subgraph\uniswap-v2-subgraph\.yarn\releases\yarn-berry.cjs:17:22438) at ChildProcess.e.emit (C:\Users\mike\Documents\uniswap-v2-subgraph\uniswap-v2-subgraph\.yarn\releases\yarn-berry.cjs:17:22579) at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12) โžค YN0000: โ”‚ UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag--unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)

Then when running : yarn run build :
Internal Error: uniswap-v2-subgraph@workspace:.: This package doesn't seem to be present in your lockfile; try to make an install to update your resolutions at J.getCandidates (C:\Users\mike\Documents\uniswap-v2-subgraph\uniswap-v2-subgraph\.yarn\releases\yarn-berry.cjs:2:347296) at n.getCandidates (C:\Users\mike\Documents\uniswap-v2-subgraph\uniswap-v2-subgraph\.yarn\releases\yarn-berry.cjs:2:336286) at C:\Users\mike\Documents\uniswap-v2-subgraph\uniswap-v2-subgraph\.yarn\releases\yarn-berry.cjs:2:357942 at Module.w (C:\Users\mike\Documents\uniswap-v2-subgraph\uniswap-v2-subgraph\.yarn\releases\yarn-berry.cjs:2:417413) at C (C:\Users\mike\Documents\uniswap-v2-subgraph\uniswap-v2-subgraph\.yarn\releases\yarn-berry.cjs:2:357905)

Thanks for the help

api design robustness

for the below query, the id must be lower case, otherwise no data return (but also no error), why it designed like this, please deal the case problem inside server-side... I spent several hours figuring out this issue.

{
 pair(id: "0xBb2b8038a1640196FbE3e38816F3e67Cba72D940"){
     reserveUSD
     trackedReserveETH
     token0Price
     token1Price
     volumeUSD
     txCount
 }
}

image

Add Swap.from to track trader EOA

Background

Swap currently tracks Swap.sender, which is the internal sender of the swap (e.g. Uniswap Router) and Swap.to, which is the originating contract (e.g. dex aggregator). We should also track the EOA account that initiated the swap. These could represent three different addresses.

Schema updates

https://github.com/Uniswap/uniswap-v2-subgraph/blob/master/schema.graphql

type Swap @entity {
  ...
  # populated from the Swap event
  from: Bytes!           # Originating EOA
  ...
}

Mapping updates

https://github.com/Uniswap/uniswap-v2-subgraph/blob/master/src/mappings/core.ts#L449

  swap.from = event.transaction.from;

Plans on adding support for Uniswap liquidity mining?

Pretty new to the graph protocol so forgive me if this is a dumb question. I am currently trying to query all of my transactions done on Uniswap and didn't see any mention of the Uniswap liquidity mining transactions.

Is it currently possible or are there any plans to add support for querying that data?

Uniswap Liquidity mining reference: https://app.uniswap.org/#/uni

API problem

When you API (v2) will be available again? At this moment it shows an error https://api.uniswap.info/v2/assets

"GraphQL error: Failed to decode `block.number` value: `subgraph QmNPKaPqgTqKdCv2k3SF9vAhbHo4PVb2cKx2Gs4PzNQkZx has only indexed up to block number 10481165 and data for block number 10489541 is therefore not yet available`"

README examples outdated

The examples provided in the README under the Querying User Data, and User Balances on Pairs are outdated. Transaction filter fields need to be renamed from timeStamp to timestamp, and tokenSymbol and userAddress no longer exists on the transaction filter.

I can provide new examples from queries I will be making, but they may not be the best showcases of functionality.

Broken Locally - JSON Results Always Empty

This subgraph does not work locally. The queries execute and always return blank JSON values.

My streaming thegraph's terminal log is pretty quiet and only showing new blocks and this repeating warning:

graph-node_1  | Aug 22 07:57:28.967 WARN Trying again after eth_call RPC call failed (attempt #26) with result Err(Web3Error(Transport("Unexpected response status code: 403 Forbidden"))), block_hash: 0x359d1dc4f14f9a07cba3ae8416958978ce98f78ad7b8d505925dad9722081f04, block_number: 10008355, subgraph_id: Qmem2vQPxhZGYf32D76oFaXp36ck6cy3qzj86gDNvoW4Da, component: SubgraphInstanceManager

The v1 one works (https://github.com/graphprotocol/uniswap-subgraph) with the exact same installation method (with v1 queries only obviously.)

I have no idea why it doesn't work. I've spent hours trying to get it to work. I also have no idea what I'm doing. Am I the only one in the world who's trying to run this locally? ยฏ\(ใƒ„)/ยฏ

Does it need an archive node to work?

I have tried installing it with and without docker on my home Ubuntu 20.04 computer and on a new, unmanaged Ubuntu 20.04 VPS. Both had all the ports open and firewalls off. Also, I tried both with Infura and a synced, fast-sync geth node. I only tried the v1 subgraph after to see if that works.

Needs to be fixed: For v1 and v2 in the package.json the "davekaj/uniswap" are exactly the same, causing an installation conflict if you want to run both
v1: "create-local": "graph create davekaj/uniswap --node http://127.0.0.1:8020",
v2: "create-local": "graph create davekaj/uniswap --node http://127.0.0.1:8020",

Local thegraph w/Uniswap v2 GraphQL POST (from my setup below)

http://IP:8000/subgraphs/name/davekaj/uniswap

{
  uniswapFactories(first: 1) {
    pairCount
    totalVolumeUSD
    totalLiquidityUSD
  }
}

output (always empty JSON):

{
    "data": {
        "uniswapFactories": []
    }
}

Local thegraph w/Uniswap V1 GraphQL POST

http://IP:8000/subgraphs/name/davekaj/uniswap (installed by itself since the URL structure conflicts with v2)

{
  uniswap(id: "1") {
    exchangeCount
    totalVolumeInEth
    totalLiquidityInEth
    totalVolumeUSD
    totalLiquidityUSD

    totalTokenBuys
    totalTokenSells
    totalAddLiquidity
    totalRemoveLiquidity
  }
}

output

{
    "data": {
        "uniswap": {
            "exchangeCount": 158,
            "totalAddLiquidity": "1118",
            "totalLiquidityInEth": "21825.539445390657723786",
            "totalLiquidityUSD": "2652750.80474073422812526480807834",
            "totalRemoveLiquidity": "382",
            "totalTokenBuys": "10527",
            "totalTokenSells": "8719",
            "totalVolumeInEth": "48010.664356604455559231",
            "totalVolumeUSD": "5683710.521175278208857501357184344"
        }
    }
}

Uniswap v2 subgraph docker setup

Fresh Ubuntu 20.04 install on an unmanaged VPS with no firewall

# apt update
# apt dist-upgrade

Install Rust

# curl https://sh.rustup.rs -sSf | sh
default option 1 selected
stable installed - rustc 1.45.2 (d3fb005a3 2020-07-31)
# source $HOME/.cargo/env

Install the correct yarn

# apt remove cmdtest
# curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
# echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
# apt update
# apt install yarn
# yarn --version
1.22.4

Install libsecret

prevents this error when installing uniswap-v2-subgraph:
"prebuild-install WARN install libsecret-1.so.0: cannot open shared object file: No such file or directDone"

# apt install -y libsecret-1-dev

Install docker + docker-compose

# apt install -y docker-compose
# docker -v
Docker version 19.03.8, build afacb8b7f0

Install extra Ubuntu packages

from https://github.com/graphprotocol/graph-node#running-a-local-graph-node

# sudo apt-get install -y clang libpq-dev libssl-dev pkg-config

Install + run thegraph and make sure it's syncing eth blocks

~# git clone https://github.com/graphprotocol/graph-node.git
~/graph-node/docker# vim docker-compose.yml

~/graph-node/docker# docker-compose up

Starting docker_ipfs_1     ... done
Starting docker_postgres_1 ... done
Recreating docker_graph-node_1 ... done
Attaching to docker_ipfs_1, docker_postgres_1, docker_graph-node_1
ipfs_1        | Changing user to ipfs
ipfs_1        | ipfs version 0.4.23
ipfs_1        | Found IPFS fs-repo at /data/ipfs
ipfs_1        | Initializing daemon...
ipfs_1        | go-ipfs version: 0.4.23-6ce9a35
ipfs_1        | Repo version: 7
ipfs_1        | System version: amd64/linux
ipfs_1        | Golang version: go1.12.16
postgres_1    |
postgres_1    | PostgreSQL Database directory appears to contain a database; Skipping initialization
postgres_1    |
postgres_1    | 2020-08-22 06:48:03.705 UTC [1] LOG:  starting PostgreSQL 12.4 (Debian 12.4-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
postgres_1    | 2020-08-22 06:48:03.709 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
postgres_1    | 2020-08-22 06:48:03.709 UTC [1] LOG:  listening on IPv6 address "::", port 5432
postgres_1    | 2020-08-22 06:48:03.711 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres_1    | 2020-08-22 06:48:03.730 UTC [24] LOG:  database system was interrupted; last known up at 2020-08-22 06:45:17 UTC
postgres_1    | 2020-08-22 06:48:03.795 UTC [24] LOG:  database system was not properly shut down; automatic recovery in progress
postgres_1    | 2020-08-22 06:48:03.796 UTC [24] LOG:  redo starts at 0/1645C40
postgres_1    | 2020-08-22 06:48:03.796 UTC [24] LOG:  invalid record length at 0/1645C78: wanted 24, got 0
postgres_1    | 2020-08-22 06:48:03.796 UTC [24] LOG:  redo done at 0/1645C40
postgres_1    | 2020-08-22 06:48:03.804 UTC [1] LOG:  database system is ready to accept connections
ipfs_1        | Swarm listening on /ip4/127.0.0.1/tcp/4001
ipfs_1        | Swarm listening on /ip4/172.18.0.2/tcp/4001
ipfs_1        | Swarm listening on /p2p-circuit
ipfs_1        | Swarm announcing /ip4/127.0.0.1/tcp/4001
ipfs_1        | Swarm announcing /ip4/172.18.0.2/tcp/4001
ipfs_1        | Swarm announcing /ip4/207.148.23.167/tcp/4001
ipfs_1        | API server listening on /ip4/0.0.0.0/tcp/5001
ipfs_1        | WebUI: http://0.0.0.0:5001/webui
ipfs_1        | Gateway (readonly) server listening on /ip4/0.0.0.0/tcp/8080
ipfs_1        | Daemon is ready
graph-node_1  | Aug 22 06:48:10.151 INFO Graph Node version: unknown (6ab7a3fd0 2020-08-21)
graph-node_1  | Aug 22 06:48:10.165 INFO Starting up
graph-node_1  | Aug 22 06:48:10.171 INFO Trying IPFS node at: http://ipfs:5001/
graph-node_1  | Aug 22 06:48:10.178 INFO Creating transport, capabilities: archive, trace, url: https://mainnet.infura.io/v3/runyourown, network: mainnet
graph-node_1  | Aug 22 06:48:10.189 INFO Successfully connected to IPFS node at: http://ipfs:5001/
graph-node_1  | Aug 22 06:48:10.196 INFO Connecting to Postgres, conn_pool_size: 10, url: postgresql://graph-node:HIDDEN_PASSWORD@postgres:5432/graph-node
graph-node_1  | Aug 22 06:48:10.235 INFO Connected to Postgres, url: postgresql://graph-node:HIDDEN_PASSWORD@postgres:5432/graph-node, pool_name: main, component: Store
graph-node_1  | Aug 22 06:48:10.244 INFO Connecting to Ethereum..., capabilities: archive, trace, network: mainnet
graph-node_1  | Aug 22 06:48:10.350 INFO Connected to Ethereum, capabilities: archive, trace, network_version: 1, network: mainnet
graph-node_1  | Aug 22 06:48:10.355 INFO Waiting for other graph-node instances to finish migrating, component: Store
graph-node_1  | Aug 22 06:48:10.357 INFO Running migrations, component: Store
graph-node_1  | Aug 22 06:48:10.736 INFO Migrations finished, component: Store
graph-node_1  | Aug 22 06:48:10.740 INFO Completed pending Postgres schema migrations, component: Store
graph-node_1  | Aug 22 06:48:10.745 INFO Creating LoadManager in disabled mode, component: LoadManager
graph-node_1  | Aug 22 06:48:10.748 INFO Starting block ingestors
graph-node_1  | Aug 22 06:48:10.750 INFO Starting block ingestor for network, network_name: mainnet
graph-node_1  | Aug 22 06:48:10.765 INFO Starting JSON-RPC admin server at: http://localhost:8020, component: JsonRpcServer
graph-node_1  | Aug 22 06:48:10.769 INFO Starting GraphQL HTTP server at: http://localhost:8000, component: GraphQLServer
graph-node_1  | Aug 22 06:48:10.771 INFO Starting index node server at: http://localhost:8030, component: IndexNodeServer
graph-node_1  | Aug 22 06:48:10.773 INFO Starting metrics server at: http://localhost:8040, component: MetricsServer
graph-node_1  | Aug 22 06:48:10.776 INFO Started all subgraphs, component: SubgraphRegistrar
graph-node_1  | Aug 22 06:48:10.778 INFO Starting GraphQL WebSocket server at: ws://localhost:8001, component: SubscriptionServer
graph-node_1  | Aug 22 06:48:10.954 INFO Downloading latest blocks from Ethereum. This may take a few minutes..., network_name: mainnet, component: BlockIngestor
graph-node_1  | Aug 22 06:49:26.366 INFO Syncing 4 blocks from Ethereum., code: BlockIngestionStatus, blocks_needed: 4, blocks_behind: 4, latest_block_head: 10708535, current_block_head: 10708531, network_name: mainnet, component: BlockIngestor
graph-node_1  | Aug 22 06:49:45.539 INFO Syncing 1 blocks from Ethereum., code: BlockIngestionStatus, blocks_needed: 1, blocks_behind: 1, latest_block_head: 10708536, current_block_head: 10708535, network_name: mainnet, component: BlockIngestor
...

Clone Uniswap v2 subgraph

If you do everything below but for uniswap v1 subgraph repo then that will work
~# git clone https://github.com/Uniswap/uniswap-v2-subgraph.git

Cloning into 'uniswap-v2-subgraph'...
remote: Enumerating objects: 135, done.
remote: Counting objects: 100% (135/135), done.
remote: Compressing objects: 100% (80/80), done.
remote: Total 1033 (delta 73), reused 86 (delta 39), pack-reused 898
Receiving objects: 100% (1033/1033), 534.19 KiB | 14.06 MiB/s, done.
Resolving deltas: 100% (552/552), done.

Yawn

~/uniswap-v2-subgraph# yarn

yarn install v1.22.4
[1/4] Resolving packages...
[2/4] Fetching packages...
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
Done in 18.81s.

Yarning

~/uniswap-v2-subgraph# yarn codegen

yarn run v1.22.4
$ graph codegen --output-dir src/types/
  Skip migration: Bump mapping apiVersion from 0.0.1 to 0.0.2
  Skip migration: Bump mapping apiVersion from 0.0.2 to 0.0.3
  Skip migration: Bump mapping specVersion from 0.0.1 to 0.0.2
โœ” Apply migrations
โœ” Load subgraph from subgraph.yaml
  Load contract ABI from abis/factory.json
  Load contract ABI from abis/ERC20.json
  Load contract ABI from abis/ERC20SymbolBytes.json
  Load contract ABI from abis/ERC20NameBytes.json
โœ” Load contract ABIs
  Generate types for contract ABI: Factory (abis/factory.json)
  Write types to src/types/Factory/Factory.ts
  Generate types for contract ABI: ERC20 (abis/ERC20.json)
  Write types to src/types/Factory/ERC20.ts
  Generate types for contract ABI: ERC20SymbolBytes (abis/ERC20SymbolBytes.json)
  Write types to src/types/Factory/ERC20SymbolBytes.ts
  Generate types for contract ABI: ERC20NameBytes (abis/ERC20NameBytes.json)
  Write types to src/types/Factory/ERC20NameBytes.ts
โœ” Generate types for contract ABIs
  Generate types for data source template Pair
  Write types for templates to src/types/templates.ts
โœ” Generate types for data source templates
  Load data source template ABI from abis/pair.json
  Load data source template ABI from abis/factory.json
โœ” Load data source template ABIs
  Generate types for data source template ABI: Pair > Pair (abis/pair.json)
  Write types to src/types/templates/Pair/Pair.ts
  Generate types for data source template ABI: Pair > Factory (abis/factory.json)
  Write types to src/types/templates/Pair/Factory.ts
โœ” Generate types for data source template ABIs
โœ” Load GraphQL schema from schema.graphql
  Write types to src/types/schema.ts
โœ” Generate types for GraphQL schema

Types generated successfully

Done in 3.12s.

"Yarn local"

Local even though you can query thegraph non-locally
This will fail if thegraph isn't running from above
~/uniswap-v2-subgraph# yarn create-local

yarn run v1.22.4
$ graph create davekaj/uniswap --node http://127.0.0.1:8020
Created subgraph: davekaj/uniswap
Done in 1.92s.

Magically integrate the uniswap v2 subgraph into the running thegraph node

~/uniswap-v2-subgraph# yarn deploy-local

yarn run v1.22.4
$ graph deploy davekaj/uniswap --debug --ipfs http://localhost:5001 --node http://127.0.0.1:8020
  Skip migration: Bump mapping apiVersion from 0.0.1 to 0.0.2
  Skip migration: Bump mapping apiVersion from 0.0.2 to 0.0.3
  Skip migration: Bump mapping specVersion from 0.0.1 to 0.0.2
โœ” Apply migrations
โœ” Load subgraph from subgraph.yaml
  Compile data source: Factory => build/Factory/Factory.wasm
  Compile data source template: Pair => build/templates/Pair/Pair.wasm
โœ” Compile subgraph
  Copy subgraph file build/schema.graphql
  Write subgraph file build/Factory/abis/factory.json
  Write subgraph file build/Factory/abis/ERC20.json
  Write subgraph file build/Factory/abis/ERC20SymbolBytes.json
  Write subgraph file build/Factory/abis/ERC20NameBytes.json
  Write subgraph file build/Pair/abis/pair.json
  Write subgraph file build/Pair/abis/factory.json
  Write subgraph manifest build/subgraph.yaml
โœ” Write compiled subgraph to build/
  Add file to IPFS build/schema.graphql
                .. QmXs1LGtqmGNBpMsL4hhoi5sWR9xM3p2Y9ZRmDwum5AaHD
  Add file to IPFS build/Factory/abis/factory.json
                .. QmZ55G1yYFzde8Vcq4cpLfNgPSEibpLi9aYCqS1jEvCKQ9
  Add file to IPFS build/Factory/abis/ERC20.json
                .. QmXuTbDkNrN27VydxbS2huvKRk62PMgUTdPDWkxcr2w7j2
  Add file to IPFS build/Factory/abis/ERC20SymbolBytes.json
                .. QmbHnhUFZa6qqqRyubUYhXntox1TCBxqryaBM1iNGqVJzT
  Add file to IPFS build/Factory/abis/ERC20NameBytes.json
                .. QmQCP6Pdp1MqpwRv2qoPHuUTwZGy7Q3eDHg4w5kzwE9mBj
  Add file to IPFS build/Factory/Factory.wasm
                .. QmZLfiUaV9CR62UQRccEoJM6fJa5p219rvXiwi3FQVpnny
  Add file to IPFS build/Pair/abis/pair.json
                .. QmbPLMADBP8L6LBVP3ZBQ8RgG7ghamD8DvbdUxHAjZrLgm
  Add file to IPFS build/Pair/abis/factory.json
                .. QmZ55G1yYFzde8Vcq4cpLfNgPSEibpLi9aYCqS1jEvCKQ9
  Add file to IPFS build/templates/Pair/Pair.wasm
                .. QmdgGPjB2osMbrKoVb9PvTeM9zLoPkSsSoPAZGfLhxWLXU
โœ” Upload subgraph to IPFS

Build completed: Qmem2vQPxhZGYf32D76oFaXp36ck6cy3qzj86gDNvoW4Da

Deployed to http://127.0.0.1:8000/subgraphs/name/davekaj/uniswap/graphql

Subgraph endpoints:
Queries (HTTP):     http://127.0.0.1:8000/subgraphs/name/davekaj/uniswap
Subscriptions (WS): http://127.0.0.1:8001/subgraphs/name/davekaj/uniswap

Done in 9.44s.

Query Time

http://OUTSIDEIP:8000/subgraphs/name/davekaj/uniswap
Now the Uniswap v2 subgraph graphql queries will execute (just like from thegraph) but the output is always empty JSON and thegraph's terminal log is quiet besides new blocks and this repeating warning:

graph-node_1  | Aug 22 07:57:28.967 WARN Trying again after eth_call RPC call failed (attempt #26) with result Err(Web3Error(Transport("Unexpected response status code: 403 Forbidden"))), block_hash: 0x359d1dc4f14f9a07cba3ae8416958978ce98f78ad7b8d505925dad9722081f04, block_number: 10008355, subgraph_id: Qmem2vQPxhZGYf32D76oFaXp36ck6cy3qzj86gDNvoW4Da, component: SubgraphInstanceManager

LiquidityPositionSnapshot points to a non-existent user

For the following query the graph throws "Null value resolved for non-null field user" error.

{
    liquidityPositionSnapshot(id: "0x559697e36f6939a033bd348be9db8bdd6d6213e0-0x1591916908") {
        block
        user {
            id
        }
    }
}

It must be a bug in mappings which allows setting the user id with a string which doesn't correspond to any User entity.

Relevant comment in the graph discord.

Token and Pair entities not tracking MPH token correctly

Issue description

The MPH-WETH pair has existing liquidity and trades (see pair contract), but the Token entity for MPH and the Pair entity for the MPH-WETH pair are not tracking the liquidity and trade data.

Example query

Query

{
  token(id: "0x75a1169e51a3c6336ef854f76cde949f999720b1") {
    symbol
    name
    tradeVolume
    tradeVolumeUSD
    untrackedVolumeUSD
    txCount
    totalLiquidity
  }
  pair(id: "0xfd9aacca3c5f8ef3aaa787e5cb8af0c041d8875f") {
    reserve0
    reserve1
    totalSupply
    reserveETH
    reserveUSD
    trackedReserveETH
    token0Price
    token1Price
    volumeToken0
    volumeToken1
    volumeUSD
    untrackedVolumeUSD
    txCount
    liquidityProviderCount
  }
}

Result

{
  "data": {
    "pair": {
      "liquidityProviderCount": "0",
      "reserve0": "0",
      "reserve1": "0",
      "reserveETH": "0",
      "reserveUSD": "0",
      "token0Price": "0",
      "token1Price": "0",
      "totalSupply": "0",
      "trackedReserveETH": "0",
      "txCount": "0",
      "untrackedVolumeUSD": "0",
      "volumeToken0": "0",
      "volumeToken1": "0",
      "volumeUSD": "0"
    },
    "token": {
      "name": "88mph.app",
      "symbol": "MPH",
      "totalLiquidity": "0",
      "tradeVolume": "0",
      "tradeVolumeUSD": "0",
      "txCount": "0",
      "untrackedVolumeUSD": "0"
    }
  }
}

Expected result

The zero-valued entries should not be zero, given the activity in the pair contract.

Uniswap v2 Subgraph instance has failed to run

Hi team,

Was testing out queries in the playground and noticed the graph was out of sync and this error showed in the logs:

https://thegraph.com/explorer/subgraph/uniswap/uniswap-v2?selected=logs

Subgraph instance failed to run: Failed to invoke handler 'handleTransfer': Mapping aborted at ~lib/@graphprotocol/graph-ts/index.ts, line 1356, column 4, with message: Call reverted, probably because an `assert` or `require` in the contract failed, consider using `try_balanceOf` to handle this in the mapping. wasm backtrace: 0: 0x1dd8 - <unknown>!<wasm function 123> 1: 0x1df6 - <unknown>!<wasm function 124> 2: 0x258d - <unknown>!<wasm function 145> , code: SubgraphSyncingFailure, id: QmWTrJJ9W8h3JE19FhCzzPYsJ2tgXZCdUqnbyuo64ToTBN

Raising in issue as an FYI.

Cheers,

Documentation

It would be really helpful to have some documentation that can be seen on the graph website explorer when experimenting with this subgraph. I know that it is very common to have copious docs on subgraphs at this point in time, but it would greatly improve the UX to just have a short sentence that describes each endpoint in the graph.

The `skip` argument must be between 0 and 5000

This query:
const myQuery = gqlquery tokens($skip: Int!) { tokens(first: 1000, skip: $skip) { id name symbol } }
, for values of skip > 5000 returns:
"Error: GraphQL error: The skip argument must be between 0 and 5000, but is..."

Why?? This used to work fine (like 3 weeks ago).

replacement for poolOwnership field under LiquidityPosition

with updated schema and removal of poolOwnership - what is the best method to obtain a user addresses' LP ownership share? query that I had prior to removal was:
query
{
users (first: 1, where: {id:'''+str(ethaddress)+'''})
{
liquidityPositions
{
poolOwnership
pair
{
id
token0
{
id
symbol
name
}
token1
{
id
symbol
name
}
reserve0
reserve1
}
liquidityTokenBalance
}

     }

}
'''

What does this even do?

https://github.com/Uniswap/uniswap-v2-subgraph/blob/9692685423f9a16fa30a2cf08ceeff69fcdd8367/src/mappings/pricing.ts#L71

Ive ran test after test and it always returns 0.

token.derivedETH seems to only be set here

https://github.com/Uniswap/uniswap-v2-subgraph/blob/master/src/mappings/core.ts#L241

and its set by this function
https://github.com/Uniswap/uniswap-v2-subgraph/blob/9692685423f9a16fa30a2cf08ceeff69fcdd8367/src/mappings/pricing.ts#L71

but this function references ANOTHER token.derivedETH, but if it never gets set anywhere its always 0, because something times zero is always zero. This function is everywhere.

Is it getting set somewhere else that im unaware of?

Subgraph stucked syncing at 10637439 block

Graph-node 0.19.2 (2020-11-24)
Uniswap-Subgrapv-V2 : master branch

Using local graph-node with deployed Uniswap-Subgraph-V2.
Today it stucked with error :

INFO Done processing Ethereum trigger, waiting_ms: thread 'mapping-QmQkfiA1MRv4WQRfxgVgi7PCZ6gziNhXwJkjD1NYfRHwHt-24a75a94-b7ab-44c7-b700-e1d06221edf7' 
panicked at 'called `Option::unwrap()` on a `None` value', graph/src/components/ethereum/types.rs:323:41
stack backtrace:
0, handler: handleSwap, total_ms: 100, trigger_type: Log, address: 0x583cโ€ฆ01f1, 
signature: Swap(indexed address,uint256,uint256,uint256,uint256,indexed address), 
runtime_host: 1/1, 
block_hash: 0xaf7f22c74a9a83291286644015369af80f5fb97afbe5692a82f2d3bff3614726, 
block_number: 10637439, subgraph_id: QmQkfiA1MRv4WQRfxgVgi7PCZ6gziNhXwJkjD1NYfRHwHt, 
component: SubgraphInstanceManager
   0:     0x55a4e288aef0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2e8cb764b7fe02e7
   1:     0x55a4e28aef1c - core::fmt::write::h7a1184eaee6a8644
   2:     0x55a4e2882f32 - std::io::Write::write_fmt::haeeb374d93a67eac
   3:     0x55a4e288d33d - std::panicking::default_hook::{{closure}}::hde0cb80358a6920a
   4:     0x55a4e288cfe8 - std::panicking::default_hook::h9b1a691049a0ec8f
   5:     0x55a4e288da21 - std::panicking::rust_panic_with_hook::h2bdec87b60580584
   6:     0x55a4e288d5c9 - std::panicking::begin_panic_handler::{{closure}}::h101ca09d9df5db47
   7:     0x55a4e288b35c - std::sys_common::backtrace::__rust_end_short_backtrace::h3bb85654c20113ca
   8:     0x55a4e288d589 - rust_begin_unwind
   9:     0x55a4e28ac391 - core::panicking::panic_fmt::h48c31e1e3d550146
  10:     0x55a4e28ac2dd - core::panicking::panic::h184ede6dd822ffb4
  11:     0x55a4e20be197 - <graph::components::ethereum::types::EthereumTransactionData as core::convert::From<&web3::types::transaction::Transaction>>::from::hf2a1e5089dee2ab5
  12:     0x55a4e1b00927 - graph_runtime_wasm::module::WasmInstance::handle_ethereum_log::h24c562be7979de0d
  13:     0x55a4e1ab1aaf - <futures::stream::for_each::ForEach<S,F,U> as futures::future::Future>::poll::ha68e3d047783eb9a
  14:     0x55a4e1aa943c - futures::task_impl::std::set::h76fc19cee70f9909
  15:     0x55a4e1b2bc36 - futures::task_impl::Spawn<T>::poll_future_notify::hc5d3e4e72c577123
  16:     0x55a4e1ab109e - futures::future::Future::wait::h369d8faf2f596bdf
  17:     0x55a4e1ae617e - tokio::runtime::context::enter::h1d4ac43047ca276b
  18:     0x55a4e1ad7b07 - std::sys_common::backtrace::__rust_begin_short_backtrace::hb6cb81cfdd6e0805
  19:     0x55a4e1ad8d16 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h37e5ce076cefb8c2
  20:     0x55a4e28914fa - std::sys::unix::thread::Thread::new::thread_start::h4afaeade0da13617
  21:     0x7f68cc9defa3 - start_thread
  22:     0x7f68ccc764cf - clone
  23:                0x0 - <unknown>

ERRO Subgraph instance failed to run: Failed to process trigger in block #10637439 (af7f22c74a9a83291286644015369af80f5fb97afbe5692a82f2d3bff3614726), 
transaction 156fea9ee3d5d2806dd05b4d6cec0e6002c3f7367837843165fc152fa11a6de9: 
Mapping terminated before handling trigger: oneshot canceled, code: 
SubgraphSyncingFailure, id: QmQkfiA1MRv4WQRfxgVgi7PCZ6gziNhXwJkjD1NYfRHwHt, 
subgraph_id: QmQkfiA1MRv4WQRfxgVgi7PCZ6gziNhXwJkjD1NYfRHwHt, 
component: SubgraphInstanceManager

How can this issue be resolved ?
What version of Uniswap-Subgraph is deployed in https://thegraph.com ??

Beginner Question About Usage

Hello and thank you very much for this project !

It can be a dumb question but, I searched everywhere : either on thegraph api documentation or uniswap api doc, but I don't clearly understand how and what is the purpose of this ?
For example, I created a basic script here with axios and it works pretty well :

https://pastebin.com/z6fsP364

I have cloned the depo, do yarn on the depo, then yarn run codegen then yarn run codegen, then yarn run create-local
But without any documentation, it is really confusing for me.

Did someone has a great introduction or quick tutorial on how to get started ?

Thank you very much.

Possible division by zero due to one of pair reserves being empty

We're using Uniswap v2 subgraph to query pricing for the DAO project we're working on (Pollen, https://hello.pollen.id/).

We wanted to have it on ropsten. Upon deployment and syncing with The Graph the division by zero error was thrown. It comes from the ropsten block 8125469 and it's related to this transaction:

https://ropsten.etherscan.io/tx/0x73d0d1a12cec1f0a9f78e303e576635b4f85de2bedde9142286b68c6ae5e2107

The error tells us that one of the pair reserves was empty. That's not supposed to happen given the UniswapV2Pair logic. Perhaps pool was tipped?

Proposed solution is to use simple notEqual(ZERO_BD) check.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.