mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-08-25 22:21:16 +00:00
The AMM host FFI was split across two crates with two ABI styles: the typed-C `amm_client_ffi` (swap primitives, under programs/) and the JSON/wire `amm_client` (new-position flow, under apps/). Fold both into a single `amm_client` crate exposing one JSON C ABI, and delete `programs/amm/client-ffi`. Rust: - Re-express the swap path as `api/swap.rs` operations on the existing `call::<T>` dispatch — swap_pair, resolve_pool, swap_plan, program_id — reusing `pair::derive_pair` (no more duplicated PDA derivation) and `risc0_zkvm::serde` for the SwapExactInput words (the same encoding the guest decodes). The account list and signer flags stay byte-identical to the old typed path. - Generate a single header (`include/amm_client.h`) covering all ops via cbindgen; bump cbindgen 0.27 -> 0.28 for `#[unsafe(no_mangle)]` support. C++: - Extend the `AmmClient` wrapper with the four swap ops. - Add `SwapRuntime` (mirrors `NewPositionRuntime`): reads accounts through the wallet, drives the swap ops, submits the transaction. - `AmmUiBackend` swap methods now delegate to `SwapRuntime`, dropping ~390 lines of typed-FFI and byte-twiddling. `program_id` becomes a JSON op, and the swap clock is derived via `derive_pair` (clock_core::CLOCK_01) instead of a hardcoded base58 literal — same account, verified.
50 lines
990 B
C
50 lines
990 B
C
#ifndef AMM_CLIENT_H
|
|
#define AMM_CLIENT_H
|
|
|
|
#pragma once
|
|
|
|
/* Generated by cbindgen. Do not edit. */
|
|
|
|
#include <stdarg.h>
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif // __cplusplus
|
|
|
|
char *amm_config_id(const char *request_json);
|
|
|
|
char *amm_token_ids(const char *request_json);
|
|
|
|
char *amm_pair_ids(const char *request_json);
|
|
|
|
char *amm_context(const char *request_json);
|
|
|
|
char *amm_quote(const char *request_json);
|
|
|
|
char *amm_plan(const char *request_json);
|
|
|
|
char *amm_swap_pair(const char *request_json);
|
|
|
|
char *amm_resolve_pool(const char *request_json);
|
|
|
|
char *amm_swap_plan(const char *request_json);
|
|
|
|
char *amm_program_id(const char *request_json);
|
|
|
|
/**
|
|
* Releases a string returned by an `amm_*` operation.
|
|
*
|
|
* # Safety
|
|
* `value` must be null or a pointer returned by this library that has not been freed.
|
|
*/
|
|
void amm_free(char *value);
|
|
|
|
#ifdef __cplusplus
|
|
} // extern "C"
|
|
#endif // __cplusplus
|
|
|
|
#endif /* AMM_CLIENT_H */
|