Skip to content

x402agent/SolanaOS / skills/solana-formal-verification

qedgen

Flagged

Formally verify programs by writing Lean 4 proofs. Trigger this skill whenever the user wants to formally verify code, generate Lean 4 proofs, prove properties about algorithms or smart contracts, verify invariants, convert program logic into formal specifications, or anything involving Lean 4 and formal verification. Also trigger when the user mentions "qedgen", "lean proof", "formal proof", "verify my code", "prove correctness", "formal verification", or wants mathematical guarantees about their implementation.

FileKindSize
.gitignoreother753 B
.npmignoreother352 B
Cargo.lockmanifest46.3 KB
Cargo.tomlmanifest307 B
LICENSEother1.0 KB
README.mdmarkdown3.7 KB
SKILL.mdskill md10.8 KB
bin/leanstralexecutablescript6.2 MB
claude.mdmarkdown6.8 KB
crates/qedgen/Cargo.tomlmanifest544 B
crates/qedgen/lean_support/QEDGen.leanother166 B
crates/qedgen/lean_support/QEDGen/Solana.leanother166 B
crates/qedgen/lean_support/QEDGen/Solana/Account.leanother4.0 KB
crates/qedgen/lean_support/QEDGen/Solana/Authority.leanother285 B
crates/qedgen/lean_support/QEDGen/Solana/Cpi.leanother3.3 KB
crates/qedgen/lean_support/QEDGen/Solana/State.leanother1.9 KB
crates/qedgen/lean_support/QEDGen/Solana/Token.leanother1.4 KB
crates/qedgen/lean_support/QEDGen/Solana/Valid.leanother2.0 KB
crates/qedgen/lean_support/README.mdmarkdown2.8 KB
crates/qedgen/lean_support/lake-manifest.jsonconfig119 B
crates/qedgen/lean_support/lakefile.leanother112 B
crates/qedgen/lean_support/lean-toolchainother25 B
crates/qedgen/lean_support/test_lemmas.leanother1.2 KB
crates/qedgen/src/api.rsscript32.3 KB
crates/qedgen/src/consolidate.rsscript6.9 KB
crates/qedgen/src/main.rsscript4.1 KB
crates/qedgen/src/project.rsscript3.1 KB
crates/qedgen/src/spec.rsscript19.3 KB
crates/qedgen/src/validate.rsscript5.6 KB
crates/qedgen/templates/.gitignoreother29 B
crates/qedgen/templates/Main.leanother154 B
crates/qedgen/templates/PROMPT_TEMPLATE.mdmarkdown3.2 KB
crates/qedgen/templates/README.lean.mdmarkdown1.6 KB
crates/qedgen/templates/lakefile.leanother293 B
crates/qedgen/templates/lean-toolchainother25 B
docs/CNAMEother10 B
docs/index.htmlother10.9 KB
docs/llms-full.txtmarkdown8.7 KB
docs/llms.txtmarkdown2.1 KB
docs/logo-dark.svgother648 B
docs/logo-light.svgother648 B
docs/style.cssother7.6 KB
example/escrow/.gitignoreother67 B
example/escrow/.prettierignoreother61 B
example/escrow/Anchor.tomlconfig353 B
example/escrow/Cargo.lockmanifest72.8 KB
example/escrow/Cargo.tomlmanifest215 B
example/escrow/migrations/deploy.tsscript428 B
example/escrow/package.jsonmanifest528 B
example/escrow/programs/escrow/Cargo.tomlmanifest376 B
example/escrow/programs/escrow/Xargo.tomlconfig62 B
example/escrow/programs/escrow/src/lib.rsscript6.7 KB
example/escrow/tests/escrow.tsscript8.6 KB
example/escrow/tsconfig.jsonconfig205 B
example/percolator/.cargo/config.tomlconfig33 B
example/percolator/.gitignoreother320 B
example/percolator/Cargo.lockmanifest8.5 KB
example/percolator/Cargo.tomlmanifest639 B
example/percolator/LICENSEother11.1 KB
example/percolator/README.mdmarkdown4.9 KB
example/percolator/examples/offsets.rsscript1.3 KB
example/percolator/scripts/audit-proof-strength.mdmarkdown6.4 KB
example/percolator/scripts/proof-strength-audit-results.mdmarkdown89.2 KB
example/percolator/scripts/run_kani_full_audit.shexecutablescript1.2 KB
example/percolator/spec.mdmarkdown108.4 KB
example/percolator/src/i128.rsscript20.4 KB
example/percolator/src/percolator.rsscript139.2 KB
example/percolator/src/wide_math.rsscript59.8 KB
example/percolator/tests/amm_tests.rsscript7.4 KB
example/percolator/tests/common/mod.rsscript4.7 KB
example/percolator/tests/fuzzing.proptest-regressionsother4.7 KB
example/percolator/tests/fuzzing.rsscript43.1 KB
example/percolator/tests/proofs_arithmetic.rsscript17.1 KB
example/percolator/tests/proofs_audit.rsscript35.0 KB
example/percolator/tests/proofs_instructions.rsscript64.8 KB
example/percolator/tests/proofs_invariants.rsscript21.0 KB
example/percolator/tests/proofs_lazy_ak.rsscript22.4 KB
example/percolator/tests/proofs_liveness.rsscript17.1 KB
example/percolator/tests/proofs_safety.rsscript104.2 KB
example/percolator/tests/proofs_v1131.rsscript25.4 KB
example/percolator/tests/unit_tests.rsscript93.8 KB
install.shexecutablescript4.9 KB
package.jsonmanifest1.1 KB

example/percolator/tests/common/mod.rs

View on GitHub
//! Shared helpers, constants, and param factories for proof files.

pub use percolator::*;
pub use percolator::i128::{I128, U128};
pub use percolator::wide_math::{
    U256, I256,
    floor_div_signed_conservative,
    saturating_mul_u256_u64,
    fee_debt_u128_checked,
    mul_div_floor_u256,
    mul_div_floor_u256_with_rem,
    mul_div_ceil_u256,
    wide_signed_mul_div_floor,
    ceil_div_positive_checked,
    mul_div_floor_u128,
    mul_div_ceil_u128,
    wide_mul_div_floor_u128,
    wide_signed_mul_div_floor_from_k_pair,
    saturating_mul_u128_u64,
};

// ============================================================================
// Small-model constants
// ============================================================================

/// Small-model scale factors (minimal bit-widths for CBMC tractability).
/// All arithmetic stays within i32/u16 to avoid 64-bit SAT blowup.
pub const S_POS_SCALE: u16 = 4;
pub const S_ADL_ONE: u16 = 256;

// ============================================================================
// Engine constants
// ============================================================================

pub const DEFAULT_ORACLE: u64 = 1_000;
pub const DEFAULT_SLOT: u64 = 100;

// ============================================================================
// Small-model helpers
// ============================================================================

/// Small-model: eager PnL for one mark event (long).
pub fn eager_mark_pnl_long(q_base: i32, delta_p: i32) -> i32 {
    q_base * delta_p
}

/// Small-model: eager PnL for one mark event (short).
pub fn eager_mark_pnl_short(q_base: i32, delta_p: i32) -> i32 {
    -(q_base * delta_p)
}

/// Small-model: lazy PnL from K difference.
/// pnl_delta = floor(|basis_q| * (K_cur - k_snap) / (a_basis * POS_SCALE))
pub fn lazy_pnl(basis_q_abs: u16, k_diff: i32, a_basis: u16) -> i32 {
    let den = (a_basis as i32) * (S_POS_SCALE as i32);
    if den == 0 { return 0; }
    let num = (basis_q_abs as i32) * k_diff;
    if num >= 0 {
        num / den
    } else {
        let abs_num = -num;
        -((abs_num + den - 1) / den)
    }
}

/// Small-model: lazy effective quantity.
pub fn lazy_eff_q(basis_q_abs: u16, a_cur: u16, a_basis: u16) -> u16 {
    if a_basis == 0 { return 0; }
    let product = (basis_q_abs as i32) * (a_cur as i32);
    (product / (a_basis as i32)) as u16
}

/// Small-model: K update for mark event (long).
pub fn k_after_mark_long(k_before: i32, a_long: u16, delta_p: i32) -> i32 {
    k_before + (a_long as i32) * delta_p
}

/// Small-model: K update for mark event (short).
pub fn k_after_mark_short(k_before: i32, a_short: u16, delta_p: i32) -> i32 {
    k_before - (a_short as i32) * delta_p
}

/// Small-model: K update for funding event (long).
pub fn k_after_fund_long(k_before: i32, a_long: u16, delta_f: i32) -> i32 {
    k_before - (a_long as i32) * delta_f
}

/// Small-model: K update for funding event (short).
pub fn k_after_fund_short(k_before: i32, a_short: u16, delta_f: i32) -> i32 {
    k_before + (a_short as i32) * delta_f
}

/// Small-model: A update for ADL quantity shrink.
pub fn a_after_adl(a_old: u16, oi_post: u16, oi: u16) -> u16 {
    if oi == 0 { return a_old; }
    let product = (a_old as i32) * (oi_post as i32);
    (product / (oi as i32)) as u16
}

// ============================================================================
// Engine param helpers
// ============================================================================

pub fn zero_fee_params() -> RiskParams {
    RiskParams {
        warmup_period_slots: 100,
        maintenance_margin_bps: 500,
        initial_margin_bps: 1000,
        trading_fee_bps: 0,
        max_accounts: MAX_ACCOUNTS as u64,
        new_account_fee: U128::ZERO,
        maintenance_fee_per_slot: U128::ZERO,
        max_crank_staleness_slots: u64::MAX,
        liquidation_fee_bps: 0,
        liquidation_fee_cap: U128::ZERO,
        liquidation_buffer_bps: 50,
        min_liquidation_abs: U128::ZERO,
        min_initial_deposit: U128::new(2),
        min_nonzero_mm_req: 1,
        min_nonzero_im_req: 2,
        insurance_floor: U128::ZERO,
    }
}

pub fn default_params() -> RiskParams {
    RiskParams {
        warmup_period_slots: 100,
        maintenance_margin_bps: 500,
        initial_margin_bps: 1000,
        trading_fee_bps: 10,
        max_accounts: MAX_ACCOUNTS as u64,
        new_account_fee: U128::new(1000),
        maintenance_fee_per_slot: U128::new(1),
        max_crank_staleness_slots: 1000,
        liquidation_fee_bps: 100,
        liquidation_fee_cap: U128::new(1_000_000),
        liquidation_buffer_bps: 50,
        min_liquidation_abs: U128::new(0),
        min_initial_deposit: U128::new(1000),
        min_nonzero_mm_req: 1,
        min_nonzero_im_req: 2,
        insurance_floor: U128::ZERO,
    }
}
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall