For the complete documentation index, see llms.txt. This page is also available as Markdown.

Buy Quota (v5.14.16)

Current Protocol Version: v5.14.16


What Is a Buy Quota?

A buy quota is an optional, per-token limit on how much of a token a single address can buy cumulatively from the bonding curve (not the DEX, after graduation).

Unlike a hard cap that reverts, exceeding your quota does not fail your transaction. Instead, the protocol automatically refunds the portion of your input that would push you over the limit β€” you simply receive less output than you asked for (down to zero if your quota is already exhausted), and the excess quote-asset input comes back to you in the same transaction.

Not every token has a quota. If a token has no cap configured, this entire mechanism has zero effect on it β€” you can buy as much as the bonding curve otherwise allows.

Why It Exists

The bonding curve is where a token's price is most volatile relative to supply β€” a single address accumulating a large share early can distort later pricing for everyone else. A buy quota lets a token limit how much cumulative exposure any single address can build up while the token is still in its bonding-curve phase, without needing to block or blacklist anyone outright.

Key Design Points

  • Quota is keyed by tx.origin, not msg.sender. This means the limit tracks the ultimate transaction originator β€” the externally-owned account (EOA) that signed and sent the transaction β€” regardless of how many intermediate contracts (routers, aggregators, smart-contract wallets acting on behalf of a single owner) the call passes through before reaching the bonding curve.

  • Quota only applies to bonding-curve buys. Once a token has migrated to a DEX, trading there is unaffected β€” a buy quota is a bonding-curve-phase mechanism only.

  • Cumulative, not per-transaction. Your quota usage accumulates across every buy you make on that token while a quota is active; it does not reset per transaction.

  • Selling never reduces your quota usage. Once you've bought against your quota, selling the tokens back does not free up allowance β€” the cumulative-bought figure only ever increases while a quota is active for that token.

  • Never causes a revert on its own. If you're already at your quota (or your input would exceed it), your buy simply executes for less than requested β€” with a full or partial refund β€” rather than failing outright. You should still set a normal slippage/minimum-output check on your own call if you require a guaranteed minimum output; the quota mechanism does not bypass that.


Checking a Token's Quota Configuration

To find out whether a token has a quota configured at all, and what it is:

  • bps is expressed in basis points of the token's max supply (e.g. 200 = 2%).

  • maxBuyAmount is the same limit expressed directly in token units, for convenience.

  • If both values come back 0, the token has no quota β€” this entire feature is a no-op for that token.

Checking Your Own Quota Usage

To find out how much of your own quota you've already used, and how much remains, for a specific token:

What Happens When You Exceed Your Quota

If your requested buy amount would push your cumulative total past your remaining allowance:

  • The protocol fills your buy up to your remaining allowance only.

  • The unused portion of your input (the amount that would have gone toward the excess) is automatically refunded to you in the same transaction β€” no separate claim step needed.

  • If your quota is already fully exhausted (remaining == 0), your buy is filled for zero output, and effectively your entire input is refunded.

This means a buy quota never blocks a transaction from succeeding β€” it only changes how much you actually receive. If your integration requires a guaranteed exact fill, check buyQuotaOf before submitting the trade, or set an appropriate minimum-output parameter on your swap call and treat a shortfall as an expected, valid outcome rather than an error.

Watching Quota Changes (Events)

Two events let you track quota state without polling:

  • Index FlapTokenMaxBuyPerOriginSet to build a live map of which tokens currently have a quota configured, and what it is.

  • Index FlapBuyQuotaUpdated (filterable by token and origin, both indexed) to track a specific address's quota usage on a specific token over time, without repeatedly calling buyQuotaOf.

Neither event fires for a token with no quota configured β€” absence of FlapTokenMaxBuyPerOriginSet for a given token is itself the signal that the token has no limit.

Summary Checklist

Last updated