Skip to content

x402agent/SolanaOS / skills/qedgen

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
Cargo.lockmanifest38.2 KB
Cargo.tomlmanifest347 B
LICENSEother1.0 KB
README.mdmarkdown4.1 KB
SKILL.mdskill md21.0 KB
claude.mdmarkdown9.7 KB
crates/qedgen/Cargo.tomlmanifest544 B
crates/qedgen/src/api.rsscript38.9 KB
crates/qedgen/src/asm2lean.rsscript26.2 KB
crates/qedgen/src/consolidate.rsscript6.2 KB
crates/qedgen/src/main.rsscript4.7 KB
crates/qedgen/src/project.rsscript3.0 KB
crates/qedgen/src/spec.rsscript19.4 KB
crates/qedgen/src/validate.rsscript5.6 KB
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.leanother292 B
crates/qedgen/templates/lean-toolchainother25 B
docs/CNAMEother10 B
docs/index.htmlother11.6 KB
docs/llms-full.txtmarkdown8.7 KB
docs/llms.txtmarkdown2.1 KB
docs/logo-dark.svgother648 B
docs/logo-light.svgother648 B
docs/qgn_demo.htmlother69.3 KB
docs/style.cssother8.1 KB
examples/rust/escrow/Anchor.tomlconfig353 B
examples/rust/escrow/Cargo.lockmanifest72.8 KB
examples/rust/escrow/Cargo.tomlmanifest215 B
examples/rust/escrow/migrations/deploy.tsscript428 B
examples/rust/escrow/package.jsonmanifest528 B
examples/rust/escrow/programs/escrow/Cargo.tomlmanifest376 B
examples/rust/escrow/programs/escrow/Xargo.tomlconfig62 B
examples/rust/escrow/programs/escrow/src/lib.rsscript6.7 KB
examples/rust/escrow/tests/escrow.tsscript8.6 KB
examples/rust/escrow/tsconfig.jsonconfig205 B
examples/rust/percolator/Cargo.lockmanifest8.5 KB
examples/rust/percolator/Cargo.tomlmanifest639 B
examples/rust/percolator/LICENSEother11.1 KB
examples/rust/percolator/README.mdmarkdown4.9 KB
examples/rust/percolator/examples/offsets.rsscript1.3 KB
examples/rust/percolator/scripts/audit-proof-strength.mdmarkdown6.4 KB
examples/rust/percolator/scripts/proof-strength-audit-results.mdmarkdown89.2 KB
examples/rust/percolator/scripts/run_kani_full_audit.shexecutablescript1.2 KB
examples/rust/percolator/spec.mdmarkdown108.4 KB
examples/rust/percolator/src/i128.rsscript20.4 KB
examples/rust/percolator/src/percolator.rsscript139.3 KB
examples/rust/percolator/src/wide_math.rsscript59.8 KB
examples/rust/percolator/tests/amm_tests.rsscript7.4 KB
examples/rust/percolator/tests/common/mod.rsscript4.7 KB
examples/rust/percolator/tests/fuzzing.proptest-regressionsother4.7 KB
examples/rust/percolator/tests/fuzzing.rsscript43.1 KB
examples/rust/percolator/tests/proofs_arithmetic.rsscript17.1 KB
examples/rust/percolator/tests/proofs_audit.rsscript35.0 KB
examples/rust/percolator/tests/proofs_instructions.rsscript64.8 KB
examples/rust/percolator/tests/proofs_invariants.rsscript21.0 KB
examples/rust/percolator/tests/proofs_lazy_ak.rsscript22.4 KB
examples/rust/percolator/tests/proofs_liveness.rsscript17.1 KB
examples/rust/percolator/tests/proofs_safety.rsscript104.2 KB
examples/rust/percolator/tests/proofs_v1131.rsscript25.4 KB
examples/rust/percolator/tests/unit_tests.rsscript93.8 KB
examples/sbpf/counter/src/counter.sother22.9 KB
examples/sbpf/slippage/src/asm-slippage/asm-slippage.sother698 B
examples/sbpf/transfer/src/transfer.sother2.4 KB
examples/sbpf/tree/src/tree.sother61.1 KB
install.shexecutablescript5.5 KB
lean_solana/QEDGen.leanother165 B
lean_solana/QEDGen/Solana.leanother165 B
lean_solana/QEDGen/Solana/Account.leanother4.0 KB
lean_solana/QEDGen/Solana/Authority.leanother285 B
lean_solana/QEDGen/Solana/Cpi.leanother9.0 KB
lean_solana/QEDGen/Solana/SBPF.leanother130 B
lean_solana/QEDGen/Solana/SBPF/Execute.leanother12.2 KB
lean_solana/QEDGen/Solana/SBPF/ISA.leanother5.1 KB
lean_solana/QEDGen/Solana/SBPF/Memory.leanother6.1 KB
lean_solana/QEDGen/Solana/SBPF/Tactic.leanother2.3 KB
lean_solana/QEDGen/Solana/State.leanother1.9 KB
lean_solana/QEDGen/Solana/Valid.leanother2.0 KB
lean_solana/README.mdmarkdown2.5 KB
lean_solana/lake-manifest.jsonconfig119 B
lean_solana/lakefile.leanother112 B
lean_solana/lean-toolchainother25 B
lean_solana/test_lemmas.leanother2.3 KB
package.jsonmanifest762 B
tools/qedgenexecutablescript357 B

examples/rust/escrow/tests/escrow.ts

View on GitHub
import * as anchor from "@coral-xyz/anchor";
import { Program } from "@coral-xyz/anchor";
import { Escrow } from "../target/types/escrow";
import { PublicKey, Keypair, SystemProgram } from "@solana/web3.js";
import {
  TOKEN_PROGRAM_ID,
  createMint,
  createAccount,
  mintTo,
  getAccount,
} from "@solana/spl-token";
import { assert } from "chai";

describe("escrow", () => {
  // Configure the client to use the local cluster.
  const provider = anchor.AnchorProvider.env();
  anchor.setProvider(provider);

  const program = anchor.workspace.Escrow as Program<Escrow>;

  let mintA: PublicKey;
  let mintB: PublicKey;
  let initializerTokenAccountA: PublicKey;
  let initializerTokenAccountB: PublicKey;
  let takerTokenAccountA: PublicKey;
  let takerTokenAccountB: PublicKey;

  let payer: Keypair;
  let initializer: PublicKey;
  const taker = Keypair.generate();

  const initializerAmount = 1000;
  const takerAmount = 500;

  before(async () => {
    // Create a test keypair and fund it
    payer = Keypair.generate();
    const airdropSig = await provider.connection.requestAirdrop(
      payer.publicKey,
      10 * anchor.web3.LAMPORTS_PER_SOL
    );
    await provider.connection.confirmTransaction(airdropSig);
    initializer = payer.publicKey;

    // Airdrop SOL to taker
    const signature = await provider.connection.requestAirdrop(
      taker.publicKey,
      2 * anchor.web3.LAMPORTS_PER_SOL
    );
    await provider.connection.confirmTransaction(signature);

    // Create mints
    mintA = await createMint(
      provider.connection,
      payer,
      initializer,
      null,
      6
    );

    mintB = await createMint(
      provider.connection,
      payer,
      initializer,
      null,
      6
    );

    // Create token accounts for initializer
    initializerTokenAccountA = await createAccount(
      provider.connection,
      payer,
      mintA,
      initializer
    );

    initializerTokenAccountB = await createAccount(
      provider.connection,
      payer,
      mintB,
      initializer
    );

    // Create token accounts for taker
    takerTokenAccountA = await createAccount(
      provider.connection,
      payer,
      mintA,
      taker.publicKey
    );

    takerTokenAccountB = await createAccount(
      provider.connection,
      payer,
      mintB,
      taker.publicKey
    );

    // Mint tokens to initializer and taker
    await mintTo(
      provider.connection,
      payer,
      mintA,
      initializerTokenAccountA,
      initializer,
      initializerAmount
    );

    await mintTo(
      provider.connection,
      payer,
      mintB,
      takerTokenAccountB,
      initializer,
      takerAmount
    );
  });

  it("Initialize escrow", async () => {
    const [escrowPda] = PublicKey.findProgramAddressSync(
      [Buffer.from("escrow"), initializer.toBuffer()],
      program.programId
    );

    const [escrowTokenAccount] = PublicKey.findProgramAddressSync(
      [Buffer.from("escrow_token"), initializer.toBuffer()],
      program.programId
    );

    await program.methods
      .initialize(
        new anchor.BN(initializerAmount),
        new anchor.BN(takerAmount)
      )
      .accounts({
        initializer: initializer,
        escrow: escrowPda,
        initializerDepositTokenAccount: initializerTokenAccountA,
        mint: mintA,
        escrowTokenAccount: escrowTokenAccount,
        systemProgram: SystemProgram.programId,
        tokenProgram: TOKEN_PROGRAM_ID,
      })
      .signers([payer])
      .rpc();

    // Verify escrow state
    const escrowAccount = await program.account.escrowState.fetch(escrowPda);
    assert.ok(escrowAccount.initializer.equals(initializer));
    assert.ok(
      escrowAccount.initializerTokenAccount.equals(initializerTokenAccountA)
    );
    assert.strictEqual(
      escrowAccount.initializerAmount.toNumber(),
      initializerAmount
    );
    assert.strictEqual(escrowAccount.takerAmount.toNumber(), takerAmount);

    // Verify tokens were transferred to escrow
    const escrowTokenAccountData = await getAccount(
      provider.connection,
      escrowTokenAccount
    );
    assert.strictEqual(
      Number(escrowTokenAccountData.amount),
      initializerAmount
    );

    // Verify initializer's token account was debited
    const initializerTokenAccountData = await getAccount(
      provider.connection,
      initializerTokenAccountA
    );
    assert.strictEqual(Number(initializerTokenAccountData.amount), 0);
  });

  it("Exchange escrow", async () => {
    const [escrowPda] = PublicKey.findProgramAddressSync(
      [Buffer.from("escrow"), initializer.toBuffer()],
      program.programId
    );

    const [escrowTokenAccount] = PublicKey.findProgramAddressSync(
      [Buffer.from("escrow_token"), initializer.toBuffer()],
      program.programId
    );

    await program.methods
      .exchange()
      .accounts({
        taker: taker.publicKey,
        escrow: escrowPda,
        takerDepositTokenAccount: takerTokenAccountB,
        takerReceiveTokenAccount: takerTokenAccountA,
        initializerReceiveTokenAccount: initializerTokenAccountB,
        escrowTokenAccount: escrowTokenAccount,
        initializer: initializer,
        tokenProgram: TOKEN_PROGRAM_ID,
      })
      .signers([taker])
      .rpc();

    // Verify taker received initializer's tokens
    const takerTokenAccountAData = await getAccount(
      provider.connection,
      takerTokenAccountA
    );
    assert.strictEqual(
      Number(takerTokenAccountAData.amount),
      initializerAmount
    );

    // Verify initializer received taker's tokens
    const initializerTokenAccountBData = await getAccount(
      provider.connection,
      initializerTokenAccountB
    );
    assert.strictEqual(Number(initializerTokenAccountBData.amount), takerAmount);

    // Verify taker's deposit account was debited
    const takerTokenAccountBData = await getAccount(
      provider.connection,
      takerTokenAccountB
    );
    assert.strictEqual(Number(takerTokenAccountBData.amount), 0);

    // Verify escrow account was closed
    try {
      await program.account.escrowState.fetch(escrowPda);
      assert.fail("Escrow account should be closed");
    } catch (err) {
      assert.ok(err.message.includes("Account does not exist"));
    }
  });

  it("Initialize and cancel escrow", async () => {
    // Use a different payer for this test to avoid PDA collision
    const newPayer = Keypair.generate();
    const airdropSig = await provider.connection.requestAirdrop(
      newPayer.publicKey,
      10 * anchor.web3.LAMPORTS_PER_SOL
    );
    await provider.connection.confirmTransaction(airdropSig);

    // Create new token account for this payer
    const newInitializerTokenAccount = await createAccount(
      provider.connection,
      newPayer,
      mintA,
      newPayer.publicKey
    );

    // Mint tokens to new account (using original payer as mint authority)
    await mintTo(
      provider.connection,
      payer,
      mintA,
      newInitializerTokenAccount,
      initializer,
      initializerAmount
    );

    const [escrowPda] = PublicKey.findProgramAddressSync(
      [Buffer.from("escrow"), newPayer.publicKey.toBuffer()],
      program.programId
    );

    const [escrowTokenAccount] = PublicKey.findProgramAddressSync(
      [Buffer.from("escrow_token"), newPayer.publicKey.toBuffer()],
      program.programId
    );

    // Initialize new escrow
    await program.methods
      .initialize(
        new anchor.BN(initializerAmount),
        new anchor.BN(takerAmount)
      )
      .accounts({
        initializer: newPayer.publicKey,
        escrow: escrowPda,
        initializerDepositTokenAccount: newInitializerTokenAccount,
        mint: mintA,
        escrowTokenAccount: escrowTokenAccount,
        systemProgram: SystemProgram.programId,
        tokenProgram: TOKEN_PROGRAM_ID,
      })
      .signers([newPayer])
      .rpc();

    // Cancel the escrow
    await program.methods
      .cancel()
      .accounts({
        initializer: newPayer.publicKey,
        escrow: escrowPda,
        initializerDepositTokenAccount: newInitializerTokenAccount,
        escrowTokenAccount: escrowTokenAccount,
        tokenProgram: TOKEN_PROGRAM_ID,
      })
      .signers([newPayer])
      .rpc();

    // Verify tokens were returned to initializer
    const initializerTokenAccountData = await getAccount(
      provider.connection,
      newInitializerTokenAccount
    );
    assert.strictEqual(
      Number(initializerTokenAccountData.amount),
      initializerAmount
    );

    // Verify escrow account was closed
    try {
      await program.account.escrowState.fetch(escrowPda);
      assert.fail("Escrow account should be closed");
    } catch (err) {
      assert.ok(err.message.includes("Account does not exist"));
    }
  });
});
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