clockwork_pool_program/instructions/
pool_rotate.rs

1use {crate::objects::*, anchor_lang::prelude::*};
2
3#[derive(Accounts)]
4pub struct PoolRotate<'info> {
5    #[account(
6        address = Config::pubkey(), 
7        has_one = pool_authority
8    )]
9    pub config: Account<'info, Config>,
10
11    #[account(mut, address = pool.pubkey())]
12    pub pool: Account<'info, Pool>,
13
14    #[account()]
15    pub pool_authority: Signer<'info>,
16
17    #[account()]
18    pub worker: SystemAccount<'info>,
19}
20
21pub fn handler(ctx: Context<PoolRotate>) -> Result<()> {
22    // Get accounts
23    let pool = &mut ctx.accounts.pool;
24    let worker = &ctx.accounts.worker;
25
26    // Rotate the worker into the pool
27    pool.rotate(worker.key())?;
28
29    Ok(())
30}