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

@juncta/sdk

v0.1.5

Published

TypeScript SDK for the Juncta Protocol public API

Downloads

116

Readme

@juncta/sdk

TypeScript SDK for the Juncta Protocol public API. Works in Node.js, browsers, and edge runtimes (ESM + CJS).

Installation

npm install @juncta/sdk

Quick start

import { JunctaClient } from "@juncta/sdk";

const client = new JunctaClient();

const { pools } = await client.getPools({ chainId: "cedra-testnet" });
console.log(pools);

The default base URL is https://api.juncta.xyz/v1. No API key is required.

Client options

const client = new JunctaClient({
  baseUrl: "https://api.juncta.xyz/v1", // optional override
});

Methods

Pools

// List pools (optional filter by chain)
const { pools, total, page, limit } = await client.getPools({
  chainId: "cedra-testnet", // "cedra-testnet" | "aptos-testnet" | "stellar-testnet"
  page: 1,
  limit: 20,
});

// Get a single pool - includes bins summary and APY breakdown
const pool = await client.getPool("pool-id");
// pool.apy_breakdown.fee_apy, pool.apy_breakdown.lending_apy, pool.apy_breakdown.total_apy
// pool.bins.active_count, pool.bins.lending_count, pool.bins.idle_count

// Get per-bin visualization data for a pool
const { bins, active_bin } = await client.getPoolBins("pool-id");
// bins[n].type - "center" | "active" | "lending" | "idle"

Tokens

// List tokens
const { tokens, total } = await client.getTokens({
  chainId: "stellar-testnet",
  page: 1,
  limit: 20,
  stable: true, // optional - filter to stablecoins only
});

// Get a single token
const token = await client.getToken("cedra-testnet", "0xabc123::coin::USDC");

// Get USD price for a token
const price = await client.getTokenPrice("cedra-testnet", "0xabc123::coin::USDC");
// price.price_usd, price.symbol, price.updated_at

Lending

// List tokens available for lending/borrowing
const { tokens } = await client.getLendableTokens({ chainId: "cedra-testnet" });
// tokens[n].supply_apy, tokens[n].borrow_apy, tokens[n].utilization, tokens[n].ltv

Positions

// Get LP positions for an account
const { positions, has_position } = await client.getPositions("0xabc123", {
  chainId: "cedra-testnet", // optional
  poolId: "pool-id",        // optional
});
// positions[n].net_shares, net_amount_x, net_amount_y

Liquidity preview

// Preview how liquidity is distributed across bins before adding
const preview = await client.getLiquidityPreview({
  chainId: "cedra-testnet",
  poolId: "pool-id",
  strategy: "spot",     // "spot" | "curve" | "bid_ask" | "wide"
  amountX: 1_000_000,
  amountY: 1_000_000,
  centerBin: 8388608,   // optional - defaults to active bin
  bidWeight: 50,        // optional - bid/ask weight % for "bid_ask" strategy
});
// preview.bins, preview.estimated_apy, preview.bin_range

Analytics

// Protocol-wide overview (TVL, lending capital, APY breakdown, bin counts)
const overview = await client.getProtocolOverview();
// overview.total_tvl_usd, overview.lending_supplied_usd
// overview.trading_fee_apy, overview.lending_yield_apy, overview.combined_apy
// overview.total_bins, overview.active_bins, overview.lending_bins, overview.idle_bins

// Protocol summary (24h swaps, volume, fees, etc.)
const summary = await client.getAnalyticsSummary({ chainId: "cedra-testnet" });

// Volume breakdown by pool
const rows = await client.getAnalyticsVolume({
  chainId: "cedra-testnet",
  poolId: "pool-id", // optional
  period: "7d",      // "1h" | "24h" | "7d" | "30d"
});

// Fee stats
const fees = await client.getAnalyticsFees({ period: "24h" });

Swap quote

const quote = await client.getSwapQuote({
  chain: "cedra",      // "cedra" | "aptos" | "stellar"
  pool: "pool-id",
  amountIn: "1000000",
  direction: "x_to_y", // "x_to_y" | "y_to_x"
  sender: "0xabc123",  // required for Stellar, optional for Cedra/Aptos
});

console.log(quote.amount_out, quote.fee, quote.price);

Transaction build + submit

All build methods work on Cedra, Aptos, and Stellar. The response type field tells you how to handle the payload:

  • "entry_function" - Cedra / Aptos. Pass payload directly to your Move wallet SDK.
  • "soroban_xdr" - Stellar. Sign the XDR with your wallet, then submit via submitTx.
// Swap
const build = await client.buildSwapTx({
  chain: "cedra",
  pool: "pool-id",
  amountIn: 1_000_000,
  minOut: 0,
  direction: "x_to_y",
  sender: "0xabc123",
});

// Add liquidity - strategy controls bin distribution
const addLiq = await client.buildAddLiquidityTx({
  chain: "cedra",
  pool: "pool-id",
  amountX: 1_000_000,
  amountY: 1_000_000,
  strategy: "spot",    // "spot" | "curve" | "bid_ask" | "wide"
  centerBin: 8388608,  // optional
  bidWeight: 50,       // optional - for "bid_ask" strategy
  sender: "0xabc123",
});

// Remove liquidity
await client.buildRemoveLiquidityTx({ chain, pool, binId, shares, sender });

// Create pool
await client.buildCreatePoolTx({ chain, tokenX, tokenY, basePrice, poolType, binStep, initialPrice, sender });

// Lending
await client.buildLendDepositTx({ chain, storeAddr, token, amount, sender });
await client.buildLendWithdrawTx({ chain, storeAddr, token, shares, sender });

// Borrow against LP collateral
await client.buildBorrowLPTx({ chain, storeAddr, lpStoreAddr, oracleAddr, token, positionId, poolId, borrowAmount, sender });

// Repay borrow
await client.buildRepayTx({ chain, storeAddr, token, positionId, amount, sender });

// Adaptive manager - call register AFTER the add-liquidity transaction confirms
await client.buildAdaptiveRegisterTx({ chain, pool, positionId, lowerBin, upperBin, sender });
await client.buildAdaptiveDeregisterTx({ chain, positionId, sender });

// Submit signed XDR (Stellar only)
const submitted = await client.submitTx({
  chain: "stellar",
  signedXdr: "AAAAAgAAA...",
});
console.log(submitted.hash);

Error handling

All methods throw JunctaAPIError on non-2xx responses.

import { JunctaClient, JunctaAPIError } from "@juncta/sdk";

try {
  const pool = await client.getPool("bad-id");
} catch (err) {
  if (err instanceof JunctaAPIError) {
    console.log(err.status); // 404
    console.log(err.body);   // raw response body
  }
}

Types

All request and response types are exported:

import type {
  Chain,
  SwapChain,
  SwapDirection,
  Period,
  PoolType,
  LiquidityStrategy,
  Pool,
  ActiveBin,
  PoolBins,
  APYBreakdown,
  PoolDetail,
  PoolBinVisualization,
  PoolBinsResponse,
  PoolsResponse,
  Token,
  TokenPrice,
  TokensResponse,
  LPPosition,
  PositionsResponse,
  BinWeight,
  LiquidityPreviewResponse,
  LendableToken,
  LendableTokensResponse,
  ProtocolOverviewResponse,
  SummaryResponse,
  VolumeRow,
  FeesResponse,
  QuoteResponse,
  BuildResponse,
  SubmitTxResponse,
} from "@juncta/sdk";

License

Apache-2.0