From 91b0a0863ba50a7d1c6c5b529b14985bbc6d1bdc Mon Sep 17 00:00:00 2001 From: Daniel Karzel Date: Tue, 6 Jul 2021 15:44:47 +1000 Subject: [PATCH] Add script to list sellers and auto trigger swap Uses best price to determine the seller to swap with. --- docs/cli/discover_and_take.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 docs/cli/discover_and_take.sh diff --git a/docs/cli/discover_and_take.sh b/docs/cli/discover_and_take.sh new file mode 100755 index 00000000..43adca9b --- /dev/null +++ b/docs/cli/discover_and_take.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +CLI_PATH=$1 +YOUR_MONERO_ADDR=$2 +YOUR_BITCOIN_ADDR=$3 + +CLI_LIST_SELLERS="$CLI_PATH --testnet --json --debug list-sellers" +echo "Requesting sellers with command: $CLI_LIST_SELLERS" +echo + +BEST_SELLER=$($CLI_LIST_SELLERS | jq -s -c 'min_by(.status .Online .price)' | jq -r '.multiaddr, (.status .Online .price), (.status .Online .min_quantity), (.status .Online .max_quantity)') +read ADDR PRICE MIN MAX < <(echo $BEST_SELLER) + +echo + +echo "Seller with best price:" +echo " multiaddr : $ADDR" +echo " price : $PRICE sat" +echo " min_quantity: $MIN sat" +echo " max_quantity: $MAX sat" + +echo + +CLI_SWAP="$CLI_PATH --testnet --debug buy-xmr --receive-address $YOUR_MONERO_ADDR --change-address $YOUR_BITCOIN_ADDR --seller $ADDR" + +echo "Starting swap with best seller using command $CLI_SWAP" +echo +$CLI_SWAP