This commit is contained in:
Hardhat Chad
2025-06-13 13:20:24 -07:00
parent f487593ba2
commit 1e4e9d9fdf
4 changed files with 70 additions and 30 deletions

View File

@@ -42,6 +42,12 @@ async fn main() {
"blocks" => {
log_blocks(&rpc).await.unwrap();
}
"deposit" => {
deposit(&rpc, &payer).await.unwrap();
}
"swap" => {
swap(&rpc, &payer).await.unwrap();
}
_ => panic!("Invalid command"),
};
}
@@ -68,6 +74,34 @@ async fn close(
Ok(())
}
async fn deposit(
rpc: &RpcClient,
payer: &solana_sdk::signer::keypair::Keypair,
) -> 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::deposit(payer.pubkey(), id, 10000000);
submit_transaction(rpc, payer, &[ix]).await?;
Ok(())
}
async fn swap(
rpc: &RpcClient,
payer: &solana_sdk::signer::keypair::Keypair,
) -> 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::swap(
payer.pubkey(),
id,
10000000,
SwapDirection::Buy,
SwapPrecision::ExactIn,
);
submit_transaction(rpc, payer, &[ix]).await?;
Ok(())
}
async fn log_clock(rpc: &RpcClient) -> Result<(), anyhow::Error> {
let clock = get_clock(&rpc).await?;
println!("Clock: {:?}", clock);