@@ -242,21 +242,21 @@ mod add_pool_reward {
242
242
/// Use [Self::new] to validate the parameters.
243
243
#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
244
244
pub ( super ) struct AddPoolRewardParams {
245
- _priv : ( ) ,
246
245
pub ( super ) position_kind : PositionKind ,
247
246
/// At least the current timestamp.
248
247
pub ( super ) start_time_secs : u64 ,
249
248
/// Larger than [MIN_REWARD_PERIOD_SECS].
250
249
pub ( super ) duration_secs : u32 ,
251
250
/// Larger than zero.
252
251
pub ( super ) reward_token_amount : u64 ,
252
+
253
+ _priv : ( ) ,
253
254
}
254
255
255
256
/// Use [Self::from_unchecked_iter] to validate the accounts except for
256
257
/// * `reward_token_vault_info`
257
258
/// * `rent_info`
258
259
pub ( super ) struct AddPoolRewardAccounts < ' a , ' info > {
259
- _priv : ( ) ,
260
260
/// ✅ belongs to this program
261
261
/// ✅ unpacks
262
262
/// ✅ belongs to `lending_market_info`
@@ -269,6 +269,8 @@ mod add_pool_reward {
269
269
pub ( super ) reward_token_source_info : & ' a AccountInfo < ' info > ,
270
270
/// ✅ seed of `lending_market_info`, `reserve_info`, `reward_mint_info`
271
271
pub ( super ) reward_authority_info : & ' a AccountInfo < ' info > ,
272
+ /// ✅ belongs to the token program
273
+ /// ✅ has no data
272
274
/// ❓ we don't yet know whether it's rent exempt
273
275
pub ( super ) reward_token_vault_info : & ' a AccountInfo < ' info > ,
274
276
/// ✅ belongs to this program
@@ -285,6 +287,8 @@ mod add_pool_reward {
285
287
pub ( super ) token_program_info : & ' a AccountInfo < ' info > ,
286
288
287
289
pub ( super ) reserve : Box < Reserve > ,
290
+
291
+ _priv : ( ) ,
288
292
}
289
293
290
294
impl AddPoolRewardParams {
@@ -322,12 +326,12 @@ mod add_pool_reward {
322
326
}
323
327
324
328
Ok ( Self {
325
- _priv : ( ) ,
326
-
327
329
position_kind,
328
330
start_time_secs,
329
331
duration_secs,
330
332
reward_token_amount,
333
+
334
+ _priv : ( ) ,
331
335
} )
332
336
}
333
337
}
@@ -377,9 +381,16 @@ mod add_pool_reward {
377
381
return Err ( LendingError :: InvalidAccountInput . into ( ) ) ;
378
382
}
379
383
380
- Ok ( Self {
381
- _priv : ( ) ,
384
+ if reward_token_vault_info. owner != token_program_info. key {
385
+ msg ! ( "Reward token vault provided must be owned by the token program" ) ;
386
+ return Err ( LendingError :: InvalidTokenOwner . into ( ) ) ;
387
+ }
388
+ if !reward_token_vault_info. data . borrow ( ) . is_empty ( ) {
389
+ msg ! ( "Reward token vault provided must be empty" ) ;
390
+ return Err ( LendingError :: InvalidAccountInput . into ( ) ) ;
391
+ }
382
392
393
+ Ok ( Self {
383
394
reserve_info,
384
395
reward_mint_info,
385
396
reward_token_source_info,
@@ -391,6 +402,8 @@ mod add_pool_reward {
391
402
token_program_info,
392
403
393
404
reserve,
405
+
406
+ _priv : ( ) ,
394
407
} )
395
408
}
396
409
}
@@ -400,16 +413,14 @@ mod cancel_pool_reward {
400
413
use super :: * ;
401
414
402
415
pub ( super ) struct CancelPoolRewardParams {
403
- _priv : ( ) ,
404
-
405
416
position_kind : PositionKind ,
406
417
pool_reward_index : u64 ,
418
+
419
+ _priv : ( ) ,
407
420
}
408
421
409
422
/// Use [Self::from_unchecked_iter] to validate the accounts.
410
423
pub ( super ) struct CancelPoolRewardAccounts < ' a , ' info > {
411
- _priv : ( ) ,
412
-
413
424
/// ✅ belongs to this program
414
425
/// ✅ unpacks
415
426
/// ✅ belongs to `lending_market_info`
@@ -433,6 +444,8 @@ mod cancel_pool_reward {
433
444
pub ( super ) token_program_info : & ' a AccountInfo < ' info > ,
434
445
435
446
pub ( super ) reserve : Box < Reserve > ,
447
+
448
+ _priv : ( ) ,
436
449
}
437
450
438
451
impl < ' a , ' info > CancelPoolRewardAccounts < ' a , ' info > {
@@ -498,10 +511,10 @@ mod cancel_pool_reward {
498
511
impl CancelPoolRewardParams {
499
512
pub ( super ) fn new ( position_kind : PositionKind , pool_reward_index : u64 ) -> Self {
500
513
Self {
501
- _priv : ( ) ,
502
-
503
514
position_kind,
504
515
pool_reward_index,
516
+
517
+ _priv : ( ) ,
505
518
}
506
519
}
507
520
}
@@ -511,10 +524,10 @@ mod close_pool_reward {
511
524
use super :: * ;
512
525
513
526
pub ( super ) struct ClosePoolRewardParams {
514
- _priv : ( ) ,
515
-
516
527
position_kind : PositionKind ,
517
528
pool_reward_index : u64 ,
529
+
530
+ _priv : ( ) ,
518
531
}
519
532
520
533
/// Use [Self::from_unchecked_iter] to validate the accounts.
@@ -590,8 +603,6 @@ mod close_pool_reward {
590
603
}
591
604
592
605
Ok ( Self {
593
- _priv : ( ) ,
594
-
595
606
reserve_info,
596
607
reward_mint_info,
597
608
reward_token_destination_info,
@@ -602,17 +613,19 @@ mod close_pool_reward {
602
613
token_program_info,
603
614
604
615
reserve,
616
+
617
+ _priv : ( ) ,
605
618
} )
606
619
}
607
620
}
608
621
609
622
impl ClosePoolRewardParams {
610
623
pub ( super ) fn new ( position_kind : PositionKind , pool_reward_index : u64 ) -> Self {
611
624
Self {
612
- _priv : ( ) ,
613
-
614
625
position_kind,
615
626
pool_reward_index,
627
+
628
+ _priv : ( ) ,
616
629
}
617
630
}
618
631
}
0 commit comments