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

cro-sdk

v1.7.8

Published

`cro-sdk` is a TypeScript SDK for interacting with the CroAg platform. It provides a comprehensive set of features for fetching APY data, managing user portfolios, performing swaps, staking, NFT management, and more.

Readme

Cro SDK

Overview

cro-sdk is a TypeScript SDK for interacting with the CroAg platform. It provides a comprehensive set of features for fetching APY data, managing user portfolios, performing swaps, staking, NFT management, and more.

Installation

Install the SDK via npm:

npm install cro-sdk

Usage Example

Import the SDK

import { CroAgSDK, ApyType, ProjectType } from 'cro-sdk'

Initialize the SDK

const sdk = new CroAgSDK()
console.log(ApyType, ProjectType)

Fetch and Deposit APY Data

async function processApyData() {
  const apyData = await sdk.getApyList(ApyType.LST, ProjectType.KAI_FINANCE)
  console.log(apyData)

  for (const route of apyData) {
    try {
      const tx = await sdk.croDeposit(
        route,
        '0x2::sui::Sui',
        2000000000n,
        '0x...'
      )
      if (tx) console.log(tx.getData().commands)
      await delay()
    } catch (e) {
      console.log(route)
      console.error(e)
    }
  }
}

Fetch User Portfolios and Withdraw Funds

async function fetchAndWithdrawPortfolios() {
  const portfolios = await sdk.fetchAllPortfolios(
    '0x...'
  )
  console.log(portfolios)

  if (portfolios != null) {
    for (const asset of portfolios) {
      console.log(asset)
      const tx = await sdk.croWithdraw(asset, asset.totalBalance)
      if (tx) console.log(tx.getData().commands)
    }
  }
}

Get Zero Objects and Mint

async function handleZeroObjects() {
  const objects = await sdk.get_zero_objs(
    '0x...'
  )
  console.log(objects)

  const tx = await sdk.zero_obj_mint(objects)
  if (tx) console.log(tx.getData().commands)
}

Perform Swap and Fetch Coin Information

Get Swap Routers

async function getSwapRouters() {
  const routers = await sdk.getSwapRouters(
    '0x2::sui::Sui',
    '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC',
    BigInt(1000000000000)
  )
  console.log(routers)
}

Get Coin Information

async function getCoin() {
  console.log(await sdk.getCoinsShow())
  console.log(await sdk.getCoinByType('0x2::sui::Sui'))
}

Stake and Unstake CRO

async function stakeCRO() {
  const tx = await sdk.stake(
    '0x...',
    BigInt(100000000)
  )
  if (tx) console.log(tx.getData().commands)
}

async function unstakeCRO() {
  const tx = await sdk.unstake(
    '0x...',
    BigInt(50000000)
  )
  if (tx) console.log(tx.getData().commands)
}

Manage NFTs (Mint, Points, Claim CRO)

async function manageNFTs() {
  const mintedNFT = await sdk.mint_nft(
    '0x...'
  )
  if (mintedNFT) console.log(mintedNFT.getData().commands)

  const referralNFT = await sdk.referral_mint_nft(
    '0x...',
    '0x123456789abcdef'
  )
  if (referralNFT) console.log(referralNFT.getData().commands)

  const addPointsTx = await sdk.add_points(
    '0x...',
    'nftId123',
    BigInt(100)
  )
  if (addPointsTx) console.log(addPointsTx.getData().commands)

  const claimCROTx = await sdk.claim_cro(
    '0x...',
    'nftId123'
  )
  if (claimCROTx) console.log(claimCROTx.getData().commands)
}

API Reference

Enums

  • ApyType

    • DEFAULT - Default type
    • DEFI - Decentralized Finance
    • LST - Liquidity Staking
    • STABLECOINS - Stablecoins
  • ProjectType

    • DEFAULT - Default project
    • NAVI_LENDING - Navi Lending
    • SCALLOP_LEND - Scallop Lending
    • KAI_FINANCE - Kai Finance

Interfaces

ApyData

| Property | Type | Description | | --------------------- | -------------- | ---------------------------- | | apy | string | Annual Percentage Yield | | coin_type | string | Coin type | | id | number | Unique identifier | | name | string | Name | | navi_pool_config_name | string | null | Navi pool configuration name | | navi_symbol | string | null | Navi symbol | | project | string | Project name | | symbol | string | Symbol | | tvl_usd | string | Total Value Locked (USD) | | type | string | Type | | update_time | string | Update time |

CroPortfolio

| Property | Type | Description | | ------------ | ------ | ------------- | | owner | string | Owner | | platform | string | Platform | | coinType | string | Coin type | | totalBalance | bigint | Total balance | | coinMetadata | any | Coin metadata |

Coin

| Property | Type | Description | | -------- | ------ | ------------------ | | type | string | Coin type | | name | string | Coin name | | symbol | string | Coin symbol | | decimals | number | Number of decimals | | iconUrl | string | URL to coin icon |

Class Methods

CroAgSDK

The CroAgSDK class contains all the methods required for interacting with the platform. Below is a list of available methods:

  • APY Management

    • getApyList(type?: ApyType, project?: ProjectType, single?: boolean): Promise<ApyData[]>
    • getApyListByType(coinType: string): Promise<ApyData[]>
  • Portfolio Management

    • fetchAllPortfolios(address: string): Promise<CroPortfolio[] | null>
    • fetchApyByPlatformAndCoinType(platform: string, coinType: string): Promise<ApyData | null>
  • Deposits and Withdrawals

    • croDeposit(apyData: ApyData, type_in: string, amount_in: bigint, address: string, referral?: string): Promise<Transaction | null>
    • croWithdraw(portfolio: CroPortfolio, amount: bigint, referral?: string): Promise<Transaction | null>
  • Zero Object Management

    • get_zero_objs(address: string): Promise<CoinStruct[]>
    • zero_obj_mint(objects: CoinStruct[]): Promise<Transaction | null>
  • Swap and Coin Management

    • getSwapRouters(from: string, target: string, amount_in: bigint): Promise<RouterData | null>
    • swap(tx: Transaction, from: string, target: string, inputCoin: any, amount_in: bigint, slippage: number): Promise<TransactionObjectArgument | null>
    • getCoinsShow(): Promise<Coin[] | null>
    • getCoinByType(coinType: string): Promise<Coin | null>
  • NFT Management

    • mint_nft(address: string, referral_address?: string): Promise<Transaction | null>
    • add_points(address: string, nftId: string, amount: bigint): Promise<Transaction | null>
    • claim_cro(address: string, nftId: string): Promise<Transaction | null>
  • Staking

    • stake(address: string, amount: bigint): Promise<Transaction | null>
    • unstake(address: string, amount: bigint): Promise<Transaction | null>

Contributing

We welcome contributions! Please refer to the Contributing Guide.

License

This project is licensed under the MIT License. See the LICENSE file for details.