Skip to main content

Crate perpl_sdk

Crate perpl_sdk 

Source
Expand description

Perpl DEX SDK.

§Overview

Convenient in-memory cache of on-chain exchange state.

Use state::SnapshotBuilder to capture initial state snapshot, then stream::raw to catch up with the recent state and keep snapshot up to date.

Use types::OrderRequest to prepare order requests to send them with crate::abi::dex::Exchange::ExchangeInstance::execOrdersV2.

The deployed contract may lag behind the revision the SDK targets, so the snapshot detects the contract’s state::ContractFeatures and degrades gracefully rather than failing on a missing selector.

See ./tests for examples.

§Limitations/follow-ups

  • Funding events processing is to follow.

  • Current version relies on log polling to implement reliably continuous stream of events. Future versions could improve indexing latency by utilizing WebSocket subscriptions and/or Monad execution events.

  • Test coverage is far below reasonable.

§Features

FeatureDefaultDescription
displayyesEnables std::fmt::Display implementation for state types.
testingyesEnables testing module.

§Testing

testing module provides a local testing environment with collateral token and exchange smart contracts deployed.

Modules§

abi
error
num
state
Exchange state tracking.
stream
testing
Local Anvil-based testing environment.
types

Structs§

Chain
Chain the exchange is operating on.