Skip to content

Galiusbro/N-Dollar_SPL_v2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

N-Dollar DeFi Smart Contracts Suite

This repository contains a suite of Solana smart contracts (programs) for a modular DeFi ecosystem centered around the N-Dollar token, custom token creation, distribution, referral rewards, bonding curve mechanics, and a liquidity pool. All programs are written using the Anchor framework.


Programs Overview

1. n-dollar

Purpose: Implements the N-Dollar token and its initial liquidity pool.

Key Features:

  • Creation of the N-Dollar token with metadata.
  • Initialization of a liquidity pool for N-Dollar and SOL.
  • Mints 108,000,000 N-Dollar tokens to the pool vault.

2. liquidity-pool

Purpose: Provides a simple AMM (Automated Market Maker) for swapping between N-Dollar and SOL, and for adding/removing liquidity.

Key Features:

  • Pool initialization with N-Dollar and SOL vaults.
  • Add liquidity (N-Dollar + SOL).
  • Swap SOL to N-Dollar and vice versa using a constant product formula.

3. genesis

Purpose: Allows users to create their own tokens, with metadata, using N-Dollar as payment for rent and fees.

Key Features:

  • Validates token parameters (name, symbol, supply, etc.).
  • Swaps N-Dollar to SOL for rent via the liquidity pool.
  • Creates token mint, metadata, and info accounts.
  • Mints the total supply to a distributor account for further distribution.

4. token-distributor

Purpose: Handles the distribution of newly created tokens according to a predefined allocation.

Key Features:

  • Distributes tokens from the distributor account to:
    • Referral program treasury (10%)
    • Bonding curve (40%)
    • AI agent (50%)
  • Ensures all associated token accounts are created as needed.

5. referral-program

Purpose: Implements a simple referral reward mechanism.

Key Features:

  • Distributes fixed rewards from the referral treasury to two referees.
  • Ensures sufficient treasury balance and correct account ownership.

6. bonding-curve

Purpose: Implements a linear bonding curve for token price discovery and liquidity.

Key Features:

  • Initializes a bonding curve with a target supply and price range.
  • Allows users to buy tokens from the curve (price increases linearly).
  • Allows users to sell tokens back to the curve (price decreases linearly).
  • All calculations are performed with high precision and overflow checks.

Example Flow

  1. User creates a new token via the genesis program, paying with N-Dollar.
  2. Token supply is minted to a distributor account.
  3. token-distributor splits the supply between the referral treasury, bonding curve, and AI agent.
  4. Users can buy/sell tokens on the bonding curve, or swap N-Dollar/SOL in the liquidity pool.
  5. Referral rewards are distributed via the referral program.

Technologies


Structure

programs/
  n-dollar/           # N-Dollar token and pool initialization
  liquidity-pool/     # AMM for N-Dollar/SOL swaps
  genesis/            # User token creation
  token-distributor/  # Token distribution logic
  referral-program/   # Referral rewards
  bonding-curve/      # Linear bonding curve for tokens

Deployment

Each program is independent but designed to work together. Deploy using Anchor CLI:

anchor build
anchor deploy

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors