Skip to content

Conversation

@serichoi65
Copy link
Contributor

@serichoi65 serichoi65 commented Jun 26, 2025

Description

Currently, GetStakerShares show the latest shares of a staker. We want to add an option to see the historical values of staked tokens.

Fixes #411

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

tested locally

sidecar=> with distinct_staker_strategies as (
                                select
                                        ssd.staker,
                                        ssd.strategy,
                                        ssd.shares,
                                        ssd.block_number,
                                        ssd.block_time,
                                        ssd.transaction_hash,
                                        ssd.log_index
                                from staker_share_deltas as ssd
                                where
                                        ssd.staker = '0x00000002f32c0886ee65d68059fbdb76ef6a6996'
                                and ssd.block_number <= 20468025
                                order by ssd.block_number desc, ssd.log_index desc
                        ) select
                        dss.*,
                        dsc.operator,
                        dsc.delegated,
                        coalesce(aosc.avs_list, '[]'::jsonb) as avs_addresses
                from distinct_staker_strategies as dss
                left join lateral (
                        select
                                sdc.staker,
                                sdc.operator,
                                sdc.delegated,
                                row_number() over (partition by sdc.staker order by sdc.block_number desc, sdc.log_index) as rn
                        from staker_delegation_changes as sdc
                        where
                                sdc.staker = dss.staker
                                and sdc.block_number <= 20468025
                        order by block_number desc
                ) as dsc on (dsc.rn = 1)
                left join lateral (
                        select
                                jsonb_agg(distinct aosc.avs) as avs_list
                        from avs_operator_state_changes aosc
                        where
                                aosc.operator = dsc.operator
                                and aosc.block_number <= 20468025
                                and aosc.registered = true
                ) as aosc on true;
                   staker                   |                  strategy                  |         shares         | block_number |     block_time      |                          transaction_hash                          | log_index | operator | delegated | avs_addresses 
--------------------------------------------+--------------------------------------------+------------------------+--------------+---------------------+--------------------------------------------------------------------+-----------+----------+-----------+---------------
 0x00000002f32c0886ee65d68059fbdb76ef6a6996 | 0xacb55c530acdb2849e6d4f36992cd8c9d50ed8f7 | -110000000000000000000 |     20468024 | 2024-08-06 07:25:47 | 0xbd691d9a308c68f22b769873755e0d40d17ac7d559a87c57243bb87cffc1260a |       196 |          |           | []
 0x00000002f32c0886ee65d68059fbdb76ef6a6996 | 0xacb55c530acdb2849e6d4f36992cd8c9d50ed8f7 |  110000000000000000000 |     19842748 | 2024-05-10 22:54:11 | 0x61cc902ac06b6750536c288056f82da96e26edef3aec0c5a5d1aab7e2ba6a6c2 |       597 |          |           | []
 0x00000002f32c0886ee65d68059fbdb76ef6a6996 | 0x0fe4f44bee93503346a3ac9ee5a26b130a5796d6 |     -95653239182155230 |     19141905 | 2024-02-02 16:29:11 | 0x5390a4396b8b0809128677ada0de39a16a7ed290ba028eca25741506ebb4bf90 |       461 |          |           | []
 0x00000002f32c0886ee65d68059fbdb76ef6a6996 | 0x0fe4f44bee93503346a3ac9ee5a26b130a5796d6 |      95653239182155230 |     18814818 | 2023-12-18 19:01:23 | 0xa23eaf08ac82f547219c8522471e17b4340c1c75b8de5eb5120037a565656310 |       200 |          |           | []
(4 rows)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

@serichoi65 serichoi65 requested a review from a team as a code owner June 26, 2025 20:10
@serichoi65 serichoi65 force-pushed the seri.choi/staker-operator branch 2 times, most recently from 14dc1de to 835960e Compare June 30, 2025 13:40
@serichoi65 serichoi65 force-pushed the seri.choi/staker-operator branch from 835960e to f526fb9 Compare June 30, 2025 13:58
@serichoi65 serichoi65 changed the title feat: historical rows for staker shares api feat: historical rows for StakerShares api Jun 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add historical read options for staker_shares table

2 participants