sui_scallop_sdk 1.3.0 copy "sui_scallop_sdk: ^1.3.0" to clipboard
sui_scallop_sdk: ^1.3.0 copied to clipboard

A Dart SDK for the Scallop lending protocol on Sui - market data, obligations, spools, lending/borrowing actions, and naming.

example/sui_scallop_sdk_example.dart

import 'dart:io';

import 'package:sui_kit/sui_kit.dart';
import 'package:sui_scallop_sdk/sui_scallop_sdk.dart';

/// Minimal end-to-end example for the Scallop Dart SDK.
///
/// Run with:
///
/// ```bash
/// dart run example/sui_scallop_sdk_example.dart
/// ```
///
/// A secret key is only required to sign transactions; the read-only market
/// queries below work without one. Provide it through the `PRIVATE_KEY`
/// environment variable (hex or bech32) to try the lending action at the end.
Future<void> main() async {
  // 1. Construct the SDK. All parameters are optional and default to mainnet.
  final scallop = Scallop(
    networkType: NetworkType.mainnet,
    secretKey: Platform.environment['PRIVATE_KEY'],
  );

  // 2. Initialize: fetches package/object IDs, coin metadata and whitelists,
  //    and wires up the query/builder/client stack. Must be awaited once
  //    before accessing `scallop.query`, `scallop.client`, etc.
  await scallop.init();

  // 3. Read market data (no wallet required).
  final query = scallop.query;
  final market = await query.getMarketPools(['sui', 'wusdc']);
  for (final pool in market.pools.values) {
    if (pool == null) continue;
    print(
      '${pool.symbol}: supply APY ${(pool.supplyApy * 100).toStringAsFixed(2)}% '
      '| borrow APY ${(pool.borrowApy * 100).toStringAsFixed(2)}%',
    );
  }

  final tvl = await query.getTvl();
  print('Protocol TVL: \$${tvl.totalValue}');

  // 4. Submit a transaction (requires PRIVATE_KEY). Amounts are in the coin's
  //    smallest unit, e.g. MIST for SUI (1 SUI = 1_000_000_000).
  if (Platform.environment['PRIVATE_KEY'] != null) {
    final client = scallop.client;
    final res = await client.deposit('sui', BigInt.from(1000000000));
    print('Deposit submitted: ${res.txResponse?.digest}');
  }

  // 5. Release the underlying providers when finished.
  scallop.dispose();
}
0
likes
160
points
672
downloads

Documentation

API reference

Publisher

verified publisherscallop.io

Weekly Downloads

A Dart SDK for the Scallop lending protocol on Sui - market data, obligations, spools, lending/borrowing actions, and naming.

Repository (GitHub)
View/report issues

Topics

#sui #scallop #defi #lending #blockchain

License

Apache-2.0 (license)

Dependencies

bcs_dart, collection, decimal, freezed_annotation, http, json_annotation, meta, pyth_sui_dart, riverpod, riverpod_annotation, sui_dart, sui_kit

More

Packages that depend on sui_scallop_sdk