access-protocol 0.7.15

Access Protocol
Documentation
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
use solana_sdk::signer::Signer;
use solana_test_framework::*;

use crate::common::test_runner::TestRunner;

pub mod common;

const DAY: u64 = 86400;
const DAILY_INFLATION: u64 = 1_000_000_000_000; // 1M of tokens

#[tokio::test]
async fn full_system_test() {
    // ------------------------------------------
    // DAY 1
    //-------------------------------------------
    // Setup the token + basic accounts
    let mut tr = TestRunner::new(DAILY_INFLATION).await.unwrap();

    // Setup 3 airdrop users
    let airdrop_user1 = tr.create_user_with_ata().await.unwrap();
    let airdrop_user2 = tr.create_user_with_ata().await.unwrap();
    let airdrop_user3 = tr.create_user_with_ata().await.unwrap();

    // Setup 2 vesting users
    let vesting_user1 = tr.create_user_with_ata().await.unwrap();
    let vesting_user2 = tr.create_user_with_ata().await.unwrap();

    // Setup 3 pool owners
    let pool_owner = tr.create_user_with_ata().await.unwrap();
    let pool_owner2 = tr.create_user_with_ata().await.unwrap();
    let pool_owner3 = tr.create_user_with_ata().await.unwrap();

    // Setup all the pools
    tr.create_pool(&pool_owner, 1_000_000_000)
        .await
        .unwrap();
    tr.create_pool(&pool_owner2, 1_000_000_000)
        .await
        .unwrap();
    tr.create_pool(&pool_owner3, 1_000_000_000)
        .await
        .unwrap();

    // Activate the pools
    tr.activate_stake_pool(&pool_owner.pubkey()).await.unwrap();
    tr.activate_stake_pool(&pool_owner2.pubkey()).await.unwrap();
    tr.activate_stake_pool(&pool_owner3.pubkey()).await.unwrap();

    // Setup 1 staker with 10_200_000_000 tokens in his account and appropriate stake accounts for all pools
    let staker = tr.create_user_with_ata().await.unwrap();
    tr.mint(&staker.pubkey(), 10_200_000_000).await.unwrap();
    tr.create_stake_account(&pool_owner.pubkey(), &staker.pubkey())
        .await
        .unwrap();
    tr.create_stake_account(&pool_owner2.pubkey(), &staker.pubkey())
        .await
        .unwrap();
    tr.create_stake_account(&pool_owner3.pubkey(), &staker.pubkey())
        .await
        .unwrap();

    // ------------------------------------------
    // DAY 2
    //-------------------------------------------
    tr.sleep(DAY).await.unwrap();
    tr.crank_pool(&pool_owner.pubkey()).await.unwrap();
    // First two airdrop users get airdrop of 100000 tokens to the first pool with the release date on day 10
    tr.create_bond(
        &pool_owner.pubkey(),
        &airdrop_user1.pubkey(),
        100_000_000_000,
        1,
        8 * DAY as i64,
        1,
    )
    .await
    .unwrap();
    tr.create_bond(
        &pool_owner.pubkey(),
        &airdrop_user2.pubkey(),
        100_000_000_000,
        1,
        8 * DAY as i64,
        1,
    )
    .await
    .unwrap();
    tr.claim_bond(&pool_owner.pubkey(), &airdrop_user1.pubkey())
        .await
        .unwrap();
    tr.claim_bond(&pool_owner.pubkey(), &airdrop_user2.pubkey())
        .await
        .unwrap();

    let pool_stats = tr.pool_stats(pool_owner.pubkey()).await.unwrap();
    assert_eq!(pool_stats.header.total_staked, 200_000_000_000);
    let central_state = tr.central_state_stats().await.unwrap();
    assert_eq!(central_state.account.total_staked, 200_000_000_000);

    // ------------------------------------------
    // DAY 3
    //-------------------------------------------
    tr.sleep(DAY).await.unwrap();
    tr.crank_pool(&pool_owner.pubkey()).await.unwrap();
    tr.crank_pool(&pool_owner2.pubkey()).await.unwrap();
    tr.crank_pool(&pool_owner3.pubkey()).await.unwrap();

    // last airdrop user gets airdrop of 100000 tokens to second pool with the release date on day 10
    tr.create_bond(
        &pool_owner2.pubkey(),
        &airdrop_user3.pubkey(),
        100_000_000_000,
        1,
        7 * DAY as i64,
        1,
    )
    .await
    .unwrap();
    tr.claim_bond(&pool_owner2.pubkey(), &airdrop_user3.pubkey())
        .await
        .unwrap();

    // staker stakes 10000 tokens to each pool - second stake should fail at first, then we mint some more tokens to the staker
    tr.stake(&pool_owner.pubkey(), &staker, 10_000_000_000)
        .await
        .unwrap();
    tr.stake(&pool_owner2.pubkey(), &staker, 10_000_000_000)
        .await
        .unwrap_err();
    tr.mint(&staker.pubkey(), 20_400_000_000).await.unwrap();
    let staker_stats = tr.staker_stats(staker.pubkey()).await.unwrap();
    assert_eq!(staker_stats.balance, 20_400_000_000);
    tr.sleep(1).await.unwrap(); // so that we are not sending the same transaction twice in the same block
    tr.stake(&pool_owner2.pubkey(), &staker, 10_000_000_000)
        .await
        .unwrap();
    let staker_stats = tr.staker_stats(staker.pubkey()).await.unwrap();
    assert_eq!(staker_stats.balance, 10_200_000_000);
    tr.stake(&pool_owner3.pubkey(), &staker, 10_000_000_000)
        .await
        .unwrap();

    // check that the totalStaked and pool stats are correct
    let pool1_stats = tr.pool_stats(pool_owner.pubkey()).await.unwrap();
    assert_eq!(pool1_stats.header.total_staked, 210_000_000_000);
    let pool2_stats = tr.pool_stats(pool_owner2.pubkey()).await.unwrap();
    assert_eq!(pool2_stats.header.total_staked, 110_000_000_000);
    let pool3_stats = tr.pool_stats(pool_owner3.pubkey()).await.unwrap();
    assert_eq!(pool3_stats.header.total_staked, 10_000_000_000);
    let central_state = tr.central_state_stats().await.unwrap();
    assert_eq!(central_state.account.total_staked, 330_000_000_000);

    // ------------------------------------------
    // DAY 4
    //-------------------------------------------
    tr.sleep(DAY).await.unwrap();
    tr.crank_pool(&pool_owner.pubkey()).await.unwrap();
    tr.crank_pool(&pool_owner2.pubkey()).await.unwrap();
    tr.crank_pool(&pool_owner3.pubkey()).await.unwrap();

    // create vesting airdrop with cliff at day 7 with rewards for 100_000 tokens to both vesting users to pool1 and pool3
    // fixme the parameter should be 3 * DAY not 2 * DAY, but with the current implementation this wouldn't work
    tr.create_bond(
        &pool_owner.pubkey(),
        &vesting_user1.pubkey(),
        10_000_000_000,
        10,
        2 * DAY as i64,
        DAY as i64,
    )
    .await
    .unwrap();
    tr.claim_bond(&pool_owner.pubkey(), &vesting_user1.pubkey())
        .await
        .unwrap();
    tr.create_bond(
        &pool_owner.pubkey(),
        &vesting_user2.pubkey(),
        10_000_000_000,
        10,
        2 * DAY as i64,
        DAY as i64,
    )
    .await
    .unwrap();
    tr.claim_bond(&pool_owner.pubkey(), &vesting_user2.pubkey())
        .await
        .unwrap();
    tr.create_bond(
        &pool_owner3.pubkey(),
        &vesting_user1.pubkey(),
        10_000_000_010,
        10,
        2 * DAY as i64,
        DAY as i64,
    )
    .await
    .unwrap();
    tr.claim_bond(&pool_owner3.pubkey(), &vesting_user1.pubkey())
        .await
        .unwrap();
    tr.create_bond(
        &pool_owner3.pubkey(),
        &vesting_user2.pubkey(),
        10_000_000_010,
        10,
        2 * DAY as i64,
        DAY as i64,
    )
    .await
    .unwrap();
    tr.claim_bond(&pool_owner3.pubkey(), &vesting_user2.pubkey())
        .await
        .unwrap();

    // check that the totalStaked and pool stats are correct
    let pool1_stats = tr.pool_stats(pool_owner.pubkey()).await.unwrap();
    assert_eq!(pool1_stats.header.total_staked, 230_000_000_000);
    let pool2_stats = tr.pool_stats(pool_owner2.pubkey()).await.unwrap();
    assert_eq!(pool2_stats.header.total_staked, 110_000_000_000);
    let pool3_stats = tr.pool_stats(pool_owner3.pubkey()).await.unwrap();
    assert_eq!(pool3_stats.header.total_staked, 30_000_000_020);
    let central_state = tr.central_state_stats().await.unwrap();
    assert_eq!(central_state.account.total_staked, 370_000_000_020);

    // ------------------------------------------
    // DAY 5
    //-------------------------------------------
    tr.sleep(DAY).await.unwrap();
    tr.crank_pool(&pool_owner.pubkey()).await.unwrap();
    tr.crank_pool(&pool_owner2.pubkey()).await.unwrap();
    tr.crank_pool(&pool_owner3.pubkey()).await.unwrap();

    // staker unstakes 5000 tokens from pool1 - first unstake should fail at first, then he claims his rewards, but just for pool 1
    tr.unstake(&pool_owner.pubkey(), &staker, 5_000_000_000)
        .await
        .unwrap_err();
    tr.claim_staker_rewards(&pool_owner.pubkey(), &staker)
        .await
        .unwrap();
    tr.sleep(1).await.unwrap(); // so that we are not sending the same transaction twice in the same block
    tr.unstake(&pool_owner.pubkey(), &staker, 5_000_000_000)
        .await
        .unwrap();

    // check that the totalStaked and pool stats are correct
    let pool1_stats = tr.pool_stats(pool_owner.pubkey()).await.unwrap();
    assert_eq!(pool1_stats.header.total_staked, 225_000_000_000);
    let pool2_stats = tr.pool_stats(pool_owner2.pubkey()).await.unwrap();
    assert_eq!(pool2_stats.header.total_staked, 110_000_000_000);
    let pool3_stats = tr.pool_stats(pool_owner3.pubkey()).await.unwrap();
    assert_eq!(pool3_stats.header.total_staked, 30_000_000_020);
    let central_state = tr.central_state_stats().await.unwrap();
    assert_eq!(central_state.account.total_staked, 365_000_000_020);
    let staker_stats = tr.staker_stats(staker.pubkey()).await.unwrap();
    assert_eq!(
        staker_stats.balance,
        5_000_000_000
            + ((DAILY_INFLATION as f64 / 330.0 * 10.0 * 0.5)
                + (DAILY_INFLATION as f64 * 10_000_000_000.0 / 370_000_000_020.0 * 0.5))
                .round() as u64
    );

    // ------------------------------------------
    // DAY 6
    //-------------------------------------------
    tr.sleep(DAY).await.unwrap();
    tr.crank_pool(&pool_owner.pubkey()).await.unwrap();
    tr.crank_pool(&pool_owner2.pubkey()).await.unwrap();
    tr.crank_pool(&pool_owner3.pubkey()).await.unwrap();

    //vestingUser1 should be able to claim his rewards in pool1
    tr.claim_bond_rewards(&pool_owner.pubkey(), &vesting_user1)
        .await
        .unwrap();
    let vesting_owner_stats = tr.staker_stats(vesting_user1.pubkey()).await.unwrap();
    // todo maybe investigate this rounding error
    assert_eq!(
        vesting_owner_stats.balance / 10,
        ((DAILY_INFLATION as f64 * 10_000_000_000.0 / 370_000_000_020.0 * 0.5)
            + (DAILY_INFLATION as f64 * 10_000_000_000.0 / 365_000_000_020.0 * 0.5))
            .round() as u64
            / 10
    );

    // no one can claim their airdrops yet
    tr.unlock_bond(&pool_owner.pubkey(), &airdrop_user1)
        .await
        .unwrap_err();
    tr.unlock_bond(&pool_owner.pubkey(), &airdrop_user2)
        .await
        .unwrap_err();
    tr.unlock_bond(&pool_owner2.pubkey(), &airdrop_user3)
        .await
        .unwrap_err();
    tr.unlock_bond(&pool_owner.pubkey(), &vesting_user1)
        .await
        .unwrap_err();
    tr.unlock_bond(&pool_owner.pubkey(), &vesting_user2)
        .await
        .unwrap_err();

    // claim rewards as a pool1 owner
    tr.claim_pool_rewards(&pool_owner).await.unwrap();
    let pool_owner_stats = tr.staker_stats(pool_owner.pubkey()).await.unwrap();
    assert_eq!(
        pool_owner_stats.balance,
        ((DAILY_INFLATION as f64 * 0.5)
            + (DAILY_INFLATION as f64 / 330.0 * 210.0 * 0.5)
            + (DAILY_INFLATION as f64 * 230_000_000_000.0 / 370_000_000_020.0 * 0.5)
            + (DAILY_INFLATION as f64 * 225_000_000_000.0 / 365_000_000_020.0 * 0.5))
            .round() as u64
    );

    // ------------------------------------------
    // DAY 7
    //-------------------------------------------
    tr.sleep(DAY).await.unwrap();
    tr.crank_pool(&pool_owner.pubkey()).await.unwrap();
    tr.crank_pool(&pool_owner2.pubkey()).await.unwrap();
    tr.crank_pool(&pool_owner3.pubkey()).await.unwrap();

    // the first part of the vesting airdrop should be ready now
    tr.claim_bond_rewards(&pool_owner.pubkey(), &vesting_user1)
        .await
        .unwrap();
    tr.unlock_bond(&pool_owner.pubkey(), &vesting_user1)
        .await
        .unwrap();
    let vesting_owner_stats = tr.staker_stats(vesting_user1.pubkey()).await.unwrap();
    // todo maybe investigate this rounding error
    assert_eq!(
        vesting_owner_stats.balance / 10,
        1_000_000_000 / 10
            + ((DAILY_INFLATION as f64 * 10_000_000_000.0 / 370_000_000_020.0 * 0.5)
                + (DAILY_INFLATION as f64 * 10_000_000_000.0 / 365_000_000_020.0 * 0.5)
                + (DAILY_INFLATION as f64 * 10_000_000_000.0 / 365_000_000_020.0 * 0.5))
                .round() as u64
                / 10
    );

    // second unlock of the same bond should fail today
    tr.sleep(1).await.unwrap(); // so that we are not sending the same transaction twice in the same block
    tr.claim_bond_rewards(&pool_owner.pubkey(), &vesting_user1)
        .await
        .unwrap_err();
    tr.unlock_bond(&pool_owner.pubkey(), &vesting_user1)
        .await
        .unwrap_err();

    // pool1 owner should be able to claim his rewards again
    tr.claim_pool_rewards(&pool_owner).await.unwrap();
    let pool_owner_stats = tr.staker_stats(pool_owner.pubkey()).await.unwrap();
    assert_eq!(
        pool_owner_stats.balance,
        ((DAILY_INFLATION as f64 * 0.5)
            + (DAILY_INFLATION as f64 / 330.0 * 210.0 * 0.5)
            + (DAILY_INFLATION as f64 * 230_000_000_000.0 / 370_000_000_020.0 * 0.5)
            + (DAILY_INFLATION as f64 * 225_000_000_000.0 / 365_000_000_020.0 * 0.5)
            + (DAILY_INFLATION as f64 * 225_000_000_000.0 / 365_000_000_020.0 * 0.5))
            .round() as u64
    );

    // ------------------------------------------
    // DAY 8
    //-------------------------------------------
    tr.sleep(DAY).await.unwrap();
    tr.crank_pool(&pool_owner.pubkey()).await.unwrap();
    tr.crank_pool(&pool_owner2.pubkey()).await.unwrap();
    tr.crank_pool(&pool_owner3.pubkey()).await.unwrap();

    // the second part of the vesting airdrop should be ready now
    tr.claim_bond_rewards(&pool_owner.pubkey(), &vesting_user1)
        .await
        .unwrap();
    tr.unlock_bond(&pool_owner.pubkey(), &vesting_user1)
        .await
        .unwrap();
    let vesting_owner_stats = tr.staker_stats(vesting_user1.pubkey()).await.unwrap();
    // todo maybe investigate this rounding error
    assert_eq!(
        vesting_owner_stats.balance / 10,
        2_000_000_000 / 10
            + ((DAILY_INFLATION as f64 * 10_000_000_000.0 / 370_000_000_020.0 * 0.5)
                + (DAILY_INFLATION as f64 * 10_000_000_000.0 / 365_000_000_020.0 * 0.5)
                + (DAILY_INFLATION as f64 * 10_000_000_000.0 / 365_000_000_020.0 * 0.5)
                + (DAILY_INFLATION as f64 * 9_000_000_000.0 / 364_000_000_020.0 * 0.5))
                .round() as u64
                / 10
    );

    // ------------------------------------------
    // DAY 9
    //-------------------------------------------
    tr.sleep(DAY).await.unwrap();
    tr.crank_pool(&pool_owner.pubkey()).await.unwrap();
    tr.crank_pool(&pool_owner2.pubkey()).await.unwrap();
    tr.crank_pool(&pool_owner3.pubkey()).await.unwrap();

    // check that the airdrop_users still cannot claim their airdrop
    tr.claim_bond_rewards(&pool_owner.pubkey(), &airdrop_user1)
        .await
        .unwrap();
    tr.unlock_bond(&pool_owner.pubkey(), &airdrop_user1)
        .await
        .unwrap_err();
    tr.claim_bond_rewards(&pool_owner.pubkey(), &airdrop_user2)
        .await
        .unwrap();
    tr.unlock_bond(&pool_owner.pubkey(), &airdrop_user2)
        .await
        .unwrap_err();
    tr.claim_bond_rewards(&pool_owner2.pubkey(), &airdrop_user3)
        .await
        .unwrap();
    tr.unlock_bond(&pool_owner2.pubkey(), &airdrop_user3)
        .await
        .unwrap_err();

    // ------------------------------------------
    // DAY 10
    //-------------------------------------------
    tr.sleep(DAY).await.unwrap();
    tr.crank_pool(&pool_owner.pubkey()).await.unwrap();
    tr.crank_pool(&pool_owner2.pubkey()).await.unwrap();
    tr.crank_pool(&pool_owner3.pubkey()).await.unwrap();

    // check that the airdropUser2 can claim his airdrop
    tr.claim_bond_rewards(&pool_owner.pubkey(), &airdrop_user2)
        .await
        .unwrap();
    tr.unlock_bond(&pool_owner.pubkey(), &airdrop_user2)
        .await
        .unwrap();
    let airdrop_user2_stats = tr.staker_stats(airdrop_user2.pubkey()).await.unwrap();
    // todo maybe investigate this rounding error
    assert_eq!(
        airdrop_user2_stats.balance / 100,
        100_000_000_000 / 100
            + (DAILY_INFLATION as f64 * 100_000_000_000.0 / 200_000_000_000.0 * 0.5
                + DAILY_INFLATION as f64 * 100_000_000_000.0 / 330_000_000_000.0 * 0.5
                + DAILY_INFLATION as f64 * 100_000_000_000.0 / 370_000_000_020.0 * 0.5
                + DAILY_INFLATION as f64 * 100_000_000_000.0 / 365_000_000_020.0 * 0.5
                + DAILY_INFLATION as f64 * 100_000_000_000.0 / 365_000_000_020.0 * 0.5
                + DAILY_INFLATION as f64 * 100_000_000_000.0 / 364_000_000_020.0 * 0.5
                + DAILY_INFLATION as f64 * 100_000_000_000.0 / 363_000_000_020.0 * 0.5
                + DAILY_INFLATION as f64 * 100_000_000_000.0 / 363_000_000_020.0 * 0.5)
                .round() as u64
                / 100
    );

    //check that the pool1 owner can claim his rewards
    tr.claim_pool_rewards(&pool_owner).await.unwrap();
    let pool_owner_stats = tr.staker_stats(pool_owner.pubkey()).await.unwrap();
    assert_eq!(
        pool_owner_stats.balance / 10,
        (DAILY_INFLATION as f64 * 0.5
            + DAILY_INFLATION as f64 / 330.0 * 210.0 * 0.5
            + DAILY_INFLATION as f64 * 230_000_000_000.0 / 370_000_000_020.0 * 0.5
            + DAILY_INFLATION as f64 * 225_000_000_000.0 / 365_000_000_020.0 * 0.5
            + DAILY_INFLATION as f64 * 225_000_000_000.0 / 365_000_000_020.0 * 0.5
            + DAILY_INFLATION as f64 * 224_000_000_000.0 / 364_000_000_020.0 * 0.5
            + DAILY_INFLATION as f64 * 223_000_000_000.0 / 363_000_000_020.0 * 0.5
            + DAILY_INFLATION as f64 * 223_000_000_000.0 / 363_000_000_020.0 * 0.5)
            .round() as u64
            / 10
    );

    // ------------------------------------------
    // DAY 11
    //-------------------------------------------
    tr.sleep(DAY).await.unwrap();
    tr.crank_pool(&pool_owner.pubkey()).await.unwrap();
    tr.crank_pool(&pool_owner2.pubkey()).await.unwrap();
    tr.crank_pool(&pool_owner3.pubkey()).await.unwrap();

    // check that the pool1 owner can claim his rewards
    tr.claim_pool_rewards(&pool_owner).await.unwrap();
    let pool_owner_stats = tr.staker_stats(pool_owner.pubkey()).await.unwrap();
    assert_eq!(
        pool_owner_stats.balance / 10,
        ((DAILY_INFLATION as f64 * 0.5)
            + (DAILY_INFLATION as f64 / 330.0 * 210.0 * 0.5)
            + (DAILY_INFLATION as f64 * 230_000_000_000.0 / 370_000_000_020.0 * 0.5)
            + (DAILY_INFLATION as f64 * 225_000_000_000.0 / 365_000_000_020.0 * 0.5)
            + (DAILY_INFLATION as f64 * 225_000_000_000.0 / 365_000_000_020.0 * 0.5)
            + (DAILY_INFLATION as f64 * 224_000_000_000.0 / 364_000_000_020.0 * 0.5)
            + (DAILY_INFLATION as f64 * 223_000_000_000.0 / 363_000_000_020.0 * 0.5)
            + (DAILY_INFLATION as f64 * 223_000_000_000.0 / 363_000_000_020.0 * 0.5)
            + (DAILY_INFLATION as f64 * 123_000_000_000.0 / 263_000_000_020.0 * 0.5))
            .round() as u64
            / 10
    );

    // staker claims all rewards
    tr.claim_staker_rewards(&pool_owner.pubkey(), &staker)
        .await
        .unwrap();
    tr.claim_staker_rewards(&pool_owner2.pubkey(), &staker)
        .await
        .unwrap();
    tr.claim_staker_rewards(&pool_owner3.pubkey(), &staker)
        .await
        .unwrap();
    let staker_stats = tr.staker_stats(staker.pubkey()).await.unwrap();
    // todo maybe investigate this rounding error
    assert_eq!(
        staker_stats.balance / 100,
        5_000_000_000 / 100
            + ((DAILY_INFLATION as f64 / 330.0 * 30.0 * 0.5)
                + (DAILY_INFLATION as f64 * 30_000_000_000.0 / 370_000_000_020.0 * 0.5)
                + (DAILY_INFLATION as f64 * 25_000_000_000.0 / 365_000_000_020.0 * 0.5)
                + (DAILY_INFLATION as f64 * 25_000_000_000.0 / 365_000_000_020.0 * 0.5)
                + (DAILY_INFLATION as f64 * 25_000_000_000.0 / 364_000_000_020.0 * 0.5)
                + (DAILY_INFLATION as f64 * 25_000_000_000.0 / 363_000_000_020.0 * 0.5)
                + (DAILY_INFLATION as f64 * 25_000_000_000.0 / 363_000_000_020.0 * 0.5)
                + (DAILY_INFLATION as f64 * 25_000_000_000.0 / 263_000_000_020.0 * 0.5))
                .round() as u64
                / 100
    );

    // unstake it all
    tr.unstake(&pool_owner.pubkey(), &staker, 5_000_000_000)
        .await
        .unwrap();
    tr.unstake(&pool_owner2.pubkey(), &staker, 10_000_000_000)
        .await
        .unwrap();
    tr.unstake(&pool_owner3.pubkey(), &staker, 10_000_000_000)
        .await
        .unwrap();

    // claim rewards as a staker - should not claim anything
    tr.sleep(1).await.unwrap(); // so that we are not sending the same transaction twice in the same block
    tr.claim_staker_rewards(&pool_owner.pubkey(), &staker)
        .await
        .unwrap();
    tr.claim_staker_rewards(&pool_owner2.pubkey(), &staker)
        .await
        .unwrap();
    tr.claim_staker_rewards(&pool_owner3.pubkey(), &staker)
        .await
        .unwrap();
    let staker_stats = tr.staker_stats(staker.pubkey()).await.unwrap();
    // todo maybe investigate this rounding error
    assert_eq!(
        staker_stats.balance / 100,
        30_000_000_000 / 100
            + ((DAILY_INFLATION as f64 / 330.0 * 30.0 * 0.5)
                + (DAILY_INFLATION as f64 * 30_000_000_000.0 / 370_000_000_020.0 * 0.5)
                + (DAILY_INFLATION as f64 * 25_000_000_000.0 / 365_000_000_020.0 * 0.5)
                + (DAILY_INFLATION as f64 * 25_000_000_000.0 / 365_000_000_020.0 * 0.5)
                + (DAILY_INFLATION as f64 * 25_000_000_000.0 / 364_000_000_020.0 * 0.5)
                + (DAILY_INFLATION as f64 * 25_000_000_000.0 / 363_000_000_020.0 * 0.5)
                + (DAILY_INFLATION as f64 * 25_000_000_000.0 / 363_000_000_020.0 * 0.5)
                + (DAILY_INFLATION as f64 * 25_000_000_000.0 / 263_000_000_020.0 * 0.5))
                .round() as u64
                / 100
    );
}