An Introduction to the Market-Making Bot for Atomic-Swap

1 220
Avatar for SmartBCH
1 year ago

To give members of the community a convenient and secure tool to maintain a 1:1 peg between BCH and SBCH, we have developed several tools based on AtomicSwap. The most important of these tools is the Market-Making Bot.

The Bot compensates for the usability shortcomings of the AtomicSwap protocol, which requires both parties to be online at the same time to complete the transaction. For non-professional users, being online all the time is impossible. Having both parties agree to be online at the same time makes matchmaking very difficult. The cross-chain scenarios served by AtomicSwap are naturally unable to automate the execution using means like an order book and AMM pool. Third-party custodian solutions like CEX are available but again go against the trustless principle that AtomicSwap adheres to.

The Market-Making Bot controls a private key. It is always online and readily available to non-professional users, thus avoiding difficult matchmaking.

In the AtomicSwap protocol, the roles of the two parties in a transaction are not reciprocal, but one party plays the "maker" role and the other party plays the "taker" role. The flow is as follows:

1. The maker announces an offer to swap coins through a certain smart contract.

2. The taker accepts the offer and deposits the tokens to be handed over to the maker into the Hashed Timelock Contract (HTLC) on the A blockchain.

3. The maker notices the toker's acceptance of the offer and deposits the token to be given to the taker in HTLC on the B blockchain.

4. The taker retrieves the coins from the HTLC on the B blockchain, which reveals the HTLC's hash preimage.

5. The maker uses the same hash preimage to retrieve the Token from HTLC on A blockchain.

The Market-Making Bot is always online, and it plays the role of the maker described above. It publishes its on-chain address, introduction, the validity period of one swap, fee rate, penalty ratio, and other information in the contract on smartBCH. At the same time, it holds a certain amount of BCH and SBCH on both BCH mainchain and smartBCH sidechain, the amount of which is publicly available. The coins it holds are the offer it gives to takers. Anytime, as long as the Bot has enough coins on the sidechain, takers can execute step 2 above on the mainchain, and vice versa. In step 2, to successfully complete the subsequent swap, the taker needs to provide the following information via OP_RETURN (on mainchain) or EVM Log (on sidechain):

1. The address of the Bot. There may be more than one Bot providing services to takers, and the on-chain address is needed to distinguish which one it is.

2. Taker's address

3. The hash lock

4. The expiration time of this Swap. It must meet the Bot's requirement of swap expiration time, otherwise, the Bot won't respond to this request.

5. The penalty ratio. It must be the same as the penalty ratio announced by the Bot, otherwise, the Bot will not respond to this request.

To provide service to takers, the Bot needs to use its funds, that is to say, it gives up the opportunity to utilize these funds to generate interest in other ways. Furthermore, Bot runs on cloud servers, which also incurs costs. Therefore, it makes sense for Bot to charge a percentage of the swapped assets as a fee.

AtomicSwap's trustless guarantee means that neither the taker nor the maker can embezzle the other's assets, while there is no guarantee that the swap will always be successful. Both the taker and the maker may pay the miner fee or gas fee for nothing but fail to complete the swap because of the other's non-cooperation. The Bot's inability to complete the swap due to subjective or objective reasons may cause the maker to lose its credibility, resulting in no taker being willing to trade with it at the end, which defeats its purpose of earning fees by providing services over a long period. Therefore, it is reasonable to believe that the Bot is unlikely to fail to cooperate with Taker because of subjective malice. On the contrary, takers do not need to maintain a better quality of service in the long run to accumulate credibility. Because they are anonymous, even intentional sabotage is difficult to trace. Based on these considerations, we do not penalize interaction failures caused by the Bot, while forfeiting a certain amount of money for transaction failures caused by takers, to avoid Bot suffering from ineffective use of funds due to attackers.

We will release the first version of the Market-Making Bot in a couple of days. If you'd like to help maintaining the 1:1 peg between BCH and SBCH, please consider run a Market-Making Bot, which can also bring fee earnings to you. If operating a Market-Making Bot looks too complex to you, just trading with a Bot is also helpful: when a Bot's SBCH pool is larger and BCH pool is small, you can swap BCH for SBCH with it, and then the pools will be more balanced.

5
$ 0.09
$ 0.08 from @TheRandomRewarder
$ 0.01 from @halu
Avatar for SmartBCH
1 year ago

Comments

I have never tried this type of business, but I will definitely start to inform myself.

$ 0.00
1 year ago