Skip to content

Phase 1: vault and factory contracts - #108

Merged
MFrancis-dev merged 2 commits into
mainfrom
feat/contracts
Nov 4, 2026
Merged

MFrancis-dev merged 2 commits into
mainfrom
feat/contracts

Conversation

@MFrancis-dev

Copy link
Copy Markdown
Owner

Implements the Stack contracts per ARCHITECTURE.md §3 and decisions KD-5 (immutable vaults) and KD-8 (regular deploy).

What changed

  • Vault: set_plan / resume / pause, bounded execute_buy (keeper, once per interval, ≤ amount_per_run, optional storage registration of the deposit address, schedule restored on failure), withdraw, recover_token, ft_on_transfer, NEP-297 events.
  • Factory: set_vault_code (admin, future vaults only), create_vault_for (keeper, one per owner, daily cap), rollback on failed deploy, chained USDC registration, retry_registration, code-hash view.
  • Tests: 49 total — 24 vault unit, 9 factory unit, 16 near-workspaces sandbox tests (I1–I7, private callbacks, registration, insufficient balance, factory, recovery). Test-only mock-ft crate.
  • Docs: ARCHITECTURE §3 tables/events, ESSENTIALS rules, contracts README, project_structure.

Wasm: vault 137 KB, factory 146 KB (~1.5 NEAR locked per vault).

Closes #20
Closes #21
Closes #22
Closes #23
Closes #24
Closes #25
Closes #26
Closes #27
Closes #28
Closes #29
Closes #31

Roadmap

  • ROADMAP.md updated: K1.1–K1.10, K1.12 done; Phase 1 at 92% (K1.13 deploy is human-only)

Checks

  • cargo test (unit + sandbox), cargo clippy clean, pnpm contracts:build
  • pnpm typecheck && pnpm lint

NEAR HACKATHON rules

  • No secrets committed
  • New libraries (near-contract-standards in the test-only mock) to be listed in the README (K10.3)
  • Nothing deployed or signed with real keys

Not done

  • K1.13 deployment needs the human (accounts, funding, approval).
  • K0.9 (does 1Click pre-register deposit addresses) is still blocked on the partner JWT; the keeper attaches a storage deposit meanwhile.

Vault: plan controls, bounded execute_buy with optional deposit-address
storage registration and a failure callback that restores the schedule,
owner withdraw and token recovery, ft_on_transfer, NEP-297 events.

Factory: admin uploads vault code once (future vaults only), keeper-only
create_vault_for with one vault per owner and a daily cap, rollback on a
failed deploy, chained USDC registration plus retry_registration.

Tests: 24 vault and 9 factory unit tests, 16 near-workspaces sandbox
tests covering invariants I1-I7, private callbacks, registration,
insufficient balance, factory rules and recovery. Adds a test-only
mock-ft crate.
near-workspaces compile_project shells out to the cargo near CLI.
@MFrancis-dev
MFrancis-dev merged commit d7f4834 into main Nov 4, 2026
3 checks passed
@MFrancis-dev
MFrancis-dev deleted the feat/contracts branch November 4, 2026 18:59
MFrancis-dev added a commit that referenced this pull request Nov 4, 2026
Vault and factory per ARCHITECTURE §3 (KD-5, KD-8); 49 contract tests incl. 16 near-workspaces sandbox tests; CI installs cargo-near for them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment