Skip to content

Commit

Permalink
Adding shares deltas table
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmcgary committed Oct 29, 2024
1 parent 8e3930b commit 2c19d6b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
11 changes: 11 additions & 0 deletions internal/postgres/migrations/202409082234_stakerShare/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ func (m *Migration) Up(db *sql.DB, grm *gorm.DB) error {
created_at timestamp with time zone DEFAULT current_timestamp,
unique (staker, strategy, block_number)
)`,
`create table if not exists staker_share_deltas (
staker varchar not null,
strategy varchar not null,
shares numeric not null,
strategy_index bigint not null,
transaction_hash varchar not null,
log_index bigint not null,
block_time timestamp not null,
block_date varchar not null,
block_number bigint not null
)`,
}
for _, query := range queries {
if res := grm.Exec(query); res.Error != nil {
Expand Down
9 changes: 4 additions & 5 deletions pkg/rewards/rewards_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"gorm.io/gorm"
"os"
"path/filepath"
"slices"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -315,10 +314,10 @@ func Test_Rewards(t *testing.T) {
fmt.Printf("Total duration for rewards compute %s: %v\n", snapshotDate, time.Since(snapshotStartTime))
testStart = time.Now()

if !slices.Contains([]string{"2024-08-02", "2024-08-12"}, snapshotDate) {
t.Logf("Skipping gold staging validation for snapshot date: %s", snapshotDate)
continue
}
//if !slices.Contains([]string{"2024-08-02", "2024-08-12"}, snapshotDate) {
// t.Logf("Skipping gold staging validation for snapshot date: %s", snapshotDate)
// continue
//}

expectedRows, err := tests.GetGoldStagingExpectedResults(projectRoot, snapshotDate)
if err != nil {
Expand Down
16 changes: 15 additions & 1 deletion pkg/rewards/tables.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package rewards

import "time"
import (
"time"
)

type CombinedRewards struct {
Avs string
Expand Down Expand Up @@ -51,3 +53,15 @@ type StakerShareSnapshot struct {
Snapshot time.Time
Shares string
}

type StakerShareDeltas struct {
Staker string
Strategy string
Shares string
StrategyIndex string
TransactionHash string
LogIndex string
BlockTime time.Time
BlockDate string
BlockNumber uint64
}

0 comments on commit 2c19d6b

Please sign in to comment.