Skip to main content

yield_prepare

Paid — $0.01 per call via x402.
Prepare yield intents with execution calldata. Handles deposits, redemptions, and rebalances. Operations:
  • deposit (default): Discover best vault, score, and return deposit calldata. For unconfigured EOAs, includes EIP-7702 setup.
  • redeem: Build execution module Redeem hook calldata for withdrawing from a vault position.
  • rebalance: Chain Redeem + Deposit hooks to move funds from one vault to a better one. Always returns the recommended vault strategy with APY, risk, and TVL data.

Parameters

operation
enum
Operation type: deposit into vault, redeem from vault, or rebalance between vaultsAllowed values: deposit, redeem, rebalanceDefault: "deposit"
asset
string
Asset to deposit (e.g., “USDC”). Required for deposit.
amount
string
Amount to deposit in human-readable form (e.g., “10000”). Required for deposit.
chain
enum
Target chainAllowed values: base, ethereum-sepoliaDefault: "base"
agentAddress
string
required
Agent’s EOA address
strategy
enum
Investment strategyAllowed values: maximize_apy, minimize_risk, balancedDefault: "balanced"
riskTolerance
enum
Risk tolerance levelAllowed values: low, medium, high
vaultId
string
Vault ID to redeem from or rebalance out of. Required for redeem and rebalance.
shares
string
Number of shares to redeem (as string for BigInt). Provide shares or percentage, not both.
percentage
number
Percentage of position to redeem. Provide shares or percentage, not both.

Response

The response varies based on whether your wallet needs first-time EIP-7702 setup.

Deposit — wallet already configured (needsSetup: false)

{
  "operation": "deposit",
  "intentId": "f3ab8fb8-4adb-4f0f-bcff-f38165d55f58",
  "needsSetup": false,
  "strategy": {
    "vaultName": "Morpho Blue USDC",
    "expectedAPY": 0.162,
    "riskScore": "low",
    "protocol": "Morpho Blue",
    "chain": "base",
    "tvl": 45000000
  },
  "execution": {
    "intentEnvelope": {
      "version": "1",
      "intentId": "f3ab8fb8-4adb-4f0f-bcff-f38165d55f58",
      "chainId": 8453,
      "entryPoint": "0x0000000071727De22E5E9d8BAf0edAc6f37da032",
      "sender": "0x...",
      "userOps": [{ "userOperation": { "sender": "0x...", "nonce": "0x1", "callData": "0x...", "signature": "0x1234" } }],
      "destinationExecutions": [],
      "expiry": 1739932000,
      "validAfter": 1739931100,
      "merkleRoot": "0x...",
      "proofs": [[]],
      "signing": { "domain": {}, "types": {}, "primaryType": "IntentEnvelope", "message": {} }
    },
    "to": "0x0000000071727De22E5E9d8BAf0edAc6f37da032",
    "calldata": "0x...",
    "estimatedGas": "300000"
  }
}

Deposit — first-time wallet (needsSetup: true)

{
  "operation": "deposit",
  "intentId": "a1b2c3d4-...",
  "needsSetup": true,
  "strategy": {
    "vaultName": "Morpho Blue USDC",
    "expectedAPY": 0.162,
    "riskScore": "low"
  },
  "setup": {
    "type": "eip7702",
    "description": "First-time EIP-7702 delegation required",
    "authorization": {
      "chainId": 8453,
      "address": "0x...",
      "nonce": "0x0"
    },
    "setupTransaction": {
      "to": "0x...",
      "data": "0x...",
      "value": "0x0",
      "type": "0x4"
    }
  }
}
When needsSetup is true, sign and submit the setup transaction first, then call yield_prepare again to get the execution payload.

Redeem

{
  "operation": "redeem",
  "intentId": "2db20fca-a844-442c-9267-624f47b2f1f7",
  "needsSetup": false,
  "execution": {
    "intentEnvelope": { "version": "1", "chainId": 8453, "userOps": [{ "userOperation": { "sender": "0x...", "callData": "0x..." } }], "merkleRoot": "0x...", "proofs": [[]] },
    "to": "0x0000000071727De22E5E9d8BAf0edAc6f37da032",
    "calldata": "0x...",
    "estimatedGas": "250000"
  }
}