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

feat: pump and dump implementation #485

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

175 changes: 100 additions & 75 deletions src/canister/individual_user_template/can.did
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ type FractionalDeveloperVotingPower = record {
airdrop_distribution : opt AirdropDistribution;
swap_distribution : opt SwapDistribution;
};
type GameDirection = variant { Dump; Pump };
type GetPostsOfUserProfileError = variant {
ReachedEndOfItemsList;
InvalidBoundsPassed;
Expand Down Expand Up @@ -182,6 +183,7 @@ type KnownPrincipalType = variant {
CanisterIdTopicCacheIndex;
CanisterIdRootCanister;
CanisterIdDataBackup;
CanisterIdSnsLedger;
CanisterIdSnsWasm;
CanisterIdPostCache;
CanisterIdSNSController;
Expand Down Expand Up @@ -268,6 +270,13 @@ type PaginationError = variant {
InvalidBoundsPassed;
ExceededMaxNumberOfItemsAllowedInOneRequest;
};
type ParticipatedGameInfo = record {
game_direction : GameDirection;
reward : nat;
pumps : nat64;
dumps : nat64;
token_root : principal;
};
type PlaceBetArg = record {
bet_amount : nat64;
post_id : nat64;
Expand Down Expand Up @@ -347,6 +356,11 @@ type PostViewStatistics = record {
threshold_view_count : nat64;
};
type Principals = record { principals : vec principal };
type PumpNDumpStateDiff = variant {
Participant : ParticipatedGameInfo;
CreatorReward : nat;
};
type PumpsAndDumps = record { pumps : nat; dumps : nat };
type RejectionCode = variant {
NoError;
CanisterError;
Expand All @@ -357,47 +371,48 @@ type RejectionCode = variant {
CanisterReject;
};
type Result = variant { Ok : bool; Err : text };
type Result_1 = variant { Ok : nat64; Err : text };
type Result_10 = variant { Ok : Post; Err };
type Result_11 = variant { Ok : SystemTime; Err : text };
type Result_12 = variant {
type Result_1 = variant { Ok; Err : text };
type Result_10 = variant { Ok : BetDetails; Err : text };
type Result_11 = variant { Ok : Post; Err };
type Result_12 = variant { Ok : SystemTime; Err : text };
type Result_13 = variant {
Ok : vec PostDetailsForFrontend;
Err : GetPostsOfUserProfileError;
};
type Result_13 = variant { Ok : SessionType; Err : text };
type Result_14 = variant { Ok : vec SuccessHistoryItemV1; Err : text };
type Result_15 = variant { Ok : vec principal; Err : PaginationError };
type Result_16 = variant {
type Result_14 = variant { Ok : SessionType; Err : text };
type Result_15 = variant { Ok : vec SuccessHistoryItemV1; Err : text };
type Result_16 = variant { Ok : vec principal; Err : PaginationError };
type Result_17 = variant {
Ok : vec record { nat64; TokenEvent };
Err : PaginationError;
};
type Result_17 = variant { Ok : vec WatchHistoryItem; Err : text };
type Result_18 = variant { Ok : vec text; Err : NamespaceErrors };
type Result_19 = variant { Ok : vec record { nat64; nat8 }; Err : text };
type Result_2 = variant { Ok : bool; Err : CdaoTokenError };
type Result_20 = variant { Ok; Err : MigrationErrors };
type Result_21 = variant { Ok; Err : AirdropError };
type Result_22 = variant { Ok : text; Err : text };
type Result_23 = variant { Ok : IndividualUserCreatorDaoEntry; Err : text };
type Result_24 = variant { Committed : Committed; Aborted : record {} };
type Result_25 = variant { Ok : Ok; Err : GovernanceError };
type Result_26 = variant { Ok; Err : CdaoTokenError };
type Result_27 = variant {
type Result_18 = variant { Ok : vec WatchHistoryItem; Err : text };
type Result_19 = variant { Ok : vec text; Err : NamespaceErrors };
type Result_2 = variant { Ok : nat64; Err : text };
type Result_20 = variant { Ok : vec record { nat64; nat8 }; Err : text };
type Result_21 = variant { Ok : vec ParticipatedGameInfo; Err : text };
type Result_22 = variant { Ok; Err : MigrationErrors };
type Result_23 = variant { Ok; Err : AirdropError };
type Result_24 = variant { Ok : text; Err : text };
type Result_25 = variant { Ok : IndividualUserCreatorDaoEntry; Err : text };
type Result_26 = variant { Committed : Committed; Aborted : record {} };
type Result_27 = variant { Ok : Ok; Err : GovernanceError };
type Result_28 = variant { Ok; Err : CdaoTokenError };
type Result_29 = variant {
Ok : UserProfileDetailsForFrontend;
Err : UpdateProfileDetailsError;
};
type Result_28 = variant { Ok; Err : text };
type Result_29 = variant { Ok; Err : UpdateProfileSetUniqueUsernameError };
type Result_3 = variant {
type Result_3 = variant { Ok : bool; Err : CdaoTokenError };
type Result_30 = variant { Ok; Err : UpdateProfileSetUniqueUsernameError };
type Result_4 = variant {
Ok : BettingStatus;
Err : BetOnCurrentlyViewingPostError;
};
type Result_4 = variant { Ok : NamespaceForFrontend; Err : NamespaceErrors };
type Result_5 = variant { Ok : opt text; Err : NamespaceErrors };
type Result_6 = variant { Ok; Err : NamespaceErrors };
type Result_7 = variant { Ok : DeployedCdaoCanisters; Err : CdaoDeployError };
type Result_8 = variant { Ok : bool; Err : FollowAnotherUserProfileError };
type Result_9 = variant { Ok : BetDetails; Err : text };
type Result_5 = variant { Ok : NamespaceForFrontend; Err : NamespaceErrors };
type Result_6 = variant { Ok : opt text; Err : NamespaceErrors };
type Result_7 = variant { Ok; Err : NamespaceErrors };
type Result_8 = variant { Ok : DeployedCdaoCanisters; Err : CdaoDeployError };
type Result_9 = variant { Ok : bool; Err : FollowAnotherUserProfileError };
type RoomBetPossibleOutcomes = variant { HotWon; BetOngoing; Draw; NotWon };
type RoomDetails = record {
total_hot_bets : nat64;
Expand All @@ -408,10 +423,10 @@ type RoomDetails = record {
};
type SessionType = variant { AnonymousSession; RegisteredSession };
type SettleNeuronsFundParticipationRequest = record {
result : opt Result_24;
result : opt Result_26;
nns_proposal_id : opt nat64;
};
type SettleNeuronsFundParticipationResponse = record { result : opt Result_25 };
type SettleNeuronsFundParticipationResponse = record { result : opt Result_27 };
type SlotDetails = record { room_details : vec record { nat64; RoomDetails } };
type SnsInitPayload = record {
url : opt text;
Expand Down Expand Up @@ -557,24 +572,28 @@ type WatchHistoryItem = record {
};
service : (IndividualUserTemplateInitArgs) -> {
add_device_id : (text) -> (Result);
add_post_v2 : (PostDetailsFromFrontend) -> (Result_1);
add_token : (principal) -> (Result_2);
bet_on_currently_viewing_post : (PlaceBetArg) -> (Result_3);
add_dollr_to_liquidity_pool : (principal, nat) -> (Result_1);
add_post_v2 : (PostDetailsFromFrontend) -> (Result_2);
add_token : (principal) -> (Result_3);
bet_on_currently_viewing_post : (PlaceBetArg) -> (Result_4);
check_and_update_scores_and_share_with_post_cache_if_difference_beyond_threshold : (
vec nat64,
) -> ();
clear_snapshot : () -> ();
create_a_namespace : (text) -> (Result_4);
create_a_namespace : (text) -> (Result_5);
delete_all_creator_token : () -> ();
delete_key_value_pair : (nat64, text) -> (Result_5);
delete_multiple_key_value_pairs : (nat64, vec text) -> (Result_6);
deploy_cdao_sns : (SnsInitPayload, nat64) -> (Result_7);
delete_key_value_pair : (nat64, text) -> (Result_6);
delete_multiple_key_value_pairs : (nat64, vec text) -> (Result_7);
deploy_cdao_sns : (SnsInitPayload, nat64) -> (Result_8);
deployed_cdao_canisters : () -> (vec DeployedCdaoCanisters) query;
do_i_follow_this_user : (FolloweeArg) -> (Result_8) query;
do_i_follow_this_user : (FolloweeArg) -> (Result_9) query;
download_snapshot : (nat64, nat64) -> (blob) query;
get_bet_details_for_a_user_on_a_post : (principal, nat64) -> (Result_9) query;
gdollr_balance : () -> (nat) query;
get_bet_details_for_a_user_on_a_post : (principal, nat64) -> (
Result_10,
) query;
get_device_identities : () -> (vec DeviceIdentity) query;
get_entire_individual_post_detail_by_id : (nat64) -> (Result_10) query;
get_entire_individual_post_detail_by_id : (nat64) -> (Result_11) query;
get_hot_or_not_bet_details_for_this_post : (nat64) -> (BettingStatus) query;
get_hot_or_not_bets_placed_by_this_profile_with_pagination : (nat64) -> (
vec PlacedBetDetail,
Expand All @@ -583,14 +602,14 @@ service : (IndividualUserTemplateInitArgs) -> {
opt PlacedBetDetail,
) query;
get_individual_post_details_by_id : (nat64) -> (PostDetailsForFrontend) query;
get_last_access_time : () -> (Result_11) query;
get_last_canister_functionality_access_time : () -> (Result_11) query;
get_last_access_time : () -> (Result_12) query;
get_last_canister_functionality_access_time : () -> (Result_12) query;
get_ml_feed_cache_paginated : (nat64, nat64) -> (vec MLFeedCacheItem) query;
get_posts_of_this_user_profile_with_pagination : (nat64, nat64) -> (
Result_12,
Result_13,
) query;
get_posts_of_this_user_profile_with_pagination_cursor : (nat64, nat64) -> (
Result_12,
Result_13,
) query;
get_principals_that_follow_this_profile_paginated : (opt nat64) -> (
vec record { nat64; FollowEntryDetail },
Expand All @@ -602,76 +621,82 @@ service : (IndividualUserTemplateInitArgs) -> {
get_profile_details_v2 : () -> (UserProfileDetailsForFrontendV2) query;
get_rewarded_for_referral : (principal, principal) -> ();
get_rewarded_for_signing_up : () -> ();
get_session_type : () -> (Result_13) query;
get_session_type : () -> (Result_14) query;
get_stable_memory_size : () -> (nat64) query;
get_success_history : () -> (Result_14) query;
get_success_history : () -> (Result_15) query;
get_token_roots_of_this_user_with_pagination_cursor : (nat64, nat64) -> (
Result_15,
Result_16,
) query;
get_user_caniser_cycle_balance : () -> (nat) query;
get_user_propensity : () -> (float64) query;
get_user_utility_token_transaction_history_with_pagination : (
nat64,
nat64,
) -> (Result_16) query;
) -> (Result_17) query;
get_utility_token_balance : () -> (nat64) query;
get_version : () -> (text) query;
get_version_number : () -> (nat64) query;
get_watch_history : () -> (Result_17) query;
get_watch_history : () -> (Result_18) query;
get_well_known_principal_value : (KnownPrincipalType) -> (
opt principal,
) query;
http_request : (HttpRequest) -> (HttpResponse) query;
list_namespace_keys : (nat64) -> (Result_18) query;
list_namespace_keys : (nat64) -> (Result_19) query;
list_namespaces : (nat64, nat64) -> (vec NamespaceForFrontend) query;
load_snapshot : () -> ();
once_reenqueue_timers_for_pending_bet_outcomes : () -> (Result_19);
read_key_value_pair : (nat64, text) -> (Result_5) query;
once_reenqueue_timers_for_pending_bet_outcomes : () -> (Result_20);
played_game_count : () -> (nat64) query;
played_game_info_with_pagination_cursor : (nat64, nat64) -> (Result_21) query;
pumps_and_dumps : () -> (PumpsAndDumps) query;
read_key_value_pair : (nat64, text) -> (Result_6) query;
receive_and_save_snaphot : (nat64, blob) -> ();
receive_bet_from_bet_makers_canister : (PlaceBetArg, principal) -> (Result_3);
receive_bet_from_bet_makers_canister : (PlaceBetArg, principal) -> (Result_4);
receive_bet_winnings_when_distributed : (nat64, BetOutcomeForBetMaker) -> ();
receive_data_from_hotornot : (principal, nat64, vec Post) -> (Result_20);
request_airdrop : (principal, opt blob, nat, principal) -> (Result_21);
reset_ml_feed_cache : () -> (Result_22);
receive_data_from_hotornot : (principal, nat64, vec Post) -> (Result_22);
reconcile_user_state : (vec PumpNDumpStateDiff) -> (Result_1);
redeem_gdollr : (nat) -> (Result_1);
request_airdrop : (principal, opt blob, nat, principal) -> (Result_23);
reset_ml_feed_cache : () -> (Result_24);
return_cycles_to_user_index_canister : (opt nat) -> ();
save_snapshot_json : () -> (nat32);
send_creator_dao_stats_to_subnet_orchestrator : () -> (Result_23);
send_creator_dao_stats_to_subnet_orchestrator : () -> (Result_25);
set_controller_as_subnet_orchestrator : (principal) -> ();
settle_neurons_fund_participation : (
SettleNeuronsFundParticipationRequest,
) -> (SettleNeuronsFundParticipationResponse);
stake_dollr_for_gdollr : (nat) -> (Result_1);
transfer_token_to_user_canister : (principal, principal, opt blob, nat) -> (
Result_26,
Result_28,
);
transfer_tokens_and_posts : (principal, principal) -> (Result_20);
update_last_access_time : () -> (Result_22);
transfer_tokens_and_posts : (principal, principal) -> (Result_22);
update_last_access_time : () -> (Result_24);
update_last_canister_functionality_access_time : () -> ();
update_ml_feed_cache : (vec MLFeedCacheItem) -> (Result_22);
update_ml_feed_cache : (vec MLFeedCacheItem) -> (Result_24);
update_post_add_view_details : (nat64, PostViewDetailsFromFrontend) -> ();
update_post_as_ready_to_view : (nat64) -> ();
update_post_increment_share_count : (nat64) -> (nat64);
update_post_status : (nat64, PostStatus) -> ();
update_post_toggle_like_status_by_caller : (nat64) -> (bool);
update_profile_display_details : (UserProfileUpdateDetailsFromFrontend) -> (
Result_27,
Result_29,
);
update_profile_owner : (opt principal) -> (Result_28);
update_profile_set_unique_username_once : (text) -> (Result_29);
update_profile_owner : (opt principal) -> (Result_1);
update_profile_set_unique_username_once : (text) -> (Result_30);
update_profiles_i_follow_toggle_list_with_specified_profile : (
FolloweeArg,
) -> (Result_8);
) -> (Result_9);
update_profiles_that_follow_me_toggle_list_with_specified_profile : (
FollowerArg,
) -> (Result_8);
update_referrer_details : (UserCanisterDetails) -> (Result_22);
update_session_type : (SessionType) -> (Result_22);
update_success_history : (SuccessHistoryItemV1) -> (Result_22);
update_user_propensity : (float64) -> (Result_22);
update_watch_history : (WatchHistoryItem) -> (Result_22);
) -> (Result_9);
update_referrer_details : (UserCanisterDetails) -> (Result_24);
update_session_type : (SessionType) -> (Result_24);
update_success_history : (SuccessHistoryItemV1) -> (Result_24);
update_user_propensity : (float64) -> (Result_24);
update_watch_history : (WatchHistoryItem) -> (Result_24);
update_well_known_principal : (KnownPrincipalType, principal) -> ();
upgrade_creator_dao_governance_canisters : (blob) -> (Result_28);
write_key_value_pair : (nat64, text, text) -> (Result_5);
upgrade_creator_dao_governance_canisters : (blob) -> (Result_1);
write_key_value_pair : (nat64, text, text) -> (Result_6);
write_multiple_key_value_pairs : (nat64, vec record { text; text }) -> (
Result_6,
Result_7,
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ fn update_session_type(session_type: SessionType) -> Result<String, String> {
None => canister_data.session_type = Some(session_type),
}

if session_type == SessionType::RegisteredSession {
canister_data.pump_n_dump.dollr_balance += canister_data.pump_n_dump.onboarding_reward.clone();
}

Ok("Success".into())
})
}
1 change: 1 addition & 0 deletions src/canister/individual_user_template/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ pub mod token;
pub mod well_known_principal;
pub mod cdao;
pub mod device_id_management;
pub mod pump_n_dump;
Loading