Git Product home page Git Product logo

indexer-helper's Introduction

ref-indexer-helper

A light web server using Flask + Gunicorn + Nginx

Feature List

feature remark URL
welcome msg version info /
timestamp current timestamp at server-side /timestamp
latest actions user's latest actions on REF /latest-actions/<account_id>
liquidity pools user's liquidity pools on REF /liquidity-pools/<account_id>
all farms -- /list-farms
pools info for distinct token pair -- /list-top-pools
token price by token id -- /get-token-price?token_id=<token_id>
all tokens price price from coingecko or native pool /list-token-price
all tokens metadata -- /list-token
pool info by single pool id -- /get-pool?pool_id=<pool_id>
all pools info -- /list-pools
pools info by tokens -- /list-pools-by-tokens?token0=<token0>&token1=<token1>
pools info by pool ids -- /list-pools-by-ids?ids=id0|id1|...|idn
provide general info of whitelist pools volume, liquidity /whitelisted-active-pools
provide info for coingecko price, volume, liquidity of all global whitelisted token pools /to-coingecko

Usage

Get user's action history of ref-finance

# request ref-user's latest 10 actions on mainnet
http://localhost/latest-actions/<account_id>
# response in json type
[
    ["<timestamp>", "<method>", "<args>", "<attached_deposit>"],
    ["<timestamp>", "<method>", "<args>", "<attached_deposit>"],
    ...
]

get user's liquidity pools

http://localhost/liquidity-pools/<account_id>
# response in json type
[
    {<pool info>},
    {<pool info>},
    ...
]

List pools with max liquidity in each token pair

http://localhost/list-top-pools
# response in json type
[
    {<pool info>},
    {<pool info>},
    ...
]

list all token with cur market price from coingecko

http://localhost/list-token-price
# response in json type
{
    token_id: {"pirce": "", "decimal": 8, "symbol": ""},
    token_id: {"pirce": "", "decimal": 8, "symbol": ""},
    ...
}

list all pools in ref-finance

http://localhost/list-pools
# response in json type
[
    {<pool info>},
    {<pool info>},
    ...
]

given two tokens, list all pools using that token pair.

http://localhost/list-pools-by-tokens?token0=xxx&token1=xxxx
# response in json type
[
    {<pool info>},
    {<pool info>},
    ...
]

Get all farms in ref-farming

# request for mainnet
http://localhost:8000/list-farms
# response
[
    {...}, # FarmInfo
    {...}, # FarmInfo
    ...
    {...}, # FarmInfo
]

Build

python3 -m venv venv
source venv/bin/activate
# apt-get install libpq-dev
pip install flask
pip install flask-cors
pip install gunicorn
pip install psycopg2
pip install base58
pip install redis
pip install requests
# Flask (2.0.0)
# gunicorn (20.1.0)
# psycopg2 (2.8.6)

deploy backend

Call deploy_xxx.sh to deploy backend shell scripts with correct network id. Then make those scripts be periodically called.
There are several ways to do that:

  • crontab
  • flask_apscheduler
  • other third-party tools

Start Service

source start_server.sh

Stop Service

pstree -ap|grep gunicorn
kill -9 <pid>

indexer-helper's People

Contributors

marco-sundsk avatar dom-jiang avatar marco-sun avatar rock-jp avatar aidai524 avatar cyb880326 avatar soul-wish 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.