Peg Docs

The Peg program

The on-chain rules that move a peg's pool and nothing else.

The Peg program holds every peg's supply and its DLMM position. It has two instructions and no way to send tokens or SOL out of its accounts: liquidity always goes back into the pool.

register_peg

Binds a peg token to its pool. It checks that:

  • the mint authority and freeze authority are revoked;
  • the peg's account holds 100% of the supply;
  • the pool is a Meteora DLMM pool of this peg against SOL.

reprice

Moves a peg's pool to a signed price. In one instruction it:

  1. checks an ed25519 signature from the price signer over the peg, the target bin and a timestamp, placed in the same transaction;
  2. refuses a timestamp that is not newer than the last one, or older than 2 minutes;
  3. refuses a move larger than 400 bins (about 49%) in one update;
  4. claims the position's fees and removes all of its liquidity;
  5. moves the pool's active bin to the target;
  6. puts all of it back: peg tokens from the price up, SOL below it, concentrated around the price.

Anyone can send a reprice with a valid signed price; the program accepts nothing else. The price signer cannot withdraw anything: a wrong price moves the pool no further than those limits allow.

Outside liquidity

DLMM pools accept liquidity from anyone. If outside liquidity sits between the current price and the target, the program places a small amount of its own at the target, then swaps through exactly the outside liquidity on the path. The swap stops on the target in the same update, and what is left of the outside liquidity ends up on the far side of the price.

Upgrades

The program's upgrade authority is revoked after deployment, so its rules cannot change.