Skip to content

Commit cd8a014

Browse files
committed
liquidity: add easy asset params
1 parent 10c15c0 commit cd8a014

File tree

4 files changed

+1049
-888
lines changed

4 files changed

+1049
-888
lines changed

liquidity/parameters.go

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,20 @@ type Parameters struct {
114114
// EasyAutoloopTarget is the target amount of liquidity that we want to
115115
// maintain in our channels.
116116
EasyAutoloopTarget btcutil.Amount
117+
118+
// AssetAutoloopParams maps an asset id hex encoded string to its
119+
// easy autoloop parameters.
120+
AssetAutoloopParams map[string]AssetParams
121+
}
122+
123+
type AssetParams struct {
124+
// EnableEasyOut is a boolean that indicates whether we should use the
125+
// easy autoloop feature for this asset.
126+
EnableEasyOut bool
127+
128+
// EasyAutoloopTargetAmount is the target amount of liquidity that we
129+
// want to maintain in our channels.
130+
EasyAutoloopTargetAmount uint64
117131
}
118132

119133
// String returns the string representation of our parameters.
@@ -413,6 +427,14 @@ func RpcToParameters(req *clientrpc.LiquidityParameters) (*Parameters,
413427
addrType = walletrpc.AddressType_TAPROOT_PUBKEY
414428
}
415429

430+
var easyAssetMap = make(map[string]AssetParams)
431+
for asset, params := range req.EasyAssetParams {
432+
easyAssetMap[asset] = AssetParams{
433+
EnableEasyOut: params.Enabled,
434+
EasyAutoloopTargetAmount: params.LocalTargetAssetAmt,
435+
}
436+
}
437+
416438
params := &Parameters{
417439
FeeLimit: feeLimit,
418440
SweepConfTarget: req.SweepConfTarget,
@@ -437,9 +459,10 @@ func RpcToParameters(req *clientrpc.LiquidityParameters) (*Parameters,
437459
Minimum: btcutil.Amount(req.MinSwapAmount),
438460
Maximum: btcutil.Amount(req.MaxSwapAmount),
439461
},
440-
HtlcConfTarget: req.HtlcConfTarget,
441-
EasyAutoloop: req.EasyAutoloop,
442-
EasyAutoloopTarget: btcutil.Amount(req.EasyAutoloopLocalTargetSat),
462+
HtlcConfTarget: req.HtlcConfTarget,
463+
EasyAutoloop: req.EasyAutoloop,
464+
EasyAutoloopTarget: btcutil.Amount(req.EasyAutoloopLocalTargetSat),
465+
AssetAutoloopParams: easyAssetMap,
443466
}
444467

445468
if req.AutoloopBudgetRefreshPeriodSec != 0 {
@@ -528,6 +551,14 @@ func ParametersToRpc(cfg Parameters) (*clientrpc.LiquidityParameters,
528551
addrType = clientrpc.AddressType_ADDRESS_TYPE_UNKNOWN
529552
}
530553

554+
easyAssetMap := make(map[string]*clientrpc.EasyAssetParams)
555+
for asset, params := range cfg.AssetAutoloopParams {
556+
easyAssetMap[asset] = &clientrpc.EasyAssetParams{
557+
Enabled: params.EnableEasyOut,
558+
LocalTargetAssetAmt: params.EasyAutoloopTargetAmount,
559+
}
560+
}
561+
531562
rpcCfg := &clientrpc.LiquidityParameters{
532563
SweepConfTarget: cfg.SweepConfTarget,
533564
FailureBackoffSec: uint64(cfg.FailureBackOff.Seconds()),
@@ -555,6 +586,7 @@ func ParametersToRpc(cfg Parameters) (*clientrpc.LiquidityParameters,
555586
EasyAutoloopLocalTargetSat: uint64(cfg.EasyAutoloopTarget),
556587
Account: cfg.Account,
557588
AccountAddrType: addrType,
589+
EasyAssetParams: easyAssetMap,
558590
}
559591

560592
switch f := cfg.FeeLimit.(type) {

0 commit comments

Comments
 (0)