Smart Contract Integration
TypeScript SDK
Auto-generated TypeScript bindings from Foundry contract artifacts via the wagmi CLI. Install@nile-markets/sdk to access pure ABI objects and constants with zero runtime dependencies on React or wagmi.
Exports include:
- Contract ABIs (
positionManagerAbi,configAbi,poolVaultAbi, etc.) - Type-safe enum constants (
Side,Tenor,Mode,CloseReason,PositionStatus) - Pair identifiers (
PAIR_IDS)
Contract addresses are loaded from deployment JSON files via the address config module, not hardcoded in the SDK.
Rust SDK
Auto-generated Rust bindings from Foundry artifacts. Thefx-contracts crate provides type-safe contract interfaces that are regenerated automatically when contract artifacts change.
Exports include:
- Contract interfaces (
OracleModule,PositionManager,PoolVault, etc.) - Constants (
EUR_USD_PAIR_IDcomputed at build time via Keccak256) - Type-safe enums (
Side,Tenor,Mode,PositionStatus,CloseReason) with#[repr(u8)]
Enable the
test-contracts feature to access MockOracle, MockPyth, and MockUSDC bindings for local development and testing.Data Indexing
Subgraph
A Graph Protocol subgraph that indexes all protocol events. Provides GraphQL access to:- Position lifecycle events (open, increase, close, settle, liquidate)
- LP vault events (deposits, withdrawals, share price changes)
- Oracle price updates and forward round publications
- Daily statistics and fee accumulation
- Protocol mode transitions
See the Subgraph API documentation for the full GraphQL schema and query examples.
Agent Integrations
Agent integration tooling is under active development for M2. The following components provide programmatic access to the protocol for AI agents and automated systems.