How trading works
A bond changes hands by moving its NFT, and the protocol contracts run no venue. Any NFT marketplace can trade the token too, see Your bond as an NFT. Coffer runs one marketplace contract, separate from the protocol, where a holder sells a bond through a listing and a buyer bids for one through an offer. The marketplace holds nobody’s funds and nobody’s bonds. Both stay in their owner’s wallet until a fill settles through approvals, and the contract’s own balance carries only the fees it has earned.
A listing and an offer
Section titled “A listing and an offer”A listing is the holder’s side. The holder names an ask in ETH, a buyer fills it and pays the ask plus the marketplace fee, and the bond moves to the buyer. An offer is the buyer’s side. A would-be buyer names an amount in WETH, the holder accepts it, and the WETH moves to the holder while the bond moves the other way. Either side can stand alone, a bond can carry a listing and several offers at once, and the first fill on either side settles the trade. The holder may accept any offer that stands, not only the highest.
Signed messages
Section titled “Signed messages”Both are signed messages. Signing is free and happens off chain. The wallet signs a typed message with seven fields, the maker’s own address, the bond, the price or the amount, the bond’s maturity value, an expiration, and two counters called nonces. The signed message is stored off chain. Nothing touches the chain until the other side fills, and the fill is one transaction by the taker, in which the contract verifies the signature at that moment and settles. Signing costs nothing, and cancelling costs only the gas of a cancel transaction.
What moves at a fill
Section titled “What moves at a fill”For a listing the contract checks, in this sequence, that the buyer is not the seller, that the ask is above zero, that the seller’s nonces are current, and that the seller holds the bond and has approved the marketplace. It checks that the listing has not expired, that the signature is the seller’s, that the bond is outstanding, that the signed maturity value equals the bond’s live one, and that the payment covers the ask plus the fee. Then it moves the seller’s nonce, so the listing can never be filled again. The NFT goes to the buyer, the ask goes to the seller in ETH, the fee stays in the marketplace, and any excess ETH is refunded. That payment reaches the seller’s wallet with all the gas the fill has left. If the wallet refuses the ETH or runs out of gas taking it, the whole fill fails, nothing moves, and the listing stays live. A seller whose wallet cannot take ETH sells through an offer instead, which pays in WETH.
For an offer the checks run in the same sequence from the other side. The taker is not the bidder, the amount is above zero, the bidder’s nonces are current, and the taker holds the bond and has approved the marketplace. The offer has not expired, the signature is the bidder’s, the bond is outstanding, and the signed maturity value equals the live one. Then the contract moves the bidder’s nonce and reads the bidder’s WETH balance and allowance. Only then does the WETH amount go from the bidder to the holder, the WETH fee from the bidder to the marketplace, and the NFT from the holder to the bidder.
One WETH balance can stand behind offers on several bonds, since each accept reads the balance at that moment. The first accept takes the WETH, and an accept of another offer then fails until the balance covers it again.
Approvals, once each
Section titled “Approvals, once each”A holder gives the marketplace one approval to move their bonds. It covers every bond the wallet holds, now and later, and nothing narrower, since the contract accepts no other kind. A buyer approves WETH for the marketplace once and without limit, so no offer needs it again. The allowance lets the marketplace draw WETH only at an accept, only against an offer that wallet signed, and never more than that offer’s amount plus its fee.
Offers are paid in WETH, wrapped ETH, because the holder’s accept draws the amount from the bidder’s wallet while the bidder is away, and a contract can draw a token on an approval but never plain ETH.
Nonces and cancels
Section titled “Nonces and cancels”Every message is signed at the bond’s current nonce for that maker. A fill advances the nonce by one, which kills every earlier signature on that bond. A cancel advances it by one plus a large amount that depends on the block it lands in, so it also kills every message signed ahead of the current nonce. Each side also has a global nonce. One transaction cancels every listing a maker has signed, and a separate one cancels every offer, so cancelling all listings leaves the maker’s offers fillable. Revoking is on chain only. Signing a new message off chain revokes nothing, so an earlier signature stays fillable until a fill or a cancel moves the nonce.
A transfer of the bond moves no nonce, and an accepted offer moves only the bidder’s. A listing whose seller no longer holds the bond cannot be filled, but its signature stays valid, so it becomes fillable again if the bond comes back to that seller before the listing expires. Cancel a listing before you accept an offer or transfer the bond if that matters to you. Offers do not depend on who holds the bond, so after a sale the remaining offers stand for the new holder. An offer you made on a bond you later come to hold cannot be filled while you hold it, since the contract refuses a trade with yourself, and the next holder can accept it.
Expirations
Section titled “Expirations”Every message carries an expiration, and after it the contract refuses the fill. Until then a signed message stays fillable unless its maker cancels it on chain. The contract checks the expiration and not the maturity date, so a matured bond stays tradable on chain while a message for it has not expired.
The maturity value binds
Section titled “The maturity value binds”The bond’s maturity value is signed into every listing and offer and checked again at the fill. If the bond’s remaining value changed after signing, through a redemption or a claim in a default, the fill fails. The value binds the size of a claim, not its quality. Two bonds with the same maturity value can settle very differently, because what a claim can draw on is the coffer’s balance and its validator’s stake, and a defaulted coffer pays first come first served from whatever it holds. The checks on Before you buy apply to a purchase here as much as to a fresh bond.
The fee
Section titled “The fee”The marketplace charges a fixed 9 percent of the buyer’s profit, the maturity value minus the price or the amount, when that difference is positive. It is charged on completed trades only, never on signing or cancelling, and a trade at or above the maturity value pays no fee. The buyer of a listing pays it in ETH on top of the ask, and the maker of an offer pays it in WETH on top of the amount. The rate is a constant in the contract with no setter, see Fees.
In the app
Section titled “In the app”The marketplace lives in the marketplace section of a bond’s page and in the Ask and Offer columns of Browse. Approve on the Approve Marketplace card gives the approval for your bonds, and Approve WETH gives the WETH allowance. Wrap ETH and Unwrap WETH in the wallet menu turn ETH into WETH and back. List Bond signs a listing that expires at the bond’s maturity, and Make Offer signs an offer that runs from 1 to 90 days. Buy Bond on a listed bond and Accept in the holder’s Offers table send the fill. Cancel Listing and Cancel Offer send the cancel that moves your nonce.
Contract wallets
Section titled “Contract wallets”A Safe or another contract wallet signs listings and offers through ERC-1271, and the contract checks such a signature at the fill. Contract wallets has the detail.
Trading adds risks of its own, a stale signature, a pre-signed nonce, a seller’s wallet that refuses ETH, a bond whose value changes, a maker’s code inside a fill, and a defaulted coffer behind an ordinary looking maturity value. Risks states each with its mechanism.