Git Product home page Git Product logo

balancer-subgraph's People

Contributors

bonustrack avatar dependabot-preview[bot] avatar johngrantuk avatar mikemcdonald avatar tomafrench 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

Watchers

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

balancer-subgraph's Issues

Feature request - daily aggregated data

I am making a request for a feature in this subgraph - daily aggregated data, such as is present on the Uniswap subgraph under the name uniswapDayData. This is an extremely useful feature for other subgraphs, and reduces the need for heavily querying a graph to find day aggregated data. Specifically, I am posting this because I am trying to query the daily transaction count, but it seems that this value returns as 0 in many cases because there were no transactions in that particular block.

handleBind decimals

handleBind should call decimals() on any erc20 added and normalize the amount based on the return. Defaults to 18 if an erc20 doesn’t implement that method

Missing Users for Swap and Transaction Entities

Background

Swap does not include a user address. Transaction includes null values for userAddress. Users should always be available from these entities (a from address is always available from events).

The source of the problem is that User objects are only created in createPoolShareEntity and handleFinalize. These should be created in additional functions.

Example

https://thegraph.com/explorer/subgraph/balancer-labs/balancer

Query

{
  transaction(id:"0x00af94491b423c1ea48634db95712a12edece4805880f9595816f8470e68e4f2-50") {
    id
    event
    userAddress { id }
  }
  user(id:"0xffbfdb803d38d794b5785ee0ac09f83b429d11b5") {
    id
  }
}

Actual result

{
  "data": {
    "transaction": {
      "event": "swap",
      "id": "0x00af94491b423c1ea48634db95712a12edece4805880f9595816f8470e68e4f2-50",
      "userAddress": null
    },
    "user": null
  }
}

Expected

{
  "data": {
    "transaction": {
      "action": null,
      "event": "swap",
      "id": "0x00af94491b423c1ea48634db95712a12edece4805880f9595816f8470e68e4f2-50",
      "sender": null,
      "userAddress": "0xffbfdb803d38d794b5785ee0ac09f83b429d11b5"
    },
    "user": {
      "id": "0xffbfdb803d38d794b5785ee0ac09f83b429d11b5"
    }
  }
}

Schema Updates

Affects:

type Swap @entity {
    ...
    userAddress: User! # EOA account that initiates the swap
}

type Transaction @entity {
    ...
    userAddress: User! # EOA account that initiates the swap
}

type User @entity {
    ...
    swaps: [Swap!]  @derivedFrom(field: "userAddress")
}

Mapping Updates

Suggested approach:

  1. Create a new helper createAndReturnUser which creates a new User entity if it does not exist and returns a User entity.
  2. Create a new helper createTransaction which creates a new Transaction entity if it does not exist.
  3. Update mapping to ensure a User is always created and made available for Transaction values.
  4. Replace repetitive Transaction with helper function createTransaction

https://github.com/balancer-labs/balancer-subgraph/blob/e93c724ee5b8de47204df8bb77e821b3168efe28/src/mappings/pool.ts

Call helper createAndReturnUser anywhere a User value is assigned in the following functions which create Transactions:

  • handleSetSwapFee
  • handleSetController
  • handleSetPublicSwap
  • handleFinalize
  • handleRebind
  • handleUnbind
  • handleGulp
  • handleJoinPool
  • handleExitPool
  • handleSwap

Assign a swap.userAddress value with helper createAndReturnUser in function handleSwap

PoolShare entity with user being the pool itself

There seems to be a bug in the data as there exist a PoolShare entity where the user is the pool itself. Here is an example query and output:

{
  poolShares(where: {userAddress: "0x5e37910cfb8de1b14ec4e4bac0bec27c35dc07d5"}) {
    id
    balance
    poolId {
      id
    }
  }
}
{
  "data": {
    "poolShares": [
      {
        "balance": "0",
        "id": "0x5e37910cfb8de1b14ec4e4bac0bec27c35dc07d5-0x5e37910cfb8de1b14ec4e4bac0bec27c35dc07d5",
        "poolId": {
          "id": "0x5e37910cfb8de1b14ec4e4bac0bec27c35dc07d5"
        }
      }
    ]
  }
}

How is this possible? Are the BPTs sent to the pool itself upon user's liquidity withdrawal?

Transactions Schema Cleanup

Background

The Transaction schema can be cleaned up and make tighter guarantees for data.

Require event

Transaction.event is always set - update the schema to require this value.

https://thegraph.com/explorer/subgraph/balancer-labs/balancer

Query

{
  transactions(
    where:{
      event: null
    }
  ) {
    id
  }
}

Result

{
  "data": {
    "transactions": []
  }
}

Remove action

Transaction.action is never set. Remove from schema.

Query

{
  transactions(
    where:{
      action_not: null
    }
  ) {
    id
  }
}

Result

{
  "data": {
    "transactions": []
  }
}

Remove sender

Transaction.sender is never set. Remove from schema.

Query

{
  transactions(
    where:{
      sender_not: null
    }
  ) {
    id
  }
}

Result

{
  "data": {
    "transactions": []
  }
}

Subgraph doesn't properly track changes in pool.crpController

For the new Balancer safe app I'm using a contract to deploy any pools and then immediately transfer ownership over to the Gnosis Safe.

It seems like the subgraph only tracks who initially deployed the smart pool contract and doesn't track any further changes. As far as the subgraph (and so the UI) knows, all these pools are still owned by the BalancerPoolDeployer contract rather than the user's Gnosis Safe. This means that no smart pools will appear in the "My Pools" list and so unless these pools are whitelisted by the Balancer team they will be inaccessible.

This is a blocking issue for the new Safe app.

3+ billion total swap volume in one day (1st of August)

While crunching the data in the subgraph, noticed that there's one pool with contract address 0xb835e10742fd05621780158790d7ae8cfa8c6f05 that accumulated 3+ billion swap volume in one day, 1st of August 2020:
image

and hasn't accumulated more after that:
image

Just wanted to double-check whether this in fact is right data or if there might be an issue with indexing.

finalizedPoolCount gives a negative number

We use Balancer's finalizedPoolCount to get the total number of pools to query data from:

image

at block height 10118632 this number is positive however:

image

Curious if there's some bug in the graph mapper?

Confusing naming

Having userAddress attribute reference user entity is confusing. It would be better to have it named as the referenced entity.

Getting error when try to deploy subgraph in graph node

Getting error in graph node logs when try to deploy balancer subgraph

Aug 21 13:15:36.545 ERRO Subgraph instance failed to run: RPC error: Error { code: MethodNotFound, message: "the method trace_filter does not exist/is not available", data: None }, code: SubgraphSyncingFailure, id: QmTMsUH9rUVjpBTDRNuUcNHM3rT9ZZmxkDmTYmyKUpzEJn, subgraph_id: QmTMsUH9rUVjpBTDRNuUcNHM3rT9ZZmxkDmTYmyKUpzEJn, component: SubgraphInstanceManager
Aug 21 13:15:41.071 INFO Syncing 1 blocks from Ethereum., code: BlockIngestionStatus, blocks_needed: 1, blocks_behind: 1, latest_block_head: 10703787, current_block_head: 10703786, network_name: mainnet,
component: BlockIngestor

To run graph-node, I use my geth-node address as --ethereum-rpc flag. Do I need to enable any rpcapi during running geth node?

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.