> For the complete documentation index, see [llms.txt](https://city-protocol.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://city-protocol.gitbook.io/docs/software-development-kit/swap/execution-and-validation.md).

# Execution & Validation

### Execution

#### executeSwap

Orchestrates the entire swap flow in a single call: approval lookup, revoke-then-approve for stale USDT-like allowances, swap transaction build, and final execution. The SDK remains transport-agnostic — you supply an `executeTransaction` callback that handles signing and broadcasting.

```
const result = await swapClient.executeSwap({
  chainIndex: "1",
  fromToken: "USDC",
  toToken: "WETH",
  amount: "100000000",
  walletAddress: "0xYourWallet",
  gasLevel: "average",
  executeTransaction: async (request) => {
    return sendSwapTransactionThroughWallet(request);
  },
});
```

**Callback payload.** The `executeTransaction` callback receives a request object with the following fields, mirroring the Rust `wallet_contract_call` flow: `to`, `chainIndex`, `value`, `data`, `unsignedTx`, `gasLimit`, `aaDexTokenAddress`, `aaDexTokenAmount`, `mevProtection`, and `jitoUnsignedTx`.

**Response shape.** `executeSwap` returns:

```
{
  approveTxHash: string | null;
  swapTxHash: string;
  fromToken: unknown;
  toToken: unknown;
  fromAmount: unknown;
  toAmount: unknown;
  priceImpact: unknown;
  gasUsed: unknown;
}
```

All other methods (quote, build, approval, chain, liquidity) return the aggregator `data` payload directly.

***

### Validation Utilities

The SDK ports the Rust pre-flight checks into TypeScript, so invalid inputs are caught before any network call. These validators normalize amounts without floating-point math, resolve chain-specific token aliases, reject same-token swaps, and guard against EVM-vs-Solana address shape mismatches.

Useful named exports include: `resolveSwapTokenAddress`, `readableToMinimalString`, `validateAmount`, `validateApproveAmount`, `validateSlippage`, `validateSwapMode`, `validateGasLevel`, `validateTips`, `validateAddressForChain`, and `isAllowanceInsufficient`.
