loopd: add instantout quote

This commit is contained in:
sputn1ck 2024-02-07 17:33:11 +01:00
parent ca8f91ab77
commit b3fe9a9c61
No known key found for this signature in database
GPG key ID: 671103D881A5F0E4
3 changed files with 72 additions and 0 deletions

View file

@ -104,4 +104,8 @@ var RequiredPermissions = map[string][]bakery.Op{
Entity: "swap",
Action: "execute",
}},
"/looprpc.SwapClient/InstantOutQuote": {{
Entity: "swap",
Action: "read",
}},
}

View file

@ -1209,6 +1209,25 @@ func (s *swapClientServer) InstantOut(ctx context.Context,
return res, nil
}
// InstantOutQuote returns a quote for an instant out swap with the provided
// parameters.
func (s *swapClientServer) InstantOutQuote(ctx context.Context,
req *clientrpc.InstantOutQuoteRequest) (
*clientrpc.InstantOutQuoteResponse, error) {
quote, err := s.instantOutManager.GetInstantOutQuote(
ctx, btcutil.Amount(req.Amt), int(req.NumReservations),
)
if err != nil {
return nil, err
}
return &clientrpc.InstantOutQuoteResponse{
ServiceFeeSat: int64(quote.ServiceFee),
SweepFeeSat: int64(quote.OnChainFee),
}, nil
}
func rpcAutoloopReason(reason liquidity.Reason) (clientrpc.AutoReason, error) {
switch reason {
case liquidity.ReasonNone: