Skip to content

Commit ea54247

Browse files
committed
looprpc: add asset id to liquidity request
1 parent 5747a8e commit ea54247

File tree

6 files changed

+1103
-973
lines changed

6 files changed

+1103
-973
lines changed

cmd/loop/liquidity.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func setRule(ctx *cli.Context) error {
106106
// We need to set the full set of current parameters every time we call
107107
// SetParameters. To allow users to set only individual fields on the
108108
// cli, we lookup our current params, then update individual values.
109-
params, err := client.GetLiquidityParams(
109+
paramsResponse, err := client.GetLiquidityParams(
110110
context.Background(), &looprpc.GetLiquidityParamsRequest{},
111111
)
112112
if err != nil {
@@ -120,6 +120,12 @@ func setRule(ctx *cli.Context) error {
120120
otherRules []*looprpc.LiquidityRule
121121
)
122122

123+
// We're only interested in the btc rules for now.
124+
params, ok := paramsResponse.Rules["BTC"]
125+
if !ok {
126+
return errors.New("no rules set for BTC")
127+
}
128+
123129
// Run through our current set of rules and check whether we have a rule
124130
// currently set for this channel or peer. We also track a slice
125131
// containing all of the rules we currently have set for other channels,
@@ -160,6 +166,7 @@ func setRule(ctx *cli.Context) error {
160166
context.Background(),
161167
&looprpc.SetLiquidityParamsRequest{
162168
Parameters: params,
169+
AssetId: "btc",
163170
},
164171
)
165172
return err
@@ -216,6 +223,7 @@ func setRule(ctx *cli.Context) error {
216223
context.Background(),
217224
&looprpc.SetLiquidityParamsRequest{
218225
Parameters: params,
226+
AssetId: "btc",
219227
},
220228
)
221229

@@ -364,13 +372,19 @@ func setParams(ctx *cli.Context) error {
364372
// We need to set the full set of current parameters every time we call
365373
// SetParameters. To allow users to set only individual fields on the
366374
// cli, we lookup our current params, then update individual values.
367-
params, err := client.GetLiquidityParams(
375+
paramsResponse, err := client.GetLiquidityParams(
368376
context.Background(), &looprpc.GetLiquidityParamsRequest{},
369377
)
370378
if err != nil {
371379
return err
372380
}
373381

382+
// We're only interested in the btc rules for now.
383+
params, ok := paramsResponse.Rules["BTC"]
384+
if !ok {
385+
return errors.New("no rules set for BTC")
386+
}
387+
374388
var flagSet, categoriesSet, feePercentSet bool
375389

376390
// Update our existing parameters with the values provided by cli flags.
@@ -556,6 +570,7 @@ func setParams(ctx *cli.Context) error {
556570
_, err = client.SetLiquidityParams(
557571
context.Background(), &looprpc.SetLiquidityParamsRequest{
558572
Parameters: params,
573+
AssetId: "btc",
559574
},
560575
)
561576

loopd/swapclient_server.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,8 +1224,8 @@ func (s *swapClientServer) GetInfo(ctx context.Context,
12241224

12251225
// GetLiquidityParams gets our current liquidity manager's parameters.
12261226
func (s *swapClientServer) GetLiquidityParams(_ context.Context,
1227-
_ *looprpc.GetLiquidityParamsRequest) (*looprpc.LiquidityParameters,
1228-
error) {
1227+
_ *looprpc.GetLiquidityParamsRequest) (
1228+
*looprpc.GetLiquidityParamsResponse, error) {
12291229

12301230
cfg := s.liquidityMgr.GetParameters()
12311231

@@ -1234,7 +1234,11 @@ func (s *swapClientServer) GetLiquidityParams(_ context.Context,
12341234
return nil, err
12351235
}
12361236

1237-
return rpcCfg, nil
1237+
return &looprpc.GetLiquidityParamsResponse{
1238+
Rules: map[string]*looprpc.LiquidityParameters{
1239+
"btc": rpcCfg,
1240+
},
1241+
}, nil
12381242
}
12391243

12401244
// SetLiquidityParams attempts to set our current liquidity manager's

0 commit comments

Comments
 (0)