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

# Supply

> POST /v1/operations/supply — Plan a supply operation

<Note>
  **Endpoint:** `POST https://api.rebelfi.io/v1/operations/supply`
</Note>

Plan a supply operation to deposit funds into a yield strategy.

### Request Body

Provide one wallet identifier:

| Field           | Type     | Required | Description                                         |
| --------------- | -------- | -------- | --------------------------------------------------- |
| `walletAddress` | `string` | One of   | Wallet address                                      |
| `walletId`      | `number` | One of   | Wallet ID from registration                         |
| `strategyId`    | `number` | Yes      | Target strategy ID (from venue listing)             |
| `amount`        | `string` | Yes      | Amount in base units (e.g., `"1000000"` for 1 USDC) |
| `tokenAddress`  | `string` | Yes      | Token contract address                              |

### Example Request

<CodeGroup>
  ```bash cURL (Ethereum) theme={null}
  curl -X POST "https://api.rebelfi.io/v1/operations/supply" \
    -H "x-api-key: your_api_key" \
    -H "Content-Type: application/json" \
    -d '{
      "walletId": 42,
      "strategyId": 5,
      "amount": "1000000000",
      "tokenAddress": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
    }'
  ```

  ```bash cURL (Solana) theme={null}
  curl -X POST "https://api.rebelfi.io/v1/operations/supply" \
    -H "x-api-key: your_api_key" \
    -H "Content-Type: application/json" \
    -d '{
      "walletId": 42,
      "strategyId": 1,
      "amount": "1000000000",
      "tokenAddress": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
    }'
  ```

  ```typescript SDK theme={null}
  const operation = await client.operations.supply({
    walletId: 42,
    strategyId: 5,
    amount: '1000000000',
    tokenAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'
  });
  ```
</CodeGroup>

### Example Response (EVM)

EVM supply operations may include multiple transactions (e.g., an ERC-20 `approve` followed by a `supply`):

```json theme={null}
{
  "operationId": 123,
  "type": "supply",
  "status": "AWAITING_SIGNATURE",
  "transactions": [
    {
      "id": 456,
      "blockchain": "ethereum",
      "status": "unsigned",
      "unsignedTransaction": "f86c...hex...",
      "description": "Approve USDC for AAVE V3"
    },
    {
      "id": 457,
      "blockchain": "ethereum",
      "status": "unsigned",
      "unsignedTransaction": "f86c...hex...",
      "description": "Supply 1000 USDC to AAVE V3"
    }
  ],
  "expiresAt": "2024-01-15T10:35:00Z"
}
```

<Info>
  On EVM chains, operations may return multiple transactions that must be signed and submitted **in order**. Sign and submit each transaction sequentially before proceeding to the next.
</Info>

### Example Response (Solana)

```json theme={null}
{
  "operationId": 124,
  "type": "supply",
  "status": "AWAITING_SIGNATURE",
  "transactions": [
    {
      "id": 458,
      "blockchain": "solana",
      "status": "unsigned",
      "unsignedTransaction": "AQAAAA...base64...",
      "description": "Supply 1000 USDC to Kamino"
    }
  ],
  "expiresAt": "2024-01-15T10:35:00Z"
}
```

### Example Response (with auto-cancelled operations)

If there were pending operations for the same wallet, they are automatically cancelled:

```json theme={null}
{
  "operationId": 124,
  "type": "supply",
  "status": "AWAITING_SIGNATURE",
  "transactions": [ ... ],
  "expiresAt": "2024-01-15T10:35:00Z",
  "cancelledOperations": [123]
}
```

<Info>
  The `cancelledOperations` field is only present when operations were auto-cancelled. It contains the IDs of the cancelled operations.
</Info>

### Errors

| Code                    | Description                                                    |
| ----------------------- | -------------------------------------------------------------- |
| `INVALID_AMOUNT`        | Amount is zero, negative, or malformed                         |
| `INVALID_ADDRESS`       | Wallet address format is invalid                               |
| `INSUFFICIENT_BALANCE`  | Wallet balance too low                                         |
| `STRATEGY_NOT_FOUND`    | Strategy ID doesn't exist                                      |
| `STRATEGY_NOT_ACTIVE`   | Strategy is paused                                             |
| `TOKEN_MISMATCH`        | Token doesn't match strategy                                   |
| `INSUFFICIENT_GAS`      | Not enough native token for transaction fee (ETH, POL, or SOL) |
| `SIMULATION_FAILED`     | Transaction simulation failed                                  |
| `OPERATION_IN_PROGRESS` | Another operation is currently executing for this wallet       |
| `WALLET_NOT_FOUND`      | Wallet ID doesn't exist                                        |

<Tip>
  If a pending operation already exists for the same wallet, it will be **automatically cancelled** when you create a new one. You don't need to cancel it first.
</Tip>
