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 🙏

© 2025 – Pkg Stats / Ryan Hefner

delta-sdk

v0.0.6

Published

Delta Trade SDK

Downloads

64

Readme

DeltaTradeSDK

DeltaTradeSDK is a JavaScript SDK for interacting with the Delta Trade platform, supporting both NEAR and Solana blockchains.

Installation

Install DeltaTradeSDK using npm or pnpm:

npm install @delta-trade/core
# or
pnpm add @delta-trade/core

Initialization

Before using the SDK, you need to initialize it. You can do this using the DeltaTradeSDK.initEnv method.

import DeltaTradeSDK from '@delta-trade/core';

const sdk = DeltaTradeSDK.initEnv({
  chain: 'near', // or 'solana'
  network: 'testnet', // or 'mainnet'
  accountId: 'your-account-id', // optional
  nearConfig: {
    jsonRpcUrls: ['https://rpc.testnet.near.org'], // optional
  },
  solanaConfig: {
    endpoint: 'https://api.testnet.solana.com', // optional
  },
});

Change Environment

sdk.changeEnv({
  chain: 'near',
  network: 'testnet',
  accountId: 'your-account-id',
});

Usage Examples

For more detailed examples, please refer to the examples directory in the repository.

Retrieve Pairs

To create a vault, you need a pairId. You can retrieve available pairs using the following method:

const pairs = await sdk.getPairs({ type: 'dca' });
console.log('Available Pairs:', pairs);

// Example: Selecting a pairId
const pairId = pairs[0]?.pair_id;
console.log('Selected Pair ID:', pairId);

Create a DCA Vault

const createParams = {
  pairId: 'pair-id',
  tradeType: 'buy',
  startTime: Date.now() + 1000 * 60 * 5,
  intervalTime: 0,
  singleAmountIn: 10,
  count: 10,
  name: 'test-dca-vault',
  recommender: '',
  lowestPrice: 0,
  highestPrice: 0,
};
const errors = await sdk.validateDCAVaultParams(createParams);
if (!errors) {
  const transaction = await sdk.createDCAVault(createParams);
  console.log('Transaction:', transaction);
  // sign and send transaction
  const wallet = await walletSelector?.wallet();
  await wallet.signAndSendTransactions(transaction);
} else {
  console.error('Validation Errors:', errors);
}

Create a Grid Vault

const gridParams = {
  pairId: 'pair-id',
  minPrice: '0.1',
  maxPrice: '1.0',
  gridAmount: 10,
  quantityPreGrid: '100',
  name: 'test-grid-vault',
  slippage: 1,
};
const gridErrors = await sdk.validateGridVaultParams(gridParams);
if (!gridErrors) {
  const gridTransaction = await sdk.createGridVault(gridParams);
  console.log('Grid Transaction:', gridTransaction);
} else {
  console.error('Grid Validation Errors:', gridErrors);
}

Create a Classic Swing Vault

const swingParams = {
  pairId: 'pair-id',
  tradeType: 'buy',
  buyPrice: '0.5',
  sellPrice: '1.0',
  everyPhasedAmount: '50',
  name: 'test-swing-vault',
};
const swingErrors = await sdk.validateSwingVaultParams('classic', swingParams);
if (!swingErrors) {
  const swingTransaction = await sdk.createClassicSwingVault(swingParams);
  console.log('Swing Transaction:', swingTransaction);
} else {
  console.error('Swing Validation Errors:', swingErrors);
}

Create a Phased Swing Vault

const phasedSwingParams = {
  pairId: 'pair-id',
  tradeType: 'buy',
  gridAmount: 5,
  intervalPrice: '0.1',
  everyPhasedAmount: '50',
  highestBuyPrice: '1.0',
  name: 'test-phased-swing-vault',
};
const phasedSwingErrors = await sdk.validateSwingVaultParams('phased', phasedSwingParams);
if (!phasedSwingErrors) {
  const phasedSwingTransaction = await sdk.createPhasedSwingVault(phasedSwingParams);
  console.log('Phased Swing Transaction:', phasedSwingTransaction);
} else {
  console.error('Phased Swing Validation Errors:', phasedSwingErrors);
}

Manage Vaults

Get My Vaults

const myGridVaults = await sdk.getMyGridVaults();
console.log('My Grid Vaults:', myGridVaults);

const mySwingVaults = await sdk.getMySwingVaults();
console.log('My Swing Vaults:', mySwingVaults);

const myDCAVaults = await sdk.getMyDCAVaults();
console.log('My DCA Vaults:', myDCAVaults);

Claim Vault

const claimResult = await sdk.claimGridVault({ botId: 'your-vault-id' });
console.log('Claim Result:', claimResult);

Close Vault

const closeResult = await sdk.closeGridVault({ botId: 'your-vault-id' });
console.log('Close Result:', closeResult);

Get Market Information

const marketInfo = await sdk.getMarketInfo();
console.log('Market Info:', marketInfo);

Get Account Assets

const assets = await sdk.getAccountAssets();
console.log('Account Assets:', assets);

Withdraw Account Asset

const result = await sdk.withdrawAccountAsset({ assetId: 'your-asset-id', amount: 100 });
console.log('Withdraw Result:', result);

Generate Referral URL

const referralUrl = await sdk.generateReferralUrl();
console.log('Referral URL:', referralUrl);

API Documentation

Initialization and Environment

  • DeltaTradeSDK.initEnv(params): Initialize the SDK environment.

    • Parameters:
      • params.chain: 'near' | 'solana'
      • params.network: 'mainnet' | 'testnet'
      • params.accountId: string (optional)
      • params.nearConfig: { jsonRpcUrls?: string[] } (optional)
      • params.solanaConfig: { endpoint?: string } (optional)
    • Returns: DeltaTradeSDK instance
  • sdk.changeEnv(params): Change the SDK environment.

    • Parameters: Partial<SDKParams>

Market and Pairs

  • sdk.getMarketInfo(): Get market information.

    • Returns: Promise<MarketInfo>
  • sdk.getPairs(params): Retrieve available trading pairs.

    • Parameters: { type: string }
    • Returns: Promise<Pair[]>
  • sdk.getPairPrices(pairIds): Get prices for specific pairs.

    • Parameters: string[]
    • Returns: Promise<Price[]>

Vault Management

DCA Vaults

  • sdk.validateDCAVaultParams(params): Validate parameters for creating a DCA vault.

    • Parameters: CreateDCAVaultParams
    • Returns: Promise<ValidationErrors | null>
  • sdk.createDCAVault(params): Create a DCA vault.

    • Parameters: CreateDCAVaultParams
    • Returns: Promise<Transaction[]>
  • sdk.claimDCAVault(id): Claim a DCA vault.

    • Parameters: string
    • Returns: Promise<Transaction[]>
  • sdk.closeDCAVault(id): Close a DCA vault.

    • Parameters: string
    • Returns: Promise<Transaction[]>

Grid Vaults

  • sdk.validateGridVaultParams(params): Validate parameters for creating a grid vault.

    • Parameters: CreateGridVaultParams
    • Returns: Promise<ValidationErrors | null>
  • sdk.createGridVault(params): Create a grid vault.

    • Parameters: CreateGridVaultParams
    • Returns: Promise<Transaction[]>
  • sdk.claimGridVault(id): Claim a grid vault.

    • Parameters: string
    • Returns: Promise<Transaction[]>
  • sdk.closeGridVault(id): Close a grid vault.

    • Parameters: string
    • Returns: Promise<Transaction[]>

Swing Vaults

  • sdk.validateSwingVaultParams(type, params): Validate parameters for creating a swing vault.

    • Parameters: SwingVaultType, CreateSwingVaultParams
    • Returns: Promise<ValidationErrors | null>
  • sdk.createClassicSwingVault(params): Create a classic swing vault.

    • Parameters: CreateClassicSwingVaultParams
    • Returns: Promise<Transaction[]>
  • sdk.createPhasedSwingVault(params): Create a phased swing vault.

    • Parameters: CreatePhasedSwingVaultParams
    • Returns: Promise<Transaction[]>
  • sdk.claimSwingVault(id): Claim a swing vault.

    • Parameters: string
    • Returns: Promise<Transaction[]>
  • sdk.closeSwingVault(id): Close a swing vault.

    • Parameters: string
    • Returns: Promise<Transaction[]>

Asset Management

  • sdk.getAccountAssets(): Get account assets.

    • Returns: Promise<AccountAssets>
  • sdk.withdrawAccountAsset(params): Withdraw an account asset.

    • Parameters: { assetId: string, amount: number }
    • Returns: Promise<Transaction[]>

Referral

  • sdk.generateReferralUrl(): Generate a referral URL.
    • Returns: Promise<string>

Contributing

Contributions are welcome! Please read CONTRIBUTING.md for more information.

License

ISC © Delta Trade