You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

65 lines
1.3 KiB

package main
import (
"context"
"fmt"
"github.com/urfave/cli"
"github.com/btcsuite/btcutil"
"github.com/lightninglabs/loop/looprpc"
"github.com/lightninglabs/loop/swap"
)
var termsCommand = cli.Command{
Name: "terms",
Usage: "Display the current swap terms imposed by the server.",
Action: terms,
}
func terms(ctx *cli.Context) error {
client, cleanup, err := getClient(ctx)
if err != nil {
return err
}
defer cleanup()
req := &looprpc.TermsRequest{}
loopOutTerms, err := client.LoopOutTerms(context.Background(), req)
if err != nil {
return err
}
loopInTerms, err := client.GetLoopInTerms(
context.Background(), &looprpc.TermsRequest{},
)
if err != nil {
return err
}
printTerms := func(terms *looprpc.TermsResponse) {
fmt.Printf("Amount: %d - %d\n",
btcutil.Amount(terms.MinSwapAmount),
btcutil.Amount(terms.MaxSwapAmount),
)
fmt.Printf("Fee: %d + %.4f %% (%d prepaid)\n",
btcutil.Amount(terms.SwapFeeBase),
swap.FeeRateAsPercentage(terms.SwapFeeRate),
btcutil.Amount(terms.PrepayAmt),
)
fmt.Printf("Cltv delta: %v blocks\n", terms.CltvDelta)
}
fmt.Println("Loop Out")
fmt.Println("--------")
printTerms(loopOutTerms)
fmt.Println()
fmt.Println("Loop In")
fmt.Println("------")
printTerms(loopInTerms)
return nil
}