templar_curator_primitives/
lib.rs

1//! Chain-agnostic curator primitives for Templar Protocol vaults.
2//!
3//! This crate provides shared curator policy and recovery logic that can be used
4//! by both NEAR and Soroban vault executors. It depends only on `templar-vault-kernel`
5//! types and contains no chain-specific SDK dependencies.
6//!
7//! # Modules
8//!
9//! - [`auth`]: Pluggable authentication and authorization primitives
10//! - [`rbac`]: Role-based access control adapter
11//! - [`policy`]: Cap groups, supply queues, withdraw routes, refresh plans, and market locks
12//! - [`recovery`]: Recovery action determination and state machine recovery logic
13//!
14#![cfg_attr(not(feature = "std"), no_std)]
15
16extern crate alloc;
17
18pub mod auth;
19pub mod governance;
20pub mod policy;
21pub mod rbac;
22#[cfg(feature = "recovery")]
23pub mod recovery;
24pub mod utils;
25
26pub use auth::{
27    boundary_policy_class, canonical_policy_class, ActionKind, AuthAdapter, AuthError,
28    AuthPolicyClass, AuthResult,
29};
30pub use rbac::{RbacAuth, RbacConfig, Role, RoleAssignment};
31
32pub use policy::{
33    cap_group::{
34        CapGroup, CapGroupError, CapGroupId, CapGroupRecord, CapGroupUpdate, CapGroupUpdateKey,
35    },
36    cap_group_adapter::{
37        cap_group_record_absolute_cap, cap_group_record_relative_cap,
38        set_cap_group_record_absolute_cap, set_cap_group_record_relative_cap,
39    },
40    cooldown::{Cooldown, CooldownError},
41    market_lock::{validate_lock_expiry, MarketLock, MarketLockSet},
42    refresh_plan::{RefreshPlan, RefreshPlanError},
43    state::{MarketConfig, PolicyState},
44    supply_queue::{SupplyQueue, SupplyQueueEntry, SupplyQueueError},
45    target_set::{
46        build_refresh_plan_from_targets, build_withdraw_plan_from_target_principals,
47        find_duplicate_target_id, find_first_duplicate, find_locked_targets, get_locked_targets,
48        has_unique_items, is_target_locked, validate_no_duplicate_targets,
49    },
50    withdraw_route::{WithdrawRoute, WithdrawRouteEntry, WithdrawRouteError},
51};
52
53#[cfg(feature = "recovery")]
54pub use recovery::{
55    determine_recovery_action, handle_allocation_failure, handle_payout_failure,
56    handle_payout_failure_default, handle_refresh_failure, handle_withdrawal_failure,
57    RecoveryContext, RecoveryOutcome, RecoveryProgress,
58};
59
60pub use governance::{
61    timelock_config_decision, FeeChangeDecision, FeeChangeError, FeeConfig, MembershipChangeError,
62    PendingQueue, PendingQueueError, PendingValue, Restrictions, TimelockConfigError,
63    TimelockDecision,
64};
65pub use utils::{nonnegative_i128_to_u128, seconds_to_nanoseconds, u128_to_i128_checked};
66
67#[cfg(test)]
68mod tests;