Code Monkey home page Code Monkey logo

terraswap-graph's Introduction

Terraswap Graph

Modules

  • Indexer

    • Get tx logs from mantle (https://hive.terra.dev/graphql) and store terraswap relative data into the database
    • Collect hourly/daily reserve, volume and transaction count of each pairs
    • Collect recent 24 hours swap data to serve recent volume
    • Collect minutely exchage rate of each pairs
    • Collect tx_history

Prerequisites

  1. Node.js >= 14.15.x
  2. PostgreSQL == 13.x

Setup

  1. Clone

    $ git clone https://github.com/terra-money/terraswap-graph.git
  2. Install packages

    $ npm install
  3. Setup the database

    • Install postgreSQL
    • create a database
      postgres => CREATE DATABASE terraswap-graph OWNER alice
      
  4. set ormconfig.js

    const { DefaultNamingStrategy } = require('typeorm')
    const { values, snakeCase } = require('lodash')
    const entities = require('orm/entities')
    
    class CamelToSnakeNamingStrategy extends DefaultNamingStrategy {
      tableName(targetName, userSpecifiedName) {
        return userSpecifiedName ? userSpecifiedName : snakeCase(targetName)
      }
      columnName(propertyName, customName, embeddedPrefixes) {
        return snakeCase(embeddedPrefixes.concat(customName ? customName : propertyName).join('_'))
      }
      columnNameCustomized(customName) {
        return customName
      }
      relationName(propertyName) {
        return snakeCase(propertyName)
      }
    }
    
    const connectionOptions = {
      host: 'localhost',
      port: 5432,
      username: 'alice',
      password: 'password',
      database: 'terraswap-graph',
    }
    
    module.exports = [
      {
        name: 'default',
        type: 'postgres',
        synchronize: false,
        migrationsRun: true,
        logging: false,
        logger: 'file',
        migrations: ['src/orm/migrations/*.ts'],
        ...connectionOptions,
      },
      {
        name: 'migration',
        type: 'postgres',
        synchronize: false,
        migrationsRun: true,
        logging: true,
        logger: 'file',
        supportBigNumbers: true,
        bigNumberStrings: true,
        entities: values(entities),
        migrations: ['src/orm/migrations/*.ts'],
        namingStrategy: new CamelToSnakeNamingStrategy(),
        ...connectionOptions,
      },
    ]
  5. Set .envrc

    about .envrc - https://direnv.net/

    .envrc (sample)

    TZ='UTC'
    
    export TERRA_LCD='https://lcd.terra.dev'
    export TERRA_CHAIN_ID='columbus-5'
    export TERRA_MANTLE='https://hive.terra.dev/graphql'
    
    export START_BLOCK_HEIGHT=549000
    

Run Modules

  • Collector

    $ npm run collect
  • GraphQL

    $ npm start

terraswap-graph's People

Contributors

alpac-4 avatar codehans avatar jdekim43 avatar jerzyla avatar mesyakim avatar pronvis avatar zmarouf avatar

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.