Skip to content

Funding window: unfunded clauses can't fill the caps (after judging) - #26

Draft
angelraph wants to merge 3 commits into
masterfrom
claude/fund-time-caps
Draft

angelraph wants to merge 3 commits into
masterfrom
claude/fund-time-caps

Conversation

@angelraph

Copy link
Copy Markdown
Owner

Do not merge or deploy until hackathon judging is over. The live testnet and mainnet contracts are unchanged.

Why

The threat model's first weakness: the factory reserves a clause's amount against the day's caps when the clause is written, before it is funded. With creators open (testnet), anyone could write unfunded clauses and fill the day's caps. Mainnet is already closed by its creators allowlist.

What changes

  • Every new clause gets a funding deadline, 10 minutes after creation (FUNDING_WINDOW_SECS).
  • After it, an unfunded clause refuses deposits: ft_on_transfer refunds them, and sync_funding no longer marks it funded.
  • Anyone may then call cancel_unfunded. Any partial deposit goes back to the buyer, and the clause reports a new cancelled outcome.
  • On cancelled, the factory gives the reservation back and decrements the open counts. It writes no receipt and no returned count, so neither side's standing changes. The clause then closes and refunds its storage like any other.
  • No factory state migration: the new enum variants are appended at the end and the window is a constant. Clauses created by the current code have no window and behave exactly as before.
  • The website and desk need no change: a cancelled clause shows as Returned.
  • docs/THREAT_MODEL.md and contracts/ABI.md describe the change. docs/x-post-next.md is a follow-up post.

Tests

  • 8 new clause unit tests: funding inside the window, deposit after the window refunded, sync after the window does not fund, cancel inside the window or without a window refused, cancelling a funded clause refused, cancel reports cancelled, and an ordinary return still reports returned.
  • 2 new factory unit tests: a cancel frees the reservation without touching standing, and a cancelled spam clause makes room for a real job the same day.
  • cargo test -p clause -p factory --lib: 48 + 28 passed. Both contracts build for wasm32.
  • Not run: the sandbox integration tests.

To ship later

DAO proposal to upload the new clause code, then redeploy the factory wasm (state compatible), then npm run judge against testnet.

🤖 Generated with Claude Code

The factory reserves a clause's amount against the day's caps when the
clause is written. With creators open (testnet), anyone could write
unfunded clauses and fill the day.

Now every new clause gets funding_deadline = creation + 10 minutes.
After it, an unfunded clause refuses deposits (ft_on_transfer refunds,
sync_funding no longer marks it funded) and anyone may call
cancel_unfunded. That returns any partial deposit to the buyer and
reports a new Cancelled outcome: the factory gives the reservation back,
decrements open counts, and writes no receipt and no returned count, so
nobody's standing changes. The clause then closes like any other.

No factory state migration: new enum variants are appended and the
window is a constant. Clauses created by the current code have no
window and behave as before. Not deployed.

Tests: 8 new clause tests, 2 new factory tests; 48 + 28 pass. Both
contracts build for wasm32.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
clausehold Ready Ready Preview Nov 11, 2026 3:22am UTC
clausehold-api-mainnet Ready Ready Preview Nov 11, 2026 3:22am UTC
clausehold-api-testnet Ready Ready Preview Nov 11, 2026 3:22am UTC

angelraph and others added 2 commits November 11, 2026 04:21
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant