{"_id":"@bastion-multisig/serum-pool","name":"@bastion-multisig/serum-pool","dist-tags":{"latest":"0.2.3"},"versions":{"0.2.3":{"name":"@bastion-multisig/serum-pool","version":"0.2.3","description":"Library for interacting with the serum pools","repository":{"type":"git","url":"https://github.com/project-serum/serum-ts.git"},"main":"dist/lib/index.js","source":"src/index.js","types":"dist/lib/index.d.ts","exports":{".":"./dist/lib/index.js"},"license":"Apache-2.0","publishConfig":{"access":"public"},"engines":{"node":">=10"},"scripts":{"build":"tsc","start":"tsc --watch","clean":"rm -rf dist","prepare":"run-s clean build","docs":"typedoc --out ../../docs/pool --mode library --composite false --rootDir src src/index.ts src/*.d.ts","test":"run-s test:build test:unit test:lint","test:build":"run-s build","test:lint":"eslint src","test:unit":"jest","test:watch":"jest --watch"},"dependencies":{"@project-serum/associated-token":"^0.1.1","@project-serum/borsh":"^0.0.1-beta.0","@project-serum/token":"^0.0.1-alpha.2","bn.js":"^5.1.2","buffer-layout":"^1.2.0"},"peerDependencies":{"@solana/web3.js":"^0.90.0"},"devDependencies":{"@solana/web3.js":"^0.90.0","@types/bn.js":"^4.11.6","@types/jest":"^26.0.9","@typescript-eslint/eslint-plugin":"^4.6.0","@typescript-eslint/parser":"^4.6.0","babel-eslint":"^10.0.3","cross-env":"^7.0.2","eslint":"^7.12.1","eslint-config-prettier":"^6.15.0","jest":"^26.4.0","npm-run-all":"^4.1.5","ts-jest":"^26.4.3","typedoc":"0.17.0-3","typescript":"^4.0.5"},"browserslist":[">0.2%","not dead","not op_mini all","maintained node versions"],"_id":"@bastion-multisig/serum-pool@0.2.3","dist":{"shasum":"6d8a17d945a6834d486dff53ae9df40fe0dcb379","integrity":"sha512-thsH7z+iShGeRRiVOwpYt11SqC8UK2I8Xn+jV3BTb3ilew9qHLQQiJTamgRZmil0NBdZwx5gsdWr03dHLiOy8g==","tarball":"https://registry.npmjs.org/@bastion-multisig/serum-pool/-/serum-pool-0.2.3.tgz","fileCount":35,"unpackedSize":199566,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDV+GTuxrVVSUraBTbrDdC7DPeCimD500Hdb+1ihpUnVwIgdcDF5zAcQLSuBLDqNpkWoWZpE9ooyrV/SFIgGc9ZERc="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi799hACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmoypw//dMpkbsZhi6DHlvhA6IU9XTHNs+9YqELvZM4urXe/P561dGf2\r\nh7h4L1b+/GZ9QlTmxAPZXwQ5aVwqTx47cCrBxRCZS6Hj74j7ZhfZfKanXAYV\r\nHWCDGe26hjUm29QYYYucAlMcQcO2JMWMhBeQKE/Pp6viXuZkI/hm09W2wb1l\r\nHpxrRxWLpOb9SEcjMs0dtWJpHkQoEOuWRYo7muyYjm4aSoTfIPwSxGL6vg3/\r\ntG9rYVXuiu6XllRk1eWxoNj5YmKvE9BWZU3QxIagSEPcnC3YqkQ5wlBwYwil\r\nghnNtGjxH3z4FvC1aaAlcDltfTUxujVW/HAhnQVowPJcfjoIkzOsPwL2QosW\r\nnt6F3RBy+rtTenaiTanmv8XCTNU9OBmbjTjsLkg/vCOSUBXgWv+AK6xaeBC9\r\nqAUOPuQLujDkj3OsUJnIyd8M4jvLBZc8jopNmCeA0euecnI3ySGYSGzcrNn3\r\nG0jIfkoqAbKGuSMZr3qlGFyim2JsvaJAlfMH0L/gBmW4Evswa94qNCnbadP4\r\nhQ9H5UQ8MaajhAkxupHFrq+hH/T+mTyWajJsajv6e6Plzqs9icREjAGcaMn8\r\nmiuptu7ZoWl3Vg74u6vf3XMOH4YsQC8AqNWAQT61TDwgK3tISNQkCiDalc6s\r\nf6bPKiW5Zg0HowCsMzHJeVD2Naj2teWYTu8=\r\n=Tzn4\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"tristyn","email":"tristynstimpson@gmail.com"},"directories":{},"maintainers":[{"name":"tristyn","email":"tristynstimpson@gmail.com"},{"name":"fedagencysimp","email":"FEDAgencySimp@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/serum-pool_0.2.3_1659887457337_0.8354025783142309"},"_hasShrinkwrap":false}},"time":{"created":"2022-08-07T15:50:57.265Z","0.2.3":"2022-08-07T15:50:57.579Z","modified":"2022-08-07T15:50:57.739Z"},"maintainers":[{"name":"tristyn","email":"tristynstimpson@gmail.com"},{"name":"fedagencysimp","email":"FEDAgencySimp@gmail.com"}],"description":"Library for interacting with the serum pools","repository":{"type":"git","url":"https://github.com/project-serum/serum-ts.git"},"license":"Apache-2.0","readme":"[![npm (scoped)](https://img.shields.io/npm/v/@project-serum/pool)](https://www.npmjs.com/package/@project-serum/pool)\n[![Build Status](https://travis-ci.com/project-serum/serum-ts.svg?branch=master)](https://travis-ci.com/project-serum/serum-ts)\n[![Documentation](https://img.shields.io/badge/typedoc-documentation-blue)](https://project-serum.github.io/serum-ts/pool/modules/_index_.html)\n[![Discord Chat](https://img.shields.io/discord/739225212658122886?color=blueviolet)](https://discord.com/channels/739225212658122886)\n[![License](https://img.shields.io/github/license/project-serum/serum-dex?color=blue)](https://opensource.org/licenses/Apache-2.0)\n\n# Serum Pools JS Library\n\nJavaScript client library for interacting with Project Serum Pools.\n\n## Installation\n\nUsing npm:\n\n```\nnpm install @solana/web3.js @project-serum/pool\n```\n\nUsing yarn:\n\n```\nyarn add @solana/web3.js @project-serum/pool\n```\n\n## Usage\n\n### Load pool info\n\nFetch and decode pool state:\n\n```js\nimport { Connection, PublicKey } from '@solana/web3.js';\nimport { loadPoolInfo, PoolTransactions } from '@project-serum/pool';\n\nlet connection = new Connection('...');\nlet poolAddress = new PublicKey('...'); // Address of the pool.\n\nlet poolInfo = await loadPoolInfo(connection, poolAddress);\nconsole.log(poolInfo.state);\n```\n\nSee [`loadPoolInfo()`](https://project-serum.github.io/serum-ts/pool/modules/_index_.html#loadpoolinfo) and [PoolState](https://project-serum.github.io/serum-ts/pool/interfaces/_index_.poolstate.html) for details.\n\nIf you already have the pool state data and just need to decode it, you can\ncall [`isPoolState()`](https://project-serum.github.io/serum-ts/pool/modules/_index_.html#ispoolstate)\nand [`decodePoolState()`](https://project-serum.github.io/serum-ts/pool/modules/_index_.html#decodepoolstate)\ndirectly.\n\n```js\nimport { decodePoolState } from '@project-serum/pool';\n\n// Pool state account data, e.g. from Connection.getAccountInfo or Connection.onAccountChange\nlet data = new Buffer('...');\n\nlet poolState = decodePoolState(data);\nconsole.log(poolState);\n```\n\nSee [`PoolState`](https://project-serum.github.io/serum-ts/pool/interfaces/_index_.poolstate.html)\nfor details on what the pool state contains.\n\n### Get pool basket\n\nUse [`getPoolBasket()`](https://project-serum.github.io/serum-ts/pool/modules/_index_.html#getpoolbasket)\nto fetch the current pool basket (the quantity of each token needed to create N pool tokens\nor the quantity of each token received for redeeming N pool tokens).\n\n```js\nimport { Connection, PublicKey } from '@solana/web3.js';\nimport { loadPoolInfo, getPoolBasket } from '@project-serum/pool';\nimport BN from 'bn.js';\n\nlet connection = new Connection('...');\nlet poolAddress = new PublicKey('...'); // Address of the pool.\n\nlet poolInfo = await loadPoolInfo(connection, poolAddress);\nlet basket = await getPoolBasket(\n  connection,\n  poolInfo,\n  { create: new BN(100) },\n  // Arbitrary SOL address, can be anything as long as it has nonzero SOL\n  // and is not a program-owned address.\n  new PublicKey('...'),\n);\n\nconsole.log(basket);\n```\n\n### Create pool tokens\n\nSend a transaction to create pool tokens:\n\n```js\nimport { Account, Connection, PublicKey } from '@solana/web3.js';\nimport { loadPoolInfo, PoolTransactions } from '@project-serum/pool';\nimport BN from 'bn.js';\n\nlet connection = new Connection('...');\nlet poolAddress = new PublicKey('...'); // Address of the pool.\nlet payer = new Account('...'); // Account to pay for solana fees.\n\nlet poolInfo = await loadPoolInfo(connection, poolAddress);\nlet { transaction, signers } = PoolTransactions.execute(\n  poolInfo,\n  {\n    // Number of tokens to create.\n    create: new BN(100),\n  },\n  {\n    // Spl-token account to send the created tokens.\n    poolTokenAccount: new PublicKey('...'),\n    // Spl-token accounts to pull funds from.\n    assetAccounts: [new PublicKey('...'), new Public('...')],\n    // Owner of poolTokenAccount and assetAccounts.\n    owner: payer.publicKey,\n  },\n  // Expected creation cost.\n  [new BN(10), new BN(10)],\n);\nawait connection.sendTransaction(transaction, [payer, ...signers]);\n```\n\nSee [`PoolTransactions.execute`](https://project-serum.github.io/serum-ts/pool/classes/_index_.pooltransactions.html#execute) for details.\n\n### Redeem pool tokens\n\nSend a transaction to redeem pool tokens:\n\n```js\nimport { Account, Connection, PublicKey } from '@solana/web3.js';\nimport { loadPoolInfo, PoolTransactions } from '@project-serum/pool';\nimport BN from 'bn.js';\n\nlet connection = new Connection('...');\nlet poolAddress = new PublicKey('...'); // Address of the pool.\nlet payer = new Account('...'); // Account to pay for solana fees.\n\nlet poolInfo = await loadPoolInfo(connection, poolAddress);\nlet { transaction, signers } = PoolTransactions.execute(\n  poolInfo,\n  {\n    // Number of tokens to redeem.\n    redeem: new BN(100),\n  },\n  {\n    // Spl-token account to pull the pool tokens to redeem from.\n    poolTokenAccount: new PublicKey('...'),\n    // Spl-token accounts to send the redemption proceeds.\n    assetAccounts: [new PublicKey('...'), new Public('...')],\n    // Owner of poolTokenAccount and assetAccounts.\n    owner: payer.publicKey,\n  },\n  // Expected redemption proceeds.\n  [new BN(10), new BN(10)],\n);\nawait connection.sendTransaction(transaction, [payer, ...signers]);\n```\n\nSee [`PoolTransactions.execute`](https://project-serum.github.io/serum-ts/pool/classes/_index_.pooltransactions.html#execute) for details.\n\n## API Reference\n\n[API Reference](https://project-serum.github.io/serum-ts/pool/modules/_index_.html)\n","readmeFilename":"README.md"}