Skip to main content

perpcity_sdk/
lib.rs

1//! # PerpCity Rust SDK
2//!
3//! A Rust SDK for the [PerpCity](https://perpcity.com) perpetual futures
4//! protocol on Base L2.
5//!
6//! ## Module overview
7//!
8//! | Module | Purpose |
9//! |---|---|
10//! | [`constants`] | Protocol constants mirrored from on-chain `Constants.sol` |
11//! | [`contracts`] | ABI bindings via Alloy `sol!` — structs, events, errors, functions |
12//! | [`convert`] | Conversions between client f64 values and on-chain representations |
13//! | [`errors`] | SDK-wide error types using `thiserror` |
14//! | [`hft`] | HFT infrastructure: nonce, gas, pipeline, state cache, latency, positions |
15//! | [`math`] | Pure math: tick ↔ price, liquidity estimation, position calculations |
16//! | [`transport`] | Multi-endpoint RPC transport with health-aware routing |
17//! | [`types`] | Client-facing types with human-readable f64 fields |
18//!
19//! ## Quick start
20//!
21//! ```rust,no_run
22//! use perpcity_sdk::{
23//!     PerpClient, HftTransport, TransportConfig, Urgency,
24//!     Deployments, OpenTakerParams, OpenMakerParams,
25//!     PerpCityError, Result,
26//! };
27//! use alloy::signers::local::PrivateKeySigner;
28//! ```
29
30#![deny(unreachable_pub)]
31#![warn(missing_debug_implementations, rust_2018_idioms)]
32
33pub mod client;
34pub mod constants;
35pub mod contracts;
36pub mod convert;
37pub mod errors;
38pub mod hft;
39pub mod math;
40pub mod transport;
41pub mod types;
42
43#[doc(inline)]
44pub use client::PerpClient;
45
46#[doc(inline)]
47pub use contracts::{IERC20, IFees, IMarginRatios, PerpManager, PoolKey, SwapConfig};
48
49#[doc(inline)]
50pub use errors::{PerpCityError, Result};
51
52#[doc(inline)]
53pub use hft::gas::{GasLimits, Urgency};
54
55#[doc(inline)]
56pub use transport::{config::TransportConfig, provider::HftTransport};
57
58#[doc(inline)]
59pub use types::{
60    Bounds, CloseParams, CloseResult, Deployments, Fees, LiveDetails, OpenInterest,
61    OpenMakerParams, OpenTakerParams, PerpData,
62};