-
Notifications
You must be signed in to change notification settings - Fork 40
Closed
Labels
Description
Summary
Introduce a more robust admin/governance model for the VaultixEscrow contract so that operational responsibilities (treasury, pausing, dispute resolution) are not all tied to a single address. This improves security, flexibility, and maintainability as the protocol grows.
Background
Right now, the contract primarily relies on a single treasury /admin for:
-
Fee configuration
-
Emergency pausing
-
Potential dispute resolution logic
As the protocol matures, we need clearer separation of concerns: -
A treasury that receives platform fees
-
An operator/admin that can pause/resume the contract
-
An arbitrator that can resolve disputes
This also sets us up for future governance (multisig/DAO) without rewriting core logic.
Scope
Contract-level only, focused on lib.rs .
Requirements
- Introduce distinct roles (e.g.):
- treasury (existing): receives fees
- operator (new): can call set_paused , update fee parameters
- arbitrator (new): can resolve disputes (where applicable)
- Store these roles in contract instance storage with clear keys.
- Add initialization/upgrade paths:
- initialize_roles(env, operator: Address, arbitrator: Address) (or extend existing initialize safely).
- Guard against re-initialization ( AlreadyInitialized -style error where appropriate).
- Update existing functions to use the correct role:
- set_paused should require operator auth instead of (or in addition to) treasury.
- Any dispute resolution-related functions should require arbitrator auth.
- Fee updates should be restricted to operator or treasury as per design.
- Emit events when roles are set or updated (e.g. RoleUpdated(role, old, new) ).
- Ensure ContractPaused logic keeps working with the new role model.
Non-Goals
- On-chain DAO or multisig implementation.
- Off-chain governance UI.
Acceptance Criteria
- Clear role separation implemented and enforced via require_auth() checks.
- All role addresses persisted and retrievable via read-only getters.
- Events emitted on role changes with a consistent schema.
- Existing tests still pass.
- New tests cover:
- Unauthorized addresses attempting admin/arb operations.
- Happy-path flows for each role (treasury, operator, arbitrator).
- Re-initialization attempts rejected where appropriate.
Testing
- Add/extend unit tests under test.rs to cover:
- Correct role assignment during initialization.
- Role-based access control for pausing, fee updates, and dispute resolution.
- Negative tests for unauthorized callers.
Reactions are currently unavailable