papertrade-sdk docs

Concepts

The complete, verified derivations are in the Protocol reference. This page is the working summary.

Units#

Markets and limits#

Bust (liquidation) price#

For a long, bust = ceil(entry * (L - 1) / L) * (1 + buffer). For a short, bust = ceil(entry * (L + 1) / L * (1 - buffer)). The buffer is about 4.76 bps. At 500x a long is liquidated about 0.15% below entry. liquidationPriceRaw reproduces the protocol integer exactly.

How a close settles#

  1. Loss: you lose the raw loss, with nothing on top. Crossing the bust price forfeits the full margin.
  2. Win: the raw gain first loses an integer deadband (entry / 50,000), then an asymmetric impact haircut that grows with the size of the move and the position, then a 2% win fee.
  3. estimateClose returns each stage, plus keptFraction, the share of the raw gain you keep.

PAPER#

PAPER is minted on realized losses (the loss basis is 98% of the loss) at a rate that is flat at 100 per 1 USD while tracked LP is under 2M USD, then decays with the tail-progress high-water mark. paperMintRate and estimatePaperMinted implement the curve. Staked PAPER earns protocol fees; pendingStakingRewardRaw computes pending rewards with 1e27 precision.

Intents, session keys and nonces#

Raw Markdown: /docs/concepts.md