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

@aries-markets/aries-tssdk

v0.0.8

Published

[![Discord][discord-image]][discord-url]

Downloads

20

Readme

SDK for Aptos Node API BY Aries Market

Discord

Aries Market

Quickstart

To start building, run below command in your project directory:

yarn add @aries-markets/aries-tssdk

If you are using the types in a commonjs module, like in a Node app, you just have to enable esModuleInterop and allowSyntheticDefaultImports in your tsconfig for types compatibility:

{
  	// ...
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true
    // ...
  }
}

Usage

With Aries SDK, you can directly interact with aptos blockchain without worried about type compatibility.

The SDK Instance is extreamly well-typed, consumable for frontend, There's type defination in the idl directory that is generated from the aptos blockchain source code, which is written in move.

  • To get the SDK Instance, you need to provide two parameters:

    client:

    const nodeUrl = 'https://fullnode.mainnet.aptoslabs.com/v1';
    const client = new AptosClient(nodeUrl, { WITH_CREDENTIALS: false });

    program: program address start with '0x'

  • Now you can get the SDK instance:

    import { getAriesSDK } from '@aries-markets/aries-tssdk';
      
    const sdk = getAriesSDK(client, program);
  • There're several main usage with the sdk you've got

    1. fetch the reserves

      const reservesTable = await sdk.reserve.Reserves.fetch.fromProgram();

      you may need some extra operations to get the desired data structure:

      export const targetCoins = [
        ['0x1::aptos_coin::AptosCoin', 'aptos']
      ];
           
      const res = await reservesTable.stats.fromKeys(
              targetCoins.map(([coin]) => {
                const [address, module, struct] = coin.split('::');
                return {
                  module,
                  keyStructName: struct,
                  address,
                };
              }),
            );
           
      const reserves =  res.map(i => ({
        coinAddress: typeInfoToStr(i.key),
        ...i.value,
      }));
    2. fetch profileDetail

      • fetch Profile with profileAdress

        const res = await sdk.profile.Profile.fetch.fromAddress(
          profileAddress,
        );
      • then you can get your deposits and loans

            const rawDeposits = await res.depositedReserves.fetch();
            const rawLoans = await res.borrowedReserves.fetch();
    3. fetch profiles

      • fetch all of your profiles base on the wallet

        const res = await sdk.profile.Profiles.fetch.fromWallet();
      • map the result to desired data structure

        const list = res.profileSigners.map(v => ({
                  profileName: v.key.replace('profile', ''),
                  address: v.value.account,
                }));
    4. basic transactions

      • get the controller object, which can be used to addReserve, registerUser, deposit, withdraw, borrow, swap, etc.

        const controller = sdk.controller;
      • addReserve

        .addReserve({
            Coin0: coinAddress,
        });
      • registerUser:

        sdk.controller.registerUser({
          default_profile_name: profileName,
        });
      • addProfile/Acount

        sdk.controller.addSubaccount({ profile_name: profileName });
      • Basic transaction, take deposit as an example

        controller.deposit(
              {
                amount: lamports, // Big Type in big.js
                profile_name: 'profile name',
                repay_only: false,
              },
              { Coin0: coinAddress },
        );

Requirements

yarn install

References