How-to: Verify SNS decentralization swap proposal
Warning: This page refers to a legacy flow of how an SNS is launched. This flow is still supported and thus may still be needed to verify ongoing SNS launches. A new page how to verify the new flow will be created shortly and linked to from here. Please find more context on this here.
The process of launching an SNS for a dapp goes through the following main stages:
- Stage 1: An NNS proposal is created to add a principal (a cycles wallet) to a privileged list on the SNS wasm modules canister (SNS-W) on the NNS. By adopting this proposal, the NNS community agrees that this SNS launch should proceed. Technically, if the proposal is adopted, the principal is allowed to perform the next step exactly once.
- Stage 2: The principal from Stage 1 makes a call to SNS-W which installs the SNS canisters with pre-approved WASMs that are stored in SNS-W and with chosen initial parameters (e.g., initial neurons, number of tokens). The developers can then hand over the control of the dapp to the SNS.
- Stage 3: An NNS proposal is created to start a decentralization swap for the SNS. In this decentralization swap, participants can contribute ICP in exchange for a share of the initial SNS tokens. This proposal defines the conditions for the decentralization swap.
- Stage 4: By adopting this proposal, the NNS community accepts the swap conditions from Stage 3 and the SNS parameters that were chosen in Stage 2. If the NNS proposal is adopted, the decentralization swap starts after a delay (that was also defined in the proposal in Stage 3).
This page contains information for NNS neuron holders to consider when voting in 'Stage 3. Specifically, it explains how the parameters in the NNS proposals can be interpreted and verified, and how SNS canisters can be queried to learn whether the SNS's configurations are valid. All this information is available on chain and can be accessed via (as yet) a manual process where there are two options to interact with the relevant canister: using the DFX tool, or using the Internet Computer Dashboard. Below, there are step by step instructions describing how to proceed and, whenever canister calls are involved, explanations for DFX and dashboard interactions are given.
There is also more general information on the trust and verification required when participating in an SNS decentralization swap. For more general information on the SNS, see the SNS FAQ.
Disclaimer: participation in any SNS is at your own risk.
Step 1: Verify the Parameters for the Decentralization Swap in the NNS proposal
You will find SNS decentralization swap proposals on the NNS Frontend dapp under the Launchpad tab. These proposals will also appear in the Voting tab and can be found easily by filtering by the 'SNS & Community Fund' topic.
As mentioned above, some of the parameters for the decentralization swap are set in the NNS proposal. To verify them, you can look at the field Params in the NNS proposal (e.g. in the NNS frontend dapp or on the dashboard). These parameters are submitted as part of the proposal and represent the information with which the NNS governance canister will open the decentralization swap if the proposal is adopted. You can check if the parameters match with those submitted in the proposal summary. In contrast to the parameters here, the summary-part of the proposal can be freely chosen by the proposer and should not be trusted.
This is what the different entries in the proposal mean:
- minParticipantsIcpE8s is the minimum amount of ICP that a swap participant has to invest for a valid participation. The value is given in fractions of 10E-8 of an ICP, which means that you have to remove eight zeros to convert this to an ICP value: In the example, 10000000 e8s = 0.1 ICP.
- maxIcpE8s is the maximum number of ICP that the decentralization swap will collect. If this maximum is reached, the swap will be finished. The value is given in fractions of 10E-8 of an ICP.
- swapDueTimestampSeconds denotes a timestamp when the decentralization swap (previously called “swap”) will be finished in case that the maximum ICP is not reached before this time. The unit of this parameter is in seconds from the Unix epoch. You can use an online converter to convert this to a human readable date and time.
- minParticipants is the minimum number of swap participants for the decentralization swap to be considered successful. If the swap ends and there are less participants, the swap failed.
- snsTokensE8s is the number of SNS tokens that are swapped in the initial decentralization swap. The value is given in fractions of 10E-8 of an SNS token. This value should match the “swap supply allocated to initial decentralization swap” that the SNS was initialized with. This can be checked in Step 3.
- maxParticipantIcpE8s is the maximum contribution that an individual swap participant can make. The value is given in fractions of 10E-8 of an ICP.
- minIcpE8s is the minimum number of ICP that the decentralization swap will collect. The value is given in fractions of 10E-8 of an ICP.
- communityFundInvestmentE8s is the amount that the community fund will collectively spend in maturity on the decentralization swap.
- targetSwapCanisterId
- neuronBasketCount defines the number of neurons each swap participants will receive after a successful decentralization swap. The total SNS tokens that a participant will get are distributed evenly across these neurons.
- neuronBasketDissolveDelayIntervalSeconds this is the difference in dissolve delays between the different neurons in the neuron basket that a swap participant gets. Every swap participant will get a neuron with dissolve delay zero and then with a dissolve delay defined by this parameter, and (in case the neuron basked consists of more than two neurons) with a neuron that is twice this parameter etc..
- saleDelaySeconds defines an optional delay, so that the swap does not get opened immediately after the adoption of the swap proposal, which gives users time to prepare for the swap start.
Step 2: Verifying the SNS canisters
The proposal payload contains the canister ID of the decentralization swap that it will call if the proposal is adopted. A good proposal summary will contain the canister IDs of the other SNS canisters as well as that of the dapp controlled by the SNS. The next step is to verify that the provided decentralization swap is indeed part of an SNS composed of the canisters claimed in the proposal summary. These steps are outlined in the How-to: Interact with SNS canisters page, but they are repeated below for convenience.
1. Preparation
DFX
If you want to use DFX, download these snippets into an empty repo so that DFX can point at the correct canisters. This will allow you to call the canisters and read the output in a human friendly way. Snippet 1: dfx.json and candid files
2. Get the SNS root canister.
The SNS root canister is the SNS canister that knows about and controls all the other SNS canisters and the dapp canisters. Therefore it is the canister by which a particular SNS can be identified. All SNS root canisters, and thus all SNSs, are listed in the NNS canister called SNS wasm modules canister, or SNS-W for short. As such, the first step is to verify that the root canister in the proposal summary is in the list of deployed_snses. SNS-W is a fixed canister ID in the NNS subnet and its canister ID is qaa6y-5yaaa-aaaaa-aaafa-cai. Call the method list_deployed_snses and verify that the root canister ID from the proposal is in the returned list.
DFX
$ dfx canister --network ic call qaa6y-5yaaa-aaaaa-aaafa-cai list_deployed_snses '(record {})'
Dashboard
In the SNS-W canister interface, click ‘+’ next to list_deployed_snses
, and then click “Call”.
3. Get all SNS and dapp canisters
From the last step, the root canister ID has been verified as a “true” SNS root canister ID deployed through the blessed canister wasm path. You can next get the rest of the canister IDs associated with that SNS by calling list_sns_canisters
on the SNS root canister.
The response from this method should have a “swap” entry that matches the swap_canister_id in the NNS proposal from Step 1. By verifying that the canister of this decentralization swap matches, you verify that the NNS proposal will indeed call the swap canister of the SNS that you are inspecting.
The response from this method also has a “dapps” entry that should match what the proposal suggests is under control of the SNS.
DFX
$ dfx canister --network ic call zxeu2-7aaaa-aaaaq-aaafa-cai list_sns_canisters '(record {} )'
You can verify that the human friendly labels match the canister ids returned by inspecting the canister_ids.json file.
Dashboard
On the dashboard, enter the canister ID of SNS root in the search tab. You should see all the methods of SNS root now. Similarly to the last step, click ‘+’ next to list_sns_canisters
, and then click “Call”.
4. Get the summary of all SNS and dapp canisters
Finally, you can get the summary and ownership graph of the SNS including the dapps. To do so, call get_sns_canisters_summary
on the SNS root canister. This will return the status of each canister in the SNS, including information such as the canister’s controller and cycles balance.
DFX
$ dfx canister --network ic call zxeu2-7aaaa-aaaaq-aaafa-cai get_sns_canisters_summary '(record {} )'
Dashboard
On the dashboard, where you should still be in the SNS root canister interface from the last Step, click ‘+’ next to get_sns_canisters_summary
, and then click “Call”.
Step 3: Verifying the initial SNS Parameters
After Step 2, the IDs of all SNS canisters are known. The next step is to verify the parameters that these canisters have been initialized with.
1. Check the initialization parameters
The SNS governance canister stores all the initial parameters that were provided to SNS-W when the SNS was first installed. SNS governance can be queried for this information to learn how the SNS was set up. This information includes the initial token distribution, as well as the initial neurons, consisting of developer and airdrop neurons.
DFX
$ dfx canister --network ic call zqfso-syaaa-aaaaq-aaafq-cai get_sns_initialization_parameters '(record {})'
Dashboard
On the dashboard, navigate to the SNS governance canister by entering the canister ID in the search bar. Then, click ‘+’ next to get_sns_initialization_parameters
, and click “Call”.
2. List the neurons that exist in SNS Governance
You can then see that the neurons available add up to the initialization parameters that you just inspected and that the current stake of them is as expected.
DFX
$ dfx canister --network ic call zqfso-syaaa-aaaaq-aaafq-cai list_neurons '(record { of_principal=null; limit=100: nat32; start_page_at=null } )'
Dashboard
Navigate to the SNS governance canister by entering the canister ID in the search bar.
For example for SNS-1, this is zqfso-syaaa-aaaaq-aaafq-cai
.
Then, click ‘+’ next to list_neurons
. You don't need to choose anything for of_principle
if you want to look at all neurons. Choose a limit as described above. For the first page you don't need to select a start_page_at
and can click “Call”.
For subsequent calls, the last neuron in the response is needed to resume iteration. Copy the vec from the "id" field from the last neuron and paste it into the start_page_at
box.
3. Verify that the SNS tokens in the decentralization swap match what was claimed in the proposal
The SNS tokens that are swapped in the decentralization swap are stored in the SNS ledger account that is owned by the SNS swap canister. Thus, to learn how many tokens are in the decentralization swap, call icrc1_balance_of
to get the balance of the Swap canister. The returned value is given in fractions of 10E-8 of an SNS token. You can now compare this value to snsTokensE8s that is specified in the NNS proposal.
DFX
$ dfx canister --network https://ic0.app call zfcdd-tqaaa-aaaaq-aaaga-cai --query icrc1_balance_of '(record {owner = principal "zcdfx-6iaaa-aaaaq-aaagq-cai" })'
Dashboard
On the dashboard, navigate to the SNS ledger canister by entering the canister ID in the search bar. Then, click ‘+’ next to icrc1_balance_of
, and provide as the argument the ID of the SNS swap canister. Then press call
.
4. Learn how many tokens are in the SNS treasury
The SNS treasury is a SNS ledger account that is owned by SNS governance. Specifically, it is on a defined subaccount of the SNS governance’s ledger account. To query it you need to compute the subaccount from the SNS governance’s ID.
Once you have the subaccount, use icrc1_balance_of
to get the balance of the SNS ledger account that belongs to the SNS treasury.
This command will be different for every SNS.
DFX
For example for SNS-1, you can get the result by using:
dfx canister --network https://ic0.app call --query zfcdd-tqaaa-aaaaq-aaaga-cai icrc1_balance_of '(record {owner = principal "zqfso-syaaa-aaaaq-aaafq-cai"; subaccount = blob "\ce\c2\14\5a\75\0f\d4\a4\72\b2\a0\21\f6\df\f1\e4\a9\07\29\97\00\06\2a\0a\02\bc\1e\a6\5c\a2\92\58" })'
Dashboard
On the dashboard, navigate to the SNS ledger canister by entering the canister ID in the search bar. Then, click ‘+’ next to icrc1_balance_of
, and provide as “owner” the canister ID of SNS governance. Also select the additional argument “subaccount (opt vet nat8)” and enter the required subaccount. Then press “Call”.
As mentioned, the subaccount depends on the SNS.