# Validation and Safety

The swap client ports comprehensive pre-flight checks originally implemented in the Rust reference flow. These safety layers ensure that malformed or invalid swap parameters are rejected before any transaction reaches the chain:

**Input Validation:** Validates `amount`, `slippage`, `tips`, `swapMode`, and `gasLevel` against expected ranges and formats through dedicated utilities such as `validateAmount`, `validateSlippage`, and `validateGasLevel`.

**Token Resolution:** Resolves chain-specific token aliases via `resolveSwapTokenAddress` and rejects same-token swaps that would result in no-ops.

**Address Safety:** Checks EVM versus Solana address shape mismatches through `validateAddressForChain` to prevent cross-ecosystem routing errors.

**Precision Safety:** Converts human-readable amounts to minimal units via `readableToMinimalString` without floating-point math, eliminating rounding drift on decimal-sensitive tokens.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://city-protocol.gitbook.io/docs/neofinance-as-a-service/swap-module/validation-and-safety.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
