On this page

latest contributor to this doc

Last Edit:

@smk762

Common Structures

overviewcommon_structures

The objects are in the request or response of multiple Komodo DeFi SDK methods have been grouped into the following sections:

  • Activation Common Structures: Details on activation modes, parameters, and server configurations for various coin types.
  • Enums: Enumerated values used across multiple methods, such as swap types, order statuses, and key policies.
  • Lightning Common Structures: Objects for Lightning Network operations, including channel and payment configurations.
  • NFT Common Structures: Structures for non-fungible token (NFT) operations, filters, and metadata.
  • Order Common Structures: Structures for orderbook entries, order data, and related parameters.
  • Swap Common Structures: Objects and events related to atomic swaps, including event types and swap status.
    • Maker Events: Step-by-step events and outcomes for atomic swaps from the maker's perspective.
    • Taker Events: Step-by-step events and outcomes for atomic swaps from the taker's perspective.
  • Wallet Common Structures: Structures for wallet operations, address derivation, balances, and key management.

Structures which are used in more than one section are listed below:

The EventStreamConfig object defines which events will be streamed to the client:

ParameterTypeRequiredDefaultDescription
access_control_allow_originstring-Defines CORS whitelist. Use "*" to allow from any origin.
worker_pathstring-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).

The 'FilterCriteria' object allows you to filter the results based on specific parameters.

ParameterTypeRequiredDefaultDescription
statusstring-Status of the transactions (e.g., "completed")
date_fromstring-Start date in ISO 8601 format
date_tostring-End date in ISO 8601 format
my_coinstring-Coin being used by you for the swap/trade.
other_coinstring-Coin you are trading against
from_timestampnumber-Start timestamp in UNIX format
to_timestampnumber-End timestamp in UNIX format

The FractionalValue object includes a numerator and denominator values for a given price or amount:

ParameterTypeRequiredDescription
numerstring (numeric)The numerator of the fractional value.
denomstring (numeric)The denominator of the fractional value.

The NumericFormatsValue returns a price or amount in three different formats: fraction, rational, and decimal.

ParameterTypeRequiredDescription
decimalnumeric stringA decimal number as a string.
rationalobjectA standard RationalValue object.
fractionobjectA standard FractionalValue object.

The PagingOptions object includes options of page selection to consult when looking for recent swaps:

ParameterTypeRequiredDefaultDescription
from_uuidstring (or null)nullSkips records until this UUID, excluding the record with this UUID. Convenient for infinite scrolling implementations.
limitnumber-Limits the number of returned swaps.
page_numbernumber-Returns limit swaps from the selected page. This parameter is ignored if from_uuid is set.

For requests which return many results, pagination offsets may be applied. ** Use either value, not both. **

ParameterTypeRequiredDefaultDescription
PageNumberinteger1Offset for paginated results
FromIdinteger-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:

You can optionally apply more detailed configuration to event streaming methods.

ParameterTypeRequiredDefaultDescription
stream_interval_secondsfloat10/5Interval in seconds between streaming event update requests. Defaults to 10 for stream::balance::enable and 5 for stream::network::enable/stream::heartbeat::enable
always_sendbooleanfalsestream::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.

ParameterTypeRequiredDescription
statestringcurrent state of sync; possible values: NotEnabled, NotStarted, InProgress, Error, Finished
additional_infoobjectA standard SyncStatusExtended object. Additional info that helps to track the progress; present for InProgress and Error states only.

ParameterTypeRequiredDescription
blocks_leftnumberpresent for ETH/ERC20 coins only; displays the number of blocks left to be processed for InProgress state
transactions_leftnumberpresent for UTXO coins only; displays the number of transactions left to be processed for InProgress state
codenumberdisplays the error code for Error state
messagenumberdisplays the error message for Error state

The WcConnNs object contains details of approved chains, methods and events while connected via WalletConnect.

ParameterTypeDescription
chainslist of stringsA list of chain IDs. For EIP155, refer to https://chainid.network/. For Cosmos, refer to https://cosmos.directory/
methodslist of stringsA list of approved methods, usable while connected. For EIP155, refer to https://docs.reown.com/advanced/multichain/rpc-reference/ethereum-rpc. For Cosmos, refer to https://docs.reown.com/advanced/multichain/rpc-reference/cosmos-rpc
eventslist of stringsA list of events to track during the connection. For EIP155, refer to https://docs.reown.com/advanced/providers/ethereum#events. For Cosmos, refer to https://tutorials.cosmos.network/academy/2-cosmos-concepts/10-events.html

The WcSession object contains details of active WalletConnect sessions.

ParameterTypeDescription
topicstringThe session topic hex string, used to identify the session for communications with the external wallet/dapp.
metadataobjectArbitrary data returned from the external wallet/dapp on connection.
pairing_topicstringThe pairing topic hex string, used for the initial external wallet/dapp connection.
namespacesobjectContains the same two WcConnNs objects for Cosmos/EIP155 which were input when initialising the connection via wc_new_connection.
expiryintegerA timestamp in unix epoch format indicating when the connection will expire if not otherwise closed.

Within each session object, there are a some values which are required as input in other WalletConnect methods:

  • pairing_topic: Only used when initally connecting with external wallets/dapps.
  • topic: Once connected, this is use for communications with the connected external wallet/dapp.

ParameterTypeDescription
errorstringA human-readable error message.
error_pathstringThe path in the code where the error occurred.
error_tracestringA stack trace of the error.
error_typestringThe type of the error.
error_dataobjectAdditional data related to the error.