Skip to content

Gavelpump/GAVEL

License CI Latest Release Last Commit Repo Size Stars Open Issues Twitter Website Docs


On-chain governance launchpad on Solana. Anchor program, TypeScript SDK, Rust CLI.

Creators stake SOL at a tier level to launch tokens. Mint authority goes to a governance PDA. Holders earn time-weighted voting power and can fire the creator, redistribute stake, or replace the dev wallet through on-chain proposals.


Features

Feature Status Description
Tiered staking stable Bronze (1), Silver (10), Gold (50), Diamond (200 SOL)
Constant product bonding curve stable k = reserve_sol * reserve_tokens with fee split
Time-weighted governance stable vote_power = balance * min(hold_seconds, 90d)
Fire creator stable Remove dev and redistribute stake to claim pool
Replace creator stable Swap dev wallet via governance vote
Fee timelock stable 30-day lock before creators can withdraw trading fees
Claim pool distribution stable Pro-rata SOL claims after fire event, bitmap-tracked
TypeScript SDK stable Full client with PDA derivation, curve math, account fetch
Rust CLI beta Inspect launches, check vote power, derive PDAs
Permissionless weight crank stable Anyone can refresh voting weights for any position

Architecture

The protocol runs as a single Anchor program on Solana with five account types.

Platform is a singleton PDA holding global config: the platform authority, treasury address, fee rate, and TVL cap. It tracks total launches and can be paused.

Launch is created per token. It stores the SPL mint, creator wallet, tier, stake amounts (locked + vesting), bonding curve reserves (SOL and token), the constant product k, accrued fees, circulating supply, status (Active/Fired/Migrated), and proposal/holder counters. Each Launch has two child PDAs: a Vault (holds SOL reserves) and a MintAuthority (controls the SPL mint).

Position is created per wallet per launch. It tracks the holder's token balance, a time-weighted average entry timestamp (recalculated on each buy), last trade timestamp, and an optional voter index assigned on first vote.

Proposal is created per governance motion. It records the proposal kind (FireDev, ReplaceDev, UpdateFee, Migrate), vote tallies (time-weighted u128), voter count, a snapshot of circulating supply for quorum, voting period expiry, and current status.

ClaimPool is created when a FireDev proposal executes. It holds the redistributed SOL, tracks remaining balance, stores a snapshot of total tokens and voting power, and uses a 1024-bit bitmap to prevent double-claiming.

Data flows from Platform down to Launch, from Launch to Position and Proposal, and from Proposal to ClaimPool on fire events. All PDAs are derived from deterministic seeds documented in programs/gavel/src/constants.rs.

Build

git clone https://github.com/Gavelpump/GAVEL.git
cd vol1

Build the Anchor program (requires Solana CLI + Anchor CLI in WSL or Linux):

anchor build

Build the Rust CLI:

cargo build --release -p gavel-cli

Build the TypeScript SDK:

cd sdk
npm install
npm run build

Run tests:

anchor test

Quick Start

TypeScript SDK

import { Connection, Keypair } from "@solana/web3.js";
import BN from "bn.js";
import { GavelClient, Tier } from "@gavel/sdk";

const connection = new Connection("https://api.devnet.solana.com");
const wallet = Keypair.generate();
const client = new GavelClient(connection, wallet);

// Launch a Silver-tier token (stakes 10 SOL)
const launch = await client.createToken("MyToken", "MTK", "https://arweave.net/meta", Tier.Silver);
// { signature: "5Uu...", mint: PublicKey, launch: PublicKey, pdas: { vault, position } }

// Buy tokens on the bonding curve
const estimate = await client.estimateBuy(launch.mint, new BN(2_000_000_000));
// { tokens: BN(48291038...), fee: BN(20000000), priceImpact: 0.0312 }

const buySig = await client.buy(launch.mint, new BN(2_000_000_000), estimate.tokens.muln(98).divn(100));

// Sell half the position
const position = await client.fetchPosition(launch.mint);
const sellAmt = position.balance.div(new BN(2));
const sellSig = await client.sell(launch.mint, sellAmt, new BN(1));

// Check vote power
const power = await client.getVotePower(launch.mint);
// BN representing balance * min(holding_seconds, 90d)

Rust CLI

use gavel_cli::commands::{health, launch, platform};

// Check cluster health
let status = health::check("https://api.devnet.solana.com").await?;

// Inspect a launch by mint address
let info = launch::inspect("https://api.devnet.solana.com", &mint_pubkey).await?;
println!("Reserve SOL: {} lamports", info.reserve_sol);
println!("Reserve tokens: {}", info.reserve_tokens);
println!("Status: {:?}", info.status);

// Derive PDA addresses
let (launch_pda, _) = pda::find_launch_address(&mint_pubkey, &program_id);
let (vault_pda, _) = pda::find_vault_address(&launch_pda, &program_id);

Shell

# Build and run the CLI
cargo run -p gavel-cli -- health --cluster devnet

# Inspect a specific launch
cargo run -p gavel-cli -- launch inspect <MINT_ADDRESS>

# Check vote power for a wallet
cargo run -p gavel-cli -- vote-power <MINT_ADDRESS> <WALLET_ADDRESS>

# List all active proposals for a launch
cargo run -p gavel-cli -- proposals list <MINT_ADDRESS>

Project Structure

gavel-engine/
  programs/gavel/
    src/
      instructions/       -- Handler for each of the 11 instructions
        initialize.rs     -- Platform setup
        create_token.rs   -- Token launch with tier staking
        buy.rs            -- Bonding curve buy
        sell.rs           -- Bonding curve sell
        propose.rs        -- Governance proposal creation
        vote.rs           -- Time-weighted vote casting
        execute_proposal.rs -- Proposal finalization
        fire_dev.rs       -- Creator removal + claim pool
        claim_distribution.rs -- Pro-rata SOL claims
        replace_dev.rs    -- Creator wallet swap
        update_weights.rs -- Permissionless weight refresh
      state/              -- Account structs (Platform, Launch, Position, Proposal, ClaimPool)
      constants.rs        -- Seeds, tier amounts, fee rates, time constants
      curves.rs           -- Constant product math, voting power, vesting
      errors.rs           -- 40+ typed error codes
      events.rs           -- Event structs for indexers
      lib.rs              -- Program entrypoint and instruction dispatch
  sdk/
    src/
      client.ts           -- GavelClient high-level API
      types.ts            -- TypeScript type definitions
      accounts/           -- Account fetchers and decoders
      instructions/       -- Instruction builders
      utils/              -- PDA derivation, curve math, voting helpers
  cli/
    src/
      main.rs             -- CLI entrypoint (clap)
      commands/            -- Subcommands (health, launch, platform, pda, proposals, vote_power)
      display/             -- Terminal table formatting
  idl/
    gavel.json            -- Anchor IDL (accounts, instructions, types, errors, events)
  tests/
    gavel.ts              -- Anchor integration tests (mocha)
  examples/
    create_token.ts       -- Launch a token end-to-end
    trade.ts              -- Buy/sell with slippage protection
    governance.ts         -- Full governance lifecycle
  docs/
    architecture.md       -- Protocol overview and PDA structure
    tiers.md              -- Tier system and stake split
    voting.md             -- Time-weighted voting math
    curves.md             -- Constant product AMM formulas

Contributing

See CONTRIBUTING.md for guidelines on code style, testing, and pull request process.

License

MIT. See LICENSE for the full text.

Links

About

On-chain governance launchpad on Solana. Creators stake, holders vote to fire. Anchor program + TypeScript SDK + Rust CLI.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages