feat(amm): expose supported fee tiers via feeTiers() op

The liquidity form's fee-tier selector was fed from the module's
newPositionContext, which hardcoded an empty list — leaving the selector
blank. Source the tiers from the program instead so the UI can never
drift from what the guest accepts.

Add amm_core::SUPPORTED_FEE_TIERS: the canonical ascending list of raw
bps ([1, 5, 30, 100]), built from the existing FEE_TIER_BPS_* constants.
is_supported_fee_tier's match is left unchanged and the new const is
unused on-chain, so the guest ImageID is unaffected; a drift-guard test
locks the list to the check (every entry accepted, neighbours rejected,
ascending/deduped).

Wire it through the stack:
- FFI: amm_fee_tiers op reading SUPPORTED_FEE_TIERS -> { feeTiers: [...] }
  (empty FeeTiersRequest, cbindgen header regenerated).
- Module: LogosList feeTiers() unwrapping the list, like tokenHoldings.
- Backend: QVariantList feeTiers() QtRO slot forwarding to the module.
- QML: LiquidityPage fetches backend.feeTiers() once (wallet-independent)
  and injects it into NewPositionForm, which wraps each int into a
  { feeBps } row for the existing delegate. Drop the now-dead feeTiers
  key from the flow's loadingContext().
This commit is contained in:
r4bbit
2026-08-13 14:22:11 +02:00
parent 4cfc03a815
commit cb1b457ad3
15 changed files with 169 additions and 21 deletions
+14
View File
@@ -1314,6 +1314,20 @@ LogosList AmmModuleImpl::tokenHoldings(bool wallet_open) {
return out;
}
LogosList AmmModuleImpl::feeTiers() {
// Pure enumeration of amm_core::SUPPORTED_FEE_TIERS — no program id, config,
// or wallet read needed. The FFI wraps the list as { feeTiers: [...] }.
const FfiResult result = call(amm_fee_tiers, json::object());
if (!result.ok)
return LogosList::array();
LogosList out = LogosList::array();
const auto it = result.value.find("feeTiers");
if (it != result.value.end() && it->is_array())
for (const auto& tier : *it) out.push_back(tier);
return out;
}
LogosMap AmmModuleImpl::newPositionContext(const LogosMap& request,
bool wallet_open,
bool refresh_wallet_accounts) {