Feature/vesting vaults - #99
Merged
bakarezainab merged 4 commits intoAug 21, 2026
Merged
Conversation
added 4 commits
January 15, 2025 08:00
Implement core vesting vault functionality: - VestingVault struct with status tracking (Active, Disputed, Released, Refunded) - Storage keys for vault mappings and indexing - create_vesting_vault: locks escrowed funds for a safety window - dispute_vesting_vault: allows admin/creator to open disputes during vesting - release_vesting_vault: releases funds after vesting period ends - refund_vesting_vault: refunds disputed vaults to task creator - View functions for vault details, task vaults, and beneficiary vaults - Time tracking functions (is_vesting_complete, get_remaining_vesting_time)
Add structured events for vesting vault operations: - emit_vesting_vault_created: emitted when a new vault is created - emit_vesting_vault_disputed: emitted when a vault is disputed - emit_vesting_vault_released: emitted when funds are released - emit_vesting_vault_refunded: emitted when disputed funds are refunded Events follow existing contract patterns with symbol_short topics and timestamp data for off-chain indexing.
Add contract-level methods for vesting vault operations: - create_vesting_vault: create time-locked vault for milestone payout - approve_milestone_with_vesting: approve milestone and create vault in one step - dispute_vesting_vault: open dispute during vesting period - release_vesting_vault: release funds after vesting ends - refund_vesting_vault: refund disputed vault to creator - View methods for vault details and time tracking The approve_milestone_with_vesting method allows creators to approve milestones while keeping funds locked for a safety window, enabling disputes before final payout.
Add 12 unit tests validating vesting vault functionality: - test_create_vesting_vault: verify vault creation and fund locking - test_cannot_release_before_vesting_ends: enforce time lock - test_release_after_vesting_ends: verify successful release - test_dispute_during_vesting_period: verify dispute mechanism - test_cannot_release_disputed_vault: block release on dispute - test_refund_disputed_vault: verify refund to creator - test_cannot_dispute_after_vesting_ends: enforce dispute window - test_vesting_time_tracking: verify time tracking functions - test_admin_can_release_vault: admin release capability - test_cannot_create_vault_for_non_approved_milestone: validation - test_cannot_create_duplicate_vault: prevent duplicates - test_multiple_vaults_different_milestones: multiple vaults All 113 tests passing (12 new + 101 existing).
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #88
Implement time-locked vesting vaults for approved milestone payouts. When a milestone is approved, funds can now be held in a vesting state for a configurable safety window (1 hour to 30 days) during which admins or task creators can open disputes. If no dispute is raised within the window, the beneficiary can claim the full payout.
Changes
New Module:
src/vesting_vault.rsVestingVaultstruct with status tracking (Active → Disputed → Released/Refunded)create_vesting_vault— locks escrowed funds for a safety windowdispute_vesting_vault— allows admin/creator to open disputes during vestingrelease_vesting_vault— releases funds after vesting period endsrefund_vesting_vault— refunds disputed vaults to task creatorget_vault,get_task_vaults,get_beneficiary_vaultsis_vesting_complete,get_remaining_vesting_timeContract Integration:
src/lib.rscreate_vesting_vault— create time-locked vault for milestone payoutapprove_milestone_with_vesting— approve milestone and create vault in one stepdispute_vesting_vault— open dispute during vesting periodrelease_vesting_vault— release funds after vesting endsrefund_vesting_vault— refund disputed vault to creatorEvents:
src/events.rsemit_vesting_vault_created— emitted when a new vault is createdemit_vesting_vault_disputed— emitted when a vault is disputedemit_vesting_vault_released— emitted when funds are releasedemit_vesting_vault_refunded— emitted when disputed funds are refundedTests:
src/vesting_vault_test.rsTesting
Test command:
cargo test --lib vesting_vault_testResults: 12/12 tests passing
test_create_vesting_vaulttest_cannot_release_before_vesting_endstest_release_after_vesting_endstest_dispute_during_vesting_periodtest_cannot_release_disputed_vaulttest_refund_disputed_vaulttest_cannot_dispute_after_vesting_endstest_vesting_time_trackingtest_admin_can_release_vaulttest_cannot_create_vault_for_non_approved_milestonetest_cannot_create_duplicate_vaulttest_multiple_vaults_different_milestonesFull suite:
cargo test --lib→ 113 tests passing (12 new + 101 existing)Tradeoffs
Architecture
The vesting vault operates on escrowed funds already held by the contract from task creation. The
approve_milestone_with_vestingmethod creates a vault instead of transferring tokens immediately, keeping funds locked until the vesting period expires or a dispute is resolved.