@@ -5,13 +5,12 @@ WITH LatestDrepDistr AS (
55 FROM
66 drep_distr
77),
8- EpochUtils AS (
8+ LatestEpoch AS (
99 SELECT
10- (Max (end_time) - Min (end_time)) / (Max (NO) - Min (NO)) AS epoch_duration,
11- Max (NO) AS last_epoch_no,
12- Max (end_time) AS last_epoch_end_time
10+ start_time,
11+ no
1312 FROM
14- epoch
13+ epoch ORDER BY no DESC LIMIT 1
1514),
1615always_no_confidence_voting_power AS (
1716 SELECT
@@ -56,13 +55,9 @@ SELECT
5655 ) as description,
5756 CASE
5857 WHEN meta .network_name ::text = ' mainnet' THEN
59- epoch_utils .last_epoch_end_time +
60- epoch_utils .epoch_duration * (gov_action_proposal .expiration - epoch_utils .last_epoch_no )::bigint +
61- INTERVAL ' 5 days'
58+ latest_epoch .start_time + (gov_action_proposal .expiration - latest_epoch .no )::bigint * INTERVAL ' 5 days' + INTERVAL ' 5 days'
6259 ELSE
63- epoch_utils .last_epoch_end_time +
64- epoch_utils .epoch_duration * (gov_action_proposal .expiration - epoch_utils .last_epoch_no )::bigint +
65- INTERVAL ' 1 day'
60+ latest_epoch .start_time + (gov_action_proposal .expiration - latest_epoch .no )::bigint * INTERVAL ' 1 day' + INTERVAL ' 1 day'
6661 END AS expiry_date,
6762 gov_action_proposal .expiration ,
6863 creator_block .time ,
10196 on gov_action_proposal .id = treasury_withdrawal .gov_action_proposal_id
10297 LEFT JOIN stake_address
10398 on stake_address .id = treasury_withdrawal .stake_address_id
104- CROSS JOIN EpochUtils AS epoch_utils
99+ CROSS JOIN LatestEpoch AS latest_epoch
105100 CROSS JOIN always_no_confidence_voting_power
106101 CROSS JOIN always_abstain_voting_power
107102 CROSS JOIN meta
@@ -162,9 +157,8 @@ GROUP BY
162157 gov_action_proposal .index ,
163158 creator_tx .hash ,
164159 creator_block .time ,
165- epoch_utils .epoch_duration ,
166- epoch_utils .last_epoch_no ,
167- epoch_utils .last_epoch_end_time ,
160+ latest_epoch .start_time ,
161+ latest_epoch .no ,
168162 proposal_params,
169163 voting_anchor .url ,
170164 voting_anchor .data_hash ,
0 commit comments