Swap

Prepare a signed compatibility-swap transaction

Compatibility transaction-preparation endpoint. It requires a fresh successful simulationId, authenticates the customer wallet with EIP-191, validates the released provider boundary, and returns the exact prepared transaction payload.

FarmDash does not broadcast the returned compatibility-swap transaction. The customer wallet signs and submits the transaction directly to the target network. The chosen aggregator or router protocol (automatic multi-provider routing: same-chain LI.FI + Relay; cross-chain LI.FI + Relay; 0x is operator-paused until reinstated and is never primary or fallback) executes the swap.

Signature canonicalization: construct v1:FARMDASH_SWAP:{fromChainId}:{toChainId}:{fromToken}:{toToken}:{fromAmount}:{agentAddress}:{toAddress}:{nonce} after lowercasing every 0x-prefixed field, including token addresses. Sign the exact UTF-8 string with EIP-191/personal_sign. A 428 simulation-gate response is evaluated before signature verification and does not prove the signature is valid.

For LI.FI native ETH routes use the zero-address native-token sentinel, not the WETH contract.

Fee schedule (combined routing target; LI.FI 25 bps platform component deducted, not stacked; gas/slippage excluded): 50 bps under $10k, 45 bps at $10k+, 40 bps at $100k+, 30 bps at $1M+.

post/agents/swap

Request

  • Base URL: https://www.farmdash.one/api
  • URL: https://www.farmdash.one/api/agents/swap
  • Auth: one of:
    • HTTP bearer
    • none

Headers

X-ClawHub-Skillstring
Example:farmdash-signal-architect

ClawHub skill attribution. An installed FarmDash skill sends its canonical skill slug (e.g. farmdash-signal-architect) on every FarmDash API request so anonymous Scout usage can be attributed to the skill that drove it. Optional and analytics-only: absence never blocks a request, and malformed values are ignored. This is a skill identity, never a wallet address, API key, or user ID.

Request body

fromChainId1 | 10 | 137 | 8453 | 42161 | 59144 required
toChainId1 | 10 | 137 | 8453 | 42161 | 59144 required
fromTokenstring required
toTokenstring required
fromAmountstring required

Amount in wei

agentAddressstring required

Agent wallet address (signer)

toAddressstring required

Destination wallet for swapped tokens

slippagenumber

Slippage tolerance in percent (capped at 5%)

protocol'lifi' | 'relay'
volumeHintUSDnumber

Advisory telemetry only — never determines the fee tier. Fee BPS uses server-oracle-derived input volume exclusively (50 bps under $10k, 45 bps at $10k+, 40 bps at $100k+, 30 bps at $1M+ combined routing target); unknown volume pays the default tier.

expectedUpsideUsdnumber

Optional upside estimate in USD for positive-net-edge checks

riskBufferUsdnumber

Optional extra execution-risk buffer in USD

healthFactornumber

Optional lending health factor supplied by the caller

liquidationBufferPctnumber

Optional liquidation-buffer percentage supplied by the caller

walletAddressstring

Optional wallet address used for on-chain approval checks

safetyMode'strict' | 'balanced'
simulationIdstring required

Fresh successful simulation_id from POST /v1/simulate

intentIdstring

Optional qi_* quote-cache/idempotency identity; must match the simulation when supplied. Do not pass this value to /v1/simulate.

noncestring required

Current timestamp in milliseconds (60s window)

signaturestring required

EIP-191 personal_sign of the v1 versioned payload

Response

Executable swap with transaction calldata

protocol'lifi' | 'relay' required

Swap quote provider. Automatic routing compares all healthy compatible providers (LI.FI, Relay; 0x paused until reinstated); force one with ?protocol= (deterministic, never silent fallback).

estimatedOutputstring required
feeBpsinteger required
feeAmountUSDstring required
feeEventIdstring uuid

Use with /agents/confirm to confirm settlement

gasEstimatestring required
expiresAtinteger required
allowanceTargetstring nullable
gasEstimateUsdnumber nullable
bridgeFeeUsdnumber nullable
simulationobject
confirmUrlstring

Example response

{
  "confirmUrl": "/api/agents/confirm"
}

Changes

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