miclockwork_network_program/
lib.rs

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