Skip to content

Edgxtech/prise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License

Prise - Cardano Native Token Price Indexer

Kotlin based indexer as used by: https://realfi.info. Provides historical and latest prices for all Cardano Native Tokens (CNT). Uses;

  • Bloxbean Yaci JVM based Cardano mini-protocols library
  • Blockbean YaciStore general purpose indexer, only for txOutput resolution (modular option)
  • dcSpark Carp general purpose indexer, only for txOutput resolution (modular option)
  • Koios Koios Cardano data API, only for txOutput resolution (modular option)
  • Blockfrost Blockfrost Cardano data API, only for txOutput resolution (modular option)
  • Cardano Foundation Token Registry for CNT metadata (modular, can be swapped)
  • Trades obtained from on-chain Cardano DEX data including Minswap V1/V2, Sundaeswap V1 and Wingriders (modular can be extended)
  • Koin dependency injection

Setup

## Make webserver log directory
sudo mkdir /var/log/spring
sudo chown -R <your-user>:<your-user> /var/log/spring
## Make indexer log directory
mkdir /var/log/prise/
sudo chown -R <your-user>:<your-user> /var/log/prise

## Build the db schema
cd webserver
## Edit src/main/resources/application.properties (or add application-default.properties); particularly spring.datasource.username & password 
mvn clean install -DskipTests
mvn spring-boot:run
## If you dont need the webserver, shut it down

cd indexer
cp prise.example.properties prise.properties
cp prise.example.properties src/test/resources/prise.properties
## Edit properties as needed; particularly database (x2) url + login, cardano-node (cnode) url and API keys for any data API used

Build

cd indexer
mvn clean install -DskipTests

Run

mvn exec:exec -Dconfig=prise.properties

Configs

prise.properties - app configuration

run.mode=livesync|oneshot
latest.prices.livesync.update.interval.seconds=
make.historical.data=true|false
start.metrics.server=true|false
metrics.server.port=
app.datasource.driver-class-name=
app.datasource.url=
app.datasource.username=
app.datasource.password=
token.metadata.service.module=tokenRegistry
chain.database.service.module=koios|carpJDBC
cnode.address=
cnode.port=
start.point.time=

 *see prise.example.properties for more detailed descriptions

src/main/resources/environment.properties

# selects specific logback config logack-$logEnv.xml
logEnv=prod|dev

Components

Component Description
indexer Core component which listens to blockchain, parses trade data, computes and persists latest and historical prices
webserver Optional; simple Spring Boot webserver with latest price and historical price endpoints

Dependencies

Dependency Description
Cardano-node Access to a fully synced Cardano node instance, for best performance in terms of stability and sync speed, use a dedicated node on a local network. Tested with cardano-node v8.9.2
Carp (Only if using Carp module) Access to a fully synced Carp database. Carp is a general purpose modular Cardano indexer using Posgresql. This is required primarily to resolve utxo references. Other alternatives will work also however will require custom implementation of the ChainDatabaseService interface
Yaci Store (Only if using Yaci Store module) Access to a fully synced Yaci Store database. Yaci Store is a general purpose modular Cardano indexer using Posgresql or MySQL. This is required primarily to resolve utxo references. Other alternatives will work also however will require custom implementation of the ChainDatabaseService interface

Modules

Module Description Implementations
ChainDatabaseService Implementations provide an ability to resolve transaction output references (e.g. txHash#index) and searching for the nearest block to a given slot/time
  • Blockfrost (preferred) Requires blockfrost.datasource properties configured in the prise.properties config file as well as a project token you can register for at blockfrost.io with ability to scale up needs
  • Yaci-Store Requires yacistore.datasource properties configured in the prise.properties config file as well as network access to a fully synced Yaci Store webservice
  • CarpJdbcService Requires carp.datasource properties configured in the prise.properties config file as well as network access to a fully synced Carp (Postgres) database
  • KoiosService (WIP)
  • Koios is a decentralised Api that can provide some of the required data. Currently it can only perform the transaction output resolutions thus you will need an alternate method to find nearest block to slot (external api or otherwise). Performance is limited, more suitable for development testing
  • CarpHttpService (WIP)
  • Preferred over CarpJdbcService for simplicity, however the default webserver doesn't provide all necessary endpoints. Currently it can resolve transaction output references only and would need a custom webserver to implement the getBlockNearestToSlot function
    TokenMetadataService Implementations provide the ability to resolve token decimals specifications for Cardano Native Tokens
  • TokenMetadataService

  • The tokens.cardano.org service
    Other implementations can be added as required

    Java Version

    Tested with Java 11
    * Have noticed at least one issue using Java 20
      due to an issue with the KoinTest Mocking framework 
      (Unsupported class file major version 64)
    

    Mysql Installation

    Official Linux Installation Guide
    Official macOS Installation Guide

    Add a mysql user:

    Login as mysql root user
    mysql> CREATE DATABASE prise;
    mysql> CREATE USER 'prise'@'localhost' IDENTIFIED BY '<password>';
    mysql> GRANT ALL PRIVILEGES ON prise.* TO 'prise'@'localhost' WITH GRANT OPTION;
    mysql> flush privileges;
    

    Miscellaneous

    * Make sure Operating System is using a timezone without daylight savings. Otherwise will see odd weekly candles misaligned
    e.g. timedatectl set-timezone Asia/Kuala_Lumpur
    

    Contributions

    Contributions welcome

    Support

    This project is made possible by Delegators to the AUSST Cardano Stakepool and supporters of Edgx R&D

    About

    Cardano Native Token (CNT) Price Indexer

    Resources

    License

    Stars

    Watchers

    Forks

    Releases

    No releases published

    Packages

    No packages published

    Languages