feat(amm): add configAccount read (decode the singleton config)

Expose the AMM config account as a read op, so a future config/admin view can show
the authority and the token/twap program ids the AMM chains into.
This commit is contained in:
r4bbit
2026-08-13 21:30:14 +02:00
parent 92f55652a8
commit 56c80ce29d
13 changed files with 135 additions and 16 deletions
+19
View File
@@ -401,6 +401,25 @@ LogosMap AmmModuleImpl::resolvePoolAccount(const std::string& def_a_hex,
return resolved;
}
LogosMap AmmModuleImpl::configAccount() {
const std::string amm_program_id = ammProgramId();
if (amm_program_id.empty())
return LogosMap{{"status", "error"}, {"error", "config_missing"}};
const json config = readConfig(amm_program_id);
if (config.is_null())
return LogosMap{{"status", "error"}, {"error", "backend_error"}};
const FfiResult result = call(amm_config_account, json{
{"ammProgramId", amm_program_id},
{"config", config},
});
if (!result.ok)
return LogosMap{{"status", "error"},
{"error", result.error.empty() ? "backend_error" : result.error}};
return result.value;
}
LogosMap AmmModuleImpl::swapExactInQuote(const std::string& token_in_hex,
const std::string& token_out_hex,
const nlohmann::json& amount_in,