mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
liquidity: add easy asset params
This commit is contained in:
parent
4ef15d6668
commit
832a0526d6
4 changed files with 1076 additions and 888 deletions
|
|
@ -114,6 +114,21 @@ type Parameters struct {
|
|||
// EasyAutoloopTarget is the target amount of liquidity that we want to
|
||||
// maintain in our channels.
|
||||
EasyAutoloopTarget btcutil.Amount
|
||||
|
||||
// AssetAutoloopParams maps an asset id hex encoded string to its
|
||||
// easy autoloop parameters.
|
||||
AssetAutoloopParams map[string]AssetParams
|
||||
}
|
||||
|
||||
// AssetParams define the asset specific autoloop parameters.
|
||||
type AssetParams struct {
|
||||
// EnableEasyOut is a boolean that indicates whether we should use the
|
||||
// easy autoloop feature for this asset.
|
||||
EnableEasyOut bool
|
||||
|
||||
// LocalTargetAssetAmount is the target amount of liquidity that we
|
||||
// want to maintain in our channels.
|
||||
LocalTargetAssetAmount uint64
|
||||
}
|
||||
|
||||
// String returns the string representation of our parameters.
|
||||
|
|
@ -413,6 +428,14 @@ func RpcToParameters(req *clientrpc.LiquidityParameters) (*Parameters,
|
|||
addrType = walletrpc.AddressType_TAPROOT_PUBKEY
|
||||
}
|
||||
|
||||
easyAssetParams := make(map[string]AssetParams)
|
||||
for asset, params := range req.EasyAssetParams {
|
||||
easyAssetParams[asset] = AssetParams{
|
||||
EnableEasyOut: params.Enabled,
|
||||
LocalTargetAssetAmount: params.LocalTargetAssetAmt,
|
||||
}
|
||||
}
|
||||
|
||||
params := &Parameters{
|
||||
FeeLimit: feeLimit,
|
||||
SweepConfTarget: req.SweepConfTarget,
|
||||
|
|
@ -437,9 +460,10 @@ func RpcToParameters(req *clientrpc.LiquidityParameters) (*Parameters,
|
|||
Minimum: btcutil.Amount(req.MinSwapAmount),
|
||||
Maximum: btcutil.Amount(req.MaxSwapAmount),
|
||||
},
|
||||
HtlcConfTarget: req.HtlcConfTarget,
|
||||
EasyAutoloop: req.EasyAutoloop,
|
||||
EasyAutoloopTarget: btcutil.Amount(req.EasyAutoloopLocalTargetSat),
|
||||
HtlcConfTarget: req.HtlcConfTarget,
|
||||
EasyAutoloop: req.EasyAutoloop,
|
||||
EasyAutoloopTarget: btcutil.Amount(req.EasyAutoloopLocalTargetSat),
|
||||
AssetAutoloopParams: easyAssetParams,
|
||||
}
|
||||
|
||||
if req.AutoloopBudgetRefreshPeriodSec != 0 {
|
||||
|
|
@ -528,6 +552,18 @@ func ParametersToRpc(cfg Parameters) (*clientrpc.LiquidityParameters,
|
|||
addrType = clientrpc.AddressType_ADDRESS_TYPE_UNKNOWN
|
||||
}
|
||||
|
||||
easyAssetMap := make(
|
||||
map[string]*clientrpc.EasyAssetAutoloopParams,
|
||||
len(cfg.AssetAutoloopParams),
|
||||
)
|
||||
|
||||
for asset, params := range cfg.AssetAutoloopParams {
|
||||
easyAssetMap[asset] = &clientrpc.EasyAssetAutoloopParams{
|
||||
Enabled: params.EnableEasyOut,
|
||||
LocalTargetAssetAmt: params.LocalTargetAssetAmount,
|
||||
}
|
||||
}
|
||||
|
||||
rpcCfg := &clientrpc.LiquidityParameters{
|
||||
SweepConfTarget: cfg.SweepConfTarget,
|
||||
FailureBackoffSec: uint64(cfg.FailureBackOff.Seconds()),
|
||||
|
|
@ -555,6 +591,7 @@ func ParametersToRpc(cfg Parameters) (*clientrpc.LiquidityParameters,
|
|||
EasyAutoloopLocalTargetSat: uint64(cfg.EasyAutoloopTarget),
|
||||
Account: cfg.Account,
|
||||
AccountAddrType: addrType,
|
||||
EasyAssetParams: easyAssetMap,
|
||||
}
|
||||
|
||||
switch f := cfg.FeeLimit.(type) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue