package ic_sns_swap.pb.v1

Mouse Melon logoGet desktop application:
View/edit binary Protocol Buffers messages

message BuyerState

swap.proto:643

Used in: GetBuyerStateResponse, Participant, Swap

message CanisterCallError

swap.proto:1218

Used in: RestoreDappControllersResponse, SetDappControllersCallResult, SetDappControllersResponse.FailedUpdate, SetModeCallResult, SettleCommunityFundParticipationResult

message CfInvestment

swap.proto:683

Information about a Neurons' Fund investment. The NNS Governance canister is the controller of these neurons.

Used in: SnsNeuronRecipe

message CfNeuron

swap.proto:504

Represents one NNS neuron from the Neurons' Fund participating in this swap.

Used in: CfParticipant

message CfParticipant

swap.proto:519

Represents a Neurons' Fund participant, possibly with several neurons.

Used in: ic_nns_governance.pb.v1.ProposalData, ListCommunityFundParticipantsResponse, NeuronsFundParticipants, OpenRequest, Swap

message DerivedState

swap.proto:794

Used in: GetStateResponse

message DirectInvestment

swap.proto:677

Information about a direct investor.

Used in: SnsNeuronRecipe

message ErrorRefundIcpRequest

swap.proto:1226

Request a refund of tokens that were sent to the canister in error. The refund is always on the ICP ledger, from this canister's subaccount of the caller to the account of the caller.

message ErrorRefundIcpResponse

swap.proto:1232

message ErrorRefundIcpResponse.Err

swap.proto:1240

Request was not successful, and no funds were transferred.

Used in: ErrorRefundIcpResponse

enum ErrorRefundIcpResponse.Err.Type

swap.proto:1241

Used in: Err

message ErrorRefundIcpResponse.Ok

swap.proto:1234

Request was completed successfully.

Used in: ErrorRefundIcpResponse

message FinalizeSwapRequest

swap.proto:847

Once a swap is committed or aborted, the tokens need to be distributed, and, if the swap was committed, neurons created.

(message has no fields)

message FinalizeSwapResponse

swap.proto:850

Response from the `finalize_swap` canister API.

Used in: GetAutoFinalizationStatusResponse, Swap

message GetAutoFinalizationStatusRequest

swap.proto:1281

(message has no fields)

message GetAutoFinalizationStatusResponse

swap.proto:1283

message GetBuyerStateRequest

swap.proto:778

message GetBuyerStateResponse

swap.proto:783

message GetBuyersTotalRequest

swap.proto:787

(message has no fields)

message GetBuyersTotalResponse

swap.proto:789

message GetCanisterStatusRequest

swap.proto:769

(message has no fields)

message GetDerivedStateRequest

swap.proto:1305

Request struct for the method `get_derived_state`

(message has no fields)

message GetDerivedStateResponse

swap.proto:1308

Response struct for the method `get_derived_state`

message GetInitRequest

swap.proto:1297

Request struct for the method `get_init`

(message has no fields)

message GetInitResponse

swap.proto:1300

Response struct for the method `get_init`

message GetLifecycleRequest

swap.proto:1272

Request struct for the method `get_lifecycle`

(message has no fields)

message GetLifecycleResponse

swap.proto:1275

Response struct for the method `get_lifecycle`

message GetOpenTicketRequest

swap.proto:1363

Request struct for the method `get_open_ticket`

(message has no fields)

message GetOpenTicketResponse

swap.proto:1366

Response struct for the method `get_open_ticket`

message GetOpenTicketResponse.Err

swap.proto:1375

Request was not successful, and no ticket was created.

Used in: GetOpenTicketResponse

enum GetOpenTicketResponse.Err.Type

swap.proto:1376

Used in: Err

message GetOpenTicketResponse.Ok

swap.proto:1368

Request was completed successfully.

Used in: GetOpenTicketResponse

message GetSaleParametersRequest

swap.proto:1504

Request struct for the method `get_sale_parameters`.

(message has no fields)

message GetSaleParametersResponse

swap.proto:1507

Response struct for the method `get_sale_parameters`.

message GetStateRequest

swap.proto:772

TODO: introduce a limits on the number of buyers to include?

(message has no fields)

message GetStateResponse

swap.proto:773

message GovernanceError

swap.proto:994

Copied from nns governance.proto.

Used in: SettleCommunityFundParticipationResult.Response, SettleNeuronsFundParticipationResponse

enum GovernanceError.ErrorType

swap.proto:995

Used in: GovernanceError

message ICRC1Account

swap.proto:1328

ICRC-1 Account. See https://github.com/dfinity/ICRC-1/tree/main/standards/ICRC-1

Used in: Ticket

message IdealMatchedParticipationFunction

swap.proto:453

This function is called "ideal" because it serves as the guideline that the Neurons' Fund will try to follow, but may deviate from in order to satisfy SNS-specific participation constraints while allocating its overall participation amount among its neurons' maturity. In contrast, The "effective" matched participation function `crate::neurons_fund::MatchedParticipationFunction` is computed *based* on this one. TODO(NNS1-1589): Until the Jira ticket gets solved, this definition needs to be synchronized with that from nns/governance/proto/ic_nns_governance/pb/v1/governance.proto.

Used in: NeuronsFundParticipationConstraints

message Init

swap.proto:281

The initialisation data of the canister. Always specified on canister creation, and cannot be modified afterwards. If the initialization parameters are incorrect, the swap will immediately be aborted.

Used in: GetInitResponse, Swap

enum Lifecycle

swap.proto:17

Lifecycle states of the swap canister. The details of their meanings are provided in the documentation of the `Swap` message.

Used in: ic_nns_governance.pb.v1.ProposalData, GetLifecycleResponse, Swap

message LinearScalingCoefficient

swap.proto:483

Some Neurons' Fund neurons might be too small, and some might be too large to participate in a given SNS swap. This causes the need to adjust Neurons' Fund participation from an "ideal" amount to an "effective" amount. * The ideal-participation of the Neurons' Fund refers to the value dictated by some curve that specifies how direct contributions should be matched with Neurons' Fund maturity. * The effective-participation of the Neurons' Fund refers to the value that the NNS Governance can actually allocate, given (1) the configuration of the Neurons' Fund at the time of execution of the corresponding CreateServiceNervousSystem proposal and (2) the amount of direct participation. This structure represents the coefficients of a linear transformation used for mapping the Neurons' Fund ideal-participation to effective-participation on a given linear (semi-open) interval. Say we have the following function for matching direct participants' contributions: `f: ICP e8s -> ICP e8s`; then the *ideal* Neuron's Fund participation amount corresponding to the direct participation of `x` ICP e8s is `f(x)`, while the Neuron's Fund *effective* participation amount is: ``` g(x) = (c.slope_numerator / c.slope_denominator) * f(x) + c.intercept ``` where `c: LinearScalingCoefficient` with `c.from_direct_participation_icp_e8s <= x < c.to_direct_participation_icp_e8s`. Note that we represent the slope as a rational number (as opposed to floating point), enabling equality comparison between two instances of this structure.

Used in: NeuronsFundParticipationConstraints

message ListCommunityFundParticipantsRequest

swap.proto:1512

Request struct for the method `list_community_fund_participants`.

message ListCommunityFundParticipantsResponse

swap.proto:1521

Response struct for the method `list_community_fund_participants`.

message ListDirectParticipantsRequest

swap.proto:1465

Request struct for the method `list_direct_participants`. This method paginates over all direct participants in the decentralization swap. Direct participants are participants who did not participate via the Neurons' Fund.

message ListDirectParticipantsResponse

swap.proto:1477

Response struct for the method `list_direct_participants`.

message ListSnsNeuronRecipesRequest

swap.proto:1526

Request for the method `list_sns_neuron_recipes`

message ListSnsNeuronRecipesResponse

swap.proto:1535

Response for the method `list_sns_neuron_recipes`

message NeuronBasketConstructionParameters

swap.proto:528

The construction parameters for the basket of neurons created for all investors in the decentralization swap.

Used in: Init, Params

message NeuronId

swap.proto:1212

The id of a specific neuron, which equals the neuron's subaccount on the ledger canister (the account that holds the neuron's staked tokens).

Used in: SnsNeuronRecipe.NeuronAttributes

message NeuronsFundParticipants

swap.proto:499

Represents multiple Neurons' Fund participants.

Used in: Init

message NeuronsFundParticipationConstraints

swap.proto:425

Constraints for the Neurons' Fund participation in an SNS swap.

Used in: Init

message NewSaleTicketRequest

swap.proto:1394

Request struct for the method `new_sale_ticket`

message NewSaleTicketResponse

swap.proto:1403

Response struct for the method `new_sale_ticket`

message NewSaleTicketResponse.Err

swap.proto:1411

Request was not successful, and no ticket was created.

Used in: NewSaleTicketResponse

message NewSaleTicketResponse.Err.InvalidUserAmount

swap.proto:1412

Used in: Err

enum NewSaleTicketResponse.Err.Type

swap.proto:1417

Used in: Err

message NewSaleTicketResponse.Ok

swap.proto:1405

Request was completed successfully.

Used in: NewSaleTicketResponse

message NotifyPaymentFailureRequest

swap.proto:1540

Request struct for the method `notify_payment_failure`

(message has no fields)

message NotifyPaymentFailureResponse

swap.proto:1545

Response for the method `notify_payment_failure` Returns the ticket if a ticket was found for the caller and the ticket was removed successfully. Returns None if no ticket was found for the caller.

message OpenRequest

swap.proto:758

message OpenResponse

swap.proto:767

(message has no fields)

message Params

swap.proto:540

The parameters of the swap, provided in the call to `open`. Cannot be modified after the call to `open`.

Used in: ic_nns_governance.pb.v1.OpenSnsTokenSwap, GetSaleParametersResponse, OpenRequest, Swap

message Participant

swap.proto:1493

A direct Participant in the decentralization swap.

Used in: ListDirectParticipantsResponse

message RefreshBuyerTokensRequest

swap.proto:831

Informs the swap canister that a buyer has sent funds to participate in the swap. Only in lifecycle state `open`.

message RefreshBuyerTokensResponse

swap.proto:840

message RestoreDappControllersRequest

swap.proto:905

Request struct for the method restore_dapp_controllers.

(message has no fields)

message RestoreDappControllersResponse

swap.proto:909

Response of the method restore_dapp_controllers. Analogous to Rust type Result<SetDappControllersResponse, CanisterCallError>.

message SetDappControllersCallResult

swap.proto:919

Analogous to Rust type Result<SetDappControllersResponse, CanisterCallError>.

Used in: FinalizeSwapResponse

message SetDappControllersRequest

swap.proto:976

Change control of the listed canisters to the listed principal id. Copy of the type in root.proto. TODO(NNS1-1589)

message SetDappControllersRequest.CanisterIds

swap.proto:977

Used in: SetDappControllersRequest

message SetDappControllersResponse

swap.proto:985

Used in: RestoreDappControllersResponse, SetDappControllersCallResult

message SetDappControllersResponse.FailedUpdate

swap.proto:986

Used in: SetDappControllersResponse

message SetModeCallResult

swap.proto:895

Analogous to Rust type Result<SetModeResponse, CanisterCallError>.

Used in: FinalizeSwapResponse

message SetModeCallResult.SetModeResult

swap.proto:901

Used in: SetModeCallResult

(message has no fields)

message SetOpenTimeWindowRequest

swap.proto:817

Used in: ic_nns_governance.pb.v1.SetSnsTokenSwapOpenTimeWindow

message SetOpenTimeWindowResponse

swap.proto:825

Response if setting the open time window succeeded.

(message has no fields)

message SettleCommunityFundParticipation

swap.proto:1060

Copied from nns governance.proto.

message SettleCommunityFundParticipation.Aborted

swap.proto:1091

When this happens, maturity needs to be restored to Neurons' Fund neurons. The amounts to be refunded can be found in the ProposalData's `cf_participants` field.

Used in: SettleCommunityFundParticipation

(message has no fields)

message SettleCommunityFundParticipation.Committed

swap.proto:1077

When this happens, ICP needs to be minted, and sent to the SNS governance canister's main account on the ICP Ledger. As with Aborted, the amount of ICP that needs to be minted can be deduced from the ProposalData's cf_participants field.

Used in: SettleCommunityFundParticipation

message SettleCommunityFundParticipationResult

swap.proto:928

Used in: FinalizeSwapResponse

message SettleCommunityFundParticipationResult.Response

swap.proto:929

Used in: SettleCommunityFundParticipationResult

message SettleNeuronsFundParticipationRequest

swap.proto:1128

Request to settle the Neurons' Fund participation in this SNS Swap. When a swap ends, the Swap canister notifies the Neurons' Fund of the swap's ultimate result, which can be either `Committed` or `Aborted`. Note that currently, the Neurons' Fund is managed by the NNS Governance canister. * If the result is `Committed`: - Neurons' Fund computes the "effective" participation amount for each of its neurons (as per the Matched Funding rules). This computation is based on the total direct participation amount, which is thus a field of `Committed`. - Neurons' Fund converts the "effective" amount of maturity into ICP by: - Requesting the ICP Ledger to mint an appropriate amount of ICP tokens and sending them to the SNS treasury. - Refunding whatever maturity is left over (the maximum possible maturity is reserved by the Neurons' Fund before the swap begins). - Neurons' Fund returns the Neurons' Fund participants back to the Swap canister (see SettleNeuronsFundParticipationResponse). - The Swap canister then creates SNS neurons for the Neurons' Fund participants. * If the result is Aborted, the Neurons' Fund is refunded for all maturity reserved for this SNS. This design assumes trust between the Neurons' Fund and the SNS Swap canisters. In the one hand, the Swap trusts that the Neurons' Fund sends the correct amount of ICP to the SNS treasury, and that the Neurons' Fund allocates its participants following the Matched Funding rules. On the other hand, the Neurons' Fund trusts that the Swap will indeed create appropriate SNS neurons for the Neurons' Fund participants. The justification for this trust assumption is as follows. The Neurons' Fund can be trusted as it is controlled by the NNS. The SNS Swap can be trusted as it is (1) deployed by SNS-W, which is also part of the NNS and (2) upgraded via an NNS proposal (unlike all other SNS canisters). This request may be submitted only by the Swap canister of an SNS instance created by a CreateServiceNervousSystem proposal. TODO(NNS1-1589): Until the Jira ticket gets solved, changes here need to be manually propagated to (sns) swap.proto.

message SettleNeuronsFundParticipationRequest.Aborted

swap.proto:1170

When this happens, all priorly reserved maturity for this SNS instance needs to be restored to the Neurons' Fund neurons.

Used in: SettleNeuronsFundParticipationRequest

(message has no fields)

message SettleNeuronsFundParticipationRequest.Committed

swap.proto:1158

When this happens, the NNS Governance needs to do several things: (1) Compute the effective amount of ICP per neuron of the Neurons' Fund as a function of `total_direct_participation_icp_e8s`. The overall Neurons' Fund participation should equal `total_neurons_fund_contribution_icp_e8s`. (2) Mint (via the ICP Ledger) and sent to the SNS governance the amount of `total_neurons_fund_contribution_icp_e8s`. (3) Respond to this request with `SettleNeuronsFundParticipationResponse`, providing the set of `NeuronsFundParticipant`s with the effective amount of ICP per neuron, as computed in step (1). (4) Refund each neuron of the Neurons' Fund with (reserved - effective) amount of ICP. Effective amounts depend on `total_direct_participation_icp_e8s` and the participation limits of a particular SNS instance, namely, each participation must be between `min_participant_icp_e8s` and `max_participant_icp_e8s`. - If a neuron of the Neurons' Fund has less than `min_participant_icp_e8s` worth of maturity, then it is ineligible to participate. - If a neuron of the Neurons' Fund has more than `max_participant_icp_e8s` worth of maturity, then its participation amount is limited to `max_participant_icp_e8s`. Reserved amounts are computed as the minimal upper bound on the effective amounts, i.e., when the value `total_direct_participation_icp_e8s` reaches its theoretical maximum.

Used in: SettleNeuronsFundParticipationRequest

message SettleNeuronsFundParticipationResponse

swap.proto:1185

Handling the Neurons' Fund and transferring some of its maturity to an SNS treasury is thus the responsibility of the NNS Governance. When a swap succeeds, a Swap canister should send a `settle_neurons_fund_participation` request to the NNS Governance, specifying its `result` field as `committed`. The NNS Governance then computes the ultimate distribution of maturity in the Neurons' Fund. However, this distribution also needs to be made available to the SNS Swap that will use this information to create SNS neurons of an appropriate size for each Neurons' Fund (as well as direct) participant. That is why in the `committed` case, the NNS Governance should populate the `neurons_fund_participants` field, while in the `aborted` case it should be empty. TODO(NNS1-1589): Until the Jira ticket gets solved, changes here need to be manually propagated to (sns) swap.proto.

message SettleNeuronsFundParticipationResponse.NeuronsFundNeuron

swap.proto:1187

Represents one NNS neuron from the Neurons' Fund participating in this swap.

Used in: Ok

message SettleNeuronsFundParticipationResponse.Ok

swap.proto:1200

Request was completed successfully.

Used in: SettleNeuronsFundParticipationResponse

message SettleNeuronsFundParticipationResult

swap.proto:941

The result from settling the neurons' fund participation in finalization.

Used in: FinalizeSwapResponse

message SettleNeuronsFundParticipationResult.Error

swap.proto:960

The failure branch of the result. This message can be set for a number of reasons not limited to - invalid state - replica errors - canister errors While some of these errors are transient and can immediately retried, others require manual intervention. The error messages and logs of the canister should provide enough context to debug.

Used in: SettleNeuronsFundParticipationResult

message SettleNeuronsFundParticipationResult.Ok

swap.proto:946

The successful branch of the result. On subsequent attempts to settle neurons fund participation (for example: due to some later stage of finalization failing and a manual retry is invoked), this branch will be set with the results of the original successful attempt.

Used in: SettleNeuronsFundParticipationResult

message SnsNeuronRecipe

swap.proto:693

Used in: ListSnsNeuronRecipesResponse, Swap

enum SnsNeuronRecipe.ClaimedStatus

swap.proto:733

The various statuses of creation that a SnsNeuronRecipe can have in an SNS.

Used in: SnsNeuronRecipe

message SnsNeuronRecipe.NeuronAttributes

swap.proto:703

Attributes of the Neuron to be created from the SnsNeuronRecipe

Used in: SnsNeuronRecipe

message Swap

swap.proto:190

The `swap` canister smart contract is used to perform a type of single-price auction (SNS/ICP) of one token type SNS for another token type ICP (this is typically ICP, but can be treated as a variable) at a specific date/time in the future. Such a single-price auction is typically used to decentralize an SNS, i.e., to ensure that a sufficient number of governance tokens of the SNS are distributed among different participants. State (lifecycle) diagram for the swap canister's state. ```text sufficient_participation && (swap_due || icp_target_reached) PENDING -------------------> ADOPTED ---------------------> OPEN -----------------------------------------> COMMITTED Swap receives a request The opening delay | | from NNS governance to has elapsed | not sufficient_participation | schedule opening | && (swap_due || icp_target_reached) | v v ABORTED ---------------------------------------> <DELETED> ``` Here `sufficient_participation` means that the minimum number of participants `min_participants` has been reached, each contributing between `min_participant_icp_e8s` and `max_participant_icp_e8s`, and their total contributions add up to at least `min_icp_e8s` and at most `max_icp_e8s`. `icp_target_reached` means that the total amount of ICP contributed is equal to `max_icp_e8s`. (The total amount of ICP contributed should never be greater than `max_icp_e8s`.) The dramatis personae of the `swap` canister are as follows: - The swap canister itself. - The NNS governance canister - which is the only principal that can open the swap. - The governance canister of the SNS to be decentralized. - The ledger canister of the SNS, i.e., the ledger of the token type being sold. - The ICP ledger canister, or more generally of the base currency of the auction. - The root canister of the SNS to control aspects of the SNS not controlled by the SNS governance canister. When the swap canister is initialized, it must be configured with the canister IDs of the other participant canisters. The next step is to provide SNS tokens for the swap. This normally happens when the canister is in the PENDING state, and the amount is validated in the call to `open`. The request to open the swap has to originate from the NNS governance canister. The request specifies the parameters of the swap, i.e., the date/time at which the token swap will take place, the minimal number of participants, the minimum number of base tokens (ICP) of each participant, as well as the minimum and maximum number (reserve and target) of base tokens (ICP) of the swap. Step 0. The canister is created, specifying the initialization parameters, which are henceforth fixed for the lifetime of the canister. Step 1 (State PENDING). The swap canister is loaded with the right amount of SNS tokens. A call to `open` will then transition the canister to the OPEN state. Step 2a. (State ADOPTED). The field `params` is received as an argument to the call to `open` and is henceforth immutable. The amount of SNS token is verified against the SNS ledger. The swap will be opened after an optional delay. The transition to OPEN happens automatically (on the canister heartbeat) when the delay elapses. Step 2a. (State OPEN). The delay has elapsed and the swap is open for participants who can enter into the auction with a number of ICP tokens until either the target amount has been reached or the auction is due, i.e., the date/time of the auction has been reached. The transition to COMMITTED or ABORTED happens automatically (on the canister heartbeat) when the necessary conditions are fulfilled. Step 3a. (State COMMITTED). Tokens are allocated to participants at a single clearing price, i.e., the number of SNS tokens being offered divided by the total number of ICP tokens contributed to the swap. In this state, a call to `finalize` will create SNS neurons for each participant and transfer ICP to the SNS governance canister. The call to `finalize` does not happen automatically (i.e., on the canister heartbeat) so that there is a caller to respond to with potential errors. Step 3b. (State ABORTED). If the parameters of the swap have not been satisfied before the due date/time, the swap is aborted and the ICP tokens transferred back to their respective owners. The swap can also be aborted early if it is determined that the swap cannot possibly succeed, e.g., because the ICP ceiling has been reached and the minimum number of participants has not been. The `swap` canister can be deleted when all tokens registered with the `swap` canister have been disbursed to their rightful owners. The logic of this canister is based on the following principles. * Message fields are never removed. * Integer and enum fields can only have their values increase (with one exception, viz., the timestamp field for the start of a transfer is reset if the transfer fails). Data flow for the Neurons' Fund. - A SNS is created. - Proposal to open a decentralization swap for the SNS is submitted to the NNS. - ProposalToOpenDecentralizationSale - The Neurons' Fund investment amount - The parameters of the decentralization swap (`Params`). - Call to open swap: - Parameters - Neurons' Fund investments - NNS Proposal ID of the NNS proposal to open the swap. - On accept of proposal to open decentralization swap: - Compute the maturity contribution of each Neurons' Fund neuron and deduct this amount from the Neurons' Fund neuron. - The swap is informed about the corresponding amount of ICP (`CfParticipant`) in the call to open. - Call back to NNS governance after the swap is committed or aborted: - On committed swap: - Ask the NNS to mint the right amount of ICP for the SNS corresponding to the Neurons' Fund investment (the NNS governance canister keeps track of the total). - On aborted swap: - Send the information about Neurons' Fund participants (`CfParticipant`) back to NNS governance which will return it to the corresponding neurons. Assign the control of the dapp (now under the SNS control) back to the specified principals. - On reject of proposal to open decentralization swap: - Assign the control of the dapp (now under the SNS control) back to the specified principals.

Used in: GetStateResponse

message SweepResult

swap.proto:871

Used in: FinalizeSwapResponse

message Ticket

swap.proto:1346

A device for ensuring that retrying (direct) participation does not result in multiple participation. Basically, this records a user's intent to participate BEFORE moving any funds. How this is used: before any money is sent, a user's agent must first look for an existing ticket. If one does not exist, then, a new one is created for the current participation that is now being attempted (for the first time). If there is already a ticket, then the new participation must be aborted. The surprise existence of the ticket indicates that there is a pending participation. In this case the user's agent must attempt to perform the same participation as stated in the ticket before doing anything else.

Used in: GetOpenTicketResponse.Ok, NewSaleTicketResponse.Err, NewSaleTicketResponse.Ok, NotifyPaymentFailureResponse

message TimeWindow

swap.proto:688

Used in: SetOpenTimeWindowRequest

message TransferableAmount

swap.proto:624

Used in: BuyerState, SnsNeuronRecipe