hojas/bisq_arbitrage_notes/operation/Manual purchase through bisq daemon.md
2023-12-09 19:27:21 +01:00

11 KiB

I am going to perform a manual trade through the bisq daemon with the bisq cli in order to get familiar with a full trade flow. I'll carefully describe below:

  • The plan
  • The execution log, with each output and response
  • The flow of funds throughout.

The plan

The plan is simply to buy some BTC by taking a small offer. The steps would be:

  1. Unlock wallet with unlockwallet.
  2. Fund the wallet
    1. Get a BTC address from the CLI with getfundingaddresses.
    2. Send 0.01 BTC to the address.
    3. Check the balance of the BTC address with getbalance and getaddressbalance.
  3. Buy a small amount of BSQ
    1. Check the available offers with getoffers --direction=BUY --currency-code=BSQ
    2. Pick one and take it with takeoffer. Payment must come from BsqSwapAccount payment account.
    3. Check the change in BSQ and BTC balances with getbalance --currency-code=BTC and getbalance --currency-code=BSQ. The BTC balance should comply with BTC = starting_btc + purchased_btc - mining_fee. The BSQ balance should comply with BSQ = starting_bsq - trading_fee.
  4. Buy a small amount of BTC
    1. Check the available offers with getoffers --direction=BUY --currency-code=BSQ.
    2. Pick one (preferably revolut since it's fast) and take it with takeoffer.
    3. Check it on the list of open trades with gettrades --category=open.
    4. Send the payment through the fiat system.
    5. Confirm the payment with confirmpaymentstarted.
    6. Regularly check gettrade until the trade is finished.
    7. Once it appears finished, verify that it appears in gettrades --category=closed.
  5. Review balances and empty the wallet.
    1. Check the change in BSQ and BTC balances with getbalance --currency-code=BTC and getbalance --currency-code=BSQ. The BTC balance should comply with BTC = starting_btc - (purchased_bsq * price) - trading_fee - mining_fee.
    2. Send the remaining BSQ to my main wallet with sendbsq
    3. Check the change in BSQ and BTC balances with getbalance --currency-code=BTC and getbalance --currency-code=BSQ. The BTC balance should comply with BTC = starting_btc - mining_fee. The BSQ balance should be zero.
    4. Send the remaining BTC to my main wallet with sendbtc.
    5. Check that the BTC balance is zero.

Log

Note: bisq_cli is an alias to call the bisq cli with the password included. Simply syntactic sugar.

  1. Unlock wallet with unlockwallet. command: bisq_cli unlockwallet --wallet-password=noesfacilvivirsinbisq --timeout=3600 output: wallet unlocked
  2. Fund the wallet 1.1 Get a BTC address from the CLI with getfundingaddresses.
    • command: bisq_cli getfundingaddresses
    • output:
BTC Address                                 Available Balance  Confirmations  Is Used
bc1qnafthlvmfknywypgjvg6l04rxg30w740s7p2px         0.00000000              0  NO     

1.2 Send 0.01 BTC to the address. 1.3 Check the balance of the BTC address with getbalance and getaddressbalance. - command: bisq_cli getbalance - output:

BTC
Available Balance  Reserved Balance  Total Available Balance  Locked Balance
       0.01000000        0.00000000               0.01000000      0.00000000
BSQ
Available Confirmed Balance  Unverified Balance  Unconfirmed Change Balance  Locked For Voting Balance  Lockup Bonds Balance  Unlocking Bonds Balance
                       0.00                0.00                        0.00                       0.00                  0.00                     0.00

with getaddressbalance: - command: bisq_cli getaddressbalance --address=bc1qnafthlvmfknywypgjvg6l04rxg30w740s7p2px - output:

BTC Address                                 Available Balance  Confirmations  Is Used
bc1qnafthlvmfknywypgjvg6l04rxg30w740s7p2px         0.01000000              0  YES
  1. Buy a small amount of BSQ 2.1 Check the available offers with getoffers --direction=BUY --currency-code=BSQ
    • command: bisq_cli getoffers --direction=BUY --currency-code=BSQ
    • output:
Buy/Sell            Price in BTC for 1 BSQ           BTC(min - max)    BSQ(min - max)  Payment Method  Creation Date (UTC)   ID
Sell BSQ (Buy BTC)              0.00003848  0.00490000 - 0.03850000  127.34 - 1000.52  BSQ Swap        2022-08-30T14:36:35Z  14389-ec20aa00-c9eb-41e0-9e3a-5340b371b8e2-194   
Sell BSQ (Buy BTC)              0.00003849  0.00500000 - 0.05000000  129.90 - 1299.04  BSQ Swap        2022-08-30T11:41:56Z  zwievr-085f03d1-94d6-4501-8010-242cd29199d2-195  
Sell BSQ (Buy BTC)              0.00003938  0.00610000 - 0.01560000   154.90 - 396.14  BSQ Swap        2022-08-30T11:57:27Z  TZITsBb-f137baac-2f6f-48ca-8d4f-34f790097d23-195 
Sell BSQ (Buy BTC)              0.00003940  0.01500000 - 0.04000000  380.71 - 1015.23  BSQ Swap        2022-08-29T05:34:22Z  kmxvby-f8c31feb-2c1c-46bb-ad66-059914a89b64-194  
Sell BSQ (Buy BTC)              0.00003950               0.03950000           1000.00  BSQ Swap        2022-08-30T07:04:16Z  35879170-8cc6f257-f25c-464d-9f71-ceccb44d9c89-195
Sell BSQ (Buy BTC)              0.00003950  0.00060000 - 0.00400000    15.19 - 101.27  BSQ Swap        2022-08-30T11:41:51Z  714117-59608f03-963f-4336-baab-64d43338e4c7-192  
Sell BSQ (Buy BTC)              0.00004000               0.00080000             20.00  BSQ Swap        2022-08-30T07:14:57Z  ue9sdp-dc7323d8-2731-4247-a058-030996d067af-195  
Sell BSQ (Buy BTC)              0.00004000               0.00080000             20.00  BSQ Swap        2022-08-30T07:14:27Z  SKCKVQDP-d4623ad7-bebc-4aed-93da-53a8ac3ff514-195
Sell BSQ (Buy BTC)              0.00004048  0.00100000 - 0.00810000    24.70 - 200.10  BSQ Swap        2022-08-29T19:41:39Z  HrOuNo-58302776-5319-4818-af00-213d0973375f-194  
Sell BSQ (Buy BTC)              0.00004049  0.00060000 - 0.00610000    14.82 - 150.65  BSQ Swap        2022-08-28T16:40:05Z  6KxJh-e4ee2a5a-64e9-46b5-951d-6c6c9f17e0c3-194   
Sell BSQ (Buy BTC)              0.00004050  0.00060000 - 0.00400000     14.81 - 98.77  BSQ Swap        2022-07-03T16:05:01Z  NJBASBFF-d92a6fe1-ca9c-4fd0-9b46-6af997df8062-192
Sell BSQ (Buy BTC)              0.00004100  0.01000000 - 0.03500000   243.90 - 853.66  BSQ Swap        2022-07-20T16:32:42Z  4KWYFJP-bb86953f-3eaf-46f8-8746-83f9e548f7ed-194 
Sell BSQ (Buy BTC)              0.00004399  0.00040000 - 0.00290000      9.09 - 65.92  BSQ Swap        2022-08-29T19:43:42Z  175293-8435740d-5985-49e7-9db8-36f033a9eebd-194  
Sell BSQ (Buy BTC)              0.00004438               0.00250000             56.33  BSQ Swap        2022-08-03T21:01:34Z  oA9oj0GO-5c9b7e5e-de84-4ca2-a387-58486f5b5935-192
Sell BSQ (Buy BTC)              0.00004648               0.00200000             43.03  BSQ Swap        2022-08-03T19:24:12Z  edwjc-94213efc-7cd0-4140-a0ae-0641e29179e2-192   
Sell BSQ (Buy BTC)              0.00004655               0.00070000             15.04  BSQ Swap        2022-07-20T20:53:08Z  asxly-427893e8-6d6b-4a12-97cc-3463cc217bdf-192   
Sell BSQ (Buy BTC)              0.00004660               0.00150000             32.19  BSQ Swap        2022-08-03T21:06:37Z  ypW2V-b690bc2e-de32-4176-a7b9-27ebc7f72e14-192   
Sell BSQ (Buy BTC)              0.00004679               0.00080000             17.10  BSQ Swap        2022-08-03T19:28:24Z  hgsZP-e7a80f22-7a06-416c-82aa-b4f5c8cbf798-192   
Sell BSQ (Buy BTC)              0.00004680               0.00060000             12.82  BSQ Swap        2022-07-20T20:49:31Z  PJNjEX-0461e540-c6ed-49f7-b1f7-8584f8aefb69-192  
Sell BSQ (Buy BTC)              0.00004724               0.00090000             19.05  BSQ Swap        2022-07-29T02:01:58Z  Fejwzd-1e0d10c9-8612-4001-b04e-fae90af42dc7-192  
Sell BSQ (Buy BTC)              0.00004990               0.00050000             10.02  BSQ Swap        2022-07-29T02:02:54Z  pcokkua-06cdeb10-c423-4ef4-87f7-d711d4d23bf1-192 
Sell BSQ (Buy BTC)              0.00005000               0.00040000              8.00  BSQ Swap        2022-08-03T20:55:05Z  6ensso-15e41f4b-5444-4394-830d-199c8d2efc93-192  
Sell BSQ (Buy BTC)              0.00005610               0.00040000              7.13  BSQ Swap        2022-07-29T01:59:34Z  3741221-a4290129-059b-47c6-a62b-e78e8613ecb9-192

2.2. Pick one and take it with takeoffer. Payment must come from BsqSwapAccount payment account. - command: bisq_cli takeoffer --offer-id=PJNjEX-0461e540-c6ed-49f7-b1f7-8584f8aefb69-192 --fee-currency=BTC - output:

trade PJNjEX-0461e540-c6ed-49f7-b1f7-8584f8aefb69-192 successfully taken

2.3. Check the change in BSQ and BTC balances with getbalance --currency-code=BTC and getbalance --currency-code=BSQ. - command: bisq_cli getbalance --currency-code=btc - output:

Available Balance  Reserved Balance  Total Available Balance  Locked Balance
       0.00938658        0.00000000               0.00938658      0.00000000

And then for BSQ: - command: bisq_cli getbalance --currency-code=bsq - output:

Available Confirmed Balance  Unverified Balance  Unconfirmed Change Balance  Locked For Voting Balance  Lockup Bonds Balance  Unlocking Bonds Balance
                      12.74                0.00                        0.00                       0.00                  0.00                     0.00

Let's see the trades details as well: - command: bisq_cli gettrades --category=closed - output:

Trade ID                                         Date/Time (UTC)       Market        Price  Deviation  Amount in BTC  Amount  Currency  Tx Fee (BTC)  Trade Fee  Buyer Deposit (BTC)  Seller Deposit (BTC)  Offer Type  Status
PJNjEX-0461e540-c6ed-49f7-b1f7-8584f8aefb69-192  2022-09-08T19:20:22Z  BSQ/BTC  0.00004680        N/A         0.0006   12.82  BSQ         0.00001342   0.00 BSQ           0.00000000            0.00000000  SELL BSQ    Confirmed

Now for the numbers:

  • BTC
    • My expected balance and the reality
paid_btc = bsq_amount * btc_per_bisq_price
final_btc_balance = starting_btc - paid_btc - mining_fee = 0.01 - (0.00004680 * 12.82) - 0.00001342 = 0.009386604
reality = 0.00938658

There is a difference of 24 sats that can be attributed to how bisq rounds the price to 8 decimal positions (so that it's counted only up to sats).

final_bsq_balance = 12.82
reality = 12.74

Where did my 0.08 BSQ go to???


	4. Check the change in BSQ and BTC balances with `getbalance --currency-code=BTC` and `getbalance --currency-code=BSQ`. The BTC balance should comply with BTC = starting_btc + purchased_btc - mining_fee. The BSQ balance should comply with BSQ = starting_bsq - trading_fee.
2. Buy a small amount of BTC
	1. Check the available offers with `getoffers --direction=BUY --currency-code=BSQ`.
	2. Pick one (preferably revolut since it's fast) and take it with `takeoffer`.
	3. Check it on the list of open trades with `gettrades --category=open`.
	4. Send the payment through the fiat system.
	5. Confirm the payment with `confirmpaymentstarted`.
	6. Regularly check `gettrade` until the trade is finished.
	7. Once it appears finished, verify that it appears in `gettrades --category=closed`.
3. Review balances and empty the wallet.
	1. Check the change in BSQ and BTC balances with `getbalance --currency-code=BTC` and `getbalance --currency-code=BSQ`. The BTC balance should comply with BTC = starting_btc - (purchased_bsq * price) - trading_fee - mining_fee.
	2. Send the remaining BSQ to my main wallet with `sendbsq`
	3. Check the change in BSQ and BTC balances with `getbalance --currency-code=BTC` and `getbalance --currency-code=BSQ`. The BTC balance should comply with BTC = starting_btc - mining_fee. The BSQ balance should be zero.
	4. Send the remaining BTC to my main wallet with `sendbtc`.
	5. Check that the BTC balance is zero.