WDK logoWDK documentation

Symbiosis Swidge API Reference

API reference for @symbiosis-finance/wdk-protocol-swidge-symbiosis 1.3.0.

Community modules are developed and maintained independently by third-party contributors.

Tether and the WDK Team do not endorse or assume responsibility for their code, security, or maintenance. Use your own judgment and proceed at your own risk.

Package exports

import SymbiosisProtocol, {
  ApiError,
  ConfigurationError,
  ExactOutNotSupportedError,
  FeeLimitExceededError,
  ReadOnlyAccountError,
  SymbiosisError,
  TransactionError,
  UnsupportedChainError,
  UnsupportedRouteError,
  UnsupportedTokenError,
  ValidationError
} from '@symbiosis-finance/wdk-protocol-swidge-symbiosis'

The package exports SymbiosisProtocol as both its default export and a named export. It also re-exports ISwidgeProtocol from @tetherto/wdk-wallet/protocols.

This reference covers release 1.3.0.

SymbiosisProtocol

SymbiosisProtocol extends SwidgeProtocol.

Constructor

new SymbiosisProtocol(
  account?: IWalletAccount | IWalletAccountReadOnly,
  config?: SymbiosisProtocolConfig
)
AccountAvailable operations
Writable account with the route's required methodsDiscovery, quote, status, and supported source execution
Read-only accountDiscovery and status; quoting uses the account's address as the request sender
undefinedDiscovery and status; quoting requires recipient to supply the request sender

chain is optional in the constructor type, but quoteSwidge() and swidge() throw ConfigurationError when it is absent.

Configuration type

type SymbiosisProtocolConfig = {
  chain?: string | number
  apiUrl?: string
  timeoutMs?: number
  partnerId?: string
  defaultSlippage?: number
  partnerAddress?: string
  refundAddress?: string
  skipApproval?: boolean
  maxNetworkFeeBps?: number | bigint
  maxProtocolFeeBps?: number | bigint
}

See Configuration for defaults, validation boundaries, and execution effects.

Methods

MethodSide effectsDescription
quoteSwidge(options)Provider API reads onlyReturns an indicative exact-input quote.
swidge(options, config?)Can approve and broadcast one or more source transactionsRequests a fresh execution response and submits its source route through the wallet account.
getSwidgeStatus(id, options?)Provider API readMaps Symbiosis settlement state to a WDK status.
getSupportedChains()Provider API reads, cachedReturns provider-listed chains with WDK chain metadata.
getSupportedTokens(options?)Provider API read, cachedReturns provider-listed tokens, optionally filtered to one chain.

quoteSwidge(options)

quoteSwidge(options: SwidgeOptions): Promise<SwidgeQuote>

Builds an exact-input request and calls /v2/quote. The method does not reserve or bind the result for swidge().

Package-specific errors include:

  • ConfigurationError when chain is missing;
  • ValidationError when fromTokenAmount is missing, is not an integer, or is not positive; a token identifier is not a string; or no account address or recipient supplies the request sender;
  • ExactOutNotSupportedError when toTokenAmount is present;
  • UnsupportedChainError or UnsupportedTokenError when discovery cannot resolve an identifier;
  • ApiError when the API returns a non-2xx response, times out, or fails before a response is received. Network failures and timeouts carry status: 0.

The method can also propagate an error from account.getAddress().

swidge(options, config?)

swidge(
  options: SwidgeOptions,
  config?: SwidgeProtocolConfig
): Promise<SwidgeResult>

Requires an account with sendTransaction(). It calls /v2/swap, checks the applicable fee caps, performs the route-specific approval or source-payment steps, and returns after source broadcast.

For ton, tron, and solana source routes, the method first probes the bound account for the transaction format the route requires (raw BoC message bodies, smart contract calls plus TRC-20 approvals, and serialized transactions respectively) and throws UnsupportedRouteError when the capability is missing or a ton route needs more than one message.

The optional second argument overrides maxNetworkFeeBps and maxProtocolFeeBps for this execution.

swidge() does not consume the preceding quoteSwidge() response or expose its fresh /v2/swap response for a separate confirmation. After its fee checks, it proceeds internally to the required wallet writes.

getSwidgeStatus(id, options?)

getSwidgeStatus(
  id: string,
  options?: SwidgeStatusOptions
): Promise<SwidgeStatusResult>

Pass the ID returned by swidge():

<sourceChainId>:<sourceTransactionHash>

For a bare transaction hash, pass options.fromChain or configure the instance source chain. The provider does not use other status hints.

The resolved source-chain ID and transaction hash are URL-encoded before the provider builds the status endpoint path.

HTTP 404 is returned as pending, not as ApiError.

getSupportedChains()

getSupportedChains(): Promise<SwidgeSupportedChain[]>

Calls the Symbiosis chain and token endpoints and maps each in-scope chain to:

FieldTypeDescription
idnumberNumeric Symbiosis chain ID
namestringProvider chain name
typestringevm, utxo, tvm, tron, or svm
nativeTokenstringNative token symbol when present in the token catalog

Monero and Zcash are filtered out because their provider routes use third-party custodial integrations outside this module's scope.

getSupportedTokens(options?)

getSupportedTokens(
  options?: SwidgeSupportedTokensOptions
): Promise<SwidgeSupportedToken[]>

The chain filter is resolved as options.toChain ?? options.fromChain. fromToken and other route context do not narrow the result.

FieldTypeDescription
tokenstringNative-format address when present, otherwise the token symbol
chainnumberNumeric Symbiosis chain ID
symbolstringProvider token symbol
decimalsnumberBase-unit precision
addressstring | undefinedToken address when it is not the native asset
namestring | undefinedProvider token name when supplied

The response is a token catalog, not proof of pair liquidity. Request a quote for route availability.

Relevant SwidgeOptions

FieldTypeProvider behavior
fromTokenstringRequired source token address, symbol, or native-token alias
toTokenstringRequired destination token address, symbol, or native-token alias
toChainstring | number | undefinedDestination chain; defaults to the configured source chain
recipientstring | undefinedDestination recipient; defaults to the bound account address. Without an account, it also supplies the request sender
refundAddressstring | undefinedPer-call refund address; overrides the constructor default
slippagenumber | undefinedDecimal slippage; overrides defaultSlippage
fromTokenAmountnumber | bigintRequired exact input in source-token base units
toTokenAmountnumber | bigintUnsupported; throws ExactOutNotSupportedError

The module does not validate slippage ranges or address formats. It converts fromTokenAmount with BigInt and throws ValidationError unless the result is greater than zero.

Quote and result fields

SwidgeQuote

FieldTypeSource
fromTokenAmountbigintRequested exact input
toTokenAmountbigintProvider-estimated output
toTokenAmountMinbigintProvider minimum output after slippage
feesSwidgeFee[]Mapped provider fee entries
estimatedDurationnumber | undefinedProvider estimate in seconds
priceImpactnumber | undefinedProvider percentage converted to a decimal

The provider does not map a quote expiry into SwidgeQuote.

SwidgeResult

FieldPublic typeProvider behavior
idstring<sourceChainId>:<sourceTransactionHash>
hashstring | undefinedSource transaction hash
feesSwidgeFee[]Fees from the fresh execution response
transactionsSwidgeTransaction[] | undefinedZero, one, or two EVM or Tron approval hashes followed by the source hash; a later status response returns its own source, destination, or refund transaction list
fromTokenAmountbigintSubmitted exact input
toTokenAmountbigintFresh provider-estimated output
toTokenAmountMinbigint | undefinedFresh provider minimum output

Status mapping

Symbiosis code or responseWDK status
0completed
1pending
2pending
3refunded
-1pending
Unknown codepending
HTTP 404pending with the known source transaction

When status is refunded, a returned settlement transaction is labeled refund; otherwise it is labeled destination.

Fee mapping and caps

Symbiosis fee ruleWDK fee typeCap
description is exactly Partner feeaffiliateNone
Every other fee entryprotocolmaxProtocolFeeBps

Mapped fees include amount, token, chain, description, and included: true.

The provider emits no network fee entry in this release, so maxNetworkFeeBps does not constrain the wallet transaction's chain fee. Inherited legacy bridge() results expose 0n for their network fee; mapped protocol fees contribute to bridgeFee.

Fee-cap fallback comparison uses decimal-normalized values when positive USD prices are unavailable. This is approximate when the fee token differs in unit value from the input token.

Error classes

Every package-specific error extends SymbiosisError.

ErrorWhen thrownUseful fields
SymbiosisErrorBase class for package-defined errorsStandard Error fields
ConfigurationErrorRequired source chain configuration is missing
ValidationErrorA locally checked option, sender, token identifier, or status ID is invalid
ExactOutNotSupportedErrortoTokenAmount requests exact-output execution
UnsupportedChainErrorA chain ID or name is not in provider discoveryidentifier
UnsupportedTokenErrorA token is not in the selected chain's token catalogidentifier
ReadOnlyAccountErrorExecution lacks a writable account, or an EVM approval is required and the account does not support approvals
UnsupportedRouteErrorThe route's source transaction cannot be executed through the bound account: a missing wallet capability for ton, tron, or solana, or a multi-message ton routetype
FeeLimitExceededErrorA mapped network or protocol total exceeds its configured capfeeType, bps, cap
TransactionErrorApproval receipt polling detects a revert (including a failed Tron approval receipt) or reaches its 180-second timeouthash
ApiErrorThe REST API returns a non-2xx response other than status lookup's special 404 handling, or a request fails or times out before a responsestatus, response, and cause for failures before a response

ApiError.status is 0 when no HTTP response was received. Errors thrown by wallet account methods are propagated and are not necessarily instances of SymbiosisError.

Inherited compatibility methods

SymbiosisProtocol inherits:

  • swap() and quoteSwap();
  • bridge() and quoteBridge().

Those methods delegate to swidge() and quoteSwidge(). For the legacy bridge shape, the provider can resolve the destination token by matching the source token symbol on the destination chain.

Prefer the Swidge methods when an application needs itemized fees, provider status, combined route semantics, or explicit destination-token selection.

On this page