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

@duocash/sdk

v0.1.1

Published

[![Actions Status](https://github.com/duocash/sdk/workflows/Test/badge.svg)](https://github.com/duocash/sdk/actions) [![version number](https://img.shields.io/npm/v/@duocash/sdk?color=success&label=version)](https://github.com/duocash/sdk/releases) [![Lic

Downloads

3

Readme

DuoCash SDK

Actions Status version number License npm bundle size (scoped version)

The goal of this SDK is to make it easy for developers to integrate DuoCash into their website/app/dApp. Right now this SDK is just able to fetch info, we plan on adding support for creating new lockers and interacting with existing lockers.

Some features of this SDK:

  • Multicall support
  • Multiple chains (ETH, BSC, MATIC, AVAX and Testnets)
  • UniswapV3 Helper

More resources:

Install

Install using one of the following commands

npm i @duocash/sdk or yarn add @duocash/sdk

Examples

Uniswap V3

We have a special helper for Uniswap V3 to make integration even easier, 2 lines of additional code is all you need. This will fetch you information on the pool such as what percentage is locked, and all the lockers (with their positions)

import {UniswapV3Helper} from "@duocash/sdk";

// You need a provider for the chain you want to fetch the data from
// This can be the users wallet 'window.ethereum' or supplied by you
const provider = new ethers.providers.InfuraProvider(
  4, // Rinkeby Testnet
  "YOUR_API_KEY"
);

// Initialize the helper by providing it the provider and the chainId
const uniV3 = new UniswapV3Helper(provider, 4);
const poolInfo = await uniV3.poolInfo("0xa9e93d50143d30fe51e2c83af0d3f721c3051475")

// That was all we really need, now we can display the data
console.log(`From this pool ${poolInfo.percentageLocked}% has been locked`)
console.log(`Liquidity has been locked in ${poolInfo.lockers.length} lockers`)
console.log(`Lockers:`)
for (var i = 0; i < poolInfo.lockers.length; i++) {
  console.log(`- ${poolInfo.lockers[i].locker.getDuoCashUri()}`)
}

Generic usage (ex. UniswapV2/Pancakeswap)

Here we are going to check an array of addresses to see if any of them are lockers. Your application would fetch an array of addresses of whatever asset you want to check. This could be a UNIv2 LP token, a regular ERC20 token etc. All addresses are checked at the same time in a single RPC call.

import {Lockers} from "@duocash/sdk";

// Your dApp fetches this from on-chain/etherscan/theGraph/BitQuery etc.
const lpHolders = [
  "0xCF9F06BaBfEE8c2486E7Ee274DAC3DDdF2d62F04",
  "0x153e4E66bB91FDa949351b9F8415bfeC5124C515"
  // ....
];

// You need a provider for the chain you want to fetch the data from
// This can be the users wallet 'window.ethereum' or supplied by you
const provider = new ethers.providers.InfuraProvider(
  4, // Rinkeby Testnet
  "YOUR_API_KEY"
);

// Initialize the DuoCash helper by providing it the provider and the chainId
const DuoCashLockers = new Lockers(provider, 4);
const lockers = await DuoCashLockers.fetchLockersByAddress(lpHolders);

// Output it to the user as a list
for (const [address, locker] of Object.entries(lockers)) {
    console.log(`${address} is a DuoCash locker, more info at ${locker.getDuoCashUri()}`)
}