mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-13 15:09:57 +00:00
cleanup
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -2400,6 +2400,7 @@ dependencies = [
|
||||
"base64 0.22.1",
|
||||
"bytemuck",
|
||||
"const-crypto",
|
||||
"meteora-pools-sdk",
|
||||
"meteora-vault-sdk",
|
||||
"mpl-token-metadata",
|
||||
"num_enum",
|
||||
|
||||
@@ -13,6 +13,7 @@ keywords.workspace = true
|
||||
base64.workspace = true
|
||||
bytemuck.workspace = true
|
||||
const-crypto.workspace = true
|
||||
meteora-pools-sdk.workspace = true
|
||||
meteora-vault-sdk.workspace = true
|
||||
mpl-token-metadata.workspace = true
|
||||
num_enum.workspace = true
|
||||
|
||||
@@ -48,6 +48,9 @@ pub const CONFIG_ADDRESS: Pubkey =
|
||||
/// The address of the mint account.
|
||||
pub const MINT_ADDRESS: Pubkey = pubkey!("oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp");
|
||||
|
||||
/// The address of the sol mint account.
|
||||
pub const SOL_MINT: Pubkey = pubkey!("So11111111111111111111111111111111111111112");
|
||||
|
||||
/// The address of the treasury account.
|
||||
pub const TREASURY_ADDRESS: Pubkey =
|
||||
Pubkey::new_from_array(ed25519::derive_program_address(&[TREASURY], &PROGRAM_ID).0);
|
||||
|
||||
@@ -4,7 +4,7 @@ use spl_associated_token_account::get_associated_token_address;
|
||||
use steel::*;
|
||||
|
||||
use crate::{
|
||||
consts::{BOARD, BOOST_RESERVE_TOKEN, MINT_ADDRESS, TREASURY_ADDRESS},
|
||||
consts::{BOARD, BOOST_RESERVE_TOKEN, MINT_ADDRESS, SOL_MINT, TREASURY_ADDRESS},
|
||||
instruction::*,
|
||||
state::*,
|
||||
};
|
||||
@@ -192,8 +192,8 @@ pub fn deploy(
|
||||
}
|
||||
|
||||
const POOL_ADDRESS: Pubkey = pubkey!("GgaDTFbqdgjoZz3FP7zrtofGwnRS4E6MCzmmD5Ni1Mxj");
|
||||
const TOKEN_A_MINT: Pubkey = pubkey!("oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp");
|
||||
const TOKEN_B_MINT: Pubkey = pubkey!("So11111111111111111111111111111111111111112");
|
||||
const TOKEN_A_MINT: Pubkey = MINT_ADDRESS; // pubkey!("oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp");
|
||||
const TOKEN_B_MINT: Pubkey = SOL_MINT; //pubkey!("So11111111111111111111111111111111111111112");
|
||||
const A_VAULT: Pubkey = pubkey!("3s6ki6dQSM8FuqWiPsnGkgVsAEo8BTAfUR1Vvt1TPiJN");
|
||||
const B_VAULT: Pubkey = pubkey!("FERjPVNEa7Udq8CEv68h6tPL46Tq7ieE49HrE2wea3XT");
|
||||
const A_TOKEN_VAULT: Pubkey = pubkey!("BtJuiRG44vew5nYBVeUhuBawPTZLyYYxdzTYzerkfnto");
|
||||
@@ -203,7 +203,6 @@ const B_VAULT_LP_MINT: Pubkey = pubkey!("FZN7QZ8ZUUAxMPfxYEYkH3cXUASzH8EqA6B4tyC
|
||||
const A_VAULT_LP: Pubkey = pubkey!("2k7V1NtM1krwh1sdt5wWqBRcvNQ5jzxj3J2rV78zdTsL");
|
||||
const B_VAULT_LP: Pubkey = pubkey!("CFATQFgkKXJyU3MdCNvQqN79qorNSMJFF8jrF66a7r6i");
|
||||
const PROTOCOL_TOKEN_FEE: Pubkey = pubkey!("6kzYo2LMo2q2bkLAD8ienoG5NC1MkNXNTfm8sdyHuX3h");
|
||||
const METEORA_PROGRAM: Pubkey = pubkey!("Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB");
|
||||
|
||||
// let [signer_info, config_info, mint_info, treasury_info, treasury_ore_info, treasury_sol_info, token_program] =
|
||||
|
||||
@@ -229,7 +228,7 @@ pub fn bury(signer: Pubkey, min_amount_out: u64) -> Instruction {
|
||||
AccountMeta::new(treasury_sol_address, false),
|
||||
AccountMeta::new_readonly(system_program::ID, false),
|
||||
AccountMeta::new_readonly(spl_token::ID, false),
|
||||
AccountMeta::new_readonly(METEORA_PROGRAM, false),
|
||||
AccountMeta::new_readonly(meteora_pools_sdk::programs::AMM_ID, false),
|
||||
// Meteora accounts
|
||||
AccountMeta::new(POOL_ADDRESS, false),
|
||||
AccountMeta::new(treasury_sol_address, false),
|
||||
|
||||
@@ -2,15 +2,9 @@ use meteora_pools_sdk::instructions::SwapInstructionArgs;
|
||||
use ore_api::prelude::*;
|
||||
use solana_program::log::sol_log;
|
||||
use solana_program::native_token::lamports_to_sol;
|
||||
use solana_program::pubkey;
|
||||
use solana_program::pubkey::Pubkey;
|
||||
use spl_token::amount_to_ui_amount;
|
||||
use steel::*;
|
||||
|
||||
const TOKEN_A_MINT: Pubkey = pubkey!("oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp");
|
||||
const TOKEN_B_MINT: Pubkey = pubkey!("So11111111111111111111111111111111111111112");
|
||||
const METEORA_PROGRAM: Pubkey = pubkey!("Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB");
|
||||
|
||||
/// Swap vaulted SOL to ORE, and burn the ORE.
|
||||
pub fn process_bury(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult {
|
||||
// Parse data.
|
||||
@@ -31,11 +25,11 @@ pub fn process_bury(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult
|
||||
mint_info.has_address(&MINT_ADDRESS)?.as_mint()?;
|
||||
treasury_info.as_account_mut::<Treasury>(&ore_api::ID)?;
|
||||
let treasury_ore =
|
||||
treasury_ore_info.as_associated_token_account(treasury_info.key, &TOKEN_A_MINT)?;
|
||||
treasury_sol_info.as_associated_token_account(treasury_info.key, &TOKEN_B_MINT)?;
|
||||
treasury_ore_info.as_associated_token_account(treasury_info.key, &MINT_ADDRESS)?;
|
||||
treasury_sol_info.as_associated_token_account(treasury_info.key, &SOL_MINT)?;
|
||||
system_program.is_program(&system_program::ID)?;
|
||||
token_program.is_program(&spl_token::ID)?;
|
||||
meteora_program.is_program(&METEORA_PROGRAM)?;
|
||||
meteora_program.is_program(&meteora_pools_sdk::programs::AMM_ID)?;
|
||||
|
||||
// Load meteora accounts.
|
||||
let [pool, user_source_token, user_destination_token, a_vault, b_vault, a_token_vault, b_token_vault, a_vault_lp_mint, b_vault_lp_mint, a_vault_lp, b_vault_lp, protocol_token_fee, user_key, vault_program, token_program] =
|
||||
@@ -49,7 +43,7 @@ pub fn process_bury(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult
|
||||
|
||||
// Record pre-swap balances.
|
||||
let treasury_sol =
|
||||
treasury_sol_info.as_associated_token_account(treasury_info.key, &TOKEN_B_MINT)?;
|
||||
treasury_sol_info.as_associated_token_account(treasury_info.key, &SOL_MINT)?;
|
||||
let pre_swap_ore_balance = treasury_ore.amount();
|
||||
let pre_swap_sol_balance = treasury_sol.amount();
|
||||
assert!(pre_swap_sol_balance > 0);
|
||||
@@ -87,9 +81,9 @@ pub fn process_bury(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult
|
||||
|
||||
// Record post-swap balances.
|
||||
let treasury_ore =
|
||||
treasury_ore_info.as_associated_token_account(treasury_info.key, &TOKEN_A_MINT)?;
|
||||
treasury_ore_info.as_associated_token_account(treasury_info.key, &MINT_ADDRESS)?;
|
||||
let treasury_sol =
|
||||
treasury_sol_info.as_associated_token_account(treasury_info.key, &TOKEN_B_MINT)?;
|
||||
treasury_sol_info.as_associated_token_account(treasury_info.key, &SOL_MINT)?;
|
||||
let post_swap_ore_balance = treasury_ore.amount();
|
||||
let post_swap_sol_balance = treasury_sol.amount();
|
||||
assert_eq!(post_swap_sol_balance, 0);
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
use ore_api::prelude::*;
|
||||
use solana_program::pubkey;
|
||||
use solana_program::pubkey::Pubkey;
|
||||
use steel::*;
|
||||
|
||||
const TOKEN_B_MINT: Pubkey = pubkey!("So11111111111111111111111111111111111111112");
|
||||
|
||||
/// Send SOL from the treasury to the WSOL account.
|
||||
pub fn process_wrap(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResult {
|
||||
// Load accounts.
|
||||
@@ -19,7 +15,7 @@ pub fn process_wrap(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResult
|
||||
let treasury = treasury_info.as_account_mut::<Treasury>(&ore_api::ID)?;
|
||||
treasury_sol_info
|
||||
.is_writable()?
|
||||
.as_associated_token_account(treasury_info.key, &TOKEN_B_MINT)?;
|
||||
.as_associated_token_account(treasury_info.key, &SOL_MINT)?;
|
||||
system_program.is_program(&system_program::ID)?;
|
||||
|
||||
// Send SOL to the WSOL account.
|
||||
|
||||
Reference in New Issue
Block a user