sablier_network_program/
lib.rs

1//! This program orchestrates a Sablier worker network deployed across a Solana cluster.
2//! It implements a PoS protocol that allows workers to rotate into "pools" proportionately to
3//! the amount of stake delgated to them. It also provides accounts for workers to collect fees
4//! and distribute those fees to delegators.
5
6pub mod constants;
7pub mod errors;
8pub mod state;
9
10mod instructions;
11mod jobs;
12
13use anchor_lang::prelude::*;
14use instructions::*;
15use jobs::*;
16use sablier_utils::thread::*;
17use state::*;
18
19declare_id!("H6CTDj7ewA6PT1jGt2WTnkhWb2RwwuoQkAsgzRuSsnaV");
20
21#[program]
22pub mod network_program {
23    pub use super::*;
24
25    pub fn config_update(ctx: Context<ConfigUpdate>, settings: ConfigSettings) -> Result<()> {
26        config_update::handler(ctx, settings)
27    }
28
29    pub fn delegation_claim(ctx: Context<DelegationClaim>, amount: u64) -> Result<()> {
30        delegation_claim::handler(ctx, amount)
31    }
32
33    pub fn delegation_create(ctx: Context<DelegationCreate>) -> Result<()> {
34        delegation_create::handler(ctx)
35    }
36
37    pub fn delegation_deposit(ctx: Context<DelegationDeposit>, amount: u64) -> Result<()> {
38        delegation_deposit::handler(ctx, amount)
39    }
40
41    pub fn delegation_withdraw(ctx: Context<DelegationWithdraw>, amount: u64) -> Result<()> {
42        delegation_withdraw::handler(ctx, amount)
43    }
44
45    pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
46        initialize::handler(ctx)
47    }
48
49    pub fn penalty_claim(ctx: Context<PenaltyClaim>) -> Result<()> {
50        penalty_claim::handler(ctx)
51    }
52
53    pub fn pool_create(ctx: Context<PoolCreate>) -> Result<()> {
54        pool_create::handler(ctx)
55    }
56
57    pub fn pool_rotate(ctx: Context<PoolRotate>) -> Result<()> {
58        pool_rotate::handler(ctx)
59    }
60
61    pub fn pool_update(ctx: Context<PoolUpdate>, settings: PoolSettings) -> Result<()> {
62        pool_update::handler(ctx, settings)
63    }
64
65    pub fn registry_nonce_hash(ctx: Context<RegistryNonceHash>) -> Result<ThreadResponse> {
66        registry_nonce_hash::handler(ctx)
67    }
68
69    pub fn registry_unlock(ctx: Context<RegistryUnlock>) -> Result<()> {
70        registry_unlock::handler(ctx)
71    }
72
73    pub fn unstake_create(ctx: Context<UnstakeCreate>, amount: u64) -> Result<()> {
74        unstake_create::handler(ctx, amount)
75    }
76
77    pub fn worker_claim(ctx: Context<WorkerClaim>, amount: u64) -> Result<()> {
78        worker_claim::handler(ctx, amount)
79    }
80
81    pub fn worker_create(ctx: Context<WorkerCreate>) -> Result<()> {
82        worker_create::handler(ctx)
83    }
84
85    pub fn worker_utils_create(ctx: Context<WorkerUtilsCreate>) -> Result<()> {
86        worker_utils_create::handler(ctx)
87    }
88
89    pub fn worker_update(ctx: Context<WorkerUpdate>, settings: WorkerSettings) -> Result<()> {
90        worker_update::handler(ctx, settings)
91    }
92
93    // DistributeFees job
94
95    pub fn distribute_fees_job(ctx: Context<DistributeFeesJob>) -> Result<ThreadResponse> {
96        jobs::distribute_fees::job::handler(ctx)
97    }
98
99    pub fn distribute_fees_process_entry(
100        ctx: Context<DistributeFeesProcessEntry>,
101    ) -> Result<ThreadResponse> {
102        jobs::distribute_fees::process_entry::handler(ctx)
103    }
104
105    pub fn distribute_fees_process_frame(
106        ctx: Context<DistributeFeesProcessFrame>,
107    ) -> Result<ThreadResponse> {
108        jobs::distribute_fees::process_frame::handler(ctx)
109    }
110
111    pub fn distribute_fees_process_snapshot(
112        ctx: Context<DistributeFeesProcessSnapshot>,
113    ) -> Result<ThreadResponse> {
114        jobs::distribute_fees::process_snapshot::handler(ctx)
115    }
116
117    // StakeDelegations job
118
119    pub fn stake_delegations_job(ctx: Context<StakeDelegationsJob>) -> Result<ThreadResponse> {
120        jobs::stake_delegations::job::handler(ctx)
121    }
122
123    pub fn stake_delegations_process_worker(
124        ctx: Context<StakeDelegationsProcessWorker>,
125    ) -> Result<ThreadResponse> {
126        jobs::stake_delegations::process_worker::handler(ctx)
127    }
128
129    pub fn stake_delegations_process_delegation(
130        ctx: Context<StakeDelegationsProcessDelegation>,
131    ) -> Result<ThreadResponse> {
132        jobs::stake_delegations::process_delegation::handler(ctx)
133    }
134
135    // TakeSnapshot job
136
137    pub fn take_snapshot_job(ctx: Context<TakeSnapshotJob>) -> Result<ThreadResponse> {
138        jobs::take_snapshot::job::handler(ctx)
139    }
140
141    pub fn take_snapshot_create_entry(
142        ctx: Context<TakeSnapshotCreateEntry>,
143    ) -> Result<ThreadResponse> {
144        jobs::take_snapshot::create_entry::handler(ctx)
145    }
146
147    pub fn take_snapshot_create_frame(
148        ctx: Context<TakeSnapshotCreateFrame>,
149    ) -> Result<ThreadResponse> {
150        jobs::take_snapshot::create_frame::handler(ctx)
151    }
152
153    pub fn take_snapshot_create_snapshot(
154        ctx: Context<TakeSnapshotCreateSnapshot>,
155    ) -> Result<ThreadResponse> {
156        jobs::take_snapshot::create_snapshot::handler(ctx)
157    }
158
159    // IncrementEpoch job
160
161    pub fn increment_epoch(ctx: Context<EpochCutover>) -> Result<ThreadResponse> {
162        jobs::increment_epoch::job::handler(ctx)
163    }
164
165    // Delete snapshot
166
167    pub fn delete_snapshot_job(ctx: Context<DeleteSnapshotJob>) -> Result<ThreadResponse> {
168        jobs::delete_snapshot::job::handler(ctx)
169    }
170
171    pub fn delete_snapshot_process_snapshot(
172        ctx: Context<DeleteSnapshotProcessSnapshot>,
173    ) -> Result<ThreadResponse> {
174        jobs::delete_snapshot::process_snapshot::handler(ctx)
175    }
176
177    pub fn delete_snapshot_process_frame(
178        ctx: Context<DeleteSnapshotProcessFrame>,
179    ) -> Result<ThreadResponse> {
180        jobs::delete_snapshot::process_frame::handler(ctx)
181    }
182
183    pub fn delete_snapshot_process_entry(
184        ctx: Context<DeleteSnapshotProcessEntry>,
185    ) -> Result<ThreadResponse> {
186        jobs::delete_snapshot::process_entry::handler(ctx)
187    }
188
189    // ProcessUnstakes job
190
191    pub fn process_unstakes_job(ctx: Context<ProcessUnstakesJob>) -> Result<ThreadResponse> {
192        jobs::process_unstakes::job::handler(ctx)
193    }
194
195    pub fn unstake_preprocess(ctx: Context<UnstakePreprocess>) -> Result<ThreadResponse> {
196        jobs::process_unstakes::unstake_preprocess::handler(ctx)
197    }
198
199    pub fn unstake_process(ctx: Context<UnstakeProcess>) -> Result<ThreadResponse> {
200        jobs::process_unstakes::unstake_process::handler(ctx)
201    }
202}