Coder Social home page Coder Social logo

ying-w / sui-scallop-sdk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from scallop-io/sui-scallop-sdk

0.0 0.0 0.0 702 KB

This is the typescript sdk for the scallop lending platform on SUI network

License: Apache License 2.0

Shell 0.02% TypeScript 99.98%

sui-scallop-sdk's Introduction

scallop

GitHub release GitHub licence

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

sui-scallop-sdk's People

Contributors

mr-donor avatar zengxinhai avatar fum-is-chum avatar nathanramli avatar djchrisssssss avatar chen4hao avatar nicetomeetyou1 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.