Skip to main content

Crate nadfun_sdk

Crate nadfun_sdk 

Source
Expand description

§Nad.fun SDK

A simple and efficient Rust SDK for Nad.fun trading and event monitoring.

§Core Features

  • Trading: Buy/sell tokens with automatic routing (bonding curve ↔ DEX)
  • Gas estimation: SDK signing providers use generated EIP-2930 access lists
  • Event Streaming: Real-time streaming and historical indexing
  • API Client: Authenticated API access with session management
  • Simple API: Two main modules - Core for trading, stream for events

§Quick Start

ⓘ
use nadfun_sdk::{Core, Network};
use alloy::primitives::{Address, U256};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Initialize Core - binds to a Network at construction
    let core = Core::new(
        "https://your-rpc-url".to_string(),
        "your-private-key".to_string(),
        Network::Mainnet
    ).await?;

    // v1 trading: access through core.v1() handle
    let (router, amount_out) = core.v1().get_amount_out(token, mon_amount, true).await?;

    // Execute buy - returns tx_hash immediately (fast!)
    let tx_hash = core.v1().buy(buy_params, router).await?;
    println!("Transaction submitted: {}", tx_hash);

    // Cross-cutting: get_receipt stays on Core
    let receipt = core.get_receipt(tx_hash).await?;
    println!("Confirmed: {}", receipt.status);

    Ok(())
}

Re-exports§

pub use api::ApiClient;
pub use api::ALLOWED_IMAGE_TYPES;
pub use constants::get_creator_manager;
pub use constants::get_creator_treasury;
pub use constants::get_nadfun_router_v2;
pub use constants::quote_tokens;
pub use constants::Network;
pub use constants::QuoteToken;
pub use core::estimate_gas;
pub use core::Core;
pub use core::CoreV1;
pub use core::CoreV2;
pub use core::GasEstimationParams;
pub use core::ReceiptWaitOptions;
pub use core::Router;
pub use core::SlippageUtils;
pub use stream::BondingCurveEvent;
pub use stream::CurveIndexer;
pub use stream::CurveStream;
pub use stream::DexIndexer;
pub use stream::DexStream;
pub use stream::EventType;
pub use stream::PoolMetadata;
pub use stream::SwapEvent;
pub use token::TokenHelper;
pub use version::SdkVersion;
pub use version::TokenInfo;
pub use types::*;

Modules§

api
Authenticated API client with session management
constants
Constants and contract addresses for the Nad.fun ecosystem
core
Core trading functionality including buy/sell operations and slippage calculations
createDeprecated
Token creation functionality (DEPRECATED)
prelude
Convenient prelude module for importing commonly used types and functions
stream
Real-time event streaming and historical data indexing
token
Token interaction utilities for ERC-20 operations
types
Type definitions for events, trading parameters, and API responses
version
Token version discriminator (SdkVersion) and on-chain classification (TokenInfo = version + quote token) used for user-side v1/v2 dispatch. Token version discriminator.

Structs§

CreatorClient
CreatorTreasury client for claiming creator rewards
PairReserves
Reserves snapshot of a NadFunPair.
PoolDiscovery
Pool discovery helper for finding DEX pools.

Functions§

get_pool_addresses_for_tokens
Convenience function to get pool addresses for tokens paired with WMON on the given network.