StarkExchange: Fast Withdrawals using Cookie Jars

A trustless mechanism that breaks the “proof-time” barrier

Jul 22 · 4 min read

A few weeks ago, we described StarkExchange, our scalability engine for non-custodial trading in centralized exchanges. In the original design, the speed of withdrawals on StarkExchange was gated by “proof generation time” — the time to gather a batch of trades, compute a proof attesting to their validity, and have the proof accepted on-chain (this takes several minutes).

We propose below an improvement: a trustless mechanism that allows much faster withdrawals, gated only by the duration of transacting over Ethereum.

Benefit: Lower Cost of Capital & Faster Response to Market Opportunities

Faster withdrawals mean lower cost of capital for traders: a trader needs less capital to participate in the market, because it is easier/faster for them to move funds around to benefit from arbitrage opportunities.

Table 1: Comparison of Exchange Solutions

Technical Discussion

Changes to the StarkExchange System:

  • Conditional Payment: Intuitively, this is a payment from Alice to Bob that goes through only if some condition is satisfied.
    We use Conditional Payments as a “blockchain proof” primitive — a means of ensuring that on-chain state controls off-chain state. Specifically, a payment is made off-chain (i.e. included in a batch attested to by a STARK proof), only if some record appears on-chain.
    Conditional Payments are already used in StarkExchange, when we move user deposits off-chain: a deposit cannot be included in a proof (which attests to a change in the off-chain state), unless a matching deposit is observed on-chain.
    The many benefits of Conditional Payments will be discussed in a separate blog post.

A Single Fast Withdrawal Flow:

  1. User sends the exchange a Fast Withdrawal request: a signed Conditional Payment transferring the amount the user wishes to withdraw to the exchange (off-chain), conditional upon the transfer of the same amount to the user on-chain.

Replenishing the Cookie Jar Contract:

The exchange replenishes its on-chain Cookie Jar from its off-chain balance (in essence recycling funds between its on-chain and off-chain balances). Replenishment can be done periodically, or can be triggered by the available funds (per token) reaching some minimum threshold amount/value.

Worth noting: the more frequent the replenishment, the lower is the exchange’s cost of capital to support Fast Withdrawals. For example: let us consider a Cookie Jar from which x tokens/hour are withdrawn. If it is replenished daily, the exchange must lock up 24x tokens in the Cookie Jar (or some higher amount that includes some safety margin). If, on the other hand, it is replenished hourly, then the exchange must keep only x tokens in the Cookie Jar. The cost of capital is determined by the frequency of replenishment.

New Revenue Stream for Exchanges

Fast withdrawals can be priced for different tiers of service. As such, they present an interesting business opportunity for exchanges, one which allows to price-discriminate between professionals (arbitrageurs, for example) who will pay for a premium service, and retail customers.

Historical Note

A similar proposal for fast withdrawals on Plasma was presented back in June 2018. That mechanism relied on fraud proofs, not validity proofs, resulting in a more complex protocol. Importantly, the “liquidity contract” presented there (the Cookie Jar contract, in our proposal), had to cover the period of time for disputing frauds (on the order of two weeks, compared to our one hour timeframe), resulting in a much higher cost of capital (about 200X higher).


StarkExchange V1.0 was designed to enable liquid self-custodial trading.

With Fast Withdrawals, StarkExchange provides:

  • For the user: lower cost of capital

The incremental cost of Fast Withdrawal to users is only the cost of capital of the limited funds locked up in the Cookie Jar; other costs (gas cost and proof generation cost) remain essentially unchanged.

Tom Brand, Avihu Levy, and Michael Riabzev


Developing the Full Proof Stack for STARK


Written by


bringing scalability and privacy to a blockchain near you



Developing the Full Proof Stack for STARK

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade