Skip to content

Commit

Permalink
arno hardfork
Browse files Browse the repository at this point in the history
  • Loading branch information
0xrajath authored and seanmcgary committed Dec 6, 2024
1 parent 1a4dfea commit dbd8a6d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
7 changes: 6 additions & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package config
import (
"errors"
"fmt"
"github.com/spf13/viper"
"strconv"
"strings"

"github.com/spf13/viper"
)

type EnvScope string
Expand All @@ -29,6 +30,7 @@ const (
Fork_Nile ForkName = "nile"
Fork_Amazon ForkName = "amazon"
Fork_Panama ForkName = "panama"
Fork_Arno ForkName = "arno"

ENV_PREFIX = "SIDECAR"
)
Expand Down Expand Up @@ -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")
Expand Down
6 changes: 6 additions & 0 deletions pkg/rewards/2_goldStakerRewardAmounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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{
Expand All @@ -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)
Expand Down
16 changes: 14 additions & 2 deletions pkg/rewards/5_goldRfaeStakers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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{
Expand All @@ -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)
Expand Down

0 comments on commit dbd8a6d

Please sign in to comment.