Contract reference
Two realms written in Gno. The rooms realm holds deposits and settles trades; the board realm only stores public listings. Amounts are in base units: 1 GNOT is 1,000,000 ugnot.
Where they live
- Rooms
- Not deployed on Onyx testnet yet
- Board
- Not deployed on Onyx testnet yet
Source and tests: gno/realms/tradewindow on GitHub.
Rooms: calls
Open(counterparty string, ttlMinutes int) uint64Anyone. Opens a room at version 1. An empty counterparty leaves the seat open. ttlMinutes is 10 to 10080; 0 means 24 hours. Returns the room id.
Join(roomID uint64)Anyone but the maker. Takes the open seat. Raises the version.
DepositCoins(roomID uint64)A party, signing directly. Adds the coins sent with the call to your side. Raises the version.
DepositToken(roomID uint64, tokenKey string, amount int64)A party. Moves a GRC20 token from your account to the realm. Approve the realm address for the amount first, in the same transaction or before. Raises the version.
WithdrawCoins(roomID uint64, denom string, amount int64)A party. Takes coins back from your side, also after expiry. Raises the version.
WithdrawToken(roomID uint64, tokenKey string, amount int64)A party. Takes tokens back from your side, also after expiry. Raises the version.
Lock(roomID uint64, version uint64) stringA party. Locks the named version, which must be the current one. If the other side already locked it, settles and returns "settled"; otherwise returns "locked".
Unlock(roomID uint64)A party. Withdraws your lock on the current version.
Cancel(roomID uint64)A party; anyone after expiry. Closes the room and sends every deposit back to its owner.
Rooms: reads
RoomJSON(id uint64) stringOne room, or null.
RoomsOfJSON(addr string, offset, limit int) stringRooms where addr is maker or taker, newest first, at most 50 per page.
LatestJSON(offset, limit int) stringAll rooms, newest first.
StatsJSON() stringRooms opened, settled and cancelled, settled volume per asset, pause state, realm address.
TokensJSON(offset, limit int) stringTokens in the GRC20 registry with name, symbol and decimals.
TokenJSON(key, owner string) stringOne token, with owner's balance and allowance to the realm.
Address() stringThe realm address: it holds deposits and is the spender to approve.
Render(path string) stringThe gno.land page: latest rooms, or room/<id>.
Refusals
the room changed: review version N and lock againLock named a version that is no longer current.
both sides need at least one assetLock on a room where a side is empty.
waiting for a counterparty to joinLock before anyone took the open seat.
this room has expired: withdraw or cancel to get deposits backJoin, deposit or lock after the room's lifetime.
only the two parties of this room can do thatA deposit, withdrawal, lock or unlock from a third account.
only the two parties can cancel a room before it expiresCancel from a third account before expiry.
this room is invite onlyJoin on a room opened for one address.
the seat is already takenJoin after someone else joined.
a side can hold at most 8 different assetsA ninth asset on one side.
token is not in the GRC20 registryDepositToken with an unknown token key.
this call does not take coins: use DepositCoinsCoins sent with any other call.
send coins with a direct call from your accountDepositCoins from code instead of a signed call.
trade rooms are paused: you can still withdraw, unlock and cancelOpen, join, deposit or lock while paused.
Board
Post(side, give, want, note string, days int) uint64Publishes a listing. side is buy, sell or swap; give and want up to 80 characters, note up to 280; days 1 to 30, 0 means 7. At most 10 open listings per account.
Close(id uint64)Takes your listing down.
OpenJSON(side string, offset, limit int) stringOpen listings, newest first, optionally one side.
ListingsOfJSON(owner string, offset, limit int) stringEvery listing of one owner.
ListingJSON(id uint64) stringOne listing, or null.
From a terminal
gnokey maketx call \ -pkgpath gno.land/r/tradewindow/rooms \ -func Lock -args 12 -args 7 \ -gas-fee 1000000ugnot -gas-wanted 20000000 \ -chainid onyx-1 -remote https://rpc.onyx.testnets.gno.land:443 \ -broadcast mykey