refactor(apps/amm): move the amm_client crate into modules/amm/ffi as amm_ffi

After the amm_module refactor, this crate is linked only by the module (the
UI delegates to modules().amm_module and links nothing), so its home under
apps/amm/ and the name "client" were both misnomers: it's the AMM business
logic the module wraps, reached across an FFI boundary — the same relationship
logos_execution_zone has with wallet_ffi. Co-locate it with the module that
owns it and name it for that role.

The FFI surface is unchanged — the exported functions are already amm_* (not
amm_client_*) — so only the crate, directory, generated header, dylib, and
package names move. The module's call sites are untouched; it just includes the
renamed header.

- apps/amm/client → modules/amm/ffi (git-tracked rename; history preserved)
- crate amm_client → amm_ffi: package name, include/amm_ffi.h, libamm_ffi.dylib,
  AMM_FFI_H guard, build.rs output path, tests/public_api.rs import
- workspace member path + Cargo.lock
- flake.nix: pname, -p, header-copy path, dylib install_name, packages.amm_ffi,
  ammModuleOutputs externalLibInputs, DYLD wrapper
- modules/amm: metadata external_libraries, CMakeLists EXTERNAL_LIBS, impl
  #include + comments, README, flake note
- apps/amm/flake.nix: drop the now-dead amm_client external-lib input (the UI
  links no external lib of its own)

Resulting layout:
  modules/amm/
    src/   # C++ module  (amm_module_impl.{h,cpp})
    ffi/   # Rust crate  amm_ffi  (Cargo.toml, src/, include/amm_ffi.h)
This commit is contained in:
r4bbit
2026-08-03 23:11:06 +02:00
parent afeba568d8
commit f5ff9b829f
38 changed files with 83 additions and 94 deletions
+50
View File
@@ -0,0 +1,50 @@
use borsh::BorshSerialize;
#[derive(BorshSerialize)]
pub(super) enum RequestCommitment {
Missing {
amount_a: u128,
amount_b: u128,
},
Active {
max_a: u128,
max_b: u128,
slippage_bps: u32,
},
}
#[derive(BorshSerialize)]
pub(super) struct SourceCommitment {
pub(super) role: String,
pub(super) commitment: [u8; 32],
}
#[derive(BorshSerialize)]
pub(super) struct FundingCommitment {
pub(super) token_id: [u8; 32],
pub(super) holding_id: Option<[u8; 32]>,
pub(super) available: u128,
pub(super) requested: u128,
}
#[derive(BorshSerialize)]
pub(super) struct QuoteCommitment {
pub(super) network_id: String,
pub(super) network_fingerprint: String,
pub(super) amm_program_id: [u8; 32],
pub(super) token_a_id: [u8; 32],
pub(super) token_b_id: [u8; 32],
pub(super) fee_bps: u32,
pub(super) pool_status: u8,
pub(super) request: RequestCommitment,
pub(super) max_a: u128,
pub(super) max_b: u128,
pub(super) actual_a: u128,
pub(super) actual_b: u128,
pub(super) expected_lp: u128,
pub(super) lp_guard: u128,
pub(super) requires_fresh_lp: bool,
pub(super) sources: Vec<SourceCommitment>,
pub(super) funding: Vec<FundingCommitment>,
pub(super) warnings: Vec<String>,
}