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 🙏

© 2024 – Pkg Stats / Ryan Hefner

pmarket-cli

v0.7.3

Published

CLI tool to trade on Polymarket

Downloads

6

Readme

pmarket-cli

Command line interface for Polymarket.


Features

  • List available markets with question filter.
  • Buy tokens/shares.
  • Sell tokens/shares.
  • Set USDC allowance for CTFExchange contract.
  • Show order book for specific token.
  • Cancel all open orders.
  • Generate api key for polymarket.

Installation

Minimum required node version is 16.20.0

npm i pmarket-cli -g

Setup

After successful installation you need to go through four steps in order to place buy and sell orders with the tool. Setup requires editing config.json file which is located under ~/.pmarket-cli/config.json where ~ is your home directory.

  1. You need to generate api key to access polygon network. I recommend using infura.io but you can use any other provider you like Steps to generate key. Once you generate the key set rpcProvider value in config.json file to your rpc provider url. Url should look something like this: https://polygon-mainnet.infura.io/v3/your-api-key

  2. Generate your private key and set it in config.json file (privateKey entry). You can use metamask to generate private key. Steps to generate private key

  3. You will need to generate an api key for polymarket. You can do this by running the following command:

pmarket-cli -k

Take values from the response and set them in config.json file (apiKey, apiSecret and passphrase entries).

  1. Set allowance for CTFExchange contract. You can do this by running the following command. This will allow CTFExchange contract to spend your USDC tokens.
pmarket-cli -a 500

After all 4 steps your config.json file should have all entries filled with values.


Usage examples:

pmarket-cli -l "Will Trump attend the first RNC debate?"

Response

[
  {
    token_0: {
      token_id: '12110463059584809904811790486163860991533989713640269122405796144537637099628',
      outcome: 'Yes'
    },
    token_1: {
      token_id: '29339358161683554702930216891507179890535004654000050338417989709558351328832',
      outcome: 'No'
    },
    question: 'Will Trump attend the first RNC debate?'
  }
]
pmarket-cli -b 12110463059584809904811790486163860991533989713640269122405796144537637099628 30 0.5

Response

  {
    "success": true,
    "errorMsg": "",
    "orderID": "0x556d3864c64d851462b2f378f5e6dcec7d31ba1632dfe44bfdcaa3cc685b45cc",
    "transactionsHashes": [
      "0x23d3b0f75446128bff33fd750870a1ea03a210de863ed7efd836ab3d18d83609"
    ],
    "status": "matched"
  }
pmarket-cli -s 12110463059584809904811790486163860991533989713640269122405796144537637099628 30 0.5

Response

  {
    "success": true,
    "errorMsg": "",
    "orderID": "0x556d3864c64d851462b2f378f5e6dcec7d31ba1632dfe44bfdcaa3cc685b45cc",
    "transactionsHashes": [
      "0x23d3b0f75446128bff33fd750870a1ea03a210de863ed7efd836ab3d18d83609"
    ],
    "status": "matched"
  }
pmarket-cli -a 500

Response

Block Gas Limit: 30323827
{
  type: 2,
  chainId: 137,
  nonce: 164,
  maxPriorityFeePerGas: BigNumber { _hex: '0xabcd', _isBigNumber: true },
  maxFeePerGas: BigNumber { _hex: '0xabcd', _isBigNumber: true },
  gasPrice: null,
  gasLimit: BigNumber { _hex: '0xabcd', _isBigNumber: true },
  to: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174',
  value: BigNumber { _hex: '0x00', _isBigNumber: true },
  data: '0x000ea7b30000000000000000000000004bfb41d5b3570defd03c39a9a4d8de6bd8b8982e00000000000000000000000000000000000000000000000000000000300aca00',
  accessList: [],
  hash: '0x6d409ef667f20807599ff2c1495df8f1ab71b7810a83e001a20196e43f469299',
  v: 0,
  r: '0xe9afafb7a4e036f4d1b06945afb5a08b8e0eb368daa5efa3b800c443e4f4113a',
  s: '0x084689146316314ad56868d3161438b31ed04a748fc008a5ac2c93f1f778779f',
  from: '0x01819b106DBfFD451bbE00ED1e3CE2fBD13CC947',
  confirmations: 0,
  wait: [Function (anonymous)]
}
pmarket-cli -o 12110463059584809904811790486163860991533989713640269122405796144537637099628

Response

{
  market: '0x6f662d9d965d0b01d08ee284a58e1dd866296729801c0cdc6867459760bd33ab',
  asset_id: '12110463059584809904811790486163860991533989713640269122405796144537637099628',
  bids: [
    { price: '0.03', size: '100' },
    { price: '0.45', size: '200' },
    { price: '0.51', size: '2000' },
    { price: '0.55', size: '200' }
  ],
  asks: [
    { price: '0.99', size: '1000' },
    { price: '0.97', size: '100' },
    { price: '0.95', size: '200' },
    { price: '0.9', size: '200' },
    { price: '0.75', size: '200' },
    { price: '0.72', size: '19' },
    { price: '0.7', size: '15' },
    { price: '0.69', size: '1022.76' },
    { price: '0.68', size: '191.52' }
  ],
  hash: '6993a77070f72dccda117544c72eb1ca4cef4bf7'
}
pmarket-cli -k

Response

{
  apiKey: 'your-api-key',
  secret: 'your-api-key-secret',
  passphrase: 'your-api-key-passphrase'
}
pmarket-cli -c

Response

{ canceled: [], not_canceled: {} }

Issues

Please use the Issue Tracker to report any issues or bugs.


License

This project is licensed under the MIT License.