{"uid":"cap_PKTC2axzoPjtJ3TR4OPtA","slug":"trdefi-swap-prepare-d4480535","name":"TRDEFI Swap Prepare","description":"TRDEFI prepare request","url":"https://yield.trdefi.com/v1/swaps?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"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."}}},"responseSchema":null,"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.02","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.02/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.02","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.02","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_KbJfmAIQ8ZmEcFWPAHk6Y","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.02","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Prepares a DeFi swap transaction against a TRDEFI yield strategy position on a specified EVM chain","exampleAgentPrompt":"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.","exampleUseCases":[{"title":"Swap tokens on Base yield strategy","prompt":"I want to swap 5000000 USDC (in base units) aToB on the Base network against strategy hash 0xabc123...def456 using my wallet 0x742d35Cc...8912 — prepare the swap transaction for me."},{"title":"Reverse swap from DeFi position","prompt":"Prepare a bToA swap on the Base chain for 2000000 base units using wallet 0x1234abcd...5678 against TRDEFI strategy 0xfeedface...9876 so I can unwind my position."},{"title":"Automate yield strategy rebalancing","prompt":"Every time my TRDEFI strategy 0xdeadcafe...1111 drifts out of balance, prepare a swap for 500000 base units in the aToB direction on Base using wallet 0x9988aabb...ccdd so I can rebalance automatically."}],"resultDescription":"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.","failureModes":["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"],"whenToPreferThis":"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.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-12T06:38:35.926Z","isFirstParty":false,"canonicalSlug":"trdefi-swap-prepare-d4480535"}