Compare commits
4 Commits
166d972222
...
221c6c0707
Author | SHA1 | Date |
---|---|---|
Maximilian Schneider | 221c6c0707 | |
Maximilian Schneider | b335258a16 | |
Maximilian Schneider | 79bc650029 | |
Maximilian Schneider | 30486b2f22 |
File diff suppressed because it is too large
Load Diff
|
@ -16,14 +16,15 @@ clap = "3.0.0-beta.2"
|
|||
solana-client = "^1.6.4"
|
||||
solana-cli = "^1.6.4"
|
||||
solana-sdk = "^1.6.4"
|
||||
mango = { version = "*", path = "../program", features=["no-entrypoint"] }
|
||||
spl-token = { version = "^3.1.0", features=["no-entrypoint"] }
|
||||
serde_json = "1.0.60"
|
||||
chrono = "*"
|
||||
common = { version = "*", path = "../common" }
|
||||
serum_dex = { version = "^0.2", git = "https://github.com/blockworks-foundation/serum-dex.git", features=["no-entrypoint", "program"] }
|
||||
|
||||
flux-aggregator = { version = "^0.1", git = "https://github.com/blockworks-foundation/solana-flux-aggregator.git", features=["program", "no-entrypoint"] }
|
||||
arrayref = "^0.3.6"
|
||||
|
||||
fixed = { version = "^1.7.0" }
|
||||
|
||||
common = { version = "*", path = "../common" }
|
||||
mango = { version = "*", path = "../program", features=["no-entrypoint"] }
|
||||
|
||||
spl-token = { version = "^3.0.0", features=["no-entrypoint"] }
|
||||
serum_dex = { version = "0.4.0", rev="3104f424ee38a415418a1cdef67970771f832857", git = "https://github.com/blockworks-foundation/serum-dex.git", default-features=false, features = ["no-entrypoint", "program"] }
|
||||
flux-aggregator = { version = "^0.1", rev="ca6706d05218acc84d164ed5149fac7612d3aa2b", git = "https://github.com/blockworks-foundation/solana-flux-aggregator.git", features=["program", "no-entrypoint"] }
|
||||
pyth-client = {version = ">=0.5.0", features = ["no-entrypoint"]}
|
||||
|
|
|
@ -17,7 +17,7 @@ use solana_sdk::commitment_config::CommitmentConfig;
|
|||
use solana_sdk::program_pack::Pack;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::signature::{Signer};
|
||||
use mango::instruction::{init_mango_group, init_margin_account, withdraw, borrow, deposit, settle_borrow, change_borrow_limit};
|
||||
use mango::instruction::{init_mango_group, init_margin_account, withdraw, borrow, deposit, settle_borrow, change_borrow_limit, switch_oracles};
|
||||
|
||||
#[derive(Clap, Debug)]
|
||||
pub struct Opts {
|
||||
|
@ -145,7 +145,7 @@ pub enum Command {
|
|||
#[clap(long)]
|
||||
mango_group_name: String,
|
||||
#[clap(long)]
|
||||
token_symbol: String,
|
||||
pair_name: String,
|
||||
#[clap(long)]
|
||||
oracle: String,
|
||||
},
|
||||
|
@ -697,7 +697,7 @@ pub fn start(opts: Opts) -> Result<()> {
|
|||
payer,
|
||||
ids_path,
|
||||
mango_group_name,
|
||||
token_symbol,
|
||||
pair_name,
|
||||
oracle,
|
||||
} => {
|
||||
println!("SwitchOracle");
|
||||
|
@ -708,15 +708,15 @@ pub fn start(opts: Opts) -> Result<()> {
|
|||
let cids = ClusterIds::load(cluster_ids);
|
||||
let mgids = cids.mango_groups[&mango_group_name].clone();
|
||||
// replace old oracle with new one when assembling instruction
|
||||
let old_oracle_pk = &cids.oracles[&token_symbol];
|
||||
let new_oracle_pks = mgids
|
||||
.oracles
|
||||
let old_oracle_pk = &cids.oracles[&pair_name];
|
||||
let new_oracle_pks: Vec<Pubkey> = mgids
|
||||
.oracle_pks
|
||||
.iter()
|
||||
.map(|o| {
|
||||
if o == old_oracle_pk {
|
||||
Pubkey::from_str(oracle.as_str())?
|
||||
Pubkey::from_str(oracle.as_str()).unwrap()
|
||||
} else {
|
||||
o
|
||||
*o
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
@ -724,16 +724,16 @@ pub fn start(opts: Opts) -> Result<()> {
|
|||
&cids.mango_program_id,
|
||||
&mgids.mango_group_pk,
|
||||
&payer.pubkey(),
|
||||
new_oracle_pks,
|
||||
);
|
||||
&new_oracle_pks.as_slice(),
|
||||
)?;
|
||||
let instructions = vec![instruction];
|
||||
let signers = vec![&payer];
|
||||
send_instructions(&client, instructions, signers, &payer.pubkey())?;
|
||||
// update ids
|
||||
let oracle_pks = ids[cluster_name][mango_group_name].get_mut("oracle_pks")?;
|
||||
oracle_pks = new_oracle_pks.iter().map(|pk| pk.to_string);
|
||||
let f = File::create(ids_path.as_str()).unwrap();
|
||||
serde_json::to_writer_pretty(&f, &ids).unwrap();
|
||||
// let oracle_pks = ids[cluster_name][mango_group_name].get_mut("oracle_pks").unwrap();
|
||||
// oracle_pks = new_oracle_pks.iter().map(|pk| pk.to_string()).collect() as Vec<String>;
|
||||
// let f = File::create(ids_path.as_str()).unwrap();
|
||||
// serde_json::to_writer_pretty(&f, &ids).unwrap();
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
@ -414,7 +414,7 @@ dependencies = [
|
|||
"bs58 0.4.0",
|
||||
"bytemuck",
|
||||
"ed25519-dalek",
|
||||
"rand 0.8.4",
|
||||
"rand 0.7.3",
|
||||
"serde_json",
|
||||
"solana-client",
|
||||
"solana-sdk",
|
||||
|
|
|
@ -10,11 +10,11 @@ solana-sdk = "^1.7.10"
|
|||
spl-token = { version = "^3.2.0", features=["no-entrypoint"] }
|
||||
anyhow = "^1.0.43"
|
||||
solana-client = "^1.7.10"
|
||||
rand = "0.8.4"
|
||||
rand = "^0.7.0"
|
||||
serde_json = "^1.0.66"
|
||||
bs58 = "0.4.0"
|
||||
bincode = "^1.3.1"
|
||||
bytemuck = "^1.7.2"
|
||||
tiny-bip39 = "0.8.0"
|
||||
tiny-hderive = "0.3.0"
|
||||
ed25519-dalek = "1.0.0-pre.4"
|
||||
ed25519-dalek = "^1.0.0"
|
||||
|
|
|
@ -57,7 +57,7 @@ impl std::fmt::Display for Cluster {
|
|||
impl Cluster {
|
||||
pub fn url(&self) -> &'static str {
|
||||
match self {
|
||||
Cluster::Devnet => "https://devnet.solana.com",
|
||||
Cluster::Devnet => "https://api.devnet.solana.com",
|
||||
Cluster::Testnet => "https://testnet.solana.com",
|
||||
// Cluster::Mainnet => "https://api.stakeconomy.com",
|
||||
Cluster::Mainnet => "https://api.mainnet-beta.solana.com",
|
||||
|
|
Loading…
Reference in New Issue