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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
use borsh::{BorshDeserialize, BorshSerialize};
use solana_client::rpc_client::RpcClient;
use solana_program::pubkey::Pubkey;
use solana_sdk::account::Account;
use tabled::Tabled;
#[derive(BorshDeserialize, BorshSerialize, Tabled)]
pub struct Rewarder {
pub base: Pubkey,
pub bump: u8,
pub authority: Pubkey,
pub pending_authority: Pubkey,
pub num_quarries: u16,
pub annual_rewards_rate: u64,
pub total_rewards_shares: u64,
pub mint_wrapper: Pubkey,
pub rewards_token_mint: Pubkey,
pub claim_fee_token_account: Pubkey,
pub max_claim_fee_millibps: u64,
pub pause_authority: Pubkey,
pub is_paused: bool,
}
impl Rewarder {
pub fn get_info(rpc_client: &RpcClient, pubkey: &Pubkey) -> Self {
let data_slice = &rpc_client.get_account_data(pubkey).unwrap()[8..];
Rewarder::try_from_slice(data_slice).unwrap()
}
pub fn get_account(rpc_client: &RpcClient, pubkey: &Pubkey) -> Account {
rpc_client.get_account(pubkey).unwrap()
}
pub fn new() -> Self {
Self {
base: Default::default(),
bump: 0,
authority: Default::default(),
pending_authority: Default::default(),
num_quarries: 0,
annual_rewards_rate: 0,
total_rewards_shares: 0,
mint_wrapper: Default::default(),
rewards_token_mint: Default::default(),
claim_fee_token_account: Default::default(),
max_claim_fee_millibps: 0,
pause_authority: Default::default(),
is_paused: false
}
}
}
#[derive(BorshDeserialize, BorshSerialize, Tabled)]
pub struct Quarry {
pub rewarder: Pubkey,
pub token_mint_key: Pubkey,
pub bump: u8,
pub index: u16,
pub token_mint_decimals: u8,
pub famine_ts: i64,
pub last_update_ts: i64,
pub rewards_per_token_stored: u128,
pub annual_rewards_rate: u64,
pub rewards_share: u64,
pub total_tokens_deposited: u64,
pub num_miners: u64,
}
impl Quarry {
pub fn get_info(rpc_client: &RpcClient, pubkey: &Pubkey) -> Self {
let data_slice = &rpc_client.get_account_data(pubkey).unwrap()[8..];
Quarry::try_from_slice(data_slice).unwrap()
}
pub fn get_account(rpc_client: &RpcClient, pubkey: &Pubkey) -> Account {
rpc_client.get_account(pubkey).unwrap()
}
pub fn new() -> Self {
Self {
rewarder: Default::default(),
token_mint_key: Default::default(),
bump: 0,
index: 0,
token_mint_decimals: 0,
famine_ts: 0,
last_update_ts: 0,
rewards_per_token_stored: 0,
annual_rewards_rate: 0,
rewards_share: 0,
total_tokens_deposited: 0,
num_miners: 0
}
}
}
#[derive(BorshDeserialize, BorshSerialize, Tabled)]
pub struct Miner {
pub quarry: Pubkey,
pub authority: Pubkey,
pub bump: u8,
pub token_vault_key: Pubkey,
pub rewards_earned: u64,
pub rewards_per_token_paid: u128,
pub balance: u64,
pub index: u64,
}
impl Miner {
pub fn get_info(rpc_client: &RpcClient, pubkey: &Pubkey) -> Self {
let data_slice = &rpc_client.get_account_data(pubkey).unwrap()[8..];
Miner::try_from_slice(data_slice).unwrap()
}
pub fn get_account(rpc_client: &RpcClient, pubkey: &Pubkey) -> Account {
rpc_client.get_account(pubkey).unwrap()
}
}