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

> Build the unsigned transaction to adjust or close an open position.

Returns the unsigned payload to adjust or unwind an **open** position, for the owner to sign. Same non-custodial model and output shape as [`build_leverage_tx`](/agents/tools/build-leverage-tx).

## Actions

<ParamField path="action" type="string" required>
  One of:

  * `close` — unwind the position fully.
  * `increase_leverage` — borrow to a higher LTV (provide `desiredLtv` or `leverage`).
  * `add_collateral` — top up (provide `payToken` + `amount`; pay in collateral or any token).
  * `remove_collateral` — withdraw collateral (provide `amount`).
  * `repay` — pay down debt (provide `payToken` + `amount`; set `full: true` to clear it).
  * `borrow` — draw more loan token (provide `amount`).
</ParamField>

## Input

<ParamField path="userAddress" type="string" required>Wallet that owns the position and will sign.</ParamField>
<ParamField path="id" type="integer" required>On-chain position index — from [`get_positions`](/agents/tools/get-positions).</ParamField>
<ParamField path="amount" type="string">Human units. Required for add/remove/repay/borrow.</ParamField>
<ParamField path="payToken" type="string">Token to pay in (add\_collateral / repay).</ParamField>
<ParamField path="full" type="boolean">`repay` only — clear the entire remaining debt.</ParamField>
<ParamField path="desiredLtv" type="string">`increase_leverage` target LTV percent.</ParamField>
<ParamField path="leverage" type="number">`increase_leverage` target leverage.</ParamField>

<ParamField path="slippage" type="number" default="0.005" />

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

## Example

```ts theme={null}
// Close position 0
const bundle = await call("build_manage_tx", { userAddress, id: 0, action: "close" });
// Send bundle.approvals (if any), then bundle.tx
```

<Note>
  Verify the result with [`get_positions`](/agents/tools/get-positions) after the transaction confirms.
</Note>
