I have a few doubts regarding the parameters of SNS dapps.
The latest_reward_event talks about how many “rounds” have passed since the last round. What is 1 “round” in an SNS dapp? If it differs from dapp to dapp, how do I find what 1 round is in terms of hours/minutes/days?
If I want to query neuron-level information, how do I know how many neurons are present in an SNS dapp to iterate through all of them via the “get_neuron” or “list_neuron” methods?
When does the data on the ICP get refreshed, is there a particular time each day the data gets refreshed?
Hi @Thanatos and thanks for the quetsions!
I think you reached the right people.
Could you elaborate on what you mean by “the data on the ICP” in 3.? Do you mean some metrics? Maybe you could provide a concrete example of what you refer to?
You can call get_nervous_system_parameters on the Governance canister of the SNS. For example, here is get_nervous_system_parameters for OpenChat. In the response, look for round_duration_seconds, which is typically set to one day (as in the NNS):
round_duration_seconds = opt (86_400 : nat64);
I’m not sure if this is the only way, but if you just want to get the total number of neurons, you can use the metrics endpoint of the Governance canister of the SNS. For example, here is the metrics endpoint for OpenChat. In the response, look for sns_governance_neurons_total, which for OpenChat is 27,168 neurons:
# HELP sns_governance_neurons_total Total number of neurons.
# TYPE sns_governance_neurons_total gauge
sns_governance_neurons_total 27168 1704307861426
You don’t need to know the total number of neurons in order to use list_neurons to iterate through all of them. You can just call list_neurons repeatedly, getting say 100 neurons at a time, until no neurons are returned, at which point you will have gotten all of them.
Since I already had something drafted, let me add these additional things in case some of it is helpful:
There used to be a field reward_event_round (defined here) which used to just “count” how often rewards have already been distributed. This is now obsolete and new proposals have the reward_event_end_timestamp_seconds (defined here).
Probably one relevant question here is how often rewards are distributed. Each SNS can define this in the SNS-specific settings called the “nervous system parameters” (more info can be found in this documentation). It is defined in the voting rewards paramters, specifically in round_duration_seconds (defined here). This is what @Dylan also linked and defines how many seconds are in a reward round. In general, each reward event covers one reward round.
As @Dylan already pointed out, you don’t need to know the number of neurons to get all of them by using the list_neuron endpoint.
Maybe the following information how to use the endpoint is helpful. list_neuron is a paginated way of listing all neurons. It can be used to return all the neurons one page at a time. To do so:
a. You can first call the method list_neuron with no arguments, which will give you the first 100 neurons.
b. Then you can enter as the argument start_page_at the ID of the last neuron that you got in the first step. This will get you the next 100 neurons (where the one with the provided ID is excluded).
c. You can repeat 2. until you went through all neurons (which you know happened when the last list has less than 100 neurons).
Note that these are repeated calls so it could be that while you do e.g., the 10th call, the first few neurons have already changed. For most use cases this might be OK, but it is something to keep in mind.