yieldaggregator

Swap

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)

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

Request body

yieldAggregatorId'5200' | '5201' | '5202' | '5203' | '5204'

The unique identifier used to route queries or transactions to the correct yield aggregator.

marketAddressstring 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.

fromstring 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.

pathstring[] 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'].

amountInstring 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".

slippagestring

The maximum allowable percentage deviation between the expected and executed swap price. Default is 1, meaning a 1% tolerance (acceptable range: 0 to 100).

gasstring

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.

enableAggregatorboolean

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.

gasPrioritystring

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.

enableFeeboolean

Flag to include a basis points fee transaction alongside the main transaction when set to true.

Example request

{
  "yieldAggregatorId": "5200",
  "marketAddress": "0xcdd26eb5eb2ce0f203a84553853667ae69ca29ce",
  "from": "0xdAe2F6EdDdA6fb4fb60cc02633DE27e2b431B402",
  "path": [
    "0x514910771AF9Ca656af840dff83E8264EcF986CA",
    "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
  ],
  "amountIn": "1000000000000000000",
  "slippage": "10",
  "gas": "100000",
  "enableAggregator": false,
  "gasPriority": "low",
  "enableFee": false
}

Response

Successful response

statusinteger
msgstring
dataobject

Example response

{
  "status": 200,
  "msg": "success",
  "data": {
    "chainId": "1",
    "from": "0xdae2f6eddda6fb4fb60cc02633de27e2b431b402",
    "to": "0x888888888889758F76e7103c6CbF23ABbF58F946",
    "value": "0",
    "gas": "1000000",
    "data": "0x2a50917c000000000000000000000000dae2f6eddda6fb4fb60cc02633de27e2b431b402000000000000000000000000b451a36c8b6b2eac77ad0737ba732818143a0e250000000000000000000000000000000000000000000000008ac7230489e8000000000000000000000000000000000000000000000000000089f69f2983fe3071000000000000000000000000000000000000000000000000489cbf8f1d0c8549000000000000000000000000000000000000000000000000b587dee5c89f4d3600000000000000000000000000000000000000000000000091397f1e3a190a92000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000005af3107a400000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    "estimationCheck": "Returned error: execution reverted: ERC20: insufficient allowance",
    "referenceId": "8d5b7f177bf541d385f723d4891a792e"
  }
}

Changes

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