Skip to content
No description, website, or topics provided.
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.
trading-bot trading-bot: update protobuf documentation Feb 20, 2020 link to go trading bot Feb 17, 2020


The project has the necessary components to create a bot for the Stakenet Dex.


alt text

  • trading-bot: a project built in scala, which is responsible for generating and placing orders to the orderbook, to make this, the bot has to connect with the lssd app by using its grpc api. Firstly it registers the currencies with which it will be working, after that it creates the trading_pair (you must use only the available ones from our orderbook), then creates orders randomly, to both sides, Sell and Buy and send them to the lssd. You can see the docs here.

    Alternatively, you can also can also check out a go implementation of the trading-bot:

  • lssd: Lightwallet Swap Service Daemon. Is a grpc application which is listening in localhost: 50051, is responsible for placing orders to the Stakenet Dex and for making the swaps, to work the the lssd api needs to connect with Lightning Network nodes to manage the wallets.

    To understand the api, you have to read the proto file from releases page in the lssd zip folder with the name of lssd.proto. Also you can find the lssd documentation here

    To run lssd: Download the app from releases page, take the last version

    Extract the zip file and open a terminal in lssd/app/. then run ./lssd.

    To see if the api is working you can see the logs with:

    tail -f ~/.local/share/Stakenet/lssd/lssd.log

    here you should see the Stakenet Dex broadcasting some messages regularly.

  • Custom lnds They can be downloaded from releases page, take the last version

    You must install the custom lnds in the next ports:

    • LTC: localhost:10001
    • BTC: localhost:10002
    • XSN: localhost:10003

    How to configure custom LND

How it works

alt text

Create your own Bot

After running the services of lssd and lnd, these are the data we will need to create our own bot:

From lssd:

  • Ip
  • Port

From lnd:

  • Ip
  • Port
  • Tls cert

To create the bot you need to follow the protobuf file (lssdrpc.proto) that comes within the lssd zip, in the app folder. which is downloaded from releases page, take the last version

Step 1: Add the currencies (you must use only the available ones from our Stakenet Dex)

// currencies
service currencies {
    rpc AddCurrency (AddCurrencyRequest) returns (AddCurrencyResponse);

Step 2 Then you must create the trading pair with:

// trading pairs
service tradingPairs {
    rpc EnableTradingPair (EnableTradingPairRequest) returns (EnableTradingPairResponse);

Step 3: Place orders: We have to create the order request with:

message PlaceOrderRequest {
    string pairId = 1;
    OrderSide side = 2;
    BigInteger funds = 3;
    BigInteger price = 4; // missing on market orders

Step 4: Send the request to the lssd with:

rpc PlaceOrder (PlaceOrderRequest) returns (PlaceOrderResponse);

Step 5: Waits until lssd daemon completes the swap, you can subscribe to swaps to know if swap is success or failure with:

// swaps
service swaps {
    rpc SubscribeSwaps (SubscribeSwapsRequest) returns (stream SwapResult);

How to get the list of open orders

Note: You need to activate the trading pair before asking for orders.

First we have to request the list of open orders with

rpc ListOrders (ListOrdersRequest) returns (ListOrdersResponse);

message ListOrdersRequest {
    string pairId = 1; // the pair id like XSN_BTC. 
    bool includeOwnOrders = 2; // if the list will include own orders.
    uint32 skip = 3; // The number of orders to skip, this is useful for pagination.  
    uint32 limit = 4; // The limit of orders to retrieve, useful for pagination.

That will return a list of orders that can be filtered with the isOwnOrder attribute included in the Order object

message Order {
    string pairId = 1;
    string orderId = 2;
    // The price of the order in satoshis.
    BigInteger price = 3;
    // The funds of the order in satoshis.
    BigInteger funds = 4;
    // The epoch time when this order was created.
    uint64 createdAt = 5;
    // Whether this order is a buy or sell
    OrderSide side = 6;
    // Whether this order is a local own order or a remote peer order.
    bool isOwnOrder = 7;

After we receive the orders, we have to subscribe for new orders with:

rpc SubscribeOrders (SubscribeOrdersRequest) returns (stream OrderUpdate);

Then use the isOwnOrder attribute to filter the orders.

You can’t perform that action at this time.