Skip to main content

jupiter_sdk/models/trigger/
mod.rs

1use serde::{Deserialize, Serialize};
2use serde_with::serde_as;
3
4
5
6
7
8#[derive(Debug, Deserialize, Serialize)]
9#[serde(rename_all = "camelCase")]
10#[serde_as]
11pub struct CreateOrderParams {
12    pub making_amount: String,
13    pub taking_amount: String,
14    pub expired_at: String,
15    // Amount of slippage the order can be executed with
16    pub slippage_bps: String,
17    // Requires the feeAccount parameter, the amount of fees in bps that will be sent to the fee account
18    pub fee_bps: String,
19}
20
21
22
23fn default_option_true() -> Option<bool> { Some(true) }
24
25
26#[derive(Debug, Deserialize, Serialize)]
27#[serde(rename_all = "camelCase")]
28#[serde_as]
29pub struct CreateOrderReq {
30    pub input_mint: String,
31    pub output_mint: String,
32    pub maker: String,
33    pub payer: String,
34    pub params: CreateOrderParams,
35    pub compute_unit_price: Option<String>,
36    pub fee_account: Option<String>,
37    #[serde(default = "default_option_true")]
38    pub wrap_and_unwrap_sol: Option<bool>,
39}
40
41
42#[derive(Debug, Deserialize, Serialize)]
43#[serde(rename_all = "camelCase")]
44#[serde_as]
45pub struct CreateOrderRes {
46    pub request_id: String,
47    pub transaction: String,
48    pub order: String,
49}
50
51
52#[derive(Debug, Deserialize, Serialize)]
53#[serde(rename_all = "camelCase")]
54#[serde_as]
55pub struct CancelOrderReq {
56    pub maker: String,
57    pub order: String,
58    // In microlamports, defaults to 95th percentile of priority fees
59    pub compute_unit_price: Option<String>,
60}
61
62#[derive(Debug, Deserialize, Serialize)]
63#[serde(rename_all = "camelCase")]
64#[serde_as]
65pub struct CancelOrderRes {
66    pub request_id: String,
67    pub transaction: String,
68}
69
70#[derive(Debug, Deserialize, Serialize)]
71#[serde(rename_all = "camelCase")]
72#[serde_as]
73pub struct CancelOrdersReq {
74    pub maker: String,
75    pub orders: Vec<String>,
76    // In microlamports, defaults to 95th percentile of priority fees
77    pub compute_unit_price: Option<String>,
78}
79
80#[derive(Debug, Deserialize, Serialize)]
81#[serde(rename_all = "camelCase")]
82#[serde_as]
83pub struct CancelOrdersRes {
84    pub request_id: String,
85    pub transaction: String,
86}
87
88#[derive(Debug, Deserialize, Serialize)]
89#[serde(rename_all = "camelCase")]
90#[serde_as]
91pub struct GetTriggerOrdersReq {
92    pub user: String,
93    pub order_status: String,
94    pub input_mint: Option<String>,
95    pub output_mint: Option<String>,
96    pub include_failed_tx: Option<bool>,
97    pub page: Option<String>,
98}
99
100#[derive(Debug, Deserialize, Serialize)]
101#[serde(rename_all = "camelCase")]
102#[serde_as]
103pub struct GetTriggerOrdersRes {
104    pub user: String,
105    pub order_status: String,
106    pub orders: Vec<TriggerOrder>,
107    pub total_pages: u64,
108    pub page: u32,
109}
110
111#[derive(Debug, Deserialize, Serialize)]
112#[serde(rename_all = "camelCase")]
113#[serde_as]
114pub struct TriggerOrder {
115    pub user_pubkey: String,
116    pub order_key: String,
117    pub input_mint: String,
118    pub output_mint: String,
119    pub making_amoutn: String,
120    pub taking_amount: String,
121    pub remaining_making_amount: String,
122    pub remaining_taking_amount: String,
123    pub raw_making_amount: String,
124    pub raw_taking_amount: String,
125    pub raw_remaining_making_amount: String,
126    pub raw_remaining_taking_amount: String,
127    pub slippage_bps: u32,
128    pub expired_at: String,
129    pub updated_at: String,
130    pub status: String,
131    pub open_tx: String,
132    pub close_tx: String,
133    pub program_version: String,
134    pub trades: Vec<Trade>
135}
136
137#[derive(Debug, Deserialize, Serialize)]
138#[serde(rename_all = "camelCase")]
139#[serde_as]
140pub struct Trade {
141    pub order_key: String,
142    pub keeper: String,
143    pub input_mint: String,
144    pub output_mint: String,
145    pub input_amount: String,
146    pub output_amount: String,
147    pub raw_input_amount: String,
148    pub raw_output_amount: String,
149    pub fee_mint: String,
150    pub fee_amount: String,
151    pub raw_fee_amount: String,
152    pub tx_id: String,
153    pub confirmed_at: String,
154    pub action: String,
155    pub product_meta: Option<String>,
156}