@@ -57,25 +57,34 @@ defmodule Operators do
5757 end
5858
5959 def get_operators_with_their_weights ( ) do
60- total_stake = Explorer.Repo . one (
61- from (
62- o in Operators ,
63- where: o . is_active == true ,
64- select: sum ( o . total_stake ) )
65- )
66-
67- get_operators ( ) |>
68- Enum . map (
69- fn operator ->
70- case operator . is_active do
71- false ->
72- Map . from_struct ( operator ) |> Map . put ( :weight , 0 )
73- true ->
74- weight = Decimal . div ( operator . total_stake , total_stake )
75- Map . from_struct ( operator ) |> Map . put ( :weight , weight )
76- end
77- end
60+ total_stake =
61+ Explorer.Repo . one (
62+ from (
63+ o in Operators ,
64+ where: o . is_active == true ,
65+ select: sum ( o . total_stake )
66+ )
7867 )
68+
69+ get_operators ( )
70+ |> Enum . map ( fn operator ->
71+ case operator . is_active do
72+ false ->
73+ Map . from_struct ( operator ) |> Map . put ( :weight , 0 )
74+
75+ true ->
76+ weight = Decimal . div ( operator . total_stake , total_stake )
77+ total_stake_eth = operator . total_stake |> EthConverter . wei_to_eth ( 2 )
78+
79+ { _ , total_stake_usd } =
80+ operator . total_stake |> EthConverter . wei_to_usd ( 0 )
81+
82+ Map . from_struct ( operator )
83+ |> Map . put ( :total_stake_eth , total_stake_eth )
84+ |> Map . put ( :total_stake_usd , total_stake_usd )
85+ |> Map . put ( :weight , weight )
86+ end
87+ end )
7988 end
8089
8190 def get_amount_of_operators do
0 commit comments