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

dolanswap-sdk

v0.1.2

Published

SDK for interacting with DolanSwap prediction markets on Algorand

Readme

dolanswap-sdk

SDK for interacting with DolanSwap prediction markets on Algorand.

npm License: MIT

Install

npm install dolanswap-sdk algosdk

Quick Start

Read-only usage — no wallet required:

import algosdk from 'algosdk'
import { DolanPredictionClient } from 'dolanswap-sdk'

const algod = new algosdk.Algodv2('', 'https://mainnet-api.algonode.cloud', 443)
const client = new DolanPredictionClient({ algodClient: algod })

const roundId = await client.getCurrentRoundId()
const round = await client.getRound(roundId)
console.log(round)

Full Client Setup

With a wallet for betting and claiming:

import algosdk from 'algosdk'
import { DolanPredictionClient } from 'dolanswap-sdk'

const account = algosdk.mnemonicToSecretKey('your mnemonic here')
const algod = new algosdk.Algodv2('', 'https://mainnet-api.algonode.cloud', 443)
const signer = algosdk.makeBasicAccountTransactionSigner(account)

const client = new DolanPredictionClient({
  algodClient: algod,
  signer,
  activeAddress: account.addr.toString(),
})

API Reference

Round Reading

| Method | Returns | Description | |---|---|---| | getCurrentRoundId() | Promise<number> | Current round ID from global state | | getRound(roundId) | Promise<Round \| null> | Single round data from box storage | | getRounds(count?) | Promise<Round[]> | Latest N rounds (default 10) | | getOpenRounds() | Promise<Round[]> | Currently bettable rounds | | getLiveRound() | Promise<Round \| null> | Currently locked/live round |

Betting

| Method | Returns | Description | |---|---|---| | placeBet(roundId, direction, amountMicroAlgo) | Promise<string> | Place a bet, returns transaction ID | | getBet(roundId, address?) | Promise<Bet \| null> | Read a user's bet for a round | | getBetHistory(address?) | Promise<number[]> | All round IDs the user has bet on |

direction: 1 = UP, 2 = DOWN

amountMicroAlgo: Amount in microALGO (1 ALGO = 1,000,000 microALGO)

Claiming

| Method | Returns | Description | |---|---|---| | getUnclaimedRounds(address?) | Promise<UnclaimedRound[]> | Rounds with unclaimed winnings/refunds | | claimWinnings(roundId) | Promise<string> | Claim a single round, returns transaction ID | | batchClaim(roundIds) | Promise<string[]> | Claim multiple rounds, returns transaction IDs |

Oracle & Price

| Method | Returns | Description | |---|---|---| | getOraclePrice() | Promise<OracleReading> | On-chain oracle ALGO/USD price | | getLivePrice() | Promise<number> | Live Coinbase ALGO/USD spot price | | streamPrice(callback) | () => void | Stream live prices, returns unsubscribe function |

Utilities

| Method | Returns | Description | |---|---|---| | calculatePayout(betAmount, direction, round) | number | Expected payout for a bet | | calculateOdds(round) | { up, down } | Current pool multipliers | | calculateExpectedValue(betAmount, direction, round, winProb) | number | Expected value given win probability | | isRoundBettable(round) | boolean | Whether the round is open for bets | | timeUntilLock(round) | number | Seconds until betting closes | | timeUntilClose(round) | number | Seconds until round settles |

Events

client.startPolling()

client.on('roundOpened', (round) => { /* new round open for betting */ })
client.on('roundLocked', (round) => { /* betting closed, round is live */ })
client.on('roundSettled', (round) => { /* round finished, check results */ })
client.on('priceUpdate', (price) => { /* live Coinbase ALGO/USD tick */ })

client.stopPolling()

| Event | Callback | Fires When | |---|---|---| | roundOpened | (round: Round) => void | A round's status transitions to OPEN | | roundLocked | (round: Round) => void | A round's status transitions to LOCKED | | roundSettled | (round: Round) => void | A round's status transitions to CLOSED | | priceUpdate | (price: number) => void | New Coinbase ALGO/USD price tick |

Constants

All exported and available for direct use:

| Constant | Value | |---|---| | PREDICTION_APP_ID | 3534901984 | | ORACLE_APP_ID | 3534900173 | | MIN_BET_MICROALGO | 1,000,000 (1 ALGO) | | MAX_BET_MICROALGO | 1,000,000,000 (1000 ALGO) | | FEE_PERCENT | 3 | | ROUND_INTERVAL_SEC | 300 | | ORACLE_STALENESS_SEC | 600 | | STATUS_OPEN / STATUS_LOCKED / STATUS_CLOSED | 1 / 2 / 3 | | OUTCOME_PENDING / OUTCOME_UP / OUTCOME_DOWN / OUTCOME_DRAW / OUTCOME_INVALID | 0 / 1 / 2 / 3 / 4 |

Examples

Runnable scripts in the examples/ directory:

# Read current rounds and prices
npx tsx examples/read-rounds.ts

# Place a bet (requires MNEMONIC env var)
MNEMONIC="your mnemonic" npx tsx examples/place-bet.ts

# Claim all unclaimed winnings
MNEMONIC="your mnemonic" npx tsx examples/claim-winnings.ts

# Stream live vs oracle price spread
npx tsx examples/monitor-prices.ts

# Run a simple spread-based bot
MNEMONIC="your mnemonic" npx tsx examples/simple-bot.ts

Game Rules

  • 5-minute betting window + 5-minute live window per round
  • Bet: 1 to 1,000 ALGO per wallet per round
  • Directions: UP or DOWN (one per wallet per round)
  • Fees: 3% on winning rounds only (1.5% treasury + 1.5% dev)
  • Draw/Invalid rounds: full refund, zero fees
  • Payout: (bet_amount x reward_pool) / winning_pool

License

MIT