{
  "id": "trail.spot.swap_and_buy_pt",
  "schemaVersion": "0.1.0",
  "name": "Spot: swap to underlying, buy Pendle PT",
  "summary": "Reusable spot-leg primitive: swap USDC (or any stable) to underlying asset via DEX aggregator, then buy a Pendle PT for fixed yield exposure. Composable inside delta-neutral trails.",
  "family": "syusd",
  "chains": ["ethereum", "base", "arbitrum"],
  "params": [
    { "name": "fromAsset",      "type": "address", "required": true, "description": "Funding asset (e.g. USDC)." },
    { "name": "underlyingAsset","type": "address", "required": true, "description": "Asset the PT is denominated in (e.g. USDe, stcUSD)." },
    { "name": "ptAsset",        "type": "address", "required": true, "description": "Pendle PT token address." },
    { "name": "pendleMarket",   "type": "address", "required": true, "description": "Pendle market address for the PT." },
    { "name": "amountIn",       "type": "uint256", "required": true, "description": "Amount of fromAsset to deploy (base units)." }
  ],
  "execution": {
    "mode": "atomic",
    "steps": [
      {
        "kind": "leaf",
        "description": "Approve DEX adapter to spend fromAsset.",
        "protocol": "magpie",
        "action": "approve",
        "args": { "asset": "$fromAsset" }
      },
      {
        "kind": "leaf",
        "id": "swap",
        "description": "Swap fromAsset → underlyingAsset via DEX aggregator.",
        "protocol": "magpie",
        "action": "swap_or_mint",
        "args": { "in": "$fromAsset", "out": "$underlyingAsset", "amountIn": "$amountIn" }
      },
      {
        "kind": "leaf",
        "description": "Approve Pendle router to pull underlying.",
        "protocol": "erc20",
        "action": "approve",
        "args": { "asset": "$underlyingAsset", "spender": "pendleRouter" }
      },
      {
        "kind": "leaf",
        "id": "buy",
        "description": "Buy PT on the Pendle market.",
        "protocol": "pendle",
        "action": "buy_pt",
        "args": { "market": "$pendleMarket", "amountUnderlying": "$swap.amountOut", "receiver": "$vault" }
      }
    ]
  },
  "preconditions": [
    "Vault has approve + swap + pendle.buy_pt leaves enabled for the involved assets.",
    "Pendle market hasn't matured (otherwise buy_pt reverts)."
  ],
  "risks": [
    "DEX slippage during swap reduces the PT amount.",
    "Pendle implied APY can move against the entry — locked until maturity unless the strategist sells PT back to YT-style position.",
    "If the PT is illiquid, exit liquidity at maturity is bottlenecked."
  ],
  "llm_doc": "Composable spot-leg primitive. Use this trail directly when the user just wants 'swap into PT and hold' for fixed-yield exposure. Composed inside trail.dn.pendle_hyperliquid as the spot side of a delta-neutral position. Atomic mode with no flashloan bracket — all 4 leaves run linearly inside one manage() call."
}
