2026-06-26 09:22:42 +02:00
|
|
|
use serde::Deserialize;
|
|
|
|
|
|
|
|
|
|
use crate::account::AccountRead;
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq)]
|
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
|
pub struct ConfigIdRequest {
|
|
|
|
|
pub amm_program_id: String,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq)]
|
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
|
pub struct TokenIdsRequest {
|
|
|
|
|
pub amm_program_id: String,
|
|
|
|
|
pub config: AccountRead,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub wallet_accounts: Vec<AccountRead>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub configured_token_ids: Vec<String>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub recent_token_ids: Vec<String>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub resolved_token_ids: Vec<String>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq)]
|
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
|
pub struct ContextRequest {
|
|
|
|
|
pub network_id: String,
|
|
|
|
|
pub network_fingerprint: String,
|
|
|
|
|
pub amm_program_id: String,
|
|
|
|
|
pub wallet_available: bool,
|
|
|
|
|
pub config: AccountRead,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub wallet_accounts: Vec<AccountRead>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub token_definitions: Vec<AccountRead>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub configured_token_ids: Vec<String>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub recent_token_ids: Vec<String>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub resolved_token_ids: Vec<String>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq)]
|
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
|
pub struct PairIdsRequest {
|
|
|
|
|
pub amm_program_id: String,
|
|
|
|
|
pub config: AccountRead,
|
|
|
|
|
pub token_a_id: String,
|
|
|
|
|
pub token_b_id: String,
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-27 16:01:37 +02:00
|
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq)]
|
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
|
pub struct SwapPairRequest {
|
|
|
|
|
pub amm_program_id: String,
|
|
|
|
|
pub token_in_id: String,
|
|
|
|
|
pub token_out_id: String,
|
|
|
|
|
pub config: AccountRead,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq)]
|
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
|
pub struct ResolvePoolRequest {
|
|
|
|
|
pub pool: AccountRead,
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-04 17:27:02 +02:00
|
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq)]
|
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
|
pub struct SwapExactInQuoteRequest {
|
|
|
|
|
pub token_in_id: String,
|
|
|
|
|
pub token_out_id: String,
|
|
|
|
|
pub amount_in_raw: String,
|
|
|
|
|
pub slippage_bps: u32,
|
|
|
|
|
/// Pool account data (hex Borsh `PoolDefinition`). Empty / undecodable ⇒ the
|
|
|
|
|
/// op returns the `no_pool` error.
|
|
|
|
|
pub pool_data: String,
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-04 19:05:06 +02:00
|
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq)]
|
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
|
pub struct SwapExactOutQuoteRequest {
|
|
|
|
|
pub token_in_id: String,
|
|
|
|
|
pub token_out_id: String,
|
|
|
|
|
pub amount_out_raw: String,
|
|
|
|
|
pub slippage_bps: u32,
|
|
|
|
|
/// Pool account data (hex Borsh `PoolDefinition`). Empty / undecodable ⇒ the
|
|
|
|
|
/// op returns the `no_pool` error.
|
|
|
|
|
pub pool_data: String,
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-04 17:00:15 +02:00
|
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq)]
|
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
|
pub struct PoolIdRequest {
|
|
|
|
|
pub amm_program_id: String,
|
|
|
|
|
pub token_in_id: String,
|
|
|
|
|
pub token_out_id: String,
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-27 16:01:37 +02:00
|
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq)]
|
|
|
|
|
#[serde(rename_all = "camelCase")]
|
2026-08-04 19:21:29 +02:00
|
|
|
pub struct SwapExactInPlanRequest {
|
2026-07-27 16:01:37 +02:00
|
|
|
pub amm_program_id: String,
|
|
|
|
|
pub token_in_id: String,
|
|
|
|
|
pub token_out_id: String,
|
|
|
|
|
pub config: AccountRead,
|
|
|
|
|
pub user_input_holding_id: String,
|
|
|
|
|
pub user_output_holding_id: String,
|
|
|
|
|
pub amount_in: String,
|
|
|
|
|
pub min_out: String,
|
|
|
|
|
pub deadline_ms: String,
|
2026-08-06 14:14:15 +02:00
|
|
|
/// Pool account data (hex Borsh `PoolDefinition`) — its stored `vault_a_id` /
|
|
|
|
|
/// `vault_b_id` are used verbatim (the guest asserts the vaults in the pool's
|
2026-08-04 22:05:35 +02:00
|
|
|
/// creation order, which needn't match the canonical token order).
|
|
|
|
|
pub pool_data: String,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq)]
|
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
|
pub struct SwapExactOutPlanRequest {
|
|
|
|
|
pub amm_program_id: String,
|
|
|
|
|
pub token_in_id: String,
|
|
|
|
|
pub token_out_id: String,
|
|
|
|
|
pub config: AccountRead,
|
|
|
|
|
pub user_input_holding_id: String,
|
|
|
|
|
pub user_output_holding_id: String,
|
|
|
|
|
pub amount_out: String,
|
|
|
|
|
pub max_in: String,
|
|
|
|
|
pub deadline_ms: String,
|
|
|
|
|
/// Pool account data (hex Borsh `PoolDefinition`) — its stored `vault_a_id` /
|
|
|
|
|
/// `vault_b_id` are used verbatim (the guest asserts the vaults in the pool's
|
2026-08-06 14:14:15 +02:00
|
|
|
/// creation order, which needn't match the canonical token order).
|
|
|
|
|
pub pool_data: String,
|
2026-07-27 16:01:37 +02:00
|
|
|
}
|
|
|
|
|
|
2026-08-07 11:56:37 +02:00
|
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq)]
|
|
|
|
|
#[serde(rename_all = "camelCase")]
|
2026-08-11 19:29:39 +02:00
|
|
|
pub struct CreatePoolQuoteRequest {
|
2026-08-07 11:56:37 +02:00
|
|
|
pub token_a_id: String,
|
|
|
|
|
pub token_b_id: String,
|
2026-08-10 15:11:35 +02:00
|
|
|
/// The opening price as a `Q64.64` fixed-point value (token B per token A, canonical
|
|
|
|
|
/// order). Required only in the price-only mode (no `amount_*_raw`), where it drives the
|
|
|
|
|
/// minimum opening deposit; when amounts are supplied the op derives the price from them.
|
|
|
|
|
#[serde(default)]
|
2026-08-11 19:29:39 +02:00
|
|
|
pub price_raw: Option<String>,
|
2026-08-07 11:56:37 +02:00
|
|
|
#[serde(default)]
|
|
|
|
|
pub amount_a_raw: Option<String>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub amount_b_raw: Option<String>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq)]
|
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
|
pub struct CreatePoolPlanRequest {
|
|
|
|
|
/// Resolved by the module from `AMM_PROGRAM_BIN` (like every id-deriving op) —
|
|
|
|
|
/// the FFI is stateless and can't read it itself.
|
|
|
|
|
pub amm_program_id: String,
|
|
|
|
|
/// AMM config account read — decoded by `derive_pair` for the `twap_oracle_program_id`
|
|
|
|
|
/// the `current_tick` PDA depends on (same as the swap plan requests).
|
|
|
|
|
pub config: AccountRead,
|
|
|
|
|
pub token_a_id: String,
|
|
|
|
|
pub token_b_id: String,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub amount_a_raw: Option<String>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub amount_b_raw: Option<String>,
|
|
|
|
|
pub fee_bps: u32,
|
|
|
|
|
pub deadline_ms: String,
|
|
|
|
|
pub user_holding_a_id: String,
|
|
|
|
|
pub user_holding_b_id: String,
|
|
|
|
|
pub user_holding_lp_id: String,
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-08 22:33:25 +02:00
|
|
|
/// Prices an `AddLiquidity` into an existing pool — the add counterpart of
|
2026-08-11 19:29:39 +02:00
|
|
|
/// `CreatePoolQuoteRequest`. The two max amounts are the caller's caps (display order);
|
2026-08-08 22:33:25 +02:00
|
|
|
/// `pool_data` is the hex Borsh `PoolDefinition` (empty ⇒ no pool), same as the swap quotes.
|
|
|
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq)]
|
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
|
pub struct AddLiquidityQuoteRequest {
|
|
|
|
|
pub token_a_id: String,
|
|
|
|
|
pub token_b_id: String,
|
|
|
|
|
pub max_amount_a_raw: String,
|
|
|
|
|
pub max_amount_b_raw: String,
|
2026-08-10 11:03:16 +02:00
|
|
|
/// Slippage tolerance in basis points — the quote returns `minimumLpRaw`, the LP floor
|
|
|
|
|
/// the submit accepts (like the swap quotes take `slippageBps` → `minReceivedRaw`).
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub slippage_bps: u32,
|
2026-08-08 22:33:25 +02:00
|
|
|
pub pool_data: String,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Builds the `AddLiquidity` submission — the add counterpart of `CreatePoolPlanRequest`.
|
|
|
|
|
/// `min_lp_raw` is the caller's slippage floor on the LP minted (the guest's
|
|
|
|
|
/// `min_amount_liquidity`, applied at submit like the swap plans' `min_out`); `pool_data`
|
|
|
|
|
/// supplies the stored vault / LP-definition ids the guest asserts against.
|
|
|
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq)]
|
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
|
pub struct AddLiquidityPlanRequest {
|
|
|
|
|
/// Resolved by the module from `AMM_PROGRAM_BIN` (like every id-deriving op).
|
|
|
|
|
pub amm_program_id: String,
|
|
|
|
|
/// AMM config account read — decoded by `derive_pair` for the `twap_oracle_program_id`
|
|
|
|
|
/// the `current_tick` PDA depends on (same as the swap / create plan requests).
|
|
|
|
|
pub config: AccountRead,
|
|
|
|
|
pub token_a_id: String,
|
|
|
|
|
pub token_b_id: String,
|
|
|
|
|
pub max_amount_a_raw: String,
|
|
|
|
|
pub max_amount_b_raw: String,
|
|
|
|
|
pub min_lp_raw: String,
|
|
|
|
|
pub deadline_ms: String,
|
|
|
|
|
pub user_holding_a_id: String,
|
|
|
|
|
pub user_holding_b_id: String,
|
|
|
|
|
pub user_holding_lp_id: String,
|
|
|
|
|
pub pool_data: String,
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-10 17:58:45 +02:00
|
|
|
/// Prices burning `lp_amount_raw` of an existing pool's LP. `slippage_bps` sets the
|
|
|
|
|
/// `minimumAmount*Raw` floors the submit enforces (the guest requires both nonzero and
|
|
|
|
|
/// `withdraw >= min`). `pool_data` is the hex Borsh `PoolDefinition` (empty ⇒ no pool).
|
|
|
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq)]
|
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
|
pub struct RemoveLiquidityQuoteRequest {
|
|
|
|
|
pub token_a_id: String,
|
|
|
|
|
pub token_b_id: String,
|
|
|
|
|
pub lp_amount_raw: String,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub slippage_bps: u32,
|
|
|
|
|
pub pool_data: String,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Builds the `RemoveLiquidity` submission — the remove counterpart of
|
|
|
|
|
/// `AddLiquidityPlanRequest`. `min_amount_*_raw` are the caller's slippage floors on the
|
|
|
|
|
/// tokens withdrawn (the guest's `min_amount_to_remove_token_*`, both applied at submit and
|
|
|
|
|
/// required nonzero); `pool_data` supplies the stored vault / LP-definition ids the guest
|
|
|
|
|
/// asserts against. Unlike add/create there is no fresh holding — the caller's existing LP
|
|
|
|
|
/// holding is burned and the existing token a/b holdings receive the withdrawal.
|
|
|
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq)]
|
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
|
pub struct RemoveLiquidityPlanRequest {
|
|
|
|
|
/// Resolved by the module from `AMM_PROGRAM_BIN` (like every id-deriving op).
|
|
|
|
|
pub amm_program_id: String,
|
|
|
|
|
/// AMM config account read — decoded by `derive_pair` for the `twap_oracle_program_id`
|
|
|
|
|
/// the `current_tick` PDA depends on (same as the swap / add plan requests).
|
|
|
|
|
pub config: AccountRead,
|
|
|
|
|
pub token_a_id: String,
|
|
|
|
|
pub token_b_id: String,
|
|
|
|
|
pub lp_amount_raw: String,
|
|
|
|
|
pub min_amount_a_raw: String,
|
|
|
|
|
pub min_amount_b_raw: String,
|
|
|
|
|
pub deadline_ms: String,
|
|
|
|
|
pub user_holding_a_id: String,
|
|
|
|
|
pub user_holding_b_id: String,
|
|
|
|
|
pub user_holding_lp_id: String,
|
|
|
|
|
pub pool_data: String,
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-10 22:36:45 +02:00
|
|
|
/// Builds the `SyncReserves` submission — a permissionless keeper op refreshing the pool's
|
|
|
|
|
/// stored reserves to the live vault balances (and its TWAP tick). No amounts / deadline /
|
|
|
|
|
/// holdings: it is a unit instruction over pool-derived accounts. `pool_data` supplies the
|
|
|
|
|
/// stored vault ids the guest asserts against.
|
|
|
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq)]
|
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
|
pub struct SyncReservesPlanRequest {
|
|
|
|
|
/// Resolved by the module from `AMM_PROGRAM_BIN` (like every id-deriving op).
|
|
|
|
|
pub amm_program_id: String,
|
|
|
|
|
/// AMM config account read — decoded by `derive_pair` for the `twap_oracle_program_id`
|
|
|
|
|
/// the `current_tick` PDA depends on (same as the swap / liquidity plan requests).
|
|
|
|
|
pub config: AccountRead,
|
|
|
|
|
pub token_a_id: String,
|
|
|
|
|
pub token_b_id: String,
|
|
|
|
|
pub pool_data: String,
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-08 14:44:41 +02:00
|
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq)]
|
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
|
pub struct TokenHoldingsRequest {
|
|
|
|
|
pub amm_program_id: String,
|
|
|
|
|
/// AMM config account read — decoded for the `token_program_id` that identifies
|
|
|
|
|
/// which wallet accounts are token holdings.
|
|
|
|
|
pub config: AccountRead,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub wallet_accounts: Vec<AccountRead>,
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-27 16:01:37 +02:00
|
|
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq)]
|
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
|
pub struct ProgramIdRequest {
|
|
|
|
|
pub elf: String,
|
|
|
|
|
}
|