Giter Site home page Giter Site logo

pool-contract-backend's Introduction

Pool Contract Backend - API Service for Pool Contract

This repository contains a simple Node.js app that serves the api with the blockchain data fetched from The Graph.

Installation

Follow these steps to install and run the app:

Prerequisites

Make sure you have the following installed on your machine:

Clone the repository

git clone https://github.com/rabindraregmi/pool-contract-backend.git

Navigate to the project directory

cd pool-contract-backend

Install dependencies

npm install

Run the app

npm run dev

Usage

Open your web browser and go to http://localhost:3000 to see the app in action.

API Endpoints

1. Get User Borrows

  • Endpoint: /v1/pool/<wallet_address>/borrows
  • Method: GET
  • Description: Returns the borrow list for given user.

Example Response:

{
    "data": [{
        "__typename": "Borrow",
        "tokenAmount": "50000000000000000000",
        "user": "0x5ba85d71ef9ae0edc180a6bf5e65f0a749f062dc",
        "Pool_id": "0x46544d0000000000000000000000000000000000000000000000000000000000",
        "blockNumber": "34938648",
        "chainId": "0x46544d0000000000000000000000000000000000000000000000000000000000",
        "transactionHash": "0xce9b631328f9ec46baeefa0aaad90f6c6ea58959aabeac7bacc22f15c5683ea8"
    }]
}

2. Get All the Borrowings

  • Endpoint: /v1/pool/borrows
  • Method: GET
  • Description: Returns all the borrowings from the system

Example Response:

{
    "data": [{
        "__typename": "Borrow",
        "tokenAmount": "50000000000000000000",
        "user": "0x5ba85d71ef9ae0edc180a6bf5e65f0a749f062dc",
        "Pool_id": "0x46544d0000000000000000000000000000000000000000000000000000000000",
        "blockNumber": "34938648",
        "chainId": "0x46544d0000000000000000000000000000000000000000000000000000000000",
        "transactionHash": "0xce9b631328f9ec46baeefa0aaad90f6c6ea58959aabeac7bacc22f15c5683ea8"
    }]
}

3. Get All the Deposits

  • Endpoint: /v1/pool/deposits
  • Method: GET
  • Description: Returns all the deposits from the system

Example Response:

{
    "data": [{
        "__typename": "Deposit",
        "user": "0x5ba85d71ef9ae0edc180a6bf5e65f0a749f062dc",
        "blockNumber": "34938482",
        "tokenAmount": "500000000000000000000",
        "Pool_id": "0x46544d0000000000000000000000000000000000000000000000000000000000",
        "chainId": "0x46544d0000000000000000000000000000000000000000000000000000000000",
        "transactionHash": "0x1e516b112510fbc7786b8eba466d71a67037ce870faa5e7ed49028bf88480570"
    }, {
        "__typename": "Deposit",
        "user": "0x9f358d16a28f69f451439124bfe9dc934b0a9894",
        "blockNumber": "35149402",
        "tokenAmount": "1000000000000000000",
        "Pool_id": "0x46544d0000000000000000000000000000000000000000000000000000000000",
        "chainId": "0x46544d0000000000000000000000000000000000000000000000000000000000",
        "transactionHash": "0x55f38e5ae0525cc4644691a0ef281b13b6896355ae030696180ebba66f7c255f"
    }, {
        "__typename": "Deposit",
        "user": "0x9f358d16a28f69f451439124bfe9dc934b0a9894",
        "blockNumber": "35004275",
        "tokenAmount": "1000000000000000000",
        "Pool_id": "0x46544d0000000000000000000000000000000000000000000000000000000000",
        "chainId": "0x46544d0000000000000000000000000000000000000000000000000000000000",
        "transactionHash": "0xaf836f954e7799b28d914c5c4838cab8652ced49008fdf81767a8ca194aa023a"
    }]
}

4. Get All the Deposits of User

  • Endpoint: /v1/pool/<wallet_address>/deposits
  • Method: GET
  • Description: Returns all the deposits from the system of given user

Example Response:

{
    "data": [{
        "__typename": "Deposit",
        "tokenAmount": "500000000000000000000",
        "user": "0x5ba85d71ef9ae0edc180a6bf5e65f0a749f062dc",
        "Pool_id": "0x46544d0000000000000000000000000000000000000000000000000000000000",
        "blockNumber": "34938482",
        "chainId": "0x46544d0000000000000000000000000000000000000000000000000000000000",
        "transactionHash": "0x1e516b112510fbc7786b8eba466d71a67037ce870faa5e7ed49028bf88480570"
    }]
}

5. Get User Borrow and Deposit Trend

  • Endpoint: /v1/pool/<wallet_address>/trend
  • Method: GET
  • Description: Returns all the deposits & borrow trend from the system of given user

Example Response:

{
    "data": {
        "34938482": {
            "borrows": [],
            "deposits": [{
                "__typename": "Deposit",
                "tokenAmount": "500000000000000000000",
                "user": "0x5ba85d71ef9ae0edc180a6bf5e65f0a749f062dc",
                "Pool_id": "0x46544d0000000000000000000000000000000000000000000000000000000000",
                "blockNumber": "34938482",
                "chainId": "0x46544d0000000000000000000000000000000000000000000000000000000000"
            }]
        },
        "34938648": {
            "borrows": [{
                "__typename": "Borrow",
                "tokenAmount": "50000000000000000000",
                "user": "0x5ba85d71ef9ae0edc180a6bf5e65f0a749f062dc",
                "Pool_id": "0x46544d0000000000000000000000000000000000000000000000000000000000",
                "blockNumber": "34938648",
                "chainId": "0x46544d0000000000000000000000000000000000000000000000000000000000"
            }],
            "deposits": []
        }
    }
}

4. Get All the Deposits & Borrow Trends of System

  • Endpoint: /v1/pool/trends
  • Method: GET
  • Description: Returns all the deposits from the system of given user

Example Response:

{
    "data": {
        "34938482": {
            "borrows": [],
            "deposits": [{
                "__typename": "Deposit",
                "tokenAmount": "500000000000000000000",
                "user": "0x5ba85d71ef9ae0edc180a6bf5e65f0a749f062dc",
                "Pool_id": "0x46544d0000000000000000000000000000000000000000000000000000000000",
                "blockNumber": "34938482",
                "chainId": "0x46544d0000000000000000000000000000000000000000000000000000000000"
            }]
        },
        "34938648": {
            "borrows": [{
                "__typename": "Borrow",
                "tokenAmount": "50000000000000000000",
                "user": "0x5ba85d71ef9ae0edc180a6bf5e65f0a749f062dc",
                "Pool_id": "0x46544d0000000000000000000000000000000000000000000000000000000000",
                "blockNumber": "34938648",
                "chainId": "0x46544d0000000000000000000000000000000000000000000000000000000000"
            }],
            "deposits": []
        },
        "35004275": {
            "borrows": [],
            "deposits": [{
                "__typename": "Deposit",
                "tokenAmount": "1000000000000000000",
                "user": "0x9f358d16a28f69f451439124bfe9dc934b0a9894",
                "Pool_id": "0x46544d0000000000000000000000000000000000000000000000000000000000",
                "blockNumber": "35004275",
                "chainId": "0x46544d0000000000000000000000000000000000000000000000000000000000"
            }]
        },
        "35149402": {
            "borrows": [],
            "deposits": [{
                "__typename": "Deposit",
                "tokenAmount": "1000000000000000000",
                "user": "0x9f358d16a28f69f451439124bfe9dc934b0a9894",
                "Pool_id": "0x46544d0000000000000000000000000000000000000000000000000000000000",
                "blockNumber": "35149402",
                "chainId": "0x46544d0000000000000000000000000000000000000000000000000000000000"
            }]
        }
    }
}

Happy coding!

pool-contract-backend's People

Contributors

rabindraregmi avatar

Watchers

 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.