> ## Documentation Index
> Fetch the complete documentation index at: https://docs.glider.fi/llms.txt
> Use this file to discover all available pages before exploring further.

# Execute Swap

> Execute a client-quoted LiFi swap, backend-quoted LiFi swap, or feature-gated Ondo Direct market order for a portfolio vault via v2 actions.

`v2.portfolio.actions.submit` supports client-quoted LiFi swaps,
backend-quoted LiFi swaps, and feature-gated Ondo Direct EVM market orders.

`kind: "swap"` submits a client-supplied `RouteExtended`:

* `chainId` (string, required): execution chain for the submitted route.
* `executionConstraints` (object, optional): additive backend-side settlement
  guards for stricter callers such as Investing Account manual trades.
  * `sameChainOnly` (boolean, optional): rejects multi-chain routes.
  * `expectedVaultChainId` (string, optional): requires the route to execute on
    that chain and settle into the authenticated portfolio's exact vault on
    that chain.
* `route` (RouteExtended, required): precomputed LiFi route payload.
* `slippageBps` (integer, optional): per-trade slippage override in basis
  points (`0` to `1000`). When provided, this overrides user preference and
  default fallback slippage for that trade.

`kind: "swap"` with `params.provider: "ondo_direct"` submits a confirmed Ondo
Direct quote:

* `chainId` (string, required): Ondo Direct execution chain.
* `sellTokenAddress` (EVM address, required)
* `buyTokenAddress` (EVM address, required)
* `sellAmount` (raw integer string, required)
* `recipientAddress` (EVM address, required): must be an owned vault on the
  requested chain.
* `expectedReceiveAmount` (raw integer string, required): pass the
  `estimatedReceiveAmount` returned by
  `v2.portfolio.actions.previewOndoDirectQuote`; the engine rejects firm quotes
  that fall outside its server-side deviation guard and fails closed if it is
  absent.

`kind: "swap_backend_quote"` submits raw quote parameters and lets the backend
fetch the LiFi route inside engine before execution:

* `fromChainId` (string, required)
* `fromTokenAddress` (string, required)
* `fromAmount` (string, required)
* `toChainId` (string, required)
* `toTokenAddress` (string, required)
* `toAddress` (string, required): must be owned by the authenticated user or
  one of their owned vaults
* `slippageBps` (integer, optional): overrides only slippage while backend
  quoting still uses saved user or portfolio swap preferences plus server
  defaults for the remaining route settings

Both modes return a canonical `swap` execution handle. Use:

* `v2.executions.get` for lightweight summary polling
* `v2.executions.detail` for the persisted execution timeline
* `v2.executions.result` for terminal machine output
* `v2.executions.stream` for canonical realtime execution events over subscriptions
* `GET /v1/executions/:operationId/stream` for direct SSE consumers such as CLIs,
  external integrations, or chat surfaces
* `GET /v1/ai/executions/:operationId/ag-ui-stream` for TanStack AI / AG-UI
  consumers that want standard AG-UI event chunks over SSE

<Note>
  This tRPC endpoint requires an authenticated wallet session (SIWE).
</Note>

<RequestExample>
  ```bash cURL theme={null}
  # Client-quoted route execution
  curl --request POST \
    --url 'https://api.glider.fi/v1/trpc/v2.portfolio.actions.submit' \
    --header 'Content-Type: application/json' \
    --data '{
      "input": {
        "portfolioId": "portfolio-123",
        "kind": "swap",
        "params": {
          "chainId": "8453",
          "executionConstraints": {
            "sameChainOnly": true,
            "expectedVaultChainId": "8453"
          },
          "slippageBps": 250,
          "route": {
            "id": "lifi-route-id",
            "fromChainId": 8453,
            "toChainId": 8453,
            "steps": [
              {
                "id": "step-0",
                "action": {
                  "fromChainId": 8453,
                  "toChainId": 8453
                }
              }
            ]
          }
        },
        "requestId": "optional-request-id",
        "correlationId": "optional-correlation-id"
      }
    }'
  ```
</RequestExample>

<RequestExample>
  ```bash cURL theme={null}
  # Ondo Direct market order execution after previewOndoDirectQuote
  curl --request POST \
    --url 'https://api.glider.fi/v1/trpc/v2.portfolio.actions.submit' \
    --header 'Content-Type: application/json' \
    --data '{
      "input": {
        "portfolioId": "portfolio-123",
        "kind": "swap",
        "params": {
          "provider": "ondo_direct",
          "chainId": "1",
          "sellTokenAddress": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
          "buyTokenAddress": "0x1111111111111111111111111111111111111111",
          "sellAmount": "1000000",
          "recipientAddress": "0x2222222222222222222222222222222222222222",
          "expectedReceiveAmount": "5000000000000000000"
        },
        "requestId": "optional-request-id",
        "correlationId": "optional-correlation-id"
      }
    }'
  ```
</RequestExample>

<RequestExample>
  ```bash cURL theme={null}
  # Backend-quoted swap execution
  curl --request POST \
    --url 'https://api.glider.fi/v1/trpc/v2.portfolio.actions.submit' \
    --header 'Content-Type: application/json' \
    --data '{
      "input": {
        "portfolioId": "portfolio-123",
        "kind": "swap_backend_quote",
        "params": {
          "fromChainId": "8453",
          "toChainId": "1",
          "fromTokenAddress": "0x0000000000000000000000000000000000000001",
          "toTokenAddress": "0x0000000000000000000000000000000000000002",
          "fromAmount": "1000000",
          "toAddress": "0x1111111111111111111111111111111111111111",
          "slippageBps": 150
        },
        "requestId": "optional-request-id",
        "correlationId": "optional-correlation-id"
      }
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {
    "result": {
      "data": {
        "operationId": "op_123",
        "state": "accepted",
        "refs": {
          "eventId": "evt_123"
        }
      }
    }
  }
  ```
</ResponseExample>
