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. When easy autoloop is enabled, the response holds the loop out that easy autoloop would make next, or the reason that it would not make one. [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/regtest/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>,
// "static_loop_in": <StaticAddressLoopInRequest>,
// "disqualified": <Disqualified>,
// "easy_autoloop_reason": <AutoReason>,
// }

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
static_loop_in
StaticAddressLoopInRequest[]array
disqualified
Disqualified[]array
easy_autoloop_reason
AutoReasonstring

Nested Messages​

looprpc.AssetLoopOutRequest​

FieldgRPC TypeREST Type
asset_id
bytesstring
asset_edge_node
bytesstring
max_limit_multiplier
doublenumber
expiry
int64string

looprpc.AssetRfqInfo​

FieldgRPC TypeREST Type
prepay_rfq_id
bytesstring
max_prepay_asset_amt
uint64string
prepay_asset_rate
FixedPointobject
swap_rfq_id
bytesstring
max_swap_asset_amt
uint64string
swap_asset_rate
FixedPointobject
asset_name
stringstring

looprpc.Disqualified​

FieldgRPC TypeREST Type
channel_id
uint64string
pubkey
bytesstring
reason
AutoReasonstring

looprpc.FixedPoint​

FieldgRPC TypeREST Type
coefficient
stringstring
scale
uint32integer

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
asset_info
AssetLoopOutRequestobject
asset_rfq_info
AssetRfqInfoobject

looprpc.StaticAddressLoopInRequest​

FieldgRPC TypeREST Type
outpoints
string[]array
max_swap_fee_satoshis
int64string
last_hop
bytesstring
label
stringstring
initiator
stringstring
route_hints
RouteHint[]array
private
boolboolean
payment_timeout_seconds
uint32integer
amount
int64string
fast
boolboolean

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
AUTO_REASON_STATIC_LOOP_IN_NO_CANDIDATE
14
AUTO_REASON_CUSTOM_CHANNEL_DATA
15
AUTO_REASON_BELOW_MINIMUM
16
AUTO_REASON_NO_ELIGIBLE_CHANNEL
17
AUTO_REASON_CHANNEL_INACTIVE
18
AUTO_REASON_PEER_EXCLUDED
19