mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-08-25 14:11:09 +00:00
Two naming cleanups on the create-pool quote, aligning it with the add / remove counterparts (per modules/amm/INTERFACE.md). Pure renames — no behavior change. - `liquidityQuote` → `createPoolQuote` across the stack: the FFI op (`liquidity_quote` → `create_pool_quote`, `LiquidityQuoteRequest` → `CreatePoolQuoteRequest`, `amm_liquidity_quote` → `amm_create_pool_quote`, cbindgen header regenerated), the module method, the AmmUiBackend slot, and the QML call site. It really is the create-pool quote — `addLiquidityQuote` / `removeLiquidityQuote` are the other branches — so the old name misled. - `initialPriceRealRaw` → `priceRaw` (request field `initial_price_real_raw` → `price_raw`): drops the legacy "Real" and unifies the price key with the add / remove quotes, which already return `priceRaw`. Create, add, and remove quotes now all speak `priceRaw`; the create-vs-add routing in NewPositionFlow keys on `request.priceRaw`.
34 lines
1.3 KiB
Rust
34 lines
1.3 KiB
Rust
use amm_ffi::{
|
|
config_id, create_pool_plan, create_pool_quote, AmmResult, ConfigIdRequest,
|
|
CreatePoolPlanRequest, CreatePoolQuoteRequest,
|
|
};
|
|
|
|
#[test]
|
|
fn direct_rust_api_does_not_require_ffi() {
|
|
let response = config_id(ConfigIdRequest {
|
|
amm_program_id: "0000000000000000000000000000000000000000000000000000000000000000".into(),
|
|
})
|
|
.expect("valid program ID should produce a response");
|
|
|
|
assert_eq!(response["status"], "ok");
|
|
assert!(response["configId"].is_string());
|
|
}
|
|
|
|
// The create-pool surface must be reachable from the crate root too — Rust callers import from
|
|
// `amm_ffi::`, not `amm_ffi::api`. create_pool_quote is a pure preview, so exercise it directly;
|
|
// create_pool_plan needs chain reads, so a typed reference is enough to pin the re-export.
|
|
#[test]
|
|
fn create_pool_surface_is_reexported_from_crate_root() {
|
|
let quote = create_pool_quote(CreatePoolQuoteRequest {
|
|
token_a_id: "11".repeat(32),
|
|
token_b_id: "22".repeat(32),
|
|
price_raw: None, // amounts supplied ⇒ the op derives the price
|
|
amount_a_raw: Some("1000000".into()),
|
|
amount_b_raw: Some("4000000".into()),
|
|
})
|
|
.expect("a valid pure create-pool quote should succeed");
|
|
assert_eq!(quote["actualAmountARaw"], "1000000");
|
|
|
|
let _plan: fn(CreatePoolPlanRequest) -> AmmResult = create_pool_plan;
|
|
}
|