From d54d7055fa5ddcf7e176c603ad35c9ae9e4951c8 Mon Sep 17 00:00:00 2001 From: carla Date: Thu, 3 Sep 2020 10:36:45 +0200 Subject: [PATCH] loop: add swap suggestions command --- cmd/loop/liquidity.go | 28 ++++++++++++++++++++++++++++ cmd/loop/main.go | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/cmd/loop/liquidity.go b/cmd/loop/liquidity.go index c0a2b08..c382d7e 100644 --- a/cmd/loop/liquidity.go +++ b/cmd/loop/liquidity.go @@ -170,3 +170,31 @@ func setParam(ctx *cli.Context) error { return err } + +var suggestSwapCommand = cli.Command{ + Name: "suggestswaps", + Usage: "show a list of suggested swaps", + Description: "Displays a list of suggested swaps that aim to obtain " + + "the liquidity balance as specified by the rules set in " + + "the liquidity manager.", + Action: suggestSwap, +} + +func suggestSwap(ctx *cli.Context) error { + client, cleanup, err := getClient(ctx) + if err != nil { + return err + } + defer cleanup() + + resp, err := client.SuggestSwaps( + context.Background(), &looprpc.SuggestSwapsRequest{}, + ) + if err != nil { + return err + } + + printJSON(resp) + + return nil +} diff --git a/cmd/loop/main.go b/cmd/loop/main.go index fd4878c..1e7e7ff 100644 --- a/cmd/loop/main.go +++ b/cmd/loop/main.go @@ -110,7 +110,7 @@ func main() { loopOutCommand, loopInCommand, termsCommand, monitorCommand, quoteCommand, listAuthCommand, listSwapsCommand, swapInfoCommand, getLiquidityParamsCommand, - setLiquidityParamCommand, + setLiquidityParamCommand, suggestSwapCommand, } err := app.Run(os.Args)