GetLiquidityParams
GetLiquidityParams gets the parameters that the daemon's liquidity manager is currently configured with. This may be nil if nothing is configured. [EXPERIMENTAL]: endpoint is subject to change.
Source: looprpc/client.proto
gRPC
rpc GetLiquidityParams (GetLiquidityParamsRequest) returns (LiquidityParameters);
REST
HTTP Method | Path |
---|---|
GET | /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 = {};
client.getLiquidityParams(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "rules": <LiquidityRule>,
// "fee_ppm": <uint64>,
// "sweep_fee_rate_sat_per_vbyte": <uint64>,
// "max_swap_fee_ppm": <uint64>,
// "max_routing_fee_ppm": <uint64>,
// "max_prepay_routing_fee_ppm": <uint64>,
// "max_prepay_sat": <uint64>,
// "max_miner_fee_sat": <uint64>,
// "sweep_conf_target": <int32>,
// "failure_backoff_sec": <uint64>,
// "autoloop": <bool>,
// "autoloop_budget_sat": <uint64>,
// "autoloop_budget_start_sec": <uint64>,
// "auto_max_in_flight": <uint64>,
// "min_swap_amount": <uint64>,
// "max_swap_amount": <uint64>,
// "htlc_conf_target": <int32>,
// "autoloop_dest_address": <string>,
// "autoloop_budget_refresh_period_sec": <uint64>,
// "autoloop_budget_last_refresh": <uint64>,
// "easy_autoloop": <bool>,
// "easy_autoloop_local_target_sat": <uint64>,
// "account": <string>,
// "account_addr_type": <AddressType>,
// }
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.GetLiquidityParamsRequest()
response = stub.GetLiquidityParams(request)
print(response)
# {
# "rules": <LiquidityRule>,
# "fee_ppm": <uint64>,
# "sweep_fee_rate_sat_per_vbyte": <uint64>,
# "max_swap_fee_ppm": <uint64>,
# "max_routing_fee_ppm": <uint64>,
# "max_prepay_routing_fee_ppm": <uint64>,
# "max_prepay_sat": <uint64>,
# "max_miner_fee_sat": <uint64>,
# "sweep_conf_target": <int32>,
# "failure_backoff_sec": <uint64>,
# "autoloop": <bool>,
# "autoloop_budget_sat": <uint64>,
# "autoloop_budget_start_sec": <uint64>,
# "auto_max_in_flight": <uint64>,
# "min_swap_amount": <uint64>,
# "max_swap_amount": <uint64>,
# "htlc_conf_target": <int32>,
# "autoloop_dest_address": <string>,
# "autoloop_budget_refresh_period_sec": <uint64>,
# "autoloop_budget_last_refresh": <uint64>,
# "easy_autoloop": <bool>,
# "easy_autoloop_local_target_sat": <uint64>,
# "account": <string>,
# "account_addr_type": <AddressType>,
# }
- Javascript
- Python
const fs = require('fs');
const request = require('request');
const REST_HOST = 'localhost:8081'
const MACAROON_PATH = 'LOOP_DIR/regtest/loop.macaroon'
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'),
},
}
request.get(options, function(error, response, body) {
console.log(body);
});
// Console output:
// {
// "rules": <array>, // <LiquidityRule>
// "fee_ppm": <string>, // <uint64>
// "sweep_fee_rate_sat_per_vbyte": <string>, // <uint64>
// "max_swap_fee_ppm": <string>, // <uint64>
// "max_routing_fee_ppm": <string>, // <uint64>
// "max_prepay_routing_fee_ppm": <string>, // <uint64>
// "max_prepay_sat": <string>, // <uint64>
// "max_miner_fee_sat": <string>, // <uint64>
// "sweep_conf_target": <integer>, // <int32>
// "failure_backoff_sec": <string>, // <uint64>
// "autoloop": <boolean>, // <bool>
// "autoloop_budget_sat": <string>, // <uint64>
// "autoloop_budget_start_sec": <string>, // <uint64>
// "auto_max_in_flight": <string>, // <uint64>
// "min_swap_amount": <string>, // <uint64>
// "max_swap_amount": <string>, // <uint64>
// "htlc_conf_target": <integer>, // <int32>
// "autoloop_dest_address": <string>, // <string>
// "autoloop_budget_refresh_period_sec": <string>, // <uint64>
// "autoloop_budget_last_refresh": <string>, // <uint64>
// "easy_autoloop": <boolean>, // <bool>
// "easy_autoloop_local_target_sat": <string>, // <uint64>
// "account": <string>, // <string>
// "account_addr_type": <string>, // <AddressType>
// }
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}
r = requests.get(url, headers=headers, verify=TLS_PATH)
print(r.json())
# {
# "rules": <LiquidityRule>,
# "fee_ppm": <uint64>,
# "sweep_fee_rate_sat_per_vbyte": <uint64>,
# "max_swap_fee_ppm": <uint64>,
# "max_routing_fee_ppm": <uint64>,
# "max_prepay_routing_fee_ppm": <uint64>,
# "max_prepay_sat": <uint64>,
# "max_miner_fee_sat": <uint64>,
# "sweep_conf_target": <int32>,
# "failure_backoff_sec": <uint64>,
# "autoloop": <bool>,
# "autoloop_budget_sat": <uint64>,
# "autoloop_budget_start_sec": <uint64>,
# "auto_max_in_flight": <uint64>,
# "min_swap_amount": <uint64>,
# "max_swap_amount": <uint64>,
# "htlc_conf_target": <int32>,
# "autoloop_dest_address": <string>,
# "autoloop_budget_refresh_period_sec": <uint64>,
# "autoloop_budget_last_refresh": <uint64>,
# "easy_autoloop": <bool>,
# "easy_autoloop_local_target_sat": <uint64>,
# "account": <string>,
# "account_addr_type": <AddressType>,
# }
$ loop getparams --help
NAME:
loop getparams - show liquidity manager parameters
USAGE:
loop getparams [arguments...]
DESCRIPTION:
Displays the current set of parameters that are set for the liquidity manager.
Messages
looprpc.GetLiquidityParamsRequest
Source: looprpc/client.proto
note
This request has no parameters.
looprpc.LiquidityParameters
Source: looprpc/client.proto
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 |
Nested Messages
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 |