Skip to content

feat: interfold token vesting escrow [skip-line-limit]#1557

Merged
hmzakhalid merged 36 commits into
mainfrom
feat/token-vesting-escrow
Jun 15, 2026
Merged

feat: interfold token vesting escrow [skip-line-limit]#1557
hmzakhalid merged 36 commits into
mainfrom
feat/token-vesting-escrow

Conversation

@hmzakhalid

@hmzakhalid hmzakhalid commented May 27, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Token-level pooled locks with per-account schedules and locked-floor transfer enforcement (prevents transfers that would violate locked balances)
    • Auto-created claim-derived lock schedules for approved claim sources; expanded lock-manager admin controls and TGE configuration
    • New totalBonded() view and exit payouts returning ENCL to each source’s configured withdrawal address
  • Documentation

    • Revised bonding, unbonding, exit-claiming, slashing, deactivation, and registry coordination flows; updated token flow diagrams
  • Chores

    • Updated local deployment addresses and block numbers across examples/templates

@vercel

vercel Bot commented May 27, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
crisp Ready Ready Preview, Comment Jun 15, 2026 2:49pm
enclave-docs Ready Ready Preview, Comment Jun 15, 2026 2:49pm
enclave-enclave-dashboard Ready Ready Preview, Comment Jun 15, 2026 2:49pm
interfold-dashboard Ready Ready Preview, Comment Jun 15, 2026 2:49pm

Request Review

@coderabbitai

coderabbitai Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds BondingRegistry.totalBonded and reentrancy hardening; implements EnclaveToken pooled lock schedules, LOCK_MANAGER_ROLE, and locked-floor invariant tied to bonding credit; updates deployEnclave TGE resolution; updates flow-trace docs; refreshes tests, examples, and deployment artifacts.

Changes

License Bonding Accounting and Token-Level Locking

Layer / File(s) Summary
BondingRegistry License Bond Accounting
packages/enclave-contracts/contracts/interfaces/IBondingRegistry.sol, packages/enclave-contracts/contracts/registry/BondingRegistry.sol, packages/enclave-contracts/artifacts/contracts/interfaces/IBondingRegistry.sol/IBondingRegistry.json
Adds totalBonded(address) (active license bond + pending ENCL exits); central _bondLicense helper; bondLicense, unbondLicense, claimExits, slashLicenseBond gain nonReentrant; refactors slashing to deduct active portion then slash pending via exit-queue helpers.
EnclaveToken Token-Level Locking
packages/enclave-contracts/contracts/token/EnclaveToken.sol
Adds LOCK_MANAGER_ROLE, per-account absolute lock schedules (max 64), claim-lock profiles and approved claim sources, and enforces balanceOf + bondingRegistry.totalBonded >= lockedFloorOf. New APIs for schedule/profile management, TGE and bonding registry config, and schedule queries; _update enforces locked-floor and creates claim-derived schedules for approved sources.
Deployment Script TGE Configuration
packages/enclave-contracts/scripts/deployEnclave.ts, packages/enclave-contracts/README.md
Adds parseRequiredUint64 and resolveInterfoldTgeTimestamp to validate/resolve INTERFOLD_TGE_TIMESTAMP (required on non-local chains, fallback to latest block on local), configures EnclaveToken TGE timestamp, sets BondingRegistry address, and whitelists BondingRegistry.
Flow-Trace Documentation Updates
agent/flow-trace/02_TOKENS_AND_ACTIVATION.md, agent/flow-trace/05_FAILURE_REFUND_SLASHING.md, agent/flow-trace/06_DEACTIVATION_AND_COMPLETION.md
Documents LOCK_MANAGER_ROLE and locked-floor invariant; reorders bondLicense state update to credit licenseBond before ENCL transfer; clarifies pending ENCL remains in totalBonded until claim/slash; splits claimExits: tickets-only then per-source license payouts to each source withdrawal address with (operator, amount, sourceId) callbacks; documents LIFO slashing by source.
Test Coverage
packages/enclave-contracts/test/Registry/BondingRegistry.spec.ts, packages/enclave-contracts/test/Token/EnclaveToken.spec.ts
BondingRegistry tests assert totalBonded and slashing effects; H-21 exit-queue test rewritten to use ticket tranches; EnclaveToken tests exercise LOCK_MANAGER_ROLE, locked-floor enforcement, claim-source schedule creation, schedule slot reuse, and bonding/slash interactions.
Examples, Templates & Artifacts
examples/CRISP/**, templates/default/**, packages/enclave-contracts/artifacts/**/*.json
Update example env and CRISP manifests to new localhost addresses/blockNumbers; templates/default deployed metadata refreshed; multiple contract artifacts regenerated with new buildInfoId values.
SDK Preset Path Resolution & Small Docs
packages/enclave-sdk/src/circuits/assert-micro-circuits.ts, packages/enclave-contracts/README.md, examples/CRISP/server/.env.example
Add import.meta.url guard and defer checked flag in SDK preset check; README notes INTERFOLD_TGE_TIMESTAMP requirement for non-local deployments; example env updated ENCLAVE and E3_PROGRAM addresses.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • ctrlc03

🐇 I counted bonds beneath the moonlit code,
Floors and locks where tokens now abode,
TGE set, schedules curl like spring-time grass,
Exits split, and slashes run amass,
A happy rabbit hops — the ledger grows!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title mentions 'interfold token vesting escrow' but the changeset covers multiple concerns: token-level lock schedules, bonding registry updates, exit queue refactoring, and deployment metadata changes. The relationship between the title and the primary changes is unclear. Clarify whether the title should focus on the lock-schedule feature, bonding/exit-queue refactoring, or the broader escrow system. Consider a more specific title like 'feat: add token-level lock schedules with claim-source integration' or 'feat: refactor ENCL bonding with lock-floor enforcement'.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/token-vesting-escrow

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@examples/CRISP/server/.env.example`:
- Around line 18-20: The remaining contract address envs in .env.example are out
of sync: update CRISP_VOTING_TOKEN and all MOCK_* variables so they match the
current localhost deployment manifest (so the example is self-consistent with
ENCLAVE_ADDRESS, FEE_TOKEN_ADDRESS, E3_PROGRAM_ADDRESS); locate the
CRISP_VOTING_TOKEN and MOCK_* entries in the file and replace their values with
the corresponding addresses from the latest localhost deployment manifest,
ensuring the format and hex checksums match the other entries.

In `@packages/enclave-contracts/contracts/registry/BondingRegistry.sol`:
- Around line 1184-1191: _liveLicenseSourceCount currently adds all pending
entries including those before _pendingLicenseHead that have zero amounts;
update _liveLicenseSourceCount to compute the pending portion by iterating from
_pendingLicenseHead[operator] to _pendingLicenseSources[operator].length and
count only entries whose pending amount field is non-zero (e.g.,
_pendingLicenseSources[operator][i].amount or similar), then add that count to
_licenseSources[operator].length; use the existing mappings/arrays
(_licenseSources, _pendingLicenseSources, _pendingLicenseHead) and avoid
changing external storage layout.

In `@packages/enclave-contracts/scripts/deployEnclave.ts`:
- Around line 106-109: The code reads saved TGE args using raw networkName which
can differ from the deployment key; change the call that computes
preDeployedTgeTimestamp to use the deployment-chain key returned by
getDeploymentChain(hre) instead of networkName — i.e., call
readDeploymentArgs("InterfoldVestingEscrow", getDeploymentChain(hre))
(referencing preDeployedTgeTimestamp, readDeploymentArgs, getDeploymentChain,
hre, and InterfoldVestingEscrow) so persisted tgeTimestamp is found even when
network aliases differ.

In `@packages/enclave-sdk/src/circuits/assert-micro-circuits.ts`:
- Around line 51-53: resolveActivePresetPath() is not defined/imported (causing
runtime failure) and the code checks the global ACTIVE_PRESET_PATH instead of
the call result; import or implement the resolver (resolveActivePresetPath) and
replace the global check with a null/undefined check against the returned value
(activePresetPath) so the initialization uses the runtime-resolved path.

In `@templates/default/deployed_contracts.json`:
- Around line 98-100: Top-level manifest address fields (e.g., Enclave.address
and E3RefundManager.address) are inconsistent with their corresponding proxy
records; update the manifest so each contract's top-level "address" equals its
proxyRecords.proxyAddress value (for example, set Enclave.address =
proxyRecords.Enclave.proxyAddress and E3RefundManager.address =
proxyRecords.E3RefundManager.proxyAddress) and repeat the same fix for the other
occurrence noted (lines ~114-119) so all
proxyAddress/implementationAddress/proxyAdminAddress groupings remain internally
consistent.

In `@templates/default/enclave.config.yaml`:
- Around line 6-7: The template's contract entries (notably the e3_program
address and deploy_block fields) are out of sync with the canonical deployment
manifest; update each mismatched template config entry so the e3_program value
and its deploy_block (and the other entries flagged: lines with deploy_block at
positions 10, 13, 16, 22) exactly match the corresponding values in the current
deployed_contracts.json manifest, ensuring addresses and numeric deploy_block
values are copied verbatim and preserving YAML formatting.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6a85e8d2-d93c-4ea2-afa1-3debf19cde6f

📥 Commits

Reviewing files that changed from the base of the PR and between a817b88 and 925bd79.

📒 Files selected for processing (23)
  • agent/flow-trace/02_TOKENS_AND_ACTIVATION.md
  • agent/flow-trace/05_FAILURE_REFUND_SLASHING.md
  • agent/flow-trace/06_DEACTIVATION_AND_COMPLETION.md
  • examples/CRISP/enclave.config.yaml
  • examples/CRISP/packages/crisp-contracts/deployed_contracts.json
  • examples/CRISP/packages/crisp-contracts/hardhat.config.ts
  • examples/CRISP/server/.env.example
  • packages/enclave-contracts/README.md
  • packages/enclave-contracts/artifacts/contracts/interfaces/IBondingRegistry.sol/IBondingRegistry.json
  • packages/enclave-contracts/contracts/interfaces/IBondingRegistry.sol
  • packages/enclave-contracts/contracts/interfaces/IInterfoldVestingEscrow.sol
  • packages/enclave-contracts/contracts/interfaces/ILicenseBondReceiver.sol
  • packages/enclave-contracts/contracts/registry/BondingRegistry.sol
  • packages/enclave-contracts/contracts/token/InterfoldVestingEscrow.sol
  • packages/enclave-contracts/scripts/deployAndSave/interfoldVestingEscrow.ts
  • packages/enclave-contracts/scripts/deployEnclave.ts
  • packages/enclave-contracts/scripts/index.ts
  • packages/enclave-contracts/test/Registry/BondingRegistry.spec.ts
  • packages/enclave-contracts/test/Token/InterfoldVestingEscrow.spec.ts
  • packages/enclave-sdk/src/circuits/assert-micro-circuits.ts
  • templates/default/deployed_contracts.json
  • templates/default/enclave.config.yaml
  • templates/default/hardhat.config.ts

Comment thread examples/CRISP/server/.env.example Outdated
Comment thread packages/enclave-contracts/contracts/registry/BondingRegistry.sol Outdated
Comment thread packages/enclave-contracts/scripts/deployEnclave.ts Outdated
Comment thread packages/enclave-sdk/src/circuits/assert-micro-circuits.ts Outdated
Comment thread templates/default/deployed_contracts.json Outdated
Comment thread templates/default/enclave.config.yaml Outdated
@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Actionable comments posted: 0

Co-authored-by: Cristóvão <cristovaoth@users.noreply.github.com>
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.

4 participants