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 🙏

© 2026 – Pkg Stats / Ryan Hefner

deploy-sdk-js

v0.0.7

Published

Deploy SDK - Complete DeFi interaction library with support for mint, stake, unstake, and redeem operations

Downloads

646

Readme

Deploy SDK

Complete DeFi interaction library for the Deploy platform with support for mint, stake, unstake, and redeem operations.

Platform support

The SDK works in React (web) and React Native. Same API in both; you only change how you obtain the wallet provider (browser: window.ethereum or Privy; React Native: WalletConnect, Privy React Native, or any EIP-1193 provider passed into ExternalWalletAdapter).

Installation

npm install deploy-sdk-js ethers

Quick Start

1. Initialize SDK with Privy

Pass a connected wallet from useWallets() (not the usePrivy() object). Ensure ready is true before initializing.

import { DeploySDK, PrivyAdapter, PrivyConnectedWallet, COLLATERAL_ASSETS, STAKE_TOKENS } from 'deploy-sdk-js';
import { useWallets } from '@privy-io/react-auth';

function App() {
  const { wallets, ready } = useWallets();
  const sdk = new DeploySDK({
    apiUrl: 'https://your-api-url.com', // provide your backend API URL
    chainId: 1, // Ethereum mainnet
  });

  const connectWallet = async () => {
    if (!ready || !wallets.length) {
      console.error('No wallet connected');
      return;
    }
    const wallet = wallets[0]; // or pick by chain/address
    const adapter = new PrivyAdapter(wallet as PrivyConnectedWallet);
    await sdk.initialize(adapter);
    console.log('Connected:', await sdk.getAddress());
  };
}

2. Initialize SDK with MetaMask (React / browser)

In the browser, use window.ethereum with ExternalWalletAdapter:

import { DeploySDK, ExternalWalletAdapter } from 'deploy-sdk-js';

const ethereum = window.ethereum;
const adapter = new ExternalWalletAdapter(ethereum);

const sdk = new DeploySDK({
  apiUrl: 'https://your-api-url.com', // provide your backend API URL
  chainId: 1,
});

await sdk.initialize(adapter);

3. Initialize SDK in React Native

In React Native there is no window.ethereum. Get an EIP-1193 provider from your wallet stack (e.g. WalletConnect, Privy React Native) and pass it to ExternalWalletAdapter:

import { DeploySDK, ExternalWalletAdapter } from 'deploy-sdk-js';

// provider: from WalletConnect, Privy React Native, or your custom injector
const adapter = new ExternalWalletAdapter(provider);
const sdk = new DeploySDK({
  apiUrl: 'https://your-api-url.com', // provide your backend API URL
  chainId: 1,
});

await sdk.initialize(adapter);

4. Mint dUSD

import { COLLATERAL_ASSETS } from 'deploy-sdk-js';

const mintDUSD = async () => {
  // Mint 1000 dUSD using USDC
  const result = await sdk.mint.mint(
    COLLATERAL_ASSETS.USDC,
    '1000000000', // 1000 USDC (6 decimals)
    '1000000000000000000000', // 1000 dUSD (18 decimals)
    { expiryMinutes: 10 }
  );
  
  console.log('Mint successful:', result.txHash);
};

5. Stake dUSD

import { STAKE_TOKENS } from 'deploy-sdk-js';

const stakeDUSD = async () => {
  // Stake 1000 dUSD
  const result = await sdk.stake.stake({
    token: STAKE_TOKENS.dUSD,
    amount: '1000000000000000000000', // 1000 dUSD
  });
  
  console.log('Staked:', result.sharesReceived, 'sDUSD shares');
};

6. Unstake (with Cooldown)

const unstakeProcess = async () => {
  // Step 1: Initiate cooldown
  const cooldownResult = await sdk.unstake.initiateCooldown(
    STAKE_TOKENS.dUSD,
    '500000000000000000000' // 500 sDUSD shares
  );
  
  console.log('Cooldown initiated. Ends at:', new Date(cooldownResult.cooldownEnd!));
  
  // Step 2: Wait for cooldown to complete
  // ... wait 90 days ...
  
  // Step 3: Unstake
  const unstakeResult = await sdk.unstake.unstake({
    token: STAKE_TOKENS.dUSD,
    sharesAmount: '500000000000000000000',
  });
  
  console.log('Unstaked:', unstakeResult.assetsWithdrawn, 'dUSD');
};

7. Redeem dUSD for USDC

const redeemDUSD = async () => {
  const result = await sdk.redeem.redeem(
    STAKE_TOKENS.dUSD,
    '1000000000000000000000', // 1000 dUSD
    COLLATERAL_ASSETS.USDC.address,
    '1000000000', // 1000 USDC
    { expiryMinutes: 10 }
  );
  
  console.log('Redeem successful:', result.txHash);
};

SDK Events

sdk.on('initialized', (data) => {
  console.log('SDK initialized for address:', data.address);
});

sdk.on('error', (error) => {
  console.error('SDK error:', error);
});

sdk.on('chainChanged', (data) => {
  console.log('Chain changed to:', data.chainId);
});

sdk.on('disconnected', () => {
  console.log('Wallet disconnected');
});

Utility Services

Allowance Management

// Check allowance
const allowance = await sdk.allowance.getAllowance(
  COLLATERAL_ASSETS.USDC.address,
  COLLATERAL_ASSETS.USDC.mintingContract
);

// Approve tokens
await sdk.allowance.approve(
  COLLATERAL_ASSETS.USDC.address,
  COLLATERAL_ASSETS.USDC.mintingContract,
  '1000000000'
);

// Approve max
await sdk.allowance.approveMax(
  COLLATERAL_ASSETS.USDC.address,
  COLLATERAL_ASSETS.USDC.mintingContract
);

// Ensure allowance (approves if needed)
await sdk.allowance.ensureAllowance(
  COLLATERAL_ASSETS.USDC.address,
  COLLATERAL_ASSETS.USDC.mintingContract,
  '1000000000'
);

Balance Management

// Get token balance
const balance = await sdk.balances.getTokenBalance(
  STAKE_TOKENS.dUSD.address
);

// Get native ETH balance
const ethBalance = await sdk.balances.getNativeBalance();

// Check sufficient balance
const hasEnough = await sdk.balances.hasSufficientBalance(
  STAKE_TOKENS.dUSD.address,
  '1000000000000000000000'
);

Error Handling

import { DeploySDKError, ErrorCode } from 'deploy-sdk-js';

try {
  await sdk.mint.mint(...);
} catch (error) {
  if (error instanceof DeploySDKError) {
    console.log('Error code:', error.code);
    console.log('Error message:', error.message);
  
    switch (error.code) {
      case ErrorCode.INSUFFICIENT_BALANCE:
        // Handle insufficient balance
        break;
      case ErrorCode.INSUFFICIENT_ALLOWANCE:
        // Handle insufficient allowance
        break;
      case ErrorCode.SIGNATURE_FAILED:
        // Handle signature failure
        break;
    }
  }
}

API Reference

DeploySDK

Main SDK class that provides access to all modules and services.

Constructor Options:

  • chainId: Chain ID (default: 1)
  • apiUrl: Backend API URL
  • rpcUrl: Custom RPC URL

MintModule

Handles minting dUSD using EIP-712 signed orders.

Methods:

  • createOrder(): Create a mint order
  • signOrder(): Sign a mint order
  • submitOrder(): Submit signed order to backend
  • mint(): Full mint flow (create + sign + submit)
  • estimateGas(): Estimate gas for mint

StakeModule

Handles ERC4626 vault staking operations.

Methods:

  • stake(): Stake tokens into vault
  • getPosition(): Get user's staking position
  • previewStake(): Preview shares received for stake
  • getAPY(): Calculate current APY

UnstakeModule

Handles ERC4626 vault unstaking with cooldown.

Methods:

  • initiateCooldown(): Start cooldown period
  • unstake(): Unstake tokens after cooldown
  • getCooldownStatus(): Check cooldown status
  • previewUnstake(): Preview assets received for shares

RedeemModule

Handles redeeming dUSD for collateral using EIP-712 signed orders.

Methods:

  • createOrder(): Create a redeem order
  • signOrder(): Sign a redeem order
  • submitOrder(): Submit signed order to backend
  • redeem(): Full redeem flow (create + sign + submit)
  • estimateGas(): Estimate gas for redeem

Supported Tokens

Collateral Assets

  • USDC: USD Coin (6 decimals)
  • USDT: Tether USD (6 decimals)

Stake Tokens

  • dUSD: Deploy USD (stake to sDUSD)

License

UNLICENSED