1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
use anchor_lang::prelude::*;

#[error_code]
pub enum ErrorCode {
    // validations
    #[msg("Invalid stake pool")]
    InvalidStakePool = 0,
    #[msg("Invalid stake entry")]
    InvalidStakeEntry,
    #[msg("Invalid stake pool authority")]
    InvalidAuthority,
    #[msg("Mismatched user and escrow")]
    InvalidEscrow,

    // actions
    #[msg("Invalid user original mint token account")]
    InvalidUserStakeMintTokenAccount = 10,
    #[msg("Invalid last staker")]
    InvalidLastStaker,
    #[msg("Cannot update unstaked entry")]
    CannotUpdateUnstakedEntry,
    #[msg("Cannot close staked entry")]
    CannotCloseStakedEntry,
    #[msg("Cannot close staked entry")]
    CannotClosePoolWithStakedEntries,

    // authorization errors
    #[msg("Invalid mint metadata")]
    InvalidMintMetadata = 20,
    #[msg("Mint not allowed in this pool")]
    MintNotAllowedInPool,
    #[msg("Invalid stake authorization provided")]
    InvalidStakeAuthorizationRecord,
    #[msg("Mint metadata is owned by the incorrect program")]
    InvalidMintMetadataOwner,

    // payment errors
    #[msg("Invalid payment mint")]
    InvalidPaymentMint = 30,
    #[msg("Invalid payment shares")]
    InvalidPaymentShares,
    #[msg("Invalid payment share")]
    InvalidPaymentShare,
    #[msg("Invalid payment token account")]
    InvalidPaymentTokenAccount,
    #[msg("Invalid payer token account")]
    InvalidPayerTokenAccount,
    #[msg("Invalid transfer program")]
    InvalidTransferProgram,

    // cooldown errors
    #[msg("Token still has some cooldown seconds remaining")]
    CooldownSecondRemaining = 40,

    // stake_pool errors
    #[msg("Stake pool has ended")]
    StakePoolHasEnded = 50,
    #[msg("Minimum stake seconds not satisfied")]
    MinStakeSecondsNotSatisfied,

    // boost errors
    #[msg("Cannot boost unstaked token")]
    CannotBoostUnstakedToken = 60,
    #[msg("Cannot boost past current time less than start time")]
    CannotBoostMoreThanCurrentTime,
    #[msg("Invalid boost payer token account")]
    InvalidBoostPayerTokenAccount,
    #[msg("Invalid boost payment recipient token account")]
    InvalidBoostPaymentRecipientTokenAccount,
    #[msg("Invalid payment info")]
    InvalidPaymentInfo,
    #[msg("Cannot boost a fungible token stake entry")]
    CannotBoostFungibleToken,

    // reward_receipt errors
    #[msg("Max number of receipts exceeded")]
    MaxNumberOfReceiptsExceeded = 70,
    #[msg("Invalid claimer")]
    InvalidClaimer,
    #[msg("Reward seconds not satisifed")]
    RewardSecondsNotSatisfied,
    #[msg("Invalid payer token account")]
    InvalidPayerTokenAcount,
    #[msg("Invalid max claimed receipts")]
    InvalidMaxClaimedReceipts,
    #[msg("Invalid reward receipt")]
    InvalidRewardReceipt,
    #[msg("Invalid receipt entry")]
    InvalidReceiptEntry,
    #[msg("Insufficient available stake seconds to use")]
    InsufficientAvailableStakeSeconds,
    #[msg("Invalid receipt manager")]
    InvalidReceiptManager,
    #[msg("Reward receipt is not allowed")]
    RewardReceiptIsNotAllowed,
    #[msg("Reward receipt already claimed")]
    RewardReceiptAlreadyClaimed,

    // reward_distribution errors
    #[msg("Invalid token account")]
    InvalidTokenAccount = 90,
    #[msg("Invalid reward mint")]
    InvalidRewardMint,
    #[msg("Invalid user reward mint token account")]
    InvalidUserRewardMintTokenAccount,
    #[msg("Invalid reward distributor")]
    InvalidRewardDistributor,
    #[msg("Invalid reward distributor authority")]
    InvalidRewardDistributorAuthority,
    #[msg("Invalid reward distributor kind")]
    InvalidRewardDistributorKind,
    #[msg("Initial supply required for kind treasury")]
    SupplyRequired,
    #[msg("Invalid distributor for pool")]
    InvalidPoolDistributor,
    #[msg("Distributor is already open")]
    DistributorNotClosed,
    #[msg("Distributor is already closed")]
    DistributorAlreadyClosed,
    #[msg("Invalid reward entry")]
    InvalidRewardEntry,
    #[msg("Invalid reward distributor token account")]
    InvalidRewardDistributorTokenAccount,
    #[msg("Invalid authority token account")]
    InvalidAuthorityTokenAccount,
    #[msg("Max reward seconds claimed")]
    MaxRewardSecondsClaimed,
}