Skip to main content

SuggestSwaps

SuggestSwaps returns a list of recommended swaps based on the current state of your node's channels and it's liquidity manager parameters. Note that only loop out suggestions are currently supported. [EXPERIMENTAL]: endpoint is subject to change.

Source: looprpc/client.proto

gRPC

rpc SuggestSwaps (SuggestSwapsRequest) returns (SuggestSwapsResponse);

REST

HTTP MethodPath
GET /v1/auto/suggest

Code Samples

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.suggestSwaps(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "loop_out": <LoopOutRequest>,
// "loop_in": <LoopInRequest>,
// "disqualified": <Disqualified>,
// }

Messages

looprpc.SuggestSwapsRequest

Source: looprpc/client.proto

note

This request has no parameters.

looprpc.SuggestSwapsResponse

Source: looprpc/client.proto

FieldgRPC TypeREST Type
loop_out
LoopOutRequest[]array
loop_in
LoopInRequest[]array
disqualified
Disqualified[]array

Nested Messages

looprpc.Disqualified

FieldgRPC TypeREST Type
channel_id
uint64string
pubkey
bytesstring
reason
AutoReasonstring

looprpc.LoopInRequest

FieldgRPC TypeREST Type
amt
int64string
max_swap_fee
int64string
max_miner_fee
int64string
last_hop
bytesstring
external_htlc
boolboolean
htlc_conf_target
int32integer
label
stringstring
initiator
stringstring
route_hints
RouteHint[]array
private
boolboolean

looprpc.LoopOutRequest

FieldgRPC TypeREST Type
amt
int64string
dest
stringstring
max_swap_routing_fee
int64string
max_prepay_routing_fee
int64string
max_swap_fee
int64string
max_prepay_amt
int64string
max_miner_fee
int64string
loop_out_channeldeprecated
uint64string
outgoing_chan_set
uint64[]array
sweep_conf_target
int32integer
htlc_confirmations
int32integer
swap_publication_deadline
uint64string
label
stringstring
initiator
stringstring
account
stringstring
account_addr_type
AddressTypestring
is_external_addr
boolboolean
reservation_ids
bytes[]array
payment_timeout
uint32integer

Enums

looprpc.AddressType

NameNumber
ADDRESS_TYPE_UNKNOWN
0
TAPROOT_PUBKEY
1

looprpc.AutoReason

NameNumber
AUTO_REASON_UNKNOWN
0
AUTO_REASON_BUDGET_NOT_STARTED
1
AUTO_REASON_SWEEP_FEES
2
AUTO_REASON_BUDGET_ELAPSED
3
AUTO_REASON_IN_FLIGHT
4
AUTO_REASON_SWAP_FEE
5
AUTO_REASON_MINER_FEE
6
AUTO_REASON_PREPAY
7
AUTO_REASON_FAILURE_BACKOFF
8
AUTO_REASON_LOOP_OUT
9
AUTO_REASON_LOOP_IN
10
AUTO_REASON_LIQUIDITY_OK
11
AUTO_REASON_BUDGET_INSUFFICIENT
12
AUTO_REASON_FEE_INSUFFICIENT
13