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

✨ New evaluation reward/slash thresholds #366

Merged
merged 1 commit into from
Aug 23, 2024
Merged
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: 1 addition & 1 deletion pallets/funding/src/functions/1_application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl<T: Config> Pallet<T> {
evaluation_round_info: EvaluationRoundInfoOf::<T> {
total_bonded_usd: Zero::zero(),
total_bonded_plmc: Zero::zero(),
evaluators_outcome: EvaluatorsOutcome::Unchanged,
evaluators_outcome: None,
},
usd_bid_on_oversubscription: None,
funding_end_block: None,
Expand Down
11 changes: 6 additions & 5 deletions pallets/funding/src/functions/3_auction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl<T: Config> Pallet<T> {
project_id,
project_details,
ProjectStatus::AuctionInitializePeriod,
ProjectStatus::Auction,
ProjectStatus::AuctionRound,
T::AuctionOpeningDuration::get(),
skip_round_end_check,
)
Expand All @@ -45,7 +45,6 @@ impl<T: Config> Pallet<T> {
#[transactional]
pub fn do_end_auction(project_id: ProjectId) -> DispatchResultWithPostInfo {
// * Get variables *
let project_details = ProjectsDetails::<T>::get(project_id).ok_or(Error::<T>::ProjectDetailsNotFound)?;
let project_metadata = ProjectsMetadata::<T>::get(project_id).ok_or(Error::<T>::ProjectMetadataNotFound)?;
let bucket = Buckets::<T>::get(project_id).ok_or(Error::<T>::BucketNotFound)?;

Expand All @@ -60,6 +59,8 @@ impl<T: Config> Pallet<T> {
project_metadata.auction_round_allocation_percentage * project_metadata.total_allocation_size,
weighted_token_price,
);
let updated_project_details =
ProjectsDetails::<T>::get(project_id).ok_or(Error::<T>::ProjectDetailsNotFound)?;

match calculation_result {
Err(e) => return Err(DispatchErrorWithPostInfo { post_info: ().into(), error: e }),
Expand All @@ -68,8 +69,8 @@ impl<T: Config> Pallet<T> {
// * Transition Round *
Self::transition_project(
project_id,
project_details,
ProjectStatus::Auction,
updated_project_details,
ProjectStatus::AuctionRound,
ProjectStatus::CommunityRound(now.saturating_add(T::CommunityFundingDuration::get())),
T::CommunityFundingDuration::get() + T::RemainderFundingDuration::get(),
false,
Expand Down Expand Up @@ -151,7 +152,7 @@ impl<T: Config> Pallet<T> {

ensure!(ct_amount > Zero::zero(), Error::<T>::TooLow);
ensure!(did != project_details.issuer_did, Error::<T>::ParticipationToOwnProject);
ensure!(matches!(project_details.status, ProjectStatus::Auction), Error::<T>::IncorrectRound);
ensure!(matches!(project_details.status, ProjectStatus::AuctionRound), Error::<T>::IncorrectRound);
ensure!(
project_metadata.participation_currencies.contains(&funding_asset),
Error::<T>::FundingAssetNotAccepted
Expand Down
16 changes: 5 additions & 11 deletions pallets/funding/src/functions/5_funding_end.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,17 @@ impl<T: Config> Pallet<T> {

// * Update Storage *
DidWithActiveProjects::<T>::set(issuer_did, None);
let evaluator_outcome = match funding_ratio {
ratio if ratio <= Perquintill::from_percent(75u64) => EvaluatorsOutcome::Slashed,
ratio if ratio < Perquintill::from_percent(90u64) => EvaluatorsOutcome::Unchanged,
_ => {
let reward_info = Self::generate_evaluator_rewards_info(project_id)?;
EvaluatorsOutcome::Rewarded(reward_info)
},
};

project_details.evaluation_round_info.evaluators_outcome = evaluator_outcome;

let (next_status, duration, actual_weight) = if funding_ratio <= T::FundingSuccessThreshold::get() {
let (next_status, duration, actual_weight) = if funding_ratio < T::FundingSuccessThreshold::get() {
project_details.evaluation_round_info.evaluators_outcome = Some(EvaluatorsOutcome::Slashed);
(
ProjectStatus::FundingFailed,
1u32.into(),
WeightInfoOf::<T>::end_funding_automatically_rejected_evaluators_slashed(1),
)
} else {
let reward_info = Self::generate_evaluator_rewards_info(project_id)?;
project_details.evaluation_round_info.evaluators_outcome = Some(EvaluatorsOutcome::Rewarded(reward_info));
(
ProjectStatus::FundingSuccessful,
T::SuccessToSettlementTime::get(),
Expand All @@ -83,6 +76,7 @@ impl<T: Config> Pallet<T> {
let round_end = now.saturating_add(duration).saturating_sub(One::one());
project_details.round_duration.update(Some(now), Some(round_end));
project_details.status = next_status;
ProjectsDetails::<T>::insert(project_id, project_details);

Ok(PostDispatchInfo { actual_weight: Some(actual_weight), pays_fee: Pays::Yes })
}
Expand Down
Loading