-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: rewards 2.1 calculation (#215)
# Motivation We need to support Rewards v2.1 calculation. This PR builds on top of #197 which supported the Eigen state models for `OperatorDirectedOperatorSetRewardSubmissions`, `OperatorSetSplits`, `OperatorSetOperatorRegistrations`, `OperatorSetStrategyRegistrations`. # Modifications * Snapshot generation for: `OperatorDirectedOperatorSetRewardSubmissions`, `OperatorSetSplits`, `OperatorSetOperatorRegistrations`, `OperatorSetStrategyRegistrations`. * Refactoring Staging and Final numbering from 11 and 12 to 15 and 16. * Mississippi hard fork for Rewards v2.1. * New Operator Directed Operator Set rewards calculation to be triggered after Mississippi hard fork. * Updated Rewards For All Earners (Programmatic Incentives) calculation to include operators registered to operator sets after Mississippi hard fork. * Staker-operator calculation for Rewards v2.1. # Results Rewards v2.1 calculation. # Tests Existing Rewards tests passing. <img width="660" alt="Screenshot 2025-01-31 at 1 33 38 PM" src="https://github.com/user-attachments/assets/876c2d7c-be22-48b6-a046-55ead8a12530" />
- Loading branch information
Showing
35 changed files
with
2,768 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
pkg/postgres/migrations/202501301458_operatorSetSplitSnapshots/up.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package _202501301458_operatorSetSplitSnapshots | ||
|
||
import ( | ||
"database/sql" | ||
|
||
"github.com/Layr-Labs/sidecar/internal/config" | ||
"gorm.io/gorm" | ||
) | ||
|
||
type Migration struct { | ||
} | ||
|
||
func (m *Migration) Up(db *sql.DB, grm *gorm.DB, cfg *config.Config) error { | ||
queries := []string{ | ||
`CREATE TABLE IF NOT EXISTS operator_set_split_snapshots ( | ||
operator varchar not null, | ||
avs varchar not null, | ||
operator_set_id bigint not null, | ||
split integer not null, | ||
snapshot date not null, | ||
UNIQUE (operator, avs, operator_set_id, snapshot) | ||
)`, | ||
} | ||
for _, query := range queries { | ||
if _, err := db.Exec(query); err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func (m *Migration) GetName() string { | ||
return "202501301458_operatorSetSplitSnapshots" | ||
} |
33 changes: 33 additions & 0 deletions
33
pkg/postgres/migrations/202501301502_operatorSetOperatorRegistrationSnapshots/up.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package _202501301502_operatorSetOperatorRegistrationSnapshots | ||
|
||
import ( | ||
"database/sql" | ||
|
||
"github.com/Layr-Labs/sidecar/internal/config" | ||
"gorm.io/gorm" | ||
) | ||
|
||
type Migration struct { | ||
} | ||
|
||
func (m *Migration) Up(db *sql.DB, grm *gorm.DB, cfg *config.Config) error { | ||
queries := []string{ | ||
`CREATE TABLE IF NOT EXISTS operator_set_operator_registration_snapshots ( | ||
operator varchar not null, | ||
avs varchar not null, | ||
operator_set_id bigint not null, | ||
snapshot date not null, | ||
UNIQUE (operator, avs, operator_set_id, snapshot) | ||
)`, | ||
} | ||
for _, query := range queries { | ||
if _, err := db.Exec(query); err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func (m *Migration) GetName() string { | ||
return "202501301502_operatorSetOperatorRegistrationSnapshots" | ||
} |
33 changes: 33 additions & 0 deletions
33
pkg/postgres/migrations/202501301505_operatorSetStrategyRegistrationSnapshots/up.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package _202501301505_operatorSetStrategyRegistrationSnapshots | ||
|
||
import ( | ||
"database/sql" | ||
|
||
"github.com/Layr-Labs/sidecar/internal/config" | ||
"gorm.io/gorm" | ||
) | ||
|
||
type Migration struct { | ||
} | ||
|
||
func (m *Migration) Up(db *sql.DB, grm *gorm.DB, cfg *config.Config) error { | ||
queries := []string{ | ||
`CREATE TABLE IF NOT EXISTS operator_set_strategy_registration_snapshots ( | ||
strategy varchar not null, | ||
avs varchar not null, | ||
operator_set_id bigint not null, | ||
snapshot date not null, | ||
UNIQUE (strategy, avs, operator_set_id, snapshot) | ||
)`, | ||
} | ||
for _, query := range queries { | ||
if _, err := db.Exec(query); err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func (m *Migration) GetName() string { | ||
return "202501301505_operatorSetStrategyRegistrationSnapshots" | ||
} |
47 changes: 47 additions & 0 deletions
47
pkg/postgres/migrations/202501301945_operatorDirectedOperatorSetRewards/up.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package _202501301945_operatorDirectedOperatorSetRewards | ||
|
||
import ( | ||
"database/sql" | ||
|
||
"github.com/Layr-Labs/sidecar/internal/config" | ||
"gorm.io/gorm" | ||
) | ||
|
||
type Migration struct { | ||
} | ||
|
||
func (m *Migration) Up(db *sql.DB, grm *gorm.DB, cfg *config.Config) error { | ||
queries := []string{ | ||
`CREATE TABLE IF NOT EXISTS operator_directed_operator_set_rewards ( | ||
avs varchar not null, | ||
operator_set_id bigint not null, | ||
reward_hash varchar not null, | ||
token varchar not null, | ||
operator varchar not null, | ||
operator_index integer not null, | ||
amount numeric not null, | ||
strategy varchar not null, | ||
strategy_index integer not null, | ||
multiplier numeric(78) not null, | ||
start_timestamp timestamp(6) not null, | ||
end_timestamp timestamp(6) not null, | ||
duration bigint not null, | ||
block_number bigint not null, | ||
block_time timestamp without time zone not null, | ||
block_date date not null, | ||
UNIQUE (avs, operator_set_id, reward_hash, operator_index, strategy_index), | ||
CONSTRAINT operator_directed_operator_set_rewards_block_number_fkey FOREIGN KEY (block_number) REFERENCES blocks(number) ON DELETE CASCADE | ||
)`, | ||
} | ||
|
||
for _, query := range queries { | ||
if err := grm.Exec(query).Error; err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func (m *Migration) GetName() string { | ||
return "202501301945_operatorDirectedOperatorSetRewards" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.