mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-14 07:26:51 +00:00
variable rewards
This commit is contained in:
@@ -73,5 +73,5 @@ pub const VIRTUAL_LIQUIDITY: u64 = ONE_ORE * 5;
|
||||
/// The minimum difficulty required for payout.
|
||||
pub const MIN_DIFFICULTY: u64 = 10;
|
||||
|
||||
/// The reward rate per satisfying hash (0.002048 ORE).
|
||||
pub const REWARD_RATE: u64 = 204_800_000;
|
||||
// The reward rate per satisfying hash (0.002048 ORE).
|
||||
// pub const REWARD_RATE: u64 = 204_800_000;
|
||||
|
||||
@@ -6,7 +6,7 @@ use crate::state::SwapDirection;
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
|
||||
pub struct SwapEvent {
|
||||
/// The authority of the swap.
|
||||
pub authority: [u8; 32],
|
||||
pub authority: Pubkey,
|
||||
|
||||
/// The block id.
|
||||
pub block_id: u64,
|
||||
@@ -42,4 +42,18 @@ impl SwapEvent {
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
|
||||
pub struct RewardEvent {
|
||||
/// The authority who received the reward.
|
||||
pub authority: Pubkey,
|
||||
|
||||
/// The block id.
|
||||
pub block_id: u64,
|
||||
|
||||
/// The amount of ORE distributed as a reward.
|
||||
pub amount: u64,
|
||||
}
|
||||
|
||||
event!(SwapEvent);
|
||||
event!(RewardEvent);
|
||||
|
||||
@@ -4,6 +4,12 @@ use crate::state::block_pda;
|
||||
|
||||
use super::OreAccount;
|
||||
|
||||
// What could be variable?
|
||||
// - Payout style (winner take all / difficulty / both)
|
||||
// - Payout skew (larger / neutral / smaller)
|
||||
// - Jackpot possiblity (yes / no)
|
||||
// - Known / unknown
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
|
||||
pub struct Block {
|
||||
@@ -11,10 +17,11 @@ pub struct Block {
|
||||
pub id: u64,
|
||||
|
||||
/// The minimum difficulty required for payout.
|
||||
pub min_difficulty: u64,
|
||||
// pub min_difficulty: u64,
|
||||
|
||||
/// The reward rate per satisfying hash.
|
||||
pub reward_rate: u64,
|
||||
// pub reward_rate: u64,
|
||||
pub reward: RewardConfig,
|
||||
|
||||
/// The hash of the starting slot.
|
||||
pub slot_hash: [u8; 32],
|
||||
@@ -28,10 +35,36 @@ pub struct Block {
|
||||
/// The total amount of rewards paid out to miners.
|
||||
pub total_rewards: u64,
|
||||
|
||||
/// The total number of hashes submitted to the block.
|
||||
/// The total number of hashes that resulted in a payout.
|
||||
pub winning_hashes: u64,
|
||||
}
|
||||
|
||||
/// Configuration specifying how rewards are paid out.
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
|
||||
pub struct RewardConfig {
|
||||
/// The reward paid to the submitter of the best hash.
|
||||
pub best_hash_reward: u64,
|
||||
|
||||
/// The authority of the miner who submitted the best hash.
|
||||
pub best_hash_authority: Pubkey,
|
||||
|
||||
/// The best hash.
|
||||
pub best_hash: [u8; 32],
|
||||
|
||||
/// The reward rate paid to hashes satisfying the difficulty threshold.
|
||||
pub difficulty_reward: u64,
|
||||
|
||||
/// The minimum difficulty required for payout.
|
||||
pub difficulty_threshold: u64,
|
||||
|
||||
/// Jackpot amount.
|
||||
pub jackpot_amount: u64,
|
||||
|
||||
/// The threshold difficulty for the jackpot payout.
|
||||
pub jackpot_threshold: u64,
|
||||
}
|
||||
|
||||
impl Block {
|
||||
pub fn pda(&self) -> (Pubkey, u8) {
|
||||
block_pda(self.id)
|
||||
|
||||
@@ -54,7 +54,7 @@ impl Market {
|
||||
// Produce swap result.
|
||||
let base_out = base_via_ask + base_via_curve;
|
||||
let swap_event = SwapEvent {
|
||||
authority: [0; 32],
|
||||
authority: Pubkey::default(),
|
||||
block_id: 0,
|
||||
direction: SwapDirection::Buy as u64,
|
||||
base_to_transfer: base_out as u64,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use steel::Pubkey;
|
||||
|
||||
use crate::error::OreError;
|
||||
|
||||
use super::{Market, SwapDirection, TokenType, VirtualLimitOrder};
|
||||
@@ -57,7 +59,7 @@ impl Market {
|
||||
|
||||
// Produce swap result.
|
||||
let swap_event = SwapEvent {
|
||||
authority: [0; 32],
|
||||
authority: Pubkey::default(),
|
||||
block_id: 0,
|
||||
direction: SwapDirection::Buy as u64,
|
||||
base_to_transfer: base_out as u64,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use steel::Pubkey;
|
||||
|
||||
use crate::error::OreError;
|
||||
|
||||
use super::{Market, SwapDirection, TokenType, VirtualLimitOrder};
|
||||
@@ -61,7 +63,7 @@ impl Market {
|
||||
// Produce swap result.
|
||||
let quote_out = quote_via_bid + quote_via_curve;
|
||||
let swap_event = SwapEvent {
|
||||
authority: [0; 32],
|
||||
authority: Pubkey::default(),
|
||||
block_id: 0,
|
||||
direction: SwapDirection::Sell as u64,
|
||||
base_to_transfer: base_in as u64,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use steel::Pubkey;
|
||||
|
||||
use crate::error::OreError;
|
||||
|
||||
use super::{Market, SwapDirection, TokenType, VirtualLimitOrder};
|
||||
@@ -59,7 +61,7 @@ impl Market {
|
||||
|
||||
// Produce swap result.
|
||||
let swap_event = SwapEvent {
|
||||
authority: [0; 32],
|
||||
authority: Pubkey::default(),
|
||||
block_id: 0,
|
||||
direction: SwapDirection::Sell as u64,
|
||||
base_to_transfer: base_in as u64,
|
||||
|
||||
Reference in New Issue
Block a user