Skip to content

KomodoPlatform/mm2-client

 
 

Repository files navigation

mm2-client

my own mm2 client / tooling

Future tasks:

  • Wallet + encryption seed
  • cancel_all_order
  • setprice
  • buy
  • sell
  • my_recent_swaps
  • my_orders
  • prompt use DB desktop
  • cancel (if i want to cancel by UUID)
  • update_maker_order (want to track UUID)
  • gecko price service
  • paprika price service
  • binance websocket service
  • add total in my_balance_all
  • add am_i_seed in MM2.json if user wants it
  • get_binance_supported_pairs
  • add a way to start mm2 without extra services
  • generic price service that use in order (binance, gecko, paprika)
  • simple bot cfg

How to use the trading bot on linux:

wget https://golang.org/dl/go1.16.5.linux-amd64.tar.gz
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
git clone https://github.com/Milerius/mm2-client
cd mm2-client && go build cmd/mm2_cli_native/mm2_client.go
mkdir -p mm2
cp assets/simple_market_bot.template.json mm2/simple_market_bot.json
# edit the cfg if you want and remove the commentary
./mm2_client

> help
> init # you need to do only the first time
> start
> enable_active_coins
> enable COIN_FROM_CFG COIN_2_FROM_CFG # use that if they are not enable yet - you can use active coins next run
> get_binance_supported_pairs COIN_FROM_CFG # you can see if your coin is supported

# Be sure your balance is funded before starting the bot
> start_simple_market_maker_bot

> my_orders

# later
> stop_simple_market_maker_bot
> stop
> exit

## from another terminal
tail -f ~/.atomicdex_cli/logs/mm2.client.log

How to use the simple market maker bot with an existing atomicdex instance

go build -o mm2_tools_server_bin cmd/mm2_tools_server/mm2_tools_server.go
./mm2_tools_server_bin

# Assuming your userpass for the session is foobar
# Starting the simple market maker bot
curl --location --request POST 'localhost:13579/api/v1/start_simple_market_maker_bot' \
--header 'Content-Type: application/json' \
--data-raw '{
  "desktop_cfg_path": "/Users/milerius/coins/utils/coins_config.json",
  "mm2_coins_cfg_path": "/Users/milerius/Library/Application Support/AtomicDex Desktop/0.5.0/configs/coins.json",
  "market_maker_cfg_path": "/Users/milerius/GolandProjects/mm2-client/mm2/simple_market_bot.json",
  "mm2_userpass": "foobar"
}'

# stopping the bot
curl --location --request POST 'localhost:13579/api/v1/stop_simple_market_maker_bot'

How to use the server on Ios

building

cd mm2_tools_server
gomobile bind -v --target=ios .

using in an ios project:

//
//  main.m
//  FooBar
//
//  Created by Sztergbaum Roman on 15/07/2021.
//

#import <UIKit/UIKit.h>
#import "AppDelegate.h"
#import "Mm2_tools_server.h"

int main(int argc, char * argv[]) {
    NSString * appDelegateClassName;
    @autoreleasepool {
        // Setup code that might create autoreleased objects goes here.
        appDelegateClassName = NSStringFromClass([AppDelegate class]);
    }
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        Mm2_tools_serverLaunchServer(@"atomic_dex");

    });

    return UIApplicationMain(argc, argv, nil, appDelegateClassName);
}

using in an android project:

building

cd mm2_tools_server
gomobile bind -v --target=android .

Using in an android-studio (kotlin) project:

import mm2_tools_server.Mm2_tools_server
import kotlin.concurrent.thread

class MainActivity : AppCompatActivity() {

    private lateinit var binding: ActivityMainBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        binding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(binding.root)

        val navView: BottomNavigationView = binding.navView

        val navController = findNavController(R.id.nav_host_fragment_activity_main)
        // Passing each menu ID as a set of Ids because each
        // menu should be considered as top level destinations.
        val appBarConfiguration = AppBarConfiguration(
            setOf(
                R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_notifications
            )
        )

        thread {
            Mm2_tools_server.launchServer("atomicDex")
        }
        //print("hello world\n")
        setupActionBarWithNavController(navController, appBarConfiguration)
        navView.setupWithNavController(navController)
    }
}

miscs

#you may want for testing purpose to forward localhost port of the server
# for android simulator devices please start the emulator and run then start your app
adb forward tcp:1313 tcp:1313

Adding your API keys

API keys are populated in constants/constants.go and are used to fetch prices from external services from your local environment. Make sure to add these to your environment variables before running the server (either via .bashrc or systemd service files).

NOMICS_API_KEY=
LCW_API_KEY=
GECKO_API_KEY=
PAPRIKA_API_KEY=

Note: Nomics is defunct. Only LCW api keys are functional yet (Gecko and Paprika run without a key for now)

Building price service only

go build -o prices_komodo_earth cmd/mm2_tools_server/mm2_tools_server.go
./prices_komodo_earth

Using systemd service

[Unit]
Description=prices-komodo-earth
After=multi-user.target
Conflicts=getty@tty1.service
StartLimitIntervalSec=60
StartLimitBurst=5

[Service]
# API Keys
Environment="LCW_API_KEY=<YOUR_LCW_API_KEY>"

# Path to service binary.
WorkingDirectory=/home/admin/mm2-client
ExecStart=/home/admin/mm2-client/prices_komodo_earth -only_price_service=true

# Logs path
StandardOutput=append:/home/admin/logs/prices-komodo-earth.log
StandardError=append:/home/admin/logs/prices-komodo-earth.log

User=admin
Group=admin
Type=simple
TimeoutStopSec=30min
Restart=on-failure
RestartSec=10s

StandardInput=tty-force

[Install]
WantedBy=multi-user.target

Updating coins file via sudo cronjob

Set script to run daily via root's cronjob to update coins file and restart service

#!/bin/bash
curl https://raw.githubusercontent.com/KomodoPlatform/coins/master/utils/coins_config.json -o /home/admin/mm2-client/coins_config.json
go build -o /home/admin/mm2-client/prices_komodo_earth /home/admin/mm2-client/cmd/mm2_tools_server/mm2_tools_server.go
systemctl restart prices-komodo-earth

About

my own mm2 client / tooling

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 99.6%
  • Other 0.4%