Skip to main content

QuoteOrder

QuoteOrder calculates the premium, execution fees and max batch fee rate for an order based on the given order parameters.

Source: poolrpc/trader.proto

gRPC

rpc QuoteOrder (QuoteOrderRequest) returns (QuoteOrderResponse);

REST

HTTP MethodPath
POST /v1/pool/orders/quote

Code Samples

const fs = require('fs');
const grpc = require('@grpc/grpc-js');
const protoLoader = require('@grpc/proto-loader');

const GRPC_HOST = 'localhost:12010'
const MACAROON_PATH = 'POOL_DIR/regtest/pool.macaroon'
const TLS_PATH = 'POOL_DIR/tls.cert'

const loaderOptions = {
keepCase: true,
longs: String,
enums: String,
defaults: true,
oneofs: true,
};
const packageDefinition = protoLoader.loadSync('poolrpc/trader.proto', loaderOptions);
const poolrpc = grpc.loadPackageDefinition(packageDefinition).poolrpc;
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 poolrpc.Trader(GRPC_HOST, creds);
let request = {
amt: <uint64>,
rate_fixed: <uint32>,
lease_duration_blocks: <uint32>,
max_batch_fee_rate_sat_per_kw: <uint64>,
min_units_match: <uint32>,
};
client.quoteOrder(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "total_premium_sat": <uint64>,
// "rate_per_block": <double>,
// "rate_percent": <double>,
// "total_execution_fee_sat": <uint64>,
// "worst_case_chain_fee_sat": <uint64>,
// }

Messages

poolrpc.QuoteOrderRequest

Source: poolrpc/trader.proto

FieldgRPC TypeREST TypeREST Placement
amt
uint64stringbody
rate_fixed
uint32integerbody
lease_duration_blocks
uint32integerbody
max_batch_fee_rate_sat_per_kw
uint64stringbody
min_units_match
uint32integerbody

poolrpc.QuoteOrderResponse

Source: poolrpc/trader.proto

FieldgRPC TypeREST Type
total_premium_sat
uint64string
rate_per_block
doublenumber
rate_percent
doublenumber
total_execution_fee_sat
uint64string
worst_case_chain_fee_sat
uint64string