Skip to content
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

Merged
merged 24 commits into from
Jul 22, 2024

Conversation

StanChe
Copy link
Collaborator

@StanChe StanChe commented Jul 8, 2024

No description provided.

@@ -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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really

Copy link
Collaborator

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 {
Copy link
Collaborator Author

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment on lines 57 to 62
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;
Copy link
Collaborator Author

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

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

programs/rewards/src/instructions/fill_vault.rs Outdated Show resolved Hide resolved
@kstepanovdev kstepanovdev self-assigned this Jul 12, 2024
kstepanovdev and others added 6 commits July 12, 2024 23:04
Unify Contexts and verification checks
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]>
@kstepanovdev kstepanovdev marked this pull request as ready for review July 22, 2024 09:24
@kstepanovdev kstepanovdev merged commit a8b9553 into devnet-version Jul 22, 2024
3 checks passed
@kstepanovdev kstepanovdev deleted the refactor-and-bugfixing branch July 22, 2024 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants