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

# build_leverage_tx

> Build the unsigned transaction to open a leveraged position.

Returns the canonical **unsigned** payload to open a position, for the given wallet to sign. Non-custodial — the server never signs, sends, or holds keys. It auto-selects the open path (direct vs. zap-swap, and public-allocator reallocation when liquidity is thin) in the background, just like the app.

## Input

Same as [`simulate_leverage`](/agents/tools/simulate-leverage), plus:

<ParamField path="userAddress" type="string" required>
  The wallet that will sign. Approvals and `onBehalfOf` are built for it.
</ParamField>

## Output

```json theme={null}
{
  "chainId": 1,
  "action": "open_leverage",
  "path": "swapAndLeverage",
  "approvals": [{ "to": "0x…token", "data": "0x…" }],
  "tx": { "to": "0x…router", "data": "0x…", "value": "0" },
  "meta": {
    "positionPreview": { "leverage": "3.0", "effectiveLtv": "66.7" },
    "amountFlashLoan": "…",
    "minTokenOut": "…",
    "expiresAt": "2026-01-01T00:01:00.000Z",
    "signingUrl": "https://app.spiralstake.xyz/1/strategies/0x…?leverage=66.67&amount=50000&payToken=0x…"
  }
}
```

## Executing

<Steps>
  <Step title="Approvals first">Sign and send each entry in `approvals[]` (none for native ETH).</Step>
  <Step title="Then the tx">Sign and send `tx` from `userAddress`.</Step>
  <Step title="Or hand off the link">Give the user `meta.signingUrl` to review and sign in the Spiral app.</Step>
</Steps>

<Warning>
  `meta.expiresAt` — the embedded swap calldata is time-sensitive (\~60s). If it lapses before signing, rebuild. See [Non-custodial execution](/agents/concepts/non-custodial).
</Warning>
