> ## 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.

# simulate_leverage

> Deterministic preview of a leveraged position — no wallet needed.

Previews the exact position that opening would produce. Deterministic and read-only — identical for ETH and ERC-20 pay tokens, with no on-chain call and no wallet.

## Input

<ParamField path="strategyId" type="string" required>Morpho market id of the strategy.</ParamField>

<ParamField path="payToken" type="string" required>
  Token you pay in. The collateral (opened directly) or any other token (zapped to collateral first). Native ETH = the zero address.
</ParamField>

<ParamField path="amount" type="string" required>Amount of `payToken` in human units, e.g. `"10000"`.</ParamField>
<ParamField path="leverage" type="number">Target leverage, e.g. `3`. Provide this **or** `desiredLtv`.</ParamField>
<ParamField path="desiredLtv" type="string">Target LTV percent, e.g. `"66.67"`. Provide this **or** `leverage`.</ParamField>
<ParamField path="slippage" type="number" default="0.005">Ratio; capped at `0.01`.</ParamField>

<ParamField path="chainId" type="integer" default="1" />

## Output

```json theme={null}
{
  "path": "swapAndLeverage",
  "positionPreview": {
    "leverage": "3.0",
    "requestedLtv": "66.67",
    "effectiveLtv": "66.73",
    "amountLeveragedCollateral": "52048.44",
    "expectedLeverageApy": "5.64",
    "priceImpactPct": "0.07"
  },
  "amountFlashLoan": "…",
  "minTokenOut": "…",
  "reallocationFeeWei": null,
  "slippage": 0.005
}
```

## Example

```ts theme={null}
const sim = await call("simulate_leverage", {
  strategyId, payToken, amount: "50000", leverage: 8,
});
// sim.positionPreview.expectedLeverageApy
```

<Tip>
  Always simulate before building. The preview comes from a live swap quote, so numbers move with prices — treat it as current, not fixed.
</Tip>
