Answer a deal
Open a deal's link, answer it with a sealed size and limit, and read the outcome, Deal done or No deal.
A maker opened a deal and sent you its link. The deal shows which side the maker takes. You answer on the other side with a size and a limit of your own, sealed in your wallet. The cluster compares the two sealed limits and either trades at their midpoint or reports no deal. Neither side learns the other's number. The maker's half is Open a deal, and the mechanism is in Deals.
What the deal's page shows
The link is /deals/<the Deal account's address> and opens the deal's page in the app. Its panel The deal holds what the surface knows about the deal:
| Row | Meaning |
|---|---|
Market | The pair the deal trades, with the price of its last sounding. |
Maker | The wallet that opened the deal. |
Maker's side | Buys or Sells the base token. You take the other side. |
Counterparty | The one address that can answer, or Anyone with the link. |
Expires | The time, in UTC, after which no answer is accepted. |
Attempts left | How many answers your wallet still has, of the number the maker set for each taker. The count is read from the chain. |
Status | Opening, Open, Void, Done, Cancelled or Expired. |
The last row, Maker's size, minimum and limit, stays sealed for you. Those three values are encrypted to the maker's reading key and to the cluster. No page, API response or account gives them to a taker.
Before you answer
- A funded sealed balance in the deal's market: the quote token when the maker sells and you buy, the base token when the maker buys and you sell. Until your wallet has one, the panel's button reads Deposit and leads to the portfolio. See Deposit and withdraw.
- Your reading key. Your answer is sealed with it and your receipt is read with it. See The reading key.
- The right wallet. A deal with a named counterparty accepts answers from that wallet only. The maker's own wallet cannot answer.
Answer
Open the link
The deal's page opens. A deal that names your wallet is also listed on Deals under Addressed to you, with Answer in its row. Connect a wallet and press Unlock if the panel Answer asks for it.
Enter a size and a limit
The panel is labelled by your side. When the maker sells, enter the Size to buy and Limit: pay no more than. When the maker buys, enter the Size to sell and Limit: accept no less than. The size is in the base token and the limit in the quote token. The panel shows the fee if the deal trades and your sealed balance of the token you pay with.
Press Answer
Press Answer and sign. The stages run: sealed in your wallet, signed, computed by the cluster. The panel then shows Deal done or No deal.
Every answer you send uses one of your attempts, whichever way it ends.
Deal done
The limits crossed, the size met the maker's minimum and your sealed balance covered the trade. It settles inside the same computation, between the two sealed balances.
- Size: the smaller of your size and what is left of the deal.
- Price: the midpoint of the two limits, half their sum, rounded down in the price unit.
- Fee: the deal fee on the quote amount traded, paid by each side. The rate is in Fees.
Buying, your sealed balance gains the size in the base token and pays the quote amount plus the fee. Selling, it gives the size and gains the quote amount less the fee.
The panel shows Deal done with three rows: Bought or Sold, the size that traded. Price, the midpoint of the two limits. Fee, in the quote token. Portfolio leads to your sealed balances and receipts.
The surface shows that your answer traded and whether the deal is now filled. A filled deal reads Done and accepts no more answers. A deal with size left stays Open, and you can answer again while you have attempts.
No deal
Nothing moved. The receipt in your sealed balance has ok false and every amount zero, and the panel shows No deal with the attempts you have left. Nothing else is revealed to either side, the reason included.
No deal has one of these causes:
- The limits did not cross. Buying, your limit was below the maker's. Selling, it was above.
- Your size was under the maker's minimum and did not take all that is left of the deal.
- Your sealed balance did not cover the trade at the midpoint price, fee included.
- Your size was zero, or the quote amount of the trade is beyond the integer range.
Answer again with another size or limit while you have attempts left. The count is per wallet and per deal.
States that accept no answer
| The panel shows | Program error | Meaning and what to do |
|---|---|---|
Not the named counterparty | NotCounterparty | The deal names another wallet. Switch to that wallet to answer it. |
Expired | DealExpired | The expiry passed. Ask the maker for a new deal. |
Opening | DealNotOpen | The cluster is still computing the deal's opening. It can be answered in a moment. |
Void | DealNotOpen | The maker's sealed balance did not cover the deal, so it never opened. Ask the maker for a new deal. |
Cancelled | DealNotOpen | The maker cancelled the deal. Nothing moved. |
Out of attempts | OutOfAttempts | Your wallet has used every attempt the maker gave each taker. Ask the maker for a new deal. |
No deal at this address | | The link is incomplete or names no deal. Ask the maker for the link again. |
From the SDK, read the same state before answering:
import { PublicKey } from '@solana/web3.js'
import { attemptsAddress } from '@hadal/sdk'
const { status, account } = await hadal.deal(deal)
const mayAnswer = account.taker.equals(PublicKey.default) || account.taker.equals(hadal.owner)
const live = status === 'open' && Date.now() / 1000 <= account.expiry.toNumber()
const mine = await hadal.program.account.dealAttempts.fetchNullable(attemptsAddress(deal, hadal.owner))
const left = account.attempts - (mine?.used ?? 0)A deal with no named counterparty stores the default address, PublicKey.default, as its taker.
Errors
A transaction that cannot be accepted is refused by the program before any computation is queued, and uses no attempt. Busy means your sealed balance or the deal has a computation in flight, for example another taker's answer: send again when it has landed.
| Error | Code | Raised when |
|---|---|---|
Busy | 6001 | The market's book, the balance or the deal the instruction needs already has a computation in flight. Also raised by process_order, by cancel_order on a pending order and by fund_market while the market has one. Send again once that computation lands, or release it after it expires. |
EmptyBalance | 6019 | The sealed balance has never had a computation land on it. Raised by withdraw, place_order, add_liquidity, remove_liquidity, open_deal and take_deal. Deposit first. |
DealNotOpen | 6024 | take_deal was sent for a deal whose status is not open, or cancel_deal for a deal that is opening, void or already settled. |
DealExpired | 6025 | take_deal was sent after the deal's expiry. |
NotCounterparty | 6026 | take_deal was signed by a wallet other than the counterparty the deal names. |
InvalidCounterparty | 6027 | The maker tried to answer their own deal, or opened a deal naming themselves as counterparty. |
OutOfAttempts | 6028 | The taker has used every attempt the deal gives each taker. |
If the cluster does not finish the computation of an answer, nothing moved, the attempt stays used and awaitComputation throws at its timeout. The deal and your balance are freed as told in Release instructions. The lifecycle of a computation is in Arcium.