Komodo DeFi Framework Method: Trade Preimage
API-v1trade_preimage
The trade_preimage method returns the approximate fee amounts that are paid per the whole swap. Depending on the parameters, the function returns different results:
- If the
swap_methodisbuyorsell, then the result will include thetaker_feeand thefee_to_send_taker_fee. Thetaker_feeamount is paid from thebasecoin balance if theswap_methodissell, else it is paid from therelcoin balance. - If the
maxfield is true, then the result will include thevolume.
This method can be used instead of max_taker_vol if the max field is true and the swap_method is buy or sell. Use the resulting volume as an argument of the buy or sell requests.
Use the trade_preimage request with max = true and swap_method = \"setprice\" arguments to approximate the fee amounts only. Do not use the resulting volume as an argument of the setprice method.
This function is deprecated. Please consider using trade_preimage v2.0 instead.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| base | string | ✓ | - | The base currency of the request |
| max | bool | ✗ | false | Whether to return the maximum available volume for setprice method; must not be set or false if swap_method is buy or sell |
| price | numeric string or rational | ✓ | - | The price in rel the user is willing to pay per one unit of the base coin |
| rel | string | ✓ | - | The rel currency of the request |
| swap_method | string | ✓ | - | A standard SwapMethodEnum enum. The name of the method whose preimage is requested. |
| volume | numeric string or rational | ✗ | - | The amount the user is willing to trade; ignored if max = true and swap_method is setprice, otherwise, it must be set |
| Parameter | Type | Description |
|---|---|---|
| base_coin_fee | object | A standard ExtendedFeeInfo object. The approximate miner fee is paid per the whole swap concerning the base coin |
| fee_to_send_taker_fee | object | A standard ExtendedFeeInfo object. The approximate miner fee is paid to send the dex fee; empty if swap_method is setprice |
| rel_coin_fee | object | A standard ExtendedFeeInfo object. The approximate miner fee is paid per the whole swap concerning the rel coin |
| result | object | An object containing the relevant information |
| taker_fee | object | A standard ExtendedFeeInfo object. The dex fee to be paid by Taker; empty if swap_method is setprice |
| total_fees | array of objects | A standard TotalFeeInfo object. Each element is a sum of fees required to be paid from user's balance of corresponding ExtendedFeeInfo.coin; the elements are unique by coin |
| volume | string (numeric) | Optional. The max available volume that can be traded (in decimal representation); empty if the max argument is missing or false |
| volume_fraction | fraction | Optional. The max available volume that can be traded represented as a standard fractionalValue object; empty if the max argument is missing or false |
| volume_rat | rational | Optional. The max available volume that can be traded represented as a standard RationalValue object; empty if the max argument is missing or false |
trade_preimage
POST
trade_preimage{
"userpass": "RPC_UserP@SSW0RD",
"method": "trade_preimage",
"base": "DOC",
"rel": "BTC",
"price": "1",
"volume": "0.1",
"swap_method": "setprice"
}
POST
trade_preimage{
"userpass": "RPC_UserP@SSW0RD",
"method": "trade_preimage",
"base": "BTC",
"rel": "DOC",
"price": "1",
"volume": "0.1",
"swap_method": "buy"
}
POST
trade_preimage{
"userpass": "RPC_UserP@SSW0RD",
"method": "trade_preimage",
"base": "BAT",
"rel": "QC",
"price": "1",
"volume": "2.21363478",
"swap_method": "setprice"
}