Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ members = [
"programs/stablecoin/core",
"programs/stablecoin",
"programs/stablecoin/methods",
"programs/token_mint_authority/core",
"programs/token_mint_authority",
"programs/token_mint_authority/methods",
"programs/integration_tests",
"tools/idl-gen",
"tools/risc0-packager",
Expand All @@ -27,6 +30,7 @@ exclude = [
"programs/amm/methods/guest",
"programs/ata/methods/guest",
"programs/stablecoin/methods/guest",
"programs/token_mint_authority/methods/guest",
"programs/twap_oracle/methods/guest",
# Cycle benchmarks: standalone crate, kept out of --workspace builds/tests/CI. Run on demand
# with `cargo test --manifest-path programs/benchmark/Cargo.toml -- --ignored --nocapture`.
Expand All @@ -47,6 +51,8 @@ twap_oracle_core = { path = "programs/twap_oracle/core" }
twap_oracle_program = { path = "programs/twap_oracle" }
stablecoin_core = { path = "programs/stablecoin/core" }
stablecoin_program = { path = "programs/stablecoin" }
token_mint_authority_core = { path = "programs/token_mint_authority/core" }
token_mint_authority_program = { path = "programs/token_mint_authority" }
serde = { version = "1.0", features = ["derive"] }
borsh = { version = "1.5", features = ["derive"] }
risc0-zkvm = { version = "=3.0.5" }
Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Essential programs for the **Logos Execution Zone (LEZ)** — a zkVM-based execu
| **ata** | Associated Token Account program — derives and initializes deterministic token holding accounts for a given owner and token definition |
| **stablecoin** | Collateral-backed position program — open collateral positions as a foundation for stablecoin debt issuance |
| **twap_oracle** | TWAP oracle — provides canonical on-chain price accounts consumed by other programs (e.g. stablecoin) |
| **token-mint-authority** | Testnet faucet mint authority — holds the mint authority for faucet token definitions and lets any account self-mint a fixed amount, rate-limited to once per day per account and token, via a chained call to the token program |

## Apps

Expand Down Expand Up @@ -76,7 +77,7 @@ make clippy
make fmt

# Run unit tests for all programs (no zkVM, no ZK proof generation)
RISC0_DEV_MODE=1 cargo test -p token_program -p amm_program -p ata_program -p stablecoin_program -p twap_oracle_program
RISC0_DEV_MODE=1 cargo test -p token_program -p amm_program -p ata_program -p stablecoin_program -p twap_oracle_program -p token_mint_authority_program

# Run integration tests (dev mode skips ZK proof generation)
RISC0_DEV_MODE=1 cargo test -p integration_tests
Expand All @@ -85,13 +86,15 @@ RISC0_DEV_MODE=1 cargo test -p integration_tests
make test
```

Integration tests live in `programs/integration_tests/tests/` and cover `token`, `amm`, and `ata` programs end-to-end through the zkVM using `RISC0_DEV_MODE=1` to skip proof generation. Each test file corresponds to a program:
Integration tests live in `programs/integration_tests/tests/` and cover `token`, `amm`, `ata`, `stablecoin`, and `token-mint-authority` programs end-to-end through the zkVM using `RISC0_DEV_MODE=1` to skip proof generation. Each test file corresponds to a program:

- `programs/integration_tests/tests/token.rs`
- `programs/integration_tests/tests/amm.rs`
- `programs/integration_tests/tests/ata.rs`
- `programs/integration_tests/tests/stablecoin.rs`
- `programs/integration_tests/tests/token_mint_authority.rs`

`stablecoin` and `twap_oracle` are tested via their own unit tests (`cargo test -p stablecoin_program -p twap_oracle_program`).
`twap_oracle` is tested via its own unit tests (`cargo test -p twap_oracle_program`).

## Compile Guest Binaries

Expand Down Expand Up @@ -119,6 +122,7 @@ wallet deploy-program programs/amm/methods/guest/target/riscv32im-risc0-zkvm-elf
wallet deploy-program programs/ata/methods/guest/target/riscv32im-risc0-zkvm-elf/docker/ata.bin
wallet deploy-program programs/stablecoin/methods/guest/target/riscv32im-risc0-zkvm-elf/docker/stablecoin.bin
wallet deploy-program programs/twap_oracle/methods/guest/target/riscv32im-risc0-zkvm-elf/docker/twap_oracle.bin
wallet deploy-program programs/token_mint_authority/methods/guest/target/riscv32im-risc0-zkvm-elf/docker/token_mint_authority.bin
```

To inspect the `ProgramId` of a built binary:
Expand Down Expand Up @@ -147,6 +151,7 @@ spel generate-idl programs/amm/methods/guest/src/bin/amm.rs > artifacts/amm-idl.
spel generate-idl programs/ata/methods/guest/src/bin/ata.rs > artifacts/ata-idl.json
spel generate-idl programs/stablecoin/methods/guest/src/bin/stablecoin.rs > artifacts/stablecoin-idl.json
spel generate-idl programs/twap_oracle/methods/guest/src/bin/twap_oracle.rs > artifacts/twap_oracle-idl.json
spel generate-idl programs/token_mint_authority/methods/guest/src/bin/token_mint_authority.rs > artifacts/token_mint_authority-idl.json
```

Generated IDL files are committed under `artifacts/`. CI will fail if a program's IDL is missing or out of date.
Expand All @@ -161,4 +166,5 @@ spel --idl artifacts/amm-idl.json <instruction> [args...]
spel --idl artifacts/ata-idl.json <instruction> [args...]
spel --idl artifacts/stablecoin-idl.json <instruction> [args...]
spel --idl artifacts/twap_oracle-idl.json <instruction> [args...]
spel --idl artifacts/token_mint_authority-idl.json <instruction> [args...]
```
4 changes: 4 additions & 0 deletions apps/amm/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ tests/testnet/amm-registry.json
# Isolated custom-token store (CUSTOM_TOKEN_CONFIG) — initialized by the setup script
# and written by the app during tests/custom-token.mjs
tests/testnet/custom-tokens.json

# Faucet manifest written by the setup script for tests/faucet-swap.mjs (account ids
# + PDAs + bin/IDL paths for the FaucetMint). Regenerated on every setup run.
tests/testnet/faucet.json
3 changes: 3 additions & 0 deletions apps/amm/qml/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ Item {

SwapPage {
id: swapPage
// Lets UI tests reach refreshHoldings() to re-pull the account list after
// an out-of-band balance change (e.g. faucet-swap.mjs mints then refreshes).
objectName: "swapPage"

anchors.fill: parent
visible: navbar.currentIndex === 0
Expand Down
17 changes: 16 additions & 1 deletion apps/amm/tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ inspector (framework from
deliberately **absent** from the token config) into a Liquidity token slot and
verifies the app resolves it, selects it, and **persists** it to the custom-token
store — the "add an unlisted token by id" path. No pool / submit involved.
- `faucet-swap.mjs` funds a **brand-new** account ("Token A Holder 2") that starts
with no token A: it `initialize_account`s the account's token A holding, then
submits a **FaucetMint** through the token-mint-authority program (both via `spel`,
out of band from the UI) to mint token A into it — the faucet only mints into an
**existing** holding, so the init must come first — then **refreshes** the UI so
the newly-funded holding appears in the sell picker, selects it, and swaps **A→B**,
verifying the pool reserves changed **on-chain**. Reads `testnet/faucet.json`
(written by the setup) and needs `spel` on `PATH` plus `LEE_WALLET_HOME_DIR`
pointing at the isolated test wallet.

## Isolation

Expand Down Expand Up @@ -66,6 +75,10 @@ node apps/amm/tests/create-pool.mjs # create the (unseeded) A/C pool
node apps/amm/tests/add-liquidity.mjs # add liquidity to the seeded A/B pool
node apps/amm/tests/remove-liquidity.mjs # remove 50% from the seeded A/B pool
node apps/amm/tests/custom-token.mjs # add token D (unlisted) by id

# faucet-swap needs spel on PATH + the isolated wallet home (so it can sign the mint)
LEE_WALLET_HOME_DIR=$(pwd)/apps/amm/tests/testnet/.wallet \
node apps/amm/tests/faucet-swap.mjs # faucet-mint TKA to holder2, refresh, then swap
```

Headless CI variant (no window, launches the app itself, pass/fail only):
Expand Down Expand Up @@ -99,6 +112,8 @@ nix build .#integration-test -L
- `create-pool.mjs` — the end-to-end create-pool UI test (creates the A/C pool).
- `add-liquidity.mjs` — the end-to-end add-liquidity UI test (adds to the A/B pool).
- `remove-liquidity.mjs` — the end-to-end remove-liquidity UI test (removes 50% from the A/B pool).
- `faucet-swap.mjs` — faucet-mint token A to a fresh account, refresh the UI, then swap A→B.
- `testnet/setup-amm-testnet.sh` — isolated testnet + wallet bootstrap (TKA/TKB/TKC,
seeds the A/B pool only).
seeds the A/B pool only; also deploys the faucet, sets every token's mint authority
to the faucet PDA, and writes `testnet/faucet.json` for faucet-swap.mjs).
- `qml/`, `cpp/` — the module's own QML/C++ unit tests.
Loading
Loading