Swap offers
You are looking at an old version of this page: revision #858 by zoobc.how, 2026-10-26 22:31 UTC. See the current version
A swap offer is the simplest way to trade on ZooBC. A maker locks an amount of one asset and names the amount of another asset it wants in return; a single taker pays exactly that, and both sides move at once. Swap offers work with any pair of assets (ZBC, genesis coins or user tokens) whatever their decimals, so they also serve tokens that cannot go on an order-book market.
The three transactions
- CreateSwapOffer (type 18) names the give side (an asset and an amount), the want side (an asset and an amount), an optional expiry time in Unix seconds, and an optional designated counterparty, the only address that may accept. The give side leaves the maker's balance at once and is held in the offer, so a taker knows it is really there.
- AcceptSwapOffer (type 19) lets one taker pay the whole want side. In the same step the maker receives the want side and the taker receives the give side. A maker cannot accept its own offer.
- CancelSwapOffer (type 20) returns the give side to the maker, at any time while the offer is open.
All or nothing
There are no partial fills: one taker takes the whole offer, or nothing happens. Nothing is lent either: both legs move at once and for good, so nobody owes anything afterwards. Filling bit by bit against many counterparties is what orders on a market do.
If two takers try to accept the same offer, the first one applied wins. The second has become pointless and is a paid no-op: it pays its fee and changes nothing (see one transaction per account per block, and batches).
Expiry and cancelling
An expiry only stops acceptance. The chain never sweeps offers away, so an expired offer stays locked until its maker cancels it and recovers the give side. Swap offers pay no rent.
Swap offers and orders on a market
| Swap offer | Order on a market | |
|---|---|---|
| Assets | any two, any decimals | tokens with 8 decimals |
| Counterparties | one taker, all or nothing | fills against many orders |
| Price | fixed by the maker's two amounts | each fill at the resting order's price |
| Rent | none | the market pays rent |
With other features
- The assets a maker or a taker receives are incoming credits, so they pass through the receiver's split policy (see split and transact policies).
- An account whose transact policy refuses the Exchange category can neither make nor accept offers.
- If a token in an open offer expires, the units locked in the offer still count for the maker when the token's ZBC backing is shared out (see token upkeep (persistence)).