Skip to content

Commit 8931fd3

Browse files
committed
loop: rename setparam command to setrule
As we add more paramters to the liqudity manager, it will become more difficult to include them in a single cli endpoint with rules. This commit renames the existing setparam command (which is only used for rules at present), so that we can have a dedicated paramters cli command for all the new values we are adding.
1 parent f23a527 commit 8931fd3

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

cmd/loop/liquidity.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ func getParams(ctx *cli.Context) error {
3636
return nil
3737
}
3838

39-
var setLiquidityParamCommand = cli.Command{
40-
Name: "setparam",
39+
var setLiquidityRuleCommand = cli.Command{
40+
Name: "setrule",
4141
Usage: "set liquidity manager rule for a channel",
4242
Description: "Update or remove the liquidity rule for a channel.",
4343
ArgsUsage: "shortchanid",
@@ -58,10 +58,10 @@ var setLiquidityParamCommand = cli.Command{
5858
Usage: "remove the rule currently set for the channel.",
5959
},
6060
},
61-
Action: setParam,
61+
Action: setRule,
6262
}
6363

64-
func setParam(ctx *cli.Context) error {
64+
func setRule(ctx *cli.Context) error {
6565
// We require that a channel ID is set for this rule update.
6666
if ctx.NArg() != 1 {
6767
return fmt.Errorf("please set a channel id for the rule " +
@@ -122,12 +122,11 @@ func setParam(ctx *cli.Context) error {
122122
"flag")
123123
}
124124

125+
params.Rules = otherRules
125126
_, err = client.SetLiquidityParams(
126127
context.Background(),
127128
&looprpc.SetLiquidityParamsRequest{
128-
Parameters: &looprpc.LiquidityParameters{
129-
Rules: otherRules,
130-
},
129+
Parameters: params,
131130
},
132131
)
133132
return err
@@ -158,13 +157,16 @@ func setParam(ctx *cli.Context) error {
158157
)
159158
}
160159

160+
// Just set the rules on our current set of parameters and leave the
161+
// other values untouched.
162+
otherRules = append(otherRules, newRule)
163+
params.Rules = otherRules
164+
161165
// Update our parameters to the existing set, plus our new rule.
162166
_, err = client.SetLiquidityParams(
163167
context.Background(),
164168
&looprpc.SetLiquidityParamsRequest{
165-
Parameters: &looprpc.LiquidityParameters{
166-
Rules: append(otherRules, newRule),
167-
},
169+
Parameters: params,
168170
},
169171
)
170172

cmd/loop/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func main() {
129129
loopOutCommand, loopInCommand, termsCommand,
130130
monitorCommand, quoteCommand, listAuthCommand,
131131
listSwapsCommand, swapInfoCommand, getLiquidityParamsCommand,
132-
setLiquidityParamCommand, suggestSwapCommand,
132+
setLiquidityRuleCommand, suggestSwapCommand,
133133
}
134134

135135
err := app.Run(os.Args)

0 commit comments

Comments
 (0)