tempo_node/rpc/amm/mod.rs
1use crate::rpc::amm::pools::PoolsResponse;
2use jsonrpsee::{core::RpcResult, proc_macros::rpc};
3use reth_node_core::rpc::result::internal_rpc_err;
4use reth_rpc_eth_api::RpcNodeCore;
5use tempo_alloy::rpc::pagination::PaginationParams;
6
7pub mod pools;
8pub use pools::{Pool, PoolsFilters};
9
10#[rpc(server, namespace = "amm")]
11pub trait TempoAmmApi {
12 /// Gets paginated liquidity pools from the Fee AMM on Tempo.
13 ///
14 /// Each pool is directional (userToken → validatorToken) with fixed swap rates for fee swaps (0.997) and rebalance swaps (0.9985).
15 ///
16 /// Uses cursor-based pagination for stable iteration through pools.
17 #[method(name = "getLiquidityPools")]
18 async fn pools(&self, params: PaginationParams<PoolsFilters>) -> RpcResult<PoolsResponse>;
19}
20
21/// The JSON-RPC handlers for the `amm_` namespace.
22#[derive(Debug, Clone, Default)]
23pub struct TempoAmm<EthApi> {
24 eth_api: EthApi,
25}
26
27impl<EthApi> TempoAmm<EthApi> {
28 pub fn new(eth_api: EthApi) -> Self {
29 Self { eth_api }
30 }
31}
32
33#[async_trait::async_trait]
34impl<EthApi: RpcNodeCore> TempoAmmApiServer for TempoAmm<EthApi> {
35 async fn pools(&self, _params: PaginationParams<PoolsFilters>) -> RpcResult<PoolsResponse> {
36 Err(internal_rpc_err("unimplemented"))
37 }
38}
39
40impl<EthApi: RpcNodeCore> TempoAmm<EthApi> {
41 /// Access the underlying provider.
42 pub fn provider(&self) -> &EthApi::Provider {
43 self.eth_api.provider()
44 }
45}