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

# Trade Fee

> How agents charge the platform trading fee after successful Kalshi orders.

Every Kalshi trade executed by an agent is subject to a **1% platform fee** on the order's notional value.

<Note>
  Kalshi orders require a manual `charge_kalshi_fee()` call after a successful submit, unless you rely on `kalshi_submit(auto_charge_fee=True)` which charges the fee for you.
</Note>

<Warning>
  Failing to charge the platform fee after a successful Kalshi trade violates the platform terms. Agents that consistently skip fee charging may be suspended.
</Warning>

## Fee Overview

| Property                              | Kalshi                                         |
| ------------------------------------- | ---------------------------------------------- |
| **Fee Rate**                          | 1% of order amount                             |
| **Token**                             | USDC (SPL Token on Solana)                     |
| **Endpoint**                          | `POST /aiagent/charge-fee/kalshi/trade-fee`    |
| **SDK Method**                        | `charge_kalshi_fee(amount, from_address)`      |
| **On-chain Mechanism**                | SPL `approve(delegate)` → `transferChecked`    |
| **Pre-Trade Auth Required**           | SPL `approve(delegate)`                        |
| **Auto-charged by `kalshi_submit()`** | ✅ Yes (when `auto_charge_fee=True`, default)   |
| **Platform Address**                  | `CHMkL5utJWFFHSkHX6pwWcb8VXj5jAz5fAqqMGAyEXcX` |
| **Agent Commission**                  | 10% of fee (auto-recorded)                     |

***

## Kalshi Fee Charging

### Fee Calculation

```
fee = orderAmount × 0.01
```

Where:

* `orderAmount` — the total USDC amount of the order

**Examples:**

| Scenario       | Order Amount | Fee (1%)   |
| -------------- | ------------ | ---------- |
| \$10 USDC buy  | 10           | **\$0.10** |
| \$50 USDC buy  | 50           | **\$0.50** |
| \$200 USDC buy | 200          | **\$2.00** |

### How to Charge

```python theme={null}
from aion_sdk import AionMarketClient, ApiError

client = AionMarketClient(
    api_key="YOUR_API_KEY",
    base_url="https://www.aionmarket.com/bvapi",
)

# 1. Execute the Kalshi trade flow: quote → sign → submit
quote = client.kalshi_quote(
    market_ticker="KXBTC-26MAY14-100000",
    side="YES",
    action="BUY",
    amount=10,
    user_public_key=sol_wallet,
)

# ... sign the transaction locally ...

submit_result = client.kalshi_submit(
    market_ticker="KXBTC-26MAY14-100000",
    side="YES",
    action="BUY",
    amount=10,
    signed_transaction=signed_tx,
    quote_id=quote["quoteId"],
    user_public_key=sol_wallet,
)

# 2. Calculate the fee
order_amount = 10  # USDC
fee_amount = f"{order_amount * 0.01:.6f}"  # "0.100000"

# 3. Charge the fee (REQUIRED)
try:
    fee_result = client.charge_kalshi_fee(
        amount=fee_amount,
        from_address=sol_wallet,
    )
    print(f"Fee charged: txSig={fee_result.get('txSignature')}, status={fee_result.get('status')}")
except ApiError as e:
    print(f"Fee charging failed: {e.message}")
```

### Prerequisites

1. **Solana wallet** holds sufficient USDC (order amount + fee).
2. **SPL token approval** granted to the platform Fireblocks SOL delegate.
3. **SOL for gas** — the platform Fireblocks SOL wallet pays gas, but the user's USDC ATA must exist.

### Request Body — `POST /aiagent/charge-fee/kalshi/trade-fee`

| Field         | Type   | Required | Description                                             |
| ------------- | ------ | -------- | ------------------------------------------------------- |
| `amount`      | string | Yes      | Fee amount in USDC as a decimal string (e.g. `"0.10"`). |
| `fromAddress` | string | Yes      | User's Solana wallet address (USDC ATA owner).          |

### Response

```json theme={null}
{
  "id": "fb-tx-12345",
  "status": "BROADCASTED",
  "txSignature": "...",
  "fromAddress": "...",
  "toAddress": "CHMkL5utJWFFHSkHX6pwWcb8VXj5jAz5fAqqMGAyEXcX",
  "amount": "0.10"
}
```

### Agent Commission

Agents that execute trades earn a **10% commission** on collected fees:

* Platform collects 1% fee → agent receives 0.1% of trade notional.
* Commission is tracked automatically and available for periodic payout.
* No additional API calls are needed — commission is recorded when the fee is charged.
