Skip to main content

AddAssetSellOrder

AddAssetSellOrder is used to add a sell order for a specific asset. If a sell order already exists for the asset, it will be updated.

Source: rfqrpc/rfq.proto

gRPC

rpc AddAssetSellOrder (AddAssetSellOrderRequest) returns (AddAssetSellOrderResponse);

REST

HTTP MethodPath
POST /v1/taproot-assets/rfq/sellorder/asset-id/{asset_specifier.asset_id_str}

Code Samples

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

const GRPC_HOST = 'localhost:10029'
const MACAROON_PATH = 'TAPROOT-ASSETS_DIR/regtest/taproot-assets.macaroon'
const TLS_PATH = 'TAPROOT-ASSETS_DIR/tls.cert'

const loaderOptions = {
keepCase: true,
longs: String,
enums: String,
defaults: true,
oneofs: true,
};
const packageDefinition = protoLoader.loadSync('rfqrpc/rfq.proto', loaderOptions);
const rfqrpc = grpc.loadPackageDefinition(packageDefinition).rfqrpc;
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 rfqrpc.Rfq(GRPC_HOST, creds);
let request = {
asset_specifier: <AssetSpecifier>,
payment_max_amt: <uint64>,
expiry: <uint64>,
peer_pub_key: <bytes>,
timeout_seconds: <uint32>,
skip_asset_channel_check: <bool>,
};
client.addAssetSellOrder(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "accepted_quote": <PeerAcceptedSellQuote>,
// "invalid_quote": <InvalidQuoteResponse>,
// "rejected_quote": <RejectedQuoteResponse>,
// }

Messages

rfqrpc.AddAssetSellOrderRequest

Source: rfqrpc/rfq.proto

FieldgRPC TypeREST TypeREST Placement
asset_specifier
AssetSpecifierobjectmixed
payment_max_amt
uint64stringbody
expiry
uint64stringbody
peer_pub_key
bytesstringbody
timeout_seconds
uint32integerbody
skip_asset_channel_check
boolbooleanbody

rfqrpc.AddAssetSellOrderResponse

Source: rfqrpc/rfq.proto

FieldgRPC TypeREST Type
accepted_quote
PeerAcceptedSellQuoteobject
invalid_quote
InvalidQuoteResponseobject
rejected_quote
RejectedQuoteResponseobject

Nested Messages

rfqrpc.AssetSpecifier

FieldgRPC TypeREST Type
asset_id
bytesstring
asset_id_str
stringstring
group_key
bytesstring
group_key_str
stringstring

rfqrpc.FixedPoint

FieldgRPC TypeREST Type
coefficient
stringstring
scale
uint32integer

rfqrpc.InvalidQuoteResponse

FieldgRPC TypeREST Type
status
QuoteRespStatusstring
peer
stringstring
id
bytesstring

rfqrpc.PeerAcceptedSellQuote

FieldgRPC TypeREST Type
peer
stringstring
id
bytesstring
scid
uint64string
asset_amount
uint64string
bid_asset_rate
FixedPointobject
expiry
uint64string

rfqrpc.RejectedQuoteResponse

FieldgRPC TypeREST Type
peer
stringstring
id
bytesstring
error_message
stringstring
error_code
uint32integer

Enums

rfqrpc.QuoteRespStatus

NameNumber
INVALID_ASSET_RATES
0
INVALID_EXPIRY
1
PRICE_ORACLE_QUERY_ERR
2