diff --git a/api/src/consts.rs b/api/src/consts.rs index b4927c8..ff78331 100644 --- a/api/src/consts.rs +++ b/api/src/consts.rs @@ -65,7 +65,7 @@ pub const DENOMINATOR_BPS: u64 = 10_000; pub const SLOT_WINDOW: u64 = 4; /// Amount of hash tokens to mint to market. -pub const HASH_TOKEN_SUPPLY: u64 = 10_000_000; +pub const HASH_TOKEN_SUPPLY: u64 = 2_000_000; /// The virtual liquidity to seed the markets with (in ORE). pub const VIRTUAL_LIQUIDITY: u64 = ONE_ORE * 5; @@ -73,11 +73,11 @@ pub const VIRTUAL_LIQUIDITY: u64 = ONE_ORE * 5; /// The minimum difficulty required for payout. pub const NUGGET_DIFFICULTY: u64 = 10; -/// The difficulty threshold for the motherlode payout. -pub const MOTHERLOAD_DIFFICULTY: u64 = 35; +// The difficulty threshold for the motherlode payout. +// pub const MOTHERLOAD_DIFFICULTY: u64 = 35; -/// The fee to open a block. -pub const OPEN_FEE: u64 = ONE_ORE / 100; +// The fee to open a block. +// pub const OPEN_FEE: u64 = ONE_ORE / 100; // The reward rate per satisfying hash (0.002048 ORE). // pub const REWARD_RATE: u64 = 204_800_000; diff --git a/api/src/event.rs b/api/src/event.rs index a8be86d..1eaaeed 100644 --- a/api/src/event.rs +++ b/api/src/event.rs @@ -150,8 +150,11 @@ pub struct CommitEvent { /// The amount of hashpower committed. pub amount: u64, - /// The total amount of hashpower this user has committed. - pub commitment: u64, + /// The total amount of hashpower committed to the block. + pub block_commitment: u64, + + /// The total amount of hashpower this miner has committed to the block. + pub permit_commitment: u64, /// The timestamp of the event. pub ts: i64, @@ -172,8 +175,11 @@ pub struct UncommitEvent { /// The amount of hashpower committed. pub amount: u64, - /// The total amount of hashpower this user has committed. - pub commitment: u64, + /// The total amount of hashpower committed to the block. + pub block_commitment: u64, + + /// The total amount of hashpower this miner has committed to the block. + pub permit_commitment: u64, /// The timestamp of the event. pub ts: i64, diff --git a/api/src/state/block.rs b/api/src/state/block.rs index 78cf38e..d1838e4 100644 --- a/api/src/state/block.rs +++ b/api/src/state/block.rs @@ -48,9 +48,6 @@ pub struct RewardConfig { /// The best hash. pub lode_hash: [u8; 32], - /// The threshold difficulty for the motherlode payout. - pub motherlode_threshold: u64, - /// The reward rate paid to hashes satisfying the difficulty threshold. pub nugget_reward: u64, diff --git a/cli/src/main.rs b/cli/src/main.rs index c5dcb06..f9256a2 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -156,10 +156,6 @@ fn print_block(block: Block, clock: &Clock) { println!(" Lode hash: {:?}", block.reward.lode_hash); println!(" Nugget reward: {:?}", block.reward.nugget_reward); println!(" Nugget threshold: {:?}", block.reward.nugget_threshold); - println!( - " Motherlode threshold: {:?}", - block.reward.motherlode_threshold - ); } async fn log_blocks(rpc: &RpcClient) -> Result<(), anyhow::Error> { diff --git a/program/src/close.rs b/program/src/close.rs index 50cdb68..12ef4f3 100644 --- a/program/src/close.rs +++ b/program/src/close.rs @@ -5,7 +5,7 @@ use steel::*; pub fn process_close(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResult { // Load accounts. let clock = Clock::get()?; - let [signer_info, block_info, market_info, mint_base_info, mint_quote_info, recipient_info, treasury_info, treasury_tokens_info, vault_base_info, vault_quote_info, system_program, token_program, associated_token_program] = + let [signer_info, block_info, market_info, mint_base_info, mint_quote_info, recipient_info, treasury_info, vault_base_info, vault_quote_info, system_program, token_program] = accounts else { return Err(ProgramError::NotEnoughAccountKeys); @@ -28,32 +28,6 @@ pub fn process_close(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResul vault_quote_info.as_associated_token_account(market_info.key, mint_quote_info.key)?; system_program.is_program(&system_program::ID)?; token_program.is_program(&spl_token::ID)?; - associated_token_program.is_program(&spl_associated_token_account::ID)?; - - // Load treasury token accounts. - if treasury_tokens_info.data_is_empty() { - create_associated_token_account( - signer_info, - treasury_info, - treasury_tokens_info, - mint_quote_info, - system_program, - token_program, - associated_token_program, - )?; - } else { - treasury_tokens_info.as_associated_token_account(&TREASURY_ADDRESS, mint_quote_info.key)?; - } - - // Fund motherlode reward. - mint_to_signed( - mint_quote_info, - treasury_tokens_info, - treasury_info, - token_program, - OPEN_FEE, - &[TREASURY], - )?; // Payout block reward. if block.reward.lode_reward > 0 && block.reward.lode_authority != Pubkey::default() { diff --git a/program/src/commit.rs b/program/src/commit.rs index c705a27..ee46c24 100644 --- a/program/src/commit.rs +++ b/program/src/commit.rs @@ -106,7 +106,8 @@ pub fn process_commit(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResul authority: *signer_info.key, block_id: block.id, amount, - commitment: permit.commitment, + block_commitment: block.total_committed, + permit_commitment: permit.commitment, ts: clock.unix_timestamp, } .log_return(); diff --git a/program/src/mine.rs b/program/src/mine.rs index 1a5551e..ded31c4 100644 --- a/program/src/mine.rs +++ b/program/src/mine.rs @@ -117,31 +117,6 @@ pub fn process_mine(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult block.reward.lode_hash = miner.hash; block.reward.lode_authority = miner.authority; } - - // If hash is motherlode hash, pay the motherlode reward. - if score >= block.reward.motherlode_threshold { - // Execute transfer. - let motherlode_amount = treasury_tokens.amount(); - transfer_signed( - authority_info, - treasury_tokens_info, - recipient_info, - token_program, - motherlode_amount, - &[TREASURY], - )?; - - // Emit event. - RewardEvent { - disc: OreEvent::Reward as u64, - amount: motherlode_amount, - authority: miner.authority, - block_id: block.id, - rewards_type: RewardsType::Motherlode as u64, - ts: clock.unix_timestamp, - } - .log(); - } } // Payout ORE. diff --git a/program/src/open.rs b/program/src/open.rs index ce3ae61..d013236 100644 --- a/program/src/open.rs +++ b/program/src/open.rs @@ -33,23 +33,13 @@ pub fn process_open(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult mint_quote_info.has_address(&MINT_ADDRESS)?.as_mint()?; sender_info .is_writable()? - .as_associated_token_account(&signer_info.key, &mint_quote_info.key)? - .assert(|t| t.amount() >= OPEN_FEE)?; + .as_associated_token_account(&signer_info.key, &mint_quote_info.key)?; treasury_info.has_address(&TREASURY_ADDRESS)?; system_program.is_program(&system_program::ID)?; token_program.is_program(&spl_token::ID)?; associated_token_program.is_program(&spl_associated_token_account::ID)?; rent_sysvar.is_sysvar(&sysvar::rent::ID)?; - // Pay block opening fee. - burn( - sender_info, - mint_quote_info, - signer_info, - token_program, - OPEN_FEE, - )?; - // Error out if start slot is within the current period. let start_slot = id * 1500; let current_period_start = (clock.slot / 1500) * 1500; @@ -72,7 +62,6 @@ pub fn process_open(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult lode_hash: [0; 32], lode_authority: Pubkey::default(), lode_reward: 0, - motherlode_threshold: MOTHERLOAD_DIFFICULTY, nugget_reward: 0, nugget_threshold: NUGGET_DIFFICULTY, }; diff --git a/program/src/uncommit.rs b/program/src/uncommit.rs index 5cdd232..9843844 100644 --- a/program/src/uncommit.rs +++ b/program/src/uncommit.rs @@ -66,7 +66,8 @@ pub fn process_uncommit(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramRes disc: OreEvent::Uncommit as u64, authority: *signer_info.key, block_id: block.id, - commitment: permit.commitment, + block_commitment: block.total_committed, + permit_commitment: permit.commitment, amount, ts: clock.unix_timestamp, }