99 "github.com/btcsuite/btcd/btcutil"
1010 "github.com/lightninglabs/loop"
1111 "github.com/lightninglabs/loop/looprpc"
12+ "github.com/lightninglabs/taproot-assets/rfqmath"
13+ "github.com/lightninglabs/taproot-assets/taprpc/rfqrpc"
14+ "github.com/lightningnetwork/lnd/lnwire"
1215 "github.com/lightningnetwork/lnd/routing/route"
1316 "github.com/urfave/cli"
1417)
@@ -268,7 +271,19 @@ func printQuoteOutResp(req *looprpc.QuoteRequest,
268271 totalFee := resp .HtlcSweepFeeSat + resp .SwapFeeSat
269272
270273 if resp .AssetRfqInfo != nil {
274+ assetAmtSwap , err := getAssetAmt (
275+ req .Amt , resp .AssetRfqInfo .SwapAssetRate ,
276+ )
277+ if err != nil {
278+ fmt .Printf ("Error converting asset amount: %v\n " , err )
279+ return
280+ }
281+ exchangeRate := float64 (assetAmtSwap ) / float64 (req .Amt )
271282 fmt .Printf (assetAmtFmt , "Send off-chain:" ,
283+ assetAmtSwap , resp .AssetRfqInfo .AssetName )
284+ fmt .Printf (rateFmt , "Exchange rate:" ,
285+ exchangeRate , resp .AssetRfqInfo .AssetName )
286+ fmt .Printf (assetAmtFmt , "Limit Send off-chain:" ,
272287 resp .AssetRfqInfo .MaxSwapAssetAmt ,
273288 resp .AssetRfqInfo .AssetName )
274289 } else {
@@ -288,7 +303,17 @@ func printQuoteOutResp(req *looprpc.QuoteRequest,
288303 fmt .Printf (satAmtFmt , "Estimated total fee:" , totalFee )
289304 fmt .Println ()
290305 if resp .AssetRfqInfo != nil {
306+ assetAmtPrepay , err := getAssetAmt (
307+ resp .PrepayAmtSat , resp .AssetRfqInfo .PrepayAssetRate ,
308+ )
309+ if err != nil {
310+ fmt .Printf ("Error converting asset amount: %v\n " , err )
311+ return
312+ }
291313 fmt .Printf (assetAmtFmt , "No show penalty (prepay):" ,
314+ assetAmtPrepay ,
315+ resp .AssetRfqInfo .AssetName )
316+ fmt .Printf (assetAmtFmt , "Limit no show penalty (prepay):" ,
292317 resp .AssetRfqInfo .MaxPrepayAssetAmt ,
293318 resp .AssetRfqInfo .AssetName )
294319 } else {
@@ -302,3 +327,33 @@ func printQuoteOutResp(req *looprpc.QuoteRequest,
302327 time .Unix (int64 (req .SwapPublicationDeadline ), 0 ),
303328 )
304329}
330+
331+ // getAssetAmt returns the asset amount for the given amount in satoshis and
332+ // the asset rate.
333+ func getAssetAmt (amt int64 , assetRate * looprpc.FixedPoint ) (
334+ uint64 , error ) {
335+
336+ askAssetRate , err := unmarshalFixedPoint (assetRate )
337+ if err != nil {
338+ return 0 , err
339+ }
340+
341+ msatAmt := lnwire .MilliSatoshi ((amt * 1000 ))
342+
343+ assetAmt := rfqmath .MilliSatoshiToUnits (msatAmt , * askAssetRate )
344+
345+ return assetAmt .ToUint64 (), nil
346+ }
347+
348+ // unmarshalFixedPoint converts an RPC FixedPoint to a BigIntFixedPoint.
349+ func unmarshalFixedPoint (fp * looprpc.FixedPoint ) (* rfqmath.BigIntFixedPoint ,
350+ error ) {
351+
352+ // convert the looprpc.FixedPoint to a rfqrpc.FixedPoint
353+ rfqrpcFP := & rfqrpc.FixedPoint {
354+ Coefficient : fp .Coefficient ,
355+ Scale : fp .Scale ,
356+ }
357+
358+ return rfqrpc .UnmarshalFixedPoint (rfqrpcFP )
359+ }
0 commit comments