-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mint-options): add lightweight option minter cron
- Loading branch information
1 parent
cec5872
commit 4de334c
Showing
9 changed files
with
69 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use crate::context::app_context::AppContext; | ||
use crate::models::{MintOptionsBody, MintOptionsResponse}; | ||
use axum::{extract::State, http::StatusCode, Json}; | ||
use std::sync::Arc; | ||
|
||
pub async fn mint_options( | ||
State(app_context): State<Arc<AppContext>>, | ||
Json(payload): Json<MintOptionsBody>, | ||
) -> (StatusCode, Json<MintOptionsResponse>) { | ||
// Spawn a new task to handle minting in the background | ||
tokio::spawn(async move { | ||
// Your minting logic goes here | ||
process_mint_options(app_context, payload).await; | ||
}); | ||
|
||
( | ||
StatusCode::ACCEPTED, | ||
Json(MintOptionsResponse { | ||
message: "Minting process started in the background".to_string(), | ||
}), | ||
) | ||
} | ||
|
||
async fn process_mint_options(app_context: Arc<AppContext>, payload: MintOptionsBody) { | ||
loop { | ||
println!("{payload:?} {app_context:?}"); | ||
// Implement your actual minting logic here | ||
// This will run in the background | ||
tokio::time::sleep(std::time::Duration::from_secs(1)).await; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
pub mod health; | ||
pub mod mint_options; | ||
pub mod trades; | ||
|
||
pub use health::*; | ||
pub use mint_options::*; | ||
pub use trades::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Debug, Deserialize, Serialize)] | ||
pub struct MintOptionsBody { | ||
pub strike_price: u64, | ||
pub price_decimals: u8, | ||
pub underlying_amount_per_contract: u64, | ||
pub expiration_timestamp: i64, | ||
} | ||
|
||
#[derive(Debug, Serialize)] | ||
pub struct MintOptionsResponse { | ||
pub message: String, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
pub mod health; | ||
pub mod mint_options; | ||
pub mod program_types; | ||
pub mod trades; | ||
|
||
pub use health::*; | ||
pub use mint_options::*; | ||
pub use trades::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod euro_meta; | ||
pub mod expiration_data; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use crate::context::app_context::AppContext; | ||
use crate::handlers::mint_options; | ||
use axum::{routing::post, Router}; | ||
use std::sync::Arc; | ||
|
||
pub fn bot_actions_route(app_context: Arc<AppContext>) -> Router { | ||
Router::new() | ||
.route("/mint-options", post(mint_options)) | ||
.with_state(app_context) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters