> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dzap.io/llms.txt
> Use this file to discover all available pages before exploring further.

# TypeScript Types

> Key request and response interfaces for the DZap SDK

Reference for the main types used with `getTradeQuotes`, `trade`, `buildTradeTxn`, and `getAllowance`. Import from `@dzapio/sdk`.

## Trade quotes

### TradeQuotesRequest

```typescript theme={null}
type TradeQuotesRequest = {
  fromChain: number;
  gasless?: boolean;
  private?: boolean;
  data: TradeQuotesRequestData[];
  disableEstimation?: boolean;
  account?: string;
  bridges?: ProtocolFilter;
  dexes?: ProtocolFilter;
  filter?: QuoteFilter;
  timingStrategy?: Partial<{ minWaitTimeMs; maxWaitTimeMs; subsequentDelayMs; preferredResultCount; relaxMinSuccessOnDelay }>;
};
```

### TradeQuotesRequestData

```typescript theme={null}
type TradeQuotesRequestData = {
  amount: string;        // wei as string
  srcToken: string;
  srcDecimals?: number;
  destToken: string;
  destDecimals?: number;
  toChain: number;
  slippage: number;
  selectedSource?: string;
};
```

### TradeQuotesResponse

Returned directly by `getTradeQuotes()` (object keyed by pair key):

```typescript theme={null}
type TradeQuotesResponse = {
  [pair: string]: {
    status?: string;
    message?: string;
    recommendedSource: string;
    fastestSource?: string;
    bestReturnSource: string;
    questSource?: string;
    quoteRates?: TradeQuotesByProviderId;
    tokensWithoutPrice: Record<number, string[]>;
  };
};
```

Use `recommendedSource ?? bestReturnSource` when building trade data.

## Trade build & execute

### TradeBuildTxnRequest

```typescript theme={null}
type TradeBuildTxnRequest = {
  sender: HexString;
  refundee: HexString;
  fromChain: number;
  gasless: boolean;
  private?: boolean;
  disableEstimation?: boolean;
  data: TradeBuildTxnRequestData[];
  hasPermit2ApprovalForAllTokens?: boolean;
  publicKey?: string; // Bitcoin chains only
};
```

### TradeBuildTxnRequestData

```typescript theme={null}
type TradeBuildTxnRequestData = {
  amount: string;
  srcToken: string;
  srcDecimals?: number;
  destToken: string;
  destDecimals?: number;
  toChain: number;
  protocol: string;   // from quote recommendedSource or bestReturnSource
  recipient: string;
  slippage: number;
  additionalInfo?: AdditionalInfo;
  permitData?: string;
};
```

### TradeBuildTxnResponse (buildTradeTxn / build response, non-gasless)

Returned by `buildTradeTxn(request)` (when `gasless: false`) and passed as `txnData` to `trade()`. `transaction` is the chain-specific payload; several fields are also mirrored at the top level for backwards compatibility (`@deprecated`, EVM-only):

```typescript theme={null}
type TradeBuildTxnResponse = {
  status: "success";
  txId: string;        // Build/transaction ID
  chainId: number;
  transaction: EvmTxData | SvmTxData | BtcTxData | BtclnTxData | HyperLiquidTxData;
  gasless: false;
  private: boolean;
  quotes: Record<string, ParamQuotes>;

  // @deprecated top-level mirror of transaction, EVM only:
  data: string;
  from: string;
  to?: string;
  value?: string;
  gasLimit?: string;

  svmTxData?: { blockhash: string; lastValidBlockHeight: number };
  btcTxData?: { inputs: PsbtInput[]; outputs: PsbtOutput[]; feeRate: number };
  btclnTxData?: { paymentRequestType: "bolt11"; paymentRequest: string; paymentExpiry: number };
  additionalInfo: Record<string, Record<string, unknown>>;
  updatedQuotes: Record<string, string>;
};

type EvmTxData = { from: HexString; data: HexString; to: HexString; value: string; gasLimit: string };

type ParamQuotes = {
  additionalInfo?: Record<string, unknown>;
  destAmount: string;
  provider: string;
  minDestAmount: string;
  priceImpact?: string | null;
  duration?: string;
};
```

When `gasless: true` is requested instead, the response is a `GaslessTradeBuildTxnResponse`:

```typescript theme={null}
type GaslessTradeBuildTxnResponse = {
  status: "success";
  txId: HexString;
  transaction: BridgeGaslessTxData | SwapGaslessTxData;
  quotes: Record<string, ParamQuotes>;
  gasless: true;
  onlySwapData: false;
};
```

### DZapTransactionResponse (trade / zap execution result)

```typescript theme={null}
type DZapTransactionResponse = {
  status: TxnStatus;
  errorMsg?: string;
  code: StatusCodes | number;
  action?: "TRY_ANOTHER_ROUTE" | "INCREASE_SLIPPAGE" | "INCREASE_ALLOWANCE";
  txnHash?: HexString;
  error?: unknown;
  additionalInfo?: Record<string, unknown>;
  updatedQuotes?: Record<string, string>;
};
```

## Allowance

`getAllowance()` returns `{ status, code, data }`. `data` is keyed by token address — there is no `approvalNeeded`/`signatureNeeded` field; derive those from `allowance`/`type`:

```typescript theme={null}
// data shape (per token address)
type AllowanceDataEntry = {
  allowance: bigint;
  type: "dzap" | "permit2" | "eip2612";
};

// Example: check if any token needs an on-chain approval
const data = allowanceCheck.data ?? {};
const needsApproval = tokens.some((t) => {
  const entry = data[t.address];
  return entry && entry.type !== "eip2612" && entry.allowance < BigInt(t.amount);
});
// "permit2" and "eip2612" types both additionally require a sign() call before executing
const needsSignature = tokens.some((t) => data[t.address]?.type !== "dzap");
```

## HexString

Addresses and hashes use the type `HexString` = `` `0x${string}` ``.

## Next steps

* [Enums reference](/sdk/reference/enums)
* [Errors reference](/sdk/reference/errors)
* [Execute trade](/sdk/trade/execute-trade)
* [Approvals](/sdk/approvals)
