Skip to main content

Documentation Index

Fetch the complete documentation index at: https://flashnet-build.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

Conductor is the contract TradingClient calls under the hood. Most integrators should use TradingClient.swap and never see Conductor directly. This page covers the raw calldata encoders for cases where you need to call it without the SDK wrapper.

When you need this

  • Wiring a swap into a contract you wrote, where the SDK doesn’t run.
  • Building a custom UI that constructs intents manually.
  • Tooling that batches multiple swaps into one signed transaction.
For everything else, Swaps is the right page.

Encoders

import { Conductor } from "@flashnet/sdk";

const calldata = Conductor.encodeSwap({
  tokenIn: "0x...",
  tokenOut: "0x...",
  fee: 3000,
  amountIn: 1_000_000n,
  minAmountOut: 950_000n,
});

// swapBTC is payable: msg.value carries the input amount.
// SwapBTCParams has no amountIn field.
const btcInCalldata = Conductor.encodeSwapBTC({
  tokenOut: "0x...",
  fee: 3000,
  minAmountOut: 950_000_000_000_000_000n,
});
The encoders return 0x-prefixed calldata. Wrap in an EIP-1559 transaction, sign, and submit through ExecutionClient.execute (which expects the RLP-hex of the signed tx, not the calldata directly). For encodeSwapBTC, set the transaction’s value to the input amount in wei (sats × WEI_PER_SAT = 10^10). For encodeSwap, set value: 0n.

Variants

TradingClient.swap picks one of ten Conductor methods automatically based on input asset, output asset, withdraw flag, and approval mode:
Input → OutputWithdrawApproval modeConductor method
token → tokenfalsen/aswap
BTC → tokenfalsen/aswapBTC
BTC → tokentruen/aswapBTCAndWithdraw
token → BTCtrueexactswapAndWithdrawBTC
token → tokentrueexactswapAndWithdraw
token → BTCtruepermit2swapAndWithdrawBTCWithPermit2
token → tokentruepermit2swapAndWithdrawWithPermit2
BTC → tokentrueEIP-2612 (useAvailableBalance)swapBTCAndWithdrawWithEIP2612
token → BTCtrueEIP-2612 (useAvailableBalance)swapAndWithdrawBTCWithEIP2612
token → tokentrueEIP-2612 (useAvailableBalance)swapAndWithdrawWithEIP2612
Permit2 and EIP-2612 are distinct schemes. Permit2 is the standalone Uniswap router (signed PermitTransferFrom); EIP-2612 is per-token (SparkToken implements it). The SDK only exports encodeSwap and encodeSwapBTC directly; the withdraw and permit variants are constructed inside TradingClient.

Custom errors

Conductor’s revert selectors are in CONDUCTOR_REVERT_ERRORS:
import { decodeRevertReason, CONDUCTOR_REVERT_ERRORS } from "@flashnet/sdk";

const decoded = decodeRevertReason(intent.statusMessage);
// e.g. { name: "TokensNotSorted()", selector: "0x6e8f1947", raw: "..." }
Common ones:
  • TokensNotSorted() — input/output addresses must be passed in canonical sort order.
  • PoolDoesNotExist() — wrong fee tier or pool not yet created.
  • InsufficientBTCValue()value doesn’t match amountIn for BTC swaps.
  • WBTCNotInPair() — BTC swap targeting a pool that doesn’t include WBTC.

Why this exists

Conductor is the integrator-facing contract for a Uniswap V3 deployment that lives on Flashnet Execution. It wraps the standard Uniswap router with Permit2 plumbing and Spark-side withdrawal sweeping so a single signed transaction can pull tokens in, swap, take fees, and dispatch the output back to Spark. The SDK abstracts all of that. This page exists so you can opt out when you need to.