Architecture

bwickchain is a proof-of-stake blockchain with a set of CosmWasm smart contracts and off-chain services that together form a token launch and trading ecosystem.

System Overview

┌─────────────────────────────────────────────────────────────────┐
│                         bwickchain                               │
│                                                                 │
│  Chain Modules          CosmWasm Contracts                 │
│  ┌──────────┐ ┌──────────┐  ┌─────────────┐ ┌──────────────┐   │
│  │ x/bridge │ │x/token   │  │  Launchpad  │ │     AMM      │   │
│  │ mint/burn│ │ launch   │  │  (bonding   │ │  (xy=k DEX)  │   │
│  └──────────┘ └──────────┘  │   curves)   │ └──────────────┘   │
│                              └─────────────┘                    │
│  ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐           │
│  │ x/bank   │ │x/staking │ │  x/wasm  │ │  x/gov   │           │
│  └──────────┘ └──────────┘ └──────────┘ └──────────┘           │
│                                                                 │
├─────────────────────────────────────────────────────────────────┤
│                     BFT Consensus                          │
└────────────┬────────────────────┬───────────────────┬───────────┘
             │                    │                   │
        ┌────┴────┐          ┌────┴────┐         ┌────┴────┐
        │  RPC    │          │  REST   │         │  gRPC   │
        │ :26657  │          │ :1317   │         │ :9090   │
        └────┬────┘          └────┬────┘         └────┬────┘
             │                    │                   │
     ┌───────┴────────────────────┴───────────────────┴────────┐
     │                   Off-Chain Services                     │
     │                                                          │
     │  ┌──────────────┐  ┌───────────────┐  ┌──────────────┐  │
     │  │   Backend    │  │ Telegram Bot  │  │   Relayer    │  │
     │  │  (indexer +  │  │  (trading UI  │  │ (Solana ↔    │  │
     │  │   REST API)  │  │   in chat)    │  │  BWICK bridge) │  │
     │  └──────────────┘  └───────────────┘  └──────────────┘  │
     └──────────────────────────────────────────────────────────┘

Technology Stack

ComponentTechnologyVersion
ConsensusBFT proof-of-stakeLatest
Applicationbwickchain runtimev0.53.4
Smart Contractswasmd (CosmWasm)v0.60.3
IBCibc-gov10.4.0
BackendNode.js / TypeScript / Express-
DatabaseTimescaleDB (PostgreSQL)-
Telegram BotgrammY (TypeScript)-
RelayerTypeScript / CosmJS-

Launchpad (Bonding Curves)

The Launchpad is a CosmWasm contract that lets anyone create a new token with a built-in bonding curve. It works like pump.fun - tokens start cheap, price rises as people buy, and the token automatically graduates to the AMM when enough BWICK accumulates.

How It Works

┌──────────────┐       ┌───────────────────┐       ┌──────────────┐
│   Create     │──────▶│  Bonding Curve     │──────▶│  Graduated   │
│  (pay 80K    │       │  (buy/sell along   │       │  (all liqui- │
│   BWICK fee)   │       │   constant-product │       │   dity moves │
│              │       │   virtual curve)   │       │   to AMM)    │
└──────────────┘       └───────────────────┘       └──────────────┘
                        threshold reached ─────────▶

Token Supply Distribution

Each token launches with a fixed 100M supply, split between the bonding curve and AMM liquidity:
AllocationAmountPurpose
Tokens on curve~79.31MAvailable for buyers during bonding phase
Tokens for LP~20.69MReserved for the AMM pool at graduation
These are dynamically computed from the oracle BWICK/USD price and configured USD targets when each token is created.

Bonding Curve Math

The launchpad uses a constant-product virtual curve (not a simple linear curve). Virtual reserves create a starting price without requiring seed liquidity:
K = virtual_bwick * virtual_tokens              (constant)
virtual_tokens_current = virtual_tokens_start - tokens_sold
virtual_bwick_current    = K / virtual_tokens_current
Spot price (ubwick per token):
price = K * 10^6 / (virtual_tokens_current)^2
Buy calculation (BWICK in, tokens out):
fee            = bwick_input * buy_fee_bps / 10000
bwick_after_fee  = bwick_input - fee
tokens_out     = virtual_tokens_current - K / (virtual_bwick_current + bwick_after_fee)
Sell calculation (tokens in, BWICK out):
bwick_gross = virtual_bwick_current - K / (virtual_tokens_current + tokens_in)
fee       = bwick_gross * sell_fee_bps / 10000
bwick_out   = bwick_gross - fee

Fee Structure

FeeRateDetails
Token creation80,000 BWICKFixed fee, becomes initial curve reserves
Buy fee0.5% (50 bps)Deducted from BWICK input before curve math
Sell fee2.5% (250 bps)Deducted from BWICK output after curve math
All fees stay in the curve’s BWICK reserves, which means fees accelerate progress toward graduation. At graduation, all accumulated reserves (including fees) flow into the AMM pool.

Dynamic Graduation Threshold

The graduation threshold is computed from the current BWICK/USD oracle price:
threshold_ubwick = target_raised_usd * 10^6 / bwick_usd_price
Clamped between configurable min/max bounds:
ParameterDefault
Graduation raise10,000,000 BWICK (fixed, oracle-independent)
Target starting market cap (USD)$1,000
Target graduation market cap (USD)$10,000
Min graduation threshold100,000 BWICK
Max graduation threshold50,000,000 BWICK
The graduation threshold is a fixed BWICK amount, so it is deterministic regardless of BWICK price swings. Curve sizing uses constant-product virtual reserves chosen so the AMM pool opens at the same price the curve ends at.

Graduation Flow

When bwick_reserves >= graduation_threshold (auto-triggered on any buy, or callable manually):
  1. Mark the curve as graduated (permanently closed)
  2. Transfer all remaining unsold tokens to the AMM contract
  3. Call AMM CreatePool with all BWICK reserves + remaining tokens
  4. The AMM pool starts with an augmented fee (see below)

AMM (Decentralized Exchange)

The AMM is a constant-product automated market maker (x * y = k) for tokens that have graduated from the Launchpad. Swap fees stay in the pool and auto-compound, benefiting liquidity providers.

Pool Creation

Pools are created only by authorized contracts - the Launchpad (at graduation) and the x/tokenlaunch module (for curated listings). Regular users cannot create pools. When a token graduates:
AssetAmount
BWICKAll curve reserves (~graduation threshold)
TokenAll unsold tokens from the curve (~20.69M)

Swap Math

Standard constant-product formula:
fee_amount      = input_amount * fee_bps / 10000
input_after_fee = input_amount - fee_amount
output_amount   = output_reserve * input_after_fee / (input_reserve + input_after_fee)
Fee tokens stay in the pool, increasing reserves. LP positions grow in value as fees accumulate - no claiming or compounding needed.

Fee Structure

FeeRateDetails
Base swap fee1% (100 bps)Applied to all swaps, stays in pool
Augmented fee1% (100 bps)Extra fee on newly graduated pools

Augmented Fee

Newly graduated pools start with a temporary extra 1% fee on top of the base 1%. This protects early liquidity and discourages manipulation right after graduation. The augmented fee auto-disables when the pool reaches 10x its initial value:
pool_value = bwick_reserve * 2
disabled when: pool_value >= initial_bwick * 10
No admin action needed - the check runs on every swap automatically.

Trade Routing

DirectionHow
BWICK to TokenSend native ubwick with Swap message to AMM
Token to BWICKCW20 Send to AMM with SwapTokenForBwick inner message

Launchpad + AMM Lifecycle

The full lifecycle of a token from creation through trading:
1. Creator pays 80K BWICK → Launchpad creates CW20 token + bonding curve

2. Users buy/sell on curve      │  price rises as supply decreases
   (0.5% buy fee, 2.5% sell)   │  fees accumulate in BWICK reserves

3. BWICK reserves hit threshold ──┘

4. Graduation (auto-triggered)  │  all BWICK + unsold tokens → AMM

5. AMM pool created             │  augmented fee active (1% extra)

6. Trading continues on AMM     │  xy=k pricing, 1-2% swap fee

7. Pool grows to 10x value ─────┘  augmented fee auto-disabled

Bridge (Solana ↔ bwickchain)

The bridge is a native chain module (x/bridge) with a trusted relayer architecture. BWICK tokens on Solana are locked/released, and corresponding tokens are minted/burned on bwickchain.

Solana to BWICK (Deposit)

User locks BWICK SPL tokens on Solana
  → Relayer detects lock event
  → Relayer submits MsgMintFromBridge on bwickchain
    - Validates: bridge enabled, caller is relayer, lock not already processed
    - Mints ubwick to recipient
    - Records mint (idempotent dedup by lock ID)
    - Tracks total bridge-minted supply

BWICK to Solana (Withdraw)

User submits MsgBurnForBridgeOut(solana_address, amount)
  → Coins escrowed (NOT burned yet) in module account
  → If amount > approval threshold: requires admin approval first
  → Relayer releases SPL tokens on Solana
  → Relayer confirms release → coins burned from module account
Coins are escrowed rather than immediately burned. If the Solana-side release fails, the user’s funds are safe.

Safety Parameters

ParameterDefault
Max burn per tx1,000,000 BWICK
Max mint per tx1,000,000 BWICK
Max burns per block10
Admin approval threshold100,000 BWICK

Supply Tracking

An on-chain counter (BridgeMintedSupply) tracks total minted supply from bridging. Users cannot burn more than has been bridged in, preventing the bridge from creating inflation.

Telegram Bot

The Telegram Bot is a self-custodial trading interface built with grammY. Users get an encrypted wallet and can trade tokens without leaving Telegram.

How It Works

┌──────────────┐     ┌──────────────────┐     ┌──────────────┐
│   Telegram   │────▶│   Bot Service    │────▶│  bwickchain   │
│   (user)     │     │                  │     │              │
│              │◀────│  - Wallet mgmt   │◀────│  Launchpad   │
│  /start      │     │  - Trade routing │     │  AMM         │
│  paste addr  │     │  - Limit orders  │     │  CW20s       │
│  /buy /sell  │     │  - Referrals     │     │              │
└──────────────┘     └──────────────────┘     └──────────────┘

Trade Routing

The bot automatically routes trades to the correct contract based on token status:
Token StatusBuy RouteSell Route
On bonding curveLaunchpad BuyCW20 Send to Launchpad
GraduatedAMM SwapCW20 Send to AMM
Users don’t need to know which contract to interact with - the bot queries the token’s graduation status and routes accordingly.

Limit Orders

The bot runs a limit order monitor that polls prices every 15 seconds:
  • Buy orders trigger when price drops to or below the target
  • Sell orders trigger when price rises to or above the target
  • Execution uses the same routing logic as manual trades
  • Users are notified via Telegram message when orders fill

Wallet Security

Each user gets a 24-word HD mnemonic wallet, encrypted at rest:
  • AES-256-GCM encryption with per-user random salt
  • Key derived via PBKDF2-SHA512 (600,000 iterations) from a server master key
  • Mnemonics never stored in plaintext
  • Export shows mnemonic briefly, then auto-deletes the message after 30 seconds

Backend (Indexer + API)

The backend is a Node.js service that indexes chain events and provides a REST API and real-time data feeds for frontends and the Telegram bot.

Indexing Pipeline

bwickchain (chain RPC, polled every ~5s)


  Block Poller
  (searchTx for each block height)


  Event Parser
  (filters wasm events from Launchpad + AMM contracts)


  Trade Writer (single DB transaction)
  ├── INSERT raw_trades (idempotent via ON CONFLICT)
  ├── UPSERT tokens (auto-discovery on first trade)
  ├── UPDATE indexer_state (cursor)
  └── COMMIT → SSE broadcast


  TimescaleDB Continuous Aggregates
  raw_trades → ohlcv_1m → ohlcv_5m → ohlcv_1h → ohlcv_1d

API Endpoints

RouteDescription
GET /api/tokensAll indexed tokens with metadata
GET /api/tokens/:addressSingle token details
GET /api/tradesRecent trades (filterable by token)
GET /api/candles/:addressOHLCV candles (1m, 5m, 1h, 1d timeframes)
GET /api/sseServer-Sent Events stream (trades, launches, graduations)
GET /api/wallet/balanceNative BWICK balance
GET /api/wallet/tokensCW20 token balances
POST /api/wallet/broadcastRelay signed transactions to chain

Oracle Price Feed

An oracle updater fetches the BWICK/USD price from pump.fun every 5 minutes and submits it to the Launchpad contract. This price is used for USD display values across the apps; graduation itself is denominated in BWICK and does not depend on the oracle.

Custom Chain Modules

x/bridge

Handles Solana ↔ BWICK token bridging with mint/burn mechanics, relayer authorization, and admin approval for large transfers. See Bridge Architecture for details.

x/tokenlaunch

Provides an on-chain governance path for listing tokens directly in the AMM, bypassing the bonding curve. Only bridge-verified wallets (users who have used the Solana bridge) can vote on proposals, providing Sybil resistance. Flow: Submit proposal → bridge-verified wallets vote → at threshold, admin seeds AMM pool with CW20 token + BWICK liquidity.

Standard Chain Modules

ModuleStatusNotes
x/authActiveAccount management
x/bankActiveNative token transfers
x/stakingActiveValidator operations
x/govActiveOn-chain governance
x/distributionActiveFee reward distribution
x/mintDisabledZero inflation - all params set to 0
x/wasmActiveCosmWasm smart contracts
x/ibcActiveInter-Blockchain Communication

Network Endpoints

ServicePortProtocolPurpose
Chain RPC26657HTTP/WSBlock queries, tx broadcast
REST API1317HTTPchain state queries
gRPC9090HTTP/2High-performance queries
Launchpad API3001HTTPToken data, candles, SSE feeds
P2P26656TCPNode communication