xmr-btc-swap icon indicating copy to clipboard operation
xmr-btc-swap copied to clipboard

Plug-in hook for custom quotes on the ASB

Open Scalena opened this issue 2 years ago • 6 comments

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

  • Users could determine their exchange rate using a custom algorithm instead of using a Kraken-style websocket plus a fixed spread percentage.
  • Users could dynamically set their min_buy_btc and max_buy_btc limits using a custom algorithm, for example based on their wallet balances.

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.

Scalena avatar Jul 22 '22 18:07 Scalena

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?

delta1 avatar Jul 25 '22 10:07 delta1

@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

Scalena avatar Jul 27 '22 20:07 Scalena

Thanks!

delta1 avatar Jul 28 '22 04:07 delta1

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?

ikmckenz avatar Sep 12 '23 01:09 ikmckenz

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)

delta1 avatar Sep 12 '23 08:09 delta1

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.

ikmckenz avatar Sep 12 '23 21:09 ikmckenz