Skip to content
forked from Hu-Fi/Mr.Market

Mr. Market is the exchange oracle of HuFi, and a CeFi crypto bot on Mixin Messenger

License

Notifications You must be signed in to change notification settings

zed-wong/Mr.Market

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

871 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WARNING: This is highly alpha code. Do not use it or you will lose all your money. We'd like to thank Little creatures for being the first company to test Mr. Market and for helping with QA.

Playwright Tests Unit Tests Unit Tests Lint

Introduction

What is Mr.Market

Mr Market is a CeFi crypto bot and the reference exchange oracle for Hu Fi. Mr Market has three main functions

  • An automated crypto bot that supports a variety of strategies for arbitrage across CeFi exchanges.
  • What is Hu-Fi
  • A front end where users can contribute funds to increase the ability to do Hu Fi market making.

Development

Getting Started

Prerequisites

Install dependencies

make install

SQLite database

SQLite is file-based. Set DATABASE_PATH in /server/.env and the database file is created automatically.

Run development servers

make start-dev

Tests

Client

Install dependencies

bunx playwright install

Running tests

Unit testing

bun run test:unit

E2E testing

bun run test:e2e

Server

Running tests

Unit testing

bun test

Deployment Guide

Preparations

First, ensure you have the following environment variables ready. These are crucial for the configuration of the server and interface.

Server Environment Variables (/server/.env)

Variable Description Source
ADMIN_PASSWORD Admin page password User-defined
JWT_SECRET JWT secret key (32 bit) User-defined
COINGECKO_API_KEY Coingecko API key Coingecko
DATABASE_PATH SQLite database file path User-defined
MIXIN_APP_ID Mixin App ID Mixin Developer Dashboard
MIXIN_SESSION_ID Mixin Session ID Mixin Developer Dashboard
MIXIN_SERVER_PUBLIC_KEY Mixin Server Public key Mixin Developer Dashboard
MIXIN_SESSION_PRIVATE_KEY Mixin Session Private key Mixin Developer Dashboard
MIXIN_SPEND_PRIVATE_KEY Mixin Spend Private key Mixin Developer Dashboard
MIXIN_OAUTH_SECRET Mixin Oauth Secret Mixin Developer Dashboard
BINANCE_API_KEY Binance Account API Key Binance Account Settings
BINANCE_SECRET Binance Account API Secret Binance Account Settings

Refer to ./server/.env.example to enable more exchanges for strategies.

Interface Environment Variables (/interface/.env)

Variable Description Source
PUBLIC_BOT_ID Mixin App ID Mixin Developer Dashboard
PUBLIC_HUFI_SOCKET_URL Server deployment URL Server Hosting Platform
PUBLIC_HUFI_BACKEND_URL Server deployment URL Server Hosting Platform

Variables starting with MIXIN are obtained from the Mixin bot keystore, accessible on the Mixin developer dashboard by creating a new bot.

Deploy on Render

This guide will walk you through the process of deploying a server, and an interface on Render for our application. SQLite is used for persistence, so no external database service is required. By the end of these steps, you will have a fully functional server and interface setup.

  1. Deploy Server on Render

    • Login to the Render, and create a new web service. Connect the github repo, and adjust the environment variables.

    • Use

      • ./server for Root Directory
    • bun install --frozen-lockfile; bun run build for Build Command

    • bun run migration:run for Pre-Deploy Command (Available in advanced settings)

    • bun run start:prod for Start Command

  2. Deploy Interface on Render

    • Login to the Render, and create a new static site. Connect the github repo, and adjust the environment variables.

    • Use

      • ./interface for Root Directory
      • bun install --frozen-lockfile; bun run build for Build Command
      • build for Publish Directory
    • Setup Redirect & Rewrite Rules as follows.

      Source Destination Action
      /(.*) /app.html Redirect

Deploy with Docker

  1. Deploy Server

    If you have docker installed on your server, it's much easier to run the Mr.Market server without setting up an additional database service.

    • Make sure you have .env file is configured properly.
    • Run docker compose up in server directory.
  2. Deploy Interface

    We do not docker deployment for Mr.Market interface.

Troubleshooting

If you encounter issues during the deployment, check the following:

  • Ensure all environment variables are correctly set.
  • Verify that your Render account is active and in good standing.
  • Consult the Render documentation for detailed troubleshooting steps.

Built With

License

This project is licensed under the GNU Affero General Public License - see the LICENSE.md file for details

Free Data provided by

"Data provided by CoinGecko",

About

Mr. Market is the exchange oracle of HuFi, and a CeFi crypto bot on Mixin Messenger

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

No contributors

Languages

  • Svelte 50.9%
  • TypeScript 48.5%
  • CSS 0.3%
  • JavaScript 0.2%
  • Makefile 0.1%
  • HTML 0.0%