This commit is contained in:
Hardhat Chad
2025-06-25 16:21:09 -05:00
parent 2cef573e36
commit 27c956c7b4
4 changed files with 31 additions and 5 deletions

View File

@@ -9,6 +9,7 @@ use crate::{
pub fn open(signer: Pubkey, id: u64) -> Instruction {
let block_adddress = block_pda(id).0;
let config_address = config_pda().0;
let market_address = market_pda(id).0;
let base_mint_address = mint_pda(id).0;
let collateral_address = collateral_pda(id).0;
@@ -21,6 +22,7 @@ pub fn open(signer: Pubkey, id: u64) -> Instruction {
accounts: vec![
AccountMeta::new(signer, true),
AccountMeta::new(block_adddress, false),
AccountMeta::new(config_address, false),
AccountMeta::new(collateral_address, false),
AccountMeta::new(commitment_address, false),
AccountMeta::new(market_address, false),
@@ -42,8 +44,12 @@ pub fn open(signer: Pubkey, id: u64) -> Instruction {
}
}
pub fn close(signer: Pubkey, recipient: Pubkey, id: u64) -> Instruction {
pub fn close(signer: Pubkey, fee_collector: Pubkey, recipient: Pubkey, id: u64) -> Instruction {
let block_adddress = block_pda(id).0;
let config_address = config_pda().0;
let collateral_address = collateral_pda(id).0;
let commitment_address = commitment_pda(id).0;
let fee_collector_address = get_associated_token_address(&fee_collector, &MINT_ADDRESS);
let market_address = market_pda(id).0;
let base_mint_address = mint_pda(id).0;
let vault_base = vault_base_pda(id).0;
@@ -53,6 +59,10 @@ pub fn close(signer: Pubkey, recipient: Pubkey, id: u64) -> Instruction {
accounts: vec![
AccountMeta::new(signer, true),
AccountMeta::new(block_adddress, false),
AccountMeta::new(config_address, false),
AccountMeta::new(collateral_address, false),
AccountMeta::new(commitment_address, false),
AccountMeta::new(fee_collector_address, false),
AccountMeta::new(market_address, false),
AccountMeta::new(base_mint_address, false),
AccountMeta::new(MINT_ADDRESS, false),

View File

@@ -10,14 +10,14 @@ pub struct Config {
// The address that can set the admin.
pub admin: Pubkey,
/// Number of blocks that can be open for trading at one time.
pub block_limit: u64,
// The address that receives fees.
pub fee_collector: Pubkey,
// The fee rate taken for each swap.
pub fee_rate: u64,
/// Number of blocks that can be open for trading at one time.
pub block_limit: u64,
}
impl Config {

View File

@@ -51,6 +51,12 @@ async fn main() {
"commit" => {
commit(&rpc, &payer).await.unwrap();
}
"set_admin" => {
set_admin(&rpc, &payer).await.unwrap();
}
// "set_block_limit" => {
// set_block_limit(&rpc, &payer).await.unwrap();
// }
// "uncommit" => {
// uncommit(&rpc, &payer).await.unwrap();
// }
@@ -75,7 +81,7 @@ async fn close(
) -> Result<(), anyhow::Error> {
let id_str = std::env::var("ID").expect("Missing ID env var");
let id = id_str.parse::<u64>()?;
let ix = ore_api::sdk::close(payer.pubkey(), payer.pubkey(), id);
let ix = ore_api::sdk::close(payer.pubkey(), payer.pubkey(), payer.pubkey(), id);
submit_transaction(rpc, payer, &[ix]).await?;
Ok(())
}
@@ -119,6 +125,15 @@ async fn swap(
Ok(())
}
async fn set_admin(
rpc: &RpcClient,
payer: &solana_sdk::signer::keypair::Keypair,
) -> Result<(), anyhow::Error> {
let ix = ore_api::sdk::set_admin(payer.pubkey(), payer.pubkey());
submit_transaction(rpc, payer, &[ix]).await?;
Ok(())
}
async fn log_clock(rpc: &RpcClient) -> Result<(), anyhow::Error> {
let clock = get_clock(&rpc).await?;
println!("Clock");

View File

@@ -29,6 +29,7 @@ pub fn process_set_admin(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramRe
)?;
let config = config_info.as_account_mut::<Config>(&ore_api::ID)?;
config.admin = *signer_info.key;
config.block_limit = 100;
config.fee_collector = *signer_info.key;
config.fee_rate = 0;
config