Orders and trading keys
Every order you place on Loaf is signed by your trading key, a signing key set up for your account with your Loaf wallet. A signature is a cryptographic seal that only that key can produce. It proves an order came from your account and fixes its terms, so any change would make it invalid.
Your trading key
Your account works with two keys, each with its own job.
| Key | How you get it | What it does |
|---|---|---|
| Loaf wallet | Created for your account the first time you sign in, whether you use email or a wallet of your own | Owns your account; you deposit to it, and every withdrawal is paid to it |
| Trading key | Set up with your Loaf wallet when you enable trading on the Trade page, after your first deposit | Signs your orders and cancellations in the background |
You never handle the trading key: the app signs with it in the background, so there is nothing to approve in a wallet. Withdrawals are only ever paid to your Loaf wallet. Smart-contract wallets such as Safe, which a contract controls rather than a single key, are not supported.
You can replace your trading key, after which the old key can no longer sign for your account.
What a signed order fixes
Each signature fixes an order’s market, side, size, price limit, fee cap and expiry. Every validity proof then checks each fill against those terms, so no fill can settle on terms you did not sign.
| Part of the order | What every proof checks |
|---|---|
| Signature | The order carries a valid signature from its account |
| Market | The market is active |
| Side | Each fill pairs a buy with a sell, between two different accounts that exist |
| Size | The order never fills for more than its size |
| Price limit | Every fill is at the limit price or better |
| Fee cap | The fee is within the signed cap and the market’s rate |
| Expiry | No fill takes place after the order expires |
The fee cap means you never pay more than the rate shown when you placed the order. If the same signed order reaches the matching engine twice, it is placed only once. Through the API, you can sign up to 256 orders with one signature, which suits market makers refreshing many quotes at once.
Cancels and expiry
| Cancel-all | One signed request cancels every open order in your account |
| Cancel-after | A dead man’s switch that cancels your orders unless you renew it within a window you choose, 10 to 120 seconds |
| Expiry | Every order carries an expiry, and no order stays live for more than about 46 days |
Every proof enforces two of these: no order cancelled by a cancel-all fills afterwards, and no order fills after its expiry. Cancel-after protects you if your connection or trading system fails while your orders rest on the book. Order types covers every order type and time in force, and the API reference covers the requests.
Warning. Anyone who obtains your trading key can place and cancel orders for your account, though withdrawals are only paid to your Loaf wallet. Loaf never asks for your recovery phrase or private key.