anaciri / perp_cli_curie

Built for Perpetual Protocol v2 Curie on Optimism chain. This CLI tool was built with Rust.
https://perp.com
0 stars 0 forks source link

Sweep: add a margin CLI option that prints the current margin for the trader #1

Open anaciri opened 5 months ago

anaciri commented 5 months ago

when user types perp margin, it will look at all positions for that trader and retrieve the current margin ratio

Checklist - [X] Create `src/margin.rs` ✓ https://github.com/anaciri/perp_cli_curie/commit/e6d3a4ccdad8f38582a97637746f72ce57c00733 [Edit](https://github.com/anaciri/perp_cli_curie/edit/sweep/add_a_margin_cli_option_that_prints_the/src/margin.rs) - [X] Running GitHub Actions for `src/margin.rs` ✓ [Edit](https://github.com/anaciri/perp_cli_curie/edit/sweep/add_a_margin_cli_option_that_prints_the/src/margin.rs) - [X] Modify `src/args.rs` ✓ https://github.com/anaciri/perp_cli_curie/commit/a0a0812211a9bd610550f2d3b153578b9693bcbc [Edit](https://github.com/anaciri/perp_cli_curie/edit/sweep/add_a_margin_cli_option_that_prints_the/src/args.rs) - [X] Running GitHub Actions for `src/args.rs` ✓ [Edit](https://github.com/anaciri/perp_cli_curie/edit/sweep/add_a_margin_cli_option_that_prints_the/src/args.rs) - [X] Modify `src/main.rs` ✓ https://github.com/anaciri/perp_cli_curie/commit/79cb7e84510d5e5c8f8389217c9770a9daf7b7e3 [Edit](https://github.com/anaciri/perp_cli_curie/edit/sweep/add_a_margin_cli_option_that_prints_the/src/main.rs) - [X] Running GitHub Actions for `src/main.rs` ✓ [Edit](https://github.com/anaciri/perp_cli_curie/edit/sweep/add_a_margin_cli_option_that_prints_the/src/main.rs)
sweep-ai[bot] commented 5 months ago

🚀 Here's the PR! #3

See Sweep's progress at the progress dashboard!
💎 Sweep Pro: I'm using GPT-4. You have unlimited GPT-4 tickets. (tracking ID: b5b2dd466b)
Install Sweep Configs: Pull Request

[!TIP] I can email you next time I complete a pull request if you set up your email here!


Actions (click)


Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I think are relevant in decreasing order of relevance (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/anaciri/perp_cli_curie/blob/3c3f71ad2efdbabf93ca39752ef17edf8862031c/src/portfolio.rs#L1-L173 https://github.com/anaciri/perp_cli_curie/blob/3c3f71ad2efdbabf93ca39752ef17edf8862031c/src/args.rs#L1-L169 https://github.com/anaciri/perp_cli_curie/blob/3c3f71ad2efdbabf93ca39752ef17edf8862031c/src/main.rs#L1-L54

Step 2: ⌨️ Coding

Ran GitHub Actions for e6d3a4ccdad8f38582a97637746f72ce57c00733:

--- 
+++ 
@@ -31,6 +31,8 @@
     Open(OpenCommand),
     /// Close all positions in a CLOSED market.
     Quit(QuitCommand),
+    /// Retrieve the current margin for the trader
+    Margin(MarginCommand),
     /// Swap ETH or ERC-20 tokens on Velodrome for collateral tokens
     Swap(SwapCommand),
     /// Setup or edit the configuration settings of the app
@@ -168,3 +170,10 @@
     /// Base token address to close positions for
     pub token: String,
 }
+
+#[derive(Debug, Args)]
+/// Retrieve the current margin for the trader
+pub struct MarginCommand {
+    /// The address of the trader
+    pub trader_address: Option,
+}

Ran GitHub Actions for a0a0812211a9bd610550f2d3b153578b9693bcbc:

--- 
+++ 
@@ -2,6 +2,7 @@
 use eyre::Result;
 use perpcli_rs::{
     amm,
+    margin,
     args::{PerpArgs, SubCommand::*},
     close, config, deposit, open, portfolio, position, quit, swap, tokens, withdraw,
 };
@@ -26,6 +27,7 @@
         Open(open_args) => open::process(open_args).await?,
         Close(close_args) => close::process(close_args).await?,
         Swap(swap_args) => swap::process(swap_args).await?,
+        Margin(margin_args) => margin::process_margin_command(margin_args).await?,
         Config(config_args) => {
             if config_args.rpc.expect("true/false") {
                 config::change_rpc()?;

Ran GitHub Actions for 79cb7e84510d5e5c8f8389217c9770a9daf7b7e3:


Step 3: 🔁 Code Review

I have finished reviewing the code for completeness. I did not find errors for sweep/add_a_margin_cli_option_that_prints_the.


🎉 Latest improvements to Sweep:
  • New dashboard launched for real-time tracking of Sweep issues, covering all stages from search to coding.
  • Integration of OpenAI's latest Assistant API for more efficient and reliable code planning and editing, improving speed by 3x.
  • Use the GitHub issues extension for creating Sweep issues directly from your editor.

💡 To recreate the pull request edit the issue title or description. Something wrong? Let us know.

This is an automated message generated by Sweep AI.