Skip to content

lfzlim/XRPL-Hackathon-2026

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

30 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ”„ LoyaltySwap

Slides Link

Swap loyalty points anywhere on XRPL

Unlocking ~$10B AUD in siloed loyalty value. Trade Macca's for Qantas, Woolworths for GYG โ€” instantly, trustlessly, on-chain.

LoyaltySwap Banner Build License XRPL


๐ŸŽฏ The Problem

Australians hold $10B+ AUD in loyalty points trapped in silos. You can't swap Macca's points for Qantas miles. Points expire. Value is lost.

LoyaltySwap tokenises loyalty points as XRPL tokens, enabling market-driven AMM swaps via rippling โ€” no brand system changes required.


โšก Quick Start

Option A: Local Development

# 1. Clone the repository
git clone <repo-url>
cd XRPL-Hackathon-2026

# 2. Install frontend dependencies
npm install

# 3. Set up backend
cd backend
python3 -m venv venv
source venv/bin/activate        # On Windows: venv\Scripts\activate
pip install -r requirements.txt
cd ..

# 4. Start backend (first run creates 7 issuer wallets on XRPL Testnet ~60s)
cd backend
source venv/bin/activate
uvicorn main:app --host 0.0.0.0 --port 8000
# Wait for: โœ… 7 AMM pools seeded (in-memory)
# Subsequent restarts are instant (wallets cached in .issuer_wallets.json)

# 5. In a new terminal, start frontend
cd XRPL-Hackathon-2026
npm run dev

Option B: Docker

docker-compose up --build

๐Ÿš€ Features

๐Ÿ” AMM Swap Widget (Hero)

Uniswap-style two-panel swap interface. Select any loyalty token pair, see live AMM quotes with optimal routing (mMacca โ†’ XRP โ†’ mQantas), price impact, and execute real on-ledger XRPL transactions.

๐Ÿ’ฐ 7 Tokenised Australian Brands

Token Brand Description
๐Ÿ” mMacca McDonald's AU MyMacca's Rewards
โœˆ๏ธ mQantas Qantas Airways Frequent Flyer Points
๐Ÿ›ฉ๏ธ mJetstar Jetstar Airways Jetstar Rewards
๐ŸŒฎ mGYG Guzman y Gomez GYG Loyalty
๐ŸŽ mApple Apple Apple Rewards
๐Ÿ’ป mKmart Kmart Kmart Rewards
๐Ÿ›’ mWoolies Woolworths Everyday Rewards

๐Ÿ’ง Liquidity Pools

Provide liquidity to earn 0.3% AMM fees. View TVL, APY, and pool share in real-time.

๐Ÿ“ฒ P2P Transfers

Send tokenised points to any XRPL address with real on-ledger Payment transactions. QR code generation for instant sharing.

๐Ÿง On-Ramp (Deposit)

Custodial ramp with 3-step flow: select brand โ†’ scan QR โ†’ mint tokens 1:1. Auto-creates trustlines for new tokens.


๐ŸŽฎ Demo Flow

Follow this exact flow to see the full LoyaltySwap experience:

Step 1: Connect Wallet

  1. Click "Connect Xaman" (top-right, pink button)
  2. Wait ~15s โ€” a real XRPL Testnet wallet is created via faucet with 3 token trustlines + initial balances
  3. โœ… You'll see your real truncated XRPL address and XRP balance

Step 2: Execute a Swap

  1. On the Swap tab (default), enter 100 in the "You pay" field
  2. Note the live quote: ~79 mQantas from 100 mMacca
  3. See the routing: mMacca โ†’ XRP โ†’ mQantas
  4. Click "Swap" โ€” real XRPL transactions are submitted (~5s)
  5. Click the explorer link to see your transaction on https://testnet.xrpl.org
  6. Click "Done" โ€” balances update from the ledger

Step 3: Browse Token Grid

  1. Click any brand card to go to the swap widget

Step 4: Add Liquidity

  1. Click the "Liquidity" tab
  2. Select two tokens, enter amounts
  3. See pool TVL, APY, and your share estimate
  4. Click "Add Liquidity"

Step 5: Send P2P

  1. Click the "Transfer" tab
  2. Enter a recipient XRPL address
  3. Select token + amount โ†’ click "Send"
  4. See your QR code for receiving

Step 6: Deposit Points

  1. Click the "On-Ramp" tab
  2. Select a brand (e.g., mMacca), enter 500
  3. Click "Scan & Mint" โ€” watch the 3-step process
  4. Points are minted 1:1 to your wallet

๐Ÿ—๏ธ Architecture

XRPL-Hackathon-2026/
โ”œโ”€โ”€ index.html              # Entry point
โ”œโ”€โ”€ vite.config.js          # Vite + React + proxy config
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ docker-compose.yml      # One-command Docker setup
โ”œโ”€โ”€ Dockerfile              # Frontend container
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ .dockerignore
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ main.py             # FastAPI app with lifespan + CORS
โ”‚   โ”œโ”€โ”€ routes.py           # All API endpoints (auth, swap, mint, transfer, pools)
โ”‚   โ”œโ”€โ”€ xrpl_client.py      # XRPL Testnet integration (wallets, hex currencies, AMM)
โ”‚   โ”œโ”€โ”€ requirements.txt    # Python deps (fastapi, xrpl-py, uvicorn)
โ”‚   โ”œโ”€โ”€ Dockerfile          # Backend container
โ”‚   โ””โ”€โ”€ .issuer_wallets.json # Cached issuer wallets (auto-generated, gitignored)
โ””โ”€โ”€ src/
    โ”œโ”€โ”€ main.jsx             # React root with WalletProvider
    โ”œโ”€โ”€ App.jsx              # Main layout: tabs, hero, footer
    โ”œโ”€โ”€ index.css            # Full design system (600+ lines)
    โ”œโ”€โ”€ context/
    โ”‚   โ””โ”€โ”€ WalletContext.jsx # Real XRPL wallet state (faucet, seed, balances)
    โ”œโ”€โ”€ data/
    โ”‚   โ”œโ”€โ”€ tokens.js        # 7 brand token definitions
    โ”‚   โ””โ”€โ”€ pools.js         # Local AMM pool calculations (fallback)
    โ”œโ”€โ”€ services/
    โ”‚   โ””โ”€โ”€ api.js           # API service layer (connects to FastAPI backend)
    โ””โ”€โ”€ components/
        โ”œโ”€โ”€ Navbar.jsx       # Sticky nav + tab bar + wallet button
        โ”œโ”€โ”€ SwapWidget.jsx   # Uniswap-style swap interface
        โ”œโ”€โ”€ TokenSelector.jsx# Searchable token modal
        โ”œโ”€โ”€ BrandGrid.jsx    # 7-card token overview grid
        โ”œโ”€โ”€ LiquidityPanel.jsx # LP interface
        โ”œโ”€โ”€ P2PTransfer.jsx  # Send tokens + QR code
        โ”œโ”€โ”€ OnRamp.jsx       # Deposit (scan โ†’ mint with auto-trustline)
        โ”œโ”€โ”€ SuccessOverlay.jsx # Confetti + tx hash + explorer link
        โ””โ”€โ”€ RevenueWidget.jsx # Platform stats dashboard

How Swaps Work (Real XRPL Testnet)

User: Swap 100 mMacca โ†’ mQantas

1. Quote: Constant product AMM math (x * y = k), 0.3% fee per hop
2. Route: mMacca โ†’ XRP โ†’ mQantas (two hops)
3. Step 1: User sends 100 mMacca to mMacca issuer (real Payment tx)
4. Step 2: mQantas issuer sends ~79 mQantas to user (real Payment tx)
5. Auto-trustline: If user doesn't have mQantas trustline, it's created first
6. Result: Two real on-ledger transactions, visible on testnet.xrpl.org
7. Currency codes: >3 char names hex-encoded (mMacca โ†’ 6D4D616363610000...)

๐ŸŽจ Design System

Token Hex Usage
--pink #FF007A Primary CTAs, accents
--dark-bg #0D0D0D App background
--dark-card #191919 Card surfaces
--green #27AE60 Positive indicators
--purple #8B5CF6 Liquidity theme
--red #EB5757 Negative indicators

Font: Inter (Google Fonts) โ€” 400/500/600/700/800/900
Responsive: Mobile-first, max-width 1200px, bottom nav on mobile


๐Ÿ› ๏ธ Tech Stack

Layer Technology
Frontend React 19 + Vite 5
Backend Python FastAPI + uvicorn
XRPL xrpl-py โ€” real Testnet transactions
Styling Vanilla CSS with design tokens
Icons Lucide React
QR Codes qrcode.react
Animations react-confetti + CSS keyframes
AMM Engine Custom constant product (x*y=k)
Network XRPL Testnet (s.altnet.rippletest.net)
Deploy Docker Compose

๐Ÿ”‘ API Endpoints

Method Endpoint Description
GET /health Backend health + pool count
POST /api/v1/auth/connect Connect wallet, get JWT + balances
POST /api/v1/wallet/create Create funded testnet wallet + trustlines
GET /api/v1/wallet/balances/{address} Real on-ledger token balances
GET /api/v1/swaps/quote AMM swap quote
POST /api/v1/swaps/execute Execute real swap (2 Payment txs)
POST /api/v1/tokens/mint/{token} Mint tokens from issuer to user
POST /api/v1/transfers/send P2P token transfer
GET /api/v1/pools All AMM pool info
GET /api/v1/tokens Token metadata + hex codes + issuers

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors