Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Round based Launchpad #92

Merged
merged 3 commits into from
Jan 27, 2025
Merged

Round based Launchpad #92

merged 3 commits into from
Jan 27, 2025

Conversation

psorinionut
Copy link
Contributor

Updates all the Launchpad SCs to use rounds across the board. From setup to vesting.
Includes the refund user tickets functionality.

Copy link

Coverage Summary

Totals

Count Covered %
Lines 9685 9140 94.37
Regions 2260 1962 86.81
Functions 685 491 71.68
Instantiations 3441 1005 29.21

Files

Expand
File Lines Regions Functions Instantiations
/launchpad-common/src/blacklist.rs 96.88% 93.75% 80.00% 33.87%
/launchpad-common/src/common_events.rs 71.43% 29.41% 29.41% 26.67%
/launchpad-common/src/config.rs 30.00% 22.22% 22.22% 25.00%
/launchpad-common/src/launch_stage.rs 90.38% 80.00% 63.64% 38.33%
/launchpad-common/src/lib.rs 76.92% 50.00% 33.33% 26.92%
/launchpad-common/src/ongoing_operation.rs 61.29% 53.12% 53.85% 39.87%
/launchpad-common/src/permissions.rs 72.73% 60.00% 50.00% 13.64%
/launchpad-common/src/random.rs 55.81% 55.00% 30.00% 28.38%
/launchpad-common/src/setup.rs 46.39% 48.28% 37.50% 17.79%
/launchpad-common/src/tickets.rs 84.62% 67.74% 57.14% 36.61%
/launchpad-common/src/token_send.rs 94.87% 77.78% 60.00% 39.47%
/launchpad-common/src/user_interactions.rs 98.59% 95.65% 83.33% 34.52%
/launchpad-common/src/winner_selection.rs 88.31% 88.46% 80.00% 26.95%
/launchpad-guaranteed-tickets-v2/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/launchpad-guaranteed-tickets-v2/src/events.rs 87.74% 35.00% 35.00% 23.08%
/launchpad-guaranteed-tickets-v2/src/guaranteed_ticket_winners.rs 94.34% 88.41% 70.00% 35.00%
/launchpad-guaranteed-tickets-v2/src/guaranteed_tickets_init.rs 90.85% 75.47% 42.11% 32.69%
/launchpad-guaranteed-tickets-v2/src/lib.rs 89.39% 87.27% 82.35% 15.56%
/launchpad-guaranteed-tickets-v2/src/token_release.rs 87.10% 76.00% 38.89% 21.43%
/launchpad-guaranteed-tickets-v2/tests/guaranteed_tickets_setup/mod.rs 100.00% 100.00% 100.00% 100.00%
/launchpad-guaranteed-tickets-v2/tests/guaranteed_tickets_test.rs 100.00% 100.00% 100.00% 100.00%
/launchpad-guaranteed-tickets/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/launchpad-guaranteed-tickets/src/guaranteed_ticket_winners.rs 89.66% 80.65% 57.14% 32.84%
/launchpad-guaranteed-tickets/src/guaranteed_tickets_init.rs 95.79% 82.50% 66.67% 29.41%
/launchpad-guaranteed-tickets/src/lib.rs 88.40% 85.45% 87.50% 9.93%
/launchpad-guaranteed-tickets/src/token_release.rs 92.13% 74.07% 50.00% 8.33%
/launchpad-guaranteed-tickets/tests/guaranteed_tickets_setup/mod.rs 100.00% 100.00% 100.00% 100.00%
/launchpad-guaranteed-tickets/tests/guaranteed_tickets_test.rs 100.00% 100.00% 100.00% 100.00%
/launchpad-locked-tokens-and-guaranteed-tickets/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/launchpad-locked-tokens-and-guaranteed-tickets/src/lib.rs 84.88% 76.19% 72.73% 12.90%
/launchpad-locked-tokens-and-guaranteed-tickets/tests/guaranteed_tickets_setup/mod.rs 100.00% 100.00% 100.00% 100.00%
/launchpad-locked-tokens-and-guaranteed-tickets/tests/guaranteed_tickets_setup/simple_lock_mock.rs 70.89% 50.00% 37.50% 37.50%
/launchpad-locked-tokens-and-guaranteed-tickets/tests/locked_tokens_with_guaranteed_tickets_test.rs 100.00% 100.00% 100.00% 100.00%
/launchpad-locked-tokens/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/launchpad-locked-tokens/src/lib.rs 77.14% 50.00% 50.00% 7.69%
/launchpad-locked-tokens/src/locked_launchpad_token_send.rs 95.65% 78.95% 85.71% 40.00%
/launchpad-locked-tokens/tests/launchpad_locked_tokens_test.rs 87.83% 68.00% 61.54% 61.54%
/launchpad-migration-guaranteed-tickets/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/launchpad-migration-guaranteed-tickets/src/guaranteed_ticket_winners.rs 89.66% 80.65% 57.14% 17.78%
/launchpad-migration-guaranteed-tickets/src/guaranteed_tickets_init.rs 95.79% 82.50% 66.67% 21.74%
/launchpad-migration-guaranteed-tickets/src/lib.rs 77.00% 75.00% 76.92% 8.00%
/launchpad-migration-guaranteed-tickets/tests/migration_guaranteed_tickets_setup/mod.rs 100.00% 100.00% 100.00% 100.00%
/launchpad-migration-guaranteed-tickets/tests/migration_guaranteed_tickets_test.rs 100.00% 100.00% 100.00% 100.00%
/launchpad-nft-and-guaranteed-tickets/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/launchpad-nft-and-guaranteed-tickets/src/combined_selection.rs 85.37% 69.23% 60.00% 23.08%
/launchpad-nft-and-guaranteed-tickets/src/lib.rs 88.24% 80.00% 75.00% 11.54%
/launchpad-nft-and-guaranteed-tickets/tests/combined_selection_setup/mod.rs 94.15% 88.68% 88.89% 88.89%
/launchpad-nft-and-guaranteed-tickets/tests/combined_selection_test.rs 100.00% 100.00% 100.00% 100.00%
/launchpad-with-nft/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/launchpad-with-nft/src/claim_nft.rs 91.30% 85.71% 33.33% 12.50%
/launchpad-with-nft/src/confirm_nft.rs 97.56% 81.82% 80.00% 27.27%
/launchpad-with-nft/src/lib.rs 87.14% 73.33% 66.67% 6.06%
/launchpad-with-nft/src/mystery_sft.rs 56.67% 55.56% 40.00% 12.16%
/launchpad-with-nft/src/nft_blacklist.rs 85.71% 62.50% 33.33% 6.25%
/launchpad-with-nft/src/nft_config.rs 60.87% 62.50% 60.00% 13.64%
/launchpad-with-nft/src/nft_winners_selection.rs 81.82% 66.67% 50.00% 12.50%
/launchpad-with-nft/tests/launchpad_v2_test.rs 100.00% 100.00% 100.00% 100.00%
/launchpad-with-nft/tests/launchpad_with_nft_setup/mod.rs 100.00% 93.33% 100.00% 100.00%
/launchpad/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/launchpad/src/lib.rs 0.00% 0.00% 0.00% 0.00%

Comment on lines +98 to +103
#[endpoint(refundUserTickets)]
fn refund_user_tickets(&self, users_list: MultiValueEncoded<ManagedAddress>) {
let users_vec = users_list.to_vec();
self.add_users_to_blacklist(&users_vec);
self.clear_users_with_guaranteed_ticket_after_blacklist(&users_vec);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either simply call add_users_to_blacklist_endpoint, or, if the event is that important, make a common function blacklist_users where you do the common logic and just fire the event in add_users_to_blacklist_endpoint

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need the function to be without an event, like the blacklist method. I understand that it could be easier and more logical from the coding point of view to make a common function, but in this case, I think it is ok to actually have these lines separately, without what is out of scope.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@@ -5,11 +5,11 @@ use launchpad_common::{config, launch_stage};

pub const MAX_PERCENTAGE: u64 = 10_000;
pub const MAX_UNLOCK_MILESTONES_ENTRIES: usize = 60;
pub const MAX_RELEASE_EPOCH_DIFF: u64 = 1800;
pub const MAX_RELEASE_DIFF: u64 = 60 * 60 * 24 * 365 * 5;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a code reader, I have to think that this means... 5 years? Add a comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really. It was 5 years when we used timestamps. Now, If we get to a 0.6s round duration, it will be less that 5 years. But at the same time, I don't want to specify the constant's value based on what we assume will be the block duration. Maybe make the multiply and put the value directly?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a new, fixed value.

@psorinionut psorinionut merged commit f171bb0 into main Jan 27, 2025
6 checks passed
@psorinionut psorinionut deleted the round-based-launchpad branch January 27, 2025 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants