WDK logoWDK documentation

Rhino.fi Swidge Usage

Install and use @rhino.fi/wdk-protocol-swidge-rhinofi for Rhino.fi cross-chain routes.

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.

Install

npm install @rhino.fi/wdk-protocol-swidge-rhinofi@1.2.0 @tetherto/wdk-wallet-evm

Install ERC-4337 support when you need smart-account execution:

npm install @tetherto/wdk-wallet-evm-erc-4337

Install the matching wallet module when Solana or Tron is the source ecosystem:

# Solana source accounts
npm install @tetherto/wdk-wallet-solana
# Tron source accounts
npm install @tetherto/wdk-wallet-tron

Create the Protocol

import { WalletAccountEvm } from '@tetherto/wdk-wallet-evm'
import RhinofiProtocol from '@rhino.fi/wdk-protocol-swidge-rhinofi'

const account = new WalletAccountEvm(seedPhrase, "0'/0/0", {
  provider: 'https://ethereum-rpc.publicnode.com'
})

const rhinofi = new RhinofiProtocol(account, {
  apiKey: process.env.RHINO_API_KEY,
  maxNetworkFeeBps: 50,
  maxProtocolFeeBps: 30
})

const ETHEREUM_USDT = '0xdAC17F958D2ee523a2206206994597C13D831ec7'
const AVALANCHE_USDT = '0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7'

Discover Chains and Tokens

const chains = await rhinofi.getSupportedChains()
const tokens = await rhinofi.getSupportedTokens({
  fromChain: 'ETHEREUM'
})

The module reads live Rhino.fi chain and token config. The source chain must be derivable from the WDK account for execution.

Quote a Route

const quote = await rhinofi.quoteSwidge({
  fromToken: ETHEREUM_USDT,
  toToken: AVALANCHE_USDT,
  toChain: 'AVALANCHE',
  recipient: '0xRecipient...',
  fromTokenAmount: 100_000_000n
})

console.log('Expected output:', quote.toTokenAmount)
console.log('Minimum output:', quote.toTokenAmountMin)
console.log('Fees:', quote.fees)

This route bridges USD₮ from Ethereum to Avalanche. Token addresses are chain-specific; use the exact address returned by the provider's current config for each side of a different route.

Use toTokenAmount instead of fromTokenAmount for exact-output routes when supported by the provider route.

Execute a Route

quoteSwidge() returns the provider quote as quote.quote. Pass it to swidge() to execute the quote shown to the user. Quotes expire, so request a new quote if execution rejects a stale one. Omitting quote makes swidge() fetch a fresh provider quote.

const result = await rhinofi.swidge({
  fromToken: ETHEREUM_USDT,
  toToken: AVALANCHE_USDT,
  toChain: 'AVALANCHE',
  recipient: '0xRecipient...',
  fromTokenAmount: 100_000_000n
}, {
  quote: quote.quote
})

console.log('Operation ID:', result.id)
console.log('Source transaction:', result.hash)

swidge() resolves after the source deposit transaction is broadcast. The destination settlement can continue after the method returns.

Track Status

const status = await rhinofi.getSwidgeStatus(result.id)

if (status.status === 'completed') {
  console.log('Route completed')
}

Handle Errors

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

try {
  await rhinofi.swidge(options)
} catch (error) {
  if (error instanceof AccountRequiredError) {
    // Bind a supported writable WDK source account before execution.
  } else if (error instanceof ConfigurationError) {
    // Check apiKey and API configuration.
  } else if (error instanceof FeeLimitExceededError) {
    // Ask the user to approve the quoted fee or lower the amount.
  } else if (error instanceof RhinofiProtocolError) {
    // Handle another Rhino.fi module error.
  }
}

On this page