mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-13 15:09:57 +00:00
sol
This commit is contained in:
@@ -17,18 +17,12 @@ pub const ONE_MINUTE: i64 = 60;
|
||||
/// The maximum token supply (5 million).
|
||||
pub const MAX_SUPPLY: u64 = ONE_ORE * 5_000_000;
|
||||
|
||||
/// The seed of the block account PDA.
|
||||
pub const BLOCK: &[u8] = b"block";
|
||||
|
||||
/// The seed of the board account PDA.
|
||||
pub const BOARD: &[u8] = b"board";
|
||||
|
||||
/// The seed of the config account PDA.
|
||||
pub const CONFIG: &[u8] = b"config";
|
||||
|
||||
/// The seed of the market account PDA.
|
||||
pub const MARKET: &[u8] = b"market";
|
||||
|
||||
/// The seed of the miner account PDA.
|
||||
pub const MINER: &[u8] = b"miner";
|
||||
|
||||
@@ -55,29 +49,8 @@ pub const TREASURY_ADDRESS: Pubkey =
|
||||
/// The address of the treasury account.
|
||||
pub const TREASURY_BUMP: u8 = ed25519::derive_program_address(&[TREASURY], &PROGRAM_ID).1;
|
||||
|
||||
/// Swap fee in lamports.
|
||||
pub const FEE_LAMPORTS: u64 = 100_000; // 0.0001 SOL
|
||||
|
||||
/// Denominator for fee calculations.
|
||||
pub const DENOMINATOR_BPS: u64 = 10_000;
|
||||
|
||||
/// Window to submit hashes, in slots.
|
||||
pub const INITIAL_BLOCK_DURATION: u64 = 1500;
|
||||
|
||||
/// Window to submit hashes, in slots.
|
||||
pub const INITIAL_SNIPER_FEE_DURATION: u64 = 50;
|
||||
|
||||
/// Window to submit hashes, in slots.
|
||||
pub const MINING_WINDOW: u64 = 150; // 150 slots is 150 * 0.4 = 60 seconds
|
||||
|
||||
/// Slot window size, used for sandwich resistance.
|
||||
pub const SLOT_WINDOW: u64 = 4;
|
||||
|
||||
/// Amount of hash tokens to mint to market.
|
||||
pub const HASHPOWER_LIQUIDITY: u64 = 1_000_000;
|
||||
|
||||
/// The ORE liquidity to seed the markets with.
|
||||
pub const ORE_LIQUIDITY: u64 = ONE_ORE * 100;
|
||||
|
||||
/// The address of the boost reserve token account.
|
||||
pub const BOOST_RESERVE_TOKEN: Pubkey = pubkey!("Gce36ZUsBDJsoLrfCBxUB5Sfq2DsGunofStvxFx6rBiD");
|
||||
|
||||
@@ -4,11 +4,13 @@ use steel::*;
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, TryFromPrimitive)]
|
||||
pub enum OreInstruction {
|
||||
// User
|
||||
Claim = 0,
|
||||
Initialize = 1,
|
||||
InitializeSquare = 2,
|
||||
Prospect = 3,
|
||||
Reset = 4,
|
||||
ClaimSOL = 0,
|
||||
ClaimORE = 1,
|
||||
Initialize = 2,
|
||||
InitializeSquares = 3,
|
||||
Prospect = 4,
|
||||
Redeem = 5,
|
||||
Reset = 6,
|
||||
|
||||
// Admin
|
||||
SetAdmin = 8,
|
||||
@@ -20,7 +22,13 @@ pub enum OreInstruction {
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
|
||||
pub struct Claim {
|
||||
pub struct ClaimSOL {
|
||||
pub amount: [u8; 8],
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
|
||||
pub struct ClaimORE {
|
||||
pub amount: [u8; 8],
|
||||
}
|
||||
|
||||
@@ -30,7 +38,13 @@ pub struct Initialize {}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
|
||||
pub struct InitializeSquare {}
|
||||
pub struct InitializeSquares {}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
|
||||
pub struct Redeem {
|
||||
pub amount: [u8; 8],
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
|
||||
@@ -97,11 +111,13 @@ pub struct SetSniperFeeDuration {
|
||||
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
|
||||
pub struct ClaimSeeker {}
|
||||
|
||||
instruction!(OreInstruction, Claim);
|
||||
instruction!(OreInstruction, ClaimSOL);
|
||||
instruction!(OreInstruction, ClaimORE);
|
||||
instruction!(OreInstruction, Redeem);
|
||||
instruction!(OreInstruction, Reset);
|
||||
instruction!(OreInstruction, Prospect);
|
||||
instruction!(OreInstruction, Initialize);
|
||||
instruction!(OreInstruction, InitializeSquare);
|
||||
instruction!(OreInstruction, InitializeSquares);
|
||||
instruction!(OreInstruction, SetAdmin);
|
||||
instruction!(OreInstruction, SetFeeCollector);
|
||||
instruction!(OreInstruction, ClaimSeeker);
|
||||
|
||||
@@ -2,7 +2,7 @@ use spl_associated_token_account::get_associated_token_address;
|
||||
use steel::*;
|
||||
|
||||
use crate::{
|
||||
consts::{BOOST_RESERVE_TOKEN, MARKET, MINT_ADDRESS, TREASURY_ADDRESS},
|
||||
consts::{BOOST_RESERVE_TOKEN, MINT_ADDRESS, TREASURY_ADDRESS},
|
||||
instruction::*,
|
||||
state::*,
|
||||
};
|
||||
@@ -14,7 +14,7 @@ pub fn initialize(signer: Pubkey) -> Instruction {
|
||||
let board_address = board_pda().0;
|
||||
let mint_address = MINT_ADDRESS;
|
||||
let treasury_address = TREASURY_ADDRESS;
|
||||
let vault_address = vault_address();
|
||||
let treasury_tokens_address = treasury_tokens_address();
|
||||
Instruction {
|
||||
program_id: crate::ID,
|
||||
accounts: vec![
|
||||
@@ -23,7 +23,7 @@ pub fn initialize(signer: Pubkey) -> Instruction {
|
||||
AccountMeta::new(config_address, false),
|
||||
AccountMeta::new(mint_address, false),
|
||||
AccountMeta::new(treasury_address, false),
|
||||
AccountMeta::new(vault_address, false),
|
||||
AccountMeta::new(treasury_tokens_address, false),
|
||||
AccountMeta::new_readonly(system_program::ID, false),
|
||||
AccountMeta::new_readonly(spl_token::ID, false),
|
||||
AccountMeta::new_readonly(spl_associated_token_account::ID, false),
|
||||
@@ -66,27 +66,47 @@ pub fn initialize_squares(signer: Pubkey) -> Instruction {
|
||||
AccountMeta::new(square_pda(23).0, false),
|
||||
AccountMeta::new(square_pda(24).0, false),
|
||||
],
|
||||
data: InitializeSquare {}.to_bytes(),
|
||||
data: InitializeSquares {}.to_bytes(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn claim(signer: Pubkey, amount: u64) -> Instruction {
|
||||
pub fn claim_sol(signer: Pubkey, amount: u64) -> Instruction {
|
||||
let miner_address = miner_pda(signer).0;
|
||||
let miner_tokens_address = get_associated_token_address(&miner_address, &MINT_ADDRESS);
|
||||
Instruction {
|
||||
program_id: crate::ID,
|
||||
accounts: vec![
|
||||
AccountMeta::new(signer, true),
|
||||
AccountMeta::new(miner_address, false),
|
||||
AccountMeta::new_readonly(system_program::ID, false),
|
||||
],
|
||||
data: ClaimSOL {
|
||||
amount: amount.to_le_bytes(),
|
||||
}
|
||||
.to_bytes(),
|
||||
}
|
||||
}
|
||||
|
||||
// let [signer_info, miner_info, mint_info, recipient_info, treasury_info, treasury_tokens_info, system_program, token_program, associated_token_program] =
|
||||
|
||||
pub fn claim_ore(signer: Pubkey, amount: u64) -> Instruction {
|
||||
let miner_address = miner_pda(signer).0;
|
||||
let treasury_address = treasury_pda().0;
|
||||
let treasury_tokens_address = get_associated_token_address(&treasury_address, &MINT_ADDRESS);
|
||||
let recipient_address = get_associated_token_address(&signer, &MINT_ADDRESS);
|
||||
Instruction {
|
||||
program_id: crate::ID,
|
||||
accounts: vec![
|
||||
AccountMeta::new(signer, true),
|
||||
AccountMeta::new(miner_address, false),
|
||||
AccountMeta::new(miner_tokens_address, false),
|
||||
AccountMeta::new(recipient_address, false),
|
||||
AccountMeta::new(MINT_ADDRESS, false),
|
||||
AccountMeta::new(recipient_address, false),
|
||||
AccountMeta::new(treasury_address, false),
|
||||
AccountMeta::new(treasury_tokens_address, false),
|
||||
AccountMeta::new_readonly(system_program::ID, false),
|
||||
AccountMeta::new_readonly(spl_token::ID, false),
|
||||
AccountMeta::new_readonly(spl_associated_token_account::ID, false),
|
||||
],
|
||||
data: Claim {
|
||||
data: ClaimORE {
|
||||
amount: amount.to_le_bytes(),
|
||||
}
|
||||
.to_bytes(),
|
||||
@@ -100,14 +120,14 @@ pub fn reset(signer: Pubkey, miners: Vec<Pubkey>) -> Instruction {
|
||||
let mint_address = MINT_ADDRESS;
|
||||
let treasury_address = TREASURY_ADDRESS;
|
||||
let reserve_tokens_address = BOOST_RESERVE_TOKEN;
|
||||
let vault_address = vault_address();
|
||||
let treasury_tokens_address = treasury_tokens_address();
|
||||
let mut accounts = vec![
|
||||
AccountMeta::new(signer, true),
|
||||
AccountMeta::new(board_address, false),
|
||||
AccountMeta::new(mint_address, false),
|
||||
AccountMeta::new(treasury_address, false),
|
||||
AccountMeta::new(reserve_tokens_address, false),
|
||||
AccountMeta::new(vault_address, false),
|
||||
AccountMeta::new(treasury_address, false),
|
||||
AccountMeta::new(treasury_tokens_address, false),
|
||||
AccountMeta::new_readonly(system_program::ID, false),
|
||||
AccountMeta::new_readonly(spl_token::ID, false),
|
||||
AccountMeta::new_readonly(sysvar::slot_hashes::ID, false),
|
||||
@@ -124,15 +144,13 @@ pub fn reset(signer: Pubkey, miners: Vec<Pubkey>) -> Instruction {
|
||||
}
|
||||
}
|
||||
|
||||
// let [signer_info, board_info, config_info, fee_collector_info, miner_info, mint_info, sender_info, square_info, vault_info, system_program, token_program, associated_token_program] =
|
||||
// let [signer_info, board_info, config_info, fee_collector_info, miner_info, sender_info, square_info, system_program] =
|
||||
|
||||
pub fn prospect(signer: Pubkey, fee_collector: Pubkey, amount: u64, square_id: u64) -> Instruction {
|
||||
let board_address = board_pda().0;
|
||||
let config_address = config_pda().0;
|
||||
let miner_address = miner_pda(signer).0;
|
||||
let sender_address = get_associated_token_address(&signer, &MINT_ADDRESS);
|
||||
let square_address = square_pda(square_id).0;
|
||||
let vault_address = vault_address();
|
||||
Instruction {
|
||||
program_id: crate::ID,
|
||||
accounts: vec![
|
||||
@@ -141,11 +159,8 @@ pub fn prospect(signer: Pubkey, fee_collector: Pubkey, amount: u64, square_id: u
|
||||
AccountMeta::new(config_address, false),
|
||||
AccountMeta::new(fee_collector, false),
|
||||
AccountMeta::new(miner_address, false),
|
||||
AccountMeta::new(sender_address, false),
|
||||
AccountMeta::new(square_address, false),
|
||||
AccountMeta::new(vault_address, false),
|
||||
AccountMeta::new_readonly(system_program::ID, false),
|
||||
AccountMeta::new_readonly(spl_token::ID, false),
|
||||
],
|
||||
data: Prospect {
|
||||
amount: amount.to_le_bytes(),
|
||||
|
||||
@@ -25,13 +25,16 @@ pub struct Board {
|
||||
/// The hash of the end slot, provided by solana, used for random number generation.
|
||||
pub slot_hash: [u8; 32],
|
||||
|
||||
/// The total amount of ORE burned for the round.
|
||||
pub total_burned: u64,
|
||||
/// The top winner of the round.
|
||||
pub top_winner: Pubkey,
|
||||
|
||||
/// The total amount of ORE committed for the round.
|
||||
pub total_commits: u64,
|
||||
/// The total amount of SOL prospected in the round.
|
||||
pub total_prospects: u64,
|
||||
|
||||
/// The total amount of ORE won by miners for the round.
|
||||
/// The total amount of SOL put in the ORE vault.
|
||||
pub total_vaulted: u64,
|
||||
|
||||
/// The total amount of SOL won by miners for the round.
|
||||
pub total_winnings: u64,
|
||||
}
|
||||
|
||||
|
||||
@@ -13,14 +13,20 @@ pub struct Miner {
|
||||
/// The miner's committed square in the current round round.
|
||||
pub commits: [u64; 25],
|
||||
|
||||
/// The amount of SOL this miner can claim.
|
||||
pub rewards_sol: u64,
|
||||
|
||||
/// The amount of ORE this miner can claim.
|
||||
pub rewards: u64,
|
||||
pub rewards_ore: u64,
|
||||
|
||||
/// The ID of the round this miner last played in.
|
||||
pub round_id: u64,
|
||||
|
||||
/// The total amount of SOL this miner has mined across all blocks.
|
||||
pub lifetime_rewards_sol: u64,
|
||||
|
||||
/// The total amount of ORE this miner has mined across all blocks.
|
||||
pub total_rewards: u64,
|
||||
pub lifetime_rewards_ore: u64,
|
||||
}
|
||||
|
||||
impl Miner {
|
||||
|
||||
@@ -42,15 +42,15 @@ pub fn square_pda(id: u64) -> (Pubkey, u8) {
|
||||
Pubkey::find_program_address(&[SQUARE, &id.to_le_bytes()], &crate::ID)
|
||||
}
|
||||
|
||||
pub fn vault_address() -> Pubkey {
|
||||
let board_address = board_pda().0;
|
||||
spl_associated_token_account::get_associated_token_address(&board_address, &MINT_ADDRESS)
|
||||
}
|
||||
// pub fn vault_address() -> Pubkey {
|
||||
// let board_address = board_pda().0;
|
||||
// spl_associated_token_account::get_associated_token_address(&board_address, &MINT_ADDRESS)
|
||||
// }
|
||||
|
||||
pub fn treasury_pda() -> (Pubkey, u8) {
|
||||
Pubkey::find_program_address(&[TREASURY], &crate::ID)
|
||||
}
|
||||
|
||||
// pub fn treasury_tokens_address() -> Pubkey {
|
||||
// spl_associated_token_account::get_associated_token_address(&TREASURY_ADDRESS, &MINT_ADDRESS)
|
||||
// }
|
||||
pub fn treasury_tokens_address() -> Pubkey {
|
||||
spl_associated_token_account::get_associated_token_address(&TREASURY_ADDRESS, &MINT_ADDRESS)
|
||||
}
|
||||
|
||||
@@ -8,7 +8,9 @@ use super::OreAccount;
|
||||
/// the program's global token account.
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
|
||||
pub struct Treasury {}
|
||||
pub struct Treasury {
|
||||
pub balance: u64,
|
||||
}
|
||||
|
||||
impl Treasury {
|
||||
pub fn pda() -> (Pubkey, u8) {
|
||||
|
||||
@@ -33,8 +33,11 @@ async fn main() {
|
||||
"clock" => {
|
||||
log_clock(&rpc).await.unwrap();
|
||||
}
|
||||
"claim" => {
|
||||
claim(&rpc, &payer).await.unwrap();
|
||||
"claim_sol" => {
|
||||
claim_sol(&rpc, &payer).await.unwrap();
|
||||
}
|
||||
"claim_ore" => {
|
||||
claim_ore(&rpc, &payer).await.unwrap();
|
||||
}
|
||||
"board" => {
|
||||
log_board(&rpc).await.unwrap();
|
||||
@@ -89,6 +92,7 @@ async fn keys() -> Result<(), anyhow::Error> {
|
||||
println!("Config: {}", config_address);
|
||||
// let keys = get_program_accounts::<Miner>(rpc, ore_api::ID, vec![]).await?;
|
||||
// println!("Keys: {:?}", keys);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -110,11 +114,20 @@ async fn initialize_squares(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn claim(
|
||||
async fn claim_sol(
|
||||
rpc: &RpcClient,
|
||||
payer: &solana_sdk::signer::keypair::Keypair,
|
||||
) -> Result<(), anyhow::Error> {
|
||||
let ix = ore_api::sdk::claim(payer.pubkey(), u64::MAX);
|
||||
let ix = ore_api::sdk::claim_sol(payer.pubkey(), u64::MAX);
|
||||
submit_transaction(rpc, payer, &[ix]).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn claim_ore(
|
||||
rpc: &RpcClient,
|
||||
payer: &solana_sdk::signer::keypair::Keypair,
|
||||
) -> Result<(), anyhow::Error> {
|
||||
let ix = ore_api::sdk::claim_ore(payer.pubkey(), u64::MAX);
|
||||
submit_transaction(rpc, payer, &[ix]).await?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -199,10 +212,12 @@ async fn set_fee_collector(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn log_treasury(_rpc: &RpcClient) -> Result<(), anyhow::Error> {
|
||||
async fn log_treasury(rpc: &RpcClient) -> Result<(), anyhow::Error> {
|
||||
let treasury_address = ore_api::state::treasury_pda().0;
|
||||
let treasury = get_treasury(rpc).await?;
|
||||
println!("Treasury");
|
||||
println!(" address: {}", treasury_address);
|
||||
println!(" balance: {}", treasury.balance);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -230,9 +245,11 @@ async fn log_miner(
|
||||
println!(" address: {}", miner_address);
|
||||
println!(" authority: {}", authority);
|
||||
println!(" commits: {:?}", miner.commits);
|
||||
println!(" rewards: {}", miner.rewards);
|
||||
println!(" rewards_sol: {}", miner.rewards_sol);
|
||||
println!(" rewards_ore: {}", miner.rewards_ore);
|
||||
println!(" round_id: {}", miner.round_id);
|
||||
println!(" total_rewards: {}", miner.total_rewards);
|
||||
println!(" lifetime_rewards_sol: {}", miner.lifetime_rewards_sol);
|
||||
println!(" lifetime_rewards_ore: {}", miner.lifetime_rewards_ore);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -270,11 +287,12 @@ fn print_board(board: Board, clock: &Clock) {
|
||||
println!("Board");
|
||||
println!(" Id: {:?}", board.id);
|
||||
println!(" Slot hash: {:?}", board.slot_hash);
|
||||
println!(" Total commits: {}", board.total_commits);
|
||||
println!(" Total burned: {}", board.total_burned);
|
||||
println!(" Start slot: {}", board.start_slot);
|
||||
println!(" End slot: {}", board.end_slot);
|
||||
println!(" Commits: {:?}", board.commits);
|
||||
println!(" Total prospects: {}", board.total_prospects);
|
||||
println!(" Total vaulted: {}", board.total_vaulted);
|
||||
println!(" Total winnings: {}", board.total_winnings);
|
||||
if board.slot_hash != [0; 32] {
|
||||
println!(" Winning square: {}", get_winning_square(&board.slot_hash));
|
||||
}
|
||||
@@ -306,6 +324,13 @@ async fn get_square(rpc: &RpcClient, id: u64) -> Result<Square, anyhow::Error> {
|
||||
Ok(*square)
|
||||
}
|
||||
|
||||
async fn get_treasury(rpc: &RpcClient) -> Result<Treasury, anyhow::Error> {
|
||||
let treasury_pda = ore_api::state::treasury_pda();
|
||||
let account = rpc.get_account(&treasury_pda.0).await?;
|
||||
let treasury = Treasury::try_from_bytes(&account.data)?;
|
||||
Ok(*treasury)
|
||||
}
|
||||
|
||||
async fn get_config(rpc: &RpcClient) -> Result<Config, anyhow::Error> {
|
||||
let config_pda = ore_api::state::config_pda();
|
||||
let account = rpc.get_account(&config_pda.0).await?;
|
||||
|
||||
@@ -1 +1 @@
|
||||
solana-test-validator -r --url https://api.mainnet-beta.solana.com --bpf-program oreV3EG1i9BEgiAJ8b177Z2S2rMarzak4NMv1kULvWv target/deploy/ore.so --clone oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp --clone 45db2FSR4mcXdSVVZbKbwojU6uYDpMyhpEi7cC8nHaWG --clone 9c9X7aDRAF41faiDs94ELjT19UrGnn72wBW9hPsS4Awy --clone HBUh9g46wk2X89CvaNN15UmsznP59rh6od1h8JwYAopk --clone Gce36ZUsBDJsoLrfCBxUB5Sfq2DsGunofStvxFx6rBiD --clone 3Ag5aesdDawsCWP32YqZN2NB2eUoH5e8UKcgP9j4arFX
|
||||
solana-test-validator -r --url https://api.mainnet-beta.solana.com --bpf-program oreV3EG1i9BEgiAJ8b177Z2S2rMarzak4NMv1kULvWv target/deploy/ore.so --clone oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp --clone 45db2FSR4mcXdSVVZbKbwojU6uYDpMyhpEi7cC8nHaWG --clone HBUh9g46wk2X89CvaNN15UmsznP59rh6od1h8JwYAopk --clone Gce36ZUsBDJsoLrfCBxUB5Sfq2DsGunofStvxFx6rBiD --clone 3Ag5aesdDawsCWP32YqZN2NB2eUoH5e8UKcgP9j4arFX --clone tHCCE3KWKx8i8cDjX2DQ3Z7EMJkScAVwkfxdWz8SqgP
|
||||
@@ -2,25 +2,25 @@ use ore_api::prelude::*;
|
||||
use steel::*;
|
||||
|
||||
/// Claims a block reward.
|
||||
pub fn process_claim(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult {
|
||||
pub fn process_claim_ore(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult {
|
||||
// Parse data.
|
||||
let args = Claim::try_from_bytes(data)?;
|
||||
let args = ClaimORE::try_from_bytes(data)?;
|
||||
let amount = u64::from_le_bytes(args.amount);
|
||||
|
||||
// Load accounts.
|
||||
let [signer_info, board_info, miner_info, mint_info, recipient_info, vault_info, system_program, token_program, associated_token_program] =
|
||||
let [signer_info, miner_info, mint_info, recipient_info, treasury_info, treasury_tokens_info, system_program, token_program, associated_token_program] =
|
||||
accounts
|
||||
else {
|
||||
return Err(ProgramError::NotEnoughAccountKeys);
|
||||
};
|
||||
signer_info.is_signer()?;
|
||||
board_info.as_account::<Board>(&ore_api::ID)?;
|
||||
let miner = miner_info
|
||||
.as_account_mut::<Miner>(&ore_api::ID)?
|
||||
.assert_mut(|m| m.authority == *signer_info.key)?;
|
||||
mint_info.has_address(&MINT_ADDRESS)?.as_mint()?;
|
||||
recipient_info.as_associated_token_account(&signer_info.key, &mint_info.key)?;
|
||||
vault_info.as_associated_token_account(&board_info.key, &mint_info.key)?;
|
||||
treasury_info.as_account_mut::<Treasury>(&ore_api::ID)?;
|
||||
treasury_tokens_info.as_associated_token_account(&treasury_info.key, &mint_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)?;
|
||||
@@ -41,19 +41,19 @@ pub fn process_claim(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult
|
||||
}
|
||||
|
||||
// Load amount.
|
||||
let amount = miner.rewards.min(amount);
|
||||
let amount = miner.rewards_ore.min(amount);
|
||||
|
||||
// Update miner.
|
||||
miner.rewards -= amount;
|
||||
miner.rewards_ore -= amount;
|
||||
|
||||
// Transfer reward to recipient.
|
||||
transfer_signed(
|
||||
board_info,
|
||||
vault_info,
|
||||
treasury_info,
|
||||
treasury_tokens_info,
|
||||
recipient_info,
|
||||
token_program,
|
||||
amount,
|
||||
&[BOARD],
|
||||
&[TREASURY],
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
30
program/src/claim_sol.rs
Normal file
30
program/src/claim_sol.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
use ore_api::prelude::*;
|
||||
use steel::*;
|
||||
|
||||
/// Claims a block reward.
|
||||
pub fn process_claim_sol(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult {
|
||||
// Parse data.
|
||||
let args = ClaimSOL::try_from_bytes(data)?;
|
||||
let amount = u64::from_le_bytes(args.amount);
|
||||
|
||||
// Load accounts.
|
||||
let [signer_info, miner_info, system_program] = accounts else {
|
||||
return Err(ProgramError::NotEnoughAccountKeys);
|
||||
};
|
||||
signer_info.is_signer()?;
|
||||
let miner = miner_info
|
||||
.as_account_mut::<Miner>(&ore_api::ID)?
|
||||
.assert_mut(|m| m.authority == *signer_info.key)?;
|
||||
system_program.is_program(&system_program::ID)?;
|
||||
|
||||
// Load amount.
|
||||
let amount = miner.rewards_sol.min(amount);
|
||||
|
||||
// Update miner.
|
||||
miner.rewards_sol -= amount;
|
||||
|
||||
// Transfer reward to recipient.
|
||||
miner_info.send(amount, signer_info);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -4,7 +4,7 @@ use steel::*;
|
||||
/// Initializes the program.
|
||||
pub fn process_initialize(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResult {
|
||||
// Load accounts.
|
||||
let [signer_info, board_info, config_info, mint_info, treasury_info, vault_info, system_program, token_program, associated_token_program] =
|
||||
let [signer_info, board_info, config_info, mint_info, treasury_info, treasury_tokens_info, system_program, token_program, associated_token_program] =
|
||||
accounts
|
||||
else {
|
||||
return Err(ProgramError::NotEnoughAccountKeys);
|
||||
@@ -14,7 +14,7 @@ pub fn process_initialize(accounts: &[AccountInfo<'_>], _data: &[u8]) -> Program
|
||||
config_info.has_seeds(&[CONFIG], &ore_api::ID)?;
|
||||
mint_info.has_address(&MINT_ADDRESS)?.as_mint()?;
|
||||
treasury_info.has_seeds(&[TREASURY], &ore_api::ID)?;
|
||||
vault_info.has_address(&vault_address())?;
|
||||
treasury_tokens_info.has_address(&treasury_tokens_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)?;
|
||||
@@ -35,8 +35,10 @@ pub fn process_initialize(accounts: &[AccountInfo<'_>], _data: &[u8]) -> Program
|
||||
board.start_slot = 0;
|
||||
board.end_slot = 0;
|
||||
board.slot_hash = [0; 32];
|
||||
board.total_commits = 0;
|
||||
board.total_burned = 0;
|
||||
board.top_winner = Pubkey::default();
|
||||
board.total_prospects = 0;
|
||||
board.total_vaulted = 0;
|
||||
board.total_winnings = 0;
|
||||
} else {
|
||||
board_info.as_account::<Board>(&ore_api::ID)?;
|
||||
}
|
||||
@@ -52,10 +54,10 @@ pub fn process_initialize(accounts: &[AccountInfo<'_>], _data: &[u8]) -> Program
|
||||
)?;
|
||||
let config = config_info.as_account_mut::<Config>(&ore_api::ID)?;
|
||||
config.admin = *signer_info.key;
|
||||
config.block_duration = INITIAL_BLOCK_DURATION;
|
||||
config.sniper_fee_duration = INITIAL_SNIPER_FEE_DURATION;
|
||||
config.block_duration = 0;
|
||||
config.sniper_fee_duration = 0;
|
||||
config.fee_collector = *signer_info.key;
|
||||
config.fee_rate = FEE_LAMPORTS;
|
||||
config.fee_rate = 0;
|
||||
} else {
|
||||
config_info.as_account::<Config>(&ore_api::ID)?;
|
||||
}
|
||||
@@ -69,23 +71,25 @@ pub fn process_initialize(accounts: &[AccountInfo<'_>], _data: &[u8]) -> Program
|
||||
&ore_api::ID,
|
||||
&[TREASURY],
|
||||
)?;
|
||||
let treasury = treasury_info.as_account_mut::<Treasury>(&ore_api::ID)?;
|
||||
treasury.balance = 0;
|
||||
} else {
|
||||
treasury_info.as_account::<Treasury>(&ore_api::ID)?;
|
||||
}
|
||||
|
||||
// Initialize vault token account.
|
||||
if vault_info.data_is_empty() {
|
||||
if treasury_tokens_info.data_is_empty() {
|
||||
create_associated_token_account(
|
||||
signer_info,
|
||||
board_info,
|
||||
vault_info,
|
||||
treasury_info,
|
||||
treasury_tokens_info,
|
||||
mint_info,
|
||||
system_program,
|
||||
token_program,
|
||||
associated_token_program,
|
||||
)?;
|
||||
} else {
|
||||
vault_info.as_associated_token_account(board_info.key, mint_info.key)?;
|
||||
treasury_tokens_info.as_associated_token_account(treasury_info.key, mint_info.key)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -2,7 +2,7 @@ use ore_api::prelude::*;
|
||||
use steel::*;
|
||||
|
||||
/// Initializes the program.
|
||||
pub fn process_initialize_square(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResult {
|
||||
pub fn process_initialize_squares(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResult {
|
||||
// Load accounts.
|
||||
let (required_accounts, square_accounts) = accounts.split_at(2);
|
||||
let [signer_info, system_program] = required_accounts else {
|
||||
@@ -1,18 +1,22 @@
|
||||
mod claim;
|
||||
mod claim_ore;
|
||||
mod claim_seeker;
|
||||
mod claim_sol;
|
||||
mod initialize;
|
||||
mod initialize_square;
|
||||
mod initialize_squares;
|
||||
mod prospect;
|
||||
mod redeem;
|
||||
mod reset;
|
||||
mod set_admin;
|
||||
mod set_fee_collector;
|
||||
mod whitelist;
|
||||
|
||||
use claim::*;
|
||||
use claim_ore::*;
|
||||
use claim_seeker::*;
|
||||
use claim_sol::*;
|
||||
use initialize::*;
|
||||
use initialize_square::*;
|
||||
use initialize_squares::*;
|
||||
use prospect::*;
|
||||
use redeem::*;
|
||||
use reset::*;
|
||||
use set_admin::*;
|
||||
use set_fee_collector::*;
|
||||
@@ -29,10 +33,12 @@ pub fn process_instruction(
|
||||
|
||||
match ix {
|
||||
// User
|
||||
OreInstruction::Claim => process_claim(accounts, data)?,
|
||||
OreInstruction::ClaimSOL => process_claim_sol(accounts, data)?,
|
||||
OreInstruction::ClaimORE => process_claim_ore(accounts, data)?,
|
||||
OreInstruction::Initialize => process_initialize(accounts, data)?,
|
||||
OreInstruction::InitializeSquare => process_initialize_square(accounts, data)?,
|
||||
OreInstruction::InitializeSquares => process_initialize_squares(accounts, data)?,
|
||||
OreInstruction::Prospect => process_prospect(accounts, data)?,
|
||||
OreInstruction::Redeem => process_redeem(accounts, data)?,
|
||||
OreInstruction::Reset => process_reset(accounts, data)?,
|
||||
|
||||
// Admin
|
||||
@@ -41,8 +47,6 @@ pub fn process_instruction(
|
||||
|
||||
// Seeker
|
||||
OreInstruction::ClaimSeeker => process_claim_seeker(accounts, data)?,
|
||||
|
||||
_ => return Err(ProgramError::InvalidInstructionData),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -10,7 +10,7 @@ pub fn process_prospect(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramRes
|
||||
|
||||
// Load accounts.
|
||||
let clock = Clock::get()?;
|
||||
let [signer_info, board_info, config_info, fee_collector_info, miner_info, sender_info, square_info, vault_info, system_program, token_program] =
|
||||
let [signer_info, board_info, config_info, fee_collector_info, miner_info, square_info, system_program] =
|
||||
accounts
|
||||
else {
|
||||
return Err(ProgramError::NotEnoughAccountKeys);
|
||||
@@ -27,13 +27,10 @@ pub fn process_prospect(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramRes
|
||||
.has_address(&config.fee_collector)?
|
||||
.is_writable()?;
|
||||
miner_info.is_writable()?;
|
||||
sender_info.as_associated_token_account(&signer_info.key, &MINT_ADDRESS)?;
|
||||
let square = square_info
|
||||
.as_account_mut::<Square>(&ore_api::ID)?
|
||||
.assert_mut(|s| s.id == square_id)?;
|
||||
vault_info.has_address(&vault_address())?;
|
||||
system_program.is_program(&system_program::ID)?;
|
||||
token_program.is_program(&spl_token::ID)?;
|
||||
|
||||
// Create miner.
|
||||
let miner = if miner_info.data_is_empty() {
|
||||
@@ -47,9 +44,11 @@ pub fn process_prospect(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramRes
|
||||
let miner = miner_info.as_account_mut::<Miner>(&ore_api::ID)?;
|
||||
miner.authority = *signer_info.key;
|
||||
miner.commits = [0; 25];
|
||||
miner.rewards = 0;
|
||||
miner.rewards_sol = 0;
|
||||
miner.rewards_ore = 0;
|
||||
miner.round_id = board.id;
|
||||
miner.total_rewards = 0;
|
||||
miner.lifetime_rewards_sol = 0;
|
||||
miner.lifetime_rewards_ore = 0;
|
||||
miner
|
||||
} else {
|
||||
miner_info
|
||||
@@ -64,8 +63,9 @@ pub fn process_prospect(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramRes
|
||||
board.slot_hash = [0; 32];
|
||||
board.start_slot = clock.slot;
|
||||
board.end_slot = clock.slot + 150; // one minute
|
||||
board.total_commits = 0;
|
||||
board.total_burned = 0;
|
||||
board.total_prospects = 0;
|
||||
board.total_vaulted = 0;
|
||||
board.total_winnings = 0;
|
||||
}
|
||||
|
||||
// Reset miner
|
||||
@@ -81,6 +81,10 @@ pub fn process_prospect(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramRes
|
||||
square.round_id = board.id;
|
||||
}
|
||||
|
||||
// Normalize amount.
|
||||
let fee = amount / 100;
|
||||
let amount = amount - fee;
|
||||
|
||||
// Update miner
|
||||
let is_first_play_on_square = miner.commits[square_id as usize] == 0;
|
||||
miner.commits[square_id as usize] += amount;
|
||||
@@ -93,15 +97,11 @@ pub fn process_prospect(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramRes
|
||||
|
||||
// Update board
|
||||
board.commits[square_id as usize] += amount;
|
||||
board.total_commits += amount;
|
||||
board.total_prospects += amount;
|
||||
|
||||
// Transfer tokens.
|
||||
transfer(signer_info, sender_info, vault_info, token_program, amount)?;
|
||||
|
||||
// Pay fee.
|
||||
if config.fee_rate > 0 {
|
||||
fee_collector_info.collect(config.fee_rate, &signer_info)?;
|
||||
}
|
||||
// Transfer prospects.
|
||||
board_info.collect(amount, &signer_info)?;
|
||||
fee_collector_info.collect(fee, &signer_info)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
39
program/src/redeem.rs
Normal file
39
program/src/redeem.rs
Normal file
@@ -0,0 +1,39 @@
|
||||
use ore_api::prelude::*;
|
||||
use steel::*;
|
||||
|
||||
/// Redeem ORE for SOL backing.
|
||||
pub fn process_redeem(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult {
|
||||
// Parse data.
|
||||
let args = Redeem::try_from_bytes(data)?;
|
||||
let amount = u64::from_le_bytes(args.amount);
|
||||
|
||||
// Load accounts.
|
||||
let [signer_info, mint_info, sender_info, treasury_info, system_program, token_program] =
|
||||
accounts
|
||||
else {
|
||||
return Err(ProgramError::NotEnoughAccountKeys);
|
||||
};
|
||||
signer_info.is_signer()?;
|
||||
let mint = mint_info.has_address(&MINT_ADDRESS)?.as_mint()?;
|
||||
let sender = sender_info.as_associated_token_account(&signer_info.key, &mint_info.key)?;
|
||||
let treasury = treasury_info
|
||||
.as_account_mut::<Treasury>(&ore_api::ID)?
|
||||
.assert_mut(|t| t.balance >= amount)?;
|
||||
system_program.is_program(&system_program::ID)?;
|
||||
token_program.is_program(&spl_token::ID)?;
|
||||
|
||||
// Normalize amount.
|
||||
let amount = amount.min(sender.amount());
|
||||
|
||||
// Load redemption amount.
|
||||
let redemption_amount = treasury.balance * amount / mint.supply();
|
||||
|
||||
// Burn ORE.
|
||||
burn(sender_info, mint_info, signer_info, token_program, amount)?;
|
||||
|
||||
// Transfer SOL to recipient.
|
||||
treasury_info.send(redemption_amount, signer_info);
|
||||
treasury.balance -= redemption_amount;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
use ore_api::prelude::*;
|
||||
use solana_program::slot_hashes::SlotHashes;
|
||||
use solana_program::{log::sol_log, slot_hashes::SlotHashes};
|
||||
use steel::*;
|
||||
|
||||
/// Claims a block reward.
|
||||
@@ -7,7 +7,7 @@ pub fn process_reset(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResul
|
||||
// Load accounts.
|
||||
let clock = Clock::get()?;
|
||||
let (required_accounts, miner_accounts) = accounts.split_at(9);
|
||||
let [signer_info, board_info, mint_info, treasury_info, reserve_tokens_info, vault_info, system_program, token_program, slot_hashes_sysvar] =
|
||||
let [signer_info, board_info, mint_info, reserve_tokens_info, treasury_info, treasury_tokens_info, system_program, token_program, slot_hashes_sysvar] =
|
||||
required_accounts
|
||||
else {
|
||||
return Err(ProgramError::NotEnoughAccountKeys);
|
||||
@@ -22,12 +22,14 @@ pub fn process_reset(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResul
|
||||
.has_address(&BOOST_RESERVE_TOKEN)?
|
||||
.as_token_account()?
|
||||
.assert(|t| t.mint() == MINT_ADDRESS)?;
|
||||
vault_info.has_address(&vault_address())?;
|
||||
treasury_info.has_address(&TREASURY_ADDRESS)?;
|
||||
let treasury = treasury_info.as_account_mut::<Treasury>(&ore_api::ID)?;
|
||||
treasury_tokens_info.as_associated_token_account(&treasury_info.key, &mint_info.key)?;
|
||||
system_program.is_program(&system_program::ID)?;
|
||||
token_program.is_program(&spl_token::ID)?;
|
||||
slot_hashes_sysvar.is_sysvar(&sysvar::slot_hashes::ID)?;
|
||||
|
||||
sol_log("A");
|
||||
|
||||
// Mint tokens to the boost reserve.
|
||||
mint_to_signed(
|
||||
mint_info,
|
||||
@@ -38,6 +40,8 @@ pub fn process_reset(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResul
|
||||
&[TREASURY],
|
||||
)?;
|
||||
|
||||
sol_log("B");
|
||||
|
||||
// Sample slot hashes.
|
||||
let (winning_square, square_commits) =
|
||||
if let Ok(slot_hash) = get_slot_hash(board.end_slot, slot_hashes_sysvar) {
|
||||
@@ -51,20 +55,18 @@ pub fn process_reset(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResul
|
||||
(u64::MAX, 0)
|
||||
};
|
||||
|
||||
// No one won. Burn all rewards.
|
||||
sol_log("C");
|
||||
|
||||
// No one won. Vault all prospects.
|
||||
if square_commits == 0 {
|
||||
board.total_burned = board.total_commits;
|
||||
burn_signed(
|
||||
vault_info,
|
||||
mint_info,
|
||||
board_info,
|
||||
token_program,
|
||||
board.total_commits,
|
||||
&[BOARD],
|
||||
)?;
|
||||
board.total_vaulted = board.total_prospects;
|
||||
treasury.balance += board.total_prospects;
|
||||
board_info.send(board.total_prospects, &treasury_info);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
sol_log("D");
|
||||
|
||||
// Get winnings amount (prospects on all non-winning squares).
|
||||
let mut winnings = 0;
|
||||
for (i, commits) in board.commits.iter().enumerate() {
|
||||
@@ -73,55 +75,118 @@ pub fn process_reset(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResul
|
||||
}
|
||||
}
|
||||
|
||||
// Get burn amount.
|
||||
let burn_amount = winnings / 10; // Burn 10% of non-winning prospects.
|
||||
board.total_burned = burn_amount;
|
||||
let winnings = winnings - burn_amount;
|
||||
burn_signed(
|
||||
vault_info,
|
||||
mint_info,
|
||||
board_info,
|
||||
token_program,
|
||||
burn_amount,
|
||||
&[BOARD],
|
||||
)?;
|
||||
sol_log("E");
|
||||
|
||||
// Mint 1 ORE to winners while there are emissions left.
|
||||
let mint_amount = ONE_ORE.min(MAX_SUPPLY - mint.supply());
|
||||
let winnings = winnings + mint_amount;
|
||||
if mint_amount > 0 {
|
||||
mint_to_signed(
|
||||
mint_info,
|
||||
vault_info,
|
||||
treasury_info,
|
||||
token_program,
|
||||
mint_amount,
|
||||
&[TREASURY],
|
||||
)?;
|
||||
}
|
||||
// Get vault amount.
|
||||
let vault_amount = winnings / 10; // Vault 10% of winnings.
|
||||
board.total_vaulted = vault_amount;
|
||||
let winnings = winnings - vault_amount;
|
||||
// board_info.send(vault_amount, &treasury_info);
|
||||
treasury.balance += vault_amount;
|
||||
|
||||
sol_log("F");
|
||||
|
||||
// Payout winnings to miners.
|
||||
let mut top_winner = None;
|
||||
let mut top_winner_commits = 0;
|
||||
let mut rewards_sol = [0; 16];
|
||||
let mut checksum = 0;
|
||||
for miner_info in miner_accounts {
|
||||
for (i, miner_info) in miner_accounts.iter().enumerate() {
|
||||
sol_log("G");
|
||||
// Transfer winnings to miner.
|
||||
let miner = miner_info
|
||||
.as_account_mut::<Miner>(&ore_api::ID)?
|
||||
.assert_mut(|m| m.round_id == board.id)?;
|
||||
let miner_commits = miner.commits[winning_square as usize];
|
||||
let rewards = (winnings * miner_commits / square_commits) + miner_commits; // Winners get their own prospect back plus their share of the winnings.
|
||||
miner.rewards += rewards;
|
||||
miner.total_rewards += rewards;
|
||||
let rewards = miner_commits + (winnings * miner_commits / square_commits); // Winners get their own prospect back plus their share of the winnings.
|
||||
miner.rewards_sol += rewards;
|
||||
miner.lifetime_rewards_sol += rewards;
|
||||
checksum += miner_commits;
|
||||
rewards_sol[i] = rewards;
|
||||
// board_info.send(rewards, &miner_info);
|
||||
|
||||
// Find the top winner.
|
||||
if miner_commits > top_winner_commits {
|
||||
sol_log("H");
|
||||
top_winner_commits = miner_commits;
|
||||
top_winner = Some(i);
|
||||
// top_winner = Some(miner);
|
||||
}
|
||||
}
|
||||
|
||||
sol_log("I");
|
||||
|
||||
// Verify checksum.
|
||||
if checksum != square_commits {
|
||||
// This can only happen if the caller didn't provide full set of winning miners.
|
||||
sol_log("J");
|
||||
return Err(ProgramError::InvalidAccountData);
|
||||
}
|
||||
|
||||
sol_log("K");
|
||||
|
||||
// Payout reward to top winner.
|
||||
if let Some(i) = top_winner {
|
||||
sol_log("L");
|
||||
let miner = miner_accounts[i].as_account_mut::<Miner>(&ore_api::ID)?;
|
||||
let mint_amount = ONE_ORE.min(MAX_SUPPLY - mint.supply());
|
||||
if mint_amount > 0 {
|
||||
// sol_log("M");
|
||||
miner.rewards_ore += mint_amount;
|
||||
miner.lifetime_rewards_ore += mint_amount;
|
||||
board.top_winner = miner.authority;
|
||||
// sol_log("M2");
|
||||
mint_to_signed(
|
||||
mint_info,
|
||||
treasury_tokens_info,
|
||||
treasury_info,
|
||||
token_program,
|
||||
mint_amount,
|
||||
&[TREASURY],
|
||||
)?;
|
||||
// sol_log("N");
|
||||
}
|
||||
|
||||
// miner.rewards_ore += rewards_sol[i];
|
||||
// miner.lifetime_rewards_ore += rewards_sol[i];
|
||||
// board.top_winner = miner.authority;
|
||||
}
|
||||
|
||||
// if let Some(miner) = top_winner {
|
||||
// sol_log("L");
|
||||
// let mint_amount = ONE_ORE.min(MAX_SUPPLY - mint.supply());
|
||||
// sol_log(&format!("mint_amount: {}", mint_amount));
|
||||
// if mint_amount > 0 {
|
||||
// sol_log("M");
|
||||
// miner.rewards_ore += mint_amount;
|
||||
// miner.lifetime_rewards_ore += mint_amount;
|
||||
// board.top_winner = miner.authority;
|
||||
// sol_log("M2");
|
||||
// mint_to_signed(
|
||||
// mint_info,
|
||||
// treasury_tokens_info,
|
||||
// treasury_info,
|
||||
// token_program,
|
||||
// mint_amount,
|
||||
// &[TREASURY],
|
||||
// )?;
|
||||
// sol_log("N");
|
||||
// }
|
||||
// }
|
||||
|
||||
sol_log("O");
|
||||
|
||||
// Update board.
|
||||
board.total_winnings = winnings;
|
||||
|
||||
// Do SOL transfers.
|
||||
board_info.send(vault_amount, &treasury_info);
|
||||
for (i, miner_info) in miner_accounts.iter().enumerate() {
|
||||
board_info.send(rewards_sol[i], &miner_info);
|
||||
}
|
||||
|
||||
// Send vault amount to treasury.
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user