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

Dual staking #44

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open

Dual staking #44

wants to merge 28 commits into from

Conversation

jmoreira-valory
Copy link
Collaborator

@jmoreira-valory jmoreira-valory commented Mar 5, 2025

Proposed changes

  • Added dual staking support.
  • Improved logic for refill requirement.
  • ContractLogicError had to be replaced by a general Exception, because depending on the RPC provider it might raise other exception type.

Types of changes

What types of changes does your code introduce?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

staking_token_requirements = self._compute_staking_token_requirements(
service_config_id, chain, staking_params
)
staking_token_requirements[staking_params["staking_token"]] = (
Copy link
Member

Choose a reason for hiding this comment

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

it looks like we can avoid overwriting these requirement by just reading the on_chain_state also in the compute function, and having this logic there

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes and no.

The output of this method is the service asset requirements (native, tokens, dual tokens, etc) required to deploy a service from scratch.

On another method, we retrieve the bonded assets.

So, the requirements needed will be service_asset_requirements - bonded_assets

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I opted for this way to have separation between what's bonded and what's on the Safe. We can discuss.

Copy link
Collaborator Author

@jmoreira-valory jmoreira-valory Mar 10, 2025

Choose a reason for hiding this comment

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

In other words, the following invariant must always be satisfied (*):

master_safe_balance + bonded_assets >= protocol_asset_requirements

=

master_safe_balance >= protocol_asset_requirements - bonded_assets

(*) Obviously, the value bonded_assets and master_safe_balance depend on the protocol state, but we have a methodology to compute these values.

@jmoreira-valory jmoreira-valory changed the title [WIP] Dual staking Dual staking Mar 11, 2025
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.

2 participants