Gas Is Free Forever: How the PaymasterFacet Funds Itself
3 min read
Starting with v2.6, every transaction on THRYX is gas-free for users. Not "gas-free with an asterisk." Actually free. The Diamond contract itself pays for gas using its own reserves, and those reserves replenish automatically from trading fees.
The Old Way (Broken)
Previously, gas sponsorship required a separately funded wallet on the server. That wallet would send ETH to users before each trade. Problems: the wallet could run out, it needed manual topping up, and the private key had to live on the server.
The New Way (Self-Sustaining)
The PaymasterFacet lives inside the Diamond contract. It holds its own ETH reserves and THRYX buffer. When a user needs gas, the Cloudflare relay calls sponsorGas(user) on the contract. The contract sends ETH directly from its reserves to the user. No external wallet involved.
How It Refills
Every swap on the protocol generates a 0.5% fee. A portion of the protocol's share (5%) routes to the paymaster as THRYX. A background keeper checks every 15 minutes: if the paymaster's ETH is running low, it calls rebalancePaymaster() to convert THRYX into ETH. The contract enforces rate limiting (1 hour cooldown, max 10% per sell) to protect the THRYX price.
The result: more trading volume means more fees, which means more gas sponsorship capacity, which means more users can trade for free, which means more volume. A virtuous cycle.
Security
Only the authorized relay wallet can call sponsorGas(). The relay key lives in Cloudflare Workers as an encrypted secret. The Render server calls the relay via HTTPS. No private keys on the web server. The contract checks caller authorization on every call.
Gas Limits
Standard trades use around 200-300K gas. But graduation buys — where a buy triggers the token to graduate and create an AMM pool in the same transaction — need 968K+ gas. The platform sets a 1.5M gas limit on all buys to handle this gracefully. Sells use a 500K limit. These generous limits ensure no trade ever fails due to gas estimation.
What Users See
Nothing. They click Buy or Sell, the trade executes, and they never think about gas. That is the point.