Komodo DeFi Framework Method: common_structures
The objects are in the request or response of multiple Komodo DeFi SDK methods have been grouped into the following sections:
Structures which are used in more than one section are listed below:
The NumericFormatsValue returns a price or amount in three different formats: fraction, rational, and decimal.
| Parameter | Type | Required | Description |
|---|---|---|---|
| decimal | numeric string | ✓ | A decimal number as a string. |
| rational | object | ✓ | A standard RationalValue object. |
| fraction | object | ✓ | A standard FractionalValue object. |
The FractionalValue object includes a numerator and denominator values for a given price or amount:
| Parameter | Type | Required | Description |
|---|---|---|---|
| numer | string (numeric) | ✓ | The numerator of the fractional value. |
| denom | string (numeric) | ✓ | The denominator of the fractional value. |
For requests which return many results, pagination offsets may be applied. ** Use either value, not both. **
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| PageNumber | integer | ✗ | 1 | Offset for paginated results |
| FromId | integer | ✗ | - | Ignores any results prior to this UUID |
The Komodo DeFi SDK now offers the num-rational crate feature which allows for higher precision numeric values to represent order volumes and prices in a unique format as explained below:
[
[1, [0, 1]],
[1, [1]]
]
In the above unique format, the first item [1,[0,1]] is the numerator and the second item [1,[1]] is the denominator.
The numerator and denominator are BigInteger numbers represented as a sign and a uint32 array (where numbers are 32-bit parts of big integer in little-endian order).
[1,[0,1]] represents +0000000000000000000000000000000010000000000000000000000000000000 = 4294967296
[-1,[1,1]] represents -1000000000000000000000000000000010000000000000000000000000000000 = -4294967297
You can optionally apply more detailed configuration to event streaming methods.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| stream_interval_seconds | float | ✗ | 10/5 | Interval in seconds between streaming event update requests. Defaults to 10 for stream::balance::enable and 5 for stream::network::enable/stream::heartbeat::enable |
| always_send | boolean | ✗ | false | stream::network::enable only. If true, network data will always be sent every stream_interval_seconds, even when there is no change. If false, network data will be sent regardless. |
The EventStreamConfig object defines which events will be streamed to the client:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| access_control_allow_origin | string | ✗ | - | Defines CORS whitelist. Use "*" to allow from any origin. |
| worker_path | string | ✗ | - | WASM only. Path to a custom worker.js file. |
Configurable events, and how to enable them, is detailed in the streaming methods doc
An example of the event stream output can then be viewed in https://github.com/KomodoPlatform/komodo-defi-framework/blob/main/examples/sse/index.html?id=CLIENT_ID
The CLIENT_ID value used in the url must match the client_id value used when enabling streaming events. In the case of a single client only, defining the client_id is not required (it will default to 0).
| Parameter | Type | Required | Description |
|---|---|---|---|
| state | string | ✓ | current state of sync; possible values: NotEnabled, NotStarted, InProgress, Error, Finished |
| additional_info | object | ✓ | A standard SyncStatusExtended object. Additional info that helps to track the progress; present for InProgress and Error states only. |
| Parameter | Type | Required | Description |
|---|---|---|---|
| blocks_left | number | ✗ | present for ETH/ERC20 coins only; displays the number of blocks left to be processed for InProgress state |
| transactions_left | number | ✗ | present for UTXO coins only; displays the number of transactions left to be processed for InProgress state |
| code | number | ✗ | displays the error code for Error state |
| message | number | ✗ | displays the error message for Error state |
The 'FilterCriteria' object allows you to filter the results based on specific parameters.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| status | string | ✗ | - | Status of the transactions (e.g., "completed") |
| date_from | string | ✗ | - | Start date in ISO 8601 format |
| date_to | string | ✗ | - | End date in ISO 8601 format |
| my_coin | string | ✗ | - | Coin being used by you for the swap/trade. |
| other_coin | string | ✗ | - | Coin you are trading against |
| from_timestamp | number | ✗ | - | Start timestamp in UNIX format |
| to_timestamp | number | ✗ | - | End timestamp in UNIX format |
The PagingOptions object includes options of page selection to consult when looking for recent swaps:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| from_uuid | string (or null) | ✗ | null | Skips records until this UUID, excluding the record with this UUID. Convenient for infinite scrolling implementations. |
| limit | number | ✗ | - | Limits the number of returned swaps. |
| page_number | number | ✗ | - | Returns limit swaps from the selected page. This parameter is ignored if from_uuid is set. |
The specified coin was not found or is not activated yet.
| Parameter | Type | Required | Description |
|---|---|---|---|
| coin | string | ✓ | the not found coin specified in the Request |
The request was failed due to a network error.
| Parameter | Type | Required | Description |
|---|---|---|---|
| (none) | string | ✓ | the transport error description |
The request was failed due to an Komodo DeFi API internal error.
| Parameter | Type | Required | Description |
|---|---|---|---|
| (none) | string | ✓ | the internal error description |
| Value | Description |
|---|---|
| POLYGON | Polygon network |
| FANTOM | Fantom network |
| ETH | Ethereum network |
| BSC | Binance Smart Chain |
| AVALANCHE | Avalanche network |
| Value | Description |
|---|---|
| ERC721 | ERC-721 NFT contract type |
| ERC1155 | ERC-1155 NFT contract type |
| Value | Description |
|---|---|
| Receive | NFT was received |
| Send | NFT was sent |