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

[mtg-296] delegated staking extend staking with delegate parameter #13

Conversation

kstepanovdev
Copy link
Collaborator

No description provided.

@kstepanovdev kstepanovdev requested a review from StanChe July 12, 2024 11:52
@kstepanovdev kstepanovdev self-assigned this Jul 12, 2024
@kstepanovdev kstepanovdev changed the base branch from master to refactor-and-bugfixing July 12, 2024 11:52
@kstepanovdev kstepanovdev force-pushed the mtg-296-delegated-staking-extend-staking-with-delegate-parameter branch from a260659 to 53211ef Compare July 16, 2024 14:57
@kstepanovdev kstepanovdev requested a review from StanChe July 16, 2024 20:09
@kstepanovdev kstepanovdev requested a review from rwwwx July 16, 2024 20:09
Copy link
Contributor

@StanChe StanChe left a comment

Choose a reason for hiding this comment

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

Logic-wise looks great, some comments on optimization of code and execution.

program-states/src/state/deposit_entry.rs Outdated Show resolved Hide resolved
programs/voter-stake-registry/src/cpi_instructions.rs Outdated Show resolved Hide resolved
kstepanovdev and others added 4 commits July 18, 2024 13:48
Co-authored-by: Stanislav Cherviakov <stchervyakov@gmail.com>
Co-authored-by: Stanislav Cherviakov <stchervyakov@gmail.com>
…parameter' of github.com:adm-metaex/mplx-staking into mtg-296-delegated-staking-extend-staking-with-delegate-parameter
@@ -207,3 +219,37 @@ pub struct Stake<'info> {
#[account(executable)]
pub rewards_program: UncheckedAccount<'info>,
}

impl Stake<'_> {
pub fn verify_delegate_and_its_mining(
Copy link
Contributor

Choose a reason for hiding this comment

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

Great, thanks. A question - why not implementing the check over the instance of &self? This way the call will be simplified to ctx.accounts.verify_delegate_and_its_mining(deposit_entry)?;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because I'm dumb. Good catch! Fixed.

kstepanovdev and others added 2 commits July 19, 2024 14:30
* added change delegate function

* Fixes after rebase

* fix aligment

* Update program-states/src/state/deposit_entry.rs

Co-authored-by: Stanislav Cherviakov <stchervyakov@gmail.com>

---------

Co-authored-by: Stanislav Cherviakov <stchervyakov@gmail.com>
@kstepanovdev kstepanovdev merged commit b7b51e6 into refactor-and-bugfixing Jul 19, 2024
0 of 4 checks passed
@kstepanovdev kstepanovdev deleted the mtg-296-delegated-staking-extend-staking-with-delegate-parameter branch July 19, 2024 11:41
kstepanovdev added a commit that referenced this pull request Jul 22, 2024
* feat: add multiplier (#15)

* [MTG-234] calculate weighted stake

* cleaning up voting mint

* rename RestakeDeposit to ExtendStake

* rename LockTokens to Stake

* From now, funds will be withdrew from the Mining account on unlock operation instead of withdraw

* stop passing redundant parameters for unlock tokens

* minor fixes

* remove passing redundant parameters from Stake function

* add closing mining account on close voter ix

* update rustfmt

* hotfix

* Initialize rewards-pool deposit authority signature

* fixed comments and fmt

* unify stake and extend_stakes operations

* update tests

* small fixes logic in extend_stake

* fix tests

* extend_stake substraction hotfix

* hotfix for exnted_stake and lockup period

* fixed `weighted_stake` function, added tests (#12)

fixed weighted_stake function, added tests

* Update governance (#11)

* update spl_governance to 3.1.1

* update governance

* refactor dependencies

* add CPI functions && add extend deposit function

* add CPI invocations (except for withdraw)

* add CPI invocation for the withdraw function

* cleanup

* extend CPI enum && provide source with program ids

* add initial invocations of rewards contract && add basic methods for interaction with rewards

* add create_mint function for test utils

* add RewardsCookies and extend context of Addin Context

* refactor tests && enable CPI calls in test for all functions && change mutability of input parameters for functions that are related to CPI invocatioins

* CPI invocations for instructions

* restring votingMintConfig with the only one value

* update integration tests accordingly to the newest changes in processor

* add new time warp util && make test_all_deposits green

* add more money for the current deposit is forbidden now

* no CPI is needed when LockupKind and LockupType are None

* add new error

* fix integration tests

* add claim fucntion

* update claim function && small refactor

* update tests to verify whether claim CPI is working

* Update CPI invocations accordingly to the latest rewards API

* Change CPI call interfaces
&& binary fixture
&& integration tests accordingly to the devnet version requirements

* update program id

* add check for vault field

* read returned data from cpi

* update contract's id

* update program's idl

* add initialize_pool cpi invocation on each registrar creation

* update tests accordingly to adding initialize_pool function via cpi

* update IDL

* add more comment about passed into ixs accounts

* update idl

* update idl

* update idl

* fix for updating idl

* update fixture for testing

* remove mentions about fill_authority

* Clarify comments regarding PDA calculations for the Rewards contract

* remove redundant dependencies

* update restake function accordingly to the changes in the rewards

* add tests for the restake function

* Fix bug with restake && add tests for restake

* Add test option to the contract

* merge packages back in order to produce correct idls

* update ts types

* experimental commit with freshly redifined deposit && lock_tokens functions

* make tests green

* update fixture

* update idl

* separate states && contract itself

* fix: delegate adding on deposit entry creation

* fix: now it's possible to deposit to DepositEntry that has some tokens already

* Remove redundat accounts && change get_unix_time function

* minor fix: remove registrar parsing from unlock_tokens()

* update contract accordingly to the latest on rewards program

* refactor: drop unused errors

* feat: update IDL

* rust fmt file with the reformatting

* updated imports granularity to module

* cleaning up voting mint

* rename RestakeDeposit to ExtendStake

* rename LockTokens to Stake

* From now, funds will be withdrew from the Mining account on unlock operation instead of withdraw

* stop passing redundant parameters for unlock tokens

* minor fixes

* remove passing redundant parameters from Stake function

* add closing mining account on close voter ix

* update rustfmt

* hotfix

* Initialize rewards-pool deposit authority signature

* fixed comments and fmt

* unify stake and extend_stakes operations

* update tests

* small fixes logic in extend_stake

* fix tests

* extend_stake substraction hotfix

* hotfix for exnted_stake and lockup period

* Update governance (#11)

* update spl_governance to 3.1.1

* update governance

* refactor dependencies

* mtg-425: Error handling improvements  (#14)

improved error handling

* [mtg-296] delegated staking extend staking with delegate parameter (#13)

* initial delegate

* add delegate initial design

* update tests

* update tests && fixtures

* initial delegate

* add delegate initial design

* update fixtures

* remove redundant reprs

* store deposit mining on each creation of deposit entry && add additional validations for stake and extend methods

* update tests

* remove redundant file

* mtg-425: Error handling improvements  (#14)

improved error handling

* initial delegate

* add delegate initial design

* update tests

* update tests && fixtures

* initial delegate

* add delegate initial design

* update fixtures

* remove redundant reprs

* store deposit mining on each creation of deposit entry && add additional validations for stake and extend methods

* update tests

* remove redundant file

* add delegate as a dedicated wallet instead of delegate_mining

* Update program-states/src/state/deposit_entry.rs

Co-authored-by: Stanislav Cherviakov <stchervyakov@gmail.com>

* Update programs/voter-stake-registry/src/cpi_instructions.rs

Co-authored-by: Stanislav Cherviakov <stchervyakov@gmail.com>

* unify mining verification

* simplify mining verification

* [mtg-308] (#15)

* added change delegate function

* Fixes after rebase

* fix aligment

* Update program-states/src/state/deposit_entry.rs

Co-authored-by: Stanislav Cherviakov <stchervyakov@gmail.com>

---------

Co-authored-by: Stanislav Cherviakov <stchervyakov@gmail.com>

---------

Co-authored-by: Matiukhin Vlad <87382371+rwwwx@users.noreply.github.com>
Co-authored-by: Stanislav Cherviakov <stchervyakov@gmail.com>

---------

Co-authored-by: Vadim <31490938+n00m4d@users.noreply.github.com>
Co-authored-by: Stanislav Cherviakov <stchervyakov@gmail.com>
Co-authored-by: rwwwx <vlad.matiukhin@gmail.com>
Co-authored-by: Matiukhin Vlad <87382371+rwwwx@users.noreply.github.com>
Co-authored-by: Kyryo Stepanov <mutexnova@kerneldemon.local>
Co-authored-by: Vadim <grozinok@gmail.com>
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