Skip to content

Atomic Swaps

shermand100 edited this page Jan 23, 2024 · 3 revisions

This Wiki shows a simplified example of how to use AthanorLabs Atomic Swap Utility in conjunction with PiNodeXMR

This Utility is created and maintained by AthanorLabs. We like it so have brought it to your attention via PiNodeXMR but be mindful of local regulations regarding crypto swaps and any tax implications you may incur through it's use. PiNodeXMR does not endorse it's use and is very aware this is in BETA so funds may be at risk from undiscovered bugs. However it is from testing by individuals like you than confidence in it is gained. If you encounter bugs or issues please include logs and report to:

https://github.com/AthanorLabs/atomic-swap/issues

To install:

For PiNodeXMR versions below v5.23.08 an update to this version is required.

  1. Perform PiNodeXMR update from terminal setup menu
  2. That will add the "Update Atomic Swap Utility" option to your menu.
  3. Perform "Update Atomic Swap Utility" to install Atomic Swaps.
  4. Navigate to the Web-UI "Swap" tab and enter an Ethereum JSON RPC node endpoint. Then click "Start Swap Service"

How to interact with the Atomic Swap Utility to **MAKE **offers

We're excited for a full Web based interface in the future, it's in the works. For now we can get most of the basic functions from a menu I've added to the terminal setup menu:

Atomic Swap Menu

View Balances

Generated from ~/atomic-swap/bin/swapcli balances

Prints out your Ethereum Address, Ethereum Balance, Monero Address, Monero Balance, Unlocked XMR Balance and Blocks to Unlock in the format:

Ethereum address: 0x9F79B0...270f
ETH Balance: 0.0209...99708
Monero address: 44jye9Vwf...Es1EKTPWUNELJh3
XMR Balance: 0.271...54
Unlocked XMR balance: 0.271...54
Blocks to unlock: 0
Press enter to continue

View Monero Address + QR

Generated from ~/atomic-swap/bin/swapcli xmr-address

This and the below option show their respective Addresses and QR codes. These can be used to fund the wallets created by the Atomic Swap Utility. THESE WALLETS ARE UNLOCKED WITH NO PASSWORD Details of how to backup these wallets is later in this document. Again this utility is in BETA. FUNDS MAY BE AT RISK

Example:

Atomic Swap Menu

Note: A sufficient size screen resolution is needed to display the QR code properly.

View Ethereum Address + QR

Generated from ~/atomic-swap/bin/swapcli eth-address

... As above but for Ethereum

View Past Swaps

Generated from ~/atomic-swap/bin/swapcli past

If you have performed a Swap in the past you will be able to review it here. An example I created:

Past swaps:
ID: 0x9d19f0eaf5a23a91bb2d3eb6d5e28ce046dc4fcc9da9d104a728534943dcdc55
Start time: 2023-08-02-22:20:40
End time: 2023-08-02-22:46:26
Provided: 0.12734429266 XMR
Received: 0.0109999999999708 ETH
Exchange Rate: 0.08638 XMR/ETH
Status: Success
Press enter to continue

View Status of Ongoing Swaps

Generated from ~/atomic-swap/bin/swapcli ongoing

When you make an offer to sell XMR it may take some time for a buy to take your offer. When the trade is in progress you can view the status with this command.

Clear All Offers

Generated from ~/atomic-swap/bin/swapcli clear-offers

When you have created swap offers this option will revoke them all. (So long as someone hasn't initiated taking the offer - I think)

Show My Offers

Generated from ~/atomic-swap/bin/swapcli get-offers

Further down I'll show you how to create a Swap. When you do it'll be shown here.

Discover Available XMR->ETH Offers

Generated from ~/atomic-swap/bin/swapcli query-all

See what XMR->ETH offers are out in the wild provided by other users.

Suggested XMR ETH Exchange Rate

Generated from ~/atomic-swap/bin/swapcli suggested-exchange-rate

This option refers to a single source from "Chainlink Oracle" for the market XMR ETH rate. Personally I also refer to a second source to ensure accuracy should the server be wrong or manipulated.

Example output:

Exchange rate: 0.085888
XMR/USD Price: 139.2098      (2023-09-06 16:03:07 +0100 BST)
ETH/USD Price: 1620.83446955 (2023-09-06 16:15:29 +0100 BST)
Press enter to continue

Where offering 1 XMR receives 0.085888 ETH in return.

Create XMR Sell Offer

Ok the business end. Shown here is a Gif of the Steps to offer a XMR->ETH swap:

Atomic Swap Example

  1. With you Monero Wallet suitably funded, select the MINIMUM amount of XMR you'll sell in one swap. MUST BE MIN 0.01 ETH EQUIVILANT
  2. Select the MAXIMUM amount of XMR you'll sell in one swap. MUST BE MIN 0.01 ETH EQUIVILANT AND LARGER THAN YOUR SET MINIMUM
  3. You'll now be shown the exchange rate as provided by "Chainlink Oracle", I recommend referring to a second source to be sure of this. E.g: Exchange rate: 0.085888, means when offering 1 XMR you receive 0.085888 ETH in return.
  4. Enter the exchange rate you are willing to take for your XMR. Again, be sure not to short change yourself!
  5. Last chance to back out! This page then gives a summary of what you are offering to the world and is your last chance to cancel the offer. (If you have made a mistake after offering - use the "Clear all Offers" Option above, assuming a bot hasn't snatched up your mistake first!

Note: - By referring to the AthanorLabs Github documents you can easily see how to offer XMR for any ERC20 Token instead of ETH. A balance of ETH will be required still for gas fees

How to interact with the Atomic Swap Utility to TAKE offers

At the moment this is done via CLI only in the format and follows the official docs from AthanorLabs GitHub: https://github.com/AthanorLabs/atomic-swap/blob/master/docs/mainnet.md#monero-taker

Note: -

  • If you wish to swap for an ERC20 instead of ETH, you can set the asset with --eth-asset TOKEN-CONTRACT-ADDRESS. However, you must have a funded ETH account to perform a swap for an ERC20, as relayers are not supported for token swaps.

Additionally, an error may be present when creating a swap due to balances etc. When the setup menu re-appears scroll up to check for messages. Logs at:

/home/pinodexmr/.atomicswap/mainnet/atomicSwap.log

/home/pinodexmr/.atomicswap/mainnet/monero-wallet-rpc.log

Wallet backups

From https://github.com/AthanorLabs/atomic-swap/blob/master/docs/default-file-locations.md

/home/pinodexmr/.atomicswap/mainnet/wallet/swap-wallet
This is the default location for your monero wallet file. You can change the location using --wallet-file, but place the wallet file in a dedicated wallet directory, as swapd will create temporary, xmrtaker-* swap wallets in this same directory. Internally, swapd launches a monero-wallet-rpc instance whose log file is located at {DATA_DIR}/moner-wallet-rpc.log or one directory above the wallet file's directory when using the --wallet-file flag.

Note: Monero wallets actually consist of 3 files. Using the default wallet file path, the files are:

/home/pinodexmr/.atomicswap/mainnet/swap-wallet
/home/pinodexmr/.atomicswap/mainnet/wallet/swap-wallet.keys
/home/pinodexmr/.atomicswap/mainnet/wallet/swap-wallet.address.txt
When passing the --wallet-file flag to swapd, we only specify the path to the first file above. More information on what the individual files contain can be [found here](https://monero.stackexchange.com/a/2804/3691).

/home/pinodexmr/.atomicswap/mainnet/eth.key
This is the default location of your Ethereum private key used by swaps. Alternate locations can be configured with --eth-privkey. If the file does not exist, a new random key will be created and placed in this location.

Other Payment Options

  • You can offer to be a relayer node and be paid 0.01 ETH per transaction you relay - minus gas fees. This adds privacy to the ETH transaction. See https://github.com/AthanorLabs/atomic-swap/blob/master/docs/mainnet.md#relayer

  • When selling XMR you can offer to accept a ERC20 Token. If you wish to swap for an ERC20 instead of ETH, you can set the asset with --eth-asset TOKEN-CONTRACT-ADDRESS. However, you must have a funded ETH account to perform a swap for an ERC20, as relayers are not supported for token swaps.

AthanorLabs GPLv3 Disclaimer:

THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.