mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-08-25 06:01:11 +00:00
Introduce the add-liquidity vertical mirroring the swap + createPool patterns,
for depositing into an existing pool via the AddLiquidity instruction.
FFI (amm_ffi):
- add_liquidity_quote — decode poolData, orient the caller's max amounts to the
pool's canonical order, run the guest's exact ideal->actual->delta_lp math, and
return { amountARaw, amountBRaw, expectedLpRaw, priceRaw } in display order.
Slippage-free like create's quote; the min-LP floor is applied at submit.
- add_liquidity_plan — canonicalize (token, max-amount, holding) as one unit,
take vaults + LP definition from poolData, emit the 10-account AddLiquidity
order (only the user holdings a/b/LP sign). Takes minLpRaw directly, like
swap_exact_in_plan takes min_out.
Shared with createPool: extract canonical_triples (the pair/amount/holding
canonical swap) and plan_response (the tx-submission envelope); both the create
and add plans now use them.
68 lines
1.5 KiB
C
68 lines
1.5 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_add_liquidity_quote(const char *request_json);
|
|
|
|
char *amm_add_liquidity_plan(const char *request_json);
|
|
|
|
char *amm_token_holdings(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 */
|