Skip to main content

Crate dedust_api_client

Crate dedust_api_client 

Source
Expand description

§dedust_api_client

Thin typed wrapper for the DeDust asset registry, API v4 pool discovery endpoints, and legacy API v2.

Use this crate when an application needs raw typed access to DeDust asset metadata, pool discovery/configuration, pool trades, or routing plans. The crate does not join asset metadata into pools, load on-chain pool state, choose routes, calculate slippage, execute swaps, or normalize DeDust data into a shared DEX domain model.

§Usage

[dependencies]
dedust_api_client = "0.7"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }

The minimum supported Rust version (MSRV) is 1.88.

Run requests inside an async Tokio runtime. Match response enums with a wildcard arm because they are non-exhaustive.

use dedust_api_client::api_client::DedustApiClient;
use dedust_api_client::assets::{AssetsRequest, AssetsResponse};
use dedust_api_client::v4::{PoolsParams, V4Request, V4Response};

let client = DedustApiClient::builder().build()?;

let assets_response = client.assets.exec(AssetsRequest::List).await?;
match assets_response {
    AssetsResponse::List(assets) => println!("assets: {}", assets.len()),
    _ => println!("unexpected DeDust asset response variant"),
}

let pools_response = client.v4.exec(V4Request::AllCpmmPools).await?;
match pools_response {
    V4Response::AllCpmmPools(pools) => println!("CPMM v2 pools: {}", pools.len()),
    _ => println!("unexpected DeDust v4 response variant"),
}

let params = PoolsParams::new().with_limit(100);
let screened_page = client.v4.all_pools(&params).await?;
println!("screened pool rows: {}", screened_page.total_count);

The asset registry returns friendly TON addresses and absolute image URLs. The v4 endpoints return raw workchain:hex_hash addresses and asset strings such as native and jetton:0:<hash>. Applications own any address conversion and domain normalization.

§Asset Registry

MethodEndpointRequestResponse
GET/list.jsonAssetsRequest::ListAssetsResponse::List

The default asset-registry origin is https://assets.dedust.io.

§API v4 Pool Discovery

MethodEndpointRequestResponse
POST/get_poolsV4ApiClient::pools(&PoolsParams)One PoolsResponse page
POST/get_pools, all pagesV4ApiClient::all_pools(&PoolsParams)Aggregated PoolsResponse
GET/get_pools_allclassicV4Request::AllClassicPoolsV4Response::AllClassicPools
GET/get_pools_allstableV4Request::AllStablePoolsV4Response::AllStablePools
GET/get_pools_allcpmmV4Request::AllCpmmPoolsV4Response::AllCpmmPools
GET/get_pools_alluranusV4Request::AllUranusPoolsV4Response::AllUranusPools

The default v4 origin is https://mainnet.api.dedust.io/v4/api. POST /get_pools is the enriched screener used by the DeDust web application. It returns asset-pair rows with nested pools, TVL, volume, APR, reserves, fees, rewards, and embedded asset metadata. total_count counts grouped rows rather than nested pools, and the current upstream page limit is 100. Decimal and raw integer amounts remain strings to preserve the wire representation. PoolsParams::new() uses that 100-row limit. all_pools resets the offset to zero, loads pages sequentially using the configured limit, merges embedded asset metadata, and returns no partial response if a page fails or pagination is inconsistent.

The four get_pools_all* endpoints return much larger discovery and configuration registries without the screener’s dynamic enrichment. Uranus records identify launchpad tokens and fundraising configuration rather than ordinary two-asset pools.

POST /get_pools and the other UI operations below are observed web-application interfaces, not endpoints documented in DeDust’s public developer reference. They may change without a public API compatibility notice.

§Observed but unsupported web-application operations

The current DeDust frontend also calls these v4 endpoint groups, which this crate does not yet expose:

AreaEndpoints
Pool lookupPOST /v4/api/get_pair_pools, POST /v4/api/pools/summary, GET /v4/api/pools/{address}
Pool analyticsGET /v4/api/chart, GET /v4/api/coin_transactions
AssetsGET /v4/api/coins/{asset}/resolver
PositionsGET /v4/api/pools/{pool}/providers, GET /v4/api/pools/{pool}/liquidity_position/{wallet}
PortfolioGET /v4/api/portfolio/{wallet}, GET /v4/api/portfolio/{wallet}/earnings
RouterGET /v4/router/assets, GET /v4/router/memepads-assets, POST /v4/router/quote, POST /v4/router/swap

§Legacy API v2

The following operations remain available through client.v2 for backward compatibility. The v2 asset and pool-list endpoints are considered legacy and should not be selected for new registry integrations.

MethodSupported
/v2/accounts/{address}/assets
/v2/accounts/{address}/trades
/v2/assets✅
/v2/assets/{symbol}
/v2/coinmarketcap/markets
/v2/dns/{domain}
/v2/gcko/pairs
/v2/gcko/tickers
/v2/gcko/trades
/v2/jettons/{address}/circulating-supply
/v2/jettons/{address}/metadata
/v2/jettons/{address}/top-buys
/v2/jettons/{address}/top-traders
/v2/jettons/{address}/total-supply
/v2/pools✅
/v2/pools-lite✅
/v2/pools/{address}/metadata
/v2/pools/{address}/trades✅
/v2/prices
/v2/routing/plan✅

RoutingPlanParams::new maps the zero TON address to native and all other addresses to jetton:<address>.

Public request and response types are marked #[non_exhaustive] for SemVer headroom. Build public POD structs with Default::default().with_<field>(...) or request parameter constructors, pass request parameters directly where Into<Request> is implemented, and include a wildcard arm when matching public enums.

The existing with_api_url and with_executor builder setters configure v2. Use with_assets_url/with_assets_executor and with_v4_url/with_v4_executor to override the other origins independently.

Live API tests hit DeDust directly. Asset and pool counts, metadata, routing amounts, and ordering can drift with upstream state.

Re-exports§

pub use api_clients_core;

Modules§

api_client
Top-level DeDust client and builder.
assets
DeDust asset-registry requests, responses, and wire models.
v2
DeDust API v2 requests, responses, and wire models.
v4
DeDust API v4 pool-discovery requests, responses, and wire models.

Macros§

unwrap_assets_response
Extract the expected payload from a DeDust AssetsResponse.
unwrap_response
unwrap_v4_response
Extract the expected payload from a DeDust V4Response.