mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-08-25 06:01:11 +00:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user