{"_id":"@anand18m/minswap-sdk","_rev":"1-3f0b0b1db044bc0764338e9240722f5a","name":"@anand18m/minswap-sdk","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"@anand18m/minswap-sdk","version":"0.1.0","description":"Query Minswap data and build transactions","type":"module","types":"./build/index.d.ts","exports":{".":{"types":"./build/index.d.ts","import":"./build/index.es.js"}},"scripts":{"build":"rimraf build && rollup -c rollup.config.js","test":"NODE_OPTIONS=--experimental-vm-modules jest && tsc","lint":"eslint src --ext .ts","format":"prettier --write **/*.ts && eslint src --fix --ext .ts","check-format":"prettier --check **/*.ts && eslint src --ext .ts","exec":"ts-node --esm --experimental-specifier-resolution=node"},"keywords":["minswap","cardano","blockfrost","dex","blockchain","lucid"],"author":{"name":"anand18m"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/minswap/sdk.git"},"bugs":{"url":"https://github.com/minswap/sdk/issues"},"homepage":"https://github.com/minswap/sdk#readme","dependencies":{"@blockfrost/blockfrost-js":"^5.3.1","@minswap/tiny-invariant":"^1.2.0","big.js":"^6.1.1","lucid-cardano":"^0.10.1"},"devDependencies":{"@types/big.js":"^6.1.3","@types/jest":"^27.5.2","@types/json-bigint":"^1.0.1","@typescript-eslint/eslint-plugin":"^5.20.0","@typescript-eslint/parser":"^5.20.0","esbuild":"^0.14.38","eslint":"^8.13.0","eslint-plugin-simple-import-sort":"^7.0.0","eslint-plugin-unicorn":"^48.0.1","eslint-plugin-unused-imports":"^2.0.0","jest":"^29.3.1","json-bigint":"^1.0.0","prettier":"3.0.0","rollup":"^2.70.2","rollup-plugin-dts":"^4.2.1","rollup-plugin-esbuild":"^4.9.1","ts-jest":"^29.1.1","ts-node":"^10.9.1","typescript":"^4.6.3"},"_id":"@anand18m/minswap-sdk@0.1.0","_nodeVersion":"18.17.0","_npmVersion":"9.6.7","dist":{"integrity":"sha512-hmzYt43q3b37kx3XWubtRmTzwAx5y6Xh55xWIR4To2Anj+exPiAXVtMWxdH+GG2cle7b5Y0HFllr/XmuCzN9yA==","shasum":"34dd850cb9f14d68bb5bcfb56024eafa748c9951","tarball":"https://registry.npmjs.org/@anand18m/minswap-sdk/-/minswap-sdk-0.1.0.tgz","fileCount":6,"unpackedSize":147794,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDatnAAqaUmX5EluMM5aDJAcJEwQuwbYo/Q2CRqrIVuyQIgXq0z200YLNJ+UhASKJh4FLDlxl7kuGVLBNrxQMF4hcE="}]},"_npmUser":{"name":"anand18m","email":"anand18mohan@gmail.com"},"directories":{},"maintainers":[{"name":"anand18m","email":"anand18mohan@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/minswap-sdk_0.1.0_1709726038878_0.8480594664515944"},"_hasShrinkwrap":false},"0.2.0":{"name":"@anand18m/minswap-sdk","version":"0.2.0","description":"Query Minswap data and build transactions","type":"module","types":"./build/index.d.ts","exports":{".":{"types":"./build/index.d.ts","import":"./build/index.es.js"}},"scripts":{"build":"rimraf build && rollup -c rollup.config.js","test":"NODE_OPTIONS=--experimental-vm-modules jest && tsc","lint":"eslint src --ext .ts","format":"prettier --write **/*.ts && eslint src --fix --ext .ts","check-format":"prettier --check **/*.ts && eslint src --ext .ts","exec":"ts-node --esm --experimental-specifier-resolution=node"},"keywords":["minswap","cardano","blockfrost","dex","blockchain","lucid"],"author":{"name":"anand18m"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/minswap/sdk.git"},"bugs":{"url":"https://github.com/minswap/sdk/issues"},"homepage":"https://github.com/minswap/sdk#readme","dependencies":{"@blockfrost/blockfrost-js":"^5.3.1","@minswap/tiny-invariant":"^1.2.0","big.js":"^6.1.1","lucid-cardano":"^0.10.1"},"devDependencies":{"@types/big.js":"^6.1.3","@types/jest":"^27.5.2","@types/json-bigint":"^1.0.1","@typescript-eslint/eslint-plugin":"^5.20.0","@typescript-eslint/parser":"^5.20.0","esbuild":"^0.14.38","eslint":"^8.13.0","eslint-plugin-simple-import-sort":"^7.0.0","eslint-plugin-unicorn":"^48.0.1","eslint-plugin-unused-imports":"^2.0.0","jest":"^29.3.1","json-bigint":"^1.0.0","prettier":"3.0.0","rollup":"^2.70.2","rollup-plugin-dts":"^4.2.1","rollup-plugin-esbuild":"^4.9.1","ts-jest":"^29.1.1","ts-node":"^10.9.1","typescript":"^4.6.3"},"_id":"@anand18m/minswap-sdk@0.2.0","_nodeVersion":"18.17.0","_npmVersion":"9.6.7","dist":{"integrity":"sha512-qjYX8poihfqtLMv/DGINrtm4DIrOPD6wX7ZNponETzaujgoWpRjr+pQoLLgeWAa92d90U13KBJe0BQaR95LXgA==","shasum":"ff811b7f74911372817323a0abbc4af9bb3c41ad","tarball":"https://registry.npmjs.org/@anand18m/minswap-sdk/-/minswap-sdk-0.2.0.tgz","fileCount":6,"unpackedSize":149740,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEqfS3yMlmgIV+AiTQuky/f1d24xDEGwGVn2V/+IPmixAiBifsbRkbLQfH7kzTttzVa8HVOy/3gVkYwh1FQFBIWACA=="}]},"_npmUser":{"name":"anand18m","email":"anand18mohan@gmail.com"},"directories":{},"maintainers":[{"name":"anand18m","email":"anand18mohan@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/minswap-sdk_0.2.0_1709730582388_0.49141844329016116"},"_hasShrinkwrap":false}},"time":{"created":"2024-03-06T11:53:58.778Z","0.1.0":"2024-03-06T11:53:59.028Z","modified":"2024-03-06T13:09:43.392Z","0.2.0":"2024-03-06T13:09:42.588Z"},"maintainers":[{"name":"anand18m","email":"anand18mohan@gmail.com"}],"description":"Query Minswap data and build transactions","homepage":"https://github.com/minswap/sdk#readme","keywords":["minswap","cardano","blockfrost","dex","blockchain","lucid"],"repository":{"type":"git","url":"git+https://github.com/minswap/sdk.git"},"author":{"name":"anand18m"},"bugs":{"url":"https://github.com/minswap/sdk/issues"},"license":"MIT","readme":"# Minswap SDK\n\n## Features\n\n- [x] Get current pair price\n- [x] Get historical pair price\n- [x] Calculate trade price\n- [x] Calculate price impact\n- [x] Create orders and submit with Lucid\n\n## Install\n\n- NPM: `npm install @minswap/sdk`\n- Yarn: `yarn add @minswap/sdk`\n\n## ES Module Requirement\n\nThis package depends on `lucid-cardano`, which is an ESM package, so it's also an ESM package. To import from ESM package, you need to specify `\"type\": \"module\"` in `package.json` and configure other build flags accordingly.\n\n## Examples\n\n### Example 1: Get current price of MIN/ADA pool\n\n```ts\nimport { BlockFrostAPI } from \"@blockfrost/blockfrost-js\";\nimport { BlockfrostAdapter } from \"@minswap/sdk\";\n\nconst api = new BlockfrostAdapter({\n  blockFrost: new BlockFrostAPI({\n    projectId: \"<your_project_id>\",\n    network: \"mainnet\",\n  }),\n});\nfor (let i = 1; ; i++) {\n  const pools = await api.getPools({\n    page: i,\n  });\n  if (pools.length === 0) {\n    // last page\n    break;\n  }\n  const minADAPool = pools.find(\n    (p) =>\n      p.assetA === \"lovelace\" &&\n      p.assetB ===\n        \"29d222ce763455e3d7a09a665ce554f00ac89d2e99a1a83d267170c64d494e\"\n  );\n  if (minADAPool) {\n    const [a, b] = await api.getPoolPrice({ pool: minADAPool });\n    console.log(\n      `ADA/MIN price: ${a.toString()}; MIN/ADA price: ${b.toString()}`\n    );\n    // we can later use this ID to call getPoolById\n    console.log(`ADA/MIN pool ID: ${minADAPool.id}`);\n    break;\n  }\n}\n```\n\n### Example 2: Get historical prices of MIN/ADA pool\n\n```ts\nimport { BlockFrostAPI } from \"@blockfrost/blockfrost-js\";\nimport { BlockfrostAdapter, NetworkId } from \"@minswap/sdk\";\n\nconst MIN_ADA_POOL_ID =\n  \"6aa2153e1ae896a95539c9d62f76cedcdabdcdf144e564b8955f609d660cf6a2\";\n\nconst api = new BlockfrostAdapter({\n  blockFrost: new BlockFrostAPI({\n    projectId: \"<your_project_id>\",\n    network: \"mainnet\",\n  }),\n});\nconst history = await api.getPoolHistory({ id: MIN_ADA_POOL_ID });\nfor (const historyPoint of history) {\n  const pool = await api.getPoolInTx({ txHash: historyPoint.txHash });\n  if (!pool) {\n    throw new Error(\"pool not found\");\n  }\n  const [price0, price1] = await api.getPoolPrice({\n    pool,\n    decimalsA: 6,\n    decimalsB: 6,\n  });\n  console.log(`${historyPoint.time}: ${price0} ADA/MIN, ${price1} MIN/ADA`);\n}\n```\n\n### Example 3: Build Order transaction and submit\n\nSee `examples/` for more details. You can run a single file like `npm run exec examples/example.ts`.\n","readmeFilename":"README.md"}