@@ -20,6 +20,7 @@ import (
2020 "github.com/lightninglabs/loop/sweep"
2121 "github.com/lightninglabs/loop/sweepbatcher"
2222 "github.com/lightninglabs/loop/utils"
23+ "github.com/lightninglabs/taproot-assets/taprpc/rfqrpc"
2324 "github.com/lightningnetwork/lnd/lntypes"
2425 "github.com/lightningnetwork/lnd/routing/route"
2526 "google.golang.org/grpc"
@@ -661,6 +662,10 @@ func (s *Client) LoopOutQuote(ctx context.Context,
661662 // If we use an Asset we'll rfq to get the asset amounts to use for
662663 // the swap.
663664 if request .AssetRFQRequest != nil {
665+ if s .assetClient == nil {
666+ return nil , errors .New ("asset client must be set " +
667+ "when trying to loop out with an asset" )
668+ }
664669 rfqReq := request .AssetRFQRequest
665670 if rfqReq .Expiry == 0 {
666671 rfqReq .Expiry = time .Now ().Add (defaultRFQExpiry ).Unix ()
@@ -680,6 +685,13 @@ func (s *Client) LoopOutQuote(ctx context.Context,
680685 return nil , err
681686 }
682687
688+ prepayAssetRate , err := rfqrpc .UnmarshalFixedPoint (
689+ prepayRfq .BidAssetRate ,
690+ )
691+ if err != nil {
692+ return nil , err
693+ }
694+
683695 // The actual invoice swap amount is the requested amount plus
684696 // the swap fee minus the prepay amount.
685697 invoiceAmt := request .Amount + quote .SwapFee -
@@ -694,6 +706,13 @@ func (s *Client) LoopOutQuote(ctx context.Context,
694706 return nil , err
695707 }
696708
709+ swapAssetRate , err := rfqrpc .UnmarshalFixedPoint (
710+ swapRfq .BidAssetRate ,
711+ )
712+ if err != nil {
713+ return nil , err
714+ }
715+
697716 // We'll also want the asset name to verify for the client.
698717 assetName , err := s .assetClient .GetAssetName (
699718 ctx , rfqReq .AssetId ,
@@ -705,8 +724,10 @@ func (s *Client) LoopOutQuote(ctx context.Context,
705724 loopOutQuote .LoopOutRfq = & LoopOutRfq {
706725 PrepayRfqId : prepayRfq .Id ,
707726 MaxPrepayAssetAmt : prepayRfq .AssetAmount ,
727+ PrepayAssetRate : prepayAssetRate ,
708728 SwapRfqId : swapRfq .Id ,
709729 MaxSwapAssetAmt : swapRfq .AssetAmount ,
730+ SwapAssetRate : swapAssetRate ,
710731 AssetName : assetName ,
711732 }
712733 }
0 commit comments