-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from adm-metaex/penalties/decrease-rewards
[mtg-577] Add decrease rewards penalty instruction
- Loading branch information
Showing
7 changed files
with
216 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
programs/rewards/src/instructions/penalties/decrease_rewards.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use crate::{asserts::assert_and_get_pool_and_mining, utils::AccountLoader}; | ||
use solana_program::{account_info::AccountInfo, entrypoint::ProgramResult, pubkey::Pubkey}; | ||
|
||
pub fn process_decrease_rewards<'a>( | ||
program_id: &Pubkey, | ||
accounts: &'a [AccountInfo<'a>], | ||
mining_owner: &Pubkey, | ||
decreased_weighted_stake_number: u64, | ||
) -> ProgramResult { | ||
let account_info_iter = &mut accounts.iter().enumerate(); | ||
|
||
let deposit_authority = AccountLoader::next_signer(account_info_iter)?; | ||
let reward_pool = AccountLoader::next_with_owner(account_info_iter, program_id)?; | ||
let mining = AccountLoader::next_with_owner(account_info_iter, program_id)?; | ||
|
||
let reward_pool_data = &mut reward_pool.data.borrow_mut(); | ||
let mining_data = &mut mining.data.borrow_mut(); | ||
|
||
let (_, mut wrapped_mining) = assert_and_get_pool_and_mining( | ||
program_id, | ||
mining_owner, | ||
mining, | ||
reward_pool, | ||
deposit_authority, | ||
reward_pool_data, | ||
mining_data, | ||
)?; | ||
|
||
wrapped_mining.decrease_rewards(decreased_weighted_stake_number)?; | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
mod allow_tokenflow; | ||
mod decrease_rewards; | ||
mod restrict_batch_minting; | ||
mod restrict_tokenflow; | ||
mod slash; | ||
|
||
pub(crate) use allow_tokenflow::*; | ||
pub(crate) use decrease_rewards::*; | ||
pub(crate) use restrict_batch_minting::*; | ||
pub(crate) use restrict_tokenflow::*; | ||
pub(crate) use slash::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters