comit-network / xmr-btc-swap

Bitcoin–Monero Cross-chain Atomic Swap
GNU General Public License v3.0
630 stars 78 forks source link

Plug-in hook for custom quotes on the ASB #1060

Open Scalena opened 1 year ago

Scalena commented 1 year ago

By providing a hook for a plug-in to be queried on a quote request, two features could be added to the ASB:

The current websocket + fixed values solution could be extracted into an exchangable plug-in or be kept as a default solution. Starting a plug-in API might also lay the foundations for future costumization features around a robust ASB core.

delta1 commented 1 year ago

Hey @Scalena, thanks for submitting. I like the idea and will think about it and investigate a bit. Do you have suggestions or references for similar plugin systems implemented elsewhere I could look at?

Scalena commented 1 year ago

@delta1 That's great! Actually, I got the idea while looking into Core Lightning (https://github.com/ElementsProject/lightning) which is, after all, a related application and has a very elaborate plugin system. I'm not sure if something similar would be appropriate for this project, but it is definitely worth looking at for inspiration. See also at https://github.com/ElementsProject/lightning/blob/master/doc/PLUGINS.md

delta1 commented 1 year ago

Thanks!

ikmckenz commented 10 months ago

Instead of a plug-in system, perhaps an easier approach to accomplish this would be to create a way to stream desired prices to the ASB through some kind of IPC, perhaps Unix sockets?

delta1 commented 10 months ago

Neat idea, thanks @ikmckenz. However, I think that the source of the price feed is orthogonal to the method of calculation of the provider's spread.

Ultimately we want the provider to be able to specify both:

  1. Where their price data comes (price plugin)
  2. How their spread and min/max available are calculated (spread plugin)
ikmckenz commented 9 months ago

Once it's safer to trade larger amounts through atomic swaps, I think makers who want to quote higher volumes and tighter spreads will want features that will be difficult to implement in a plugin system.

  1. Quoted prices derived from an average of exchanges, or moving average of prices over a window, or other more complicated calculations such as book pressure.
  2. Spread derived from volatility, makers want to quote a larger spread when prices are moving quickly but can quote tighter when prices are calm. Volatility can be estimated by historical prices, or by options pricing, etc.
  3. Min/Max quotes derived from some calculation like min(inventory in maker wallet, maker inventory on exchanges, offers available to take for hedging on exchanges), or again informed by volatility.

Unless the plugins can stream in pre-calculated data from external applications, the plugin system would have to be pretty sophisticated with it's own DSL to define how all the inputs are set. Essentially the plugins would have to be a fully featured independent trading system.