mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-13 23:16:52 +00:00
bury
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -2514,6 +2514,7 @@ dependencies = [
|
||||
"base64 0.22.1",
|
||||
"bincode",
|
||||
"bytemuck",
|
||||
"meteora-pools-sdk",
|
||||
"ore-api 3.7.0",
|
||||
"ore-boost-api",
|
||||
"serde_json",
|
||||
|
||||
@@ -36,11 +36,11 @@ pub fn bet(signer: Pubkey, mint: Pubkey, amount: u64, round: u64, seed: [u8; 32]
|
||||
pub fn bury(signer: Pubkey, swap: Swap) -> Instruction {
|
||||
let block = block_pda().0;
|
||||
let block_bets = spl_associated_token_account::get_associated_token_address(
|
||||
&signer,
|
||||
&block,
|
||||
&spl_token::native_mint::ID,
|
||||
);
|
||||
let block_ore =
|
||||
spl_associated_token_account::get_associated_token_address(&signer, &MINT_ADDRESS);
|
||||
spl_associated_token_account::get_associated_token_address(&block, &MINT_ADDRESS);
|
||||
Instruction {
|
||||
program_id: crate::ID,
|
||||
accounts: vec![
|
||||
@@ -53,8 +53,6 @@ pub fn bury(signer: Pubkey, swap: Swap) -> Instruction {
|
||||
AccountMeta::new(MINT_ADDRESS, false),
|
||||
// swap accounts
|
||||
AccountMeta::new(swap.pool, false),
|
||||
AccountMeta::new(swap.user_source_token, false),
|
||||
AccountMeta::new(swap.user_destination_token, false),
|
||||
AccountMeta::new(swap.a_vault, false),
|
||||
AccountMeta::new(swap.b_vault, false),
|
||||
AccountMeta::new(swap.a_token_vault, false),
|
||||
@@ -68,7 +66,7 @@ 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: Close {}.to_bytes(),
|
||||
data: Bury {}.to_bytes(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ anyhow.workspace = true
|
||||
base64 = "0.22.1"
|
||||
bincode = "1.3.3"
|
||||
bytemuck.workspace = true
|
||||
meteora-pools-sdk.workspace = true
|
||||
ore-api = { path = "../api" }
|
||||
ore-boost-api.workspace = true
|
||||
serde_json = "1.0.140"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use meteora_pools_sdk::instructions::Swap;
|
||||
use ore_api::{prelude::*, sdk::*};
|
||||
use solana_account_decoder::UiAccountEncoding;
|
||||
use solana_client::{
|
||||
@@ -6,6 +7,7 @@ use solana_client::{
|
||||
rpc_config::{RpcAccountInfoConfig, RpcProgramAccountsConfig},
|
||||
rpc_filter::{Memcmp, RpcFilterType},
|
||||
};
|
||||
use solana_program::pubkey;
|
||||
use solana_sdk::{
|
||||
compute_budget::ComputeBudgetInstruction,
|
||||
keccak::hashv,
|
||||
@@ -57,6 +59,9 @@ async fn main() {
|
||||
let wagers = get_block_wagers(&rpc).await.unwrap();
|
||||
println!("Wagers: {:?}", wagers);
|
||||
}
|
||||
"bury" => {
|
||||
bury_ore_sol(&rpc, &payer).await.unwrap();
|
||||
}
|
||||
_ => panic!("Invalid command"),
|
||||
};
|
||||
}
|
||||
@@ -156,6 +161,32 @@ async fn bet(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn bury_ore_sol(
|
||||
rpc: &RpcClient,
|
||||
payer: &solana_sdk::signer::keypair::Keypair,
|
||||
) -> Result<(), solana_client::client_error::ClientError> {
|
||||
let swap = Swap {
|
||||
pool: pubkey!("GgaDTFbqdgjoZz3FP7zrtofGwnRS4E6MCzmmD5Ni1Mxj"),
|
||||
user_source_token: spl_token::native_mint::ID,
|
||||
user_destination_token: ore_api::consts::MINT_ADDRESS,
|
||||
a_vault: pubkey!("3s6ki6dQSM8FuqWiPsnGkgVsAEo8BTAfUR1Vvt1TPiJN"),
|
||||
b_vault: pubkey!("FERjPVNEa7Udq8CEv68h6tPL46Tq7ieE49HrE2wea3XT"),
|
||||
a_token_vault: pubkey!("BtJuiRG44vew5nYBVeUhuBawPTZLyYYxdzTYzerkfnto"),
|
||||
b_token_vault: pubkey!("HZeLxbZ9uHtSpwZC3LBr4Nubd14iHwz7bRSghRZf5VCG"),
|
||||
a_vault_lp_mint: pubkey!("6Av9sdKvnjwoDHVnhEiz6JEq8e6SGzmhCsCncT2WJ7nN"),
|
||||
b_vault_lp_mint: pubkey!("FZN7QZ8ZUUAxMPfxYEYkH3cXUASzH8EqA6B4tyCL8f1j"),
|
||||
a_vault_lp: pubkey!("2k7V1NtM1krwh1sdt5wWqBRcvNQ5jzxj3J2rV78zdTsL"),
|
||||
b_vault_lp: pubkey!("CFATQFgkKXJyU3MdCNvQqN79qorNSMJFF8jrF66a7r6i"),
|
||||
protocol_token_fee: pubkey!("3WYz5TC8X4FLvwWQ2QvSfXuZHXjqvsdymKwmMFkgCgVs"),
|
||||
user: payer.pubkey(),
|
||||
vault_program: pubkey!("24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi"),
|
||||
token_program: spl_token::ID,
|
||||
};
|
||||
let ix = bury(payer.pubkey(), swap);
|
||||
submit_transaction(rpc, payer, &[ix]).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn build_payout_ix(
|
||||
rpc: &RpcClient,
|
||||
payer: &solana_sdk::signer::keypair::Keypair,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use meteora_pools_sdk::instructions::{SwapCpi, SwapCpiAccounts, SwapInstructionArgs};
|
||||
use ore_api::prelude::*;
|
||||
use solana_program::log::sol_log;
|
||||
use steel::*;
|
||||
|
||||
/// Swaps bets into ORE and buries the ORE.
|
||||
@@ -7,19 +8,24 @@ pub fn process_bury(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResult
|
||||
// Load accounts.
|
||||
let clock = Clock::get()?;
|
||||
let (required_accounts, meteora_accounts) = accounts.split_at(6);
|
||||
sol_log(format!("Loading {} required accounts", meteora_accounts.len()).as_str());
|
||||
let [signer_info, block_info, block_bets_info, block_ore_info, bet_mint_info, ore_mint_info] =
|
||||
required_accounts
|
||||
else {
|
||||
return Err(ProgramError::NotEnoughAccountKeys);
|
||||
};
|
||||
signer_info.is_signer()?.has_address(&INITIALIZER_ADDRESS)?;
|
||||
signer_info.is_signer()?; // .has_address(&INITIALIZER_ADDRESS)?;
|
||||
block_info.as_account::<Block>(&ore_api::ID)?;
|
||||
let block_bets =
|
||||
block_bets_info.as_associated_token_account(block_info.key, bet_mint_info.key)?;
|
||||
block_ore_info.as_associated_token_account(block_info.key, &MINT_ADDRESS)?;
|
||||
let block_bets = block_bets_info
|
||||
.is_writable()?
|
||||
.as_associated_token_account(block_info.key, bet_mint_info.key)?;
|
||||
block_ore_info
|
||||
.is_writable()?
|
||||
.as_associated_token_account(block_info.key, &MINT_ADDRESS)?;
|
||||
bet_mint_info.as_mint()?;
|
||||
ore_mint_info.has_address(&MINT_ADDRESS)?.as_mint()?;
|
||||
|
||||
sol_log(format!("Loading {} meteora accounts", meteora_accounts.len()).as_str());
|
||||
// Load meteora accounts.
|
||||
let [pool_info, a_vault_info, b_vault_info, a_token_vault_info, b_token_vault_info, a_vault_lp_mint_info, b_vault_lp_mint_info, a_vault_lp_info, b_vault_lp_info, protocol_token_fee_info, vault_program_info, token_program_info, meteora_pools_program] =
|
||||
meteora_accounts
|
||||
|
||||
Reference in New Issue
Block a user