mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-29 23:26:45 +00:00
commit
This commit is contained in:
@@ -8,24 +8,30 @@ use crate::{
|
||||
state::*,
|
||||
};
|
||||
|
||||
pub fn bet(signer: Pubkey, mint: Pubkey, amount: u64, round: u64, seed: [u8; 32]) -> Instruction {
|
||||
pub fn deploy(
|
||||
signer: Pubkey,
|
||||
mint: Pubkey,
|
||||
amount: u64,
|
||||
round: u64,
|
||||
seed: [u8; 32],
|
||||
) -> Instruction {
|
||||
let sender = spl_associated_token_account::get_associated_token_address(&signer, &mint);
|
||||
let block = block_pda().0;
|
||||
let block_bets = spl_associated_token_account::get_associated_token_address(&block, &mint);
|
||||
let wager = wager_pda(round, seed).0;
|
||||
let block_commits = spl_associated_token_account::get_associated_token_address(&block, &mint);
|
||||
let commit = commit_pda(round, seed).0;
|
||||
Instruction {
|
||||
program_id: crate::ID,
|
||||
accounts: vec![
|
||||
AccountMeta::new(signer, true),
|
||||
AccountMeta::new(block, false),
|
||||
AccountMeta::new(block_bets, false),
|
||||
AccountMeta::new(block_commits, false),
|
||||
AccountMeta::new(commit, false),
|
||||
AccountMeta::new(sender, false),
|
||||
AccountMeta::new(wager, false),
|
||||
AccountMeta::new_readonly(system_program::ID, false),
|
||||
AccountMeta::new_readonly(spl_token::ID, false),
|
||||
AccountMeta::new_readonly(sysvar::slot_hashes::ID, false),
|
||||
],
|
||||
data: Bet {
|
||||
data: Deploy {
|
||||
amount: amount.to_le_bytes(),
|
||||
seed,
|
||||
}
|
||||
@@ -33,9 +39,9 @@ pub fn bet(signer: Pubkey, mint: Pubkey, amount: u64, round: u64, seed: [u8; 32]
|
||||
}
|
||||
}
|
||||
|
||||
pub fn bury(signer: Pubkey, swap: Swap) -> Instruction {
|
||||
pub fn bury(signer: Pubkey, swap: Swap, amount: u64) -> Instruction {
|
||||
let block = block_pda().0;
|
||||
let block_bets = spl_associated_token_account::get_associated_token_address(
|
||||
let block_commits = spl_associated_token_account::get_associated_token_address(
|
||||
&block,
|
||||
&spl_token::native_mint::ID,
|
||||
);
|
||||
@@ -47,7 +53,7 @@ pub fn bury(signer: Pubkey, swap: Swap) -> Instruction {
|
||||
// required accounts
|
||||
AccountMeta::new(signer, true),
|
||||
AccountMeta::new(block, false),
|
||||
AccountMeta::new(block_bets, false),
|
||||
AccountMeta::new(block_commits, false),
|
||||
AccountMeta::new(block_ore, false),
|
||||
AccountMeta::new(spl_token::native_mint::ID, false),
|
||||
AccountMeta::new(MINT_ADDRESS, false),
|
||||
@@ -66,18 +72,21 @@ pub fn bury(signer: Pubkey, swap: Swap) -> Instruction {
|
||||
AccountMeta::new_readonly(spl_token::ID, false),
|
||||
AccountMeta::new_readonly(meteora_pools_sdk::programs::AMM_ID, false),
|
||||
],
|
||||
data: Bury {}.to_bytes(),
|
||||
data: Bury {
|
||||
amount: amount.to_le_bytes(),
|
||||
}
|
||||
.to_bytes(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn close(signer: Pubkey, wager: Pubkey) -> Instruction {
|
||||
pub fn close(signer: Pubkey, commit: Pubkey) -> Instruction {
|
||||
let block = block_pda().0;
|
||||
Instruction {
|
||||
program_id: crate::ID,
|
||||
accounts: vec![
|
||||
AccountMeta::new(signer, true),
|
||||
AccountMeta::new(block, false),
|
||||
AccountMeta::new(wager, false),
|
||||
AccountMeta::new(commit, false),
|
||||
AccountMeta::new_readonly(system_program::ID, false),
|
||||
],
|
||||
data: Close {}.to_bytes(),
|
||||
@@ -86,7 +95,7 @@ pub fn close(signer: Pubkey, wager: Pubkey) -> Instruction {
|
||||
|
||||
pub fn initialize(signer: Pubkey) -> Instruction {
|
||||
let block = block_pda().0;
|
||||
let block_bets =
|
||||
let block_commits =
|
||||
spl_associated_token_account::get_associated_token_address(&block, &native_mint::ID);
|
||||
let block_ore =
|
||||
spl_associated_token_account::get_associated_token_address(&block, &MINT_ADDRESS);
|
||||
@@ -95,7 +104,7 @@ pub fn initialize(signer: Pubkey) -> Instruction {
|
||||
accounts: vec![
|
||||
AccountMeta::new(signer, true),
|
||||
AccountMeta::new(block, false),
|
||||
AccountMeta::new(block_bets, false),
|
||||
AccountMeta::new(block_commits, false),
|
||||
AccountMeta::new(block_ore, false),
|
||||
AccountMeta::new_readonly(MINT_ADDRESS, false),
|
||||
AccountMeta::new_readonly(native_mint::ID, false),
|
||||
@@ -107,15 +116,15 @@ pub fn initialize(signer: Pubkey) -> Instruction {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn payout(signer: Pubkey, wager: Pubkey, recipient: Pubkey) -> Instruction {
|
||||
pub fn payout(signer: Pubkey, commit: Pubkey, recipient: Pubkey) -> Instruction {
|
||||
let block = block_pda().0;
|
||||
Instruction {
|
||||
program_id: crate::ID,
|
||||
accounts: vec![
|
||||
AccountMeta::new(signer, true),
|
||||
AccountMeta::new(block, false),
|
||||
AccountMeta::new(commit, false),
|
||||
AccountMeta::new(MINT_ADDRESS, false),
|
||||
AccountMeta::new(wager, false),
|
||||
AccountMeta::new(recipient, false),
|
||||
AccountMeta::new(TREASURY_ADDRESS, false),
|
||||
AccountMeta::new(TREASURY_TOKENS_ADDRESS, false),
|
||||
|
||||
Reference in New Issue
Block a user