Skip to content

edycutjong/paciport

Repository files navigation

PaciPort Logo

⚑ PaciPort

1-Click Perpetual Position Migration

Next.js React CCXT Supabase TypeScript

Migrate open perpetual positions from any exchange to Pacifica in < 2 seconds. Zero market exposure. Zero price risk.

PaciPort is a delta-neutral position migration engine built for the Pacifica Exchange Hackathon. It enables traders to teleport their open perp positions between exchanges with atomic, slippage-minimized execution β€” closing on the source and opening on the destination in parallel to maintain continuous market exposure.


🎯 Problem

Moving perpetual positions between crypto exchanges is a nightmare:

  1. Manual close β†’ transfer β†’ re-open takes minutes, exposing traders to price risk
  2. No tooling exists to atomically migrate positions across exchanges
  3. Sticky TVL β€” exchanges benefit from the friction. Traders pay the cost

πŸ’‘ Solution

PaciPort executes a delta-neutral swap β€” simultaneously closing a position on the source exchange and opening an identical position on the destination β€” achieving zero net market exposure during migration.

Key features:

  • Atomic 2-leg execution β€” close source + open destination concurrently via Promise.allSettled
  • Automatic rollback β€” if one leg fails, the other is reversed
  • Live price simulation β€” real-time PnL updates on all positions
  • Migration receipt β€” detailed execution report with slippage analysis
  • Fee savings calculator β€” shows annual savings from lower maker/taker fees
  • Position teleport animation β€” Framer Motion "teleport" effect as positions move between panels

πŸ—οΈ Architecture

Architecture


πŸ› οΈ Tech Stack

Layer Technology
Framework Next.js 16.2.2 (App Router)
UI React 19.2.4
Styling Tailwind CSS v4 + CSS custom props
Animations Framer Motion 12
Exchange CCXT 4.5 (unified trading API)
Backend Supabase (auth + credential vault)
Fonts Inter + JetBrains Mono
Language TypeScript 5

πŸš€ Getting Started

Prerequisites

  • Node.js β‰₯ 18
  • npm β‰₯ 9

Installation

git clone https://github.com/edycutjong/paciport.git
cd paciport
npm install

Environment Variables

Create a .env.local file in the project root:

# Supabase (optional β€” falls back to mock)
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key

Note: The app runs fully in demo mode without any environment variables. All exchange credentials are mocked and sandbox mode is enforced.

Run Development Server

npm run dev

Open http://localhost:3000 to see the dashboard.

Build for Production

npm run build
npm start

πŸ“ Project Structure

paciport/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ migrate/route.ts      # POST β€” execute position migration
β”‚   β”‚   └── positions/route.ts    # GET  β€” fetch live positions
β”‚   β”œβ”€β”€ globals.css               # Design tokens + animations
β”‚   β”œβ”€β”€ layout.tsx                # Root layout with metadata
β”‚   └── page.tsx                  # Main dashboard (3-column layout)
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ ExchangePanelHeader.tsx   # Exchange connection status header
β”‚   β”œβ”€β”€ MigrateButton.tsx         # Animated migration trigger
β”‚   β”œβ”€β”€ MigrationProgress.tsx     # Step-by-step execution timeline
β”‚   β”œβ”€β”€ MigrationReceipt.tsx      # Post-migration execution report
β”‚   └── PositionCard.tsx          # Individual position display card
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ demo-data.ts              # Demo positions + price simulator
β”‚   β”œβ”€β”€ exchange-client.ts        # CCXT client factory + caching
β”‚   β”œβ”€β”€ migration-engine.ts       # Core delta-neutral swap engine
β”‚   β”œβ”€β”€ supabase.ts               # Supabase client + credential vault
β”‚   └── types.ts                  # TypeScript interfaces
β”œβ”€β”€ public/                       # Static assets
β”œβ”€β”€ package.json
β”œβ”€β”€ tsconfig.json
└── next.config.ts

πŸ“‘ API Reference

POST /api/migrate

Execute a delta-neutral position migration.

Request Body:

{
  "positionIds": ["pos-sol-long", "pos-eth-short"],
  "sourceExchange": "binance",
  "destinationExchange": "pacifica",
  "maxSlippage": 0.1,
  "dryRun": false
}

Response:

{
  "results": [
    {
      "id": "mig-1712592000000-a1b2c3",
      "status": "success",
      "position": { "..." },
      "sourceLeg": { "status": "filled", "fillPrice": 148.18, "slippage": 0.0135 },
      "destinationLeg": { "status": "filled", "fillPrice": 148.22, "slippage": 0.0135 },
      "executionTimeMs": 1412,
      "netSlippage": 0.0135
    }
  ],
  "summary": {
    "total": 1,
    "successful": 1,
    "failed": 0,
    "totalExecutionTimeMs": 1412,
    "allSuccess": true
  }
}

GET /api/positions

Fetch all demo positions with live price updates.


βš™οΈ How the Migration Engine Works

  1. Select positions on the source exchange panel (Binance)
  2. Click Migrate β†’ triggers POST /api/migrate
  3. Engine executes concurrently:
    • Source leg: Close position on Binance (market sell for longs, market buy for shorts)
    • Destination leg: Open identical position on Pacifica (same size, same side)
  4. Atomic safety:
    • Both legs execute via Promise.allSettled
    • If one leg fails and the other succeeds β†’ automatic rollback
    • If both succeed β†’ migration complete
  5. Receipt generated with execution time, slippage per leg, and net slippage

Demo Mode vs Live Mode

Feature Demo Mode (demo-user) Live Mode (real userId)
Order execution Simulated (random slippage) Real CCXT market orders
Exchange connection Mocked credentials Decrypted from Supabase vault
Sandbox mode Always on Based on API key prefix
Rollback Simulated Real reverse orders

🎨 Design System

The UI uses a custom dark theme with CSS custom properties:

Token Value Usage
--bg #09090b Page background
--surface #111113 Card backgrounds
--primary #06b6d4 Pacifica brand (cyan)
--migrate #3b82f6 Migration action (blue)
--success #22c55e Positive PnL
--loss #ef4444 Negative PnL
--speed-gold #fbbf24 Fee savings highlight
--competitor #f59e0b Source exchange (amber)

Fonts: Inter (UI) + JetBrains Mono (data/numbers)


πŸ† Hackathon Context

Competition: Pacifica Exchange Hackathon
Track: DeFi / Exchange Tooling
Core Thesis: Reduce TVL friction by making position migration instant, safe, and free β€” giving Pacifica a competitive acquisition channel for existing perp traders.

Why Pacifica Should Care

  • TVL acquisition tool β€” removes the #1 barrier to switching exchanges
  • Network effect β€” each migration adds liquidity to Pacifica's order books
  • Fee incentive β€” savings calculator shows traders exactly how much they'd save annually

πŸ“„ License

MIT Β© 2026 Edy Cu

About

Delta-neutral position migration engine enabling traders to teleport open perpetual positions between exchanges with atomic execution.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors