SatSale / SatSale

Lightweight Bitcoin payment processor written in easily deployable Python. Self custody donations and payments on-chain & Lightning network, directly connected to your own Bitcoin node! No middleman/custodian.
MIT License
240 stars 50 forks source link

Add support for SideSwap.io in weakhand mode #25

Open steepdawn974 opened 2 years ago

steepdawn974 commented 2 years ago

== This is a PROPOSAL. Happy to discuss ==

Situation

Currently, Weakhands mode allows to immediatly swap incoming BTC payments to L-USDT using Sideshift.ai. Swaps on Sideshift are relatively expensive, roughly 1.5% from what I can gather. They removed the Fee section from the FAQ and probably cover everything from via spreads.

Proposal

SideSwap.io is a better alternative, and currently the cheapest way on the market. Drawback: does not support Lightning payments

From their TG chat:

We're focused on adoption and removing barriers to use liquid. To help pay our bills, we charge a 0.1% fee on any pegin or pegout. If you swap through our instant swap, we have a 0.6-0.7% spread (from which we pay 0.2% to hedge, so profits are just below 0.5%). Swap and token market orders have a 0.1% fee.

Howto

To swap on-chain BTC to L-BTC via SideSwap, two steps would be necessary

  1. Call BTC-to-LBTC Peg-in. This swap is usually immediate for <0.25 BTC, as it's covered out of SideSwaps own balance (a native Peg-in to the Liquid sidechain would otherwise take 102 confirmations). Fee: 0.1%
  2. Perform an instant/market order swap of L-BTC to L-USDT . One would need to clarify with SideSwap team (TG channel) which API endpoint performs an instant/market order swap; I'm not sure whether submitting an order is sufficient or would only place you in the order book.
nickfarrow commented 2 years ago

I completely agree, I also noticed there's pretty big friction with sideshift... Full disclosure I also chucked my referral link in there ($0.16 to date) to get something back from this large fee.

However I would like to avoid doing two swaps if possible. I'm even thinking of coding my own LN-BTC -> L-BTC atomic swap service (haven't researched much). I would've hoped boltz.ai would support this currency conversion, among other swap providers. Maybe it isn't a popular pair yet :/

Still open to doing this in the mean time, but would make things a bit more complex doing a swap with bitcoind RPC, wait for confirmation then do another swap. Also we don't have any access to a liquid wallets/node and make that swap transaction. At the moment we're only sending to liquid addresses. Probably will not extend to full liquid support until people desire to receive payments on that network.

kristapsk commented 2 years ago

How about supporting multiple swap options and then at the moment of payment code automatically uses cheapest one that works at that moment?

Also probably there will be some alternative hedging options without swapping to USDT using derivatives in future, see https://twitter.com/LNMarkets/status/1473017215620370441.

kristapsk commented 2 years ago

TIL there is another service that could be used for swaps - https://fixedfloat.com/, they also have some API. Unfortunatelly, no Liquid Network support currently.

kristapsk commented 2 years ago

Here's some concept of trustless and noncustodial LN <-> stablecoin swaps. https://twitter.com/jokoono/status/1501213103714971666

kristapsk commented 1 year ago

Also probably there will be some alternative hedging options without swapping to USDT using derivatives in future, see https://twitter.com/LNMarkets/status/1473017215620370441.

And they implemented this. Here instead of selling LN BTC for USDT, you can instead deposit to @LNMarkets and then immediately convert BTC in your account to "synthetic USD", which basically is 1x leveraged BTCUSD futures short position that hedges BTC volatility vs USD. API docs - https://docs.lnmarkets.com/api/v1/#tag/Swap.

For context - https://twitter.com/LNMarkets/status/1595748989990830080.

kristapsk commented 1 year ago

Here's some LNBits extension (in Python!) providing synthetic stablecoins, using derivatives - https://github.com/lnbits/stable-wallets. Haven't studied it in details yet, but maybe could be something useful.