xmr-btc-swap
xmr-btc-swap copied to clipboard
Plug-in hook for custom quotes on the ASB
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
andmax_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.
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 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
Thanks!
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?
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:
- Where their price data comes (price plugin)
- How their spread and min/max available are calculated (spread plugin)
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.
- 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.
- 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.
- 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.