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    allowed_while_paused, boundary_policy_class, canonical_policy_class, ActionKind, AuthAdapter,
28    AuthError, 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::{
42        AcquireLeaseError, FencingError, FencingToken, LeaseDurationNs, LeaseOwner, MarketLease,
43        MarketLeaseRegistry, ReleaseLeaseError,
44    },
45    refresh_plan::{
46        build_stale_refresh_plan, refresh_execution_plan, RefreshExecutionPlan, RefreshPlan,
47        RefreshPlanError, RefreshTargetStatus, RefreshThrottle, RefreshTiming,
48    },
49    state::{MarketConfig, PolicyState},
50    supply_queue::{SupplyQueue, SupplyQueueEntry, SupplyQueueError},
51    target_set::{
52        build_refresh_plan_from_targets, build_withdraw_capacity_pairs_from_target_principals,
53        find_first_duplicate, has_unique_items,
54    },
55    withdraw_route::{
56        withdraw_plan_from_principals, WithdrawPlanEntry, WithdrawRoute, WithdrawRouteEntry,
57        WithdrawRouteError,
58    },
59};
60
61#[cfg(feature = "recovery")]
62pub use recovery::{
63    compute_payout_failure_outcome, compute_payout_success_outcome, compute_recovery_stats,
64    compute_settlement_shares, determine_recovery_action, plan_allocation_recovery,
65    plan_payout_recovery, plan_refresh_recovery, plan_withdrawal_recovery, PayoutRecoveryEvidence,
66    RecoveryContext, RecoveryError, RecoveryOutcome, RecoveryPolicy, RecoveryProgress,
67};
68
69pub use governance::{
70    timelock_config_decision, FeeChangeDecision, FeeChangeError, FeeConfig, MembershipChangeError,
71    MembershipChangeKind, PendingActions, PendingValue, Restrictions, ScheduledPending,
72    TakePending, TimelockConfigError, TimelockDecision,
73};
74pub use utils::{nonnegative_i128_to_u128, seconds_to_nanoseconds, u128_to_i128_checked};
75
76#[cfg(test)]
77mod tests;