> ## 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 (yield)

> Move funds between protocols with an unsigned Solana transaction.

<ParamField header="x-api-key" type="string" required placeholder="your-api-key">
  Your StarkFi API key.
</ParamField>

<ParamField body="chain_name" type="string" required>
  Enabled chain, e.g. `solana`.
</ParamField>

<ParamField body="amount" type="string" required>
  Must parse to a finite number greater than zero.
</ParamField>

<ParamField body="wallet" type="string">
  User pubkey (or use `signer`).
</ParamField>

<ParamField body="signer" type="string">
  Alias of `wallet`.
</ParamField>

<ParamField body="asset" type="string">
  Token symbol (or use `symbol`, `token_mint`, `mint`).
</ParamField>

<ParamField body="provider_out" type="enum<string>">
  Withdraw leg: `jupiter_lend` or `kamino` (use with `provider_in`).
</ParamField>

<ParamField body="provider_in" type="enum<string>">
  Deposit leg: `jupiter_lend` or `kamino` (use with `provider_out`).
</ParamField>

<ParamField body="provider" type="enum<string>">
  When both legs use the **same** protocol, send only this field.
</ParamField>

<RequestExample>
  ```bash cURL 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": "10.0",
      "provider_out": "kamino",
      "provider_in": "jupiter_lend"
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 - Success theme={null}
  {
    "statusCode": 200,
    "success": true,
    "status": "rebalance_yield_strategy_ok",
    "message": "Yield strategy rebalanced successfully",
    "data": {
      "mode": "single_transaction",
      "transaction": "AQAAAAA..."
    }
  }
  ```

  ```json 413 - Payload Too Large theme={null}
  {
    "statusCode": 413,
    "success": false,
    "status": "rebalance_transaction_too_large",
    "message": "..."
  }
  ```

  ```json 400 - Bad Request theme={null}
  {
    "statusCode": 400,
    "success": false,
    "status": "invalid_parameters",
    "message": "informe provider ou provider_in + provider_out"
  }
  ```
</ResponseExample>

### Response

<ResponseField name="data.mode" type="string">
  `single_transaction` when instructions fit in one packet.
</ResponseField>

<ResponseField name="data.transaction" type="string">
  Base64 unsigned Solana wire. Sign and broadcast on your RPC, or optionally via [Broadcast yield](/broadcast).
</ResponseField>
