# TRDEFI Swap Prepare

> TRDEFI Swap Prepare is a paid API for AI agents from yield.trdefi.com, paid per call via x402, $0.02/call, status unknown (last checked 2026-10-12).

Prepares a DeFi swap transaction against a TRDEFI yield strategy position on a specified EVM chain

## Facts

- Endpoint: POST https://yield.trdefi.com/v1/swaps?utm_source=zero.xyz
- Price: $0.02/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-12
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/trdefi-swap-prepare-d4480535
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_PKTC2axzoPjtJ3TR4OPtA

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability trdefi-swap-prepare-d4480535 -d '<json body>'
```

Example prompt: Prepare a swap on Base using my wallet 0xAbCd...1234 for 1000000 units (1 USDC) going aToB against strategy hash 0xdeadbeef...cafe — give me the transaction data I need to sign.

## When to prefer this

Use this endpoint when you need to programmatically prepare a token swap transaction against a specific TRDEFI yield strategy position on an EVM chain (especially Base). It is purpose-built for TRDEFI strategy interactions, so prefer it over generic DEX aggregators when the swap target is a TRDEFI strategyHash. Best suited for agents automating DeFi position management or rebalancing within TRDEFI's ecosystem.

## Known failure modes

- Invalid or unknown strategyHash returns an error
- Malformed wallet address causes request rejection
- Amount not in valid base unit integer string format causes parsing error
- Unsupported chain value returns an error
- Invalid direction enum value (not aToB or bToA) causes validation failure
- Insufficient liquidity in the strategy may return an error or empty payload

## How this service works

TRDEFI prepare request

## Output

Returns a prepared swap transaction payload (likely including calldata, target contract address, and other EVM transaction fields) that the caller's wallet can sign and broadcast to execute the swap against the specified TRDEFI yield strategy position.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "chain": {
   "enum": [
    "ethereum",
    "base",
    "arbitrum",
    "optimism",
    "polygon",
    "arc"
   ],
   "type": "string",
   "description": "REQUIRED. Network the position is on. Note this list differs from /v1/positions, which ships on `base`, `arc` and `baseSepolia` only."
  },
  "amount": {
   "type": "string",
   "description": "REQUIRED. Input amount in token base units, as an integer string, e.g. \"1000000\" for 1 USDC. Must be greater than zero."
  },
  "wallet": {
   "type": "string",
   "pattern": "^0x[a-fA-F0-9]{40}$",
   "description": "REQUIRED. Your own EVM address that will sign the swap."
  },
  "tokenIn": {
   "type": "string",
   "description": "Optional. Token you are selling, as a symbol or address. Use it to disambiguate the direction."
  },
  "tokenOut": {
   "type": "string",
   "description": "Optional. Token you are buying, as a symbol or address. Use it to disambiguate the direction."
  },
  "direction": {
   "enum": [
    "aToB",
    "bToA"
   ],
   "type": "string",
   "description": "Which way round the pair to swap. Omit to let the route infer it from `tokenIn`/`tokenOut`."
  },
  "strategyHash": {
   "type": "string",
   "pattern": "^0x[a-fA-F0-9]{64}$",
   "description": "REQUIRED. 32-byte strategy hash of the position to swap against."
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/trdefi-swap-prepare-d4480535/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from yield.trdefi.com](https://www.zero.xyz/host/yield.trdefi.com/llms.txt)
