Skip to content

Commit 832a052

Browse files
committed
liquidity: add easy asset params
1 parent 4ef15d6 commit 832a052

File tree

4 files changed

+1076
-888
lines changed

4 files changed

+1076
-888
lines changed

liquidity/parameters.go

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,21 @@ 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+
// AssetParams define the asset specific autoloop parameters.
124+
type AssetParams struct {
125+
// EnableEasyOut is a boolean that indicates whether we should use the
126+
// easy autoloop feature for this asset.
127+
EnableEasyOut bool
128+
129+
// LocalTargetAssetAmount is the target amount of liquidity that we
130+
// want to maintain in our channels.
131+
LocalTargetAssetAmount uint64
117132
}
118133

119134
// String returns the string representation of our parameters.
@@ -413,6 +428,14 @@ func RpcToParameters(req *clientrpc.LiquidityParameters) (*Parameters,
413428
addrType = walletrpc.AddressType_TAPROOT_PUBKEY
414429
}
415430

431+
easyAssetParams := make(map[string]AssetParams)
432+
for asset, params := range req.EasyAssetParams {
433+
easyAssetParams[asset] = AssetParams{
434+
EnableEasyOut: params.Enabled,
435+
LocalTargetAssetAmount: params.LocalTargetAssetAmt,
436+
}
437+
}
438+
416439
params := &Parameters{
417440
FeeLimit: feeLimit,
418441
SweepConfTarget: req.SweepConfTarget,
@@ -437,9 +460,10 @@ func RpcToParameters(req *clientrpc.LiquidityParameters) (*Parameters,
437460
Minimum: btcutil.Amount(req.MinSwapAmount),
438461
Maximum: btcutil.Amount(req.MaxSwapAmount),
439462
},
440-
HtlcConfTarget: req.HtlcConfTarget,
441-
EasyAutoloop: req.EasyAutoloop,
442-
EasyAutoloopTarget: btcutil.Amount(req.EasyAutoloopLocalTargetSat),
463+
HtlcConfTarget: req.HtlcConfTarget,
464+
EasyAutoloop: req.EasyAutoloop,
465+
EasyAutoloopTarget: btcutil.Amount(req.EasyAutoloopLocalTargetSat),
466+
AssetAutoloopParams: easyAssetParams,
443467
}
444468

445469
if req.AutoloopBudgetRefreshPeriodSec != 0 {
@@ -528,6 +552,18 @@ func ParametersToRpc(cfg Parameters) (*clientrpc.LiquidityParameters,
528552
addrType = clientrpc.AddressType_ADDRESS_TYPE_UNKNOWN
529553
}
530554

555+
easyAssetMap := make(
556+
map[string]*clientrpc.EasyAssetAutoloopParams,
557+
len(cfg.AssetAutoloopParams),
558+
)
559+
560+
for asset, params := range cfg.AssetAutoloopParams {
561+
easyAssetMap[asset] = &clientrpc.EasyAssetAutoloopParams{
562+
Enabled: params.EnableEasyOut,
563+
LocalTargetAssetAmt: params.LocalTargetAssetAmount,
564+
}
565+
}
566+
531567
rpcCfg := &clientrpc.LiquidityParameters{
532568
SweepConfTarget: cfg.SweepConfTarget,
533569
FailureBackoffSec: uint64(cfg.FailureBackOff.Seconds()),
@@ -555,6 +591,7 @@ func ParametersToRpc(cfg Parameters) (*clientrpc.LiquidityParameters,
555591
EasyAutoloopLocalTargetSat: uint64(cfg.EasyAutoloopTarget),
556592
Account: cfg.Account,
557593
AccountAddrType: addrType,
594+
EasyAssetParams: easyAssetMap,
558595
}
559596

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

0 commit comments

Comments
 (0)