diff --git a/apps/block_scout_web/lib/block_scout_web/chain.ex b/apps/block_scout_web/lib/block_scout_web/chain.ex
index a890e98a3d..bac1e66b3c 100644
--- a/apps/block_scout_web/lib/block_scout_web/chain.ex
+++ b/apps/block_scout_web/lib/block_scout_web/chain.ex
@@ -283,7 +283,7 @@ defmodule BlockScoutWeb.Chain do
%{"block_number" => block_number}
end
- defp paging_params(%StakingPool{staking_address_hash: address_hash, staked_ratio: value}) do
+ defp paging_params(%StakingPool{staking_address_hash: address_hash, stakes_ratio: value}) do
%{"address_hash" => address_hash, "value" => Decimal.to_string(value)}
end
diff --git a/apps/block_scout_web/lib/block_scout_web/channels/stakes_channel.ex b/apps/block_scout_web/lib/block_scout_web/channels/stakes_channel.ex
index ef306b50c4..6857470b14 100644
--- a/apps/block_scout_web/lib/block_scout_web/channels/stakes_channel.ex
+++ b/apps/block_scout_web/lib/block_scout_web/channels/stakes_channel.ex
@@ -41,7 +41,7 @@ defmodule BlockScoutWeb.StakesChannel do
token = ContractState.get(:token)
html =
- View.render_to_string(StakesView, "_stakes_modal_validator_info.html",
+ View.render_to_string(StakesView, "_stakes_modal_pool_info.html",
validator: pool,
delegator: delegator,
average_block_time: average_block_time,
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/stakes/_rows.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/stakes/_rows.html.eex
index 25f7f6ac66..8ac2afb7c7 100644
--- a/apps/block_scout_web/lib/block_scout_web/templates/stakes/_rows.html.eex
+++ b/apps/block_scout_web/lib/block_scout_web/templates/stakes/_rows.html.eex
@@ -23,7 +23,7 @@
<%= if @pools_type == :inactive do %>
<%= if @pool.is_banned, do: gettext("Yes"), else: gettext("No") %>
<% else %>
- <%= if @pool.staked_ratio, do: "#{@pool.staked_ratio}%" %>
+ <%= if @pool.stakes_ratio, do: "#{@pool.stakes_ratio}%" %>
<% end %>
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/stakes/_stakes_modal_validator_info.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/stakes/_stakes_modal_pool_info.html.eex
similarity index 96%
rename from apps/block_scout_web/lib/block_scout_web/templates/stakes/_stakes_modal_validator_info.html.eex
rename to apps/block_scout_web/lib/block_scout_web/templates/stakes/_stakes_modal_pool_info.html.eex
index 02a0123554..bf011701d5 100644
--- a/apps/block_scout_web/lib/block_scout_web/templates/stakes/_stakes_modal_validator_info.html.eex
+++ b/apps/block_scout_web/lib/block_scout_web/templates/stakes/_stakes_modal_pool_info.html.eex
@@ -41,12 +41,12 @@
render BlockScoutWeb.StakesView,
"_stakes_validator_info_item.html",
title: gettext("Stakes Ratio"),
- value: if(@validator.staked_ratio, do: "#{@validator.staked_ratio}%")
+ value: if(@validator.stakes_ratio, do: "#{@validator.stakes_ratio}%")
%>
<%=
render BlockScoutWeb.StakesView,
"_stakes_validator_info_item.html",
- title: gettext("Reward Percent"),
+ title: gettext("Share of Pool’s Reward"),
value: "#{@validator.block_reward_ratio}%"
%>
<%=
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/stakes/_stakes_progress.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/stakes/_stakes_progress.html.eex
index 4c64f0239b..e4a48a7d6c 100644
--- a/apps/block_scout_web/lib/block_scout_web/templates/stakes/_stakes_progress.html.eex
+++ b/apps/block_scout_web/lib/block_scout_web/templates/stakes/_stakes_progress.html.eex
@@ -24,7 +24,7 @@
<%= gettext("Stakes Ratio") %>
- <%= @pool.staked_ratio %>%
+ <%= @pool.stakes_ratio %>%
diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex
index 203535dc28..c4fc454fba 100644
--- a/apps/explorer/lib/explorer/chain.ex
+++ b/apps/explorer/lib/explorer/chain.ex
@@ -4781,15 +4781,15 @@ defmodule Explorer.Chain do
paging_query =
base_query
|> limit(^paging_options.page_size)
- |> order_by(desc: :staked_ratio, asc: :staking_address_hash)
+ |> order_by(desc: :stakes_ratio, asc: :staking_address_hash)
case paging_options.key do
{value, address_hash} ->
where(
paging_query,
[p],
- p.staked_ratio < ^value or
- (p.staked_ratio == ^value and p.staking_address_hash > ^address_hash)
+ p.stakes_ratio < ^value or
+ (p.stakes_ratio == ^value and p.staking_address_hash > ^address_hash)
)
_ ->
diff --git a/apps/explorer/lib/explorer/chain/import/runner/staking_pools.ex b/apps/explorer/lib/explorer/chain/import/runner/staking_pools.ex
index d7a3b7c46b..bdc51d9e82 100644
--- a/apps/explorer/lib/explorer/chain/import/runner/staking_pools.ex
+++ b/apps/explorer/lib/explorer/chain/import/runner/staking_pools.ex
@@ -131,7 +131,7 @@ defmodule Explorer.Chain.Import.Runner.StakingPools do
are_delegators_banned: fragment("EXCLUDED.are_delegators_banned"),
likelihood: fragment("EXCLUDED.likelihood"),
block_reward_ratio: fragment("EXCLUDED.block_reward_ratio"),
- staked_ratio: fragment("EXCLUDED.staked_ratio"),
+ stakes_ratio: fragment("EXCLUDED.stakes_ratio"),
validator_reward_ratio: fragment("EXCLUDED.validator_reward_ratio"),
snapshotted_validator_reward_ratio: pool.snapshotted_validator_reward_ratio,
self_staked_amount: fragment("EXCLUDED.self_staked_amount"),
diff --git a/apps/explorer/lib/explorer/chain/staking_pool.ex b/apps/explorer/lib/explorer/chain/staking_pool.ex
index 7b51c07bce..189715a5ab 100644
--- a/apps/explorer/lib/explorer/chain/staking_pool.ex
+++ b/apps/explorer/lib/explorer/chain/staking_pool.ex
@@ -25,7 +25,7 @@ defmodule Explorer.Chain.StakingPool do
are_delegators_banned: boolean,
likelihood: Decimal.t(),
block_reward_ratio: Decimal.t(),
- staked_ratio: Decimal.t(),
+ stakes_ratio: Decimal.t(),
validator_reward_ratio: Decimal.t(),
snapshotted_validator_reward_ratio: Decimal.t(),
self_staked_amount: Decimal.t(),
@@ -41,7 +41,7 @@ defmodule Explorer.Chain.StakingPool do
@attrs ~w(
is_active delegators_count total_staked_amount self_staked_amount snapshotted_total_staked_amount snapshotted_self_staked_amount is_validator
was_validator_count is_banned are_delegators_banned ban_reason was_banned_count banned_until banned_delegators_until likelihood
- staked_ratio validator_reward_ratio snapshotted_validator_reward_ratio staking_address_hash mining_address_hash block_reward_ratio
+ stakes_ratio validator_reward_ratio snapshotted_validator_reward_ratio staking_address_hash mining_address_hash block_reward_ratio
is_unremovable
)a
@req_attrs ~w(
@@ -61,7 +61,7 @@ defmodule Explorer.Chain.StakingPool do
field(:are_delegators_banned, :boolean, default: false)
field(:likelihood, :decimal)
field(:block_reward_ratio, :decimal)
- field(:staked_ratio, :decimal)
+ field(:stakes_ratio, :decimal)
field(:validator_reward_ratio, :decimal)
field(:snapshotted_validator_reward_ratio, :decimal)
field(:self_staked_amount, :decimal)
diff --git a/apps/explorer/lib/explorer/staking/contract_reader.ex b/apps/explorer/lib/explorer/staking/contract_reader.ex
index 9b62f394d4..d2e70fc2cb 100644
--- a/apps/explorer/lib/explorer/staking/contract_reader.ex
+++ b/apps/explorer/lib/explorer/staking/contract_reader.ex
@@ -16,7 +16,7 @@ defmodule Explorer.Staking.ContractReader do
staking_allowed: {:staking, "areStakeAndWithdrawAllowed", []},
active_pools: {:staking, "getPools", []},
inactive_pools: {:staking, "getPoolsInactive", []},
- pools_likely: {:staking, "getPoolsToBeElected", []},
+ pools_to_be_elected: {:staking, "getPoolsToBeElected", []},
pools_likelihood: {:staking, "getPoolsLikelihood", []},
validators: {:validator_set, "getValidators", []},
unremovable_validator: {:validator_set, "unremovableValidator", []},
@@ -50,13 +50,13 @@ defmodule Explorer.Staking.ContractReader do
]
end
- def delegator_requests(pool_address, delegator_address) do
+ def delegator_requests(pool_staking_address, delegator_address) do
[
- stake_amount: {:staking, "stakeAmount", [pool_address, delegator_address]},
- ordered_withdraw: {:staking, "orderedWithdrawAmount", [pool_address, delegator_address]},
- max_withdraw_allowed: {:staking, "maxWithdrawAllowed", [pool_address, delegator_address]},
- max_ordered_withdraw_allowed: {:staking, "maxWithdrawOrderAllowed", [pool_address, delegator_address]},
- ordered_withdraw_epoch: {:staking, "orderWithdrawEpoch", [pool_address, delegator_address]}
+ stake_amount: {:staking, "stakeAmount", [pool_staking_address, delegator_address]},
+ ordered_withdraw: {:staking, "orderedWithdrawAmount", [pool_staking_address, delegator_address]},
+ max_withdraw_allowed: {:staking, "maxWithdrawAllowed", [pool_staking_address, delegator_address]},
+ max_ordered_withdraw_allowed: {:staking, "maxWithdrawOrderAllowed", [pool_staking_address, delegator_address]},
+ ordered_withdraw_epoch: {:staking, "orderWithdrawEpoch", [pool_staking_address, delegator_address]}
]
end
diff --git a/apps/explorer/lib/explorer/staking/contract_state.ex b/apps/explorer/lib/explorer/staking/contract_state.ex
index 16e47f3de4..31f1315ced 100644
--- a/apps/explorer/lib/explorer/staking/contract_state.ex
+++ b/apps/explorer/lib/explorer/staking/contract_state.ex
@@ -173,7 +173,7 @@ defmodule Explorer.Staking.ContractState do
[likelihood_values, total_likelihood] = global_responses.pools_likelihood
likelihood =
- global_responses.pools_likely
+ global_responses.pools_to_be_elected # array of pool addresses (staking addresses)
|> Enum.zip(likelihood_values)
|> Enum.into(%{})
@@ -217,7 +217,7 @@ defmodule Explorer.Staking.ContractState do
%{
staking_address_hash: staking_address,
delegators_count: length(staking_response.active_delegators),
- staked_ratio:
+ stakes_ratio:
if staking_response.is_active do
ratio(staking_response.total_staked_amount, staked_total)
end,
diff --git a/apps/explorer/lib/explorer/staking/stake_snapshotting.ex b/apps/explorer/lib/explorer/staking/stake_snapshotting.ex
index ca479a9b2e..63557c5363 100644
--- a/apps/explorer/lib/explorer/staking/stake_snapshotting.ex
+++ b/apps/explorer/lib/explorer/staking/stake_snapshotting.ex
@@ -26,7 +26,7 @@ defmodule Explorer.Staking.StakeSnapshotting do
pool_staking_addresses =
pool_mining_addresses
- |> Enum.map(&transform_requests/1)
+ |> Enum.map(&staking_by_mining_requests/1)
|> ContractReader.perform_grouped_requests(pool_mining_addresses, contracts, abi)
|> Enum.flat_map(fn {_, value} -> value end)
|> Enum.map(fn {_key, staking_address_hash} -> decode_data(staking_address_hash) end)
@@ -134,9 +134,9 @@ defmodule Explorer.Staking.StakeSnapshotting do
})
end
- def transform_requests(minig_address) do
+ def staking_by_mining_requests(mining_address) do
[
- staking_address: {:validator_set, "stakingByMiningAddress", [minig_address]}
+ staking_address: {:validator_set, "stakingByMiningAddress", [mining_address]}
]
end
@@ -152,14 +152,14 @@ defmodule Explorer.Staking.StakeSnapshotting do
]
end
- defp delegator_requests(pool_address, delegator_address, block_number) do
+ defp delegator_requests(pool_staking_address, delegator_address, block_number) do
[
- stake_amount: {:staking, "stakeAmount", [pool_address, delegator_address]},
- snapshotted_stake_amount: {:staking, "stakeAmount", [pool_address, delegator_address], block_number - 1},
- ordered_withdraw: {:staking, "orderedWithdrawAmount", [pool_address, delegator_address]},
- max_withdraw_allowed: {:staking, "maxWithdrawAllowed", [pool_address, delegator_address]},
- max_ordered_withdraw_allowed: {:staking, "maxWithdrawOrderAllowed", [pool_address, delegator_address]},
- ordered_withdraw_epoch: {:staking, "orderWithdrawEpoch", [pool_address, delegator_address]}
+ stake_amount: {:staking, "stakeAmount", [pool_staking_address, delegator_address]},
+ snapshotted_stake_amount: {:staking, "stakeAmount", [pool_staking_address, delegator_address], block_number - 1},
+ ordered_withdraw: {:staking, "orderedWithdrawAmount", [pool_staking_address, delegator_address]},
+ max_withdraw_allowed: {:staking, "maxWithdrawAllowed", [pool_staking_address, delegator_address]},
+ max_ordered_withdraw_allowed: {:staking, "maxWithdrawOrderAllowed", [pool_staking_address, delegator_address]},
+ ordered_withdraw_epoch: {:staking, "orderWithdrawEpoch", [pool_staking_address, delegator_address]}
]
end
@@ -182,7 +182,7 @@ defmodule Explorer.Staking.StakeSnapshotting do
are_delegators_banned: pool.are_delegators_banned,
likelihood: pool.likelihood,
block_reward_ratio: pool.block_reward_ratio,
- staked_ratio: pool.staked_ratio,
+ stakes_ratio: pool.stakes_ratio,
validator_reward_ratio: pool.validator_reward_ratio,
ban_reason: pool.ban_reason,
was_banned_count: pool.was_banned_count,
diff --git a/apps/explorer/priv/repo/migrations/20190521104412_create_staking_pools.exs b/apps/explorer/priv/repo/migrations/20190521104412_create_staking_pools.exs
index 7011fd962c..ce78745053 100644
--- a/apps/explorer/priv/repo/migrations/20190521104412_create_staking_pools.exs
+++ b/apps/explorer/priv/repo/migrations/20190521104412_create_staking_pools.exs
@@ -14,7 +14,7 @@ defmodule Explorer.Repo.Migrations.CreateStakingPools do
add(:was_banned_count, :integer)
add(:banned_until, :bigint)
add(:likelihood, :decimal, precision: 5, scale: 2)
- add(:staked_ratio, :decimal, precision: 5, scale: 2)
+ add(:stakes_ratio, :decimal, precision: 5, scale: 2)
add(:staking_address_hash, :bytea)
add(:mining_address_hash, :bytea)