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

@koibanx/swapper-sdk

v0.1.1

Published

Swapper SDK

Downloads

1,172

Readme

Koibanx Swapper SDK

Swapper SDK based in module Swapper

Description

Swapper module allows to virtually segragate the liquidiy from an external liquidity provider (ELP) into accounts, transfer them between those accounts, and swap liquidity, within a given account, between different assets the ELP provides. The rate will be given from an external exchange wich will provide the exchange rates, and the trading methods needed for the swapper to operate. The segregation is virtual because the module can't move the real balance, but uses a representation (ledger token) to disperse the funds between accounts.

What can be done?

  • Create a master account tracking a liquidity provider's balance
  • Create an account from a master account
  • Transfer crypto between accounts
  • Swap account's cryptos

Use case example

Having an ELP (lets say Bitgo) with different cryptoassets, you can configure each asset as an external source and segregate your liquidity to other players using the accounts. This accounts can transfer assets between them (a closed loop operation), buy or sell coin from your main account (segregate) or swap an asset for another asset, using Bitgo's rate.

SDK Documentation

Feast yourself

Installation

npm install @koibanx/swapper-sdk

NOTE: you must have the npm token in your .npmrc file


Initialization

Node

Using ES6 import

import SwapperSdk from '@koibanx/swapper-sdk';

const swapper = SwapperSdk({
  baseURL: 'http://your-url',
});

With require

exports.__esModule = true;
const SwapperSdk = require('@koibanx/swapper-sdk')["default"];

const swapper = SwapperSdk({
  baseURL: 'http://your-url',
});

Types

  • Typescript (@koibanx/swapper-sdk/dist/index.d.ts)

Examples

Using ES6 import

import SwapperSdk from "@koibanx/swapper-sdk";

const swapperSDK = SwapperSdk({
    baseURL: 'http://your-url',
})

const catchError = (err, modulo) => {
  console.log('Modulo: ', modulo);
  console.log('details: ', err.details);
  console.log('shortMessage: ', err.message);
  console.log('errorCode: ', err.code);
}

// Create Master Account

swapper.account.createMasterAccount({
  credentials: [
    {
      type: 'bitso',
      apiKey: 'IegAxnLvEY',
      secret: '140ae1d278h650cfd34c1f59dc57509c',
    },
  ],
  allowRed: false,
}).then((data) => {
  console.log('createMasterAccount', JSON.stringify(data._id));
}).catch((e) => catchError(e, 'createMasterAccount'));

// Create Account

swapper.account.createAccount({
  parentId: '63c614d967520921f328dcf2',
}).then((data) => {
  console.log('createAccount', JSON.stringify(data._id));
}).catch((e) => catchError(e, 'createAccount'));

// Get Account

swapper.account.getAccount({
  id: '63c614d967520921f328dcf2',
}).then((acc1) => {
  console.log('getAccount', JSON.stringify(acc1._id));
}).catch((e) => catchError(e, 'getAccount'));

// Implemented

swapper.account.createMasterAccount({
  credentials: [
    {
      type: 'bitso',
      apiKey: 'IegAxnLvEY',
      secret: '140ae1d278h650cfd34c1f59dc57509c',
    },
  ],
  allowRed: false,
}).then((data) => {
  console.log('createMasterAccount', JSON.stringify(data._id));
  p.account.createAccount({
    parentId: data._id,
  }).then((acc) => {
    console.log('createAccount', JSON.stringify(acc._id));
    swapper.account.getAccount({
      id: acc._id,
    }).then((acc1) => {
      console.log('getAccount', JSON.stringify(acc1._id));
    }).catch((e) => catchError(e, 'getAccount'));
  }).catch((e) => catchError(e, 'createAccount'));
}).catch((e) => catchError(e, 'createMasterAccount'));