setprice
setprice base rel price (volume max cancel_previous=true base_confs base_nota rel_confs rel_nota min_volume save_in_history timeout_in_minutes)
The setprice method places an order on the orderbook, and it relies on this node acting as a maker, also called a Bob node.
The setprice order is always considered a sell, for internal implementation convenience.
You can optionally supply timeout_in_minutes to create expirable maker orders. When this field is set, Komodo DeFi Framework automatically cancels the maker order after the requested number of minutes; omit the field to keep the order active until it fills or you cancel it manually.
To prevent a user from making trades in which the transaction fees may end up costing a significant portion of the value of the trade, we have set a lower limit to the value of a trade. See the description of the volume and min_volume arguments for more info.
| Parameter* = required | Type | Description |
|---|---|---|
| base* | string | Ticker of the coin you want to sell (maker side) |
| price* | number | RationalValue | FractionalValue | Desired amount of rel per 1 unit of base (supports decimal strings, num-rational arrays, or fraction objects) |
| rel* | string | Ticker of the coin you want to receive |
| base_confs / rel_confs | number | Optional. Override the required blockchain confirmations for the base or rel side |
| base_nota / rel_nota | bool | Optional. Override whether dPoW notarization is required for the base or rel side |
| cancel_previous | bool | Optional. Defaults to true. Cancels any existing maker orders for the same pair before placing the new order |
| max | bool | Optional. If true, uses the entire available base balance (leaving 0.001 base in reserve for fees) |
| min_volume | number | RationalValue | FractionalValue | Optional. Minimum base volume that must remain for the order to stay open; must be ≤ volume and satisfy min_trading_vol limits for both coins |
| save_in_history | bool | Optional. Defaults to true. Set to false to skip persisting the short order history locally (the order status is still tracked while active) |
| timeout_in_minutes | number (integer) | Optional expiration timer for maker orders. When set, Komodo DeFi Framework automatically cancels the order after the specified number of minutes |
| volume | number | RationalValue | FractionalValue | Optional. Maximum amount of base you are willing to sell; required when max is false. Must satisfy each coin's min_trading_vol limits for both the base amount and the implied rel amount (volume * price) |
| Parameter* = required | Type | Description |
|---|---|---|
| result* | object | Order object describing the maker order that was created |
| result.base / result.rel* | string | Tickers of the order's trade pair |
| result.created_at / result.updated_at* | number (timestamp in ms) | Creation and last update timestamps for the order |
| result.matches* | object (map) | Map of currently matched swaps keyed by counterparty UUID; empty for newly created orders |
| result.max_base_vol / result.max_base_vol_rat* | string | RationalValue | Maximum base volume that can be filled from this order |
| result.price / result.price_rat* | string | RationalValue | Maker price in decimal and rational representations |
| result.started_swaps* | array of strings | UUIDs of swaps that were initiated from this order |
| result.uuid* | string | UUID of the created maker order |
| base_orderbook_ticker / rel_orderbook_ticker | string | null | Optional. Present when coins are remapped via orderbook_ticker; null otherwise |
| result.conf_settings | ConfSettings object | Optional. Effective confirmation/notarization settings applied to the order |
| result.min_base_vol / result.min_base_vol_rat | string | RationalValue | Optional. Minimum base volume the order accepts |
If your setprice order includes UTXO coins activated via electrum, and connection to its servers is lost, your order will automatically cancel and will need to be recreated once the connection is restored.
{
"base": "BASE",
"method": "setprice",
"price": "0.9",
"rel": "REL",
"userpass": "RPC_UserP@SSW0RD",
"volume": "1"
}
{
"base": "BASE",
"method": "setprice",
"price": "1.25",
"rel": "REL",
"timeout_in_minutes": 45,
"userpass": "RPC_UserP@SSW0RD",
"volume": "2"
}
{
"base": "BASE",
"max": true,
"method": "setprice",
"price": "0.9",
"rel": "REL",
"userpass": "RPC_UserP@SSW0RD"
}
{
"base": "HELLO",
"method": "setprice",
"price": [
[
1,
[
1
]
],
[
1,
[
1
]
]
],
"rel": "WORLD",
"userpass": "RPC_UserP@SSW0RD",
"volume": [
[
1,
[
1
]
],
[
1,
[
1
]
]
]
}
{
"base": "HELLO",
"method": "setprice",
"price": {
"denom": "1",
"numer": "2"
},
"rel": "WORLD",
"userpass": "RPC_UserP@SSW0RD",
"volume": {
"denom": "2",
"numer": "3"
}
}
{
"base": "HELLO",
"method": "setprice",
"min_volume": "1",
"price": {
"denom": "1",
"numer": "2"
},
"rel": "WORLD",
"userpass": "RPC_UserP@SSW0RD",
"volume": {
"denom": "2",
"numer": "3"
}
}
{
"base": "HELLO",
"base_confs": 2,
"base_nota": true,
"method": "setprice",
"price": {
"denom": "1",
"numer": "2"
},
"rel": "WORLD",
"rel_confs": 5,
"rel_nota": false,
"userpass": "RPC_UserP@SSW0RD",
"volume": {
"denom": "2",
"numer": "3"
}
}
{
"base": "KMD",
"method": "setprice",
"price": {
"denom": "12",
"numer": "7"
},
"rel": "TKL",
"save_in_history": false,
"userpass": "RPC_UserP@SSW0RD",
"volume": {
"denom": "3",
"numer": "4"
}
}
Response (Response (success))
{
"base_orderbook_ticker": null,
"rel_orderbook_ticker": null,
"result": {
"base": "BASE",
"conf_settings": {
"base_confs": 2,
"base_nota": true,
"rel_confs": 5,
"rel_nota": false
},
"created_at": 1559052299258,
"matches": {},
"max_base_vol": "1",
"max_base_vol_rat": [
[
1,
[
1
]
],
[
1,
[
1
]
]
],
"min_base_vol": "0",
"min_base_vol_rat": [
[
0,
[]
],
[
1,
[
1
]
]
],
"price": "1",
"price_rat": [
[
1,
[
1
]
],
[
1,
[
1
]
]
],
"rel": "REL",
"started_swaps": [],
"updated_at": 1559052299258,
"uuid": "6a242691-6c05-474a-85c1-5b3f42278f41"
}
}
Response (Error (rel coin missing))
{
"error": "Rel coin REL is not found"
}