Redgold Documentation

Redgold Documentation

AMM Swaps & Exchange

This guide will explain the basics of using Redgold's native swap AMMs to exchange Redgold for other assets, as well as some brief information on how they work.

What are native swaps?

Native swaps are a type of automated market maker (AMM) that allows users to swap one asset for another, using a multiparty encryption scheme for a group of nodes to hold the keys to the underlying assets being swapped. This allows for avoiding the use of wrapper tokens and trusted intermediaries. Liquidity is provided to the multiparty group in a permissionless fashion, and the execution of swap requests and overall stake determines the current price automatically.

What do I need to know to execute a swap?

The most important concept to understand before attempting a swap, is that you must have direct access to the keys or mnemonics used to generate the source address of the funds. This is because the output of the swap is sent directly to the corresponding address of the source funds, and can only be unlocked by a signature from the exact same key that was used to send the funds.

This feature is primarily intended for ease-of-use and security, as Redgold can reconstruct Bitcoin and other addresses the same way to verify signatures. Simply having access to a key that sends funds to an AMM is the criteria for unlocking the funds on the other side.

In the future, more complex swapping parameters will be supported for arbitrary key changes during exchange, but this requires a multi-transaction workflow with additional fees, for now, this is the simplest recommended path to follow.

How can I execute a swap?

Currently, only BTC/RDG pools are supported. To execute a swap, navigate to the Explorer page corresponding to the environment of interest: Redgold Dev Explorer or Redgold Mainnet Explorer for example, and look at the top of the page for the current recommended BTC/RDG pool address. Click on that.

Using this page, you can view the current estimated AMM order book, as well as calculate a preview of a trade showing the exact expected exchange rate. Simply sending any funds to this address in BTC will result in the receipt of RDG at the current AMM rate, received at the same 'address' that sent the BTC.

How do I spend the funds I receive?

The wallet software, so long as it contains the same key, will automatically allow you to spend the funds received to any valid address. We recognize address formats from multiple networks, and allow signature verification against any output address type.

Example Walk Through From the UI

This workflow can be tested on dev, staging, and test environments before attempting on mainnet to ensure you understand the process. The following steps are a basic example of how to execute a swap using the Redgold wallet.

All non-mainnet environments use Bitcoin testnet funds, please find an appropriate faucet to obtain testnet funds. A Redgold faucet is provided on the explorer page as well.

Please see the Redgold Wallet Guide for more details on how to setup keys, once setup, you can view the corresponding Bitcoin address to your hot wallet key, and hot wallet Bitcoin transactions are supported (cold are not yet.) Here is an example of a singular key that holds BTC, RDG, and ETH and is sending BTC using the Redgold wallet to the AMM swap address

In here, we have sent a tiny amount of Bitcoin testnet funds to the dev AMM swap address found on the explorer page.

By then viewing the explorer page and searching for our corresponding BTC source address, we should see an incoming transaction from the AMM sent on the Redgold network but with a spendable address of the BTC original source address. This allows us to spend it using the same key, and the Redgold wallet will automatically recognize these funds.