diba-io / bitmask-core

Core functionality for the BitMask wallet
https://bitmask.app
Other
93 stars 21 forks source link

Support Auction Swaps #430

Closed crisdut closed 6 months ago

crisdut commented 7 months ago

Description This PR intent supports sequential swaps and unifies the previous swap operations (now called "strategies").

Now, BMC have three ways to make swap operations:

  1. P2P: The strategy allows participants (sellers and buyers) to make swaps without a coordinator. The match engine used is FIFO, i.e., the first bid that arrives with the correct target price.
  2. Airdrop: The strategy allows participants (issuers) to make individual or collection airdrops. The airdrop respect the FIFO (First In First Out).
  3. Auction: The strategy allows participants (sellers) to make individual or collection offers. The match engine used is the highest price, i.e., after the offer expires (or finished by seller), the coordinator selects the highest price bid and executes. ~Then, the coordinator updates the next available offer with the new UTXO (in case of the collections)~. All offers of the collections are publish and allow to receive bids.
  4. HotSwap: The strategy allows participants (sellers and buyers) to make swaps without a coordinator. The main difference of the P2P is the sign condition. The sign condition is post-sign, i.e., the seller is the last to sign.

Also, It was necessary to carry out some refactorings to increase the maintainability of the swaps in BMC, according to the checklist below:

Sequential Swaps (epic)

Closes #413 Closes #365 Closes #422

PS: I added #422 here because we can resolve all offers/bids in one "big" L1 transaction.

josediegorobles commented 7 months ago

Hi, could you update the wasm api?

crisdut commented 7 months ago

Hi, could you update the wasm api?

Yes, I think I finishing it today.

crisdut commented 7 months ago

Prevents reuse of bitcoin utxos (force update dustless verification)

Suppose we have a seller who wanted to sell 5 items and wants to sell via sequential swap. Throughout operations, the UTXO related to assets may decrease to smaller fractions until it turns to dust. As the seller no longer changes the PSBTs after the start of the auctions (the coordinator manages it), I thought about making a "minimum satoshis for operation" rule for the RGB20 and RGB21 wallets, what do you think?

crisdut commented 6 months ago

Prevents reuse of bitcoin utxos (force update dustless verification)

Suppose we have a seller who wanted to sell 5 items and wants to sell via sequential swap. Throughout operations, the UTXO related to assets may decrease to smaller fractions until it turns to dust. As the seller no longer changes the PSBTs after the start of the auctions (the coordinator manages it), I thought about making a "minimum satoshis for operation" rule for the RGB20 and RGB21 wallets, what do you think?

What do you guys think, @cryptoquick and @josediegorobles ?

cryptoquick commented 6 months ago

@crisdut We should always have an input from the buyer for paying fees and paying for the dust output.

Also, there's no way to batch transfers with auctions because they're separate PSBTs, correct? That's fine so long as multiple sequences can be spent within the same block.