-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor and bugfixing - a way to view it #14
Conversation
programs/rewards/src/instruction.rs
Outdated
@@ -116,6 +118,14 @@ pub enum RewardsInstruction { | |||
#[account(0, writable, name = "reward_pool", desc = "The address of the reward pool")] | |||
#[account(1, signer, name = "distribute_authority", desc = "The address of Authority who is eligble for distributiong rewards for users")] | |||
DistributeRewards, | |||
|
|||
/// Distributes tokens among mining owners |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not really
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
let mining = Mining::unpack(&self.mining.data.borrow())?; | ||
assert_account_key(self.mining_owner, &mining.owner)?; | ||
|
||
if mining.index.unclaimed_rewards != 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
before this check you'll need to update the unclaimed_rewards:
the user might not have interacted with the mining after the initial deposit. If the deposit has expired with no other interactions the unclaimed_rewards will still be 0 at that point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
let dest_starting_lamports = self.target_account.lamports(); | ||
|
||
**self.target_account.lamports.borrow_mut() = dest_starting_lamports | ||
.checked_add(self.mining.lamports()) | ||
.ok_or(MplxRewardsError::MathOverflow)?; | ||
**self.mining.lamports.borrow_mut() = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it the same anchor is doing when provided with close = sol_destination
? If so it's worth commenting this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
* Initialize rewards-pool deposit authority signature * fixed comments and fmt
…-of-returning-Ok Throw an error instead of returning Ok() when 'rewards == 0'
fixed CI/CD, added README.md and cargo audit
Unify Contexts and verification checks
improved error handling
Threw an error if `weighted_stake_diffs.entry()` is empty
* initial design * fix tests for delegated initial design * Extend extend_stake instruction with delegate parameter Extend deposit_mining instruction with delegate parameter * Refactor and make arithmetic operations more readable * Add tests for delegated staking * minor fix * [MTG-237] ci cd (#17) fixed CI/CD, added README.md and cargo audit * Change ordering for PartialOrd and Ord for LockupPeriod * refactor * refactor asserts * remove redundant substraction from delegated stake check * Forbid mining account from closing if it has stake_from_others * remove useless comment * add delegate_mining field to the withdraw_mining && remove verification for weighted stake since it's done on the staking contract * initial design * fix tests for delegated initial design * Extend extend_stake instruction with delegate parameter Extend deposit_mining instruction with delegate parameter * Refactor and make arithmetic operations more readable * Add tests for delegated staking * Change ordering for PartialOrd and Ord for LockupPeriod * refactor * refactor asserts * remove redundant substraction from delegated stake check * Forbid mining account from closing if it has stake_from_others * remove useless comment * add delegate_mining field to the withdraw_mining && remove verification for weighted stake since it's done on the staking contract * remove useless imports * add more packing on closing account * update tests * remove redundant packing * [mtg-308] (#24) * add change delegate function * change_delegate: add an early return for the case when new_delegate_mining and old_delegate_mining are the same * satisfy clippy * [mtg-297] add stake_from_others for rewards calculations (#26) * add change delegate function * change_delegate: add an early return for the case when new_delegate_mining and old_delegate_mining are the same * satisfy clippy * add stake_from_others for rewards calculations * satisfy clippy * update tests && rebase * Add refreshing of rewards for delegate mining each time it's stake_from_others changes * Update programs/rewards/src/instruction.rs Co-authored-by: Stanislav Cherviakov <[email protected]> * minor fix after merge commit --------- Co-authored-by: Stanislav Cherviakov <[email protected]> --------- Co-authored-by: Matiukhin Vlad <[email protected]> Co-authored-by: Stanislav Cherviakov <[email protected]>
…nto refactor-and-bugfixing
No description provided.