npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@scallop-io/sui-scallop-sdk

v1.3.2

Published

Typescript sdk for interacting with Scallop contract on SUI

Downloads

7,216

Readme

The Typescript SDK for interacting with the Scallop lending protocol on the SUI network

Description

This SDK is used to interact with sui-lending-protocol and is written based on another sui-integrated tool, sui-kit. It consists of seven main functional models, here's a brief introduction to each of them:

  • Scallop: Provide an entry to quickly create an instance (client, address, query, builder, utils) and complete initialization at the same time.

  • ScallopClient: Helps users encapsulate basic operations for interacting with the contract. Once the instance is created, it can be called directly for use.

  • ScallopAddress: Used to manage the addresses of the lending contract. It's prepackaged into the client and provides the addresses of mainly production environment for customers to query addresses, usually used in conjunction with the builder.

  • ScallopQuery: Used to encapsulate all methods for querying on-chain data of the scallop contract. More useful information will be provided here in the future, such as lending, collateral, or borrowing portfolios.

  • ScallopBuilder: Used for more detailed organization of the lending protocol's transaction blocks. You can build your own transaction combinations according to your needs by this model.

  • ScallopUtils: Used to encapsulate some useful methods that will be used when interacting with the scallop contract.

  • ScallopIndexer: It is used to query the on-chain index data through the SDK API. It is mainly used in query instances, effectively reducing the number of RPC requests..

Pre-requisites

  • Installation:

    pnpm install @scallop-io/sui-scallop-sdk
  • Create an instance:

    Note: Currently, this SDK only supports the mainnet network. When you use the testnet network, it will give errors because there is no address package ID for the testnet.

    // Create an instance quickly through the`Scallop` class to construct other models.
    const scallopSDK = new Scallop({
        networkType: 'mainnet',
        ...
    });
    
    const scallopAddress = await scallopSDK.getScallopAddress(...);
    const scallopQuery = await scallopSDK.createScallopQuery(...);
    const scallopBuilder = await scallopSDK.createScallopBuilder(...);
    const scallopUtils = await scallopSDK.createScallopUtils(...);
    const scallopClient = await scallopSDK.createScallopClient(...);
    const scallopIndexer = await scallopSDK.createScallopIndexer();
    
    // Or, you can choose to import the class directly to create an instance.
    import {
      ScallopAddress,
      ScallopBuilder,
      ScallopQuery,
      ScallopUtils,
      ScallopIndexer,
      ScallopClient,
    } from '@scallop-io/sui-scallop-sdk'
    
    const scallopAddress = new ScallopAddress(...);
    const ScallopQuery = new ScallopQuery(...);
    const ScallopBuilder = new ScallopBuilder(...);
    const ScallopUtils = new ScallopUtils(...);
    const scallopClient = new ScallopClient(...);
    const ScallopIndexer = new ScallopIndexer();
    // Remember to initialize the instance before using it
    await scallopAddress.read();
    await ScallopQuery.init();
    await ScallopBuilder.init();
    await ScallopUtils.init();
    await scallopClient.init();

Quick Guide for each model

Below we will give a brief introduction to these instances respectively, and introduce the functions through test codes.

For the original codes, please refer to test folder.

You need to set up the .env file before testing. (Reference .env.example)

  • Run the test

    pnpm run test:unit test/index.spec.ts
    pnpm run test:unit test/address.spec.ts
    pnpm run test:unit test/builder.spec.ts
    pnpm run test:unit test/query.spec.ts
    pnpm run test:unit test/utils.spec.ts
    pnpm run test:unit test/indexer.spec.ts

License

APACHE-2.0