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

# Build rebalance operation

> Move funds between yield providers using an unsigned Solana transaction.

Create a rebalance to move funds between `jupiter_lend` and `kamino` (or refresh the same protocol). The response contains an unsigned transaction to sign and broadcast.

```http theme={null}
PATCH /yield/rebalance
```

<Steps>
  <Step title="Request body">
    | Parameter      | Type   | Required | Description                                                |
    | -------------- | ------ | -------- | ---------------------------------------------------------- |
    | `chain_name`   | string | ✅        | Network (e.g. `solana`)                                    |
    | `amount`       | string | ✅        | Decimal amount to move (`> 0`)                             |
    | `wallet`       | string | ✅        | User's wallet public key                                   |
    | `asset`        | string | ✅        | Token symbol (e.g. `USDC`)                                 |
    | `provider_out` | string |          | Withdraw leg: `jupiter_lend` or `kamino`                   |
    | `provider_in`  | string |          | Deposit leg: `jupiter_lend` or `kamino`                    |
    | `provider`     | string |          | When both legs use the same protocol, send only this field |

    <Info>
      Provide `provider_in` + `provider_out`, or a single `provider` when both legs are the same protocol.
    </Info>
  </Step>

  <Step title="Request example">
    ```shellscript theme={null}
    curl --request PATCH \
      --url https://api.starkfi.io/yield/rebalance \
      --header 'Content-Type: application/json' \
      --header 'x-api-key: <api_key>' \
      --data '{
        "chain_name": "solana",
        "wallet": "FmTGYpzX27fDqaiytXUdFVaphC5o68G61Q3uhVM2d8bm",
        "asset": "USDC",
        "amount": "0.01",
        "provider_out": "kamino",
        "provider_in": "jupiter_lend"
      }'
    ```
  </Step>

  <Step title="Expected response">
    ```json theme={null}
    {
      "statusCode": 200,
      "success": true,
      "status": "rebalance_yield_strategy_ok",
      "message": "Yield strategy rebalanced successfully",
      "data": {
        "mode": "single_transaction",
        "transaction": "<base64_unsigned_versioned_tx>"
      }
    }
    ```

    When instructions fit in one packet, `mode` is `single_transaction` and `transaction` holds the unsigned wire. Larger rebalances may return separate transactions — sign each and pass an array to yield broadcast if using StarkFi relay.
  </Step>

  <Step title="Sign and broadcast">
    Sign the returned wire(s), then broadcast on your RPC or optionally via [`POST /yield/broadcast`](/broadcast-your-operations).
  </Step>
</Steps>
