Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a command to query quotes from auctioneers #1

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target/
.env
32 changes: 29 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@ Options:

Our CLI offers the following pathways:

- 🌞 `solana`: For Solana -> Solana single domain intents
- 🌙 `ethereum`: For Ethereum -> Ethereum single domain intents
- 🌞 `new-intent`: Submit a new intent into the network
- 🌞 `query-quote`: Submit a new intent into the network

Beneath each of these commands there are 4 sub-commands:

- 🌞 `solana`: For Solana -> Solana single domain interactions
- 🌙 `ethereum`: For Ethereum -> Ethereum single domain interactions
- 🌠 `solana-ethereum`: For the daring Solana -> Ethereum cross-domain
- 🌌 `ethereum-solana`: For the brave Ethereum -> Solana cross-domain

## 🧭 Command Details
## 🧭 new-intent Command Details

### 🌞 Solana Single Domain

Expand Down Expand Up @@ -70,6 +75,26 @@ cargo run -- ethereum-solana <token_in> <amount_in> <token_out> <amount_out> <ti
- `timeout`: The duration in UNIX timestamp before you can withdraw token_in
- `dst_user`: The address of the recipient (for cross-domain only)

## 🎭 query-quote Command details

This command builds a quotes query and dispatches it to the auctioneer given by
the `AUCTIONEER_URL` environment variable (see below). It waits for the results
to arrive and presents them. Sub-commands (`ethereum`, `solana`, etc.) determine
to which networks input token and output token should belong.

Quotes query returns an amount of output tokens that can be swapped for the given
amount of input token by various solvers available on the network. The result
contains a list of solvers who can handle the intent along with the amount of
output tokens each of them is willing to swap for.

## 🎭 Arguments Explained

- `token_in`: The address of your input token
- `src_address`: The address to send input tokens from
- `amount`: The amount of tokens to swap
- `dst_address`: The address to send output tokens to
- `token_out`: The address of your output token

## 🗝️ Environment Variables

Make sure to set up your .env file with these keys:
Expand All @@ -78,6 +103,7 @@ Make sure to set up your .env file with these keys:
ETHEREUM_RPC="" # Your Ethereum node RPC URL
ETHEREUM_PKEY="" # Your Ethereum private key
SOLANA_KEYPAIR="" # Your Solana wallet private key (e.g., Phantom wallet private key)
AUCTIONEER_URL="" # Auctioneer to query quotes from
```

## 🌟 Examples
Expand Down
84 changes: 67 additions & 17 deletions user/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,57 @@ use std::str::FromStr;
use crate::Pubkey;

pub fn parse_cli() -> ArgMatches {
let quote_query_args = quote_query_args();
Command::new("Mantis SDK Intent CLI")
.version("1.0")
.about("Handles Solana and Ethereum escrow intents. Single Domain & Cross Domain")
.subcommand(
Command::new("solana")
.about("Solana -> Solana single domain intent")
.args(common_args()), // Use common_args for Solana
Command::new("submit-intent")
.about("Submit a new intent to the network")
.subcommand(
Command::new("solana")
.about("Solana -> Solana single domain intent")
.args(common_args()), // Use common_args for Solana
)
.subcommand(
Command::new("solana-ethereum")
.about("Solana -> Ethereum cross-domain intent")
.args(cross_domain_args()), // Use cross_domain_args for cross domain
)
.subcommand(
Command::new("ethereum")
.about("Ethereum -> Ethereum single domain intent")
.args(common_args_ethereum()), // Use common_args_ethereum for Ethereum
)
.subcommand(
Command::new("ethereum-solana")
.about("Ethereum -> Solana cross-domain intent")
.args(cross_domain_args_ethereum()), // Use Ethereum cross domain args
)
)
.subcommand(
Command::new("solana-ethereum")
.about("Solana -> Ethereum cross-domain intent")
.args(cross_domain_args()), // Use cross_domain_args for cross domain
)
.subcommand(
Command::new("ethereum")
.about("Ethereum -> Ethereum single domain intent")
.args(common_args_ethereum()), // Use common_args_ethereum for Ethereum
)
.subcommand(
Command::new("ethereum-solana")
.about("Ethereum -> Solana cross-domain intent")
.args(cross_domain_args_ethereum()), // Use Ethereum cross domain args
Command::new("query-quote")
.about("Query an amount of output tokens offered for a given amount of input tokens")
.subcommand(
Command::new("solana")
.about("Solana -> Solana single domain swap")
.args(quote_query_args.clone()),
)
.subcommand(
Command::new("solana-ethereum")
.about("Solana -> Ethereum cross-domain swap")
.args(quote_query_args.clone()),
)
.subcommand(
Command::new("ethereum")
.about("Ethereum -> Ethereum single domain swap")
.args(quote_query_args.clone()),
)
.subcommand(
Command::new("ethereum-solana")
.about("Ethereum -> Solana cross-domain swap")
.args(quote_query_args),
)
)
.get_matches()
}
Expand Down Expand Up @@ -115,4 +144,25 @@ fn cross_domain_args_ethereum() -> Vec<Arg> {
.help("Destination user address"),
);
args
}
}

fn quote_query_args() -> Vec<Arg> {
vec![
Arg::new("token_in")
.required(true)
.help("Input token address"),
Arg::new("src_address")
.required(true)
.help("The address where input tokens are coming from"),
Arg::new("amount")
.required(true)
.value_parser(clap::value_parser!(u64))
.help("Amount of input tokens to be swapped"),
Arg::new("dst_address")
.required(true)
.help("The address where output tokens are going to"),
Arg::new("token_out")
.required(true)
.help("Output token address"),
]
}
Loading