WDK logoWDK documentation

LI.FI Swidge Configuration

Configuration options for @lifi/wdk-protocol-swidge-lifi.

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.

Configure LifiSwidgeProtocol with a WDK EVM account when you need execution, account-address-based quotes, or status lookups. Without an account, the module supports quotes and discovery when config.provider is supplied.

import { WalletAccountEvm } from '@tetherto/wdk-wallet-evm'
import { LifiSwidgeProtocol } from '@lifi/wdk-protocol-swidge-lifi'

const account = new WalletAccountEvm(seedPhrase, "0'/0/0", {
  provider: 'https://mainnet.infura.io/v3/YOUR_KEY'
})

const swidge = new LifiSwidgeProtocol(account, {
  integrator: 'my-app',
  order: 'RECOMMENDED',
  maxNetworkFeeBps: 100,
  maxProtocolFeeBps: 50
})

Constructor

new LifiSwidgeProtocol(account?, config?)
ParameterDescription
accountOptional WDK EVM account. Writable accounts can execute. Read-only accounts can quote, check status, and discover support.
configOptional LifiSwidgeProtocolConfig for fee caps, provider setup, LI.FI route selection, retries, and contract validation.

When account is omitted, config.provider is required for quoteSwidge(). Accountless quote requests omit fromAddress.

Configuration Options

OptionTypeDescription
providerstring | Eip1193ProviderRPC URL or EIP-1193 provider. Falls back to account._config.provider when omitted.
integratorstringLI.FI integrator identifier sent with API requests.
apiKeystringLI.FI API key for higher rate limits. Keep it server-side.
order'RECOMMENDED' | 'FASTEST' | 'CHEAPEST'Route selection strategy. Defaults to RECOMMENDED.
allowBridgesstring[]Bridge protocol allowlist, for example ['stargate'].
denyBridgesstring[]Bridge protocol denylist, for example ['across']. When omitted, no bridge filter is sent and LI.FI considers all bridges. For gasless integrations, pass the exported NATIVE_VALUE_BRIDGE_DENY_LIST to exclude bridges that require native token value.
allowDestinationCallbooleanAllows LI.FI routes that execute a destination-chain call, such as a destination-chain swap. Forwarded only when set explicitly; when omitted, LI.FI's own default (true) applies. Set false to filter out routes that may leave the user with an intermediary token if the destination call fails.
allowNativeValuebooleanWhether swidge() may execute quotes whose transaction requires native token value (transactionRequest.value > 0). Defaults to true. Set false for gasless setups (for example ERC-4337 with a paymaster): such quotes are rejected before any approval is sent.
maxNetworkFeeBpsnumber | bigintRejects execution when LI.FI reports SEND gas costs above this many basis points of a positive fromAmountUSD. If input USD pricing is missing or zero, the check is skipped; missing gas-cost USD values count as zero.
maxProtocolFeeBpsnumber | bigintRejects execution when protocol fees exceed this many basis points of the input amount.
timeoutnumberPer-request timeout in milliseconds. Defaults to 30000.
retriesnumberExtra attempts for transient failures. Defaults to 1; set 0 to disable retries.
retryDelaynumberBase retry delay in milliseconds. Defaults to 500 and backs off exponentially.
trustedContractstrue | Record<number, string | string[]>Requires quote transaction targets and approval addresses to match known LI.FI contracts before execution. Off by default.

Per-Call Overrides

Pass a config object to swidge(options, config) to override fee caps or execution settings for one operation.

const route = {
  fromToken: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
  toToken: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
  toChain: 'arbitrum',
  fromTokenAmount: 10_000_000n
}

await swidge.swidge(route, {
  maxProtocolFeeBps: 20,
  maxNetworkFeeBps: 75
})

Route Filtering

By default the module applies no extra route filtering: denyBridges is not set, allowDestinationCall is not forwarded (LI.FI's server-side default of true applies), and quotes that require native token value execute as-is. This gives the widest route coverage and matches LI.FI SDK behavior.

For gasless integrations — for example ERC-4337 where a paymaster covers source-chain gas but the LI.FI route transaction itself must not require separate native token value — opt in explicitly:

import {
  LifiSwidgeProtocol,
  NATIVE_VALUE_BRIDGE_DENY_LIST
} from '@lifi/wdk-protocol-swidge-lifi'

const swidge = new LifiSwidgeProtocol(account, {
  denyBridges: NATIVE_VALUE_BRIDGE_DENY_LIST, // filter native-value bridges at quote time
  allowNativeValue: false                     // reject any quote whose tx still needs native value
})

NATIVE_VALUE_BRIDGE_DENY_LIST is the maintained list of bridges known to require native token value in the source transaction. denyBridges replaces (does not append to) any default, so denyBridges: ['across'] denies only across.

Set allowDestinationCall: false to exclude routes that require a destination-chain call, such as a swap after bridging, which can leave the user holding an intermediary token if the destination call fails.

With allowNativeValue: false, execution rejects any quote whose transaction request requires native token value before sending approvals or the route transaction, even if a native-value bridge was not filtered out at quote time.

Contract Validation

The module always validates returned transaction data before forwarding it to the wallet. Enable trustedContracts when the integration also needs an allowlist check against LI.FI Diamond deployments and Permit2.

const swidge = new LifiSwidgeProtocol(account, {
  trustedContracts: true
})

To extend the built-in allowlist for a chain, pass chain IDs mapped to one or more extra trusted addresses:

const swidge = new LifiSwidgeProtocol(account, {
  trustedContracts: {
    137: [trustedPolygonContractAddress]
  }
})

trustedPolygonContractAddress must be a validated EVM address for the additional contract your integration trusts.

Security Notes

  • Do not expose LI.FI API keys in browser clients.
  • Use explicit fee caps when routing user funds.
  • Validate route choices with getSupportedChains() and getSupportedTokens() before quoting.
  • Ask for user confirmation before calling swidge().

On this page