Files
lez-programs/modules/amm/ffi/include/amm_ffi.h
r4bbit b610c64871 feat(modules/amm): add createPool quote + plan ops and module methods
Bring pool creation onto the redesigned lean module surface
  mirroring the shipped swap vertical.

  FFI (amm_ffi):
  - amm_liquidity_quote: a pure create-pool preview from the two deposit
    amounts — expectedLpRaw / initialPriceRaw / lockedLpRaw via the shared
    amm_core opening-LP math (isqrt_product, MINIMUM_LIQUIDITY,
    spot_price_q64_64), so the preview equals what new_definition mints. No
    chain reads, no quoteHash, and no fee input (the fee is neither part of the
    pool PDA nor the pricing — one pool per pair).
  - amm_create_pool_plan: canonicalizes the pair, moving amounts and user
    holdings as one unit so each (vault, holding, amount) triple names the same
    token, then emits the fixed 11-account NewDefinition plan (only the user
    a/b and fresh LP holdings sign).

  Module (AmmModuleImpl):
  - liquidityQuote(request): thin preview wrapper, normalizes ids to hex.
  - createPool(request, fresh_lp_id): a new pool always needs a fresh LP
    holding, so an empty fresh_lp_id returns requiresFreshLp without
    submitting; otherwise builds the plan and submits, returning a hex
    transactionId.
2026-08-11 09:58:58 +02:00

62 lines
1.3 KiB
C

#ifndef AMM_FFI_H
#define AMM_FFI_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_pool_id(const char *request_json);
char *amm_swap_exact_in_quote(const char *request_json);
char *amm_swap_exact_out_quote(const char *request_json);
char *amm_swap_exact_in_plan(const char *request_json);
char *amm_swap_exact_out_plan(const char *request_json);
char *amm_liquidity_quote(const char *request_json);
char *amm_create_pool_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_FFI_H */