mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-08-25 22:21:16 +00:00
Server-side SwapExactOutput submission, mirroring the exact-in path. The
swap_exact_out_plan FFI op resolves the pool via the shared derive_pair,
encodes amm_core::Instruction::SwapExactOutput { exact_amount_out,
max_amount_in, deadline }, and returns the same four tx-submission fields as
swap_exact_in_plan (programId, accountIds, signingRequirements, instruction)
in the identical fixed 8-account IDL order — only the user's input holding
signs. Recoverable domain failures (same_token_pair, config_unavailable) go
through the FFI envelope as Err. C export amm_swap_exact_out_plan (cbindgen
header regenerated).
The module swapExactOutput(defA, defB, userIn, userOut, amountOut, maxIn,
deadline) method reads the AMM config, calls the op, and submits the plan via
send_generic_public_transaction, returning the tx hash (empty string on
failure). Same argument conventions and I/O-free split as swapExactInput.
Not yet wired into AmmUiBackend/QML — the SwapCard rewire is a follow-up. The
existing swap UI path is untouched, so nothing breaks.
58 lines
1.2 KiB
C
58 lines
1.2 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_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 */
|