
{"id":133438,"date":"2026-02-08T09:04:14","date_gmt":"2026-02-08T09:04:14","guid":{"rendered":"https:\/\/mycryptomania.com\/?p=133438"},"modified":"2026-02-08T09:04:14","modified_gmt":"2026-02-08T09:04:14","slug":"percolator-protocol-perpetual-trading-on-solana","status":"publish","type":"post","link":"https:\/\/mycryptomania.com\/?p=133438","title":{"rendered":"Percolator Protocol: Perpetual Trading on Solana"},"content":{"rendered":"<h4>Understanding the Percolator perpetual protocol on Solana\u200a\u2014\u200awithout the\u00a0jargon.<\/h4>\n<h4>What Is Percolator?<\/h4>\n<p><a href=\"https:\/\/github.com\/aeyakovenko\/percolator-cli\">Percolator<\/a> is an on-chain perpetual futures protocol built on Solana. In plain terms: it lets people trade leveraged long\/short positions on an asset (e.g. SOL) that never expire, with collateral held in a shared vault and prices coming from oracles (e.g. Chainlink, Pyth). The protocol is experimental and unaudited\u200a\u2014\u200afor educational and testing only, not production or real\u00a0funds.<\/p>\n<p>Think of it as a decentralized, programmable \u201cperps engine\u201d: one program holds all market state in a single slab account, and external matcher programs define how trades are\u00a0priced.<\/p>\n<p>This separation makes it flexible: you can run standard or inverted markets, passive LPs, or custom AMM-style pricing.<\/p>\n<h4>Percolator Protocol\u200a\u2014\u200aCore\u00a0Ideas<\/h4>\n<h4>1. The Slab = One Market, One Big\u00a0Account<\/h4>\n<p>Everything for a single market lives in one on-chain account called a\u00a0slab:<\/p>\n<p>\u2022 <strong>Header<\/strong>\u200a\u2014\u200amagic, version, admin, flags (e.g. \u201cresolved\u201d for binary markets).<\/p>\n<p>\u2022 <strong>Market config\u200a<\/strong>\u2014\u200acollateral mint, vault, oracle feed ID, invert\/unit scale, funding and risk-threshold parameters, optional oracle authority.<\/p>\n<p>\u2022 <strong>Risk engine\u200a<\/strong>\u2014\u200avault balance, insurance fund, risk params (margins, fees, liquidation), funding index, crank\/sweep state, and a bitmap + array of up to 4096 accounts (users and\u00a0LPs).<\/p>\n<p><strong>So: one slab<\/strong> = one perpetual (or one binary)\u00a0market.<\/p>\n<p><strong>Deploy another slab<\/strong> = another\u00a0market.<\/p>\n<h4>2. Two Kinds of Accounts: Users and\u00a0LPs<\/h4>\n<p>Each account in the slab is\u00a0either:<\/p>\n<p>\u2022 <strong>User<\/strong>\u200a\u2014\u200aa trader. They deposit collateral, open\/close positions (long = positive size, short = negative size), and have PnL, margin, funding,\u00a0etc.<\/p>\n<p>\u2022 <strong>LP (liquidity provider)\u200a<\/strong>\u2014\u200aprovides liquidity and takes the other side of trades. They also have capital and a position (opposite to the net of user positions they\u2019ve matched). LPs are bound to a matcher (program + context) that defines how trades are\u00a0priced.<\/p>\n<p>Accounts are indexed (0..N). The slab tracks which indices are used via a bitmap and stores each account\u2019s capital, position, entry price, funding index, matcher program\/context (for LPs), and\u00a0owner.<\/p>\n<h4>3. Oracles Feed Price; Optional Authority Overrides<\/h4>\n<p>Prices come from oracles (e.g. Pyth Pull feed ID or Chainlink). The slab\u00a0stores:<\/p>\n<p>\u2022 Max staleness and confidence filter.<\/p>\n<p><strong>\u2022 Optional oracle authority:<\/strong> if set, an admin can push a price (used for testing, binary settlement, or controlled environments). When authority price is set and recent, it overrides the external\u00a0feed.<\/p>\n<p>So: normal operation = Pyth\/Chainlink; special cases = admin-controlled price.<\/p>\n<h4><strong>4. Inverted\u00a0Markets<\/strong><\/h4>\n<p>A market can be inverted: internally the protocol uses 1\/price (e.g. USD per SOL \u2192 SOL per USD). That\u2019s useful when collateral is SOL and you want \u201clong USD \/ short USD\u201d style exposure: long = profit when SOL goes down, short = profit when SOL goes up. Same risk engine, different price interpretation.<\/p>\n<h4>5. Matchers: Who Decides Trade\u00a0Price?<\/h4>\n<p>Trades can happen in two\u00a0ways:<\/p>\n<p><strong>Trade (no CPI)\u200a<\/strong>\u2014\u200aOnly the percolator program runs. User and LP sign; execution and pricing are handled inside percolator (e.g. agreed off-chain or by a simple rule). No other program is called. Good for testing or trusted LP\u2013user\u00a0pairs.<strong>Trade (CPI)<\/strong>\u200a\u2014\u200aPercolator invokes an external matcher program via CPI. The matcher (e.g. percolator-match) is passed the oracle and its context, computes the execution price, and returns it. Percolator then applies that price (size, fees, margin) and updates\u00a0state.<\/p>\n<p>CPI here means Cross-Program Invocation on\u00a0Solana.<\/p>\n<p>So matchers are the \u201cpricing layer\u201d: passive (e.g. oracle \u00b1 50 bps), vAMM-style (spread + impact), or fully custom. The protocol enforces that the LP\u2019s matcher program\/context match and that the matcher verifies the LP PDA as signer (so only that LP\u2019s liquidity is\u00a0used).<\/p>\n<h4><strong>6. Keeper Crank: Funding, Mark, and Liquidation<\/strong><\/h4>\n<p>A keeper crank is a permissionless instruction that:<\/p>\n<p>\u2022 Updates mark price and funding from the oracle and LP net position.<\/p>\n<p>\u2022 Applies funding to open positions.<\/p>\n<p>\u2022 Runs the liquidation\/force-close logic (e.g. under-maintenance-margin accounts liquidated at oracle price; dust positions cleaned\u00a0up).<\/p>\n<p>Funding is computed on-chain from LP inventory so that longs\/shorts pay each other (and the protocol can take a cut). Risk-increasing trades require a \u201crecent\u201d crank (e.g. within ~200 slots) so that mark and funding are up to\u00a0date.<\/p>\n<h4>7. Insurance and\u00a0Risk<\/h4>\n<p>\u2022 An insurance fund (topped up by admin or fees) absorbs losses when positions are liquidated or force-closed. There is a threshold; below it, the market can enter \u201crisk reduction only\u201d (only position-reducing trades allowed).<\/p>\n<p>\u2022 <strong>Haircut-ratio logic<\/strong> (O(1) aggregates: total capital, positive PnL) is used so the system can handle insolvencies without a heavy ADL sweep. Conservation is maintained: vault \u2265 capital + insurance + positive PnL (with small rounding tolerance).<\/p>\n<h4>8. Binary \/ Premarkets<\/h4>\n<p>The same slab can be used as a binary (event) market: outcome YES\/NO. Admin sets an oracle authority, pushes a settlement price (e.g. 1.0 = YES, ~0 = NO), then calls resolve-market. After that, no new trades\/deposits; keeper crank force-closes all positions at the settlement price. Once everything is closed, admin can withdraw insurance and users withdraw remaining capital. So: one codebase for both perpetuals and event settlement.<\/p>\n<h4>Use Cases<\/h4>\n<h4>1. Perpetual Futures (Standard or Inverted)<\/h4>\n<p>\u2022 <strong>Standard<\/strong>: e.g. SOL\/USD perp with SOL or USDC as collateral; long\/short SOL.<\/p>\n<p>\u2022 <strong>Inverted<\/strong>: e.g. SOL collateral, price = 1\/SOL in USD terms; long = bullish USD (bearish SOL), short = bearish USD (bullish SOL). Good when you want to keep collateral in SOL and express a view on \u201cSOL going up or\u00a0down.\u201d<\/p>\n<p>Use the CLI (or SDK) to: init market \u2192 init user \u2192 deposit \u2192 run keeper crank \u2192 trade (trade-cpi or trade-nocpi). Same flow for both, only invert and unit_scale differ in init-market.<\/p>\n<h4>2. Liquidity Provision (Passive or\u00a0vAMM)<\/h4>\n<p>\u2022<strong> Passive LP:<\/strong> one matcher (e.g. percolator-match) with a fixed spread (e.g. 50 bps). LP deposits collateral, init-lp with that matcher context; traders get oracle \u00b1\u00a0spread.<\/p>\n<p>\u2022 <strong>vAMM-style LP:<\/strong> matcher with base spread + impact + fee. Tighter spreads for small size, wider for large; you can run scripts like add-vamm-lp.ts to add such LPs. Bots (e.g. random-traders.ts) can route to the best LP by simulated price.<\/p>\n<p><strong>Use case:<\/strong> market-making, earning spread\/fees, or running a custom pricing strategy in your own\u00a0matcher.<\/p>\n<h4><strong>3. Keeper \/ Infrastructure<\/strong><\/h4>\n<p>\u2022 <strong>Crank bot:<\/strong> calls keeper-crank every few seconds so funding and mark are fresh and liquidations run. Required for risk-increasing trades (staleness checks).<\/p>\n<p>\u2022 <strong>Liquidator:<\/strong> monitors accounts and calls liquidate-at-oracle when an account is under maintenance margin. Permissionless; liquidator earns a\u00a0fee.<\/p>\n<p>Use case: run public goods (crank) or profit from liquidation fees.<\/p>\n<h4><strong>4. Binary \/ Event Markets (Premarkets)<\/strong><\/h4>\n<p>\u2022 Create a slab with no external feed (e.g. Pyth feed ID = zeros, \u201cHyperp\u201d mode), set initial mark price (e.g. 0.5 = 50% implied), set oracle authority to\u00a0admin.<\/p>\n<p>\u2022 Users trade as in a perp; when the event resolves, admin push-oracle-price (YES=1e6, NO\u22480), then resolve-market, then crank until all positions are force-closed, then withdraw insurance and user\u00a0capital.<\/p>\n<p><strong>Use case:<\/strong> prediction markets, event contracts, or any binary outcome that settles at a single\u00a0price.<\/p>\n<h4><strong>5. Testing and Stress\u00a0Testing<\/strong><\/h4>\n<p>\u2022 Oracle authority: push fixed or extreme prices to test liquidations, funding, or edge cases without moving real\u00a0markets.<\/p>\n<p>\u2022 Scripts: e.g. stress-haircut-system.ts, stress-worst-case.ts, oracle-authority-stress.ts, pentest-oracle.ts for security\/stress; test-*.ts for invariants and\u00a0flows.<\/p>\n<p>\u2022 Devnet: setup-devnet-market.ts creates a full inverted SOL\/USD market with Chainlink and a funded LP; you can run bots and tests against\u00a0it.<\/p>\n<p>Use case: protocol teams, auditors, or integrators validating behavior before\u00a0mainnet.<\/p>\n<h4>6. Admin and Parameter Tuning<\/h4>\n<p>\u2022 update-config: change funding horizon, K, scale, max premium, threshold floor\/risk\/interval\/step\/alpha\/min\/max (funding and risk-threshold behavior).<\/p>\n<p>\u2022 set-risk-threshold, set-maintenance-fee: fine-tune risk and\u00a0cost.<\/p>\n<p>\u2022 topup-insurance, withdraw-insurance (when resolved and empty): manage insurance fund.<\/p>\n<p>Use case: market operators adjusting to volatility or\u00a0demand.<\/p>\n<h4>Potential and Directions<\/h4>\n<h4>1. Perpetuals on\u00a0Solana<\/h4>\n<p>Percolator shows that a single-program, single-slab perpetual engine can live on Solana with Pyth\/Chainlink, multiple LPs, and permissionless crank\/liquidators. That\u2019s a base\u00a0for:<\/p>\n<p>\u2022 Public perp markets (e.g. SOL, BTC, ETH) with SOL or stablecoin collateral.<\/p>\n<p>\u2022 Inverted markets where collateral is the native asset and traders want leveraged exposure to \u201cthe other side\u201d of the\u00a0pair.<\/p>\n<h4>2. Pluggable Matchers<\/h4>\n<p>Because pricing is in external matcher programs, the core protocol stays minimal and secure\u00a0while:<\/p>\n<p>\u2022 Teams can ship new matchers (e.g. order-book style, RFQ, or hybrid) without changing the risk\u00a0engine.<\/p>\n<p>\u2022 Multiple matchers (passive, vAMM, etc.) can coexist in one market; traders and bots choose the best price (as in best-price and random-traders).<\/p>\n<p><strong>Potential:<\/strong> a matcher ecosystem (central limit order book, request-for-quote, volatility-sensitive spreads) on top of one shared perp\u00a0engine.<\/p>\n<h4>3. Binary and Event\u00a0Markets<\/h4>\n<p>The same slab and risk engine support resolve + force-close at settlement price,\u00a0so:<\/p>\n<p>\u2022 Prediction markets and event contracts can be built on the same codebase as\u00a0perps.<\/p>\n<p>\u2022 Operators can run both perps and binary markets with one deployment and one\u00a0CLI\/SDK.<\/p>\n<p><strong>Potential<\/strong>: unified \u201cfutures + events\u201d layer on\u00a0Solana.<\/p>\n<h4>4. Composability and Automation<\/h4>\n<p>\u2022 Programmatic API: the CLI is a thin wrapper over instructions and slab parsing; the repo\u2019s encode*, buildAccountMetas, and parse* functions are a small SDK. UIs, bots, and other programs can compose on\u00a0top.<\/p>\n<p>\u2022 Keeper\/liquidator incentives: permissionless crank and liquidate-at-oracle allow third parties to run infrastructure and earn fees without permission.<\/p>\n<p><strong>Potential<\/strong>: integrations with wallets, aggregators, and automated strategies.<\/p>\n<p>FOR EDUCATIONAL PURPOSES ONLY. The Percolator program and this CLI have not been audited. Do not use in production or with real funds. Use at your own\u00a0risk.<\/p>\n<h4><strong>Source<\/strong><\/h4>\n<p>This article is based on the percolator-cli codebase (https:\/\/github.com\/aeyakovenko\/percolator-cli) and related repos (percolator, percolator-prog, percolator-match).<\/p>\n<p><a href=\"https:\/\/medium.com\/coinmonks\/percolator-protocol-perpetual-trading-on-solana-f854fe2bc250\">Percolator Protocol: Perpetual Trading on Solana<\/a> was originally published in <a href=\"https:\/\/medium.com\/coinmonks\">Coinmonks<\/a> on Medium, where people are continuing the conversation by highlighting and responding to this story.<\/p>","protected":false},"excerpt":{"rendered":"<p>Understanding the Percolator perpetual protocol on Solana\u200a\u2014\u200awithout the\u00a0jargon. What Is Percolator? Percolator is an on-chain perpetual futures protocol built on Solana. In plain terms: it lets people trade leveraged long\/short positions on an asset (e.g. SOL) that never expire, with collateral held in a shared vault and prices coming from oracles (e.g. Chainlink, Pyth). The [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":133439,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-133438","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-interesting"],"_links":{"self":[{"href":"https:\/\/mycryptomania.com\/index.php?rest_route=\/wp\/v2\/posts\/133438"}],"collection":[{"href":"https:\/\/mycryptomania.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mycryptomania.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/mycryptomania.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=133438"}],"version-history":[{"count":0,"href":"https:\/\/mycryptomania.com\/index.php?rest_route=\/wp\/v2\/posts\/133438\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mycryptomania.com\/index.php?rest_route=\/wp\/v2\/media\/133439"}],"wp:attachment":[{"href":"https:\/\/mycryptomania.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=133438"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mycryptomania.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=133438"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mycryptomania.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=133438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}