# Negotiation

> Counteroffers, immutable quote versions, terms hashes and how acceptance pins the exact version you reviewed.

Source: https://cairva.xyz/docs/negotiation

Negotiation happens in a private deal room between one buyer and one supplier. The rule that makes it safe is simple: every proposal is a new, numbered, immutable version, and acceptance names one exact version.

## Versions

Each time the supplier issues terms or either side counters, Cairva stores a new version with:

- the complete terms, not a diff
- the total price, computed from the terms
- an expiry
- an optional note
- a SHA-256 hash over the terms, price and expiry

Old versions never change. The deal room shows them side by side so you can see exactly what moved.

## Taking turns

| Who acts | Allowed when | Result |
| --- | --- | --- |
| Supplier issues a firm quote | The request is open or negotiating | Quote is `issued` and it's the buyer's turn |
| Buyer counters | The latest version came from the supplier | Quote is `countered` and it's the supplier's turn |
| Supplier counters | The latest version came from the buyer | A new firm version, `issued` again |
| Supplier withdraws | Before acceptance | Quote is `withdrawn` |

You can't counter your own latest version. Wait for the other side.

A supplier's counter is checked against their lot again, so it can't promise capacity the lot doesn't have. A buyer's counter is a proposal and isn't checked against the lot until the supplier answers it.

> [!WARNING]
> If someone posts a new version while you're editing, your counter is rejected with `stale_version`. Review the latest version and try again. This keeps you from responding to terms that are no longer on the table.

## Accepting

Only a supplier-issued version can be accepted, and only by an admin of the buyer organization. The acceptance carries the version number and the terms hash you reviewed. Cairva rejects it if:

- a newer version exists (`stale_version`)
- the hash doesn't match the current version (`stale_version`)
- the version has expired (`quote_expired`). Ask the supplier to reissue
- the latest version is your own counter, still waiting on the supplier

On acceptance Cairva locks the lot, reserves the tokens on it so the same supply can't be sold twice, and creates the agreement and its allocation. The agreement records a contract hash over the version, the terms hash, both organizations, and who accepted and when.

Quotes expire on their own once the current version's expiry passes.

Next: [Agreements](https://cairva.xyz/docs/agreements).
