Skip to main content

POST /v1/yield/prepare

Pricing policy — $0.01 per call via x402 when payment enforcement is enabled. Current pre-prod deployment keeps x402 disabled. When enforced, attach the X-PAYMENT header.
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 calldata for withdrawing from a vault position.
  • rebalance: 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: active chain keys from rhaios-config.yaml for the deployment. Current pre-prod profile supports ethereum and base.Default: "base"
agentAddress
string
required
Agent’s EOA address
vaultId
string
required
Target vault ID from yield_discover. Required for all operations.
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.

Example

curl -X POST https://api.staging.rhaios.com/v1/yield/prepare \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "deposit",
    "asset": "USDC",
    "amount": "1000",
    "agentAddress": "0x...",
    "vaultId": "42"
  }'
With x402 payment (when enforced):
curl -X POST https://api.staging.rhaios.com/v1/yield/prepare \
  -H "Content-Type: application/json" \
  -H "X-PAYMENT: <x402-payment-proof>" \
  -d '{
    "operation": "deposit",
    "asset": "USDC",
    "amount": "1000",
    "agentAddress": "0x...",
    "vaultId": "42"
  }'

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": "Aave V3 USDC",
    "expectedAPY": 0.162,
    "riskScore": "low",
    "protocol": "Aave V3",
    "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, full setup (needsSetup: true, setupType: "full")

{
  "operation": "deposit",
  "intentId": "a1b2c3d4-...",
  "needsSetup": true,
  "strategy": {
    "vaultName": "Aave V3 USDC",
    "expectedAPY": 0.162,
    "riskScore": "low"
  },
  "setup": {
    "setupType": "full",
    "description": "First-time EIP-7702 delegation + module initialization",
    "authorization": {
      "contractAddress": "0x...",
      "chainId": 8453
    },
    "initCalldata": "0x...",
    "to": "0x..."
  },
  "setupTicket": {
    "version": 1,
    "walletAddress": "0x...",
    "chainId": 8453,
    "implementation": "0x...",
    "initCalldataHash": "0x...",
    "setupType": "full",
    "expiresAt": "2025-03-01T00:00:00.000Z"
  }
}

Deposit — module re-initialization (needsSetup: true, setupType: "modules")

When delegation already exists but modules failed to initialize (e.g., initializeAccount() reverted silently in a prior setup attempt):
{
  "operation": "deposit",
  "intentId": "e5f6g7h8-...",
  "needsSetup": true,
  "strategy": {
    "vaultName": "Aave V3 USDC",
    "expectedAPY": 0.162,
    "riskScore": "low"
  },
  "setup": {
    "setupType": "modules",
    "description": "Module initialization only. Delegation already active — send as regular transaction (type 2), not Type-4.",
    "authorization": null,
    "initCalldata": "0x...",
    "to": "0x..."
  },
  "setupTicket": {
    "version": 1,
    "walletAddress": "0x...",
    "chainId": 8453,
    "implementation": "0x...",
    "initCalldataHash": "0x...",
    "setupType": "modules",
    "expiresAt": "2025-03-01T00:00:00.000Z"
  }
}
When needsSetup is true, sign and submit the setup transaction first, then call POST /v1/yield/prepare again to get the execution payload. For setupType: "full", sign a Type-4 (EIP-7702) transaction with authorization_list. For setupType: "modules", sign a regular Type-2 (EIP-1559) self-call transaction.

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"
  }
}