From dbd8a6de1696843cd8fc98dd736ae28c83b2948b Mon Sep 17 00:00:00 2001 From: 0xrajath Date: Mon, 2 Dec 2024 11:18:56 -0500 Subject: [PATCH] arno hardfork --- internal/config/config.go | 7 ++++++- pkg/rewards/2_goldStakerRewardAmounts.go | 6 ++++++ pkg/rewards/5_goldRfaeStakers.go | 16 ++++++++++++++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index a251c949..f9efde0b 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -3,9 +3,10 @@ package config import ( "errors" "fmt" - "github.com/spf13/viper" "strconv" "strings" + + "github.com/spf13/viper" ) type EnvScope string @@ -29,6 +30,7 @@ const ( Fork_Nile ForkName = "nile" Fork_Amazon ForkName = "amazon" Fork_Panama ForkName = "panama" + Fork_Arno ForkName = "arno" ENV_PREFIX = "SIDECAR" ) @@ -252,18 +254,21 @@ func (c *Config) GetForkDates() (ForkMap, error) { Fork_Amazon: "1970-01-01", // Amazon hard fork was never on preprod as we backfilled Fork_Nile: "2024-08-14", // Last calculation end timestamp was 8-13: https://holesky.etherscan.io/tx/0xb5a6855e88c79312b7c0e1c9f59ae9890b97f157ea27e69e4f0fadada4712b64#eventlog Fork_Panama: "2024-10-01", + Fork_Arno: "2024-12-04", }, nil case Chain_Holesky: return ForkMap{ Fork_Amazon: "1970-01-01", // Amazon hard fork was never on testnet as we backfilled Fork_Nile: "2024-08-13", // Last calculation end timestamp was 8-12: https://holesky.etherscan.io/tx/0x5fc81b5ed2a78b017ef313c181d8627737a97fef87eee85acedbe39fc8708c56#eventlog Fork_Panama: "2024-10-01", + Fork_Arno: "2024-12-10", }, nil case Chain_Mainnet: return ForkMap{ Fork_Amazon: "2024-08-02", // Last calculation end timestamp was 8-01: https://etherscan.io/tx/0x2aff6f7b0132092c05c8f6f41a5e5eeeb208aa0d95ebcc9022d7823e343dd012#eventlog Fork_Nile: "2024-08-12", // Last calculation end timestamp was 8-11: https://etherscan.io/tx/0x922d29d93c02d189fc2332041f01a80e0007cd7a625a5663ef9d30082f7ef66f#eventlog Fork_Panama: "2024-10-01", + Fork_Arno: "2025-01-07", }, nil } return nil, errors.New("unsupported chain") diff --git a/pkg/rewards/2_goldStakerRewardAmounts.go b/pkg/rewards/2_goldStakerRewardAmounts.go index de2c94e0..a4f510cc 100644 --- a/pkg/rewards/2_goldStakerRewardAmounts.go +++ b/pkg/rewards/2_goldStakerRewardAmounts.go @@ -118,6 +118,8 @@ token_breakdowns AS ( cast(sott.total_staker_operator_payout * 0.10 AS DECIMAL(38,0)) WHEN sott.snapshot < @nileHardforkDate AND sott.reward_submission_date < @nileHardforkDate THEN (sott.total_staker_operator_payout * 0.10)::text::decimal(38,0) + WHEN sott.snapshot < @arnoHardforkDate AND sott.reward_submission_date < @arnoHardforkDate THEN + floor(sott.total_staker_operator_payout * 0.10) ELSE floor(sott.total_staker_operator_payout * COALESCE(oas.split, 1000) / CAST(10000 AS DECIMAL)) END as operator_tokens, @@ -126,6 +128,8 @@ token_breakdowns AS ( sott.total_staker_operator_payout - cast(sott.total_staker_operator_payout * 0.10 as DECIMAL(38,0)) WHEN sott.snapshot < @nileHardforkDate AND sott.reward_submission_date < @nileHardforkDate THEN sott.total_staker_operator_payout - ((sott.total_staker_operator_payout * 0.10)::text::decimal(38,0)) + WHEN sott.snapshot < @arnoHardforkDate AND sott.reward_submission_date < @arnoHardforkDate THEN + sott.total_staker_operator_payout - floor(sott.total_staker_operator_payout * 0.10) ELSE sott.total_staker_operator_payout - floor(sott.total_staker_operator_payout * COALESCE(oas.split, 1000) / CAST(10000 AS DECIMAL)) END as staker_tokens @@ -146,6 +150,7 @@ func (rc *RewardsCalculator) GenerateGold2StakerRewardAmountsTable(snapshotDate zap.String("destTableName", destTableName), zap.String("amazonHardforkDate", forks[config.Fork_Amazon]), zap.String("nileHardforkDate", forks[config.Fork_Nile]), + zap.String("arnoHardforkDate", forks[config.Fork_Arno]), ) query, err := rewardsUtils.RenderQueryTemplate(_2_goldStakerRewardAmountsQuery, map[string]string{ @@ -160,6 +165,7 @@ func (rc *RewardsCalculator) GenerateGold2StakerRewardAmountsTable(snapshotDate res := rc.grm.Exec(query, sql.Named("amazonHardforkDate", forks[config.Fork_Amazon]), sql.Named("nileHardforkDate", forks[config.Fork_Nile]), + sql.Named("arnoHardforkDate", forks[config.Fork_Arno]), ) if res.Error != nil { rc.logger.Sugar().Errorw("Failed to create gold_staker_reward_amounts", "error", res.Error) diff --git a/pkg/rewards/5_goldRfaeStakers.go b/pkg/rewards/5_goldRfaeStakers.go index 830b262a..9d1fd7aa 100644 --- a/pkg/rewards/5_goldRfaeStakers.go +++ b/pkg/rewards/5_goldRfaeStakers.go @@ -112,8 +112,18 @@ staker_operator_total_tokens AS ( -- If no split is found, default to 1000 (10%) token_breakdowns AS ( SELECT sott.*, - floor(sott.total_staker_operator_payout * COALESCE(ops.split, 1000) / CAST(10000 AS DECIMAL)) as operator_tokens, - sott.total_staker_operator_payout - floor(sott.total_staker_operator_payout * COALESCE(ops.split, 1000) / CAST(10000 AS DECIMAL)) as staker_tokens + CASE + WHEN sott.snapshot < @arnoHardforkDate AND sott.reward_submission_date < @arnoHardforkDate THEN + floor(sott.total_staker_operator_payout * 0.10) + ELSE + floor(sott.total_staker_operator_payout * COALESCE(ops.split, 1000) / CAST(10000 AS DECIMAL)) + END as operator_tokens, + CASE + WHEN sott.snapshot < @arnoHardforkDate AND sott.reward_submission_date < @arnoHardforkDate THEN + sott.total_staker_operator_payout - floor(sott.total_staker_operator_payout * 0.10) + ELSE + sott.total_staker_operator_payout - floor(sott.total_staker_operator_payout * COALESCE(ops.split, 1000) / CAST(10000 AS DECIMAL)) + END as staker_tokens FROM staker_operator_total_tokens sott LEFT JOIN operator_pi_split_snapshots ops ON sott.operator = ops.operator AND sott.snapshot = ops.snapshot @@ -129,6 +139,7 @@ func (rc *RewardsCalculator) GenerateGold5RfaeStakersTable(snapshotDate string, rc.logger.Sugar().Infow("Generating rfae stakers table", zap.String("cutoffDate", snapshotDate), zap.String("destTableName", destTableName), + zap.String("arnoHardforkDate", forks[config.Fork_Arno]), ) query, err := rewardsUtils.RenderQueryTemplate(_5_goldRfaeStakersQuery, map[string]string{ @@ -143,6 +154,7 @@ func (rc *RewardsCalculator) GenerateGold5RfaeStakersTable(snapshotDate string, res := rc.grm.Exec(query, sql.Named("panamaForkDate", forks[config.Fork_Panama]), sql.Named("network", rc.globalConfig.Chain.String()), + sql.Named("arnoHardforkDate", forks[config.Fork_Arno]), ) if res.Error != nil { rc.logger.Sugar().Errorw("Failed to generate gold_rfae_stakers", "error", res.Error)