phase_protocol_sdk/state/
roadmap.rs

1
2use crate::id;
3use anchor_lang::{account, prelude::Pubkey, prelude::*, AnchorDeserialize, AnchorSerialize};
4
5#[derive(AnchorSerialize, AnchorDeserialize, Clone, PartialEq, Debug)]
6pub enum RoadmapGovType {
7    NFT,
8
9    //Not implemented
10    SPL,
11}
12
13
14#[derive(AnchorSerialize, AnchorDeserialize, Clone, PartialEq, Debug)]
15
16pub enum RoadmapState {
17    //In draft a roadmap config can be freely edited and updated
18    Draft,
19
20    LockedForMint,
21
22    Resolution,
23
24    StagedForResolution,
25
26    // State to show that some staged phases have been moved into approved state
27    // while some are still to be processed into that state
28    Actioning,
29
30    // The Roadmap has been approved and team is now able to action phases
31    // to show what they are currently implementing from the roadmap
32    Actioned,
33
34    Refunding,
35
36    // Not currently implemented
37    Complete,
38
39    Canceled,
40}
41
42#[derive(AnchorSerialize, AnchorDeserialize, Clone, PartialEq, Debug)]
43pub struct RoadmapConfig {
44    pub usdc_team_withdrawl_account: Pubkey,
45    pub sol_team_withdrawal_account: Pubkey,
46    pub minting_account_plugin_program_address: Option<Pubkey>,
47    // Authority can be set for plugin to allow creation of minting account seperate from team authority
48    pub dev_authority: Pubkey,
49}
50
51
52#[account]
53#[derive(Debug)]
54pub struct Roadmap {
55    pub realm: Pubkey,
56    pub collection: Option<Pubkey>,
57    pub team_authority: Pubkey,
58    pub dao_authority: Pubkey,
59    pub metadata_shadow_drive: Pubkey,
60    pub governance_program_id: Pubkey,
61    pub governance_type: RoadmapGovType,
62    pub state: RoadmapState,
63    pub config: RoadmapConfig,
64    pub staged_phase_count: u8,
65    pub locked_phase_count: u8,
66    pub resolution_proposal: Option<Pubkey>,
67
68    // Amount of value in phases that are in lockedForMint state
69    // Only can be actioned if mint completes or is withdrawn and there is enough in the pools
70    // to transfer into phase vaults
71    pub locked_total_usdc: u64,
72    pub locked_total_sol: u64,
73
74    // Amount for phases staged for approval once the roadmap has been unlocked and is in actioning state
75    pub staged_total_usdc: u64,
76    pub staged_total_sol: u64,
77
78    pub approved_phase_count: u8,
79    pub phase_count: u8,
80    pub phases_complete: u8,
81    pub usdc_roadmap_pool: Pubkey,
82    pub sol_roadmap_pool: Pubkey,
83    pub mint_contract_record: Option<Pubkey>,
84    pub bump: u8,
85    pub initial_payout_percentage : u16,
86    pub has_initial_payout_completed : bool,
87    pub reserved: [u8; 15],
88    pub name: String,
89}
90
91impl Roadmap {
92    pub fn space(name: &str) -> usize {
93        8 +
94        std::mem::size_of::<Pubkey>() + // realm_pubkey
95        4 + std::mem::size_of::<Pubkey>() + // collection
96        std::mem::size_of::<Pubkey>() + // team_authority
97        std::mem::size_of::<Pubkey>() + // dao_authority
98        std::mem::size_of::<Pubkey>() + // metadata_shadow_drive
99        std::mem::size_of::<Pubkey>() + // governance_program_id
100        1+ //governance type
101        1 + // state
102        std::mem::size_of::<RoadmapConfig>() +
103        1 + // Staged count
104        1 + // Locked count
105        4 + std::mem::size_of::<Pubkey>()+ // roadmap_resolution_proposal
106        16 + // locked_total_usdc
107        16 + // locked_total_sol
108        16 + // staged total usd
109        16 + // staged total sol
110        1 + // Approved phase count
111        1 + // Phase count
112        1 + //Phases completed
113        std::mem::size_of::<Pubkey>()+ // usdc roadmap_pool
114        std::mem::size_of::<Pubkey>()+ // sol roadmap_pool
115        4 + std::mem::size_of::<Pubkey>()+ // mint_contract_record
116        1 + // bump,
117        16 + //payout percentage
118        1 + // has initial payout completed
119        15 + //reserved
120        name.len()
121    }
122}
123
124
125pub fn get_roadmap_address(realm: &Pubkey, governance_program: &Pubkey) -> Pubkey {
126    Pubkey::find_program_address(
127        &[b"roadmap", governance_program.as_ref(), realm.as_ref()],
128        &id(),
129    )
130    .0
131}
132
133pub fn get_roadmap_pool_address(roadmap: &Pubkey, mint: &Pubkey) -> Pubkey {
134    Pubkey::find_program_address(&[b"roadmap_pool", roadmap.as_ref(), mint.as_ref()], &id()).0
135}