WDK logoWDK documentation

Rhino.fi Swidge API Reference

API reference for @rhino.fi/wdk-protocol-swidge-rhinofi.

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.

RhinofiProtocol

RhinofiProtocol extends SwidgeProtocol from @tetherto/wdk-wallet/protocols and implements the shared WDK swidge methods.

import RhinofiProtocol, {
  AccountRequiredError,
  ConfigurationError
} from '@rhino.fi/wdk-protocol-swidge-rhinofi'

const rhinofi = new RhinofiProtocol(account, config)

Constructor

new RhinofiProtocol(account?, config)
AccountAvailable operations
WalletAccountEvmDiscovery, quote, status, and execution.
WalletAccountEvmErc4337Discovery, quote, status, and execution through a smart account.
WalletAccountSolanaDiscovery, quote, status, and execution from Solana.
WalletAccountTronDiscovery, quote, status, and execution from Tron.
WalletAccountReadOnlyEvmDiscovery, quotes, and status lookups without signing.
WalletAccountReadOnlyEvmErc4337Discovery, quotes, and status lookups without signing.
WalletAccountReadOnlySolanaDiscovery, quotes, and status lookups without signing.
WalletAccountReadOnlyTronDiscovery, quotes, and status lookups without signing.
undefinedDiscovery and status lookups; quotes and execution require an account.

Methods

MethodDescription
quoteSwidge(options)Returns a Rhino.fi route quote and the raw provider quote.
swidge(options, config?)Executes a route and returns when the source deposit is broadcast.
getSwidgeStatus(id, options?)Maps Rhino.fi operation state to WDK SwidgeStatus.
getSupportedChains()Returns chains supported by Rhino.fi config.
getSupportedTokens(options?)Returns tokens supported by Rhino.fi config, optionally filtered by chain context.

quoteSwidge(options)

quoteSwidge(options: SwidgeOptions): Promise<SwidgeQuote & { quote: object }>

The source chain is derived from the account when required by the route. Pass the returned quote field to swidge() when execution must use this exact provider quote.

swidge(options, config?)

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

Requires a supported writable WDK source account. The method submits the source-chain deposit and returns the operation ID and source transaction hash.

getSwidgeStatus(id, options?)

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

Use the id returned by swidge().

Config Type

type RhinofiProtocolConfig = {
  apiKey: string
  apiBaseUrl?: string
  maxNetworkFeeBps?: number | bigint
  maxProtocolFeeBps?: number | bigint
  configTtlMs?: number
}

Per-Call Config Type

type DepositSubmission =
  | { type: 'transaction'; txHash: string }
  | { type: 'user-operation'; userOpHash: string }

type SwidgeCallConfig = {
  maxNetworkFeeBps?: number | bigint
  maxProtocolFeeBps?: number | bigint
  quote?: object
  onDepositSubmitted?: (submission: DepositSubmission) => void
}

Use quote to execute the exact provider quote returned by quoteSwidge(). onDepositSubmitted reports that the deposit has left the device before a settled transaction hash is available; callback errors do not abort execution.

Status Mapping

Rhino.fi stateWDK status
PENDING, PENDING_CONFIRMATION, DEPOSIT_ACCEPTED, ACCEPTEDpending
EXECUTEDcompleted
SWAP_FAILEDrefund-pending
SWAP_FAILED_REFUNDED, DEPOSIT_RECEIVED_AFTER_GRACE_PERIOD_REFUNDEDrefunded
DEPOSIT_RECEIVED_AFTER_GRACE_PERIODaction-required
FAILEDfailed
CANCELLEDcancelled

Fee Mapping

Rhino.fi quote feeWDK fee typeLegacy field
gasFee plus sourceGasFeenetworkfee
Platform and percentage fee remainderprotocolbridgeFee

The network and protocol fee amounts are itemized in SwidgeFee[] and denominated in the input token.

Error Types

All Rhino.fi module errors extend RhinofiProtocolError.

ErrorWhen thrown
AccountRequiredErrorswidge() is called without a writable account.
ConfigurationErrorRequired configuration is missing, such as apiKey.
UnsupportedChainErrorA chain is unknown, unsupported, or invalid as a source chain.
UnsupportedTokenErrorA token is unknown or unsupported on the selected chain.
FeeLimitExceededErrorQuoted fees exceed configured fee caps.
UnknownOperationErrorStatus is requested for an unknown operation ID.
SwidgeExecutionErrorRhino.fi quote or execution fails. The .code field can carry provider failure codes.

Legacy Delegations

Inherited swap, quoteSwap, bridge, and quoteBridge calls delegate to swidge() and quoteSwidge(). Because those legacy option shapes do not carry source-chain context, the source chain must be derivable from the bound account.

On this page