Skip to content

Commit

Permalink
Add ProtocolConfig.os_token_vaults field (#126)
Browse files Browse the repository at this point in the history
* Add ProtocolConfig.os_token_vaults field

* Bump version v0.6.30

* Review fix

Co-authored-by: Dmitri Tsumak <[email protected]>
Signed-off-by: evgeny-stakewise <[email protected]>

* Fix linter

---------

Signed-off-by: evgeny-stakewise <[email protected]>
Co-authored-by: Dmitri Tsumak <[email protected]>
  • Loading branch information
evgeny-stakewise and tsudmi authored Nov 8, 2024
1 parent c5c7112 commit 4c9dc35
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "sw-utils"
version = "v0.6.29"
version = "v0.6.30"
description = "StakeWise Python utils"
authors = ["StakeWise Labs <[email protected]>"]
license = "GPL-3.0-or-later"
Expand Down
3 changes: 3 additions & 0 deletions sw_utils/protocol_config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from web3 import Web3
from web3.types import Wei

from sw_utils.typings import Oracle, ProtocolConfig
Expand Down Expand Up @@ -31,6 +32,7 @@ def build_protocol_config(
raise ValueError('Invalid exit signature threshold')

vault_exiting_validators_limit_bps = config_data.get('vault_exiting_validators_limit_bps') or 0
os_token_vaults = [Web3.to_checksum_address(v) for v in config_data.get('os_token_vaults', [])]

return ProtocolConfig(
oracles=oracles,
Expand All @@ -48,4 +50,5 @@ def build_protocol_config(
signature_validity_period=config_data['signature_validity_period'],
until_force_exit_epochs=config_data['until_force_exit_epochs'],
vault_exiting_validators_limit_bps=vault_exiting_validators_limit_bps,
os_token_vaults=os_token_vaults,
)
6 changes: 5 additions & 1 deletion sw_utils/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def wei_amount(self, start: int = 10, stop: int = 1000) -> Wei:
faker.add_provider(Web3Provider)


# pylint: disable=too-many-arguments
# pylint: disable=too-many-arguments,too-many-locals
def get_mocked_protocol_config(
oracles: list[Oracle] | None = None,
oracles_count: int = 1,
Expand All @@ -64,6 +64,8 @@ def get_mocked_protocol_config(
inactive_validator_balance: Wei = Web3.to_wei(31.75, 'ether'),
validator_min_active_epochs: int = 2250, # 10 days
vault_fee_max_bps: int = 1500, # 15%
vault_exiting_validators_limit_bps: int = 0,
os_token_vaults: list[str] | None = None,
) -> ProtocolConfig:
return ProtocolConfig(
oracles=oracles
Expand All @@ -89,4 +91,6 @@ def get_mocked_protocol_config(
until_force_exit_epochs=until_force_exit_epochs,
rewards_threshold=rewards_threshold,
validators_threshold=validators_threshold,
vault_exiting_validators_limit_bps=vault_exiting_validators_limit_bps,
os_token_vaults=os_token_vaults or [],
)
9 changes: 6 additions & 3 deletions sw_utils/typings.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,12 @@ class ProtocolConfig:

exit_signature_recover_threshold: int

# max exiting validators bps for genesis vault
# zero value means limit is not set
vault_exiting_validators_limit_bps: int = 0
# Max exiting validators bps for genesis vault.
# Zero value means limit is not set.
vault_exiting_validators_limit_bps: int

# List of vaults used to determine osToken reward rate
os_token_vaults: list[ChecksumAddress]

# Keeper settings
validators_threshold: int = 0
Expand Down

0 comments on commit 4c9dc35

Please sign in to comment.