0.0.7 • Published 2 years ago

@dipdup/dapp-stats v0.0.7

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Dappstore GQL client

npm version Made With License: MIT

Autogenerated typed SDK for Dappstore API with a built-in GQL client.

Installation

npm i @dipdup/dapp-stats

Usage

First of all you need to create an instance of Dappstore client:

import { createClient } from '@dipdup/dapp-stats'

const client = createClient({
    url: 'http://dapps-indexer.dipdup.net/v1/graphql',
    subscription: {
        url: "wss://dapps-indexer.dipdup.net/v1/graphql"
    }
});

Query

import { everything } from '@dipdup/dapp-stats'

client.chain.query
    .dapp()
    .get({ ...everything })
    .then(res => console.log)

Reference queries

Dapps listing

Query all dapps with highlights

query Dapps($frame: string) {
    dapp {
        slug,
        metadata,  # json
        dapp_highlights(where: {frame: {eq: $frame}}) {
            num_interactions,
            num_interactions_change,
            num_users,
            num_users_change,
            volume_usd,
            volume_usd_change,
            tvl_usd,
            tvl_usd_change,
        },
        num_contracts
    }
}

Dapp page

query Dapp($slug: string, $frame: string) {
    dapps(where: {slug: {eq: $slug}}) {
        slug,
        metadata,
        dapp_highlights(where: {frame: {eq: $frame}}) {
            num_interactions,
            num_interactions_change,
            num_users,
            num_users_change,
            volume_usd,
            volume_usd_change,
            tvl_usd,
            tvl_usd_change
        },
        num_contracts,
        dapp_tokens {
            name,
            symbol,
            decimals,
            num_holders,
            market_cap_tez,
            price_tez,
            price_change_1d,
        }
    }
}

Iter contracts:

query Contracts($offset: int, $limit: int, $slug: string) {
    contracts(where: {dapp_id: {eq: $slug}}, limit: $limit, offset: $offset) {
        name,
        address
    }
}

Search contracts:

query Contracts($term: string, $slug: string) {
    contracts(where: {name: {ilike: $term}, dapp_slug: {eq: $slug}}) {
        name,
        address
    }
}

Histograms:

query Histograms($slug: string, $limit: number) {
    dapp_stat(  # switch timeframe by changing the table name (TBD)
        limit: $limit, 
        where: {dapp_slug: {eq: $slug}},
        order_by: {bucket: asc}
    ) {
        bucket,
        num_interactions,
        num_users,
        volume_tez,
        volume_usd,
        tvl_tez,
        tvl_usd
    }
}

Release

Make sure you have bumped and comitted the package version and the latest version is available at the endpoint specified in package.json.

npm i
npm run build
npm publish --access public
0.0.7

2 years ago

0.0.6

2 years ago

0.0.3

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago