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

whales-pre-market-aptos-sdk

v1.5.1

Published

TypeScript SDK for Whales Pre-Market on Aptos blockchain

Readme

Whales Pre-Market Aptos SDK

TypeScript SDK for interacting with the Whales Pre-Market smart contract on Aptos blockchain.

Installation

npm install whales-pre-market-aptos-sdk

Usage

import {
  PreMarketAptos,
  OfferType,
  signDiscount,
  WEI6,
} from "whales-pre-market-aptos-sdk";
import { Network, APTOS_FA } from "@aptos-labs/ts-sdk";

// Initialize the SDK
const sdk = new PreMarketAptos(
  {
    network: Network.MAINNET, // or 'TESTNET'
    fullnode: "custom_fullnode_url",
    clientConfig: {
      WITH_CREDENTIALS: true,
      API_KEY: "api_key_here",
    },
  },
  {
    apiUrl: "no_code_indexing_api",
    authorizationKey: "api_key",
  }
);

// Get configuration
const config = await sdk.getConfig();

// Get token configuration
const tokenConfig = await sdk.getTokenConfig("token_config_address");

// Create an offer
const keypair = new Ed25519PrivateKey("private_key_here");
const account = Account.fromPrivateKey({ privateKey: keypair });

const tokenConfig = "token_config_address";
const exToken = APTOS_FA;
const offerType = OfferType.Buy;
const amount = 100;
const value = 1000;
const fullMatch = true;

const { rawTx } = await preMarket.buildCreateOffer(
  account.accountAddress,
  tokenConfig,
  exToken,
  offerType,
  amount,
  value,
  fullMatch
);

const pendingTxn = await preMarket.aptos.signAndSubmitTransaction({
  signer: account,
  transaction: rawTx,
});
const response = await preMarket.aptos.waitForTransaction({
  transactionHash: pendingTxn.hash,
});
console.log("Tx succeed. - ", response.hash);

// build cancel with discount
const offer = "offer_object_address";
const discountData = {
  id: "offer_object_address",
  sellerDiscount: WEI6 / 2,
  buyerDiscount: WEI6 / 5,
};

const settleDiscount = signDiscount(
  "discount_signer_private_key",
  discountData.id,
  discountData.buyerDiscount,
  discountData.sellerDiscount
);

const cancelTx = await preMarket.buildCancelOfferWithDiscount(
  ownerAccount.accountAddress,
  offer,
  settleDiscount
);

// crawl events
let startIndex = 0;
const limit = 25;

while (true) {
  const events = await preMarket.eventCrawler.getEvents(startIndex, limit);
  console.log(events);
  startIndex += events.length;

  if (events.length === 0) {
    break;
  }
}

// crawl events with graphQL
let lastTxVersion = 0;
const limit = 25;

while (true) {
  const events = await preMarket.eventCrawler.getEventsV2(lastTxVersion, limit);
  console.log(events);

  if (events.length > 0) {
    lastTxVersion = events[events.length - 1]?.transaction_version;
  }

  if (events.length === 0) {
    break;
  }
}

Features

  • ✅ Configuration management
  • ✅ Token operations
  • ✅ Offer creation and management
  • ✅ Order settlement
  • ✅ Role-based access control
  • ✅ GraphQL client for event querying
  • ✅ TypeScript support with full type definitions

API Documentation

Core Methods

Configuration & Query

  • getConfig() - Get platform configuration
  • getTokenConfig(tokenConfigId) - Get token configuration
  • getOffer(offerId) - Get offer details
  • getOrder(orderId) - Get order details
  • getRole(user) - Get user role
  • isTokenAccepted(token) - Check if token is accepted

Owner Functions

  • buildMigrate(owner) - Migrate contract
  • buildUpdateConfig(owner, params) - Update platform configuration
  • buildAddRole(owner, user, role) - Add user role
  • buildRemoveRole(owner, user) - Remove user role

Admin Functions

  • buildTokenForceCancelSettlePhase(admin, tokenConfig) - Force cancel token settle phase
  • buildCancelToken(admin, tokenConfig) - Cancel token

Operator Functions

  • buildAcceptExToken(operator, token) - Accept external token
  • buildRemoveExToken(operator, token) - Remove external token
  • buildCreateToken(operator, tokenIndex, settleDuration) - Create new token
  • buildTokenToSettlePhase(operator, tokenConfig, token, settleRate) - Move token to settle phase
  • buildToggleTokenStatus(operator, tokenConfig) - Toggle token status
  • buildUpdateSettleDuration(operator, tokenConfig, newDuration) - Update settle duration
  • buildForceCancelOrder(operator, order) - Force cancel order

User Functions

  • buildCreateOffer(sender, tokenConfig, exToken, offerType, amount, value, fullMatch) - Create a new offer
  • buildFillOffer(sender, offer, amount) - Fill an existing offer
  • buildCancelOffer(sender, offer) - Cancel an offer
  • buildCancelOfferWithDiscount(sender, offer, discount) - Cancel offer with discount
  • buildSettleFilled(sender, order) - Settle a filled order
  • buildSettleFilledWithDiscount(sender, order, discount) - Settle filled order with discount
  • buildSettleCancelled(sender, order) - Settle a cancelled order
  • buildSettleCancelledWithDiscount(sender, order, discount) - Settle cancelled order with discount

License

MIT