WDK logoWDK documentation

Rhino.fi Swidge API Reference

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

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.
WalletAccountReadOnlyEvmDiscovery and quotes for routes that do not need signing.
undefinedDiscovery and account-independent setup when route context allows it.

Methods

MethodDescription
quoteSwidge(options)Returns a non-binding Rhino.fi route 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>

The source chain is derived from the account when required by the route.

swidge(options, config?)

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

Requires a writable WDK EVM 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
}

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