Git Product home page Git Product logo

ergo-dex-backend's Introduction

Spectrum Finance off-chain services

A set of off-chain services facilitating Spectrum Finance functioning.

AMM DEX services:

  • UTXO Tracker - extracts AMM orders and pool state updates from the UTXO feed
  • AMM Executor - executes AMM orders into a transaction chain
  • Pool Resolver - tracks pool updates

AMM Services

OrderBook DEX services:

  • UTXO Tracker - extracts orders from the UTXO feed
  • Matcher - order-book matching engine
  • Orders Executor - executes orders
  • Markets API - aggregates market data and provides a convenient API to access it

Building & Running the off-chain services

Prerequisites

The services require access to an Ergo node, so if you do not have one yet install as instructed here: Ergo github Besides the node the services depend on tools such as Kafka and Redis to run, to make it easier to manage a docker based solution has been made to allow for easy building and running of the services. The only requirements besides the node are that you have the following installed:

  • GIT to download the code and help fetch updates. GIT
  • Docker and Docker-compose (included in Docker for Windows). Docker

Building

First you need to download the code from this repo. The easiest way to keep it updated in the future is by using git:

cd <the folder you want to keep the off-chain services code in>
git clone https://github.com/spectrum-finance/ergo-dex-backend.git

Instructions for the containers are all defined in the docker-compose.yml file. The only configuration needed for running the services need to be stored in a file called config.env. An example can be found in config-example.env Make a copy of the example file, name it config.env and edit the file to match your values:

Linux:

cd ergo-dex-backend
cp ./config-example.env ./config.env

Windows:

cd ergo-dex-backend
copy ./config-example.env ./config.env

The 3 values that need to be changed in the config.env file are the mnemonic (howto) from which bot will create the wallet to receive fees on and pay miner fees from (in SPF fee cases) and the URI to your node (localhost/127.0.0.1 might not be accessible from within a docker container, it is best to use the local lan ip if the node is running on the same host). You have to setup URI twice.

Running the services

Once the config.env file is created, make sure you have funds on expected address (you can check which address bot will use with HowTo.scala script). Next, the only thing left to do is to run the containers:

Linux:

sudo -E docker-compose up -d

Windows:

docker-compose up -d

Verifying the services are running correctly

You can look into the logs of the services to ensure they are running correctly. To look at a combined log for all services use the following command:

Linux:

cd ergo-dex-backend
sudo docker-compose logs -f

Windows:

cd ergo-dex-backend
docker-compose logs -f

Updating the services

After running git pull from the instructions below make sure to check for potential changes in config-example.env to apply to your own config.env!

Linux:

git pull
sudo -E docker-compose pull
sudo -E docker-compose up -d

Windows:

git pull
docker-compose pull
docker-compose up -d

ergo-dex-backend's People

Contributors

alesfatalis avatar cardano-apexpool avatar gusevtimofey avatar luivatra avatar oskin1 avatar semyonoskin avatar yasha-black avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ergo-dex-backend's Issues

certain docker containers not restarting

Currently running the ergo-dex-backend, and after 10 hours of running, kafka-1 docker container shut down and did not restart, causing other containers to start throwing errors. Would suggest doing restart unless stopped or restart always into the default docker compose script

[Logs] kafka TOPIC_ALREADY_EXISTS (Topic 'hc' already exists.) - what does this mean?

While watching the logs after first launching the bot, I'm getting repeated kafka "TOPIC_ALREADY_EXISTS (Topic 'hc' already exists.) " followed by ergo-amm-executioner new heights.

What does this actually mean? Is this an error?

kafka | [2024-02-20 02:12:03,724] INFO [Controller 1] CreateTopics result(s): CreatableTopic(name='hc', numPartitions=-1, replicationFactor=-1, assignments=[], configs=[]): TOPIC_ALREADY_EXISTS (Topic 'hc' already exists.) (org.apache.kafka.controller.ReplicationControlManager)

Min amount of Erg or other tokens needed in wallet to get started?

The documentation says to send some amount to the wallet, but it should really be elaborated. What is the minimum Erg required to get started? Do you require other tokens to have a pair for liquidity pools?

For someone just getting started this information would be very helpful.

ErgoDEX API "all pool stats" should return pool_id in response

Issue: there are two API calls which require the p1 parameter (assuming it is pool_id), "pool locks" and "pool stats". Without this information, API users will not know where to get that data and excludes them from using this service.

Currently you can get the pool_id by...

  1. Running backend DB service and looking up the pool_id from pools table
  2. Ask someone else for the list (https://github.com/Eeysirhc/ergodex-price-app/blob/main/ergodex-pool_id.csv)

Proposal: include the p1/pool_id value in the response for "all pool stats" API call (which I think makes the most sense).

Docker ARM64 build support?

Is there a way to support arm64 in the docker build? Looks like it throws a warning message. I'm running on an arm processor.

image

HowTo.scala throws error when running as instructed

When trying to run HowTo.scala the following error occurs.

sbt "; project amm-executor; test"

[error] ## Exception when compiling 133 sources to C:\Users\didel\ergo-dex-backend\modules\dex-core\target\scala-2.12\classes [error] scala.reflect.internal.FatalError: Error accessing C:\Users\didel\AppData\Local\Coursier\Cache\v1\https\repo1.maven.org\maven2\com\github\pureconfig\pureconfig-core_2.12\0.14.1\pureconfig-core_2.12-0.14.1.jar

I tried with JDK 11, 17, 21 on a Windows 10 and a Debian Linux machine and the same error occured in all scenarios.

Add ' in a section of the config-example.env file

Currently, the file content is: JAVA_TOOL_OPTIONS="-Dnetwork.node-uri=http://<my node ip>:9053 -Dexchange.mnemonic='<my ergo mnemonic>' "

In my setup, it worked only when I added ' in the node-uri. To avoid this issue, I suggest it to be changed to the following content:
JAVA_TOOL_OPTIONS="-Dnetwork.node-uri='http://<my node ip>:9053' -Dexchange.mnemonic='<my ergo mnemonic>' "

./run.ps1 throws warning

It builds and runs succesfully, but not sure if this error is something to worry about?

`
./run.ps1: line 1: :DEX_SOURCES_PATH=: command not found
time="2022-06-04T10:41:30+01:00" level=warning msg="The "DEX_SOURCES_PATH" variable is not set. Defaulting to a blank string."

time="2022-06-04T10:41:30+01:00" level=warning msg="The "DEX_SOURCES_PATH" variable is not set. Defaulting to a blank string."

time="2022-06-04T10:41:30+01:00" level=warning msg="The "DEX_SOURCES_PATH" variable is not set. Defaulting to a blank string."
`

Backend DB incorrectly populating x/y IDs in "pools" table

Issue: the "pools" table is not correctly populating the associated x/y ID ticker values for the respective liquidity pool ID.

Each LP pair has their own ID. For example, ERG/ergopad would have its own unique value and ergopad/ERG would have something else despite the asset ticker ID being the same - they are just switched.

If we run the following for the above example....

select 
distinct p.pool_id, 
p.x_id, 
a_x.ticker as x_ticker, 
p.y_id, 
a_y.ticker as y_ticker, 
a_x.ticker || '/' || a_y.ticker as ticker
from pools p 
LEFT JOIN assets a_x ON a_x.id = p.x_id
LEFT JOIN assets a_y ON a_y.id = p.y_id

where (a_x.ticker = 'ergopad' or a_y.ticker = 'ergopad')
and (a_x.ticker = 'ERG' or a_y.ticker = 'ERG')
;

We get the following results:

Row 1

pool_id: 61a579c46d92f2718576fc9839a2a1983f172e889ec234af8504b5bbf10edd89	
x_id: 0000000000000000000000000000000000000000000000000000000000000000
x_ticker: ERG	
y_id: d71693c49a84fbbecd4908c94813b46514b18b67a99952dc1e6e4791556de413
y_ticker: ergopad
ticker: ERG/ergopad

Row 2

pool_id: d7868533f26db1b1728c1f85c2326a3c0327b57ddab14e41a2b77a5d4c20f4b2	
x_id: 0000000000000000000000000000000000000000000000000000000000000000
x_ticker: ERG
y_id: d71693c49a84fbbecd4908c94813b46514b18b67a99952dc1e6e4791556de413
y_ticker: ergopad
ticker: ERG/ergopad

Despite being different pool IDs, the x_id and y_id columns are populating the same values for both and creating an incorrect output for the final ticker column.

events-tracker image does not match the detected host platform

I'm currently running on Asahi ArchLinux arm64.

Upon a 'docker compose up -d' I get the following error:

! events-tracker The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested 0.0s

Can I add anything to the docker compose file for the events watcher?

sudo docker-compose logs -f wouldn't work

I didn't copy paste exactly what the error was but it was something along the lines of [ERROR DEX_PATH /modules/blah/blah/blah]

I edit my docker-compose.yml to just use my full path and its working fine now. however didn't work "out of the box"
/home/username/ergo/ergo-dex-backend/modules/utxo-tracker/target/docker/stage
/home/username/ergo/ergo-dex-backend/modules/amm-executor/target/docker/stage
/home/username/ergo/ergo-dex-backend/modules/pool-resolver/target/docker/stage

Brand new installation of ubuntu server 20.04.3

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.