0.44.28 • Published 21 hours ago

@scallop-io/sui-scallop-sdk v0.44.28

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
21 hours ago

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

Description

This SDK is used to interact with sui-lending-protocal 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:

    // 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

0.44.28

21 hours ago

0.44.26

16 days ago

0.44.27

16 days ago

0.44.24

20 days ago

0.44.25

20 days ago

0.44.23

20 days ago

0.44.22

1 month ago

0.44.21

1 month ago

0.44.20

2 months ago

0.44.19

2 months ago

0.44.17

2 months ago

0.44.18

2 months ago

0.44.15

3 months ago

0.44.16

3 months ago

0.44.14

4 months ago

0.44.13

4 months ago

0.44.11

4 months ago

0.44.12

4 months ago

0.44.10

5 months ago

0.44.8

5 months ago

0.44.9

5 months ago

0.44.7

5 months ago

0.44.6

6 months ago

0.37.20

6 months ago

0.44.5

6 months ago

0.37.19

6 months ago

0.37.18

6 months ago

0.44.4

6 months ago

0.44.3

6 months ago

0.44.2

6 months ago

0.37.17

6 months ago

0.37.16

6 months ago

0.37.15

6 months ago

0.44.1

7 months ago

0.37.14

7 months ago

0.44.0

7 months ago

0.42.8

7 months ago

0.42.7

7 months ago

0.42.6

7 months ago

0.42.5

7 months ago

0.42.4

7 months ago

0.42.3

7 months ago

0.42.2

7 months ago

0.37.13

7 months ago

0.42.1

8 months ago

0.42.0

8 months ago

0.37.12

8 months ago

0.37.10

9 months ago

0.37.9

9 months ago

0.37.8

9 months ago

0.37.7

9 months ago

0.37.6

10 months ago

0.37.5

10 months ago

0.37.4

10 months ago

0.37.3

10 months ago