mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-14 15:10:13 +00:00
remove motherlode
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
|
||||
@@ -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> {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user