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) {
|
||||
|
|
|
|||
1877
looprpc/client.pb.go
1877
looprpc/client.pb.go
File diff suppressed because it is too large
Load diff
|
|
@ -1207,6 +1207,29 @@ message LiquidityParameters {
|
|||
The address type of the account specified in the account field.
|
||||
*/
|
||||
AddressType account_addr_type = 24;
|
||||
|
||||
/*
|
||||
A map of asset parameters to use for swaps. The key is the asset id and the
|
||||
value is the parameters to use for swaps in that asset.
|
||||
*/
|
||||
map<string, EasyAssetAutoloopParams> easy_asset_params = 25;
|
||||
}
|
||||
|
||||
message EasyAssetAutoloopParams {
|
||||
/*
|
||||
Set to true to enable easy autoloop for this asset. If set the client will
|
||||
automatically dispatch swaps in order to meet the configured local balance
|
||||
target size. Currently only loop out is supported, meaning that easy
|
||||
autoloop can only reduce the funds that are held as balance in channels.
|
||||
*/
|
||||
bool enabled = 1;
|
||||
|
||||
/*
|
||||
The local balance target size, expressed in the asset's base units. This is
|
||||
used by easy autoloop to determine how much liquidity should be maintained
|
||||
in channels.
|
||||
*/
|
||||
uint64 local_target_asset_amt = 2;
|
||||
}
|
||||
|
||||
enum LiquidityRuleType {
|
||||
|
|
|
|||
|
|
@ -884,6 +884,20 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"looprpcEasyAssetAutoloopParams": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"type": "boolean",
|
||||
"description": "Set to true to enable easy autoloop for this asset. If set the client will\nautomatically dispatch swaps in order to meet the configured local balance\ntarget size. Currently only loop out is supported, meaning that easy\nautoloop can only reduce the funds that are held as balance in channels."
|
||||
},
|
||||
"local_target_asset_amt": {
|
||||
"type": "string",
|
||||
"format": "uint64",
|
||||
"description": "The local balance target size, expressed in the asset's base units. This is\nused by easy autoloop to determine how much liquidity should be maintained\nin channels."
|
||||
}
|
||||
}
|
||||
},
|
||||
"looprpcFailureReason": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
|
|
@ -1255,6 +1269,13 @@
|
|||
"account_addr_type": {
|
||||
"$ref": "#/definitions/looprpcAddressType",
|
||||
"description": "The address type of the account specified in the account field."
|
||||
},
|
||||
"easy_asset_params": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"$ref": "#/definitions/looprpcEasyAssetAutoloopParams"
|
||||
},
|
||||
"description": "A map of asset parameters to use for swaps. The key is the asset id and the\nvalue is the parameters to use for swaps in that asset."
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue