Is there a way to complete a partial offer with atomic transactions?

+1 vote

I have the following scenario. Person A wants to sell 100 units of Asset Alpha for 200 units of Asset Beta.

Person B see the offer and wants to buy 50 units of Asset Alpha so he needs to use the append (appendrawexchange) function. But I would like to let him do the transaction for half of the Assets (completerawexchange), and leave the other half for anyone else.

The only way I can think of doing that right now is to literally create 100 separate offers.

Am I understanding this wrong? Is there a better way to do this?

asked Nov 2, 2018 by Andrew

1 Answer

+1 vote
 
Best answer

Yes, you can certainly do this, and you don't even need to do anything special or create many separate offers.

Person B uses appendrawexchange to add what they are willing to offer, and what they want to receive. These are not the full amounts, so the output will be a not-yet-balanced transaction.

This transaction is itself a new offer of exchange, with outstanding amounts offered and received, that can be passed on to other participants. They can treat it like any other offer of exchange.

answered Nov 5, 2018 by MultiChain
Hi!

Is there a way to make the partial transaction / funds being send -  instead of waiting for the full offer to be accepted?

Thx
The point of an atomic exchange transaction is to guarantee that a full exchange takes place, as desired by the party making the original offer. But it doesn't have any rules about who specifically completes that exchange, and it can be completed in multiple stages and by multiple parties.

So let's say the second party agrees to exchange part of the sum, and uses the appendrawexchange command in their node to add that part on, before sending the transaction back to the original party.

If the original party is able, and happy with what remains, they could then complete the exchange using their own funds, and then the transaction will be ready for broadcast and confirmation. As a result, the partial exchange will have been executed.

Note that for this to work, the original offering party will need to already own some of the asset that they were asking for in the exchange.
Hi!

I appreciate your reply / suggestion. Maybe this feature should be consider by having a "boolean inFull" and "int minimumFill" parameter.

As is, it is more like an auction (1 for 1) than an exchange and it void some of the superb possibilities of your atomic exchange implementation.

It surely depend on use case, but I feel in many situations participants offering inventory would be happy to have partial fill.

This could be based on the assets ratio equality. Ie: Client A ask 1000 ABC for 1 XYZ (locked). Client B ask 0.5 XYZ and offer 500 ABC(locked). 500 ABC / 1000 ABC = 0.5 and 0.5 XYZ / 1 = 0.5. Both of those ratio need too match. Here, only half would be fill.      

Since funds are lock on both side, the transaction could be amended on that criteria (ratio equality) while sendrawtransaction and return the remaining as new offer tagged partial fill - instead returning error: mismatch in input/output quantities.

Thx for your time & work.
I understand the request, but the MultiChain transaction model can't easily be extended to provide this sort of functionality. So I can suggest two workarounds:

1. Create many offers of exchange for smaller amounts, so the counterparty can fulfill whichever one they like.

2. Manage the process of bids outside of the blockchain, and use the chain only for the final execution of an agreed-upon exchange.
i made a CEX like limit orders matching solution for Multichain. it's needed when amount of new incoming order more than amount of closest order on the same price level in orderbook. Because if incoming order was not filled after first exchange transaction in orderbook it's transforms in new opened exchange transaction and can't be matched with other opened exchange transactions in blockchain. So before matching orders you need to check amounts of new order and order in orderbook, and if new order's amount more than orderbook's order amount, fill one order then disable current exchange transaction and put new exchange order with new amount. in other cases everything works correct.
...