Skip to content

Validator.exchangeRatesTable from Graph QL #21348

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
nishitCrowe opened this issue Feb 25, 2025 · 3 comments
Open

Validator.exchangeRatesTable from Graph QL #21348

nishitCrowe opened this issue Feb 25, 2025 · 3 comments
Assignees
Labels

Comments

@nishitCrowe
Copy link

nishitCrowe commented Feb 25, 2025

Hi Team,

Can anyone suggest how to get PoolTokenExchangeRate from Validator.exchangeRatesTable using Graph QL. Below is the query I have tried.

Image

query {
  epoch(id: 167) {
    totalStakeRewards
    totalGasFees
    totalStakeSubsidies
    startTimestamp
    totalTransactions
    validatorSet{
        totalStake
        activeValidators{
            pageInfo{
                hasNextPage
                endCursor
            }
            nodes{
                address{
                    address
                }
                name
                description
                exchangeRatesSize
                exchangeRatesTable{
                    address
                }
            }
        }
    }
    systemStakeSubsidy{
        currentDistributionAmount
        distributionCounter
        balance
        periodLength
        decreaseRate
    }
    transactionBlocks {
      pageInfo {
        hasNextPage
        endCursor
      }
      nodes {
        digest
        sender {
          address
        }
        effects {
          gasEffects {
            gasObject {
              address
            }
          }
        }
        gasInput {
          gasPrice
          gasBudget
        }
      }
    }
  }
}
Copy link
Contributor

Thank you for opening this issue, a team member will review it shortly. Until then, please do not interact with any users that claim to be from Sui support and do not click on any links!

@stefan-mysten
Copy link
Contributor

Is this what you want?

query {
  epoch(id: 167) {
    validatorSet{
      activeValidators{
      	nodes {
          exchangeRatesTable {
            address
            dynamicFields {
              nodes {
                name {
                   json
                }
                value {
                  __typename ... on MoveValue {
                    json
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}


@nishitCrowe
Copy link
Author

Yes that's what I was looking for.

Actually I want to replicate the functionality defined in calulcate_rewards function reside in staking_pool.move class. So I am collecting data from Graph QL API to get historic data of epoch exchange rates to get reward.

Could you please help like is there any reference where I can get to know what all properties are there in dynamic fields and what does that mean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants