Giter VIP home page Giter VIP logo

subgraphs's Introduction

The Graph

This repository contains multiple subgraphs:

Build

NETWORK=polygon pnpm exec turbo run build --scope=<subgraph> --force

Testing

Matchstick documentation

# Run all tests
pnpm exec turbo run test --scope=<SUBGRAPH_NAME>

# Run single test
pnpm exec turbo run test -- <TEST> --scope=<SUBGRAPH_NAME>

Misc

Deploy a subgraph by running the command below and replacing <APP_NAME> and <NETWORK_TYPE>, e.g. miso and kovan

APP=<APP_NAME> && NETWORK=<NETWORK_TYPE> && \
node . prepare $APP $NETWORK && \
pnpm exec turbo run codegen --scope=$APP && \
pnpm exec turbo run build --scope=$APP
pnpm exec turbo run deploy:$NETWORK --scope=$APP

Query

Example:

node . prepare miso kovan && pnpm exec turbo run codegen --scope=miso && pnpm exec turbo run build --scope=miso && pnpm exec turbo run deploy:kovan --scope=miso

Check status

curl -X POST -d '{ "query": "{indexingStatusForCurrentVersion(subgraphName: \"sushiswap/bentobox-polygon\") { chains { latestBlock { hash number }}}}"}' https://api.thegraph.com/index-node/graphql

CLI

Logging

node . log sushiswap/<subgraph> 

Deployment script

add a deploy.sh in the root dir with:

# V3 DEPLOYMENT
declare -a networks=("ethereum" "gnosis" "moonbeam" "optimism")
SUBGRAPH=v3
DIRECTORY=v3
USER=sushi-v3
ACCESS_TOKEN=SET_YOUR_ACCESS_TOKEN_HERE
for network in "${networks[@]}"
do
    echo "BUILD $network $DIRECTORY" 
    NETWORK=$network pnpm exec turbo run build --scope=$DIRECTORY --force
    echo "DEPLOYING TO $USER/$SUBGRAPH-$network" 
    cd subgraphs/$DIRECTORY/ && pnpm exec graph deploy --product hosted-service $USER/$SUBGRAPH-$network --access-token $ACCESS_TOKEN
    cd ../../
done

Studio deployment example

declare -a networks=("ethereum" "avalanche" "arbitrum" "bsc" "celo" "fuse" "fantom" "gnosis" "harmony" "moonriver" "moonbeam" "optimism" "boba" "polygon" "linea" "base" "scroll" "polygon-zkevm")
SUBGRAPH=rp4
DIRECTORY=route-processor
for network in "${networks[@]}"
do
    echo "BUILD $network $DIRECTORY" 
    NETWORK=$network pnpm exec turbo run build --scope=$DIRECTORY --force
    echo "DEPLOYING TO $SUBGRAPH-$network" 
    cd subgraphs/$DIRECTORY/
    pnpm graph deploy --studio $SUBGRAPH-$network -l v0.0.1
    cd ../../
done

subgraphs's People

Contributors

0xmasayoshi avatar dusknight4 avatar hhk-eth avatar jiro-ono avatar lufycz avatar matthewlilley avatar olastenberg 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

subgraphs's Issues

Pricing thresholds (unrealiable, without BentoBox embedded due to Trident using shares only)

There's two types of pricing which are core to the subgraph.

  1. Pricing of the native currency (in USD).
  2. Pricing of tokens (in derived NATIVE)

Both require a threshold to be able to protect against manipulation. You will see the use of MINIMUM_LIQUIDITY_THRESHOLD_ETH in the old pricing module.

https://github.com/sushiswap/sushiswap-subgraph/blob/master/subgraphs/exchange/src/pricing.ts#L94

This is problematic, because Trident deals in shares, we aren't able to set a threshold perminently without context to what 1 ETH for example is in shares. This might mean that the BentoBox subgraph is embedded into this one so we can track the relationship between shares (base) and amounts (elastic) on tokens held within the BentoBox.

Another area thresholds are used is for tracking pairs, we don't track pairs until a few conditions are satisfied, minimum number of LPs, but most importantly that a threshold is reached MINIMUM_USD_THRESHOLD_NEW_PAIRS. Again, problematic and even more so in this case for the same reasons. An example of the previous logic for this below.

https://github.com/sushiswap/sushiswap-subgraph/blob/master/subgraphs/exchange/src/mappings/pair.ts#L54

Buckets

Buckets are essentially just clones of an KPI variants of entities, Token & Pool KPIs are reflected in PoolHourBucket, PoolDayBucket, TokenHourBucket, TokenDayBucket.

Each entity during update needs it's buckets updated at the same time. In a similar fashion to legacy subgraph

e.g. https://github.com/sushiswap/sushiswap-subgraph/blob/master/subgraphs/exchange/src/mappings/pair.ts#L429

Schema needs updating for Pool entities & Token to have a dayBuckets & hourBuckets relation on each.

Additionally we need a FactoryDayBucket & FactoryHourBucket too which is a reflection of KPIs in the same way.

Missing sushiswap/master-chefv2

Does this repo contain the sushiswap/master-chefv2 subgraph? It seems I can't find it. Can you be kind to add it, please?

xSUSHI subgraph should aggregate data

should have aggregated on global entity

sushi entering the bar through enter()
sushi leaving the bar thorough leave()
sushi being directly transfered to the bar
xSUSHI minted
xSUSHI burned
xSUSHI:SUSHI ratio
SUSHI:xSUSHI ratio
APR?

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.