From 399eecd13af30b85c23d7a5092e6a7314f5a376d Mon Sep 17 00:00:00 2001 From: iamakshat01 Date: Tue, 13 Dec 2022 15:53:15 +0530 Subject: [PATCH 1/6] WIP --- Cargo.lock | 145 +++++++++++++++++++++++++++++++++++++++++-- Cargo.toml | 7 ++- src/args/otc_args.rs | 20 ++++++ src/main.rs | 6 +- src/ops/otc_ops.rs | 57 ++++++++++++++++- 5 files changed, 224 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 714ddab..f0c75e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -754,6 +754,31 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crossterm" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2102ea4f781910f8a5b98dd061f4c2023f479ce7bb1236330099ceb5a93cf17" +dependencies = [ + "bitflags", + "crossterm_winapi", + "libc", + "mio 0.8.5", + "parking_lot 0.12.1", + "signal-hook", + "signal-hook-mio", + "winapi", +] + +[[package]] +name = "crossterm_winapi" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ae1b35a484aa10e07fe0638d02301c5ad24de82d310ccbd2f3693da5f09bf1c" +dependencies = [ + "winapi", +] + [[package]] name = "crunchy" version = "0.2.2" @@ -1751,6 +1776,18 @@ dependencies = [ "winapi", ] +[[package]] +name = "mio" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" +dependencies = [ + "libc", + "log", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys", +] + [[package]] name = "miow" version = "0.3.7" @@ -1908,7 +1945,17 @@ checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ "instant", "lock_api", - "parking_lot_core", + "parking_lot_core 0.8.5", +] + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core 0.9.5", ] [[package]] @@ -1925,6 +1972,19 @@ dependencies = [ "winapi", ] +[[package]] +name = "parking_lot_core" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ff9f3fef3968a3ec5945535ed654cb38ff72d7495a25619e2247fb15a2ed9ba" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-sys", +] + [[package]] name = "pbkdf2" version = "0.4.0" @@ -2295,6 +2355,30 @@ dependencies = [ "bytecheck", ] +[[package]] +name = "requestty" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d06fb394ca73d15ad0c7bbc673459506a851a84586cd90d67d42932a280281e" +dependencies = [ + "requestty-ui", + "smallvec", + "tempfile", +] + +[[package]] +name = "requestty-ui" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31a4bce6f730d12e36993944036e2f93e88033d8a78734d8734fdb0043662cae" +dependencies = [ + "bitflags", + "crossterm", + "once_cell", + "textwrap 0.15.2", + "unicode-segmentation", +] + [[package]] name = "reqwest" version = "0.11.13" @@ -2611,6 +2695,27 @@ dependencies = [ "opaque-debug", ] +[[package]] +name = "signal-hook" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a253b5e89e2698464fc26b545c9edceb338e18a89effeeecfea192c3025be29d" +dependencies = [ + "libc", + "signal-hook-registry", +] + +[[package]] +name = "signal-hook-mio" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af" +dependencies = [ + "libc", + "mio 0.8.5", + "signal-hook", +] + [[package]] name = "signal-hook-registry" version = "1.4.0" @@ -2641,6 +2746,12 @@ version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +[[package]] +name = "smawk" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f67ad224767faa3c7d8b6d91985b78e70a1324408abcb1cfcc2be4c06bc06043" + [[package]] name = "socket2" version = "0.4.7" @@ -2986,7 +3097,7 @@ dependencies = [ "log", "num-derive", "num-traits", - "parking_lot", + "parking_lot 0.11.2", "rand 0.7.3", "rustc_version", "rustversion", @@ -3050,7 +3161,7 @@ dependencies = [ "log", "num-derive", "num-traits", - "parking_lot", + "parking_lot 0.11.2", "qstring", "semver", "solana-sdk", @@ -3446,6 +3557,17 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "textwrap" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7b3e525a49ec206798b40326a44121291b530c963cfb01018f63e135bac543d" +dependencies = [ + "smawk", + "unicode-linebreak", + "unicode-width", +] + [[package]] name = "textwrap" version = "0.16.0" @@ -3527,10 +3649,10 @@ dependencies = [ "bytes", "libc", "memchr", - "mio", + "mio 0.7.14", "num_cpus", "once_cell", - "parking_lot", + "parking_lot 0.11.2", "pin-project-lite", "signal-hook-registry", "tokio-macros", @@ -3666,6 +3788,16 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" +[[package]] +name = "unicode-linebreak" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5faade31a542b8b35855fff6e8def199853b2da8da256da52f52f1316ee3137" +dependencies = [ + "hashbrown 0.12.3", + "regex", +] + [[package]] name = "unicode-normalization" version = "0.1.22" @@ -3745,7 +3877,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] -name = "vyper" +name = "vyper-cli" version = "0.0.1" dependencies = [ "anchor-client", @@ -3758,6 +3890,7 @@ dependencies = [ "redeem-logic-forward", "redeem-logic-settled-forward", "redeem-logic-vanilla-option", + "requestty", "rust_decimal", "rust_decimal_macros", "solana-cli-config", diff --git a/Cargo.toml b/Cargo.toml index 95759bc..6d4818e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "vyper" +name = "vyper-cli" version = "0.0.1" edition = "2021" @@ -21,3 +21,8 @@ console = "0.15.1" rust_decimal = "1.26" rust_decimal_macros = "1.26" chrono = "0.4.23" +requestty = "0.4.1" + +[[bin]] +name = "vyper" +path = "./main.rs" diff --git a/src/args/otc_args.rs b/src/args/otc_args.rs index f5a708d..4efb64d 100644 --- a/src/args/otc_args.rs +++ b/src/args/otc_args.rs @@ -22,10 +22,30 @@ pub struct OtcCommand { pub enum OtcSubcommand { /// Gets the configuration of otc from given public key. Fetch(FetchOtc), + /// Creates the otc with input configuration + Create(CreateOtc) } #[derive(Debug, Args)] pub struct FetchOtc { /// Public key of otc state. pub state_id: Pubkey +} + +#[derive(Debug, Args)] +pub struct CreateOtc { + // /// Senior deposit amount + // pub senior_deposit_amount: u64, + // /// Junior deposit amount + // pub junior_deposit_amount: u64, + // /// Deposit end date and time + // pub deposit_end: i64, + // /// Settle start date and time + // pub settle_start: i64, + /// Rate plugin type + pub rate_plugin_type: String, + /// Redeem plugin type + pub redeem_plugin_type: String, + // /// Deposit start date and time + // pub deposit_start: Option, } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 031d884..ec953a8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -126,8 +126,12 @@ fn main() { // otc program let otc_program_id: Pubkey = Pubkey::new(&bs58::decode(&OTC).into_vec().expect("Invalid otc program id")); let otc_program = client.program(otc_program_id); + // vyper core program + let core_program_id: Pubkey = Pubkey::new(&bs58::decode(&VYPER_CORE_ID).into_vec().expect("Invalid vyper core program id")); + let core_program = client.program(core_program_id); + // command handler - handle_otc_command(otc_command, &otc_program); + handle_otc_command(otc_command, &otc_program, &core_program); } } } diff --git a/src/ops/otc_ops.rs b/src/ops/otc_ops.rs index 59b8d33..ad489ca 100644 --- a/src/ops/otc_ops.rs +++ b/src/ops/otc_ops.rs @@ -14,7 +14,13 @@ use { }, anchor_client::{ Program, - ClientError + ClientError, + solana_sdk:: { + signer::keypair::Keypair, + signer::Signer, + system_program, + pubkey::Pubkey + }, }, vyper_otc::state::OtcState, console::style @@ -22,11 +28,12 @@ use { -pub fn handle_otc_command(otc_command: OtcCommand, program: &Program) { + +pub fn handle_otc_command(otc_command: OtcCommand, otc_program: &Program, core_program: &Program) { let command = otc_command.command; match command { OtcSubcommand::Fetch(fetch_otc) => { - let account:Result = program.account(fetch_otc.state_id); + let account:Result = otc_program.account(fetch_otc.state_id); let account = match account { Ok(otc_state) => otc_state, Err(err) => { @@ -61,5 +68,49 @@ pub fn handle_otc_command(otc_command: OtcCommand, program: &Program) { println_name_value("authority bump", &account.authority_bump); println_version("version",&account.version); } + + OtcSubcommand::Create(create_otc) => { + + + // :TODO + let collateralMintInfo: String; + + let otc_state = Keypair::new(); + let otc_authority = Pubkey::find_program_address(&[otc_state.pubkey().as_ref(),b"authority"], &otc_program.id()); + + let rate_plugin_state = Keypair::new(); + + // let rate_plugin = match create_otc.rate_plugin_type { + // String::from("swicthboard") + // } + if create_otc.rate_plugin_type.eq(&String::from("switchboard")) { + + } else if create_otc.rate_plugin_type.eq(&String::from("pyth")) { + + } else { + // error + } + + let redeem_plugin_state = Keypair::new(); + if create_otc.redeem_plugin_type.eq(&String::from("forward")) { + let notional = requestty::Question::int("notional") + .message("notional") + .build(); + println!("{:#?}", requestty::prompt_one(notional)); + + } else if create_otc.redeem_plugin_type.eq(&String::from("settled_forward")) { + + } else if create_otc.redeem_plugin_type.eq(&String::from("digital")) { + + } else if create_otc.redeem_plugin_type.eq(&String::from("vanilla_option")) { + + } else { + // error + } + + + + // println!("{:?}",create_otc) + } } } \ No newline at end of file From fa839acf1e3635158d6b71ee18e9a221a722cd27 Mon Sep 17 00:00:00 2001 From: iamakshat01 Date: Wed, 14 Dec 2022 12:52:53 +0530 Subject: [PATCH 2/6] WIP : setting up the flow for plugin creation --- Cargo.toml | 2 +- src/args/otc_args.rs | 20 +------- src/main.rs | 16 +++--- src/ops/otc_ops.rs | 113 +++++++++++++++++++++++++++++++------------ 4 files changed, 91 insertions(+), 60 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6d4818e..d22ba21 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,4 +25,4 @@ requestty = "0.4.1" [[bin]] name = "vyper" -path = "./main.rs" +path = "./src/main.rs" diff --git a/src/args/otc_args.rs b/src/args/otc_args.rs index 4efb64d..2b9d0ae 100644 --- a/src/args/otc_args.rs +++ b/src/args/otc_args.rs @@ -23,29 +23,11 @@ pub enum OtcSubcommand { /// Gets the configuration of otc from given public key. Fetch(FetchOtc), /// Creates the otc with input configuration - Create(CreateOtc) + Create } #[derive(Debug, Args)] pub struct FetchOtc { /// Public key of otc state. pub state_id: Pubkey -} - -#[derive(Debug, Args)] -pub struct CreateOtc { - // /// Senior deposit amount - // pub senior_deposit_amount: u64, - // /// Junior deposit amount - // pub junior_deposit_amount: u64, - // /// Deposit end date and time - // pub deposit_end: i64, - // /// Settle start date and time - // pub settle_start: i64, - /// Rate plugin type - pub rate_plugin_type: String, - /// Redeem plugin type - pub redeem_plugin_type: String, - // /// Deposit start date and time - // pub deposit_start: Option, } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index ec953a8..92b5dfd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -34,12 +34,12 @@ use { }; -const VYPER_CORE_ID: &str = "vyPErCcGJKQQBeeQ59gXcWrDyU4vBrq8qQfacwmsAsp"; -const REDEEM_LOGIC_FORWARD: &str = "BrpV1re8MshA8qskKVxcEG8zXG3vf2uLX6myeTKAyhsK"; -const RATE_SWITCHBOARD: &str = "2hGXiH1oEQwjCXRx8bNdHTi49ScZp7Mj2bxcjxtULKe1"; -const OTC: &str = "8aHSkExY28qCvg4gnTLU7y1Ev6HnpJ1NxuWb9XtEesVt"; -const REDEEM_LOGIC_SETTLE_FORWARD: &str = "6vBg1GMtKj7EYDLWWt6tkHoDWLAAksNPbKWiXMic99qU"; -const REDEEM_LOGIC_VANILLA_OPTION: &str = "8fSeRtFseNrjdf8quE2YELhuzLkHV7WEGRPA9Jz8xEVe"; +pub const VYPER_CORE_ID: &str = "vyPErCcGJKQQBeeQ59gXcWrDyU4vBrq8qQfacwmsAsp"; +pub const REDEEM_LOGIC_FORWARD: &str = "BrpV1re8MshA8qskKVxcEG8zXG3vf2uLX6myeTKAyhsK"; +pub const RATE_SWITCHBOARD: &str = "2hGXiH1oEQwjCXRx8bNdHTi49ScZp7Mj2bxcjxtULKe1"; +pub const OTC: &str = "8aHSkExY28qCvg4gnTLU7y1Ev6HnpJ1NxuWb9XtEesVt"; +pub const REDEEM_LOGIC_SETTLE_FORWARD: &str = "6vBg1GMtKj7EYDLWWt6tkHoDWLAAksNPbKWiXMic99qU"; +pub const REDEEM_LOGIC_VANILLA_OPTION: &str = "8fSeRtFseNrjdf8quE2YELhuzLkHV7WEGRPA9Jz8xEVe"; fn main() { @@ -85,7 +85,7 @@ fn main() { }; - let client = Client::new(current_cluster, Rc::new(key_pair)); + let client = Client::new(current_cluster.clone(), Rc::new(key_pair)); match args.vyper { Vyper::Core(core) => { // vyper core program @@ -131,7 +131,7 @@ fn main() { let core_program = client.program(core_program_id); // command handler - handle_otc_command(otc_command, &otc_program, &core_program); + handle_otc_command(otc_command, &otc_program, &core_program, &client, current_cluster); } } } diff --git a/src/ops/otc_ops.rs b/src/ops/otc_ops.rs index ad489ca..574ef9f 100644 --- a/src/ops/otc_ops.rs +++ b/src/ops/otc_ops.rs @@ -13,23 +13,32 @@ use { OtcSubcommand }, anchor_client::{ + Client, Program, + Cluster, ClientError, solana_sdk:: { signer::keypair::Keypair, signer::Signer, + pubkey:: Pubkey, system_program, - pubkey::Pubkey + instruction::AccountMeta }, }, vyper_otc::state::OtcState, - console::style + rate_switchboard::{ + accounts::InitializeContext, + instruction::Initialize, + }, + console::style, + requestty::{Question,prompt_one}, + crate::{RATE_SWITCHBOARD} }; -pub fn handle_otc_command(otc_command: OtcCommand, otc_program: &Program, core_program: &Program) { +pub fn handle_otc_command(otc_command: OtcCommand, otc_program: &Program, core_program: &Program, client: &Client, cluster: Cluster) { let command = otc_command.command; match command { OtcSubcommand::Fetch(fetch_otc) => { @@ -69,48 +78,88 @@ pub fn handle_otc_command(otc_command: OtcCommand, otc_program: &Program, core_p println_version("version",&account.version); } - OtcSubcommand::Create(create_otc) => { + OtcSubcommand::Create => { + + let rate_plugin_question = Question::select("rate plugin") + .message("Which rate plugin to select?") + .choice("Rate Switchboard") + .choice("Rate Pyth") + .build(); + let rate_plugin_answer = prompt_one(rate_plugin_question).unwrap(); + let rate_plugin_type = rate_plugin_answer.as_list_item().unwrap(); - // :TODO - let collateralMintInfo: String; - - let otc_state = Keypair::new(); - let otc_authority = Pubkey::find_program_address(&[otc_state.pubkey().as_ref(),b"authority"], &otc_program.id()); - - let rate_plugin_state = Keypair::new(); + let redeem_plugin_question = Question::select("redeem plugin") + .message("Which redeem plugin to select?") + .choice("Redeem Forward") + .choice("Redeem Settled Forward") + .choice("Redeem Digital") + .choice("Redeem Vanilla Option") + .build(); + let redeem_plugin_answer = prompt_one(redeem_plugin_question).unwrap(); + let redeem_plugin_type = redeem_plugin_answer.as_list_item().unwrap(); + + if rate_plugin_type.text == String::from("Rate Switchboard") { + // rate switchboard program + let rate_switchboard_program_id: Pubkey = Pubkey::new(&bs58::decode(&RATE_SWITCHBOARD).into_vec().expect("Invalid rate switchboard program id")); + let rate_switchboard_program = client.program(rate_switchboard_program_id); + + let rate_switchboard_state = Keypair::new(); + let rateAccounts = match cluster.url() { + "https://api.devnet.solana.com" => "9LNYQZLJG5DAyeACCTzBFG6H3sDhehP5xtYLdhrZtQkA", + _ => "7Y3nWv5B2rLiDBsNpkfXqa4cbJqszJos2sZVutF8R3FE" + }; + + let signature = rate_switchboard_program.request() + .signer(&rate_switchboard_state) + .accounts(InitializeContext { + rate_data: rate_switchboard_state.pubkey(), + signer: rate_switchboard_program.payer(), + system_program: system_program::ID + }) + .accounts(AccountMeta::new_readonly(Pubkey::new(&bs58::decode(&rateAccounts).into_vec().expect("Invalid otc program id")), false)) + .args(Initialize {}) + .send(); + let signature = match signature { + Ok(transaction) => transaction, + Err(err) => { + match err { + ClientError::AccountNotFound => println_error("Could not find a state with given public key"), + ClientError::AnchorError(err) => println!("{} : {}",style("error").red().bold(),err), + ClientError::ProgramError(err) => println!("{} : {}",style("error").red().bold(),err), + ClientError::SolanaClientError(err) => println!("{} : {}",style("error").red().bold(),err), + ClientError::SolanaClientPubsubError(err) => println!("{} : {}",style("error").red().bold(),err), + ClientError::LogParseError(err)=> println_error(&err) + } + exit(1); + } + }; + println_name_value("Rate Switchboard Plugin State successfully create at", &rate_switchboard_state.pubkey()); + println_name_value("Transaction Id", &signature); + - // let rate_plugin = match create_otc.rate_plugin_type { - // String::from("swicthboard") - // } - if create_otc.rate_plugin_type.eq(&String::from("switchboard")) { - - } else if create_otc.rate_plugin_type.eq(&String::from("pyth")) { + } else if rate_plugin_type.text == String::from("Rate Pyth") { } else { - // error + //error } - let redeem_plugin_state = Keypair::new(); - if create_otc.redeem_plugin_type.eq(&String::from("forward")) { - let notional = requestty::Question::int("notional") - .message("notional") - .build(); - println!("{:#?}", requestty::prompt_one(notional)); + if redeem_plugin_type.text == String::from("Redeem Forward") { + println!("{}","RATE SWITCH"); + } else if redeem_plugin_type.text == String::from("Redeem Settled Forward") { - } else if create_otc.redeem_plugin_type.eq(&String::from("settled_forward")) { - - } else if create_otc.redeem_plugin_type.eq(&String::from("digital")) { - - } else if create_otc.redeem_plugin_type.eq(&String::from("vanilla_option")) { + } else if redeem_plugin_type.text == String::from("Redeem Digital") { + + } else if redeem_plugin_type.text == String::from("Redeem Vanilla") { } else { - // error + //error } - - // println!("{:?}",create_otc) + println!("{:?} {:?}",rate_plugin_type.text, redeem_plugin_type.text); + + } } } \ No newline at end of file From f07e5b022dce05965f9acb5acf92637a8a37044d Mon Sep 17 00:00:00 2001 From: iamakshat01 Date: Wed, 21 Dec 2022 22:32:24 +0530 Subject: [PATCH 3/6] Added function to create otc contract --- Cargo.lock | 491 ++++++++++++++++++++----------------------- Cargo.toml | 3 +- src/args/otc_args.rs | 2 +- src/main.rs | 6 +- src/ops/otc_ops.rs | 442 +++++++++++++++++++++++++++++++------- src/utils.rs | 38 +++- 6 files changed, 644 insertions(+), 338 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 764a5ec..5a22d07 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,9 +14,9 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.17.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" +checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" dependencies = [ "gimli", ] @@ -61,10 +61,10 @@ checksum = "a9b75d05b6b4ac9d95bb6e3b786b27d3a708c4c5a87c92ffaa25bbe9ae4c5d91" dependencies = [ "anchor-syn", "anyhow", - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.49", + "quote 1.0.23", "regex", - "syn 1.0.105", + "syn 1.0.107", ] [[package]] @@ -76,10 +76,10 @@ dependencies = [ "anchor-syn", "anyhow", "bs58 0.4.0", - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.49", + "quote 1.0.23", "rustversion", - "syn 1.0.105", + "syn 1.0.107", ] [[package]] @@ -89,8 +89,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc632c540913dd051a78b00587cc47f57013d303163ddfaf4fa18717f7ccc1e0" dependencies = [ "anchor-syn", - "proc-macro2 1.0.47", - "syn 1.0.105", + "proc-macro2 1.0.49", + "syn 1.0.107", ] [[package]] @@ -100,9 +100,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b5bd1dcfa7f3bc22dacef233d70a9e0bee269c4ac484510662f257cba2353a1" dependencies = [ "anchor-syn", - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.105", + "proc-macro2 1.0.49", + "quote 1.0.23", + "syn 1.0.107", ] [[package]] @@ -113,9 +113,9 @@ checksum = "6c6f9e6ce551ac9a177a45c99a65699a860c9e95fac68675138af1246e2591b0" dependencies = [ "anchor-syn", "anyhow", - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.105", + "proc-macro2 1.0.49", + "quote 1.0.23", + "syn 1.0.107", ] [[package]] @@ -127,9 +127,9 @@ dependencies = [ "anchor-syn", "anyhow", "heck 0.3.3", - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.105", + "proc-macro2 1.0.49", + "quote 1.0.23", + "syn 1.0.107", ] [[package]] @@ -140,9 +140,9 @@ checksum = "b6831b920b173c004ddf7ae1167d1d25e9f002ffcb1773bbc5c7ce532a4441e1" dependencies = [ "anchor-syn", "anyhow", - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.105", + "proc-macro2 1.0.49", + "quote 1.0.23", + "syn 1.0.107", ] [[package]] @@ -153,9 +153,9 @@ checksum = "cde147b10c71d95dc679785db0b5f3abac0091f789167aa62ac0135e2f54e8b9" dependencies = [ "anchor-syn", "anyhow", - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.105", + "proc-macro2 1.0.49", + "quote 1.0.23", + "syn 1.0.107", ] [[package]] @@ -183,9 +183,9 @@ checksum = "9cde98a0e1a56046b040ff591dfda391f88917af2b6487d02b45093c05be3514" dependencies = [ "anchor-syn", "anyhow", - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.105", + "proc-macro2 1.0.49", + "quote 1.0.23", + "syn 1.0.107", ] [[package]] @@ -233,13 +233,13 @@ dependencies = [ "anyhow", "bs58 0.3.1", "heck 0.3.3", - "proc-macro2 1.0.47", + "proc-macro2 1.0.49", "proc-macro2-diagnostics", - "quote 1.0.21", + "quote 1.0.23", "serde", "serde_json", "sha2", - "syn 1.0.105", + "syn 1.0.107", "thiserror", ] @@ -263,9 +263,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.66" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" +checksum = "2cb2f989d18dd141ab8ae82f64d1a8cdd37e0840f73a406896cf5e99502fab61" [[package]] name = "arrayref" @@ -291,7 +291,7 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "hermit-abi", + "hermit-abi 0.1.19", "libc", "winapi", ] @@ -304,15 +304,15 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.66" +version = "0.3.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7" +checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" dependencies = [ "addr2line", "cc", "cfg-if", "libc", - "miniz_oxide 0.5.4", + "miniz_oxide", "object", "rustc-demangle", ] @@ -414,8 +414,8 @@ dependencies = [ "borsh-derive-internal", "borsh-schema-derive-internal", "proc-macro-crate 0.1.5", - "proc-macro2 1.0.47", - "syn 1.0.105", + "proc-macro2 1.0.49", + "syn 1.0.107", ] [[package]] @@ -424,9 +424,9 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5449c28a7b352f2d1e592a8a28bf139bc71afb0764a14f3c02500935d8c44065" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.105", + "proc-macro2 1.0.49", + "quote 1.0.23", + "syn 1.0.107", ] [[package]] @@ -435,9 +435,9 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdbd5696d8bfa21d53d9fe39a714a18538bad11492a42d066dbbc395fb1951c0" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.105", + "proc-macro2 1.0.49", + "quote 1.0.23", + "syn 1.0.107", ] [[package]] @@ -484,9 +484,9 @@ version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13e576ebe98e605500b3c8041bb888e966653577172df6dd97398714eb30b9bf" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.105", + "proc-macro2 1.0.49", + "quote 1.0.23", + "syn 1.0.107", ] [[package]] @@ -504,9 +504,9 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5fe233b960f12f8007e3db2d136e3cb1c291bfd7396e384ee76025fc1a3932b4" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.105", + "proc-macro2 1.0.49", + "quote 1.0.23", + "syn 1.0.107", ] [[package]] @@ -554,9 +554,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.77" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4" +checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d" dependencies = [ "jobserver", ] @@ -623,9 +623,9 @@ checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65" dependencies = [ "heck 0.4.0", "proc-macro-error", - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.105", + "proc-macro2 1.0.49", + "quote 1.0.23", + "syn 1.0.107", ] [[package]] @@ -756,9 +756,9 @@ dependencies = [ [[package]] name = "crossterm" -version = "0.23.2" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2102ea4f781910f8a5b98dd061f4c2023f479ce7bb1236330099ceb5a93cf17" +checksum = "e64e6c0fbe2c17357405f7c758c1ef960fce08bdfb2c03d88d2a18d7e09c4b67" dependencies = [ "bitflags", "crossterm_winapi", @@ -840,9 +840,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.83" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdf07d07d6531bfcdbe9b8b739b104610c6508dcc4d63b410585faf338241daf" +checksum = "5add3fc1717409d029b20c5b6903fc0c0b02fa6741d820054f4a2efa5e5816fd" dependencies = [ "cc", "cxxbridge-flags", @@ -852,34 +852,34 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.83" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2eb5b96ecdc99f72657332953d4d9c50135af1bac34277801cc3937906ebd39" +checksum = "b4c87959ba14bc6fbc61df77c3fcfe180fc32b93538c4f1031dd802ccb5f2ff0" dependencies = [ "cc", "codespan-reporting", "once_cell", - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.49", + "quote 1.0.23", "scratch", - "syn 1.0.105", + "syn 1.0.107", ] [[package]] name = "cxxbridge-flags" -version = "1.0.83" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac040a39517fd1674e0f32177648334b0f4074625b5588a64519804ba0553b12" +checksum = "69a3e162fde4e594ed2b07d0f83c6c67b745e7f28ce58c6df5e6b6bef99dfb59" [[package]] name = "cxxbridge-macro" -version = "1.0.83" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1362b0ddcfc4eb0a1f57b68bd77dd99f0e826958a96abd0ae9bd092e114ffed6" +checksum = "3e7e2adeb6a0d4a282e581096b06e1791532b7d576dcde5ccd9382acf55db8e6" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.105", + "proc-macro2 1.0.49", + "quote 1.0.23", + "syn 1.0.107", ] [[package]] @@ -989,9 +989,9 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f94fa09c2aeea5b8839e414b7b841bf429fd25b9c522116ac97ee87856d88b2" +checksum = "c9b0705efd4599c15a38151f4721f7bc388306f61084d3bfd50bd07fbca5cb60" [[package]] name = "ed25519" @@ -1079,9 +1079,9 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.105", + "proc-macro2 1.0.49", + "quote 1.0.23", + "syn 1.0.107", "synstructure", ] @@ -1119,7 +1119,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" dependencies = [ "crc32fast", - "miniz_oxide 0.6.2", + "miniz_oxide", ] [[package]] @@ -1197,9 +1197,9 @@ version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.105", + "proc-macro2 1.0.49", + "quote 1.0.23", + "syn 1.0.107", ] [[package]] @@ -1279,9 +1279,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.26.2" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" +checksum = "dec7af912d60cdbd3677c1af9352ebae6fb8394d165568a2234df0fa00f87793" [[package]] name = "h2" @@ -1344,6 +1344,15 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + [[package]] name = "hex" version = "0.4.3" @@ -1545,6 +1554,22 @@ dependencies = [ "regex", ] +[[package]] +name = "inquire" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6055ce38cac9b10ac819ed4a509d92ccbc60808152c19ff9121c98198964272" +dependencies = [ + "bitflags", + "crossterm", + "dyn-clone", + "lazy_static", + "newline-converter", + "thiserror", + "unicode-segmentation", + "unicode-width", +] + [[package]] name = "instant" version = "0.1.12" @@ -1571,9 +1596,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" +checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" [[package]] name = "jobserver" @@ -1689,9 +1714,9 @@ dependencies = [ [[package]] name = "link-cplusplus" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369" +checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" dependencies = [ "cc", ] @@ -1760,15 +1785,6 @@ version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" -[[package]] -name = "miniz_oxide" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34" -dependencies = [ - "adler", -] - [[package]] name = "miniz_oxide" version = "0.6.2" @@ -1812,6 +1828,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "newline-converter" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f71d09d5c87634207f894c6b31b6a2b2c64ea3bdcf71bd5599fdbbe1600c00f" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "nix" version = "0.23.2" @@ -1840,9 +1865,9 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.105", + "proc-macro2 1.0.49", + "quote 1.0.23", + "syn 1.0.107", ] [[package]] @@ -1866,11 +1891,11 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" dependencies = [ - "hermit-abi", + "hermit-abi 0.2.6", "libc", ] @@ -1890,9 +1915,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b0498641e53dd6ac1a4f22547548caa6864cc4933784319cd1775271c5a46ce" dependencies = [ "proc-macro-crate 1.2.1", - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.105", + "proc-macro2 1.0.49", + "quote 1.0.23", + "syn 1.0.107", ] [[package]] @@ -1903,9 +1928,9 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "object" -version = "0.29.0" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" +checksum = "239da7f290cfa979f43f85a8efeee9a8a76d0827c356d37f9d3d7254d6b537fb" dependencies = [ "memchr", ] @@ -1947,9 +1972,9 @@ checksum = "44a0b52c2cbaef7dffa5fec1a43274afe8bd2a644fa9fc50a9ef4ff0269b1257" dependencies = [ "Inflector", "proc-macro-error", - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.105", + "proc-macro2 1.0.49", + "quote 1.0.23", + "syn 1.0.107", ] [[package]] @@ -1960,7 +1985,7 @@ checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ "instant", "lock_api", - "parking_lot_core 0.8.5", + "parking_lot_core 0.8.6", ] [[package]] @@ -1975,9 +2000,9 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" dependencies = [ "cfg-if", "instant", @@ -2075,9 +2100,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ "proc-macro-error-attr", - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.105", + "proc-macro2 1.0.49", + "quote 1.0.23", + "syn 1.0.107", "version_check", ] @@ -2087,8 +2112,8 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.49", + "quote 1.0.23", "version_check", ] @@ -2103,9 +2128,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.47" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" +checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5" dependencies = [ "unicode-ident", ] @@ -2116,9 +2141,9 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4bf29726d67464d49fa6224a1d07936a8c08bb3fba727c7493f6cf1616fdaada" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.105", + "proc-macro2 1.0.49", + "quote 1.0.23", + "syn 1.0.107", "version_check", "yansi", ] @@ -2138,9 +2163,9 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.105", + "proc-macro2 1.0.49", + "quote 1.0.23", + "syn 1.0.107", ] [[package]] @@ -2193,11 +2218,11 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.21" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" dependencies = [ - "proc-macro2 1.0.47", + "proc-macro2 1.0.49", ] [[package]] @@ -2425,30 +2450,6 @@ dependencies = [ "bytecheck", ] -[[package]] -name = "requestty" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d06fb394ca73d15ad0c7bbc673459506a851a84586cd90d67d42932a280281e" -dependencies = [ - "requestty-ui", - "smallvec", - "tempfile", -] - -[[package]] -name = "requestty-ui" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31a4bce6f730d12e36993944036e2f93e88033d8a78734d8734fdb0043662cae" -dependencies = [ - "bitflags", - "crossterm", - "once_cell", - "textwrap 0.15.2", - "unicode-segmentation", -] - [[package]] name = "reqwest" version = "0.11.13" @@ -2523,9 +2524,9 @@ version = "0.7.39" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6eaedadc88b53e36dd32d940ed21ae4d850d5916f2581526921f553a72ac34c4" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.105", + "proc-macro2 1.0.49", + "quote 1.0.23", + "syn 1.0.107", ] [[package]] @@ -2562,7 +2563,7 @@ version = "1.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a7e2dba1342e9f1166786a4329ba0d6d6b8d9db7e81d702ec9ba3b39591ddff" dependencies = [ - "quote 1.0.21", + "quote 1.0.23", "rust_decimal", ] @@ -2610,15 +2611,15 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.9" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8" +checksum = "5583e89e108996506031660fe09baa5011b9dd0341b89029313006d1fb508d70" [[package]] name = "ryu" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" +checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" [[package]] name = "same-file" @@ -2647,10 +2648,10 @@ version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f188d036977451159430f3b8dc82ec76364a42b7e289c2b18a9a18f4470058e9" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.49", + "quote 1.0.23", "serde_derive_internals", - "syn 1.0.105", + "syn 1.0.107", ] [[package]] @@ -2661,9 +2662,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "scratch" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" +checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" [[package]] name = "sct" @@ -2683,37 +2684,37 @@ checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" [[package]] name = "semver" -version = "1.0.14" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4" +checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" [[package]] name = "serde" -version = "1.0.150" +version = "1.0.151" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e326c9ec8042f1b5da33252c8a37e9ffbd2c9bef0155215b6e6c80c790e05f91" +checksum = "97fed41fc1a24994d044e6db6935e69511a1153b52c15eb42493b26fa87feba0" dependencies = [ "serde_derive", ] [[package]] name = "serde_bytes" -version = "0.11.7" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfc50e8183eeeb6178dcb167ae34a8051d63535023ae38b5d8d12beae193d37b" +checksum = "718dc5fff5b36f99093fc49b280cfc96ce6fc824317783bff5a1fed0c7a64819" dependencies = [ "serde", ] [[package]] name = "serde_derive" -version = "1.0.150" +version = "1.0.151" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42a3df25b0713732468deadad63ab9da1f1fd75a48a15024b50363f128db627e" +checksum = "255abe9a125a985c05190d687b320c12f9b1f0b99445e608c21ba0782c719ad8" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.105", + "proc-macro2 1.0.49", + "quote 1.0.23", + "syn 1.0.107", ] [[package]] @@ -2722,16 +2723,16 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.105", + "proc-macro2 1.0.49", + "quote 1.0.23", + "syn 1.0.107", ] [[package]] name = "serde_json" -version = "1.0.89" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db" +checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883" dependencies = [ "itoa", "ryu", @@ -2851,12 +2852,6 @@ version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" -[[package]] -name = "smawk" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f67ad224767faa3c7d8b6d91985b78e70a1324408abcb1cfcc2be4c06bc06043" - [[package]] name = "socket2" version = "0.4.7" @@ -3085,10 +3080,10 @@ version = "1.9.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d63ab101db88ecccd8da34065b9097b88367e0744fdfd05cb7de87b4ede3717f" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.49", + "quote 1.0.23", "rustc_version", - "syn 1.0.105", + "syn 1.0.107", ] [[package]] @@ -3387,10 +3382,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3db4c93bd43c91290ad54fe6ff86179a859954f196507c4789a4876d38a62f17" dependencies = [ "bs58 0.4.0", - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.49", + "quote 1.0.23", "rustversion", - "syn 1.0.105", + "syn 1.0.107", ] [[package]] @@ -3588,12 +3583,12 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.105" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b9b43d45702de4c839cb9b51d9f529c5dd26a4aff255b42b1ebc03e88ee908" +checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", + "proc-macro2 1.0.49", + "quote 1.0.23", "unicode-ident", ] @@ -3603,9 +3598,9 @@ version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.105", + "proc-macro2 1.0.49", + "quote 1.0.23", + "syn 1.0.107", "unicode-xid 0.2.4", ] @@ -3662,17 +3657,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "textwrap" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7b3e525a49ec206798b40326a44121291b530c963cfb01018f63e135bac543d" -dependencies = [ - "smawk", - "unicode-linebreak", - "unicode-width", -] - [[package]] name = "textwrap" version = "0.16.0" @@ -3681,22 +3665,22 @@ checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" [[package]] name = "thiserror" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" +checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" +checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.105", + "proc-macro2 1.0.49", + "quote 1.0.23", + "syn 1.0.107", ] [[package]] @@ -3770,9 +3754,9 @@ version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.105", + "proc-macro2 1.0.49", + "quote 1.0.23", + "syn 1.0.107", ] [[package]] @@ -3802,9 +3786,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.5.9" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +checksum = "1333c76748e868a4d9d1017b5ab53171dfd095f70c712fdb4653a406547f598f" dependencies = [ "serde", ] @@ -3833,9 +3817,9 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.105", + "proc-macro2 1.0.49", + "quote 1.0.23", + "syn 1.0.107", ] [[package]] @@ -3889,19 +3873,9 @@ checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" [[package]] name = "unicode-ident" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" - -[[package]] -name = "unicode-linebreak" -version = "0.1.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5faade31a542b8b35855fff6e8def199853b2da8da256da52f52f1316ee3137" -dependencies = [ - "hashbrown 0.12.3", - "regex", -] +checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" [[package]] name = "unicode-normalization" @@ -3991,16 +3965,17 @@ dependencies = [ "chrono", "clap 3.2.23", "console", + "inquire", "rate-pyth", "rate-switchboard", "redeem-logic-digital", "redeem-logic-forward", "redeem-logic-settled-forward", "redeem-logic-vanilla-option", - "requestty", "rust_decimal", "rust_decimal_macros", "solana-cli-config", + "spl-token", "vyper-core 0.1.0 (git+https://github.com/vyper-protocol/vyper-core?branch=dev)", "vyper-otc", ] @@ -4024,7 +3999,7 @@ dependencies = [ [[package]] name = "vyper-core" version = "0.1.0" -source = "git+https://github.com/vyper-protocol/vyper-otc?branch=dev#8a597ce6c98c2f0bff8c9baa06cbb5a68a820a02" +source = "git+https://github.com/vyper-protocol/vyper-otc?branch=dev#81fa7b4d10131afdf323a0d8ecf4e856b8dda404" dependencies = [ "anchor-lang", "anchor-spl", @@ -4042,23 +4017,23 @@ name = "vyper-macros" version = "0.1.0" source = "git+https://github.com/vyper-protocol/vyper-core?branch=dev#2fa059ea7f9f106a7240f70c767f436034b8de0f" dependencies = [ - "quote 1.0.21", - "syn 1.0.105", + "quote 1.0.23", + "syn 1.0.107", ] [[package]] name = "vyper-macros" version = "0.1.0" -source = "git+https://github.com/vyper-protocol/vyper-otc?branch=dev#8a597ce6c98c2f0bff8c9baa06cbb5a68a820a02" +source = "git+https://github.com/vyper-protocol/vyper-otc?branch=dev#81fa7b4d10131afdf323a0d8ecf4e856b8dda404" dependencies = [ - "quote 1.0.21", - "syn 1.0.105", + "quote 1.0.23", + "syn 1.0.107", ] [[package]] name = "vyper-otc" version = "0.1.1" -source = "git+https://github.com/vyper-protocol/vyper-otc?branch=dev#8a597ce6c98c2f0bff8c9baa06cbb5a68a820a02" +source = "git+https://github.com/vyper-protocol/vyper-otc?branch=dev#81fa7b4d10131afdf323a0d8ecf4e856b8dda404" dependencies = [ "anchor-lang", "anchor-spl", @@ -4079,7 +4054,7 @@ dependencies = [ [[package]] name = "vyper-utils" version = "0.1.0" -source = "git+https://github.com/vyper-protocol/vyper-otc?branch=dev#8a597ce6c98c2f0bff8c9baa06cbb5a68a820a02" +source = "git+https://github.com/vyper-protocol/vyper-otc?branch=dev#81fa7b4d10131afdf323a0d8ecf4e856b8dda404" dependencies = [ "anchor-lang", "anchor-spl", @@ -4145,9 +4120,9 @@ dependencies = [ "bumpalo", "log", "once_cell", - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.105", + "proc-macro2 1.0.49", + "quote 1.0.23", + "syn 1.0.107", "wasm-bindgen-shared", ] @@ -4169,7 +4144,7 @@ version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" dependencies = [ - "quote 1.0.21", + "quote 1.0.23", "wasm-bindgen-macro-support", ] @@ -4179,9 +4154,9 @@ version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.105", + "proc-macro2 1.0.49", + "quote 1.0.23", + "syn 1.0.107", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4357,9 +4332,9 @@ version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44bf07cb3e50ea2003396695d58bf46bc9887a1f362260446fad6bc4e79bd36c" dependencies = [ - "proc-macro2 1.0.47", - "quote 1.0.21", - "syn 1.0.105", + "proc-macro2 1.0.49", + "quote 1.0.23", + "syn 1.0.107", "synstructure", ] diff --git a/Cargo.toml b/Cargo.toml index 86b7654..8c93dc6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,8 @@ console = "0.15.1" rust_decimal = "1.26" rust_decimal_macros = "1.26" chrono = "0.4.23" -requestty = "0.4.1" +inquire = "0.5.2" +spl-token = "3.2.0" [[bin]] name = "vyper" diff --git a/src/args/otc_args.rs b/src/args/otc_args.rs index 2b9d0ae..d32f4d3 100644 --- a/src/args/otc_args.rs +++ b/src/args/otc_args.rs @@ -22,7 +22,7 @@ pub struct OtcCommand { pub enum OtcSubcommand { /// Gets the configuration of otc from given public key. Fetch(FetchOtc), - /// Creates the otc with input configuration + /// Creates the otc with given input configuration Create } diff --git a/src/main.rs b/src/main.rs index 0919a23..d8848d3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -43,6 +43,7 @@ const REDEEM_LOGIC_FORWARD: &str = "BrpV1re8MshA8qskKVxcEG8zXG3vf2uLX6myeTKAyhsK const REDEEM_LOGIC_SETTLE_FORWARD: &str = "6vBg1GMtKj7EYDLWWt6tkHoDWLAAksNPbKWiXMic99qU"; const REDEEM_LOGIC_VANILLA_OPTION: &str = "8fSeRtFseNrjdf8quE2YELhuzLkHV7WEGRPA9Jz8xEVe"; const REDEEM_LOGIC_DIGITAL: &str = "5Dq9PjUJUG5dM9DzYFqKA4YZYeKJfGaM5Gy7NjpY3p5r"; + fn main() { // parsing arguments @@ -87,7 +88,7 @@ fn main() { }; - let client = Client::new(current_cluster.clone(), Rc::new(key_pair)); + let client = Client::new(current_cluster, Rc::new(key_pair)); match args.vyper { Vyper::Core(core) => { // vyper core program @@ -146,9 +147,8 @@ fn main() { // vyper core program let core_program_id: Pubkey = Pubkey::new(&bs58::decode(&VYPER_CORE_ID).into_vec().expect("Invalid vyper core program id")); let core_program = client.program(core_program_id); - // command handler - handle_otc_command(otc_command, &otc_program, &core_program, &client, current_cluster); + handle_otc_command(otc_command, &otc_program, &core_program, &client); } } } diff --git a/src/ops/otc_ops.rs b/src/ops/otc_ops.rs index 574ef9f..9ab9626 100644 --- a/src/ops/otc_ops.rs +++ b/src/ops/otc_ops.rs @@ -6,7 +6,9 @@ use { println_version, println_error, println_date, - println_beneficiary_value + println_beneficiary_value, + inquire_input, + error_handler }, otc_args:: { OtcCommand, @@ -15,30 +17,62 @@ use { anchor_client::{ Client, Program, - Cluster, + RequestBuilder, ClientError, solana_sdk:: { signer::keypair::Keypair, signer::Signer, pubkey:: Pubkey, system_program, - instruction::AccountMeta + instruction::AccountMeta, + sysvar }, }, - vyper_otc::state::OtcState, + vyper_otc::{ + state::OtcState, + accounts::InitializeContext as OtcInitializeContext, + instruction::Initialize as OtcInitialize, + instructions::InitializeInputData as OtcInitialInput + }, rate_switchboard::{ - accounts::InitializeContext, - instruction::Initialize, + accounts::InitializeContext as RateSwitchInitializeContext, + instruction::Initialize as RateSwitchInitialize, + }, + rate_pyth::{ + accounts::InitializeContext as RatePythInitializeContext, + instruction::Initialize as RatePythInitialize, + }, + redeem_logic_forward::{ + accounts::InitializeContext as RedeemLogicForwardInitializeContext, + instruction::Initialize as RedeemLogicForwardInitialize, + }, + redeem_logic_settled_forward::{ + accounts::InitializeContext as RedeemLogicSettledForwardInitializeContext, + instruction::Initialize as RedeemLogicSettledForwardInitialize, + }, + redeem_logic_digital::{ + accounts::InitializeContext as RedeemLogicDigitalInitializeContext, + instruction::Initialize as RedeemLogicDigitalInitialize, + }, + redeem_logic_vanilla_option::{ + accounts::InitializeContext as RedeemLogicVanillaOptionInitializeContext, + instruction::Initialize as RedeemLogicVanillaOptionInitialize, + }, + vyper_core::{ + accounts::InitializeContext as CoreInitializeContext, + instruction::Initialize as CoreInitialize, + instructions::InitializeInput as CoreInitialInput }, console::style, - requestty::{Question,prompt_one}, - crate::{RATE_SWITCHBOARD} + crate::{RATE_SWITCHBOARD, RATE_PYTH,REDEEM_LOGIC_FORWARD,REDEEM_LOGIC_SETTLE_FORWARD,REDEEM_LOGIC_DIGITAL,REDEEM_LOGIC_VANILLA_OPTION}, + inquire::{CustomType,Select,Confirm}, + chrono::NaiveDateTime }; -pub fn handle_otc_command(otc_command: OtcCommand, otc_program: &Program, core_program: &Program, client: &Client, cluster: Cluster) { +pub fn handle_otc_command(otc_command: OtcCommand, otc_program: &Program, core_program: &Program, client: &Client) { let command = otc_command.command; match command { OtcSubcommand::Fetch(fetch_otc) => { @@ -79,87 +113,349 @@ pub fn handle_otc_command(otc_command: OtcCommand, otc_program: &Program, core_p } OtcSubcommand::Create => { - - let rate_plugin_question = Question::select("rate plugin") - .message("Which rate plugin to select?") - .choice("Rate Switchboard") - .choice("Rate Pyth") - .build(); - let rate_plugin_answer = prompt_one(rate_plugin_question).unwrap(); - let rate_plugin_type = rate_plugin_answer.as_list_item().unwrap(); - + // collateral mint input + let collateral_mint= CustomType::::new("Collateral Mint") + .with_error_message("Please type enter valid Public key") + .prompt(); + let collateral_mint = inquire_input(collateral_mint); + - let redeem_plugin_question = Question::select("redeem plugin") - .message("Which redeem plugin to select?") - .choice("Redeem Forward") - .choice("Redeem Settled Forward") - .choice("Redeem Digital") - .choice("Redeem Vanilla Option") - .build(); - let redeem_plugin_answer = prompt_one(redeem_plugin_question).unwrap(); - let redeem_plugin_type = redeem_plugin_answer.as_list_item().unwrap(); - - if rate_plugin_type.text == String::from("Rate Switchboard") { - // rate switchboard program + // rate plugin choice + let rate_plugin_options = vec![ + "Rate Switchboard", + "Rate Pyth", + ]; + let rate_plugin_choice = Select::new("Which rate plugin to choose?", rate_plugin_options).prompt(); + let rate_plugin_choice = inquire_input(rate_plugin_choice); + + // rate plugin details + let rate_plugin_transaction: RequestBuilder; + let rate_plugin_state: Keypair = Keypair::new(); + let rate_plugin_program: Program; + + + if rate_plugin_choice == "Rate Switchboard" { + // input for rate switcboard let rate_switchboard_program_id: Pubkey = Pubkey::new(&bs58::decode(&RATE_SWITCHBOARD).into_vec().expect("Invalid rate switchboard program id")); - let rate_switchboard_program = client.program(rate_switchboard_program_id); - - let rate_switchboard_state = Keypair::new(); - let rateAccounts = match cluster.url() { - "https://api.devnet.solana.com" => "9LNYQZLJG5DAyeACCTzBFG6H3sDhehP5xtYLdhrZtQkA", - _ => "7Y3nWv5B2rLiDBsNpkfXqa4cbJqszJos2sZVutF8R3FE" - }; - - let signature = rate_switchboard_program.request() - .signer(&rate_switchboard_state) - .accounts(InitializeContext { - rate_data: rate_switchboard_state.pubkey(), - signer: rate_switchboard_program.payer(), + rate_plugin_program = client.program(rate_switchboard_program_id); + let tot_aggregators = CustomType::::new("How many aggregators to use?") + .with_error_message("Please type a valid number") + .with_help_message("Maximum 10 aggregators are supported") + .prompt(); + let tot_aggregators = inquire_input(tot_aggregators); + let mut cnt=0; + let mut rate_accounts = Vec::new(); + while cnt::new(&message) + .with_error_message("Please enter a vaid Public key") + .prompt(); + let aggregator = inquire_input(aggregator); + rate_accounts.push(aggregator); + cnt+=1; + } + let aggregators:Vec = rate_accounts.into_iter().map(|rate_account| { + AccountMeta::new_readonly(rate_account, false) + }).collect(); + + // transaction builder + rate_plugin_transaction = rate_plugin_program.request() + .signer(&rate_plugin_state) + .accounts(RateSwitchInitializeContext { + rate_data: rate_plugin_state.pubkey(), + signer: rate_plugin_program.payer(), system_program: system_program::ID }) - .accounts(AccountMeta::new_readonly(Pubkey::new(&bs58::decode(&rateAccounts).into_vec().expect("Invalid otc program id")), false)) - .args(Initialize {}) - .send(); - let signature = match signature { - Ok(transaction) => transaction, - Err(err) => { - match err { - ClientError::AccountNotFound => println_error("Could not find a state with given public key"), - ClientError::AnchorError(err) => println!("{} : {}",style("error").red().bold(),err), - ClientError::ProgramError(err) => println!("{} : {}",style("error").red().bold(),err), - ClientError::SolanaClientError(err) => println!("{} : {}",style("error").red().bold(),err), - ClientError::SolanaClientPubsubError(err) => println!("{} : {}",style("error").red().bold(),err), - ClientError::LogParseError(err)=> println_error(&err) - } - exit(1); - } - }; - println_name_value("Rate Switchboard Plugin State successfully create at", &rate_switchboard_state.pubkey()); - println_name_value("Transaction Id", &signature); - - - } else if rate_plugin_type.text == String::from("Rate Pyth") { + .accounts(aggregators) + .args(RateSwitchInitialize {}); + } else if rate_plugin_choice == "Rate Pyth" { + let rate_pyth_program_id: Pubkey = Pubkey::new(&bs58::decode(&RATE_PYTH).into_vec().expect("Invalid rate pyth program id")); + rate_plugin_program = client.program(rate_pyth_program_id); + let tot_oracles = CustomType::::new("How many oracles to use?") + .with_error_message("Please type a valid number") + .with_help_message("Maximum 10 oracles are supported") + .prompt(); + let tot_oracles = inquire_input(tot_oracles); + let mut cnt=0; + let mut rate_accounts = Vec::new(); + while cnt::new(&message) + .with_error_message("Please enter a vaid Public key") + .prompt(); + let oracle = inquire_input(oracle); + rate_accounts.push(oracle); + cnt+=1; + } + let oracles:Vec = rate_accounts.into_iter().map(|rate_account| { + AccountMeta::new_readonly(rate_account, false) + }).collect(); + + // transaction builder + rate_plugin_transaction = rate_plugin_program.request() + .signer(&rate_plugin_state) + .accounts(RatePythInitializeContext { + rate_data: rate_plugin_state.pubkey(), + signer: rate_plugin_program.payer(), + system_program: system_program::ID + }) + .accounts(oracles) + .args(RatePythInitialize {}); + } else { - //error + println_error("Please choose a valid Rate Plugin"); + exit(1); } - if redeem_plugin_type.text == String::from("Redeem Forward") { - println!("{}","RATE SWITCH"); - } else if redeem_plugin_type.text == String::from("Redeem Settled Forward") { + // redeem plugin choice + let redeem_plugin_options = vec![ + "Redeem Forward", + "Redeem Settled Forward", + "Redeem Digital", + "Redeem Vanilla Option" + ]; + let redeem_plugin_choice = Select::new("Which redeem plugin to choose?", redeem_plugin_options).prompt(); + let redeem_plugin_choice = inquire_input(redeem_plugin_choice); + // redeem plugin details + let redeem_plugin_transaction: RequestBuilder; + let redeem_plugin_state: Keypair = Keypair::new(); + let redeem_plugin_program: Program; - } else if redeem_plugin_type.text == String::from("Redeem Digital") { + if redeem_plugin_choice == "Redeem Forward" { + let redeem_logic_forward_program_id: Pubkey = Pubkey::new(&bs58::decode(&REDEEM_LOGIC_FORWARD).into_vec().expect("Invalid redeem logic forward program id")); + redeem_plugin_program = client.program(redeem_logic_forward_program_id); + let notional = CustomType::::new("Notional") + .with_error_message("Please type a valid number") + .prompt(); + let notional=inquire_input(notional); + let strike = CustomType::::new("Strike") + .with_error_message("Please type a valid number") + .prompt(); + let strike=inquire_input(strike); + let is_linear = Confirm::new("Is Linear?") + .with_default(true) + .prompt(); + let is_linear=inquire_input(is_linear); + + // transaction builder + redeem_plugin_transaction = redeem_plugin_program.request() + .signer(&redeem_plugin_state) + .accounts(RedeemLogicForwardInitializeContext { + redeem_logic_config: redeem_plugin_state.pubkey(), + payer: redeem_plugin_program.payer(), + system_program: system_program::ID, + }) + .args(RedeemLogicForwardInitialize { notional: notional,is_linear:is_linear, strike:strike}); + + } else if redeem_plugin_choice == "Redeem Settled Forward" { + let redeem_logic_settle_forward_program_id: Pubkey = Pubkey::new(&bs58::decode(&REDEEM_LOGIC_SETTLE_FORWARD).into_vec().expect("Invalid redeem logic forward program id")); + redeem_plugin_program = client.program(redeem_logic_settle_forward_program_id); + let notional = CustomType::::new("Notional") + .with_error_message("Please type a valid number") + .prompt(); + let notional=inquire_input(notional); + let strike = CustomType::::new("Strike") + .with_error_message("Please type a valid number") + .prompt(); + let strike=inquire_input(strike); + let is_linear = Confirm::new("Is Linear?") + .with_default(true) + .prompt(); + let is_linear=inquire_input(is_linear); + let is_standard = Confirm::new("Is Standard?") + .with_default(true) + .prompt(); + let is_standard=inquire_input(is_standard); + + // transaction builder + redeem_plugin_transaction = redeem_plugin_program.request() + .signer(&redeem_plugin_state) + .accounts(RedeemLogicSettledForwardInitializeContext { + redeem_logic_config: redeem_plugin_state.pubkey(), + payer: redeem_plugin_program.payer(), + system_program: system_program::ID, + }) + .args(RedeemLogicSettledForwardInitialize { notional: notional,is_linear:is_linear, strike:strike, is_standard:is_standard}); - } else if redeem_plugin_type.text == String::from("Redeem Vanilla") { + } else if redeem_plugin_choice == "Redeem Digital" { + let redeem_logic_digital_program_id: Pubkey = Pubkey::new(&bs58::decode(&REDEEM_LOGIC_DIGITAL).into_vec().expect("Invalid redeem logic digital program id")); + redeem_plugin_program = client.program(redeem_logic_digital_program_id); + let strike = CustomType::::new("Strike") + .with_error_message("Please type a valid number") + .prompt(); + let strike=inquire_input(strike); + let is_call = Confirm::new("Is Call?") + .with_default(true) + .prompt(); + let is_call=inquire_input(is_call); + // transaction builder + redeem_plugin_transaction = redeem_plugin_program.request() + .signer(&redeem_plugin_state) + .accounts(RedeemLogicDigitalInitializeContext { + redeem_logic_config: redeem_plugin_state.pubkey(), + payer: redeem_plugin_program.payer(), + system_program: system_program::ID, + }) + .args(RedeemLogicDigitalInitialize {is_call:is_call, strike:strike}); + + } else if redeem_plugin_choice == "Redeem Vanilla Option" { + let redeem_logic_vanilla_option_program_id: Pubkey = Pubkey::new(&bs58::decode(&REDEEM_LOGIC_VANILLA_OPTION).into_vec().expect("Invalid redeem logic forward program id")); + redeem_plugin_program = client.program(redeem_logic_vanilla_option_program_id); + let notional = CustomType::::new("Notional") + .with_error_message("Please type a valid number") + .prompt(); + let notional=inquire_input(notional); + let strike = CustomType::::new("Strike") + .with_error_message("Please type a valid number") + .prompt(); + let strike=inquire_input(strike); + let is_linear = Confirm::new("Is Linear?") + .with_default(true) + .prompt(); + let is_linear=inquire_input(is_linear); + let is_call = Confirm::new("Is Call?") + .with_default(true) + .prompt(); + let is_call=inquire_input(is_call); + + // transaction builder + redeem_plugin_transaction = redeem_plugin_program.request() + .signer(&redeem_plugin_state) + .accounts(RedeemLogicVanillaOptionInitializeContext { + redeem_logic_config: redeem_plugin_state.pubkey(), + payer: redeem_plugin_program.payer(), + system_program: system_program::ID, + }) + .args(RedeemLogicVanillaOptionInitialize { notional: notional, is_call: is_call, is_linear:is_linear, strike:strike}); } else { - //error + println_error("Please choose a valid Redeem Logic Plugin"); + exit(1); } + let otc_state = Keypair::new(); + let (otc_authority, _otc_bump) = Pubkey::find_program_address(&[otc_state.pubkey().as_ref(),b"authority"], &otc_program.id()); - println!("{:?} {:?}",rate_plugin_type.text, redeem_plugin_type.text); + let junior_tranche_mint = Keypair::new(); + let senior_tranche_mint = Keypair::new(); + let tranche_config = Keypair::new(); + let (tranche_authority,_tranche_bump) = Pubkey::find_program_address( + &[tranche_config.pubkey().as_ref(),b"authority"], + &core_program.id() + ); + let (reserve, _res_bump) = Pubkey::find_program_address(&[tranche_config.pubkey().as_ref(), collateral_mint.as_ref()], &core_program.id()); + let initial_input: CoreInitialInput = CoreInitialInput{ + tranche_mint_decimals: 6, + halt_flags : 0, + owner_restricted_ixs : (1<<0) | (1<<2) + }; + let core_transaction = core_program.request() + .accounts(CoreInitializeContext{ + payer: core_program.payer(), + owner: otc_authority, + tranche_config: tranche_config.pubkey(), + tranche_authority: tranche_authority, + rate_program: rate_plugin_program.id(), + rate_program_state: rate_plugin_state.pubkey(), + redeem_logic_program: redeem_plugin_program.id(), + redeem_logic_program_state: redeem_plugin_state.pubkey(), + reserve_mint: collateral_mint, + reserve: reserve, + junior_tranche_mint: junior_tranche_mint.pubkey(), + senior_tranche_mint: senior_tranche_mint.pubkey(), + system_program: system_program::ID, + token_program: spl_token::ID, + rent: sysvar::rent::ID + }) + .args(CoreInitialize{input_data:initial_input}) + .signer(&junior_tranche_mint) + .signer(&senior_tranche_mint) + .signer(&tranche_config); + + let senior_deposit_amount = CustomType::::new("Senior Deposit Amount") + .with_error_message("Please type a amount") + .prompt(); + let senior_deposit_amount = inquire_input(senior_deposit_amount); + let junior_deposit_amount = CustomType::::new("Junior Deposit Amount") + .with_error_message("Please type a amount") + .prompt(); + let junior_deposit_amount = inquire_input(junior_deposit_amount); + let deposit_start = CustomType::::new("Deposit Start") + .with_placeholder("yyyy-mm-dd hh:mm:ss") + .with_parser(&|i| NaiveDateTime::parse_from_str(i, "%Y-%m-%d %H:%M:%S").map_err(|_| ())) + .with_error_message("Please type a valid date and time") + .prompt(); + let deposit_start = inquire_input(deposit_start); + let deposit_end = CustomType::::new("Deposit End") + .with_placeholder("yyyy-mm-dd hh:mm:ss") + .with_parser(&|i| NaiveDateTime::parse_from_str(i, "%Y-%m-%d %H:%M:%S").map_err(|_| ())) + .with_error_message("Please type a valid date and time") + .prompt(); + let deposit_end = inquire_input(deposit_end); + let settle_start = CustomType::::new("Settle Start") + .with_placeholder("yyyy-mm-dd hh:mm:ss") + .with_parser(&|i| NaiveDateTime::parse_from_str(i, "%Y-%m-%d %H:%M:%S").map_err(|_| ())) + .with_error_message("Please type a valid date and time") + .prompt(); + let settle_start = inquire_input(settle_start); + + let otc_senior_reserve_token_account = Keypair::new(); + let otc_junior_reserve_token_account = Keypair::new(); + let otc_senior_tranche_token_account = Keypair::new(); + let otc_junior_tranche_token_account = Keypair::new(); + + let otc_initial_input = OtcInitialInput{ + senior_deposit_amount: senior_deposit_amount, + junior_deposit_amount: junior_deposit_amount, + deposit_start: Option::Some(deposit_start.timestamp()), + deposit_end: deposit_end.timestamp(), + settle_start: settle_start.timestamp(), + description: [0; 128] + }; + + let otc_transaction = otc_program.request() + .accounts(OtcInitializeContext{ + signer: otc_program.payer(), + reserve_mint: collateral_mint, + otc_authority: otc_authority, + otc_state: otc_state.pubkey(), + junior_tranche_mint: junior_tranche_mint.pubkey(), + senior_tranche_mint: senior_tranche_mint.pubkey(), + otc_senior_reserve_token_account: otc_senior_reserve_token_account.pubkey(), + otc_junior_reserve_token_account: otc_junior_reserve_token_account.pubkey(), + otc_senior_tranche_token_account: otc_senior_tranche_token_account.pubkey(), + otc_junior_tranche_token_account: otc_junior_tranche_token_account.pubkey(), + vyper_tranche_config: tranche_config.pubkey(), + vyper_core: core_program.id(), + system_program: system_program::ID, + token_program: spl_token::ID, + rent: sysvar::rent::ID + }) + .args(OtcInitialize{input_data:otc_initial_input}) + .signer(&otc_state) + .signer(&otc_senior_reserve_token_account) + .signer(&otc_junior_reserve_token_account) + .signer(&otc_senior_tranche_token_account) + .signer(&otc_junior_tranche_token_account); + + let rate_plugin_transaction = rate_plugin_transaction.send(); + let _rate_plugin_signature = error_handler(rate_plugin_transaction); + + let redeem_plugin_transaction = redeem_plugin_transaction.send(); + let _redeem_plugin_signature = error_handler(redeem_plugin_transaction); + let core_transaction = core_transaction.send(); + let _core_signature = error_handler(core_transaction); + + let otc_transaction = otc_transaction.send(); + let otc_signature = error_handler(otc_transaction); + + println_name_value("Otc contract successfully created at", &otc_state.pubkey()); + println_name_value("Transaction Id", &otc_signature); } } } \ No newline at end of file diff --git a/src/utils.rs b/src/utils.rs index 75e65eb..5156cd8 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -3,10 +3,15 @@ use { std::fmt::{Debug, Display}, vyper_core::state::SlotTracking, rust_decimal::Decimal, - anchor_client::solana_sdk::pubkey:: Pubkey, + anchor_client::solana_sdk::{ + pubkey:: Pubkey, + signature::Signature + }, + anchor_client::ClientError, std::process::exit, solana_cli_config::{CONFIG_FILE, Config}, - chrono::prelude::* + chrono::prelude::*, + inquire::{InquireError} }; pub fn println_name_value(name: &str, value: &T) { @@ -128,3 +133,32 @@ pub fn println_beneficiary_value(name: &str, value: &Option) { } } +pub fn inquire_input(input: Result) -> T{ + let value = match input { + Ok(value) => value, + Err(_) => { + println_error("Could not parse the given input"); + exit(1); + } + }; + return value; +} + +pub fn error_handler(signature: Result) -> Signature { + let signature = match signature { + Ok(transaction) => transaction, + Err(err) => { + match err { + ClientError::AccountNotFound => println_error("Could not find a account with given public key"), + ClientError::AnchorError(err) => println!("{} : {}",style("error").red().bold(),err), + ClientError::ProgramError(err) => println!("{} : {}",style("error").red().bold(),err), + ClientError::SolanaClientError(err) => println!("{} : {}",style("error").red().bold(),err), + ClientError::SolanaClientPubsubError(err) => println!("{} : {}",style("error").red().bold(),err), + ClientError::LogParseError(err)=> println_error(&err) + } + exit(1); + } + }; + return signature; +} + From 2d5bdd71516b7e6eec97b6d13c95f3766d536b17 Mon Sep 17 00:00:00 2001 From: iamakshat01 Date: Wed, 21 Dec 2022 22:47:28 +0530 Subject: [PATCH 4/6] Fixed clippy warnings --- src/ops/otc_ops.rs | 18 +++++++++--------- src/utils.rs | 10 ++++------ 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/ops/otc_ops.rs b/src/ops/otc_ops.rs index 9ab9626..abbbf0a 100644 --- a/src/ops/otc_ops.rs +++ b/src/ops/otc_ops.rs @@ -248,7 +248,7 @@ pub fn handle_otc_command(otc_command: OtcCommand, otc_program: &Program, core_p payer: redeem_plugin_program.payer(), system_program: system_program::ID, }) - .args(RedeemLogicForwardInitialize { notional: notional,is_linear:is_linear, strike:strike}); + .args(RedeemLogicForwardInitialize { notional,is_linear,strike}); } else if redeem_plugin_choice == "Redeem Settled Forward" { let redeem_logic_settle_forward_program_id: Pubkey = Pubkey::new(&bs58::decode(&REDEEM_LOGIC_SETTLE_FORWARD).into_vec().expect("Invalid redeem logic forward program id")); @@ -278,7 +278,7 @@ pub fn handle_otc_command(otc_command: OtcCommand, otc_program: &Program, core_p payer: redeem_plugin_program.payer(), system_program: system_program::ID, }) - .args(RedeemLogicSettledForwardInitialize { notional: notional,is_linear:is_linear, strike:strike, is_standard:is_standard}); + .args(RedeemLogicSettledForwardInitialize { notional,is_linear, strike, is_standard}); } else if redeem_plugin_choice == "Redeem Digital" { let redeem_logic_digital_program_id: Pubkey = Pubkey::new(&bs58::decode(&REDEEM_LOGIC_DIGITAL).into_vec().expect("Invalid redeem logic digital program id")); @@ -300,7 +300,7 @@ pub fn handle_otc_command(otc_command: OtcCommand, otc_program: &Program, core_p payer: redeem_plugin_program.payer(), system_program: system_program::ID, }) - .args(RedeemLogicDigitalInitialize {is_call:is_call, strike:strike}); + .args(RedeemLogicDigitalInitialize {is_call, strike}); } else if redeem_plugin_choice == "Redeem Vanilla Option" { let redeem_logic_vanilla_option_program_id: Pubkey = Pubkey::new(&bs58::decode(&REDEEM_LOGIC_VANILLA_OPTION).into_vec().expect("Invalid redeem logic forward program id")); @@ -330,7 +330,7 @@ pub fn handle_otc_command(otc_command: OtcCommand, otc_program: &Program, core_p payer: redeem_plugin_program.payer(), system_program: system_program::ID, }) - .args(RedeemLogicVanillaOptionInitialize { notional: notional, is_call: is_call, is_linear:is_linear, strike:strike}); + .args(RedeemLogicVanillaOptionInitialize { notional, is_call, is_linear, strike}); } else { println_error("Please choose a valid Redeem Logic Plugin"); exit(1); @@ -357,13 +357,13 @@ pub fn handle_otc_command(otc_command: OtcCommand, otc_program: &Program, core_p payer: core_program.payer(), owner: otc_authority, tranche_config: tranche_config.pubkey(), - tranche_authority: tranche_authority, + tranche_authority, rate_program: rate_plugin_program.id(), rate_program_state: rate_plugin_state.pubkey(), redeem_logic_program: redeem_plugin_program.id(), redeem_logic_program_state: redeem_plugin_state.pubkey(), reserve_mint: collateral_mint, - reserve: reserve, + reserve, junior_tranche_mint: junior_tranche_mint.pubkey(), senior_tranche_mint: senior_tranche_mint.pubkey(), system_program: system_program::ID, @@ -408,8 +408,8 @@ pub fn handle_otc_command(otc_command: OtcCommand, otc_program: &Program, core_p let otc_junior_tranche_token_account = Keypair::new(); let otc_initial_input = OtcInitialInput{ - senior_deposit_amount: senior_deposit_amount, - junior_deposit_amount: junior_deposit_amount, + senior_deposit_amount, + junior_deposit_amount, deposit_start: Option::Some(deposit_start.timestamp()), deposit_end: deposit_end.timestamp(), settle_start: settle_start.timestamp(), @@ -420,7 +420,7 @@ pub fn handle_otc_command(otc_command: OtcCommand, otc_program: &Program, core_p .accounts(OtcInitializeContext{ signer: otc_program.payer(), reserve_mint: collateral_mint, - otc_authority: otc_authority, + otc_authority, otc_state: otc_state.pubkey(), junior_tranche_mint: junior_tranche_mint.pubkey(), senior_tranche_mint: senior_tranche_mint.pubkey(), diff --git a/src/utils.rs b/src/utils.rs index 5156cd8..277e153 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -134,18 +134,17 @@ pub fn println_beneficiary_value(name: &str, value: &Option) { } pub fn inquire_input(input: Result) -> T{ - let value = match input { + match input { Ok(value) => value, Err(_) => { println_error("Could not parse the given input"); exit(1); } - }; - return value; + } } pub fn error_handler(signature: Result) -> Signature { - let signature = match signature { + match signature { Ok(transaction) => transaction, Err(err) => { match err { @@ -158,7 +157,6 @@ pub fn error_handler(signature: Result) -> Signature { } exit(1); } - }; - return signature; + } } From d30991537fa5abe8adb87d5dc76160a4036ac1d7 Mon Sep 17 00:00:00 2001 From: iamakshat01 Date: Sun, 22 Jan 2023 12:57:29 +0530 Subject: [PATCH 5/6] Added default value for times and collateral mint --- src/main.rs | 12 ++++++++++-- src/ops/otc_ops.rs | 28 ++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index d8848d3..f556a75 100644 --- a/src/main.rs +++ b/src/main.rs @@ -43,6 +43,8 @@ const REDEEM_LOGIC_FORWARD: &str = "BrpV1re8MshA8qskKVxcEG8zXG3vf2uLX6myeTKAyhsK const REDEEM_LOGIC_SETTLE_FORWARD: &str = "6vBg1GMtKj7EYDLWWt6tkHoDWLAAksNPbKWiXMic99qU"; const REDEEM_LOGIC_VANILLA_OPTION: &str = "8fSeRtFseNrjdf8quE2YELhuzLkHV7WEGRPA9Jz8xEVe"; const REDEEM_LOGIC_DIGITAL: &str = "5Dq9PjUJUG5dM9DzYFqKA4YZYeKJfGaM5Gy7NjpY3p5r"; +const SOLANA_RPC_DEVNET: &str = "https://api.devnet.solana.com"; +const SOLANA_RPC_MAINNET: &str = "https://api.mainnet-beta.solana.com"; fn main() { @@ -88,7 +90,7 @@ fn main() { }; - let client = Client::new(current_cluster, Rc::new(key_pair)); + let client = Client::new(current_cluster.clone(), Rc::new(key_pair)); match args.vyper { Vyper::Core(core) => { // vyper core program @@ -148,7 +150,13 @@ fn main() { let core_program_id: Pubkey = Pubkey::new(&bs58::decode(&VYPER_CORE_ID).into_vec().expect("Invalid vyper core program id")); let core_program = client.program(core_program_id); // command handler - handle_otc_command(otc_command, &otc_program, &core_program, &client); + let cur_rpc_url = Cluster::url(¤t_cluster); + let inuse_cluster = match cur_rpc_url { + SOLANA_RPC_DEVNET => Cluster::Devnet, + SOLANA_RPC_MAINNET => Cluster::Mainnet, + &_ => Cluster::Localnet + }; + handle_otc_command(otc_command, &otc_program, &core_program, &client, &inuse_cluster); } } } diff --git a/src/ops/otc_ops.rs b/src/ops/otc_ops.rs index abbbf0a..8c675d4 100644 --- a/src/ops/otc_ops.rs +++ b/src/ops/otc_ops.rs @@ -16,6 +16,7 @@ use { }, anchor_client::{ Client, + Cluster, Program, RequestBuilder, ClientError, @@ -66,13 +67,17 @@ use { console::style, crate::{RATE_SWITCHBOARD, RATE_PYTH,REDEEM_LOGIC_FORWARD,REDEEM_LOGIC_SETTLE_FORWARD,REDEEM_LOGIC_DIGITAL,REDEEM_LOGIC_VANILLA_OPTION}, inquire::{CustomType,Select,Confirm}, - chrono::NaiveDateTime + chrono::{ + NaiveDateTime + } }; +const USDC_MAINNET: &str = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"; +const DEV_USD: &str = "7XSvJnS19TodrQJSbjUR6tEGwmYyL1i9FX7Z5ZQHc53W"; -pub fn handle_otc_command(otc_command: OtcCommand, otc_program: &Program, core_program: &Program, client: &Client) { +pub fn handle_otc_command(otc_command: OtcCommand, otc_program: &Program, core_program: &Program, client: &Client, current_cluster: &Cluster) { let command = otc_command.command; match command { OtcSubcommand::Fetch(fetch_otc) => { @@ -113,8 +118,15 @@ pub fn handle_otc_command(otc_command: OtcCommand, otc_program: &Program, core_p } OtcSubcommand::Create => { + + let default_collateral_mint = match ¤t_cluster { + Cluster::Mainnet => USDC_MAINNET, + _ => DEV_USD + }; + // collateral mint input let collateral_mint= CustomType::::new("Collateral Mint") + .with_default(Pubkey::new(&bs58::decode(&default_collateral_mint).into_vec().expect("Invalid collateral mint"))) .with_error_message("Please type enter valid Public key") .prompt(); let collateral_mint = inquire_input(collateral_mint); @@ -383,20 +395,27 @@ pub fn handle_otc_command(otc_command: OtcCommand, otc_program: &Program, core_p .with_error_message("Please type a amount") .prompt(); let junior_deposit_amount = inquire_input(junior_deposit_amount); + + let default_deposit_start = chrono::Local::now()-chrono::Duration::hours(1); let deposit_start = CustomType::::new("Deposit Start") .with_placeholder("yyyy-mm-dd hh:mm:ss") + .with_default(default_deposit_start.naive_local()) .with_parser(&|i| NaiveDateTime::parse_from_str(i, "%Y-%m-%d %H:%M:%S").map_err(|_| ())) .with_error_message("Please type a valid date and time") .prompt(); let deposit_start = inquire_input(deposit_start); + let default_deposit_end = chrono::Local::now()+chrono::Duration::minutes(5); let deposit_end = CustomType::::new("Deposit End") + .with_default(default_deposit_end.naive_local()) .with_placeholder("yyyy-mm-dd hh:mm:ss") .with_parser(&|i| NaiveDateTime::parse_from_str(i, "%Y-%m-%d %H:%M:%S").map_err(|_| ())) .with_error_message("Please type a valid date and time") .prompt(); let deposit_end = inquire_input(deposit_end); + let settle_start_default = chrono::Local::now()+chrono::Duration::minutes(15); let settle_start = CustomType::::new("Settle Start") .with_placeholder("yyyy-mm-dd hh:mm:ss") + .with_default(settle_start_default.naive_local()) .with_parser(&|i| NaiveDateTime::parse_from_str(i, "%Y-%m-%d %H:%M:%S").map_err(|_| ())) .with_error_message("Please type a valid date and time") .prompt(); @@ -440,7 +459,9 @@ pub fn handle_otc_command(otc_command: OtcCommand, otc_program: &Program, core_p .signer(&otc_junior_reserve_token_account) .signer(&otc_senior_tranche_token_account) .signer(&otc_junior_tranche_token_account); - + + println_name_value("Tx Sending ...",&""); + let rate_plugin_transaction = rate_plugin_transaction.send(); let _rate_plugin_signature = error_handler(rate_plugin_transaction); @@ -453,7 +474,6 @@ pub fn handle_otc_command(otc_command: OtcCommand, otc_program: &Program, core_p let otc_transaction = otc_transaction.send(); let otc_signature = error_handler(otc_transaction); - println_name_value("Otc contract successfully created at", &otc_state.pubkey()); println_name_value("Transaction Id", &otc_signature); } From 7677564678172a06a6c49bc156b8c45068e781a7 Mon Sep 17 00:00:00 2001 From: iamakshat01 Date: Mon, 23 Jan 2023 22:50:31 +0530 Subject: [PATCH 6/6] Added default aggregators and oracles --- src/ops/otc_ops.rs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/ops/otc_ops.rs b/src/ops/otc_ops.rs index 8c675d4..c1398f4 100644 --- a/src/ops/otc_ops.rs +++ b/src/ops/otc_ops.rs @@ -74,8 +74,10 @@ use { const USDC_MAINNET: &str = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"; const DEV_USD: &str = "7XSvJnS19TodrQJSbjUR6tEGwmYyL1i9FX7Z5ZQHc53W"; - - +const RATE_SWITCHBOARD_SOLUSD_MAINNET :&str = "GvDMxPzN1sCj7L26YDK2HnMRXEQmQ2aemov8YBtPS7vR"; +const RATE_SWITCHBOARD_SOLUSD_DEVNET: &str = "GvDMxPzN1sCj7L26YDK2HnMRXEQmQ2aemov8YBtPS7vR"; +const RATE_PYTH_SOLUSD_ORACLE_MAINNET: &str = "H6ARHf6YXhGYeQfUzQNGk6rDNnLBQKrenN712K4AQJEG"; +const RATE_PYTH_SOLUSD_ORACLE_DEVNET: &str = "J83w4HKfqxwcq3BEMMkPFSppX3gqekLyLJBexebFVkix"; pub fn handle_otc_command(otc_command: OtcCommand, otc_program: &Program, core_program: &Program, client: &Client, current_cluster: &Cluster) { let command = otc_command.command; @@ -157,10 +159,17 @@ pub fn handle_otc_command(otc_command: OtcCommand, otc_program: &Program, core_p let tot_aggregators = inquire_input(tot_aggregators); let mut cnt=0; let mut rate_accounts = Vec::new(); + + let default_aggregator = match ¤t_cluster { + Cluster::Mainnet => RATE_SWITCHBOARD_SOLUSD_MAINNET, + _ => RATE_SWITCHBOARD_SOLUSD_DEVNET + }; + while cnt::new(&message) + .with_default(Pubkey::new(&bs58::decode(&default_aggregator).into_vec().expect("Invalid rate switchboard aggregator"))) .with_error_message("Please enter a vaid Public key") .prompt(); let aggregator = inquire_input(aggregator); @@ -192,11 +201,16 @@ pub fn handle_otc_command(otc_command: OtcCommand, otc_program: &Program, core_p let tot_oracles = inquire_input(tot_oracles); let mut cnt=0; let mut rate_accounts = Vec::new(); + let default_oracle = match ¤t_cluster { + Cluster::Mainnet => RATE_PYTH_SOLUSD_ORACLE_MAINNET, + _ => RATE_PYTH_SOLUSD_ORACLE_DEVNET + }; while cnt::new(&message) .with_error_message("Please enter a vaid Public key") + .with_default(Pubkey::new(&bs58::decode(&default_oracle).into_vec().expect("Invalid rate pyth oracle"))) .prompt(); let oracle = inquire_input(oracle); rate_accounts.push(oracle); @@ -460,7 +474,7 @@ pub fn handle_otc_command(otc_command: OtcCommand, otc_program: &Program, core_p .signer(&otc_senior_tranche_token_account) .signer(&otc_junior_tranche_token_account); - println_name_value("Tx Sending ...",&""); + println!("Tx Sending ..."); let rate_plugin_transaction = rate_plugin_transaction.send(); let _rate_plugin_signature = error_handler(rate_plugin_transaction);