Hardhat/split (#134)

* split

* consts

* cleanup
This commit is contained in:
Hardhat Chad
2025-10-03 13:17:56 -05:00
committed by GitHub
parent 7a52ff73aa
commit 3a9703d6e1
8 changed files with 37 additions and 90 deletions

View File

@@ -78,12 +78,20 @@ pub fn process_checkpoint(accounts: &[AccountInfo<'_>], _data: &[u8]) -> Program
/ round.deployed[winning_square] as u128) as u64;
// Calculate ORE rewards.
let top_miner_sample = round.top_miner_sample(r, winning_square);
if top_miner_sample >= miner.cumulative[winning_square]
&& top_miner_sample < miner.cumulative[winning_square] + miner.deployed[winning_square]
{
rewards_ore = round.top_miner_reward;
round.top_miner = miner.authority;
if round.top_miner == SPLIT_ADDRESS {
// If round is split, split the reward evenly among all miners.
rewards_ore = ((round.top_miner_reward * miner.deployed[winning_square])
/ round.deployed[winning_square]) as u64;
} else {
// If round is not split, payout to the top miner.
let top_miner_sample = round.top_miner_sample(r, winning_square);
if top_miner_sample >= miner.cumulative[winning_square]
&& top_miner_sample
< miner.cumulative[winning_square] + miner.deployed[winning_square]
{
rewards_ore = round.top_miner_reward;
round.top_miner = miner.authority;
}
}
// Calculate motherlode rewards.

View File

@@ -1,5 +1,5 @@
use ore_api::prelude::*;
use solana_program::slot_hashes::SlotHashes;
use solana_program::{pubkey, slot_hashes::SlotHashes};
use steel::*;
/// Pays out the winners and block reward.
@@ -151,6 +151,11 @@ pub fn process_reset(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResul
&[TREASURY],
)?;
// Set top miner to split reward address if the round is split.
if round.is_split_reward(r) {
round.top_miner = SPLIT_ADDRESS;
}
// Reset the motherlode if it was activated.
if round.did_hit_motherlode(r) {
round.motherlode = treasury.motherlode;
@@ -193,7 +198,7 @@ pub fn process_reset(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResul
start_slot: board.start_slot,
end_slot: board.end_slot,
winning_square: winning_square as u64,
top_miner: Pubkey::default(), // top_miner.authority,
top_miner: round.top_miner,
motherlode: round.motherlode,
num_winners: round.count[winning_square],
total_deployed: round.total_deployed,