mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-13 15:09:57 +00:00
cleanup
This commit is contained in:
1730
api/idl.json
1730
api/idl.json
File diff suppressed because it is too large
Load Diff
@@ -8,29 +8,29 @@ pub struct Block {
|
||||
/// The current round.
|
||||
pub current_round: u64,
|
||||
|
||||
/// The cumulative amount of SOL risked in the current round, up to and including this bet.
|
||||
pub total_bets: u64,
|
||||
|
||||
/// The number of bets made in the current round.
|
||||
pub bet_count: u64,
|
||||
|
||||
/// The time time the current round started.
|
||||
pub started_at: u64,
|
||||
|
||||
/// The slot at which the current round ends.
|
||||
pub ends_at: u64,
|
||||
|
||||
/// Whether or not the current round has ended.
|
||||
pub payed_out: u64,
|
||||
|
||||
/// The mint used to track wagers of the current round.
|
||||
pub mint: Pubkey,
|
||||
|
||||
/// The noise used for the current round.
|
||||
pub noise: [u8; 32],
|
||||
|
||||
/// Whether or not the current round has ended.
|
||||
pub payed_out: u64,
|
||||
|
||||
/// The amount of ORE to distribute to the winner.
|
||||
pub reward: u64,
|
||||
|
||||
/// The noise used for the current round.
|
||||
pub noise: [u8; 32],
|
||||
/// The time time the current round started.
|
||||
pub started_at: u64,
|
||||
|
||||
/// The cumulative amount of SOL risked in the current round, up to and including this bet.
|
||||
pub total_bets: u64,
|
||||
}
|
||||
|
||||
account!(OreAccount, Block);
|
||||
|
||||
@@ -29,10 +29,10 @@ pub fn proof_pda(authority: Pubkey) -> (Pubkey, u8) {
|
||||
Pubkey::find_program_address(&[PROOF, authority.as_ref()], &crate::id())
|
||||
}
|
||||
|
||||
pub fn wager_pda(round: u64, seed: [u8; 32]) -> (Pubkey, u8) {
|
||||
Pubkey::find_program_address(&[WAGER, &round.to_le_bytes(), &seed], &crate::ID)
|
||||
}
|
||||
|
||||
pub fn treasury_pda() -> (Pubkey, u8) {
|
||||
Pubkey::find_program_address(&[TREASURY], &crate::ID)
|
||||
}
|
||||
|
||||
pub fn wager_pda(round: u64, seed: [u8; 32]) -> (Pubkey, u8) {
|
||||
Pubkey::find_program_address(&[WAGER, &round.to_le_bytes(), &seed], &crate::ID)
|
||||
}
|
||||
|
||||
@@ -5,20 +5,20 @@ use super::OreAccount;
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
|
||||
pub struct Wager {
|
||||
/// The quantity of SOL this miner has bet in the current round.
|
||||
pub amount: u64,
|
||||
|
||||
/// The signer authorized to use this wager.
|
||||
pub authority: Pubkey,
|
||||
|
||||
/// The cumulative amount of SOL bet in the current round, up to and including this wager.
|
||||
pub cumulative_bets: u64,
|
||||
|
||||
/// The current round this miner is betting in.
|
||||
pub round: u64,
|
||||
|
||||
/// The ID of the bet.
|
||||
pub id: u64,
|
||||
|
||||
/// The quantity of SOL this miner has bet in the current round.
|
||||
pub amount: u64,
|
||||
|
||||
/// The cumulative amount of SOL bet in the current round, up to and including this wager.
|
||||
pub cumulative_bets: u64,
|
||||
pub seed: [u8; 32],
|
||||
|
||||
/// The timestamp of the wager.
|
||||
pub timestamp: u64,
|
||||
|
||||
12
localnet.sh
Normal file
12
localnet.sh
Normal file
@@ -0,0 +1,12 @@
|
||||
solana-test-validator -r \
|
||||
# TODO Copy accounts and programs from mainnet
|
||||
# ORE
|
||||
# Config
|
||||
# Treasury
|
||||
# Treasury tokens
|
||||
# ORE mint
|
||||
# Boost proof
|
||||
# Boost program
|
||||
# Boost config
|
||||
# Meteora program
|
||||
# Meteora pool and vaults
|
||||
@@ -20,7 +20,7 @@ pub fn process_bet(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult {
|
||||
let block = block_info
|
||||
.as_account_mut::<Block>(&ore_api::ID)?
|
||||
.assert_mut(|b| b.ends_at > clock.slot)?
|
||||
.assert_mut(|b| b.payed_out != 0)?;
|
||||
.assert_mut(|b| b.payed_out == 0)?;
|
||||
block_bets_info.as_associated_token_account(block_info.key, &block.mint)?;
|
||||
sender_info.as_associated_token_account(signer_info.key, &block.mint)?;
|
||||
wager_info.is_writable()?.is_empty()?.has_seeds(
|
||||
@@ -46,14 +46,14 @@ pub fn process_bet(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult {
|
||||
let wager = wager_info.as_account_mut::<Wager>(&ore_api::ID)?;
|
||||
wager.amount = amount;
|
||||
wager.authority = *signer_info.key;
|
||||
wager.id = block.bet_count;
|
||||
wager.round = block.current_round;
|
||||
wager.timestamp = clock.unix_timestamp as u64;
|
||||
wager.cumulative_bets = block.total_bets;
|
||||
wager.round = block.current_round;
|
||||
wager.seed = seed;
|
||||
wager.timestamp = clock.unix_timestamp as u64;
|
||||
|
||||
// Update block stats.
|
||||
block.total_bets += amount;
|
||||
block.bet_count += 1;
|
||||
block.total_bets += amount;
|
||||
|
||||
// Hash client seed into block noise for provably fair randomness.
|
||||
block.noise = hashv(&[&block.noise, &seed]).to_bytes();
|
||||
|
||||
@@ -15,7 +15,7 @@ pub fn process_payout(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResu
|
||||
signer_info.is_signer()?;
|
||||
let block = block_info
|
||||
.as_account_mut::<Block>(&ore_api::ID)?
|
||||
.assert_mut(|b| b.ends_at < clock.slot)?
|
||||
.assert_mut(|b| b.ends_at <= clock.slot)?
|
||||
.assert_mut(|b| b.payed_out == 0)?;
|
||||
treasury_info.has_address(&TREASURY_ADDRESS)?;
|
||||
treasury_tokens_info
|
||||
|
||||
Reference in New Issue
Block a user