{"_id":"@0xcryptodev/sdk","name":"@0xcryptodev/sdk","dist-tags":{"latest":"1.1.6-beta.11"},"versions":{"1.1.6-beta.11":{"name":"@0xcryptodev/sdk","version":"1.1.6-beta.11","description":"JavaScript SDK for interacting with the Balancer Protocol V2","license":"GPL-3.0-only","homepage":"https://github.com/tenet-org/Sdk-Dextenet/blob/main/README.md","repository":{"type":"git","url":"git+https://github.com/tenet-org/Sdk-Dextenet.git","directory":"balancer-js"},"main":"dist/index.js","module":"dist/index.esm.js","browser":"dist/index.umd.js","typings":"dist/index.d.ts","scripts":{"address-book:generate":"npx ts-node -P tsconfig.testing.json -r tsconfig-paths/register ./src/lib/utils/generate-address-books.ts","build":"rimraf dist && rollup -c","dev":"rollup -c -w","test":"ts-mocha --paths --recursive -p tsconfig.testing.json 'src/**/*.spec.ts' --timeout 20000","test:only":"ts-mocha --paths --recursive -p tsconfig.testing.json --timeout 20000","lint":"eslint ./src --ext .ts --max-warnings 0","lint:fix":"eslint ./src --ext .ts --max-warnings 0 --fix","subgraph:generate":"graphql-codegen --config src/modules/subgraph/codegen.yml -r dotenv/config","example":"npx ts-node -P tsconfig.examples.json -r tsconfig-paths/register","node":"npx hardhat node --tsconfig tsconfig.testing.json --fork $(. ./.env && echo $ALCHEMY_URL)","node:goerli":"npx hardhat --tsconfig tsconfig.testing.json --config hardhat.config.goerli.ts node --fork $(. ./.env && echo $ALCHEMY_URL_GOERLI) --port 8000","node:polygon":"npx hardhat --tsconfig tsconfig.testing.json --config hardhat.config.polygon.ts node --fork $(. ./.env && echo $ALCHEMY_URL_POLYGON) --port 8137","node:arbitrum":"npx hardhat --tsconfig tsconfig.testing.json --config hardhat.config.arbitrum.ts node --fork $(. ./.env && echo $ALCHEMY_URL_ARBITRUM) --port 8161","node:gnosis":"npx hardhat --tsconfig tsconfig.testing.json --config hardhat.config.gnosis.ts node --fork $(. ./.env && echo $RPC_URL_GNOSIS) --port 8100","node:zkevm":"npx hardhat --tsconfig tsconfig.testing.json --config hardhat.config.zkevm.ts node --fork $(. ./.env && echo $ALCHEMY_URL_ZKEVM) --port 8101","node:avalanche":"npx hardhat --tsconfig tsconfig.testing.json --config hardhat.config.avalanche.ts node --fork $(. ./.env && echo $RPC_URL_AVALANCHE) --port 8114","typechain:generate":"npx typechain --target ethers-v5 --out-dir src/contracts './src/lib/abi/*.json'"},"devDependencies":{"@ethersproject/solidity":"^5.6.1","@ethersproject/units":"^5.7.0","@ethersproject/wallet":"^5.5.0","@graphql-codegen/add":"^3.1.0","@graphql-codegen/cli":"^2.3.0","@graphql-codegen/introspection":"^2.1.0","@graphql-codegen/schema-ast":"^2.4.0","@graphql-codegen/typescript":"2.4.0","@graphql-codegen/typescript-document-nodes":"^2.2.0","@graphql-codegen/typescript-graphql-request":"^4.3.0","@graphql-codegen/typescript-operations":"^2.2.0","@graphql-codegen/typescript-resolvers":"2.4.1","@nomicfoundation/hardhat-network-helpers":"^1.0.4","@nomiclabs/hardhat-ethers":"^2.0.5","@rollup/plugin-commonjs":"^21.0.1","@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^13.0.0","@rollup/plugin-typescript":"^8.2.1","@typechain/ethers-v5":"^10.2.0","@types/chai":"^4.2.12","@types/lodash":"^4.14.177","@types/mocha":"^8.0.3","@types/node":"^15.12.4","@typescript-eslint/eslint-plugin":"^4.1.1","@typescript-eslint/parser":"^4.1.1","axios-mock-adapter":"^1.21.2","chai":"^4.2.0","dotenv":"^10.0.0","eslint":"^7.9.0","eslint-plugin-mocha-no-only":"^1.1.1","eslint-plugin-prettier":"^3.1.4","ethers":"^5.0.0","fishery":"^2.2.2","hardhat":"^2.9.3","mocha":"^8.2.1","mockdate":"^3.0.5","prettier":"^2.1.2","rimraf":"^3.0.2","rollup":"^2.52.8","rollup-plugin-dts":"^3.0.2","rollup-plugin-terser":"^7.0.2","tiny-invariant":"^1.1.0","ts-mocha":"^9.0.2","ts-node":"^10.9.2","tsconfig-paths":"^3.14.1","typechain":"^8.1.1","typescript":"^4.0.2"},"dependencies":{"@balancer-labs/sor":"^4.1.1-beta.16","@ethersproject/abi":"^5.4.0","@ethersproject/abstract-signer":"^5.4.0","@ethersproject/address":"^5.4.0","@ethersproject/base64":"5.5.0","@ethersproject/bignumber":"^5.4.0","@ethersproject/bytes":"^5.4.0","@ethersproject/constants":"^5.4.0","@ethersproject/contracts":"^5.4.0","@ethersproject/providers":"^5.4.5","axios":"^0.24.0","graphql":"^15.6.1","graphql-request":"^3.5.0","json-to-graphql-query":"^2.2.4","lodash":"^4.17.21"},"directories":{"example":"examples"},"keywords":["tenet","testnet","sdk"],"author":"","bugs":{"url":"https://github.com/tenet-org/Sdk-Dextenet/issues"},"gitHead":"87fc38ec630d134cf58af34f2ec8939a9bb6d438","_id":"@0xcryptodev/sdk@1.1.6-beta.11","_nodeVersion":"18.16.0","_npmVersion":"9.4.1","dist":{"integrity":"sha512-+TVhJpVBoQk3tkLNPZefNPIv4xEr4WXmUimjfDRpCW0HfdEAbYcTR74xWVJRaZ2q+Qc+sYN2FFt5Fa0CD/fa8A==","shasum":"640bed0fd30986abf53bedff76bbbf43422fc3ca","tarball":"https://registry.npmjs.org/@0xcryptodev/sdk/-/sdk-1.1.6-beta.11.tgz","fileCount":2,"unpackedSize":8627,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIF0qiXN3VJIRY/C/zwIT7HCpsP7oTJT2z7uJnzLo8BlHAiEAy66RdXaJU6KxCrS4y9BSwlT0ViT9eUv01uTokIjs2Xc="}]},"_npmUser":{"name":"0xcryptodev","email":"xcryptodev@gmail.com"},"maintainers":[{"name":"0xcryptodev","email":"xcryptodev@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sdk_1.1.6-beta.11_1708697341175_0.9746235288815024"},"_hasShrinkwrap":false}},"time":{"created":"2024-02-23T14:09:01.092Z","1.1.6-beta.11":"2024-02-23T14:09:01.383Z","modified":"2024-02-23T14:09:01.978Z"},"maintainers":[{"name":"0xcryptodev","email":"xcryptodev@gmail.com"}],"description":"JavaScript SDK for interacting with the Balancer Protocol V2","homepage":"https://github.com/tenet-org/Sdk-Dextenet/blob/main/README.md","keywords":["tenet","testnet","sdk"],"repository":{"type":"git","url":"git+https://github.com/tenet-org/Sdk-Dextenet.git","directory":"balancer-js"},"bugs":{"url":"https://github.com/tenet-org/Sdk-Dextenet/issues"},"license":"GPL-3.0-only","readme":"# Balancer Javascript SDK\r\n\r\nA JavaScript SDK which provides commonly used utilties for interacting with Balancer Protocol V2.\r\n\r\n## How to run the examples (Javascript)?\r\n\r\n**In order to run the examples provided, you need to follow the next steps:**\r\n\r\n1. ```git clone https://github.com/balancer-labs/balancer-sdk.git```\r\n2. ```cd balancer-sdk```\r\n3. ```cd balancer-js```\r\n4. Create a .env file in the balancer-js folder\r\n5. In the .env file you will need to define and initialize the following variables\r\n\r\n   We have defined both Alchemy and Infura, because some of the examples use Infura, others use Alchemy. However, feel free to modify accordingly and use your favourite one.\r\n   ALCHEMY_URL=[ALCHEMY HTTPS ENDPOINT]  \r\n   INFURA=[Infura API KEY]  \r\n   TRADER_KEY=[MetaMask PRIVATE KEY]  \r\n   Some examples also require the following Tenderly config parameters to be defined:\r\n   TENDERLY_ACCESS_KEY=[TENDERLY API ACCESS KEY]\r\n   TENDERLY_PROJECT=[TENDERLY PROJECT NAME]\r\n   TENDERLY_USER=[TENDERLY USERNAME]\r\n\r\n6. Run 'npm run node', this runs a local Hardhat Network\r\n7. Open a new terminal\r\n8. cd to balancer-js\r\n9. Install ts-node using: ```npm install ts-node```\r\n10. Install tsconfig-paths using: ```npm install --save-dev tsconfig-paths```\r\n11. Generate contracts using: ```npm run typechain:generate```\r\n12. Run one of the provided examples (eg: npm run examples:run -- examples/join.ts)\r\n\r\n## Installation\r\n\r\n## Getting Started\r\n\r\n```js\r\nimport { BalancerSDK, BalancerSdkConfig, Network } from '@balancer-labs/sdk';\r\n\r\nconst config: BalancerSdkConfig = {\r\n  network: Network.MAINNET,\r\n  rpcUrl: `https://mainnet.infura.io/v3/${process.env.INFURA}`,\r\n};\r\nconst balancer = new BalancerSDK(config);\r\n```\r\n\r\nIn some examples we present a way to make end to end trades against mainnet state. To run them you will need to setup a localhost test node using tools like ganache, hardhat, anvil.\r\n\r\nInstallation instructions for:\r\n\r\n- [Hardhat](https://hardhat.org/getting-started/#installation)\r\n\r\n  To start a MAINNET forked node:\r\n\r\n  - Set env var: `ALCHEMY_URL=[ALCHEMY HTTPS ENDPOINT for MAINNET]`\r\n  - Run: `npm run node`\r\n\r\n  To start a GOERLI forked node:\r\n\r\n  - Set env var: `ALCHEMY_URL_GOERLI=[ALCHEMY HTTPS ENDPOINT for GOERLI]`\r\n  - Run: `npm run node:goerli`\r\n\r\n- [Anvil](https://github.com/foundry-rs/foundry/tree/master/anvil#installation) - use with caution, still experimental.\r\n\r\n  To start a forked node:\r\n\r\n  ```\r\n  anvil -f FORKABLE_RPC_URL (optional pinned block: --fork-block-number XXX)\r\n  ```\r\n\r\n## Swaps Module\r\n\r\nExposes complete functionality for token swapping. An example of using the module with data fetched from the subgraph:\r\n\r\n```js\r\n// Uses SOR to find optimal route for a trading pair and amount\r\nconst route = balancer.swaps.findRouteGivenIn({\r\n  tokenIn,\r\n  tokenOut,\r\n  amount,\r\n  gasPrice,\r\n  maxPools,\r\n});\r\n\r\n// Prepares transaction attributes based on the route\r\nconst transactionAttributes = balancer.swaps.buildSwap({\r\n  userAddress,\r\n  swapInfo: route,\r\n  kind: 0, // 0 - givenIn, 1 - givenOut\r\n  deadline,\r\n  maxSlippage,\r\n});\r\n\r\n// Extract parameters required for sendTransaction\r\nconst { to, data, value } = transactionAttributes;\r\n\r\n// Execution with ethers.js\r\nconst transactionResponse = await signer.sendTransaction({ to, data, value });\r\n```\r\n\r\n## SwapsService\r\n\r\nThe SwapsService provides function to query and make swaps using Balancer V2 liquidity.\r\n\r\n```js\r\nconst swaps = new swapService({\r\n  network: Network;\r\n  rpcUrl: string;\r\n});\r\n```\r\n\r\n## Examples\r\n\r\nYou can run each example with `npm run examples:run -- examples/swaps/swap.ts`\r\n","readmeFilename":"README.md"}