scallop_deepbook_kit library

Scallop DeepBook Kit

Toolkit and helpers for interacting with DeepBook-v3 margin pools on Sui, built on top of sui_dart. Provides high-level toolkit classes for supplying to and withdrawing from margin pools, querying pool parameters, and reading on-chain margin pool metadata.

Classes

Coin
A coin configuration entry.
DeepBookConfig
DeepBook configuration resolver: resolves package ids, pyth config and the coin/pool/margin-pool maps for a network.
DeepBookMarginPool
Helper class wrapping DeepBook's MarginPool contract interactions.
DeepBookMarginToolkit
Main DeepBook Margin Toolkit class.
DeepbookPackageIds
Resolved DeepBook-v3 package and registry ids for a network.
GrpcChangedObject
A changed object from execution effects.
GrpcExecResult
Result of a raw gRPC transaction execution.
MarginBalance
A user's margin balance snapshot.
MarginPool
A margin pool configuration entry.
MarginPoolContract
Builds DeepBook-v3 margin_pool move calls. Every method takes the Transaction first and emits a single move call.
MarginPoolParams
Decoded + formatted parameters for a single DeepBook margin pool.
Pool
A trading pool configuration entry.
PythConfig
Pyth oracle configuration for a network.
ToolkitConfig
Configuration for DeepBookMarginToolkit.

Constants

DEEP_SCALAR → const int
DEEP coin scalar (1e6).
FLOAT_SCALAR → const int
Float scalar (1e9) used for rate/utilization math.
mainnetCoins → const Map<String, Coin>
Mainnet coin metadata.
mainnetMarginPools → const Map<String, MarginPool>
Mainnet margin pools.
mainnetPackageIds → const DeepbookPackageIds
Mainnet DeepBook package ids.
mainnetPools → const Map<String, Pool>
Mainnet trading pools.
mainnetPythConfigs → const PythConfig
Mainnet Pyth oracle configuration.
marginPoolParamKeys → const List<String>
Base margin-pool parameter keys (all U64 on-chain).
marginPoolWithSupplierCapParamKeys → const List<String>
Margin-pool parameter keys that require a supplier cap (all U64).
testnetCoins → const Map<String, Coin>
Testnet coin metadata.
testnetMarginPools → const Map<String, MarginPool>
Testnet margin pools.
testnetPackageIds → const DeepbookPackageIds
Testnet DeepBook package ids.
testnetPools → const Map<String, Pool>
Testnet trading pools.
testnetPythConfigs → const PythConfig
Testnet Pyth oracle configuration.

Functions

getOnChainMarginPools({SuiGrpcClient? suiClient, String tableId = _marginPoolsTableId}) Future<Map<String, MarginPool>>
Fetch all margin pool addresses and their types from the on-chain dynamic-fields table.
grpcExecute(SuiGrpcClient client, Uint8List bytes, String signatureB64) Future<GrpcExecResult>
Execute signed bytes (+ base64 signatureB64) over raw gRPC and return the status + changed objects.
grpcSimulateCommandResults(SuiGrpcClient client, Transaction tx, {bool doGasSelection = false}) Future<List<CommandResult>>
Simulate tx and return the per-command return values (devInspect-style).
resolveCoinForAmount(SuiGrpcClient client, Transaction tx, {required String owner, required String coinType, required BigInt amount}) Future
Resolve a coin argument of amount base units of coinType owned by owner, adding the necessary split/merge commands to tx, and return the coin transaction argument.
signAndExecuteTransaction(SuiGrpcClient client, SuiAccount signer, Transaction tx) Future<GrpcExecResult>
Build (server-side via gRPC simulate + doGasSelection), sign tx with signer, and execute it over gRPC. Returns the parsed execution result.

Typedefs

MarginCoinType = String
Margin coin key, e.g. 'SUI', 'DBUSDC'.
NetworkType = String
Network identifier: one of 'testnet' or 'mainnet'.