Skip to content

kushgupta18/scoutxsubgraph

Repository files navigation

Prerequisite

Install Ganache-Cli

npm i -g ganache-cli

Install Yarn

brew install yarn

Install Graph

# NPM
npm install -g @graphprotocol/graph-cli

Docker Node

Installing and Running

Step 1

Clone this repo

git clone https://github.com/kushalbery/admin_subgraph.git

Step 2

Run Ganache-Cli

ganache-cli -h 0.0.0.0 -d -l=15000000

Step 3

Clone and Run local graph node

docker-compose up

Step 4

Install npm packges

npm i

Step 5

Run subgraph

chmod +x ./start.sh
./start.sh

Query

  • Players

    {
        players(first: 1000) {
          id
          currentLongTokenPrice
          currentShortTokenPrice
          questionId
          trade(where: { timestamp_lt: "1647450015" }, first: 1, orderBy: timestamp, orderDirection: desc) {
            id
            longTokenPrice
            shortTokenPrice
            timestamp
            questionId
            fpmm {
              id
            }
          }
        }
      }
    Replace timestamp_lt value
  • User Profit & Loss Data

      query getUserPnl {
        userPlayerHoldings(where :{userId : "0x90f8bf6a479f320ead074411a4b0e7944ea8c9c1"}, subgraphError:allow){
          questionId
          tours{
            id
            userId
            questionId
            investmentAmount
            fpmmId
            outcomeIndex
            tokens
            player{
              currentLongTokenPrice
              currentShortTokenPrice
            }
          }
        }
      }
    

    Replace userId

Debug

  • In case of your graph-node exit with admin_subgraph_graph-node_1 exited with code 137 try restarting the graph-node container
  • To delete your old containers
    • docker rm $(docker ps -a -q)

To be reviewed

  • event Transfer in FPMM