Skip to content
Merged
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
115 changes: 109 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ path = "src/lib.rs"

[[bin]]
name = "strat"
path = "src/bin/strategy.rs"
path = "src/bin/dn_strat/main.rs"

[[bin]]
name = "deployer"
path = "src/bin/perp_deployer.rs"

[[bin]]
name = "dex"
path = "src/bin/perp_dex.rs"

[dependencies]
alloy = "1.0.9"
anyhow = "1.0.98"
Expand All @@ -41,3 +45,5 @@ thiserror = "2.0.12"
tokio = "1.45.1"
tokio-tungstenite = {version = "0.26.2",features = ["native-tls"] }
tokio-util = "0.7.15"
tracing = "0.1.41"
tracing-subscriber = {version = "0.3.19", features = ["json","env-filter"] }
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ run-strat:

run-deployer:
cargo run --bin deployer

run-dex:
cargo run --bin dex

debug:
cargo build
Expand Down
3 changes: 0 additions & 3 deletions src/config.rs → src/bin/dn_strat/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ pub struct Config {
#[envconfig(from = "USER_ADDRESS")]
pub user_address: String,

#[envconfig(from = "EXISTING_ORDER_ID")]
pub existing_order_id: String,

#[envconfig(from = "BOT_URL")]
pub bot_url: String,

Expand Down
2 changes: 1 addition & 1 deletion src/handlers.rs → src/bin/dn_strat/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::sync::Arc;
use axum::{Json, extract::State};
use serde::{Deserialize, Serialize};

use crate::services::{CurrentUserPositionResponse, OpenPositionRequest, StrategyManagerService};
use crate::service::{CurrentUserPositionResponse, OpenPositionRequest, StrategyManagerService};

#[derive(Deserialize, Serialize)]
pub struct ResponseJson<T> {
Expand Down
27 changes: 23 additions & 4 deletions src/bin/strategy.rs → src/bin/dn_strat/main.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
use std::sync::Arc;
use std::time::Duration;
use std::{env, sync::Arc};

use alloy::primitives::Address;
use envconfig::Envconfig;
use hyperqit::*;
use log::info;
use tokio::signal;
use tokio_util::sync::CancellationToken;
use tracing::info;

mod config;
mod handlers;
mod notifier;
mod router;
mod service;
mod strategy;

use config::Config;
use notifier::NotifierService;
use router::create_router;
use service::StrategyManagerService;
use strategy::{Asset, Strategy};
use tracing_subscriber::EnvFilter;

#[tokio::main]
async fn main() {
env_logger::init();
let config = hyperqit::Config::init_from_env().unwrap();
tracing_subscriber::fmt()
.json()
.with_env_filter(
EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info")),
)
.init();
let config = Config::init_from_env().unwrap();
let signer = Signers::Local(hyperqit::LocalWallet::signer(config.private_key));

let user_address: Address = config.user_address.parse().unwrap();
Expand Down
3 changes: 3 additions & 0 deletions src/bin/dn_strat/notifier/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mod notifier;

pub use notifier::*;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use log::{error, info};
use reqwest::Client;
use serde::Serialize;
use tracing::{error, info};

#[derive(Debug, Clone)]
pub struct NotifierService {
Expand Down
2 changes: 1 addition & 1 deletion src/router.rs → src/bin/dn_strat/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use axum::{

use crate::{
handlers::{close_position, create_new_position, get_current_position},
services::StrategyManagerService,
service::StrategyManagerService,
};

pub fn create_router(manager_svc: Arc<StrategyManagerService>) -> Router {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ use std::sync::Arc;
use anyhow::Ok;
use serde::{Deserialize, Serialize};

use crate::{Amount, Asset, Strategy, StrategyState, errors::Result};
use hyperqit::Result;

use crate::strategy::{Amount, Asset, Strategy, StrategyState};

#[derive(Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
Expand Down
File renamed without changes.
File renamed without changes.
Loading