# V2 Economy Direct Trade

`EconomyDirectTrade.V2` is the economy-layer direct player trading runtime. It
keeps item offers and currency offers in one proposal, records both participant
confirmations, and executes the exchange through working-copy inventories plus
server-authoritative currency ledger mutations.

## Runtime Surface

- `FV2EconomyDirectTradeConfig` stores server authority/source ids, item and
  currency offer limits, and the two-confirmation policy.
- `FV2EconomyDirectTradeCurrencyOffer` stores a currency id and positive minor
  unit amount.
- `FV2EconomyDirectTradeParticipantOffer` stores the participant account,
  offered item instance ids, and offered currencies.
- `FV2EconomyDirectTradeProposal` stores participant ids, both offers,
  confirmation bits, state, and timestamps.
- Operation and execution results return updated proposals, inventories,
  currency ledgers, server authority results, transferred item ids, and typed
  issues.

## Transaction Rules

1. Either participant can add item or currency offers while the trade is not
   terminal.
2. Any offer change clears both confirmations and returns the proposal to a
   negotiating state.
3. Execution requires both confirmations when `bRequireBothConfirmations` is
   enabled.
4. Item exchange uses working-copy inventories: all offered items are removed
   and added to the counterparty before any state is committed.
5. Currency exchange uses batched server-authoritative mutations per participant
   ledger, with outgoing `TransferOut` debits and incoming `TransferIn` credits.
6. Any inventory or currency authority failure returns the original proposal,
   inventories, and ledgers.

## Validation Commands

Run these checks when touching economy direct trade behavior:

```bash
python3 V2/ue/Tools/check-v2-economy-direct-trade.py
python3 V2/ue/Tools/check-v2-auction-house.py
python3 V2/ue/Tools/check-v2-server-currency-authority.py
python3 V2/ue/Tools/check-v2-currency-ledger.py
python3 V2/ue/Tools/check-v2-currency-definition.py
python3 V2/ue/Tools/check-v2-inventory-trading.py
python3 V2/ue/Tools/check-v2-ci-workflow.py
python3 -m json.tool V2/ue/Content/V2/Gameplay/Economy/EconomyDirectTrade_V2_Contract.json
python3 -m json.tool V2/ue/Build/Horde/v2-buildgraph-job.json
python3 V2/tools/validate-v2-docs.py
```
