ethyi

ethyi


Paperpetual - An paper trading app for crypto derivatives

Paperpetual: Paper perpetual contracts (I'm open to name suggestions).

Paperpetual allows you to paper trade crypto derivatives, mostly perpetual futures.

App

Source Code

image

## Why

US residents aren't allowed to trade perps and levered products due to regulatory reasons.

As FCA states, these products cannot be reliably valued by retail consumers because of the:

  • inherent nature of the underlying assets, which means they have no reliable basis for valuation
  • prevalence of market abuse and financial crime in the secondary market (e.g. cyber theft)
  • extreme volatility in cryptoasset price movements
  • inadequate understanding of cryptoassets by retail consumers
  • lack of legitimate investment need for retail consumers to invest in these products

Anyways I wanted to make a perpetual future trading simulator to better understand how these products are structured, and how risky they actually are.

Perhaps one day regulation will loosen for those who demonstrate a strong understanding of these financial products.

Also wanted to practice basic CRUD with Solana programs. This is my first dApp.

## Implementation

My app uses APIs from exchanges to get trade data and update user balances acoording to their positions. Being a paper trading App, I'm able to host trading pairs from multiple exchanges.

User balance and position data are persisted through cookies by default. If chosen, a user may persist data on-chain in the Solana devnet by using their wallet.

The user account doesn't store actual SPL tokens, that would be an unnecesarily complicated and expensive implementation. I just used a PDA account that stores an array of floats.

I used devnet because its free real estate.

## Stack

  • Frontend
    • Next + React
    • Tailwind + Material UI
    • Typescript
  • Backend / On-chain
    • Anchor
    • Rust

## Stuff to implement

  • More Pairs
    • FTX Levered tokens (no support?)
    • Binance (intl API key?)
    • Dex Perps (no volume lol)
  • Limit and Stop orders
    • Can implement with cookies, but difficult on-chain
      • Somehow have to constantly poll outside data and make the program automatically change acc details
  • Accurate pricing
    • I think my perp pnl is not accurate.
      • I think users receive and pay everytime the perp price deviates from the mark price.
      • How would I know, I've never owned perps