SetLiquidityParams
SetLiquidityParams sets a new set of parameters for the daemon's liquidity manager. Note that the full set of parameters must be provided, because this call fully overwrites our existing parameters. [EXPERIMENTAL]: endpoint is subject to change.
Source: looprpc/client.proto
gRPC
rpc SetLiquidityParams (SetLiquidityParamsRequest) returns (SetLiquidityParamsResponse);
REST
HTTP Method | Path |
---|---|
POST | /v1/liquidity/params |
Code Samples
- gRPC
- REST
- Shell
- Javascript
- Python
const fs = require('fs');
const grpc = require('@grpc/grpc-js');
const protoLoader = require('@grpc/proto-loader');
const GRPC_HOST = 'localhost:11010'
const MACAROON_PATH = 'LOOP_DIR/regtest/loop.macaroon'
const TLS_PATH = 'LOOP_DIR/tls.cert'
const loaderOptions = {
keepCase: true,
longs: String,
enums: String,
defaults: true,
oneofs: true,
};
const packageDefinition = protoLoader.loadSync('looprpc/client.proto', loaderOptions);
const looprpc = grpc.loadPackageDefinition(packageDefinition).looprpc;
process.env.GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA';
const tlsCert = fs.readFileSync(TLS_PATH);
const sslCreds = grpc.credentials.createSsl(tlsCert);
const macaroon = fs.readFileSync(MACAROON_PATH).toString('hex');
const macaroonCreds = grpc.credentials.createFromMetadataGenerator(function(args, callback) {
let metadata = new grpc.Metadata();
metadata.add('macaroon', macaroon);
callback(null, metadata);
});
let creds = grpc.credentials.combineChannelCredentials(sslCreds, macaroonCreds);
let client = new looprpc.SwapClient(GRPC_HOST, creds);
let request = {
parameters: <LiquidityParameters>,
};
client.setLiquidityParams(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// }
import codecs, grpc, os
# Generate the following 2 modules by compiling the looprpc/client.proto with the grpcio-tools.
# See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions.
import client_pb2 as looprpc, client_pb2_grpc as clientstub
GRPC_HOST = 'localhost:11010'
MACAROON_PATH = 'LOOP_DIR/regtest/loop.macaroon'
TLS_PATH = 'LOOP_DIR/tls.cert'
# create macaroon credentials
macaroon = codecs.encode(open(MACAROON_PATH, 'rb').read(), 'hex')
def metadata_callback(context, callback):
callback([('macaroon', macaroon)], None)
auth_creds = grpc.metadata_call_credentials(metadata_callback)
# create SSL credentials
os.environ['GRPC_SSL_CIPHER_SUITES'] = 'HIGH+ECDSA'
cert = open(TLS_PATH, 'rb').read()
ssl_creds = grpc.ssl_channel_credentials(cert)
# combine macaroon and SSL credentials
combined_creds = grpc.composite_channel_credentials(ssl_creds, auth_creds)
# make the request
channel = grpc.secure_channel(GRPC_HOST, combined_creds)
stub = clientstub.SwapClientStub(channel)
request = looprpc.SetLiquidityParamsRequest(
parameters=<LiquidityParameters>,
)
response = stub.SetLiquidityParams(request)
print(response)
# {
# }
- Javascript
- Python
const fs = require('fs');
const request = require('request');
const REST_HOST = 'localhost:8081'
const MACAROON_PATH = 'LOOP_DIR/regtest/loop.macaroon'
let requestBody = {
parameters: <object>, // <LiquidityParameters>
};
let options = {
url: `https://${REST_HOST}/v1/liquidity/params`,
// Work-around for self-signed certificates.
rejectUnauthorized: false,
json: true,
headers: {
'Grpc-Metadata-macaroon': fs.readFileSync(MACAROON_PATH).toString('hex'),
},
form: JSON.stringify(requestBody),
}
request.post(options, function(error, response, body) {
console.log(body);
});
// Console output:
// {
// }
import base64, codecs, json, requests
REST_HOST = 'localhost:8081'
MACAROON_PATH = 'LOOP_DIR/regtest/loop.macaroon'
TLS_PATH = 'LOOP_DIR/tls.cert'
url = f'https://{REST_HOST}/v1/liquidity/params'
macaroon = codecs.encode(open(MACAROON_PATH, 'rb').read(), 'hex')
headers = {'Grpc-Metadata-macaroon': macaroon}
data = {
'parameters': <LiquidityParameters>,
}
r = requests.post(url, headers=headers, data=json.dumps(data), verify=TLS_PATH)
print(r.json())
# {
# }
$ loop setparams --help
NAME:
loop setparams - update the parameters set for the liquidity manager
USAGE:
loop setparams [command options] [arguments...]
DESCRIPTION:
Updates the parameters set for the liquidity manager. Note the parameters are persisted in db to save the trouble of setting them again upon loopd restart. To get the defaultvalues, use `getparams` before any `setparams`.
OPTIONS:
--sweeplimit value the limit placed on our estimated sweep fee in sat/vByte. (default: 0)
--feepercent value the maximum percentage of swap amount to be used across all fee categories (default: 0)
--maxswapfee value the maximum percentage of swap volume we are willing to pay in server fees. (default: 0)
--maxroutingfee value the maximum percentage of off-chain payment volume that we are willing to pay in routingfees. (default: 0)
--maxprepayfee value the maximum percentage of off-chain prepay volume that we are willing to pay in routing fees. (default: 0)
--maxprepay value the maximum no-show (prepay) in satoshis that swap suggestions should be limited to. (default: 0)
--maxminer value the maximum miner fee in satoshis that swap suggestions should be limited to. (default: 0)
--sweepconf value the number of blocks from htlc height that swap suggestion sweeps should target, used to estimate max miner fee. (default: 0)
--failurebackoff value the amount of time, in seconds, that should pass before a channel that previously had a failed swap will be included in suggestions. (default: 0)
--autoloop set to true to enable automated dispatch of swaps, limited to the budget set by autobudget.
--destaddr value custom address to be used as destination for autoloop loop out, set to "default" in order to revert to default behavior.
--account value the name of the account to generate a new address from. You can list the names of valid accounts in your backing lnd instance with "lncli wallet accounts list".
--account_addr_type value the address type of the extended public key specified in account. Currently only pay-to-taproot-pubkey(p2tr) is supported (default: "p2tr")
--autobudget value the maximum amount of fees in satoshis that automatically dispatched loop out swaps may spend. (default: 0)
--autobudgetrefreshperiod value the time period over which the automated loop budget is refreshed. (default: 0s)
--autoinflight value the maximum number of automatically dispatched swaps that we allow to be in flight. (default: 0)
--minamt value the minimum amount in satoshis that the autoloop client will dispatch per-swap. (default: 0)
--maxamt value the maximum amount in satoshis that the autoloop client will dispatch per-swap. (default: 0)
--htlc_conf value the confirmation target for loop in on-chain htlcs. (default: 0)
--easyautoloop set to true to enable easy autoloop, which will automatically dispatch swaps in order to meet the target local balance.
--localbalancesat value the target size of total local balance in satoshis, used by easy autoloop. (default: 0)
Messages
looprpc.SetLiquidityParamsRequest
Source: looprpc/client.proto
Field | gRPC Type | REST Type | REST Placement |
---|---|---|---|
parameters | LiquidityParameters | object | body |
looprpc.SetLiquidityParamsResponse
Source: looprpc/client.proto
note
This response has no parameters.
Nested Messages
looprpc.LiquidityParameters
Field | gRPC Type | REST Type |
---|---|---|
rules | LiquidityRule[] | array |
fee_ppm | uint64 | string |
sweep_fee_rate_sat_per_vbyte | uint64 | string |
max_swap_fee_ppm | uint64 | string |
max_routing_fee_ppm | uint64 | string |
max_prepay_routing_fee_ppm | uint64 | string |
max_prepay_sat | uint64 | string |
max_miner_fee_sat | uint64 | string |
sweep_conf_target | int32 | integer |
failure_backoff_sec | uint64 | string |
autoloop | bool | boolean |
autoloop_budget_sat | uint64 | string |
autoloop_budget_start_sec deprecated | uint64 | string |
auto_max_in_flight | uint64 | string |
min_swap_amount | uint64 | string |
max_swap_amount | uint64 | string |
htlc_conf_target | int32 | integer |
autoloop_dest_address | string | string |
autoloop_budget_refresh_period_sec | uint64 | string |
autoloop_budget_last_refresh | uint64 | string |
easy_autoloop | bool | boolean |
easy_autoloop_local_target_sat | uint64 | string |
account | string | string |
account_addr_type | AddressType | string |
looprpc.LiquidityRule
Field | gRPC Type | REST Type |
---|---|---|
channel_id | uint64 | string |
swap_type | SwapType | string |
pubkey | bytes | string |
type | LiquidityRuleType | string |
incoming_threshold | uint32 | integer |
outgoing_threshold | uint32 | integer |
Enums
looprpc.AddressType
Name | Number |
---|---|
ADDRESS_TYPE_UNKNOWN | 0 |
TAPROOT_PUBKEY | 1 |
looprpc.LiquidityRuleType
Name | Number |
---|---|
UNKNOWN | 0 |
THRESHOLD | 1 |
looprpc.SwapType
Name | Number |
---|---|
LOOP_OUT | 0 |
LOOP_IN | 1 |