mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
loopd: add instantout quote
This commit is contained in:
parent
ca8f91ab77
commit
b3fe9a9c61
3 changed files with 72 additions and 0 deletions
|
|
@ -104,4 +104,8 @@ var RequiredPermissions = map[string][]bakery.Op{
|
|||
Entity: "swap",
|
||||
Action: "execute",
|
||||
}},
|
||||
"/looprpc.SwapClient/InstantOutQuote": {{
|
||||
Entity: "swap",
|
||||
Action: "read",
|
||||
}},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue