bcurve 0.1.1

DLMM bonding curve
Documentation
name: CI

on:
  push:
    branches: [ main, master ]
  pull_request:
    branches: [ main, master ]

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: full
  PKG_CONFIG_PATH: /usr/lib/x86_64-linux-gnu/pkgconfig:/usr/share/pkgconfig:/usr/lib/pkgconfig
  RUST_FONTCONFIG_DLOPEN: true
  FONTCONFIG_NO_PKG_CONFIG: true
  CARGO_PROFILE_DEV_BUILD_OVERRIDE_DEBUG: true

jobs:
  check:
    name: Check
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install system dependencies
        run: |
          sudo apt-get update
          sudo apt-get install -y pkg-config fontconfig libfontconfig1 libfontconfig1-dev libfreetype6-dev libexpat1-dev
          # Verify fontconfig installation
          echo "=== Fontconfig package info ==="
          dpkg -l | grep -i fontconfig || true
          echo "=== Fontconfig files ==="
          find /usr -name "fontconfig.pc" || true
          echo "=== pkg-config info ==="
          pkg-config --debug --libs --cflags fontconfig || true
          echo "=== System libraries ==="
          ldconfig -p | grep fontconfig || true
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - run: cargo check --all-features

  test:
    name: Test Suite
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install system dependencies
        run: |
          sudo apt-get update
          sudo apt-get install -y pkg-config fontconfig libfontconfig1 libfontconfig1-dev libfreetype6-dev libexpat1-dev
          # Verify fontconfig installation
          echo "=== Fontconfig package info ==="
          dpkg -l | grep -i fontconfig || true
          echo "=== Fontconfig files ==="
          find /usr -name "fontconfig.pc" || true
          echo "=== pkg-config info ==="
          pkg-config --debug --libs --cflags fontconfig || true
          echo "=== System libraries ==="
          ldconfig -p | grep fontconfig || true
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - run: cargo test --all-features

  fmt:
    name: Rustfmt
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt
      - run: cargo fmt --all -- --check

  clippy:
    name: Clippy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy
      - uses: Swatinem/rust-cache@v2
      - run: cargo clippy --all-features -- -D warnings


  build:
    name: Build
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
        rust: [stable, beta]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ matrix.rust }}
      - uses: Swatinem/rust-cache@v2
      - run: cargo build --release --all-features
      - run: cargo test --release --all-features

  examples:
    name: Run Examples
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install system dependencies
        run: |
          sudo apt-get update
          sudo apt-get install -y pkg-config fontconfig libfontconfig1 libfontconfig1-dev libfreetype6-dev libexpat1-dev
          # Verify fontconfig installation
          echo "=== Fontconfig package info ==="
          dpkg -l | grep -i fontconfig || true
          echo "=== Fontconfig files ==="
          find /usr -name "fontconfig.pc" || true
          echo "=== pkg-config info ==="
          pkg-config --debug --libs --cflags fontconfig || true
          echo "=== System libraries ==="
          ldconfig -p | grep fontconfig || true
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - run: cargo build --release
      - name: Run examples
        run: |
          # Geometric example
          ./target/release/bcurve \
            --mode geometric \
            --p0 0.01 --bin-step-bps 10 \
            --theta 0.6 \
            --target-supply 100000000 \
            --end-price 0.02 \
            --verbose \
            --out-dir out_geometric
          
          # Logistic example
          ./target/release/bcurve \
            --mode logistic \
            --p0 0.0015 --bin-step-bps 10 \
            --p-min 0.001 --p-max 0.05 \
            --k 0.00000008 \
            --end-price 0.03 \
            --verbose \
            --out-dir out_logistic

      - name: Check outputs
        run: |
          test -f out_geometric/schedule.csv
          test -f out_geometric/price_vs_supply.png
          test -f out_geometric/tokens_per_bin.png
          test -f out_geometric/fee_vs_volatility.png
          echo "✓ Geometric curve outputs generated successfully"

          test -f out_logistic/schedule.csv
          test -f out_logistic/price_vs_supply.png
          test -f out_logistic/tokens_per_bin.png
          test -f out_logistic/fee_vs_volatility.png
          echo "✓ Logistic curve outputs generated successfully"

      - name: Upload outputs
        uses: actions/upload-artifact@v4
        with:
          name: curve-outputs
          path: |
            out_geometric/
            out_logistic/

  security-audit:
    name: Security Audit
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: rustsec/audit-check@v1.4.1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}

  docs:
    name: Documentation
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install system dependencies
        run: |
          sudo apt-get update
          sudo apt-get install -y pkg-config fontconfig libfontconfig1 libfontconfig1-dev libfreetype6-dev libexpat1-dev
          # Verify fontconfig installation
          echo "=== Fontconfig package info ==="
          dpkg -l | grep -i fontconfig || true
          echo "=== Fontconfig files ==="
          find /usr -name "fontconfig.pc" || true
          echo "=== pkg-config info ==="
          pkg-config --debug --libs --cflags fontconfig || true
          echo "=== System libraries ==="
          ldconfig -p | grep fontconfig || true
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - run: cargo doc --no-deps --all-features
      - run: cargo test --doc --all-features

  publish-dry-run:
    name: Publish Dry Run
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install system dependencies
        run: |
          sudo apt-get update
          sudo apt-get install -y pkg-config fontconfig libfontconfig1 libfontconfig1-dev libfreetype6-dev libexpat1-dev
          # Verify fontconfig installation
          echo "=== Fontconfig package info ==="
          dpkg -l | grep -i fontconfig || true
          echo "=== Fontconfig files ==="
          find /usr -name "fontconfig.pc" || true
          echo "=== pkg-config info ==="
          pkg-config --debug --libs --cflags fontconfig || true
          echo "=== System libraries ==="
          ldconfig -p | grep fontconfig || true
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - run: cargo publish --dry-run