0xtrails. Amount fields accept human-readable decimal strings (e.g., "0.5" for 0.5 USDC), raw bigint values, or dynamic() for runtime resolution.
swap
Executes a token exchange via Uniswap V3 or SushiSwap V3. Trade type is inferred from which amount field you provide:amountIn produces EXACT_INPUT; amountOut produces EXACT_OUTPUT.
| Parameter | Type | Description |
|---|---|---|
tokenIn | string | Input token symbol or address |
tokenOut | string | Output token symbol or address |
amountIn | string | bigint | dynamic | Amount to spend (use for EXACT_INPUT) |
amountOut | string | bigint | dynamic | Amount to receive (use for EXACT_OUTPUT) |
feeTier | number | Pool fee tier in basis points; default 3000 (0.3%) |
slippage | number | Slippage tolerance; overrides provider default |
provider | string | Force a specific swap provider ("uniswap" or "sushiswap") |
Low-level swap utilities
For advanced use cases that need pre-flight pricing or manual call construction:| Utility | Description |
|---|---|
quoteSwap({ tokenIn, tokenOut, amountIn, chainId }) | Returns a price quote without signing |
getPool({ tokenA, tokenB, feeTier, chainId }) | Returns the pool address for a token pair |
swapExactInputSingle(params) | Builds an approval + swap call array for exact input |
swapExactOutputSingle(params) | Builds an approval + swap call array for exact output |
lend
Supplies tokens to a lending market. UseuseEarnMarkets to discover available marketId values.
| Parameter | Type | Description |
|---|---|---|
marketId | string | Market identifier from useEarnMarkets |
token | string | Token symbol or address to supply |
amount | string | bigint | dynamic | Amount to lend |
deposit
Contributes funds to a vault-shaped market: ERC-4626, Morpho, or Yearn vaults.| Parameter | Type | Description |
|---|---|---|
marketId | string | Vault identifier from useEarnMarkets |
token | string | Token symbol or address |
amount | string | bigint | dynamic | Amount to deposit |
assertCondition
An onchain guard. If the condition evaluates to false at execution time, the entire batch reverts. Use this to validate state before continuing (minimum balance, deadline, allowance).assertCondition does not accept dynamic() values, it evaluates concrete conditions against live chain state.
| Parameter | Type | Description |
|---|---|---|
type | "balance" | "deadline" | "allowance" | Condition type |
token | string | Token to check (for balance/allowance conditions) |
minAmount | string | bigint | Minimum acceptable amount |
deadline | number | Unix timestamp (for deadline conditions) |
custom
An escape hatch for arbitrary contract calls. UseencodeFunctionData from viem to build the calldata.
| Parameter | Type | Description |
|---|---|---|
target | string | Contract address to call |
calldata | string | ABI-encoded function call |
value | bigint | ETH value to send with the call; default 0n |