Skip to main content

Overview

Use this cookbook when you want to integrate directly with the deployed contracts instead of relying on transaction-building endpoints. This gives you full control over:
  • token approvals,
  • router call parameters,
  • wallet UX,
  • and transaction submission.
The examples below use viem, which is also the library used in the current frontend stack.

Prerequisites

You will also need:
  • the target router address,
  • the source-chain USDC address,
  • the instrument ID,
  • and a connected wallet client.
See Contract Addresses for the deployed addresses.

Shared Setup

Recipe 1: Same-Chain Buy on Base

For same-asset deposits such as Base Aave USDC, minDepositedAmount = 0n is usually acceptable because there is no internal token conversion.

Charging a referral fee

Set referralFeeBps (1–500, i.e. 0.01%–5%) and a non-zero referralWallet to route a portion of the user’s USDC to a referrer before the deposit. Fees above 500 bps are rejected by the router.

Recipe 2: Cross-Chain Buy From Base To Arbitrum

When the instrument lives on another supported chain, the same buy() entrypoint routes into the bridge path automatically.

Monitor cross-chain completion

The destination-side redeem is completed asynchronously after attestation. Poll the relay status endpoint using the source tx hash.
Direct contract callers do not need to register an operation with the backend. The relay starts from the bridge event webhook.

Recipe 3: Sell Directly Through the Router

sell() applies the referral fee on the stable currency output after the lending withdrawal and optional swap back to USDC.

When To Use Direct Contracts vs The Transaction API

Use direct contract calls when you want:
  • fully custom wallet UX,
  • explicit control over approvals and router params,
  • to avoid backend execution helpers for calldata generation.
Use the Transactions API when you want:
  • automatic source-chain selection,
  • quote normalization and slippage handling,
  • ready-to-sign transaction bundles,
  • less integration logic in your client.

Common Pitfalls

  • forgetting that amount for USDC uses 6 decimals
  • not waiting for approval confirmation before sending buy() or sell()
  • assuming cross-chain buys finish in the same transaction as the source-chain buy()
  • hardcoding outdated addresses instead of checking the deployment docs
  • using the wrong chain for the router call when the instrument lives elsewhere

Next Steps

Contract Addresses

Router, bridge, receiver, and token addresses on each supported chain

API Cookbook

API-assisted execution flow with bundle building and relay monitoring