Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 399
fix(explorer): count only active operators for weight#934
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
Merged
uri-99
merged 13 commits into
staging
from
933-fixexplorer-inactive-operators-should-not-count-their-stakeSep 16, 2024
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
2518a4f
fix: count only active operators for weight
uri-99 2818803
fix: operator.total_stake update on each restake update
uri-99 9e87ebb
fix: remove debugs
glpecile e8fd969
fix: set total_stake = 0 when unregister operator
uri-99 79c3b23
fix(wip): parsing strategies that don't have name or symbol
uri-99 e4f362d
Fix: handling of strategies with no name
uri-99 e4a70a0
fix: operator unregistration stake
uri-99 e6307e1
feat: discount restakings of removed operators
uri-99 ac568d3
fix: handling of no name erc20
uri-99 8debe9a
revert: run restakings every hour periodically
uri-99 f980e44
fix: if lt 0 check when discounting from strategy
uri-99 4701973
Merge branch 'staging' into 933-fixexplorer-inactive-operators-should…
uri-99 b60e227
Add missing dependencies to explorer
MauroToscano File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -151,7 +151,7 @@ operator_register_with_eigen_layer: | ||
| operator_mint_mock_tokens: | ||
| @echo "Minting tokens" | ||
| . ./scripts/mint_mock_token.sh $(CONFIG_FILE) 1000 | ||
| . ./scripts/mint_mock_token.sh $(CONFIG_FILE) 100000000000000000 | ||
| operator_whitelist_devnet: | ||
| @echo "Whitelisting operator" | ||
| @@ -170,7 +170,7 @@ operator_deposit_into_mock_strategy: | ||
| @go run operator/cmd/main.go deposit-into-strategy \ | ||
| --config $(CONFIG_FILE) \ | ||
| --strategy-address $(STRATEGY_ADDRESS) \ | ||
| --amount 1000 | ||
| --amount 100000000000000000 | ||
uri-99 marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| operator_deposit_into_strategy: | ||
| @echo "Depositing into strategy" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 12 additions & 4 deletions
16 explorer/lib/explorer/contract_managers/strategy_interface_manager.ex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -29,6 +29,7 @@ defmodule Restakings do | ||
| Operators.get_operators() | ||
| |> Enum.map(fn operator -> StakeRegistryManager.has_operator_changed_staking(%{fromBlock: from_block, operator_id: operator.id, operator_address: operator.address}) end) | ||
| |> Enum.reject(fn {_operator_id, _operator_address, has_changed_stake} -> not has_changed_stake end) | ||
| |> Enum.reject(fn {operator_id, _operator_address, _has_changed_stake} -> not Operators.get_operator_by_id(operator_id).is_active end) | ||
uri-99 marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| |> Enum.map(fn {operator_id, operator_address, _has_changed_stake} -> DelegationManager.get_operator_all_strategies_shares(%Operators{id: operator_id, address: operator_address}) end) | ||
| |> Enum.each(&insert_or_update_restakings/1) | ||
| end | ||
| @@ -54,6 +55,9 @@ defmodule Restakings do | ||
| |> Ecto.Multi.update(:update_strategy_total_staked, Strategies.generate_update_total_staked_changeset(%{new_restaking: restaking})) | ||
| end | ||
| multi = multi | ||
| |> Ecto.Multi.update(:update_operator_total_stake, Operators.generate_new_total_stake_changeset(%{operator_address: restaking.operator_address})) | ||
| case Explorer.Repo.transaction(multi) do | ||
| {:ok, _} -> | ||
| "Restaking inserted or updated" |> Logger.debug() | ||
| @@ -64,7 +68,16 @@ defmodule Restakings do | ||
| end | ||
| end | ||
| def get_by_operator_and_strategy(%Restakings{operator_address: operator_address, strategy_address: strategy_address}) do | ||
| def remove_restakes_of_operator(%{operator_address: operator_address}) do | ||
| Logger.debug("Removing restakes of operator") | ||
| query = from(r in Restakings, where: r.operator_address == ^operator_address) | ||
| restakings = Explorer.Repo.all(query) | ||
| Explorer.Repo.delete_all(query) | ||
| Enum.each(restakings, &Strategies.discount_restaking/1) | ||
| end | ||
| def get_by_operator_and_strategy(%Restakings{operator_address: operator_address, strategy_address: strategy_address}) do | ||
| query = from( | ||
| r in Restakings, | ||
| where: r.operator_address == ^operator_address and r.strategy_address == ^strategy_address, | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.