export const title = "Komodo DeFi Framework Method: Buy"; export const description = "The buy method issues a buy request and attempts to match an order from the orderbook based on the provided arguments.";
buy base rel price volume (match_by order_type base_confs base_nota rel_confs rel_nota min_volume)
The buy
method issues a buy request and attempts to match an order from the orderbook based on the provided arguments.
Structure | Type | Description |
---|---|---|
base | string | The name of the coin the user desires to receive |
rel | string | The name of the coin the user desires to sell |
price | various | The amount in rel the user wants per one unit of the base coin. Can be a numeric string, expressed using standard RationalValue or FractionalValue objects. |
volume | various | The amount of coins the user is willing to receive of the base coin; the following values must be greater than or equal to the min_trading_vol of the corresponding coin:
|
min_volume | various (optional) | The amount of base coin that will be used as min_volume of GoodTillCancelled order after conversion to maker; the following values must be greater than or equal to the min_trading_vol of the corresponding coin:
|
match_by | object | Optional. A standard MatchBy object, to filter to include only matches by pubkey or uuid. Important: This condition is not applied after a GoodTillCancelled order is converted to a maker request. |
order_type | object | Optional. A standard OrderType object. |
base_confs | number | Number of required blockchain confirmations for base coin atomic swap transaction; default to base coin configuration if not set |
base_nota | boolean | Whether dPoW notarization is required for base coin atomic swap transaction; default to base coin configuration if not set |
rel_confs | number | Number of required blockchain confirmations for rel coin atomic swap transaction; default to rel coin configuration if not set |
rel_nota | boolean | Whether dPoW notarization is required for rel coin atomic swap transaction; default to rel coin configuration if not set |
save_in_history | boolean | Defaults to true . If set to false no order history will be saved (though order status will be temporarily stored while in progress). If true , each order's short record history is stored in a local SQLite database table, and when the order is cancelled or fully matched, it's history will be saved as a json file |
Structure | Type | Description |
---|---|---|
action | string | The action of the request (Buy ) |
base | string | The base currency of request |
base_amount | string | The resulting amount of base currency that is received if the order matches (in decimal representation) |
base_amount_rat | rational | The resulting amount of base currency that is received if the order matches, represented as a standard RationalValue object. |
rel | string | The rel currency of the request |
rel_amount | string | The maximum amount of rel coin that is spent in order to buy the base_amount (according to price , in decimal representation) |
rel_amount_rat | rational | The maximum amount of rel coin that is spent in order to buy the base_amount (according to price , represented as a standard RationalValue object). |
method | string | This field is used for internal P2P interactions; the value is always equal to "request |
dest_pub_key | string | Reserved for future use. dest_pub_key allows the user to choose the P2P node that is eligible to match with the request. This value defaults to a "zero pubkey", which means anyone can be a match |
sender_pubkey | string | The public key of this node |
uuid | string | The request uuid |
match_by | object | A standard MatchBy object, to filter to include only matches by pubkey or uuid. |
conf_settings | object | A standard ConfSettings object. |
base_orderbook_ticker | string | The ticker of the base currency if orderbook_ticker is configured for the base currency in coins file. If not defined, will return a null value. |
rel_orderbook_ticker | string | The ticker of the rel currency if orderbook_ticker is configured for the rel currency in coins file. If not defined, will return a null value. |
{
"result": {
"action": "Buy",
"base": "HELLO",
"base_amount": "1",
"base_amount_rat": [
[1, [1]],
[1, [1]]
],
"dest_pub_key": "0000000000000000000000000000000000000000000000000000000000000000",
"method": "request",
"rel": "WORLD",
"rel_amount": "1",
"rel_amount_rat": [
[1, [1]],
[1, [1]]
],
"sender_pubkey": "c213230771ebff769c58ade63e8debac1b75062ead66796c8d793594005f3920",
"uuid": "288743e2-92a5-471e-92d5-bb828a2303c3",
"match_by": {
"data": [
"1ab7edc96abaefb358b52c583048eaaeb8ea42609d096d6cddfafa02fa510c6a"
],
"type": "Pubkeys"
},
"conf_settings": {
"base_confs": 2,
"base_nota": true,
"rel_confs": 5,
"rel_nota": false
},
"base_orderbook_ticker": null,
"rel_orderbook_ticker": null
}
}
{
"error": "rpc:278] utxo:884] REL balance 12.88892991 is too low, required 21.15"
}
{
"error": "rpc:275] lp_ordermatch:665] The WORLD amount 40000/3 is larger than available 47.60450107, balance: 47.60450107, locked by swaps: 0.00000000"
}