> For the complete documentation index, see [llms.txt](https://docs.kojascripts.eu/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kojascripts.eu/free/carmarket/configuration/exchange.md).

# Exchange

The **exchange** is the player-or-server-owned tier above zones. A player can own an entire zone, set their own listing fee, and earn commission on every sale that happens in their zone.

## Settings

{% code title="shared/config.lua" %}

```lua
Config.Exchange = {
    ZonePurchasePrice = 250000,           -- one-time price to own an entire zone
    DefaultListingFeePerWeek = 500,       -- per-listing weekly fee (sellers pay zone owner)
    DefaultCommissionPercent = 5,         -- cut taken from each sale
    MaxListingsPerZone = 50,
}
```

{% endcode %}

| Field                      |  Default | Purpose                                                          |
| -------------------------- | -------: | ---------------------------------------------------------------- |
| `ZonePurchasePrice`        | `250000` | One-time bank cost to claim a whole zone                         |
| `DefaultListingFeePerWeek` |    `500` | What each seller pays the zone owner per active listing per week |
| `DefaultCommissionPercent` |      `5` | Cut of each completed sale paid to the zone owner                |
| `MaxListingsPerZone`       |     `50` | Hard cap on simultaneous active listings per zone                |

## How money flows

When player **B** buys a vehicle from player **A** in a zone owned by player **Z** for **$100,000**:

```
B pays           → 100,000
Z (zone owner)   ← 5,000   (5% commission)
A (seller)       ← 95,000
```

If a zone has no owner, the seller gets the **full** price.

## Player-set overrides

Once a player owns a zone, they can override the defaults from the **Exchange owner** panel in the tablet UI:

* Listing fee per week
* Max listings
* Commission %

These overrides are persisted in `koja_carmarket_exchange`.

{% hint style="info" %}
Owner-set values are **not** clamped to the defaults. If you want to enforce min/max bounds, edit `server/bridge/callbacks/callbacks_exchange.lua` → `updateExchange`.
{% endhint %}

## Listing fee flow

Same cadence as parking: every minute the server checks `listing_fee_paid_until < NOW()`:

1. Fee due → remove from seller's bank → credit to zone owner (minus commission %).
2. Failure → listing deleted from the market.

Zone owners listing their **own** vehicles skip the fee.
