How trades work
Every BazaarFi trade is an on-chain account with a strict lifecycle: Initialized → Active → Completed | Cancelled | Expired. The program enforces every transition — the UI just makes them pleasant.
1. Create & escrow
When you publish a trade, the app builds a short sequence of transactions signed in a single wallet prompt:
- Create — initializes the trade account with the full manifest of what you give and what you want. Nothing is live yet.
- Deposit — each offered asset moves into escrow. SOL is held on the trade account itself; tokens and NFTs move into vault accounts owned exclusively by the trade's program-derived address. No person holds a key to these vaults.
- Activate — the program verifies every promised asset is escrowed, then flips the trade to Active. Only then is it acceptable.
Because deposits happen before activation, takers never need to trust that the maker "really has" the assets — the program already checked.
2. Accept — atomic settlement
Accepting a trade is one transaction. Within it, the program transfers every requested asset from the taker to the maker, releases every escrowed asset from the vaults to the taker, pays the protocol fee on SOL legs, and closes the vaults, refunding rent to the maker.
If any single step fails — an insufficient balance, a frozen token account, an ownership mismatch — the Solana runtime reverts the entire transaction. Partial settlement is impossible by construction.
For large bundles the app uses versioned transactions with address lookup tables, which are prepared automatically before settlement.
3. Cancel, expire, reclaim
- Cancel — the maker can cancel any time before acceptance. Escrowed SOL refunds immediately; tokens and NFTs are reclaimed in the same flow, and the trade account closes with its rent returned.
- Expire — every trade has an on-chain deadline (1 hour to 90 days). After it passes, the trade can no longer settle, and anyone can crank the expiry to unlock the maker's reclaim. Expiry is enforced by the program clock, not by our servers.
Counter offers
A counter offer is a real trade, not a message: it escrows your assets, requests the original maker's offered bundle, and is restricted so only they can accept it. Both trades are linked on-chain via counter_to. If the original maker accepts your counter, it settles atomically like any other trade; they then cancel their original listing at their leisure.
Private trades
Any trade can be restricted to a single counterparty wallet at creation. The program rejects acceptance from anyone else — useful for negotiated OTC deals where you've already agreed on terms in private.
Next: the security model behind all of this.