In its current implementation, stablesats
is coupled to and dependent on the galoy backend to fetch user transactions on a bitcoin-based banking client, e.g. Bitcoin Beach Wallet. To get it running locally, you have to, among other dependencies, set up a local galoy
backend as well. This document will walk you through the set up.
Last tested with the following tools and application:
- Rust Compiler
$ rustc --version
rustc 1.63.0 (4b91a6ea7 2022-08-08)
- Cargo
$ cargo --version
cargo 1.63.0 (fd9c4297c 2022-07-01)
- Docker
$ docker --version
Docker version 20.10.18, build b40c2f6
- Direnv
$ direnv --version
2.32.1
- Clone the galoy backend and follow the instructions detailed in the documentation. Pay particular attention to the information presented here to get local developer access to the graphql API
- Take note to shutdown the instance of the running stablesats container provisioned alongside galoy backend. Get the container ID
$ cd /path/to/galoy
$ docker compose ps
and stop/kill the container
$ docker stop $STABLESATS_CONTAINER_ID
- Clone the stablesats repository and change to its directory
cd stablesats
- Load environment variables contained in
.envrc
. Create an okx account and create trading API and secret keys. Populate the appropriate fields with the generated keys and passphrase, after this, export the variables to your environment by running
direnv allow
-
Take note to update the postgres port numbers of any of
user-trades-db
andhedging-db
to ensure these databases run alongside the postgres database(s) ongaloy
. Make the changes in docker-compose.override, in user-trades/.env and/or hedging/.env files -
Run the local containers
stablesats
depends on
$ make reset-deps-local
Note that some times migrating the databases fails because they are starting up. If you encounter an error of the form:
error: error returned from database: the database system is starting up
make: *** [Makefile:41: setup-db] Error 1
run the migration command again
$ make setup-db
- Build
stablesats
$ make build
- Run
stablesats
: See the section on how to run the application
The stablesats command line interface (CLI) is an application that allows users to get price quotes, and runs configured processes. To view the CLI commands and options, run
$ stablesats
To run the configured processes:
- Make a copy of the stablesats configuration file and rename the file. Ensure that this new configuration is not committed (add to global
.gitignore
) if contributing to the project. - Uncomment the file and update the
galoy.api
andgaloy.phone_number
config values with values contained here. Change theokex.simulated
value totrue
. - Run the CLI
$ stablesats -c $NEW_CONFIGURATION_FILE run
- For help on the
run
command
$ stablesats run --help
To get price quotes:
- Open a new terminal
- Request a quote for given price
$ stablesats price 10000
- For help on the
price
command
$ stablesats price --help
To run the integration tests, run the command
$ make test-in-ci
To run tests for a specific package
$ cargo test -p $PACKAGE_NAME
Example
$ cargo test -p okex-price
To pass github actions, check that your code is formatted and linted properly
$ make check-code
We are open to and encourage contribution from the community. Please ensure you adhere to the following when creating a pull request:
- Have a clean commit history
- Use good commit messages
- Resolve all conflicts
- Rebase often