Organize paths, rename crates (#466)
liquidator, keeper, cli and settle-bot moved to bin/ client moved to lib/client All crates have a "mango-v4-" prefix
This commit is contained in:
parent
7a51ce0619
commit
7b9e19cc08
|
@ -5,10 +5,10 @@ on:
|
|||
branches: [dev,main]
|
||||
paths: ['.github/ci-docker-publish.yml',
|
||||
'programs/**',
|
||||
'client/**',
|
||||
'keeper/**',
|
||||
'liquidator/**',
|
||||
'settle-bot/**']
|
||||
'lib/client/**',
|
||||
'bin/keeper/**',
|
||||
'bin/liquidator/**',
|
||||
'bin/settle-bot/**']
|
||||
workflow_call:
|
||||
secrets:
|
||||
GCR_PROJECT:
|
||||
|
|
|
@ -1092,68 +1092,6 @@ dependencies = [
|
|||
"os_str_bytes",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cli"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"anchor-client",
|
||||
"anchor-lang",
|
||||
"anchor-spl",
|
||||
"anyhow",
|
||||
"clap 3.2.23",
|
||||
"client",
|
||||
"dotenv",
|
||||
"env_logger 0.8.4",
|
||||
"fixed",
|
||||
"fixed-macro",
|
||||
"futures 0.3.25",
|
||||
"log 0.4.17",
|
||||
"mango-v4",
|
||||
"pyth-sdk-solana",
|
||||
"serum_dex 0.5.10",
|
||||
"solana-client",
|
||||
"solana-sdk",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "client"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"anchor-client",
|
||||
"anchor-lang",
|
||||
"anchor-spl",
|
||||
"anyhow",
|
||||
"async-channel",
|
||||
"async-once-cell",
|
||||
"async-trait",
|
||||
"base64 0.13.1",
|
||||
"bincode",
|
||||
"fixed",
|
||||
"fixed-macro",
|
||||
"futures 0.3.25",
|
||||
"itertools 0.10.5",
|
||||
"jsonrpc-core 18.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"jsonrpc-core-client",
|
||||
"log 0.4.17",
|
||||
"mango-v4",
|
||||
"pyth-sdk-solana",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serum_dex 0.5.10",
|
||||
"shellexpand",
|
||||
"solana-account-decoder",
|
||||
"solana-address-lookup-table-program",
|
||||
"solana-client",
|
||||
"solana-rpc",
|
||||
"solana-sdk",
|
||||
"spl-associated-token-account",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cloudabi"
|
||||
version = "0.0.3"
|
||||
|
@ -2849,31 +2787,6 @@ dependencies = [
|
|||
"cpufeatures",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "keeper"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"anchor-client",
|
||||
"anchor-lang",
|
||||
"anchor-spl",
|
||||
"anyhow",
|
||||
"clap 3.2.23",
|
||||
"client",
|
||||
"dotenv",
|
||||
"env_logger 0.8.4",
|
||||
"fixed",
|
||||
"fixed-macro",
|
||||
"futures 0.3.25",
|
||||
"itertools 0.10.5",
|
||||
"log 0.4.17",
|
||||
"mango-v4",
|
||||
"pyth-sdk-solana",
|
||||
"serum_dex 0.5.10",
|
||||
"solana-client",
|
||||
"solana-sdk",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kernel32-sys"
|
||||
version = "0.2.2"
|
||||
|
@ -3012,52 +2925,6 @@ version = "0.5.6"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
|
||||
|
||||
[[package]]
|
||||
name = "liquidator"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"anchor-client",
|
||||
"anchor-lang",
|
||||
"anyhow",
|
||||
"arrayref",
|
||||
"async-channel",
|
||||
"async-stream 0.2.1",
|
||||
"async-trait",
|
||||
"bs58 0.3.1",
|
||||
"bytemuck",
|
||||
"bytes 1.3.0",
|
||||
"checked_math",
|
||||
"clap 3.2.23",
|
||||
"client",
|
||||
"dotenv",
|
||||
"fixed",
|
||||
"futures 0.3.25",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"itertools 0.10.5",
|
||||
"jemallocator",
|
||||
"jsonrpc-core 18.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"jsonrpc-core-client",
|
||||
"log 0.4.17",
|
||||
"mango-v4",
|
||||
"once_cell",
|
||||
"pyth-sdk-solana",
|
||||
"rand 0.7.3",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"serum_dex 0.5.10",
|
||||
"shellexpand",
|
||||
"solana-account-decoder",
|
||||
"solana-client",
|
||||
"solana-logger",
|
||||
"solana-rpc",
|
||||
"solana-sdk",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
"tokio-tungstenite 0.16.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.3.4"
|
||||
|
@ -3164,6 +3031,187 @@ dependencies = [
|
|||
"switchboard-v2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mango-v4-cli"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"anchor-client",
|
||||
"anchor-lang",
|
||||
"anchor-spl",
|
||||
"anyhow",
|
||||
"clap 3.2.23",
|
||||
"dotenv",
|
||||
"env_logger 0.8.4",
|
||||
"fixed",
|
||||
"fixed-macro",
|
||||
"futures 0.3.25",
|
||||
"log 0.4.17",
|
||||
"mango-v4",
|
||||
"mango-v4-client",
|
||||
"pyth-sdk-solana",
|
||||
"serum_dex 0.5.10",
|
||||
"solana-client",
|
||||
"solana-sdk",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mango-v4-client"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"anchor-client",
|
||||
"anchor-lang",
|
||||
"anchor-spl",
|
||||
"anyhow",
|
||||
"async-channel",
|
||||
"async-once-cell",
|
||||
"async-trait",
|
||||
"base64 0.13.1",
|
||||
"bincode",
|
||||
"fixed",
|
||||
"fixed-macro",
|
||||
"futures 0.3.25",
|
||||
"itertools 0.10.5",
|
||||
"jsonrpc-core 18.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"jsonrpc-core-client",
|
||||
"log 0.4.17",
|
||||
"mango-v4",
|
||||
"pyth-sdk-solana",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serum_dex 0.5.10",
|
||||
"shellexpand",
|
||||
"solana-account-decoder",
|
||||
"solana-address-lookup-table-program",
|
||||
"solana-client",
|
||||
"solana-rpc",
|
||||
"solana-sdk",
|
||||
"spl-associated-token-account",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mango-v4-keeper"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"anchor-client",
|
||||
"anchor-lang",
|
||||
"anchor-spl",
|
||||
"anyhow",
|
||||
"clap 3.2.23",
|
||||
"dotenv",
|
||||
"env_logger 0.8.4",
|
||||
"fixed",
|
||||
"fixed-macro",
|
||||
"futures 0.3.25",
|
||||
"itertools 0.10.5",
|
||||
"log 0.4.17",
|
||||
"mango-v4",
|
||||
"mango-v4-client",
|
||||
"pyth-sdk-solana",
|
||||
"serum_dex 0.5.10",
|
||||
"solana-client",
|
||||
"solana-sdk",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mango-v4-liquidator"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"anchor-client",
|
||||
"anchor-lang",
|
||||
"anyhow",
|
||||
"arrayref",
|
||||
"async-channel",
|
||||
"async-stream 0.2.1",
|
||||
"async-trait",
|
||||
"bs58 0.3.1",
|
||||
"bytemuck",
|
||||
"bytes 1.3.0",
|
||||
"checked_math",
|
||||
"clap 3.2.23",
|
||||
"dotenv",
|
||||
"fixed",
|
||||
"futures 0.3.25",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"itertools 0.10.5",
|
||||
"jemallocator",
|
||||
"jsonrpc-core 18.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"jsonrpc-core-client",
|
||||
"log 0.4.17",
|
||||
"mango-v4",
|
||||
"mango-v4-client",
|
||||
"once_cell",
|
||||
"pyth-sdk-solana",
|
||||
"rand 0.7.3",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"serum_dex 0.5.10",
|
||||
"shellexpand",
|
||||
"solana-account-decoder",
|
||||
"solana-client",
|
||||
"solana-logger",
|
||||
"solana-rpc",
|
||||
"solana-sdk",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
"tokio-tungstenite 0.16.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mango-v4-settle-bot"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"anchor-client",
|
||||
"anchor-lang",
|
||||
"anyhow",
|
||||
"arrayref",
|
||||
"async-channel",
|
||||
"async-stream 0.2.1",
|
||||
"async-trait",
|
||||
"bincode",
|
||||
"bs58 0.3.1",
|
||||
"bytemuck",
|
||||
"bytes 1.3.0",
|
||||
"checked_math",
|
||||
"clap 3.2.23",
|
||||
"dotenv",
|
||||
"fixed",
|
||||
"futures 0.3.25",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"itertools 0.10.5",
|
||||
"jemallocator",
|
||||
"jsonrpc-core 18.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"jsonrpc-core-client",
|
||||
"log 0.4.17",
|
||||
"mango-v4",
|
||||
"mango-v4-client",
|
||||
"once_cell",
|
||||
"priority-queue",
|
||||
"pyth-sdk-solana",
|
||||
"rand 0.7.3",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"serum_dex 0.5.10",
|
||||
"shellexpand",
|
||||
"solana-account-decoder",
|
||||
"solana-client",
|
||||
"solana-logger",
|
||||
"solana-rpc",
|
||||
"solana-sdk",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
"tokio-tungstenite 0.16.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "matches"
|
||||
version = "0.1.9"
|
||||
|
@ -5120,54 +5168,6 @@ dependencies = [
|
|||
"without-alloc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "settle-bot"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"anchor-client",
|
||||
"anchor-lang",
|
||||
"anyhow",
|
||||
"arrayref",
|
||||
"async-channel",
|
||||
"async-stream 0.2.1",
|
||||
"async-trait",
|
||||
"bincode",
|
||||
"bs58 0.3.1",
|
||||
"bytemuck",
|
||||
"bytes 1.3.0",
|
||||
"checked_math",
|
||||
"clap 3.2.23",
|
||||
"client",
|
||||
"dotenv",
|
||||
"fixed",
|
||||
"futures 0.3.25",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"itertools 0.10.5",
|
||||
"jemallocator",
|
||||
"jsonrpc-core 18.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"jsonrpc-core-client",
|
||||
"log 0.4.17",
|
||||
"mango-v4",
|
||||
"once_cell",
|
||||
"priority-queue",
|
||||
"pyth-sdk-solana",
|
||||
"rand 0.7.3",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"serum_dex 0.5.10",
|
||||
"shellexpand",
|
||||
"solana-account-decoder",
|
||||
"solana-client",
|
||||
"solana-logger",
|
||||
"solana-rpc",
|
||||
"solana-sdk",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
"tokio-tungstenite 0.16.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha-1"
|
||||
version = "0.8.2"
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
[workspace]
|
||||
members = [
|
||||
"cli",
|
||||
"client",
|
||||
"bin/*",
|
||||
"programs/mango-v4",
|
||||
"keeper",
|
||||
"lib/*",
|
||||
"liquidator",
|
||||
"settle-bot",
|
||||
"3rdparty/anchor/cli",
|
||||
]
|
||||
|
||||
|
|
|
@ -1,24 +1,26 @@
|
|||
[package]
|
||||
name = "cli"
|
||||
name = "mango-v4-cli"
|
||||
version = "0.3.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
[[bin]]
|
||||
name = "cli"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
anchor-client = { path = "../3rdparty/anchor/client" }
|
||||
anchor-lang = { path = "../3rdparty/anchor/lang" }
|
||||
anchor-spl = { path = "../3rdparty/anchor/spl" }
|
||||
anchor-client = { path = "../../3rdparty/anchor/client" }
|
||||
anchor-lang = { path = "../../3rdparty/anchor/lang" }
|
||||
anchor-spl = { path = "../../3rdparty/anchor/spl" }
|
||||
anyhow = "1.0"
|
||||
clap = { version = "3.1.8", features = ["derive", "env"] }
|
||||
client = { path = "../client" }
|
||||
dotenv = "0.15.0"
|
||||
env_logger = "0.8.4"
|
||||
fixed = { version = "=1.11.0", features = ["serde", "borsh"] }
|
||||
fixed-macro = "^1.1.1"
|
||||
futures = "0.3.21"
|
||||
log = "0.4.0"
|
||||
mango-v4 = { path = "../programs/mango-v4", features = ["client"] }
|
||||
mango-v4 = { path = "../../programs/mango-v4", features = ["client"] }
|
||||
mango-v4-client = { path = "../../lib/client" }
|
||||
pyth-sdk-solana = "0.1.0"
|
||||
serum_dex = { git = "https://github.com/openbook-dex/program.git", default-features=false,features = ["no-entrypoint", "program"] }
|
||||
solana-client = "~1.14.9"
|
|
@ -1,5 +1,8 @@
|
|||
use clap::{Args, Parser, Subcommand};
|
||||
use client::{MangoClient, TransactionBuilderConfig};
|
||||
use mango_v4_client::{
|
||||
keypair_from_cli, pubkey_from_cli, Client, JupiterSwapMode, MangoClient,
|
||||
TransactionBuilderConfig,
|
||||
};
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
|
@ -108,9 +111,9 @@ enum Command {
|
|||
}
|
||||
|
||||
impl Rpc {
|
||||
fn client(&self, override_fee_payer: Option<&str>) -> anyhow::Result<client::Client> {
|
||||
let fee_payer = client::keypair_from_cli(override_fee_payer.unwrap_or(&self.fee_payer));
|
||||
Ok(client::Client::new(
|
||||
fn client(&self, override_fee_payer: Option<&str>) -> anyhow::Result<Client> {
|
||||
let fee_payer = keypair_from_cli(override_fee_payer.unwrap_or(&self.fee_payer));
|
||||
Ok(Client::new(
|
||||
anchor_client::Cluster::from_str(&self.url)?,
|
||||
solana_sdk::commitment_config::CommitmentConfig::confirmed(),
|
||||
Arc::new(fee_payer),
|
||||
|
@ -134,8 +137,8 @@ async fn main() -> Result<(), anyhow::Error> {
|
|||
match cli.command {
|
||||
Command::CreateAccount(cmd) => {
|
||||
let client = cmd.rpc.client(Some(&cmd.owner))?;
|
||||
let group = client::pubkey_from_cli(&cmd.group);
|
||||
let owner = client::keypair_from_cli(&cmd.owner);
|
||||
let group = pubkey_from_cli(&cmd.group);
|
||||
let owner = keypair_from_cli(&cmd.owner);
|
||||
|
||||
let account_num = if let Some(num) = cmd.account_num {
|
||||
num
|
||||
|
@ -161,19 +164,19 @@ async fn main() -> Result<(), anyhow::Error> {
|
|||
}
|
||||
Command::Deposit(cmd) => {
|
||||
let client = cmd.rpc.client(Some(&cmd.owner))?;
|
||||
let account = client::pubkey_from_cli(&cmd.account);
|
||||
let owner = Arc::new(client::keypair_from_cli(&cmd.owner));
|
||||
let mint = client::pubkey_from_cli(&cmd.mint);
|
||||
let account = pubkey_from_cli(&cmd.account);
|
||||
let owner = Arc::new(keypair_from_cli(&cmd.owner));
|
||||
let mint = pubkey_from_cli(&cmd.mint);
|
||||
let client = MangoClient::new_for_existing_account(client, account, owner).await?;
|
||||
let txsig = client.token_deposit(mint, cmd.amount, false).await?;
|
||||
println!("{}", txsig);
|
||||
}
|
||||
Command::JupiterSwap(cmd) => {
|
||||
let client = cmd.rpc.client(Some(&cmd.owner))?;
|
||||
let account = client::pubkey_from_cli(&cmd.account);
|
||||
let owner = Arc::new(client::keypair_from_cli(&cmd.owner));
|
||||
let input_mint = client::pubkey_from_cli(&cmd.input_mint);
|
||||
let output_mint = client::pubkey_from_cli(&cmd.output_mint);
|
||||
let account = pubkey_from_cli(&cmd.account);
|
||||
let owner = Arc::new(keypair_from_cli(&cmd.owner));
|
||||
let input_mint = pubkey_from_cli(&cmd.input_mint);
|
||||
let output_mint = pubkey_from_cli(&cmd.output_mint);
|
||||
let client = MangoClient::new_for_existing_account(client, account, owner).await?;
|
||||
let txsig = client
|
||||
.jupiter_swap(
|
||||
|
@ -181,18 +184,18 @@ async fn main() -> Result<(), anyhow::Error> {
|
|||
output_mint,
|
||||
cmd.amount,
|
||||
cmd.slippage_bps,
|
||||
client::JupiterSwapMode::ExactIn,
|
||||
JupiterSwapMode::ExactIn,
|
||||
)
|
||||
.await?;
|
||||
println!("{}", txsig);
|
||||
}
|
||||
Command::GroupAddress { creator, num } => {
|
||||
let creator = client::pubkey_from_cli(&creator);
|
||||
let creator = pubkey_from_cli(&creator);
|
||||
println!("{}", MangoClient::group_for_admin(creator, num));
|
||||
}
|
||||
Command::MangoAccountAddress { group, owner, num } => {
|
||||
let group = client::pubkey_from_cli(&group);
|
||||
let owner = client::pubkey_from_cli(&owner);
|
||||
let group = pubkey_from_cli(&group);
|
||||
let owner = pubkey_from_cli(&owner);
|
||||
let address = Pubkey::find_program_address(
|
||||
&[
|
||||
group.as_ref(),
|
|
@ -1,17 +1,18 @@
|
|||
[package]
|
||||
name = "keeper"
|
||||
name = "mango-v4-keeper"
|
||||
version = "0.3.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
[[bin]]
|
||||
name = "keeper"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
anchor-client = { path = "../3rdparty/anchor/client" }
|
||||
anchor-lang = { path = "../3rdparty/anchor/lang" }
|
||||
anchor-spl = { path = "../3rdparty/anchor/spl" }
|
||||
anchor-client = { path = "../../3rdparty/anchor/client" }
|
||||
anchor-lang = { path = "../../3rdparty/anchor/lang" }
|
||||
anchor-spl = { path = "../../3rdparty/anchor/spl" }
|
||||
anyhow = "1.0"
|
||||
clap = { version = "3.1.8", features = ["derive", "env"] }
|
||||
client = { path = "../client" }
|
||||
dotenv = "0.15.0"
|
||||
env_logger = "0.8.4"
|
||||
fixed = { version = "=1.11.0", features = ["serde", "borsh"] }
|
||||
|
@ -19,7 +20,8 @@ fixed-macro = "^1.1.1"
|
|||
futures = "0.3.21"
|
||||
itertools = "0.10.3"
|
||||
log = "0.4.0"
|
||||
mango-v4 = { path = "../programs/mango-v4", features = ["client"] }
|
||||
mango-v4 = { path = "../../programs/mango-v4", features = ["client"] }
|
||||
mango-v4-client = { path = "../../lib/client" }
|
||||
pyth-sdk-solana = "0.1.0"
|
||||
serum_dex = { git = "https://github.com/openbook-dex/program.git", default-features=false,features = ["no-entrypoint", "program"] }
|
||||
solana-client = "~1.14.9"
|
|
@ -7,7 +7,7 @@ use std::time::Duration;
|
|||
use anchor_client::Cluster;
|
||||
|
||||
use clap::{Parser, Subcommand};
|
||||
use client::{keypair_from_cli, Client, MangoClient};
|
||||
use mango_v4_client::{keypair_from_cli, Client, MangoClient, TransactionBuilderConfig};
|
||||
use solana_sdk::commitment_config::CommitmentConfig;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use tokio::time;
|
||||
|
@ -104,7 +104,7 @@ async fn main() -> Result<(), anyhow::Error> {
|
|||
commitment,
|
||||
owner.clone(),
|
||||
Some(Duration::from_secs(cli.timeout)),
|
||||
client::TransactionBuilderConfig {
|
||||
TransactionBuilderConfig {
|
||||
prioritization_micro_lamports: (cli.prioritization_micro_lamports > 0)
|
||||
.then_some(cli.prioritization_micro_lamports),
|
||||
},
|
|
@ -1,11 +1,15 @@
|
|||
[package]
|
||||
name = "liquidator"
|
||||
name = "mango-v4-liquidator"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
|
||||
[[bin]]
|
||||
name = "liquidator"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
anchor-lang = { path = "../3rdparty/anchor/lang" }
|
||||
anchor-client = { path = "../3rdparty/anchor/client" }
|
||||
anchor-lang = { path = "../../3rdparty/anchor/lang" }
|
||||
anchor-client = { path = "../../3rdparty/anchor/client" }
|
||||
anyhow = "1.0"
|
||||
arrayref = "0.3.6"
|
||||
async-channel = "1.6"
|
||||
|
@ -14,9 +18,8 @@ async-trait = "0.1"
|
|||
bs58 = "0.3.1"
|
||||
bytemuck = "^1.7.2"
|
||||
bytes = "1.0"
|
||||
checked_math = { path = "../lib/checked_math" }
|
||||
checked_math = { path = "../../lib/checked_math" }
|
||||
clap = { version = "3.1.8", features = ["derive", "env"] }
|
||||
client = { path = "../client" }
|
||||
dotenv = "0.15.0"
|
||||
fixed = { version = "=1.11.0", features = ["serde"] }
|
||||
futures = "0.3.17"
|
||||
|
@ -27,7 +30,8 @@ jemallocator = "0.3.2"
|
|||
jsonrpc-core = "18.0.0"
|
||||
jsonrpc-core-client = { version = "18.0.0", features = ["ws", "http", "tls"] }
|
||||
log = "0.4"
|
||||
mango-v4 = { path = "../programs/mango-v4", features = ["client"] }
|
||||
mango-v4 = { path = "../../programs/mango-v4", features = ["client"] }
|
||||
mango-v4-client = { path = "../../lib/client" }
|
||||
once_cell = "1.12.0"
|
||||
pyth-sdk-solana = "0.1.0"
|
||||
rand = "0.7"
|
|
@ -1,12 +1,12 @@
|
|||
use std::collections::HashSet;
|
||||
use std::time::Duration;
|
||||
|
||||
use client::{chain_data, health_cache, AccountFetcher, MangoClient};
|
||||
use mango_v4::accounts_zerocopy::KeyedAccountSharedData;
|
||||
use mango_v4::health::{HealthCache, HealthType};
|
||||
use mango_v4::state::{
|
||||
Bank, MangoAccountValue, PerpMarketIndex, Side, TokenIndex, QUOTE_TOKEN_INDEX,
|
||||
};
|
||||
use mango_v4_client::{chain_data, health_cache, AccountFetcher, JupiterSwapMode, MangoClient};
|
||||
use solana_sdk::signature::Signature;
|
||||
|
||||
use futures::{stream, StreamExt, TryStreamExt};
|
||||
|
@ -40,7 +40,7 @@ pub async fn jupiter_market_can_buy(
|
|||
token_mint,
|
||||
quote_amount,
|
||||
slippage,
|
||||
client::JupiterSwapMode::ExactIn,
|
||||
JupiterSwapMode::ExactIn,
|
||||
)
|
||||
.await
|
||||
.is_ok()
|
||||
|
@ -68,7 +68,7 @@ pub async fn jupiter_market_can_sell(
|
|||
quote_token_mint,
|
||||
quote_amount,
|
||||
slippage,
|
||||
client::JupiterSwapMode::ExactOut,
|
||||
JupiterSwapMode::ExactOut,
|
||||
)
|
||||
.await
|
||||
.is_ok()
|
|
@ -4,12 +4,13 @@ use std::time::Duration;
|
|||
|
||||
use anchor_client::Cluster;
|
||||
use clap::Parser;
|
||||
use client::{
|
||||
account_update_stream, chain_data, keypair_from_cli, snapshot_source, websocket_source,
|
||||
AsyncChannelSendUnlessFull, Client, MangoClient, MangoGroupContext,
|
||||
};
|
||||
use log::*;
|
||||
use mango_v4::state::{PerpMarketIndex, TokenIndex};
|
||||
use mango_v4_client::{
|
||||
account_update_stream, chain_data, keypair_from_cli, snapshot_source, websocket_source,
|
||||
AsyncChannelSendUnlessFull, Client, MangoClient, MangoClientError, MangoGroupContext,
|
||||
TransactionBuilderConfig,
|
||||
};
|
||||
|
||||
use itertools::Itertools;
|
||||
use solana_sdk::commitment_config::CommitmentConfig;
|
||||
|
@ -105,7 +106,7 @@ async fn main() -> anyhow::Result<()> {
|
|||
commitment,
|
||||
liqor_owner.clone(),
|
||||
Some(rpc_timeout),
|
||||
client::TransactionBuilderConfig {
|
||||
TransactionBuilderConfig {
|
||||
prioritization_micro_lamports: (cli.prioritization_micro_lamports > 0)
|
||||
.then_some(cli.prioritization_micro_lamports),
|
||||
},
|
||||
|
@ -496,10 +497,8 @@ impl LiquidationState {
|
|||
|
||||
// Simulation errors due to liqee precondition failures on the liquidation instructions
|
||||
// will commonly happen if our liquidator is late or if there are chain forks.
|
||||
match err.downcast_ref::<client::MangoClientError>() {
|
||||
Some(client::MangoClientError::SendTransactionPreflightFailure {
|
||||
logs, ..
|
||||
}) => {
|
||||
match err.downcast_ref::<MangoClientError>() {
|
||||
Some(MangoClientError::SendTransactionPreflightFailure { logs, .. }) => {
|
||||
if logs.iter().any(|line| {
|
||||
line.contains("HealthMustBeNegative") || line.contains("IsNotBankrupt")
|
||||
}) {
|
|
@ -1,8 +1,10 @@
|
|||
use client::{chain_data, AccountFetcher, AnyhowWrap, MangoClient, TokenContext};
|
||||
use mango_v4::accounts_zerocopy::KeyedAccountSharedData;
|
||||
use mango_v4::state::{
|
||||
Bank, BookSide, PlaceOrderType, Side, TokenIndex, TokenPosition, QUOTE_TOKEN_INDEX,
|
||||
};
|
||||
use mango_v4_client::{
|
||||
chain_data, perp_pnl, AccountFetcher, AnyhowWrap, JupiterSwapMode, MangoClient, TokenContext,
|
||||
};
|
||||
|
||||
use {fixed::types::I80F48, solana_sdk::pubkey::Pubkey};
|
||||
|
||||
|
@ -160,7 +162,7 @@ impl Rebalancer {
|
|||
token_mint,
|
||||
input_amount.to_num::<u64>(),
|
||||
self.config.slippage_bps,
|
||||
client::JupiterSwapMode::ExactIn,
|
||||
JupiterSwapMode::ExactIn,
|
||||
)
|
||||
.await?;
|
||||
log::info!(
|
||||
|
@ -192,7 +194,7 @@ impl Rebalancer {
|
|||
quote_mint,
|
||||
amount.to_num::<u64>(),
|
||||
self.config.slippage_bps,
|
||||
client::JupiterSwapMode::ExactIn,
|
||||
JupiterSwapMode::ExactIn,
|
||||
)
|
||||
.await?;
|
||||
log::info!(
|
||||
|
@ -346,11 +348,11 @@ impl Rebalancer {
|
|||
} else if base_lots == 0 && quote_native != 0 {
|
||||
// settle pnl
|
||||
let direction = if quote_native > 0 {
|
||||
client::perp_pnl::Direction::MaxNegative
|
||||
perp_pnl::Direction::MaxNegative
|
||||
} else {
|
||||
client::perp_pnl::Direction::MaxPositive
|
||||
perp_pnl::Direction::MaxPositive
|
||||
};
|
||||
let counters = client::perp_pnl::fetch_top(
|
||||
let counters = perp_pnl::fetch_top(
|
||||
&self.mango_client.context,
|
||||
self.account_fetcher.as_ref(),
|
||||
perp_position.market_index,
|
|
@ -4,7 +4,7 @@ use mango_v4::state::{Bank, MintInfo, PerpMarket};
|
|||
use solana_sdk::account::AccountSharedData;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
|
||||
pub use client::snapshot_source::is_mango_account;
|
||||
pub use mango_v4_client::snapshot_source::is_mango_account;
|
||||
|
||||
pub fn is_mango_bank<'a>(account: &'a AccountSharedData, group_id: &Pubkey) -> Option<&'a Bank> {
|
||||
let bank = account.load::<Bank>().ok()?;
|
|
@ -1,11 +1,15 @@
|
|||
[package]
|
||||
name = "settle-bot"
|
||||
name = "mango-v4-settle-bot"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
|
||||
[[bin]]
|
||||
name = "settle-bot"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
anchor-lang = { path = "../3rdparty/anchor/lang" }
|
||||
anchor-client = { path = "../3rdparty/anchor/client" }
|
||||
anchor-lang = { path = "../../3rdparty/anchor/lang" }
|
||||
anchor-client = { path = "../../3rdparty/anchor/client" }
|
||||
anyhow = "1.0"
|
||||
arrayref = "0.3.6"
|
||||
async-channel = "1.6"
|
||||
|
@ -15,9 +19,8 @@ bincode = "1.3.3"
|
|||
bs58 = "0.3.1"
|
||||
bytemuck = "^1.7.2"
|
||||
bytes = "1.0"
|
||||
checked_math = { path = "../lib/checked_math" }
|
||||
checked_math = { path = "../../lib/checked_math" }
|
||||
clap = { version = "3.1.8", features = ["derive", "env"] }
|
||||
client = { path = "../client" }
|
||||
dotenv = "0.15.0"
|
||||
fixed = { version = "=1.11.0", features = ["serde"] }
|
||||
futures = "0.3.17"
|
||||
|
@ -28,7 +31,8 @@ jemallocator = "0.3.2"
|
|||
jsonrpc-core = "18.0.0"
|
||||
jsonrpc-core-client = { version = "18.0.0", features = ["ws", "http", "tls"] }
|
||||
log = "0.4"
|
||||
mango-v4 = { path = "../programs/mango-v4", features = ["client"] }
|
||||
mango-v4 = { path = "../../programs/mango-v4", features = ["client"] }
|
||||
mango-v4-client = { path = "../../lib/client" }
|
||||
once_cell = "1.12.0"
|
||||
priority-queue = "1.3.1"
|
||||
pyth-sdk-solana = "0.1.0"
|
|
@ -4,12 +4,12 @@ use std::time::Duration;
|
|||
|
||||
use anchor_client::Cluster;
|
||||
use clap::Parser;
|
||||
use client::{
|
||||
account_update_stream, chain_data, keypair_from_cli, snapshot_source, websocket_source,
|
||||
AsyncChannelSendUnlessFull, Client, MangoClient, MangoGroupContext,
|
||||
};
|
||||
use log::*;
|
||||
use mango_v4::state::{PerpMarketIndex, TokenIndex};
|
||||
use mango_v4_client::{
|
||||
account_update_stream, chain_data, keypair_from_cli, snapshot_source, websocket_source,
|
||||
AsyncChannelSendUnlessFull, Client, MangoClient, MangoGroupContext, TransactionBuilderConfig,
|
||||
};
|
||||
|
||||
use itertools::Itertools;
|
||||
use solana_sdk::commitment_config::CommitmentConfig;
|
||||
|
@ -97,7 +97,7 @@ async fn main() -> anyhow::Result<()> {
|
|||
commitment,
|
||||
settler_owner.clone(),
|
||||
Some(rpc_timeout),
|
||||
client::TransactionBuilderConfig {
|
||||
TransactionBuilderConfig {
|
||||
prioritization_micro_lamports: (cli.prioritization_micro_lamports > 0)
|
||||
.then_some(cli.prioritization_micro_lamports),
|
||||
},
|
|
@ -2,12 +2,12 @@ use std::collections::HashMap;
|
|||
use std::sync::Arc;
|
||||
use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
|
||||
|
||||
use client::{
|
||||
chain_data, health_cache, prettify_solana_client_error, MangoClient, TransactionBuilder,
|
||||
};
|
||||
use mango_v4::accounts_zerocopy::KeyedAccountSharedData;
|
||||
use mango_v4::health::HealthType;
|
||||
use mango_v4::state::{PerpMarket, PerpMarketIndex};
|
||||
use mango_v4_client::{
|
||||
chain_data, health_cache, prettify_solana_client_error, MangoClient, TransactionBuilder,
|
||||
};
|
||||
use solana_sdk::address_lookup_table_account::AddressLookupTableAccount;
|
||||
use solana_sdk::commitment_config::CommitmentConfig;
|
||||
use solana_sdk::instruction::Instruction;
|
|
@ -4,7 +4,7 @@ use mango_v4::state::{Bank, MintInfo, PerpMarket};
|
|||
use solana_sdk::account::AccountSharedData;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
|
||||
pub use client::snapshot_source::is_mango_account;
|
||||
pub use mango_v4_client::snapshot_source::is_mango_account;
|
||||
|
||||
pub fn is_mango_bank<'a>(account: &'a AccountSharedData, group_id: &Pubkey) -> Option<&'a Bank> {
|
||||
let bank = account.load::<Bank>().ok()?;
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "client"
|
||||
name = "mango-v4-client"
|
||||
version = "0.3.0"
|
||||
edition = "2021"
|
||||
|
||||
|
@ -7,9 +7,9 @@ edition = "2021"
|
|||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
anchor-client = { path = "../3rdparty/anchor/client" }
|
||||
anchor-lang = { path = "../3rdparty/anchor/lang" }
|
||||
anchor-spl = { path = "../3rdparty/anchor/spl" }
|
||||
anchor-client = { path = "../../3rdparty/anchor/client" }
|
||||
anchor-lang = { path = "../../3rdparty/anchor/lang" }
|
||||
anchor-spl = { path = "../../3rdparty/anchor/spl" }
|
||||
anyhow = "1.0"
|
||||
async-channel = "1.6"
|
||||
async-once-cell = { version = "0.4.2", features = ["unpin"] }
|
||||
|
@ -20,7 +20,7 @@ futures = "0.3.25"
|
|||
itertools = "0.10.3"
|
||||
jsonrpc-core = "18.0.0"
|
||||
jsonrpc-core-client = { version = "18.0.0", features = ["ws", "http", "tls"] }
|
||||
mango-v4 = { path = "../programs/mango-v4", features = ["client"] }
|
||||
mango-v4 = { path = "../../programs/mango-v4", features = ["client"] }
|
||||
pyth-sdk-solana = "0.1.0"
|
||||
serum_dex = { git = "https://github.com/openbook-dex/program.git", default-features=false,features = ["no-entrypoint", "program"] }
|
||||
shellexpand = "2.1.0"
|
Loading…
Reference in New Issue