mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-08-25 22:21:16 +00:00
The `*Raw` suffix on the module's amount/price/balance/LP fields was
redundant — every such field is already a base-unit integer, and there was
no formatted sibling to disambiguate from. Drop it across the whole wire
contract in lockstep: the amm_ffi request/response fields (snake_case
`amount_in_raw` → `amount_in`, serde `rename_all="camelCase"` keeps the JSON
keys mapped), the C++ module API, the QtRO `.rep`, the QML/app that consumes
it, the mjs tests, and the module README.
Examples: expectedOutRaw→expectedOut, minReceivedRaw→minReceived,
maxInRaw→maxIn, requiredInRaw→requiredIn, priceRaw→price, reserve{A,B}Raw→
reserve{A,B}, amount{In,Out}Raw→amount{In,Out}, expectedLpRaw→expectedLp,
lpAmountRaw→lpAmount, {max,min,minimum,actual}Amount{A,B}Raw, minimumLpRaw,
minLpRaw, selectedBalance*Raw, totalSupplyRaw, quote*Raw. This also unifies a
pre-existing inconsistency where resolvePoolAccount already emitted `reserveA`
and resolveTokens already emitted `balance`.
Kept where a formatted UI sibling of the same base name exists, so `Raw`
still disambiguates the base-unit value: amountARaw / amountBRaw (vs the
user-input `amountA`/`amountB`), balanceRaw (vs display `balance`), and
initialPriceRaw (vs formatted `initialPrice`). Also kept the format-boundary
helpers formatRaw / rawLpText / probeRaw / displayRaw / displayQuoteRaw /
boundRaw.
BREAKING: the `amm_module` public API field names change (logoscore /
Basecamp / QtRO consumers must update).
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: None, // amounts supplied ⇒ the op derives the price
|
|
amount_a: Some("1000000".into()),
|
|
amount_b: Some("4000000".into()),
|
|
})
|
|
.expect("a valid pure create-pool quote should succeed");
|
|
assert_eq!(quote["actualAmountA"], "1000000");
|
|
|
|
let _plan: fn(CreatePoolPlanRequest) -> AmmResult = create_pool_plan;
|
|
}
|