positions

Prepare a swap — returns UNSIGNED transactions for your wallet to sign

Swap against a maker position that is already shipped. The 0.05% protocol fee rides inside the maker's order, so every swap that executes pays it without anything extra being asked of you.

Preflight first. The swap is simulated on-chain. If it cannot succeed — a gated strategy, an amount the maker cannot fill, an insufficient balance — the response says which, and returns no transactions at all. A wallet is never handed a transaction that is certain to revert.

Approval only when needed. The approve step appears only if your live allowance is short, so the same request is sometimes one transaction and sometimes two.

Networks. ethereum, base, arbitrum, optimism, polygon, arc. The Base Sepolia demo has its own user-signed flow on the app and is deliberately not served here.

The client signs. We never sign, never broadcast and never hold a key.

post/v1/swaps

Request

  • Base URL: https://yield.trdefi.com
  • URL: https://yield.trdefi.com/v1/swaps
  • Auth: HTTP bearer

Request body

chain'ethereum' | 'base' | 'arbitrum' | 'optimism' | 'polygon' | 'arc' required

Network key.

walletstring required

The address that will sign. It must be yours.

strategyHashstring required

The maker position to swap against.

amountstring required

Input amount in base units, as an integer string.

direction'aToB' | 'bToA'

Ignored when tokenIn and tokenOut are given.

tokenInstring

Optional explicit input token.

tokenOutstring

Optional explicit output token.

Example request

{
  "amount": "1000000"
}

Response

Prepared swap. Inert: nothing has been signed or broadcast.

Example response

{
  "meta": {
    "apiVersion": "v1"
  }
}

Changes

No recorded changes to this operation across all 1 revision of this API.