{"_id":"@aurora-balancer-labs/balancer-v2-pools","name":"@aurora-balancer-labs/balancer-v2-pools","dist-tags":{"latest":"0.0.14"},"versions":{"0.0.14":{"name":"@aurora-balancer-labs/balancer-v2-pools","version":"0.0.14","scripts":{"prepublishOnly":"tsc","test":"hardhat test"},"keywords":["balancer","v2","simulation"],"license":"MIT","dependencies":{"bignumber.js":"^9.0.1"},"devDependencies":{"@nomiclabs/hardhat-ethers":"^2.0.2","@nomiclabs/hardhat-waffle":"^2.0.1","@types/mocha":"^8.2.2","@types/node":"^15.6.1","chai":"^4.3.4","dotenv":"^10.0.0","ethereum-waffle":"^3.3.0","hardhat":"^2.3.0","npm-install-peers":"^1.2.2","ts-node":"^10.0.0","typescript":"^4.2.4"},"peerDependencies":{"@aurora-balancer-labs/v2-deployments":"^2.1.3","ethers":"^5.2.0","graphql":"^15.5.0","graphql-request":"^3.4.0"},"publishConfig":{"access":"public"},"main":"dist/src/index.js","types":"dist/src/index.d.ts","description":"<div align=\"center\">   <h2><code>balancer-v2-pools</code></h2> </div>","_id":"@aurora-balancer-labs/balancer-v2-pools@0.0.14","_nodeVersion":"16.15.1","_npmVersion":"8.11.0","dist":{"integrity":"sha512-v72t0rqjOMSMO0igVaq5K0pFb1KBThn67XQqmBU/MQ9IDuJicZdNx5Mg5zeG9WmdEU3BKbRzz4illLRlTHvVcQ==","shasum":"04542e53d24bd7ddb3f24c4d471f39d86c50f216","tarball":"https://registry.npmjs.org/@aurora-balancer-labs/balancer-v2-pools/-/balancer-v2-pools-0.0.14.tgz","fileCount":40,"unpackedSize":149749,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBLUX2SNF2FPk4MEiaRQwrqAmGg/m71doa6RT6f/3/8nAiEAuSmz3qBib3VD9hC5Iq6YiAP2Qs/Dp8TsryYEHONaGkY="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiwuviACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmocoA/9EQm7QX8N6D+0bJXJqRWvhA1na63u2wJSUyxDJ8N+NVanUYzM\r\n2w8ktdAypjTi8XxEKK85GThfc3UxEYj6WqVf+AV6zfyZBmaU9zIFZbD3Ga2S\r\n26z/hb8qA7s4nVEOqC6kKi39FbntbvTfTcJQr2XhEem9oSn+zXaHkFqSZpHd\r\n+CItsLdf1u7LM5CEoE8aMDYjq24659Od+xY/mrg5W9Az4giZ44QueslAI2dP\r\nrxjkZyeKrhgAK445lE8vyC+Pky3TLi4+nRxVE/lB34JaWs1kic+Z1L0CzTnQ\r\nT18IUOOiU9T1dUlwGgQ/gMzi0wjx5lIBeUC+QfTd74uLySUhKwx/gaVT34yR\r\nr75Kh2Rsi8KNE+JZ+ijnvTuTyrjeHggOBD/nr6AvBjOXd7hhwdqWFmEB8qjI\r\nk5fpmZIILmF+bjjaPNTP9ymsd8yW1PYs1VVEyvcBNo3SypWBQUbJrleBVz96\r\nTIy+ugVO/wzfinowlQpW7T8SkOjGjp4k9XrgwvytP2H0hZxgnClVSayQiBso\r\n7JOOci8SkZaiuNSbEYDV9l7zDe1AXRBRAvBsyGILcoFZRrBHFIYDOoYOPBFW\r\nG/uvZSpi+q0r1fEqUDfql91WlK1BADywjh2gbIWnGjLY+pmfVAYbY4vWodw+\r\nxlAD6xnOu+J0nHn13dWGAmYSevntMxK9Ucg=\r\n=keYQ\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"philipptaratuta","email":"philipp.t@blaize.tech"},"directories":{},"maintainers":[{"name":"philipptaratuta","email":"philipp.t@blaize.tech"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/balancer-v2-pools_0.0.14_1656941538581_0.7647264972085466"},"_hasShrinkwrap":false}},"time":{"created":"2022-07-04T13:32:18.522Z","0.0.14":"2022-07-04T13:32:18.753Z","modified":"2022-07-04T13:32:18.911Z"},"maintainers":[{"name":"philipptaratuta","email":"philipp.t@blaize.tech"}],"description":"<div align=\"center\">   <h2><code>balancer-v2-pools</code></h2> </div>","keywords":["balancer","v2","simulation"],"license":"MIT","readme":"<div align=\"center\">\n  <h2><code>balancer-v2-pools</code></h2>\n</div>\n\n<br/>\n\nSimple SDK for simulating the exact on-chain behaviour of various Balancer v2 pools.\n\n[![NPM](https://nodei.co/npm/@georgeroman/balancer-v2-pools.png?mini=true)](https://www.npmjs.com/package/@aurora-balancer-labs/balancer-v2-pools)\n\n### Install instructions\n\nThe SDK tries to be as lean as possible in order to prioritize certain critical usages (such as Balancer's SOR). For this reason, it only provides the bare-minimum for simulating Balancer pools off-chain. However, higher-level constructs (like initializing pools directly from on-chain data or the official Balancer subgraph) are still available. In order to be able to use these, make sure to install any peer dependencies of this package (eg. via [npm-install-peers](https://www.npmjs.com/package/npm-install-peers)).\n\n### Usage instructions\n\n```typescript\nimport { JsonRpcProvider } from \"@ethersproject/providers\";\nimport { WeightedPool } from \"@aurora-balancer-labs/balancer-v2-pools\";\nimport { initFromOnchain } from \"@aurora-balancer-labs/balancer-v2-pools/dist/src/initializers/weighted\";\n\nconst provider = new JsonRpcProvider(process.env.RPC_ENDPOINT);\n\n// WETH/DAI 60/40 on Mainnet\nconst pool = await initFromOnchain(\n  provider,\n  \"0x0b09dea16768f0799065c475be02919503cb2a3500020000000000000000001a\",\n  \"mainnet\"\n);\n\n// Swap\nconst amountOut = pool.swapGivenIn(\"WETH\", \"DAI\", \"100\");\n\n// Join\nconst bptOut = pool.joinExactTokensInForBptOut({\n  WETH: \"1\",\n  DAI: \"2000\",\n});\n\n// Exit\nconst tokensOut = pool.exitExactBptInForTokensOut(\"1.23\");\n```\n\n### Setup instructions\n\nMainnet forking is used for testing in order to make sure the SDK exactly match the EVM. Make sure to have a `.env` file in the root directory, containing the following definitions (the given block number must include the instances of the pools used in the tests):\n\n```bash\nRPC_URL=\nBLOCK_NUMBER=\n```\n\nThe setup I recommend for deterministic tests is the following:\n\n```bash\nRPC_URL=https://eth-mainnet.alchemyapi.io/v2/${ALCHEMY_KEY}\nBLOCK_NUMBER=13128465\n```\n\nTo execute the tests locally, simply run:\n\n```bash\n# Install dependencies\nnpm install\n\n# Run tests\nnpm test\n```\n","readmeFilename":"README.md"}