Expand description
Async Rust client for the Fyuz public REST API.
Fyuz is a bonding-curve token launchpad on BNB Smart Chain. A new token trades on an internal bonding curve until it reaches a $30,000 market cap, at which point it graduates into a PancakeSwap V2 pair.
Before graduation there is no DEX pool anywhere. pair_address is
None, no on-chain pair exists to quote, and this API is the only source
of price, liquidity and volume data for that token. Anything you build that
reads pre-graduation prices from a DEX aggregator will simply find nothing.
Every endpoint in this crate is unauthenticated and safe to poll.
§Quickstart
use fyuz::{DiscoverParams, DiscoverTab, FyuzClient};
#[tokio::main]
async fn main() -> Result<(), fyuz::Error> {
let client = FyuzClient::new()?;
let trending = client
.discover(&DiscoverParams::new().tab(DiscoverTab::Trending).limit(10))
.await?;
for token in &trending {
println!(
"{:<10} ${:>12.0} mcap {:>6.2}% to graduation",
token.symbol, token.marketcap, token.graduation_pct
);
}
Ok(())
}§Decimal strings, and why they are not floats
Token balances, prices, market caps and every *_wei field come back as
decimal strings and stay String in this crate’s models. An 18-decimal
token amount, or a uint256 wei total, does not survive a round trip through
f64:
let wire = "123456789012345678901234567890";
// What a "just parse it as a number" client would do:
let lossy = wire.parse::<f64>().unwrap();
assert_ne!(format!("{lossy:.0}"), wire); // silently wrongIf you need arithmetic, parse into a big-integer or decimal type of your
choosing (rust_decimal, bigdecimal, primitive_types::U256, …) at the
edge of your own code. The SDK deliberately does not pick one for you, and
deliberately never parses these into f64 on your behalf.
Aggregates that the server already computed in floating point — volume_usd,
points, reward_eth, pot_bnb, PnL figures — arrive as JSON numbers and
are modelled as f64.
Timestamps get the same treatment for the same reason, one step further: the
RFC-3339 created_at/updated_at strings and the unix-second date and
round_end fields stay as they arrived. There is no date type in core, and
picking chrono or time for you would put a dependency — and a major
version of it — into every downstream build to save one parse call. This is
the one helper the TypeScript, Go and Python SDKs have that this one
deliberately does not.
§Where Fyuz is deployed
addresses carries the deployed proxy addresses as compile-time constants,
looked up by chain id or slug:
let bsc = fyuz::deployment_for_chain_id(56).expect("mainnet is in the book");
assert_eq!(bsc.fyuz, "0x33a98bef6496684a8dac83734d9ceb0cefc7019c");GET /config still wins wherever it answers — the launchpad is behind an
upgradeable proxy, and a published crate that trusted its own copy would keep
calling a dead address after a redeploy. The book is what covers the cases the
API cannot: BSC testnet, which the public API does not serve at all, and a
/config response that arrives without a contractAddress.
§None is not 0
Pot::pot_bnb,
Claimable::claimable_wei,
TokenDetail::curve_holding and the
nullable *_wei fields on RoundReceipt are None
when the value is unknown — the RPC was unreachable, or the settlement is
not indexed yet. Rendering 0 in that case tells a user something false.
§Rate limits and retries
The API allows 120 requests per minute per IP and answers 429 with
{"error": "Too many requests"} past that. The client retries 429s, 5xxs
and transport failures automatically with exponential backoff and full
jitter, honouring Retry-After when the server sends one. Other 4xx
statuses are never retried. Three retries is the default:
use std::time::Duration;
let client = fyuz::FyuzClient::builder()
.timeout(Duration::from_secs(10))
.max_retries(5)
.user_agent("acme-indexer/2.1 (ops@acme.example)")
.build()?;Once the retries are spent the call fails with Error::RateLimited, which
is a distinct variant precisely so a backpressure handler can match on it.
§What is not here
Only the public, unauthenticated surface is implemented. The API-key-gated
routes (recording a distribution round, posting chats, watchlists, paper
trading, airdrops, …) are deliberately absent — including POST /distributor/rounds, which shares a path with
Distributor::list_rounds but is not a public endpoint.
Re-exports§
pub use addresses::deployment_for_chain_id;pub use addresses::deployment_for_network;pub use addresses::Deployment;pub use addresses::BSC;pub use addresses::BSC_TESTNET;pub use addresses::DEPLOYMENTS;pub use models::*;
Modules§
- addresses
- Where Fyuz is deployed, as compile-time constants.
- models
- Response types for every endpoint of the Fyuz public API.
Structs§
- Built
Buy - A built buy with the quote it was priced from.
- Built
Sell - A built sell with the quote it was priced from.
- BuyExact
Tokens Params - Buy an exact number of tokens, capping the spend.
- BuyParams
- Spend an exact amount of native currency on a token.
- BuyQuote
- What a buy will cost and return, priced against current curve state.
- Chart
Data Params - Arguments for
FyuzClient::get_chart_data. - Discover
Params - Filters for
FyuzClient::discover. - Distributor
- The Distributor endpoints, reached with
FyuzClient::distributor. - Fyuz
Client - Async client for the Fyuz public REST API.
- Fyuz
Client Builder - Builder for
FyuzClient. Created withFyuzClient::builder. - List
Tokens Params - Filters, sorting and paging for
FyuzClient::list_tokens. - Recent
Trades Params - Incremental polling cursor for
FyuzClient::get_recent_trades. - Rounds
Params - Paging for
Distributor::list_rounds. - RpcClient
- Minimal JSON-RPC transport.
- Sell
Params - Sell tokens for native currency.
- Sell
Quote - What a sell will return, priced against current curve state.
- Shares
Params - Window and size for
Distributor::get_shares. - Token
Detail Params - Paging of the trade list embedded in
FyuzClient::get_token. - Token
Pager - Walks every page of
GET /tokens, one request at a time. - Token
Trades Params - Paging for
FyuzClient::get_token_trades. - TopHolders
Params - Window and chain filter for
FyuzClient::get_top_holders. - Trade
Api - Builds unsigned bonding-curve transactions. Reach it through
FyuzClient::trade. - U256
- A 256-bit unsigned integer, stored big-endian.
- Unsigned
Transaction - A transaction ready to be signed and sent.
Enums§
- Call
Outcome - The outcome of an
eth_call: return data, or revert data. - Discover
Tab - Preset ordering for the discovery feed.
- Error
- Anything that can go wrong talking to the Fyuz API.
- Revert
Kind - How a contract revert was classified.
- Sort
Direction - Sort direction for
ListTokensParams::order_flag. - Token
Status - Bonding-curve lifecycle filter.
Constants§
- DEFAULT_
BASE_ URL - Production base URL, used unless
FyuzClientBuilder::base_urloverrides it. - DEFAULT_
BLOCK_ TAG - Default block tag every
eth_callis evaluated against. - DEFAULT_
DEADLINE_ SECONDS - How long a built transaction stays valid when the caller does not say.
- DEFAULT_
NETWORK - Chain slug used when a call does not name one.
- DEFAULT_
RPC_ TIMEOUT - Default per-call timeout for RPC requests.
- MAX_
DEADLINE_ SECONDS - Longest relative deadline this crate will accept, in seconds.
- MAX_
RESPONSE_ BYTES - Ceiling on any single response body this crate buffers, in bytes.
- SELECTOR_
ALLOWANCE allowance(address,address)- SELECTOR_
ALREADY_ LAUNCHED AlreadyLaunched()— the graduated-token revert.- SELECTOR_
APPROVE approve(address,uint256)- SELECTOR_
BALANCE_ OF balanceOf(address)- SELECTOR_
GET_ FIRST_ BUY_ FEE getFirstBuyFee(address)- SELECTOR_
GET_ MAX_ SELLABLE_ ETH getMaxSellableETH(address)- SELECTOR_
GET_ SWAP_ OUTPUT getSwapOutput(address,uint256,bool)- SELECTOR_
PAUSED paused()- SELECTOR_
PLATFORM_ BUY_ FEE_ BPS PLATFORM_BUY_FEE_BPS()— public storage with an owner setter (setPlatformBuyFeeBps), so it is read rather than assumed.- SELECTOR_
SWAP_ ETH_ FOR_ EXACT_ TOKENS swapETHForExactTokens(address,uint256,uint256,uint256)- SELECTOR_
SWAP_ EXACT_ ETH_ FOR_ TOKENS swapExactETHForTokens(address,uint256,uint256,uint256)- SELECTOR_
SWAP_ EXACT_ TOKENS_ FOR_ ETH swapExactTokensForETH(address,uint256,uint256,uint256)- SELECTOR_
TOKEN_ OWNER_ FEE_ BPS TOKEN_OWNER_FEE_BPS()— likewise owner-settable.- SELECTOR_
TOKEN_ POOLS tokenPools(address)- VERSION
- Version of this crate, as reported in the
User-Agent.
Functions§
- address_
word - An
addressas one 64-character word: 12 zero bytes then the 20 address bytes. - bool_
word - A
boolas one 64-character word. - decode_
address_ at - Read the
index-th word as anaddress, lower-cased. - decode_
bool_ at - Read the
index-th word as abool. Any non-zero word istrue. - decode_
uint256_ at - Read the
index-th 32-byte word of a return payload as auint256. - encode_
call - Selector plus words, as
0x-prefixed calldata. - format_
units - The smallest unit back to whole units, exactly. Inverse of
parse_units. - normalize_
address - Validate an EVM address and return it lower-cased.
- parse_
units - Whole units to the smallest unit —
"0.5"BNB to500000000000000000wei. - revert_
error - Classify revert data into a typed
Error::ContractRevert. - revert_
selector - The first four bytes of some revert data, lower-cased, or
None. - uint256_
word - A
uint256as one 64-character word.
Type Aliases§
- Result
- Convenience alias: every fallible call in this crate returns this.