balancer / balancer-subgraph Goto Github PK
View Code? Open in Web Editor NEWSubgraph (Graph Protocol) data layer for Balancer pools, swaps, txs, users
License: MIT License
Subgraph (Graph Protocol) data layer for Balancer pools, swaps, txs, users
License: MIT License
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.
It would be useful to have snapshots of user's pool shares available in the subgraph. Uni v2 subgraph has this functionality implemented.
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
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.
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"
}
}
}
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")
}
Suggested approach:
createAndReturnUser
which creates a new User entity if it does not exist and returns a User entity.createTransaction
which creates a new Transaction entity if it does not exist.Transaction
with helper function createTransaction
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
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?
The Transaction
schema can be cleaned up and make tighter guarantees for data.
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": []
}
}
action
Transaction.action
is never set. Remove from schema.
Query
{
transactions(
where:{
action_not: null
}
) {
id
}
}
Result
{
"data": {
"transactions": []
}
}
sender
Transaction.sender
is never set. Remove from schema.
Query
{
transactions(
where:{
sender_not: null
}
) {
id
}
}
Result
{
"data": {
"transactions": []
}
}
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.
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:
and hasn't accumulated more after that:
Just wanted to double-check whether this in fact is right data or if there might be an issue with indexing.
Having userAddress attribute reference user entity is confusing. It would be better to have it named as the referenced entity.
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?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.