---
title: "Swap"
method: POST
path: "/defi/v1/yieldaggregator/swap"
tags: ["yieldaggregator"]
---

# Swap

`POST /defi/v1/yieldaggregator/swap`

## Request

- Base URL: `https://svc.blockdaemon.com`
- URL: `https://svc.blockdaemon.com/defi/v1/yieldaggregator/swap`
- Auth: API key in header `X-API-Key`

Executes token swaps within a yield aggregator protocol, providing transaction metadata (chain ID, addresses, gas, reference ID). Configurable slippage, swap path, and gas priority let users tailor swaps to market conditions.

> 💡 
**Compute Unit Value:** `95` (Fixed)

## Request body

- YieldaggregatorSwapRequest: The request body for a /defi/v1/yieldaggregator/swap
  - `yieldAggregatorId` '5200' | '5201' | '5202' | '5203' | '5204': The unique identifier used to route queries or transactions to the correct yield aggregator.
  - `marketAddress` string, required: The blockchain address of the source yield market from which the tokens will be swapped. This address directs the swap to the appropriate liquidity pool within the aggregator.
  - `from` string, required: Blockchain address of the sender. For EVM chains, use a checksummed hex address (e.g., 0xABCDEF...). This address must hold sufficient balance and will sign the transaction.
  - `path` string[], required: Ordered array of token contract addresses defining the swap route from input to output. Provide [tokenInAddress, tokenOutAddress] for a direct swap. Example (WETH→USDC): ['0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'].
  - `amountIn` string, required: Amount of the input token to provide, specified in the token's smallest denomination (base units). Do not send human-readable decimal values. Examples: to swap 1 WETH (18 decimals), use "1000000000000000000"; to swap 1 USDC (6 decimals), use "1000000".
  - `slippage` string: The maximum allowable percentage deviation between the expected and executed swap price. Default is 1, meaning a 1% tolerance (acceptable range: 0 to 100).
  - `gas` string: Maximum number of gas units to allocate for the transaction, as an integer string (e.g., '200000'). If omitted, gas is estimated automatically. Note: this is gas units, not wei or gwei.
  - `enableAggregator` boolean: Enable swap aggregator functionality to facilitate swaps between tokens that are not directly convertible with the underlying asset. Set this boolean flag to true to activate advanced routing logic for such conversions.
  - `gasPriority` string: Specifies the desired gas fee priority for the transaction. Acceptable values include 'low', 'medium', or 'high', and this setting can influence the speed and cost of the swap.
  - `enableFee` boolean: Flag to include a basis points fee transaction alongside the main transaction when set to true.

## Response `200`

Successful response

- object
  - `status` integer
  - `msg` string
  - `data` object

---

[API](https://skmtc.dev/blockdaemon/apis/blockdaemon-defi-api.md) - [All operations](https://skmtc.dev/blockdaemon/apis/blockdaemon-defi-api/llms.txt) - [OpenAPI document](https://skmtc.dev/blockdaemon/apis/blockdaemon-defi-api/revisions/ec053b7c8041?raw)
