/
ic_sns_swap.pb.v1.rs
2250 lines (2250 loc) · 113 KB
/
ic_sns_swap.pb.v1.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/// 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.
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Swap {
/// The current lifecycle of the swap.
#[prost(enumeration = "Lifecycle", tag = "3")]
pub lifecycle: i32,
/// Specified on creation. That is, always specified and immutable.
#[prost(message, optional, tag = "1")]
pub init: ::core::option::Option<Init>,
/// Specified in the transition from PENDING to OPEN and immutable
/// thereafter.
#[prost(message, optional, tag = "4")]
pub params: ::core::option::Option<Params>,
/// Neurons' Fund participation. Specified in the transition from
/// PENDING to OPEN and immutable thereafter.
#[prost(message, repeated, tag = "5")]
pub cf_participants: ::prost::alloc::vec::Vec<CfParticipant>,
/// Empty in the PENDING state. In the OPEN state, new buyers can be
/// added and existing buyers can increase their bids. In the
/// COMMITTED and ABORTED states, the amount cannot be modified, and
/// the transfer timestamps are filled in.
///
/// The key is the textual representation of the buyer's principal
/// and the value represents the bid.
#[prost(btree_map = "string, message", tag = "6")]
pub buyers: ::prost::alloc::collections::BTreeMap<::prost::alloc::string::String, BuyerState>,
/// When the swap is committed, this field is initialized according
/// to the outcome of the swap.
#[prost(message, repeated, tag = "7")]
pub neuron_recipes: ::prost::alloc::vec::Vec<SnsNeuronRecipe>,
/// Gets set to whatever value is in the corresponding field of OpenRequest
/// (that field is required at the application level).
#[prost(uint64, optional, tag = "9")]
pub open_sns_token_swap_proposal_id: ::core::option::Option<u64>,
/// A lock stored in Swap state. If set to true, then a finalize_swap
/// call is in progress. In that case, new finalize_swap calls return
/// immediately without doing any real work.
///
/// The implementation of the lock should result in the lock being
/// released when the finalize_swap method returns. If
/// a lock is not released, upgrades of the Swap canister can
/// release the lock in the post upgrade hook.
#[prost(bool, optional, tag = "10")]
pub finalize_swap_in_progress: ::core::option::Option<bool>,
/// The timestamp for the actual opening of the swap, with an optional delay
/// (specified via params.sale_delay_seconds) after the adoption of the swap
/// proposal. Gets set when NNS calls `open` upon the adoption of
/// the swap proposal.
#[prost(uint64, optional, tag = "11")]
pub decentralization_sale_open_timestamp_seconds: ::core::option::Option<u64>,
/// The timestamp for the actual termination of the swap (committed or aborted).
#[prost(uint64, optional, tag = "21")]
pub decentralization_swap_termination_timestamp_seconds: ::core::option::Option<u64>,
/// This ticket id counter keeps track of the latest ticket id. Whenever a new
/// ticket is created this counter is incremented. It ensures that ticket ids
/// are unique. The ticket IDs are sequential and next_ticket_id is assigned to
/// a users new ticket upon successfully requesting a new ticket. It is
/// incremented after a user requests a new ticket successfully.
#[prost(uint64, optional, tag = "12")]
pub next_ticket_id: ::core::option::Option<u64>,
/// The last time the purge_old_tickets routine was completed.
#[prost(uint64, optional, tag = "13")]
pub purge_old_tickets_last_completion_timestamp_nanoseconds: ::core::option::Option<u64>,
/// The next principal bytes that should be checked by the next
/// running purge_old_tickets routine.
#[prost(bytes = "vec", optional, tag = "14")]
#[serde(deserialize_with = "ic_utils::deserialize::deserialize_option_blob")]
pub purge_old_tickets_next_principal: ::core::option::Option<::prost::alloc::vec::Vec<u8>>,
/// Set to true when auto-finalization is attempted. Prevents auto-finalization
/// from being attempted more than once.
#[prost(bool, optional, tag = "17")]
pub already_tried_to_auto_finalize: ::core::option::Option<bool>,
/// Set when auto-finalization finishes. Calling finalize manually has no effect
/// on this parameter.
#[prost(message, optional, tag = "18")]
pub auto_finalize_swap_response: ::core::option::Option<FinalizeSwapResponse>,
/// Amount of contributions from direct participants committed to this SNS so far.
#[prost(uint64, optional, tag = "19")]
pub direct_participation_icp_e8s: ::core::option::Option<u64>,
/// Amount of contributions from the Neurons' Fund committed to this SNS so far.
#[prost(uint64, optional, tag = "20")]
pub neurons_fund_participation_icp_e8s: ::core::option::Option<u64>,
}
/// 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.
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Init {
/// The canister ID of the NNS governance canister. This is the only
/// principal that can open the swap.
#[prost(string, tag = "1")]
pub nns_governance_canister_id: ::prost::alloc::string::String,
/// The canister ID of the governance canister of the SNS that this
/// token swap pertains to.
#[prost(string, tag = "2")]
pub sns_governance_canister_id: ::prost::alloc::string::String,
/// The ledger canister of the SNS.
#[prost(string, tag = "3")]
pub sns_ledger_canister_id: ::prost::alloc::string::String,
/// The ledger canister for the base token, typically ICP. The base
/// token is typically ICP, but this assumption is not used anywhere,
/// so, in principle, any token type can be used as base token.
#[prost(string, tag = "4")]
pub icp_ledger_canister_id: ::prost::alloc::string::String,
/// Analogous to `sns_governance_canister_id`, but for the "root"
/// canister instead of the governance canister.
#[prost(string, tag = "12")]
pub sns_root_canister_id: ::prost::alloc::string::String,
/// If the swap is aborted, control of the canister(s) should be set to these
/// principals. Must not be empty.
#[prost(string, repeated, tag = "11")]
pub fallback_controller_principal_ids: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// Same as SNS ledger. Must hold the same value as SNS ledger. Whether the
/// values match is not checked. If they don't match things will break.
#[prost(uint64, optional, tag = "13")]
pub transaction_fee_e8s: ::core::option::Option<u64>,
/// Same as SNS governance. Must hold the same value as SNS governance. Whether
/// the values match is not checked. If they don't match things will break.
#[prost(uint64, optional, tag = "14")]
pub neuron_minimum_stake_e8s: ::core::option::Option<u64>,
/// An optional text that swap participants should confirm before they may
/// participate in the swap. If the field is set, its value should be plain
/// text with at least 1 and at most 1,000 characters.
#[prost(string, optional, tag = "15")]
pub confirmation_text: ::core::option::Option<::prost::alloc::string::String>,
/// An optional set of countries that should not participate in the swap.
#[prost(message, optional, tag = "16")]
pub restricted_countries: ::core::option::Option<::ic_nervous_system_proto::pb::v1::Countries>,
/// The minimum number of buyers that must participate for the swap
/// to take place. Must be greater than zero.
#[prost(uint32, optional, tag = "17")]
pub min_participants: ::core::option::Option<u32>,
/// The total number of ICP that is required for this token swap to
/// take place. This number divided by the number of SNS tokens being
/// offered gives the seller's reserve price for the swap, i.e., the
/// minimum number of ICP per SNS tokens that the seller of SNS
/// tokens is willing to accept. If this amount is not achieved, the
/// swap will be aborted (instead of committed) when the due date/time
/// occurs. Must be smaller than or equal to `max_icp_e8s`.
#[prost(uint64, optional, tag = "18")]
pub min_icp_e8s: ::core::option::Option<u64>,
/// The number of ICP that is "targeted" by this token swap. If this
/// amount is achieved with sufficient participation, the swap will be
/// triggered immediately, without waiting for the due date
/// (`end_timestamp_seconds`). This means that an investor knows the minimum
/// number of SNS tokens received per invested ICP. If this amount is achieved
/// without reaching sufficient_participation, the swap will abort without
/// waiting for the due date. Must be at least
/// `min_participants * min_participant_icp_e8s`
#[prost(uint64, optional, tag = "19")]
pub max_icp_e8s: ::core::option::Option<u64>,
/// The total number of ICP that is required to be "directly contributed"
/// for this token swap to take place. This number divided by the number of SNS tokens being
/// offered gives the seller's reserve price for the swap, i.e., the
/// minimum number of ICP per SNS tokens that the seller of SNS
/// tokens is willing to accept. If this amount is not achieved, the
/// swap will be aborted (instead of committed) when the due date/time
/// occurs. Must be smaller than or equal to `max_icp_e8s`.
#[prost(uint64, optional, tag = "30")]
pub min_direct_participation_icp_e8s: ::core::option::Option<u64>,
/// The number of ICP that is "targeted" by this token swap. If this
/// amount is achieved with sufficient participation, the swap will be
/// triggered immediately, without waiting for the due date
/// (`end_timestamp_seconds`). This means that an investor knows the minimum
/// number of SNS tokens received per invested ICP. If this amount is achieved
/// without reaching sufficient_participation, the swap will abort without
/// waiting for the due date. Must be at least
/// `min_participants * min_participant_icp_e8s`.
#[prost(uint64, optional, tag = "31")]
pub max_direct_participation_icp_e8s: ::core::option::Option<u64>,
/// The minimum amount of ICP that each buyer must contribute to
/// participate. Must be greater than zero.
#[prost(uint64, optional, tag = "20")]
pub min_participant_icp_e8s: ::core::option::Option<u64>,
/// The maximum amount of ICP that each buyer can contribute. Must be
/// greater than or equal to `min_participant_icp_e8s` and less than
/// or equal to `max_icp_e8s`. Can effectively be disabled by
/// setting it to `max_icp_e8s`.
#[prost(uint64, optional, tag = "21")]
pub max_participant_icp_e8s: ::core::option::Option<u64>,
/// The date/time when the swap should start.
#[prost(uint64, optional, tag = "22")]
pub swap_start_timestamp_seconds: ::core::option::Option<u64>,
/// The date/time when the swap is due, i.e., it will automatically
/// end and commit or abort depending on whether the parameters have
/// been fulfilled.
#[prost(uint64, optional, tag = "23")]
pub swap_due_timestamp_seconds: ::core::option::Option<u64>,
/// The number of tokens (of `init.sns_ledger_canister_id`) that are
/// being offered. The tokens are held in escrow for the SNS
/// governance canister.
///
/// Invariant for the OPEN state:
/// ```text
/// state.sns_token_e8s <= token_ledger.balance_of(<swap-canister>)
/// ```
#[prost(uint64, optional, tag = "24")]
pub sns_token_e8s: ::core::option::Option<u64>,
/// The construction parameters for the basket of neurons created for all
/// investors in the decentralization swap. Each investor, whether via
/// the Neurons' Fund or direct, will receive `count` Neurons with
/// increasing dissolve delays. The total number of Tokens swapped for
/// by the investor will be evenly distributed across the basket. This is
/// effectively a vesting schedule to ensure there is a gradual release of
/// SNS Tokens available to all investors instead of being liquid immediately.
/// See `NeuronBasketConstructionParameters` for more details on how
/// the basket is configured.
#[prost(message, optional, tag = "25")]
pub neuron_basket_construction_parameters:
::core::option::Option<NeuronBasketConstructionParameters>,
/// The ID of the NNS proposal submitted to launch this SNS decentralization
/// swap.
#[prost(uint64, optional, tag = "26")]
pub nns_proposal_id: ::core::option::Option<u64>,
/// The Neurons' Fund participants of this SNS decentralization swap.
#[prost(message, optional, tag = "27")]
pub neurons_fund_participants: ::core::option::Option<NeuronsFundParticipants>,
/// Controls whether swap finalization should be attempted automatically in the
/// canister heartbeat. If set to false, `finalize_swap` must be called
/// manually. Note: it is safe to call `finalize_swap` multiple times
/// (regardless of the value of this field).
#[prost(bool, optional, tag = "28")]
pub should_auto_finalize: ::core::option::Option<bool>,
/// Constraints for the Neurons' Fund participation in this swap.
#[prost(message, optional, tag = "29")]
pub neurons_fund_participation_constraints:
::core::option::Option<NeuronsFundParticipationConstraints>,
/// Whether Neurons' Fund participation is requested.
#[prost(bool, optional, tag = "32")]
pub neurons_fund_participation: ::core::option::Option<bool>,
}
/// Constraints for the Neurons' Fund participation in an SNS swap.
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable, Eq)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct NeuronsFundParticipationConstraints {
/// The Neurons' Fund will not participate in this swap unless the direct
/// contributions reach this threshold (in ICP e8s).
#[prost(uint64, optional, tag = "1")]
pub min_direct_participation_threshold_icp_e8s: ::core::option::Option<u64>,
/// Maximum amount (in ICP e8s) of contributions from the Neurons' Fund to this swap.
#[prost(uint64, optional, tag = "2")]
pub max_neurons_fund_participation_icp_e8s: ::core::option::Option<u64>,
/// List of intervals in which the given linear coefficients apply for scaling the
/// ideal Neurons' Fund participation amount (down) to the effective Neurons' Fund
/// participation amount.
#[prost(message, repeated, tag = "3")]
pub coefficient_intervals: ::prost::alloc::vec::Vec<LinearScalingCoefficient>,
/// The function used in the implementation of Matched Funding for mapping amounts of direct
/// participation to "ideal" Neurons' Fund participation amounts. The value needs to be adjusted
/// to a potentially smaller value due to SNS-specific participation constraints and
/// the configuration of the Neurons' Fund at the time of the CreateServiceNervousSystem proposal
/// execution.
#[prost(message, optional, tag = "4")]
pub ideal_matched_participation_function:
::core::option::Option<IdealMatchedParticipationFunction>,
}
/// 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.
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable, Eq)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct IdealMatchedParticipationFunction {
/// The encoding of the "ideal" matched participation function is defined in `crate::neurons_fund`.
/// In the future, we could change this message to represent full abstract syntactic trees
/// comprised of elementary mathematical operators, with literals and variables as tree leaves.
#[prost(string, optional, tag = "1")]
pub serialized_representation: ::core::option::Option<::prost::alloc::string::String>,
}
/// 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.
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable, Eq)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LinearScalingCoefficient {
/// (Included) lower bound on the amount of direct participation (in ICP e8s) at which
/// these coefficients apply.
#[prost(uint64, optional, tag = "1")]
pub from_direct_participation_icp_e8s: ::core::option::Option<u64>,
/// (Excluded) upper bound on the amount of direct participation (in ICP e8s) at which
/// these coefficients apply.
#[prost(uint64, optional, tag = "2")]
pub to_direct_participation_icp_e8s: ::core::option::Option<u64>,
/// Numerator or the slope of the linear transformation.
#[prost(uint64, optional, tag = "3")]
pub slope_numerator: ::core::option::Option<u64>,
/// Denominator or the slope of the linear transformation.
#[prost(uint64, optional, tag = "4")]
pub slope_denominator: ::core::option::Option<u64>,
/// Intercept of the linear transformation (in ICP e8s).
#[prost(uint64, optional, tag = "5")]
pub intercept_icp_e8s: ::core::option::Option<u64>,
}
/// Represents multiple Neurons' Fund participants.
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct NeuronsFundParticipants {
#[prost(message, repeated, tag = "1")]
pub cf_participants: ::prost::alloc::vec::Vec<CfParticipant>,
}
/// Represents one NNS neuron from the Neurons' Fund participating in this swap.
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable, Eq)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CfNeuron {
/// The NNS neuron ID of the participating neuron.
#[prost(fixed64, tag = "1")]
pub nns_neuron_id: u64,
/// The amount of ICP that the Neurons' Fund invests associated
/// with this neuron.
#[prost(uint64, tag = "2")]
pub amount_icp_e8s: u64,
/// Idempotency flag indicating whether the neuron recipes have been created for
/// the CfNeuron. When set to true, it signifies that the action of creating neuron
/// recipes has been performed on this structure. If the action is retried, this flag
/// can be checked to avoid duplicate operations.
#[prost(bool, optional, tag = "3")]
pub has_created_neuron_recipes: ::core::option::Option<bool>,
}
/// Represents a Neurons' Fund participant, possibly with several neurons.
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable, Eq)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CfParticipant {
/// The principal that can vote on behalf of these Neurons' Fund neurons.
#[prost(string, tag = "1")]
pub hotkey_principal: ::prost::alloc::string::String,
/// Information about the participating neurons. Must not be empty.
#[prost(message, repeated, tag = "2")]
pub cf_neurons: ::prost::alloc::vec::Vec<CfNeuron>,
}
/// The construction parameters for the basket of neurons created for all
/// investors in the decentralization swap.
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable, Eq)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct NeuronBasketConstructionParameters {
/// The number of neurons each investor will receive after the
/// decentralization swap. The total tokens swapped for will be
/// evenly distributed across the `count` neurons.
#[prost(uint64, tag = "1")]
pub count: u64,
/// The amount of additional time it takes for the next neuron to dissolve.
#[prost(uint64, tag = "2")]
pub dissolve_delay_interval_seconds: u64,
}
/// The parameters of the swap, provided in the call to `open`. Cannot
/// be modified after the call to `open`.
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Params {
/// The minimum number of buyers that must participate for the swap
/// to take place. Must be greater than zero.
#[prost(uint32, tag = "1")]
pub min_participants: u32,
/// The total number of ICP that is required for this token swap to
/// take place. This number divided by the number of SNS tokens being
/// offered gives the seller's reserve price for the swap, i.e., the
/// minimum number of ICP per SNS tokens that the seller of SNS
/// tokens is willing to accept. If this amount is not achieved, the
/// swap will be aborted (instead of committed) when the due date/time
/// occurs. Must be smaller than or equal to `max_icp_e8s`.
#[prost(uint64, tag = "2")]
pub min_icp_e8s: u64,
/// The number of ICP that is "targeted" by this token swap. If this
/// amount is achieved with sufficient participation, the swap will be
/// triggered immediately, without waiting for the due date
/// (`end_timestamp_seconds`). This means that an investor knows the minimum
/// number of SNS tokens received per invested ICP. If this amount is achieved
/// without reaching sufficient_participation, the swap will abort without
/// waiting for the due date. Must be at least
/// `min_participants * min_participant_icp_e8s`.
#[prost(uint64, tag = "3")]
pub max_icp_e8s: u64,
/// The total number of ICP that is required for this token swap to
/// take place. This number divided by the number of SNS tokens being
/// offered gives the seller's reserve price for the swap, i.e., the
/// minimum number of ICP per SNS tokens that the seller of SNS
/// tokens is willing to accept. If this amount is not achieved, the
/// swap will be aborted (instead of committed) when the due date/time
/// occurs. Must be smaller than or equal to `max_icp_e8s`.
#[prost(uint64, optional, tag = "10")]
pub min_direct_participation_icp_e8s: ::core::option::Option<u64>,
/// The number of ICP that is "targeted" by this token swap. If this
/// amount is achieved with sufficient participation, the swap will be
/// triggered immediately, without waiting for the due date
/// (`end_timestamp_seconds`). This means that an investor knows the minimum
/// number of SNS tokens received per invested ICP. If this amount is achieved
/// without reaching sufficient_participation, the swap will abort without
/// waiting for the due date. Must be at least
/// `min_participants * min_participant_icp_e8s`.
#[prost(uint64, optional, tag = "11")]
pub max_direct_participation_icp_e8s: ::core::option::Option<u64>,
/// The minimum amount of ICP that each buyer must contribute to
/// participate. Must be greater than zero.
#[prost(uint64, tag = "4")]
pub min_participant_icp_e8s: u64,
/// The maximum amount of ICP that each buyer can contribute. Must be
/// greater than or equal to `min_participant_icp_e8s` and less than
/// or equal to `max_icp_e8s`. Can effectively be disabled by
/// setting it to `max_icp_e8s`.
#[prost(uint64, tag = "5")]
pub max_participant_icp_e8s: u64,
/// The date/time when the swap is due, i.e., it will automatically
/// end and commit or abort depending on whether the parameters have
/// been fulfilled.
#[prost(uint64, tag = "6")]
pub swap_due_timestamp_seconds: u64,
/// The number of tokens (of `init.sns_ledger_canister_id`) that are
/// being offered. The tokens are held in escrow for the SNS
/// governance canister.
///
/// Invariant for the OPEN state:
/// ```text
/// state.sns_token_e8s <= token_ledger.balance_of(<swap-canister>)
/// ```
#[prost(uint64, tag = "7")]
pub sns_token_e8s: u64,
/// The construction parameters for the basket of neurons created for all
/// investors in the decentralization swap. Each investor, whether via
/// the Neurons' Fund or direct, will receive `count` Neurons with
/// increasing dissolve delays. The total number of Tokens swapped for
/// by the investor will be evenly distributed across the basket. This is
/// effectively a vesting schedule to ensure there is a gradual release of
/// SNS Tokens available to all investors instead of being liquid immediately.
/// See `NeuronBasketConstructionParameters` for more details on how
/// the basket is configured.
#[prost(message, optional, tag = "8")]
pub neuron_basket_construction_parameters:
::core::option::Option<NeuronBasketConstructionParameters>,
/// An optional delay, so that the actual swap does not get opened immediately
/// after the adoption of the swap proposal.
#[prost(uint64, optional, tag = "9")]
pub sale_delay_seconds: ::core::option::Option<u64>,
}
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TransferableAmount {
/// The amount in e8s equivalent that the participant committed to the Swap,
/// which is held by the swap canister until the swap is committed or aborted.
#[prost(uint64, tag = "1")]
pub amount_e8s: u64,
/// When the transfer to refund or commit funds starts.
#[prost(uint64, tag = "2")]
pub transfer_start_timestamp_seconds: u64,
/// When the transfer to refund or commit succeeds.
#[prost(uint64, tag = "3")]
pub transfer_success_timestamp_seconds: u64,
/// The amount that was successfully transferred when swap commits or aborts
/// (minus fees).
#[prost(uint64, optional, tag = "4")]
pub amount_transferred_e8s: ::core::option::Option<u64>,
/// The fee charged when transferring from the swap canister;
#[prost(uint64, optional, tag = "5")]
pub transfer_fee_paid_e8s: ::core::option::Option<u64>,
}
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BuyerState {
/// The amount of ICP accepted from this buyer. ICP is accepted by
/// first making a ledger transfer and then calling the method
/// `refresh_buyer_token_e8s`.
///
/// Can only be set when a buyer state record for a new buyer is
/// created, which can only happen when the lifecycle state is
/// `Open`. Must be at least `min_participant_icp_e8s`, and at most
/// `max_participant_icp_e8s`.
///
/// Invariant between canisters in the OPEN state:
///
/// ```text
/// icp.amount_e8 <= icp_ledger.balance_of(subaccount(swap_canister, P)),
/// ```
///
/// where `P` is the principal ID associated with this buyer's state.
///
/// ownership
/// * PENDING - a `BuyerState` cannot exist
/// * OPEN - owned by the buyer, cannot be transferred out
/// * COMMITTED - owned by the SNS governance canister, can be transferred out
/// * ABORTED - owned by the buyer, can be transferred out
#[prost(message, optional, tag = "5")]
pub icp: ::core::option::Option<TransferableAmount>,
/// Idempotency flag indicating whether the neuron recipes have been created for
/// the BuyerState. When set to true, it signifies that the action of creating neuron
/// recipes has been performed on this structure. If the action is retried, this flag
/// can be checked to avoid duplicate operations.
#[prost(bool, optional, tag = "6")]
pub has_created_neuron_recipes: ::core::option::Option<bool>,
}
/// Information about a direct investor.
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DirectInvestment {
#[prost(string, tag = "1")]
pub buyer_principal: ::prost::alloc::string::String,
}
/// Information about a Neurons' Fund investment. The NNS Governance
/// canister is the controller of these neurons.
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CfInvestment {
#[prost(string, tag = "1")]
pub hotkey_principal: ::prost::alloc::string::String,
#[prost(fixed64, tag = "2")]
pub nns_neuron_id: u64,
}
#[derive(
candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable, Copy,
)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TimeWindow {
#[prost(uint64, tag = "1")]
pub start_timestamp_seconds: u64,
#[prost(uint64, tag = "2")]
pub end_timestamp_seconds: u64,
}
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SnsNeuronRecipe {
#[prost(message, optional, tag = "1")]
pub sns: ::core::option::Option<TransferableAmount>,
/// Attributes of the Neuron to be created from the SnsNeuronRecipe
#[prost(message, optional, tag = "4")]
pub neuron_attributes: ::core::option::Option<sns_neuron_recipe::NeuronAttributes>,
/// The status of the SnsNeuronRecipe's creation within SNS Governance. This
/// field is used as a journal between calls of `finalize`.
#[prost(enumeration = "sns_neuron_recipe::ClaimedStatus", optional, tag = "5")]
pub claimed_status: ::core::option::Option<i32>,
#[prost(oneof = "sns_neuron_recipe::Investor", tags = "2, 3")]
pub investor: ::core::option::Option<sns_neuron_recipe::Investor>,
}
/// Nested message and enum types in `SnsNeuronRecipe`.
pub mod sns_neuron_recipe {
/// Attributes of the Neuron to be created from the SnsNeuronRecipe
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct NeuronAttributes {
/// The memo to be used when calculating the Neuron's staking account
/// in the SNS Ledger.
/// See `nervous_system_common::compute_neuron_staking_subaccount`.
/// The memo is used along with the a principal_id of the "controller" of
/// the neuron. In the case of the decentralization sale, that will either be
/// the PrincipalId of NNS Governance canister for Neurons' Fund investors,
/// or the PrincipalId of the direct investor.
#[prost(uint64, tag = "1")]
pub memo: u64,
/// The dissolve delay in seconds that the Neuron will be created with.
#[prost(uint64, tag = "2")]
pub dissolve_delay_seconds: u64,
/// The list of NeuronIds that the created Neuron will follow on all SNS
/// proposal actions known to governance at the time. Additional followees
/// and following relations can be added after neuron creation.
///
/// TODO\[NNS1-1589\] Due to the dependency cycle, the `swap` canister's
/// protobuf cannot directly depend on SNS Governance NeuronId type.
/// The followees NeuronId's are of a duplicated type, which is converted to
/// SNS governance NeuronId at the time.
/// of claiming.
#[prost(message, repeated, tag = "3")]
pub followees: ::prost::alloc::vec::Vec<super::NeuronId>,
}
/// The various statuses of creation that a SnsNeuronRecipe can have in an SNS.
#[derive(
candid::CandidType,
candid::Deserialize,
serde::Serialize,
comparable::Comparable,
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration,
)]
#[repr(i32)]
pub enum ClaimedStatus {
/// Unused, here for PB lint purposes.
Unspecified = 0,
/// The Neuron is pending creation and can be claimed in SNS Governance.
Pending = 1,
/// The Neuron has been created successfully in SNS Governance.
Success = 2,
/// The Neuron has previously failed to be created in SNS Governance, but can
/// be retried in the future.
Failed = 3,
/// The Neuron is invalid and was not created in SNS Governance. This neuron
/// cannot be retried without manual intervention to update its
/// `NeuronParameters`.
Invalid = 4,
}
impl ClaimedStatus {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
ClaimedStatus::Unspecified => "CLAIMED_STATUS_UNSPECIFIED",
ClaimedStatus::Pending => "CLAIMED_STATUS_PENDING",
ClaimedStatus::Success => "CLAIMED_STATUS_SUCCESS",
ClaimedStatus::Failed => "CLAIMED_STATUS_FAILED",
ClaimedStatus::Invalid => "CLAIMED_STATUS_INVALID",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"CLAIMED_STATUS_UNSPECIFIED" => Some(Self::Unspecified),
"CLAIMED_STATUS_PENDING" => Some(Self::Pending),
"CLAIMED_STATUS_SUCCESS" => Some(Self::Success),
"CLAIMED_STATUS_FAILED" => Some(Self::Failed),
"CLAIMED_STATUS_INVALID" => Some(Self::Invalid),
_ => None,
}
}
}
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Investor {
#[prost(message, tag = "2")]
Direct(super::DirectInvestment),
#[prost(message, tag = "3")]
CommunityFund(super::CfInvestment),
}
}
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct OpenRequest {
/// The parameters of the swap.
#[prost(message, optional, tag = "1")]
pub params: ::core::option::Option<Params>,
/// Neurons' Fund participation.
#[prost(message, repeated, tag = "2")]
pub cf_participants: ::prost::alloc::vec::Vec<CfParticipant>,
/// The ID of the proposal whose execution consists of calling this method.
#[prost(uint64, optional, tag = "3")]
pub open_sns_token_swap_proposal_id: ::core::option::Option<u64>,
}
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct OpenResponse {}
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetCanisterStatusRequest {}
/// TODO: introduce a limits on the number of buyers to include?
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetStateRequest {}
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetStateResponse {
#[prost(message, optional, tag = "1")]
pub swap: ::core::option::Option<Swap>,
#[prost(message, optional, tag = "2")]
pub derived: ::core::option::Option<DerivedState>,
}
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetBuyerStateRequest {
/// The principal_id of the user who's buyer state is being queried for.
#[prost(message, optional, tag = "1")]
pub principal_id: ::core::option::Option<::ic_base_types::PrincipalId>,
}
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetBuyerStateResponse {
#[prost(message, optional, tag = "1")]
pub buyer_state: ::core::option::Option<BuyerState>,
}
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetBuyersTotalRequest {}
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetBuyersTotalResponse {
/// The total amount of ICP deposited by buyers.
#[prost(uint64, tag = "1")]
pub buyers_total: u64,
}
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DerivedState {
#[prost(uint64, tag = "1")]
pub buyer_total_icp_e8s: u64,
/// Current number of non-Neurons' Fund swap participants
#[prost(uint64, optional, tag = "3")]
pub direct_participant_count: ::core::option::Option<u64>,
/// Current number of Neurons' Fund swap participants. In particular, it's the
/// number of unique controllers of the neurons participating
/// in the Neurons' Fund.
#[prost(uint64, optional, tag = "4")]
pub cf_participant_count: ::core::option::Option<u64>,
/// Current number of Neurons' Fund neurons participating in the swap
/// May be greater than cf_participant_count if multiple neurons in
/// the Neurons' Fund have the same controller.
#[prost(uint64, optional, tag = "5")]
pub cf_neuron_count: ::core::option::Option<u64>,
/// Current approximate rate SNS tokens per ICP. Note that this should not be used for super
/// precise financial accounting, because this is floating point.
#[prost(float, tag = "2")]
pub sns_tokens_per_icp: f32,
/// Current amount of contributions from direct swap participants.
#[prost(uint64, optional, tag = "6")]
pub direct_participation_icp_e8s: ::core::option::Option<u64>,
/// Current amount that the Neurons' Fund promises to participate with if the swap were to
/// successfully finalize now. Until the swap's success criterium is satisfied, this value is
/// merely a progress indicator.
#[prost(uint64, optional, tag = "7")]
pub neurons_fund_participation_icp_e8s: ::core::option::Option<u64>,
}
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SetOpenTimeWindowRequest {
/// Duration must be between 1 and 90 days. The TimeWindow's
/// end time but be greater than or equal to the TimeWindow's
/// start time.
#[prost(message, optional, tag = "1")]
pub open_time_window: ::core::option::Option<TimeWindow>,
}
/// Response if setting the open time window succeeded.
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SetOpenTimeWindowResponse {}
/// Informs the swap canister that a buyer has sent funds to participate in the
/// swap.
///
/// Only in lifecycle state `open`.
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RefreshBuyerTokensRequest {
/// If not specified, the caller is used.
#[prost(string, tag = "1")]
pub buyer: ::prost::alloc::string::String,
/// To accept the swap participation confirmation, a participant should send
/// the confirmation text via refresh_buyer_tokens, matching the text set
/// during SNS initialization.
#[prost(string, optional, tag = "2")]
pub confirmation_text: ::core::option::Option<::prost::alloc::string::String>,
}
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RefreshBuyerTokensResponse {
#[prost(uint64, tag = "1")]
pub icp_accepted_participation_e8s: u64,
#[prost(uint64, tag = "2")]
pub icp_ledger_account_balance_e8s: u64,
}
/// Once a swap is committed or aborted, the tokens need to be
/// distributed, and, if the swap was committed, neurons created.
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FinalizeSwapRequest {}
/// Response from the `finalize_swap` canister API.
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FinalizeSwapResponse {
#[prost(message, optional, tag = "1")]
pub sweep_icp_result: ::core::option::Option<SweepResult>,
#[prost(message, optional, tag = "2")]
pub sweep_sns_result: ::core::option::Option<SweepResult>,
#[prost(message, optional, tag = "3")]
pub claim_neuron_result: ::core::option::Option<SweepResult>,
#[prost(message, optional, tag = "4")]
pub set_mode_call_result: ::core::option::Option<SetModeCallResult>,
#[prost(message, optional, tag = "5")]
pub set_dapp_controllers_call_result: ::core::option::Option<SetDappControllersCallResult>,
#[prost(message, optional, tag = "6")]
pub settle_community_fund_participation_result:
::core::option::Option<SettleCommunityFundParticipationResult>,
#[prost(message, optional, tag = "8")]
pub create_sns_neuron_recipes_result: ::core::option::Option<SweepResult>,
#[prost(message, optional, tag = "9")]
pub settle_neurons_fund_participation_result:
::core::option::Option<SettleNeuronsFundParticipationResult>,
/// Explains what (if anything) went wrong.
#[prost(string, optional, tag = "7")]
pub error_message: ::core::option::Option<::prost::alloc::string::String>,
}
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SweepResult {
/// Success means that on this call to finalize, the item in the
/// sweep succeeded.
#[prost(uint32, tag = "1")]
pub success: u32,
/// Failure means that on this call to finalize, the item in the
/// sweep failed but may be successful in the future.
#[prost(uint32, tag = "2")]
pub failure: u32,
/// Skipped means that on a previous call to finalize, the item
/// in the sweep was successful.
#[prost(uint32, tag = "3")]
pub skipped: u32,
/// Invalid means that on this call and all future calls to finalize,