{"_id":"@ape.swap/swap-v2-sdk","_rev":"20-c14b008e512ef7afb833ac1369a2222e","name":"@ape.swap/swap-v2-sdk","dist-tags":{"latest":"0.0.1-alpha.0","alpha0":"0.0.1-alpha.0","alpha1":"0.0.1-alpha.1","alpha2":"0.0.1-alpha.2","alpha3":"0.0.1-alpha.3","alpha4":"0.0.1-alpha.4"},"versions":{"0.0.1-alpha.0":{"name":"@ape.swap/swap-v2-sdk","version":"0.0.1-alpha.0","license":"GPL-3.0-only","_id":"@ape.swap/swap-v2-sdk@0.0.1-alpha.0","maintainers":[{"name":"defifofum","email":"DeFiFoFum0@gmail.com"},{"name":"babadrape","email":"babadrape@gmail.com"},{"name":"ixm-759","email":"759ixm@gmail.com"},{"name":"obiedobo","email":"obiedobo@gmail.com"},{"name":"harambe-nakamoto","email":"harambeN@protonmail.com"},{"name":"justus_o","email":"justus.onuoha@innovationupstream.com"},{"name":"apeguru","email":"hello@apeswap.finance"}],"homepage":"https://github.com/ApeSwapFinance/apeswap-swap-v2-sdk/balancer-js#readme","bugs":{"url":"https://github.com/ApeSwapFinance/apeswap-swap-v2-sdk/issues"},"dist":{"shasum":"ee24a785be489b29da22b2456acb7f40fc6e0603","tarball":"https://registry.npmjs.org/@ape.swap/swap-v2-sdk/-/swap-v2-sdk-0.0.1-alpha.0.tgz","fileCount":11,"integrity":"sha512-gs2igyJqAdrzPiIe5kVz0RdU9u5NkGLH1TN3UzJxeoRQtWqM+6evTPhgAxPIho09r1R/Z9hR0EYWFhj0L7FiDA==","signatures":[{"sig":"MEYCIQD6wvwbsEjsIE99mzVAWNfmNhiotG0zNFUDK/YCzjBFyQIhAJzoW8joAYckeXN1aUTMDZ/j94WuQtFjgW/5+UenZs7F","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":3258938,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi0F+XACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqv2g//cT1uCXj8Uvexxdo3U5GTzYhsxls53WTIHogoLNHmdDuWtRth\r\nUavcpnOEiaxH9iiVfYH8vY3y1tPKkKtX/nvx95i/mPVNlGm9epHKZ+UXFyZV\r\npO0053yNx+KtGnLD7C7z4fu+04HFtB56ktFoCVGDseFyCltd+E9rT7PRvRSN\r\najZr2zvQL4k3Ne+ANGNQLN7F3Xw95ctu0rST5aKXBQ7+KNLt7nEHOj2iHj6b\r\n7UETB3Ob6Zis81Iz1G32VU0CJnUMD/EBF9Z2xHw9KCI40l11/E18TTRC9DXN\r\nHWhLAm0GmYlVoyFXN8XB9L7I8b+dpeBuFGjQjj07QFd7W8L2UDPmHXzU6tD1\r\nGUz3zaQG8ZfR0q2gUMvMHizIry+D48AK9jP6dqQOhczjbgiphaCz3tx634dF\r\nhHBn8NqLkB2IYFdzIIc90OKgL9wkfDbFklW1yuPYtKparLrvSRuOYU1RNVHs\r\nZAlIWl5WjmLqm9Mhr7wMC5BfxGahCdTtgie6Ifmn4sIhIq5n+fmD3E+IWzt2\r\nPGapOFWy+GGMuTj4aJ2Dgyrp8j5qMaDEyDiQppkIrqWITKXkjGEodKu3kxPc\r\nrcHwWm1FN3Bp4+1B0acCoTyJI5yFYykHKquRUuDM0ecgJryvxXPvKX42eJ8f\r\ncmCGBt3xqMdgyMB8RVF6Sa3zxZrqnWIl8KM=\r\n=q7Ij\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","module":"dist/index.esm.js","browser":"dist/index.umd.js","scripts":{"dev":"rollup -c -w","lint":"eslint ./src --ext .ts --max-warnings 0","node":"npx hardhat node --fork $(grep ALCHEMY_URL .env | cut -d '=' -f2) --fork-block-number 14828550","test":"ts-mocha --paths --recursive -p tsconfig.testing.json 'src/**/*.spec.ts'","build":"rimraf dist && rollup -c","lint:fix":"eslint ./src --ext .ts --max-warnings 0 --fix","test:only":"ts-mocha --paths --recursive -p tsconfig.testing.json","examples:run":"TS_NODE_PROJECT='tsconfig.testing.json' ts-node -r tsconfig-paths/register","subgraph:generate":"graphql-codegen --config src/modules/subgraph/codegen.yml -r dotenv/config"},"typings":"dist/index.d.ts","_npmUser":{"name":"defifofum","email":"DeFiFoFum0@gmail.com"},"repository":{"url":"https://github.com/ApeSwapFinance/apeswap-swap-v2-sdk","type":"git","directory":"balancer-js"},"description":"JavaScript SDK for interacting with the Balancer Protocol V2","directories":{},"dependencies":{"axios":"^0.24.0","lodash":"^4.17.21","graphql":"^15.6.1","bignumber.js":"^9.0.2","graphql-request":"^3.5.0","@balancer-labs/sor":"^4.0.1-beta.1","@balancer-labs/typechain":"^1.0.0"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.2.0","mocha":"^8.2.1","dotenv":"^10.0.0","eslint":"^7.9.0","ethers":"^5.0.0","rimraf":"^3.0.2","rollup":"^2.52.8","fishery":"^2.2.2","hardhat":"^2.9.3","ts-node":"^10.4.0","prettier":"^2.1.2","ts-mocha":"^9.0.2","typechain":"^5.1.1","typescript":"^4.0.2","@types/chai":"^4.2.12","@types/node":"^15.12.4","@types/mocha":"^8.0.3","@types/lodash":"^4.14.177","tiny-invariant":"^1.1.0","tsconfig-paths":"^3.12.0","rollup-plugin-dts":"^3.0.2","@ethersproject/abi":"^5.4.0","@rollup/plugin-json":"^4.1.0","@ethersproject/bytes":"^5.4.0","@graphql-codegen/add":"^3.1.0","@graphql-codegen/cli":"^2.3.0","@typechain/ethers-v5":"^7.0.1","@ethersproject/wallet":"^5.5.0","@ethersproject/address":"^5.4.0","eslint-plugin-prettier":"^3.1.4","@ethersproject/solidity":"^5.6.1","@rollup/plugin-commonjs":"^21.0.1","@ethersproject/bignumber":"^5.4.0","@ethersproject/constants":"^5.4.0","@ethersproject/contracts":"^5.4.0","@ethersproject/providers":"^5.4.5","@nomiclabs/hardhat-ethers":"^2.0.5","@rollup/plugin-typescript":"^8.2.1","@typescript-eslint/parser":"^4.1.1","@graphql-codegen/schema-ast":"^2.4.0","@graphql-codegen/typescript":"2.4.0","@rollup/plugin-node-resolve":"^13.0.0","eslint-plugin-mocha-no-only":"^1.1.1","@ethersproject/abstract-signer":"^5.4.0","@georgeroman/balancer-v2-pools":"^0.0.5","@graphql-codegen/introspection":"^2.1.0","@typescript-eslint/eslint-plugin":"^4.1.1","@graphql-codegen/typescript-resolvers":"2.4.1","@graphql-codegen/typescript-operations":"^2.2.0","@graphql-codegen/typescript-document-nodes":"^2.2.0","@graphql-codegen/typescript-graphql-request":"^4.3.0"},"peerDependencies":{"@ethersproject/abi":"^5.4.0","@ethersproject/bytes":"^5.4.0","@ethersproject/address":"^5.4.0","@ethersproject/bignumber":"^5.4.0","@ethersproject/constants":"^5.4.0","@ethersproject/contracts":"^5.4.0","@ethersproject/providers":"^5.4.5","@ethersproject/abstract-signer":"^5.4.0"},"_npmOperationalInternal":{"tmp":"tmp/swap-v2-sdk_0.0.1-alpha.0_1657823127026_0.08909818323328977","host":"s3://npm-registry-packages"}},"0.0.1-alpha.1":{"name":"@ape.swap/swap-v2-sdk","version":"0.0.1-alpha.1","license":"GPL-3.0-only","_id":"@ape.swap/swap-v2-sdk@0.0.1-alpha.1","maintainers":[{"name":"defifofum","email":"DeFiFoFum0@gmail.com"},{"name":"babadrape","email":"babadrape@gmail.com"},{"name":"ixm-759","email":"759ixm@gmail.com"},{"name":"obiedobo","email":"obiedobo@gmail.com"},{"name":"harambe-nakamoto","email":"harambeN@protonmail.com"},{"name":"justus_o","email":"justus.onuoha@innovationupstream.com"},{"name":"apeguru","email":"hello@apeswap.finance"}],"homepage":"https://github.com/ApeSwapFinance/apeswap-swap-v2-sdk/balancer-js#readme","bugs":{"url":"https://github.com/ApeSwapFinance/apeswap-swap-v2-sdk/issues"},"dist":{"shasum":"b0535f3e57d26ce01be33c0f1ce4eb2cf780d68f","tarball":"https://registry.npmjs.org/@ape.swap/swap-v2-sdk/-/swap-v2-sdk-0.0.1-alpha.1.tgz","fileCount":11,"integrity":"sha512-+meiuA9UJ4qpQSmOO6qbRWmrL/EAYCQKiPHTgAVSbs93KDXtiufb/B6HZqiV0o8h2mjmFtSMo4ThDxeCwo+7ow==","signatures":[{"sig":"MEQCIGUlH/er1HWXh7itWEXc7/bGfXue6Y8QWo3yECSBSduWAiA2YGsPzeUl+BJz161UKRd3jBMAU98ieuYbtdUMvVmcIw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":3258938,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi4WZTACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpiMw/9G9xhg4kdE0kMm2Waj+ji6FnIefSnnyyP49jrXEaZh+Brxyde\r\nWu2bb4NZLzTacV+GTHQ77YuTG/8gYBcZIR80HDHiYPb4RM0wuJz7GjImCY5T\r\nhMVYlnS5LUCIsvbFacIxRmLSvPTnfr9zqj7S7aJ/w1ppTZRLYlMhF+QWmv2J\r\nur9VHVLpO5hN3LhOgvc8JHTP15u0/fBcamuVSQ5nqeXh39i5ZBx4Z1lFLMri\r\nZLz8+ekSSRFyL6I+tZg1IgZz+pkimlVctHbUJa2tGBb9413jGn6F9XF8pYPr\r\nE6zwqbsSThkbHp/QDNUXs/MFUHhYiKZbPLjnnt0PBwvm1x4jcgyjHJsKL6vc\r\n2F4mFjUPaGT3e/ETRmKSpg5jJHIPetBZe6BRV41mFP/NZf60ROozUF7I6nMo\r\nwhieESjQbAqC2paAGVBqP11+Bg68Uu475ihASutQ/cLtakaCaTTAkcnM5pLw\r\nHOa+dmXI41w3ZBzb+FW1gDN1vLUcnmmObQi9POapth87SyAWSPAm8PLZ5lTR\r\nE59Gk2F/+gyV2355ZUwxV85e/Ok6xyRdToFaUU9WP3e9W6w8ZnbOo66spWfs\r\nOqbyewXSEIHWpnFhPskIUcgKdkcOfRzMmeeUq80TyvHzKQTRDGcS+ayy4tkV\r\nY5ruoUDaeNVitIshAO+637TRZ2MS6qGmeVM=\r\n=D6hR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","module":"dist/index.esm.js","readme":"# Balancer Javascript SDK\n\nA JavaScript SDK which provides commonly used utilities for interacting with Balancer Protocol V2.\n\n## Installation\n\n## Getting Started\n\n```js\nimport { BalancerSDK, BalancerSdkConfig, Network } from '@balancer-labs/sdk';\n\nconst config: BalancerSdkConfig = {\n    network: Network.MAINNET,\n    rpcUrl: `https://kovan.infura.io/v3/${process.env.INFURA}`,\n};\nconst balancer = new BalancerSDK(config);\n```\n\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.\n\nInstallation instructions for:\n\n* [Hardhat](https://hardhat.org/getting-started/#installation)\n\n  To start a forked node:\n  ```\n  npm run node\n  ```\n\n* [Anvil](https://github.com/foundry-rs/foundry/tree/master/anvil#installation) - use with caution, still experimental.\n  \n  To start a forked node:\n  ```\n  anvil -f FORKABLE_RPC_URL (optional pinned block: --fork-block-number XXX)\n  ```\n\n## Swaps Module\n\nExposes complete functionality for token swapping. An example of using the module with data fetched from the subgraph:\n\n```js\n// Uses SOR to find optimal route for a trading pair and amount\nconst route = balancer.swaps.findRouteGivenIn({\n    tokenIn,\n    tokenOut,\n    amount,\n    gasPrice,\n    maxPools,\n})\n\n// Prepares transaction attributes based on the route\nconst transactionAttributes = balancer.swaps.buildSwap({\n    userAddress,\n    swapInfo: route,\n    kind: 0, // 0 - givenIn, 1 - givenOut\n    deadline,\n    maxSlippage,\n})\n\n// Extract parameters required for sendTransaction\nconst { to, data, value } = transactionAttributes\n\n// Execution with ethers.js\nconst transactionResponse = await signer.sendTransaction({ to, data, value })\n```\n\n\n## SwapsService\n\nThe SwapsService provides function to query and make swaps using Balancer V2 liquidity.\n\n```js\nconst swaps = new swapService({\n  network: Network;\n  rpcUrl: string;\n});\n```\n\n## Examples\n\nYou can run each example with `npm run examples:run -- examples/exampleName.ts`\n\n### #queryBatchSwap\n\nThe Balancer Vault provides a [method to simulate a call to batchSwap](https://github.com/balancer-labs/balancer-v2-monorepo/blob/master/pkg/vault/contracts/interfaces/IVault.sol#L644).\nThis function performs no checks on the sender or recipient or token balances or approvals. Note that this function is not 'view' (due to implementation details): the client code must explicitly execute eth_call instead of eth_sendTransaction.\n\n@param batchSwap - BatchSwap information used for query.\n@param batchSwap.kind - either exactIn or exactOut.\n@param batchSwap.swaps - sequence of swaps.\n@param batchSwap.assets - array contains the addresses of all assets involved in the swaps.\n@returns Returns an array with the net Vault asset balance deltas. Positive amounts represent tokens (or ETH) sent to the Vault, and negative amounts represent tokens (or ETH) sent by the Vault. Each delta corresponds to the asset at the same index in the `assets` array.\n\n```js\nswaps.queryBatchSwap(batchSwap: {\n    kind: SwapType,\n    swaps: BatchSwapStep[],\n    assets: string[]\n}): Promise<BigNumberish[]>\n```\n\n[Example](./examples/queryBatchSwap.ts)\n\n### #queryBatchSwapWithSor\n\nUses SOR to create and query a batchSwap for multiple tokens in > multiple tokensOut.\n\n@param queryWithSor - Swap information used for querying using SOR.\n@param queryWithSor.tokensIn - Array of addresses of assets in.\n@param queryWithSor.tokensOut - Array of addresses of assets out.\n@param queryWithSor.swapType - Type of Swap, ExactIn/Out.\n@param queryWithSor.amounts - Array of amounts used in swap.\n@param queryWithSor.fetchPools - Set whether SOR will fetch updated pool info.\n@returns Returns amount of tokens swaps along with swap and asset info that can be submitted to a batchSwap call.\n\n```js\nswaps.queryBatchSwapWithSor(queryWithSor: {\n    tokensIn: string[],\n    tokensOut: string[],\n    swapType: SwapType,\n    amounts: BigNumberish[],\n    fetchPools: FetchPoolsInput;\n}):\nPromise<QueryWithSorOutput {\n    returnAmounts: string[];\n    swaps: BatchSwapStep[];\n    assets: string[];\n    deltas: string[];\n}>\n```\n\n### #encodeBatchSwap\n\nStatic method to encode a [batch swap](https://dev.balancer.fi/references/contracts/apis/the-vault#batch-swaps).\n\n_NB: This method doesn't execute a batchSwap -- it returns an [ABI byte string](https://docs.soliditylang.org/en/latest/abi-spec.html) containing the data of the function call on a contract, which can then be sent to the network (ex. [sendTransaction](https://web3js.readthedocs.io/en/v1.2.11/web3-eth.html#sendtransaction)). to be executed. See example for more info._\n\n```js\n/**\n * @param {BatchSwap}           batchSwap - BatchSwap information used for query.\n * @param {SwapType}            batchSwap.kind - either exactIn or exactOut\n * @param {BatchSwapSteps[]}    batchSwap.swaps - sequence of swaps\n * @param {string[]}            batchSwap.assets - array contains the addresses of all assets involved in the swaps\n * @param {FundManagement}      batchSwap.funds - object containing information about where funds should be taken/sent\n * @param {number[]}            batchSwap.limits - limits for each token involved in the swap, where either the maximum number of tokens to send (by passing a positive value) or the minimum amount of tokens to receive (by passing a negative value) is specified\n * @param {string}              batchSwap.deadline -  time (in Unix timestamp) after which it will no longer attempt to make a trade\n * @returns {string}            encodedBatchSwapData - Returns an ABI byte string containing the data of the function call on a contract\n*/\nSwaps.encodeBatchSwap(batchSwap: {\n    kind: SwapType,\n    swaps: BatchSwapStep[],\n    assets: string[],\n    funds: FundManagement,\n    limits: number[],\n    deadline: string\n}): string\n```\n\n[Example](./examples/batchSwap.ts)\n\n### Swap Service: Flash Swaps\n\nA [Flash Swap](https://dev.balancer.fi/resources/swaps/flash-swaps) is a special type of [batch swap](https://dev.balancer.fi/resources/swaps/batch-swaps) where the caller doesn't need to own or provide any of the input tokens -- the caller is essentially taking a \"flash loan\" (an uncollateralized loan) from the Balancer Vault. The full amount of the input token must be returned to the Vault by the end of the batch (plus any swap fees), however any excess of an output tokens can be sent to any address.\n\nIMPORTANT: A \"simple\" flash swap is an arbitrage executed with only two tokens and two pools,\nswapping in the first pool and then back in the second pool for a profit. For more\ncomplex flash swaps, you will have to use batch swap directly.\n\nGotchas:\n\n-   Both pools must have both assets (tokens) for swaps to work\n-   No pool token balances can be zero\n-   If the flash swap isn't profitable, the internal flash loan will fail.\n\n### #encodeSimpleFlashSwap\n\nStatic method to encode a simple flash swap [method for a batchSwap](https://dev.balancer.fi/resources/swaps/flash-swaps).\n\n_NB: This method doesn't execute any swaps -- it returns an [ABI byte string](https://docs.soliditylang.org/en/latest/abi-spec.html) containing the data of the function call on a contract, which can then be sent to the network (ex. [sendTransaction](https://web3js.readthedocs.io/en/v1.2.11/web3-eth.html#sendtransaction)). to be executed. See example for more info._\n\n```js\n/**\n * @param {SimpleFlashSwapParameters}   params - BatchSwap information used for query.\n * @param {string}                      params.flashLoanAmount - initial input amount for the flash loan (first asset)\n * @param {string[]}                    params.poolIds - array of Balancer pool ids\n * @param {string[]}                    params.assets - array of token addresses\n * @param {string}                      params.walletAddress - array of token addresses\n * @returns {string}            encodedBatchSwapData - Returns an ABI byte string containing the data of the function call on a contract\n*/\nSwaps.encodeSimpleFlashSwap(simpleFlashSwap: {\n    flashLoanAmount: string,\n    poolIds: string[],\n    assets: string[]\n    walletAddress: string[]\n}): string\n```\n\n[Example](./examples/flashSwap.ts)\n\n### #querySimpleFlashSwap\n\nMethod to test if a simple flash swap is valid and see potential profits.\n\n```js\n/**\n * @param {SimpleFlashSwapParameters}   params - BatchSwap information used for query.\n * @param {string}                      params.flashLoanAmount - initial input amount for the flash loan (first asset)\n * @param {string[]}                    params.poolIds - array of Balancer pool ids\n * @param {string[]}                    params.assets - array of token addresses\n * @returns {Promise<{profits: Record<string, string>, isProfitable: boolean}>}       Returns an ethersjs transaction response\n*/\nswaps.querySimpleFlashSwap(batchSwap: {\n    kind: SwapType,\n    swaps: BatchSwapStep[],\n    assets: string[]\n}): string\n```\n\n[Example](./examples/querySimpleFlashSwap.ts)\n\n## Pricing Module\n\nExposes Spot Price functionality allowing user to query spot price for token pair.\n\n```js\nconst pricing = new Pricing(sdkConfig);\n```\n\n### #getSpotPrice\n\nCalculates Spot Price for a token pair - for specific pool if ID otherwise finds most liquid path and uses this as reference SP.\n\n@param { string } tokenIn Token in address.\n@param { string } tokenOut Token out address.\n@param { string } poolId Optional - if specified this pool will be used for SP calculation.\n@param { SubgraphPoolBase[] } pools Optional - Pool data. Will be fetched via dataProvider if not supplied.\n@returns  { string } Spot price.\n\n```js\nasync getSpotPrice(\n    tokenIn: string,\n    tokenOut: string,\n    poolId = '',\n    pools: SubgraphPoolBase[] = []\n): Promise<string>\n```\n\n[Example](./examples/spotPrice.ts)\n\n## Join Pool\n\nExposes Join functionality allowing user to join pools.\n\n```js\nconst balancer = new BalancerSDK(sdkConfig);\nconst pool = await balancer.poolsProvider.find(poolId);\nconst { to, functionName, attributes, data } = pool.buildJoin(params);\n```\n\n### #buildJoin\n\nBuilds a join transaction.\n\n```js\n/**\n * @param { string }   joiner - Address used to exit pool.\n * @param { string[] } tokensIn - Token addresses provided for joining pool (same length and order as amountsIn).\n * @param { string[] } amountsIn - Token amounts provided for joining pool in EVM amounts.\n * @param { string }   slippage - Maximum slippage tolerance in bps i.e. 50 = 0.5%.\n * @returns { Promise<JoinPoolAttributes> } Returns join transaction ready to send with signer.sendTransaction.\n*/\nbuildJoin: (\n  joiner: string,\n  tokensIn: string[],\n  amountsIn: string[],\n  slippage: string\n) => Promise<JoinPoolAttributes>;\n```\n\n[Example](./examples/join.ts)\n\n## RelayerService\n\nRelayers are (user opt-in, audited) contracts that can make calls to the vault (with the transaction “sender” being any arbitrary address) and use the sender’s ERC20 vault allowance, internal balance or BPTs on their behalf.\n\n```js\nconst relayer = new relayerService(\n    swapsService: SwapsService;\n    rpcUrl: string;\n);\n```\n\n### #swapUnwrapAaveStaticExactIn\n\nFinds swaps for tokenIn>wrapped Aave static tokens and chains with unwrap to underlying stable. ExactIn - Exact amount of tokenIn to use in swap.\n\n@param tokensIn - array to token addresses for swapping as tokens in.\n@param aaveStaticTokens - array contains the addresses of the Aave static tokens that tokenIn will be swapped to. These will be unwrapped.\n@param amountsIn - amounts to be swapped for each token in.\n@param rates - The rate used to convert wrappedToken to underlying.\n@param funds - Funding info for swap. Note - recipient should be relayer and sender should be caller.\n@param slippage - Slippage to be applied to swap section. i.e. 5%=50000000000000000.\n@param fetchPools - Set whether SOR will fetch updated pool info.\n@returns Transaction data with calldata. Outputs.amountsOut has final amounts out of unwrapped tokens.\n\n```js\nasync relayer.swapUnwrapAaveStaticExactIn(\n    tokensIn: string[],\n    aaveStaticTokens: string[],\n    amountsIn: BigNumberish[],\n    rates: BigNumberish[],\n    funds: FundManagement,\n    slippage: BigNumberish,\n    fetchPools: FetchPoolsInput = {\n        fetchPools: true,\n        fetchOnChain: false\n    }\n): Promise<TransactionData>\n```\n\n[Example](./examples/relayerSwapUnwrap.ts)\n\n### #swapUnwrapAaveStaticExactOut\n\nFinds swaps for tokenIn>wrapped Aave static tokens and chains with unwrap to underlying stable. ExactOut - Exact amount of tokens out are used for swaps.\n\n@param tokensIn - array to token addresses for swapping as tokens in.\n@param aaveStaticTokens - array contains the addresses of the Aave static tokens that tokenIn will be swapped to. These will be unwrapped.\n@param amountsUnwrapped - amounts of unwrapped tokens out.\n@param rates - The rate used to convert wrappedToken to underlying.\n@param funds - Funding info for swap. Note - recipient should be relayer and sender should be caller.\n@param slippage - Slippage to be applied to swap section. i.e. 5%=50000000000000000.\n@param fetchPools - Set whether SOR will fetch updated pool info.\n@returns Transaction data with calldata. Outputs.amountsIn has the amounts of tokensIn.\n\n```js\nasync relayer.swapUnwrapAaveStaticExactOut(\n    tokensIn: string[],\n    aaveStaticTokens: string[],\n    amountsUnwrapped: BigNumberish[],\n    rates: BigNumberish[],\n    funds: FundManagement,\n    slippage: BigNumberish,\n    fetchPools: FetchPoolsInput = {\n        fetchPools: true,\n        fetchOnChain: false\n    }\n): Promise<TransactionData>\n```\n\n[Example](./examples/relayerSwapUnwrap.ts)\n\n### #exitPoolAndBatchSwap\n\nChains poolExit with batchSwap to final tokens.\n\n@param params:\n@param exiter - Address used to exit pool.\n@param swapRecipient - Address that receives final tokens.\n@param poolId - Id of pool being exited.\n@param exitTokens - Array containing addresses of tokens to receive after exiting pool. (must have the same length and order as the array returned by `getPoolTokens`.)\n@param userData - Encoded exitPool data.\n@param minExitAmountsOut - Minimum amounts of exitTokens to receive when exiting pool.\n@param finalTokensOut - Array containing the addresses of the final tokens out.\n@param slippage - Slippage to be applied to swap section. i.e. 5%=50000000000000000.\n@param fetchPools - Set whether SOR will fetch updated pool info.\n@returns Transaction data with calldata. Outputs.amountsOut has amounts of finalTokensOut returned.\n\n```js\nasync relayer.exitPoolAndBatchSwap(\n    params: ExitAndBatchSwapInput {\n        exiter: string;\n        swapRecipient: string;\n        poolId: string;\n        exitTokens: string[];\n        userData: string;\n        minExitAmountsOut: string[];\n        finalTokensOut: string[];\n        slippage: string;\n        fetchPools: FetchPoolsInput;\n    }\n): Promise<TransactionData>\n```\n\n[Example](./examples/relayerExitPoolAndBatchSwap.ts)\n\n## Licensing\n\n[GNU General Public License Version 3 (GPL v3)](../../LICENSE).\n","browser":"dist/index.umd.js","scripts":{"dev":"rollup -c -w","lint":"eslint ./src --ext .ts --max-warnings 0","node":"npx hardhat node --fork $(grep ALCHEMY_URL .env | cut -d '=' -f2) --fork-block-number 14828550","test":"ts-mocha --paths --recursive -p tsconfig.testing.json 'src/**/*.spec.ts'","build":"rimraf dist && rollup -c","lint:fix":"eslint ./src --ext .ts --max-warnings 0 --fix","test:only":"ts-mocha --paths --recursive -p tsconfig.testing.json","examples:run":"TS_NODE_PROJECT='tsconfig.testing.json' ts-node -r tsconfig-paths/register","subgraph:generate":"graphql-codegen --config src/modules/subgraph/codegen.yml -r dotenv/config"},"typings":"dist/index.d.ts","_npmUser":{"name":"defifofum","email":"DeFiFoFum0@gmail.com"},"repository":{"url":"https://github.com/ApeSwapFinance/apeswap-swap-v2-sdk","type":"git","directory":"balancer-js"},"description":"JavaScript SDK for interacting with the Balancer Protocol V2","directories":{},"dependencies":{"axios":"^0.24.0","lodash":"^4.17.21","graphql":"^15.6.1","bignumber.js":"^9.0.2","graphql-request":"^3.5.0","@balancer-labs/sor":"^4.0.1-beta.1","@balancer-labs/typechain":"^1.0.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","mocha":"^8.2.1","dotenv":"^10.0.0","eslint":"^7.9.0","ethers":"^5.0.0","rimraf":"^3.0.2","rollup":"^2.52.8","fishery":"^2.2.2","hardhat":"^2.9.3","ts-node":"^10.4.0","prettier":"^2.1.2","ts-mocha":"^9.0.2","typechain":"^5.1.1","typescript":"^4.0.2","@types/chai":"^4.2.12","@types/node":"^15.12.4","@types/mocha":"^8.0.3","@types/lodash":"^4.14.177","tiny-invariant":"^1.1.0","tsconfig-paths":"^3.12.0","rollup-plugin-dts":"^3.0.2","@ethersproject/abi":"^5.4.0","@rollup/plugin-json":"^4.1.0","@ethersproject/bytes":"^5.4.0","@graphql-codegen/add":"^3.1.0","@graphql-codegen/cli":"^2.3.0","@typechain/ethers-v5":"^7.0.1","@ethersproject/wallet":"^5.5.0","@ethersproject/address":"^5.4.0","eslint-plugin-prettier":"^3.1.4","@ethersproject/solidity":"^5.6.1","@rollup/plugin-commonjs":"^21.0.1","@ethersproject/bignumber":"^5.4.0","@ethersproject/constants":"^5.4.0","@ethersproject/contracts":"^5.4.0","@ethersproject/providers":"^5.4.5","@nomiclabs/hardhat-ethers":"^2.0.5","@rollup/plugin-typescript":"^8.2.1","@typescript-eslint/parser":"^4.1.1","@graphql-codegen/schema-ast":"^2.4.0","@graphql-codegen/typescript":"2.4.0","@rollup/plugin-node-resolve":"^13.0.0","eslint-plugin-mocha-no-only":"^1.1.1","@ethersproject/abstract-signer":"^5.4.0","@georgeroman/balancer-v2-pools":"^0.0.5","@graphql-codegen/introspection":"^2.1.0","@typescript-eslint/eslint-plugin":"^4.1.1","@graphql-codegen/typescript-resolvers":"2.4.1","@graphql-codegen/typescript-operations":"^2.2.0","@graphql-codegen/typescript-document-nodes":"^2.2.0","@graphql-codegen/typescript-graphql-request":"^4.3.0"},"peerDependencies":{"@ethersproject/abi":"^5.4.0","@ethersproject/bytes":"^5.4.0","@ethersproject/address":"^5.4.0","@ethersproject/bignumber":"^5.4.0","@ethersproject/constants":"^5.4.0","@ethersproject/contracts":"^5.4.0","@ethersproject/providers":"^5.4.5","@ethersproject/abstract-signer":"^5.4.0"},"_npmOperationalInternal":{"tmp":"tmp/swap-v2-sdk_0.0.1-alpha.1_1658938963198_0.6936359415470881","host":"s3://npm-registry-packages"}},"0.0.1-alpha.2":{"name":"@ape.swap/swap-v2-sdk","version":"0.0.1-alpha.2","license":"GPL-3.0-only","_id":"@ape.swap/swap-v2-sdk@0.0.1-alpha.2","maintainers":[{"name":"defifofum","email":"DeFiFoFum0@gmail.com"},{"name":"babadrape","email":"babadrape@gmail.com"},{"name":"ixm-759","email":"759ixm@gmail.com"},{"name":"obiedobo","email":"obiedobo@gmail.com"},{"name":"harambe-nakamoto","email":"harambeN@protonmail.com"},{"name":"justus_o","email":"justus.onuoha@innovationupstream.com"},{"name":"apeguru","email":"hello@apeswap.finance"}],"homepage":"https://github.com/ApeSwapFinance/apeswap-swap-v2-sdk/balancer-js#readme","bugs":{"url":"https://github.com/ApeSwapFinance/apeswap-swap-v2-sdk/issues"},"dist":{"shasum":"1b77cc6c0925c784cde8905148dd1f5c2fc1d44c","tarball":"https://registry.npmjs.org/@ape.swap/swap-v2-sdk/-/swap-v2-sdk-0.0.1-alpha.2.tgz","fileCount":11,"integrity":"sha512-4m1ej5ciIU0nc3TZBOLSb+ubES5TAwvglnNrACgRSBNwWER7l5c6cf+fhhKmyqYv6tGuc03waXo47BV2He5cOQ==","signatures":[{"sig":"MEUCIBI+wg/flzA0Pi26lfL2TvGtJULpZCdZ2fQ9lzAwMQ6dAiEA/p1Td6ZJHcLlLueeMIjQ4tkrNroXQdkRkGMeD5m2/Sw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":3264080,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi4XAcACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqKHw/+PQRAx4hJVNh7wWMA41pKDxzzqtVOVwpKt6BMsebKBikg7uBy\r\n7PmRBFjJVwUjJHpUD1EUdV1ZWwsPSbauXlv4q8ADAqrSNG+ArDqv9RoNIdRD\r\npYcfSqTGdLiCVb5xN9FNE0HmxcuhpYdogWPiNhIwmCGGNihB0Ecx3VePeILl\r\noNfVR7OVCteVrsUNxo1v+rV8z2/iLclSbHpDzekMjGv3iWLh1zqO2awMBGXO\r\nr3ZCkXfzDGbQ+VC/3MDQFwbbXL3npKz/ytSJClV/hy8m5BZ5i/uUtQ/m7ZCL\r\n+Gqtk00kP4fECrVdfcHOKgPC8Ezopi6pMx5cIVfYU2NBGxNgtqdb/FW5U1M/\r\nokoMvB+h94vCCU54ygeczVgxBwHEaPF9eOtI2KtyItFuM7lEGE7dDqkCh30x\r\nwZrXbh3D56Xcf/z2GIbBDTJFIqK8MOEdqgAYmZU5uFo+VkTL3zQNqc2p/haX\r\npQ4fqmo2IPjJ5BBhhQsd72po5C4cLUF8qO1kFc4gTYc+usgzREukc2z7qwaB\r\nUZjU+KDFgh+xEBM1ncNwdkWm7f9L1qYbWkfRzMHNzab8hQfRyczMrop6ZSY2\r\n1VKVFDgzBZra/35/EMg4f9IsC2VbZR4ZFNEq3/hjuXHYCTBQEMAT1YiDrEZw\r\nZtSkp4XXbUGgmcD8oU8EAZA7y4j66U2rvJM=\r\n=sfF0\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","module":"dist/index.esm.js","readme":"# Balancer Javascript SDK\n\nA JavaScript SDK which provides commonly used utilities for interacting with Balancer Protocol V2.\n\n## Installation\n\n## Getting Started\n\n```js\nimport { BalancerSDK, BalancerSdkConfig, Network } from '@balancer-labs/sdk';\n\nconst config: BalancerSdkConfig = {\n    network: Network.MAINNET,\n    rpcUrl: `https://kovan.infura.io/v3/${process.env.INFURA}`,\n};\nconst balancer = new BalancerSDK(config);\n```\n\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.\n\nInstallation instructions for:\n\n* [Hardhat](https://hardhat.org/getting-started/#installation)\n\n  To start a forked node:\n  ```\n  npm run node\n  ```\n\n* [Anvil](https://github.com/foundry-rs/foundry/tree/master/anvil#installation) - use with caution, still experimental.\n  \n  To start a forked node:\n  ```\n  anvil -f FORKABLE_RPC_URL (optional pinned block: --fork-block-number XXX)\n  ```\n\n## Swaps Module\n\nExposes complete functionality for token swapping. An example of using the module with data fetched from the subgraph:\n\n```js\n// Uses SOR to find optimal route for a trading pair and amount\nconst route = balancer.swaps.findRouteGivenIn({\n    tokenIn,\n    tokenOut,\n    amount,\n    gasPrice,\n    maxPools,\n})\n\n// Prepares transaction attributes based on the route\nconst transactionAttributes = balancer.swaps.buildSwap({\n    userAddress,\n    swapInfo: route,\n    kind: 0, // 0 - givenIn, 1 - givenOut\n    deadline,\n    maxSlippage,\n})\n\n// Extract parameters required for sendTransaction\nconst { to, data, value } = transactionAttributes\n\n// Execution with ethers.js\nconst transactionResponse = await signer.sendTransaction({ to, data, value })\n```\n\n\n## SwapsService\n\nThe SwapsService provides function to query and make swaps using Balancer V2 liquidity.\n\n```js\nconst swaps = new swapService({\n  network: Network;\n  rpcUrl: string;\n});\n```\n\n## Examples\n\nYou can run each example with `npm run examples:run -- examples/exampleName.ts`\n\n### #queryBatchSwap\n\nThe Balancer Vault provides a [method to simulate a call to batchSwap](https://github.com/balancer-labs/balancer-v2-monorepo/blob/master/pkg/vault/contracts/interfaces/IVault.sol#L644).\nThis function performs no checks on the sender or recipient or token balances or approvals. Note that this function is not 'view' (due to implementation details): the client code must explicitly execute eth_call instead of eth_sendTransaction.\n\n@param batchSwap - BatchSwap information used for query.\n@param batchSwap.kind - either exactIn or exactOut.\n@param batchSwap.swaps - sequence of swaps.\n@param batchSwap.assets - array contains the addresses of all assets involved in the swaps.\n@returns Returns an array with the net Vault asset balance deltas. Positive amounts represent tokens (or ETH) sent to the Vault, and negative amounts represent tokens (or ETH) sent by the Vault. Each delta corresponds to the asset at the same index in the `assets` array.\n\n```js\nswaps.queryBatchSwap(batchSwap: {\n    kind: SwapType,\n    swaps: BatchSwapStep[],\n    assets: string[]\n}): Promise<BigNumberish[]>\n```\n\n[Example](./examples/queryBatchSwap.ts)\n\n### #queryBatchSwapWithSor\n\nUses SOR to create and query a batchSwap for multiple tokens in > multiple tokensOut.\n\n@param queryWithSor - Swap information used for querying using SOR.\n@param queryWithSor.tokensIn - Array of addresses of assets in.\n@param queryWithSor.tokensOut - Array of addresses of assets out.\n@param queryWithSor.swapType - Type of Swap, ExactIn/Out.\n@param queryWithSor.amounts - Array of amounts used in swap.\n@param queryWithSor.fetchPools - Set whether SOR will fetch updated pool info.\n@returns Returns amount of tokens swaps along with swap and asset info that can be submitted to a batchSwap call.\n\n```js\nswaps.queryBatchSwapWithSor(queryWithSor: {\n    tokensIn: string[],\n    tokensOut: string[],\n    swapType: SwapType,\n    amounts: BigNumberish[],\n    fetchPools: FetchPoolsInput;\n}):\nPromise<QueryWithSorOutput {\n    returnAmounts: string[];\n    swaps: BatchSwapStep[];\n    assets: string[];\n    deltas: string[];\n}>\n```\n\n### #encodeBatchSwap\n\nStatic method to encode a [batch swap](https://dev.balancer.fi/references/contracts/apis/the-vault#batch-swaps).\n\n_NB: This method doesn't execute a batchSwap -- it returns an [ABI byte string](https://docs.soliditylang.org/en/latest/abi-spec.html) containing the data of the function call on a contract, which can then be sent to the network (ex. [sendTransaction](https://web3js.readthedocs.io/en/v1.2.11/web3-eth.html#sendtransaction)). to be executed. See example for more info._\n\n```js\n/**\n * @param {BatchSwap}           batchSwap - BatchSwap information used for query.\n * @param {SwapType}            batchSwap.kind - either exactIn or exactOut\n * @param {BatchSwapSteps[]}    batchSwap.swaps - sequence of swaps\n * @param {string[]}            batchSwap.assets - array contains the addresses of all assets involved in the swaps\n * @param {FundManagement}      batchSwap.funds - object containing information about where funds should be taken/sent\n * @param {number[]}            batchSwap.limits - limits for each token involved in the swap, where either the maximum number of tokens to send (by passing a positive value) or the minimum amount of tokens to receive (by passing a negative value) is specified\n * @param {string}              batchSwap.deadline -  time (in Unix timestamp) after which it will no longer attempt to make a trade\n * @returns {string}            encodedBatchSwapData - Returns an ABI byte string containing the data of the function call on a contract\n*/\nSwaps.encodeBatchSwap(batchSwap: {\n    kind: SwapType,\n    swaps: BatchSwapStep[],\n    assets: string[],\n    funds: FundManagement,\n    limits: number[],\n    deadline: string\n}): string\n```\n\n[Example](./examples/batchSwap.ts)\n\n### Swap Service: Flash Swaps\n\nA [Flash Swap](https://dev.balancer.fi/resources/swaps/flash-swaps) is a special type of [batch swap](https://dev.balancer.fi/resources/swaps/batch-swaps) where the caller doesn't need to own or provide any of the input tokens -- the caller is essentially taking a \"flash loan\" (an uncollateralized loan) from the Balancer Vault. The full amount of the input token must be returned to the Vault by the end of the batch (plus any swap fees), however any excess of an output tokens can be sent to any address.\n\nIMPORTANT: A \"simple\" flash swap is an arbitrage executed with only two tokens and two pools,\nswapping in the first pool and then back in the second pool for a profit. For more\ncomplex flash swaps, you will have to use batch swap directly.\n\nGotchas:\n\n-   Both pools must have both assets (tokens) for swaps to work\n-   No pool token balances can be zero\n-   If the flash swap isn't profitable, the internal flash loan will fail.\n\n### #encodeSimpleFlashSwap\n\nStatic method to encode a simple flash swap [method for a batchSwap](https://dev.balancer.fi/resources/swaps/flash-swaps).\n\n_NB: This method doesn't execute any swaps -- it returns an [ABI byte string](https://docs.soliditylang.org/en/latest/abi-spec.html) containing the data of the function call on a contract, which can then be sent to the network (ex. [sendTransaction](https://web3js.readthedocs.io/en/v1.2.11/web3-eth.html#sendtransaction)). to be executed. See example for more info._\n\n```js\n/**\n * @param {SimpleFlashSwapParameters}   params - BatchSwap information used for query.\n * @param {string}                      params.flashLoanAmount - initial input amount for the flash loan (first asset)\n * @param {string[]}                    params.poolIds - array of Balancer pool ids\n * @param {string[]}                    params.assets - array of token addresses\n * @param {string}                      params.walletAddress - array of token addresses\n * @returns {string}            encodedBatchSwapData - Returns an ABI byte string containing the data of the function call on a contract\n*/\nSwaps.encodeSimpleFlashSwap(simpleFlashSwap: {\n    flashLoanAmount: string,\n    poolIds: string[],\n    assets: string[]\n    walletAddress: string[]\n}): string\n```\n\n[Example](./examples/flashSwap.ts)\n\n### #querySimpleFlashSwap\n\nMethod to test if a simple flash swap is valid and see potential profits.\n\n```js\n/**\n * @param {SimpleFlashSwapParameters}   params - BatchSwap information used for query.\n * @param {string}                      params.flashLoanAmount - initial input amount for the flash loan (first asset)\n * @param {string[]}                    params.poolIds - array of Balancer pool ids\n * @param {string[]}                    params.assets - array of token addresses\n * @returns {Promise<{profits: Record<string, string>, isProfitable: boolean}>}       Returns an ethersjs transaction response\n*/\nswaps.querySimpleFlashSwap(batchSwap: {\n    kind: SwapType,\n    swaps: BatchSwapStep[],\n    assets: string[]\n}): string\n```\n\n[Example](./examples/querySimpleFlashSwap.ts)\n\n## Pricing Module\n\nExposes Spot Price functionality allowing user to query spot price for token pair.\n\n```js\nconst pricing = new Pricing(sdkConfig);\n```\n\n### #getSpotPrice\n\nCalculates Spot Price for a token pair - for specific pool if ID otherwise finds most liquid path and uses this as reference SP.\n\n@param { string } tokenIn Token in address.\n@param { string } tokenOut Token out address.\n@param { string } poolId Optional - if specified this pool will be used for SP calculation.\n@param { SubgraphPoolBase[] } pools Optional - Pool data. Will be fetched via dataProvider if not supplied.\n@returns  { string } Spot price.\n\n```js\nasync getSpotPrice(\n    tokenIn: string,\n    tokenOut: string,\n    poolId = '',\n    pools: SubgraphPoolBase[] = []\n): Promise<string>\n```\n\n[Example](./examples/spotPrice.ts)\n\n## Join Pool\n\nExposes Join functionality allowing user to join pools.\n\n```js\nconst balancer = new BalancerSDK(sdkConfig);\nconst pool = await balancer.poolsProvider.find(poolId);\nconst { to, functionName, attributes, data } = pool.buildJoin(params);\n```\n\n### #buildJoin\n\nBuilds a join transaction.\n\n```js\n/**\n * @param { string }   joiner - Address used to exit pool.\n * @param { string[] } tokensIn - Token addresses provided for joining pool (same length and order as amountsIn).\n * @param { string[] } amountsIn - Token amounts provided for joining pool in EVM amounts.\n * @param { string }   slippage - Maximum slippage tolerance in bps i.e. 50 = 0.5%.\n * @returns { Promise<JoinPoolAttributes> } Returns join transaction ready to send with signer.sendTransaction.\n*/\nbuildJoin: (\n  joiner: string,\n  tokensIn: string[],\n  amountsIn: string[],\n  slippage: string\n) => Promise<JoinPoolAttributes>;\n```\n\n[Example](./examples/join.ts)\n\n## RelayerService\n\nRelayers are (user opt-in, audited) contracts that can make calls to the vault (with the transaction “sender” being any arbitrary address) and use the sender’s ERC20 vault allowance, internal balance or BPTs on their behalf.\n\n```js\nconst relayer = new relayerService(\n    swapsService: SwapsService;\n    rpcUrl: string;\n);\n```\n\n### #swapUnwrapAaveStaticExactIn\n\nFinds swaps for tokenIn>wrapped Aave static tokens and chains with unwrap to underlying stable. ExactIn - Exact amount of tokenIn to use in swap.\n\n@param tokensIn - array to token addresses for swapping as tokens in.\n@param aaveStaticTokens - array contains the addresses of the Aave static tokens that tokenIn will be swapped to. These will be unwrapped.\n@param amountsIn - amounts to be swapped for each token in.\n@param rates - The rate used to convert wrappedToken to underlying.\n@param funds - Funding info for swap. Note - recipient should be relayer and sender should be caller.\n@param slippage - Slippage to be applied to swap section. i.e. 5%=50000000000000000.\n@param fetchPools - Set whether SOR will fetch updated pool info.\n@returns Transaction data with calldata. Outputs.amountsOut has final amounts out of unwrapped tokens.\n\n```js\nasync relayer.swapUnwrapAaveStaticExactIn(\n    tokensIn: string[],\n    aaveStaticTokens: string[],\n    amountsIn: BigNumberish[],\n    rates: BigNumberish[],\n    funds: FundManagement,\n    slippage: BigNumberish,\n    fetchPools: FetchPoolsInput = {\n        fetchPools: true,\n        fetchOnChain: false\n    }\n): Promise<TransactionData>\n```\n\n[Example](./examples/relayerSwapUnwrap.ts)\n\n### #swapUnwrapAaveStaticExactOut\n\nFinds swaps for tokenIn>wrapped Aave static tokens and chains with unwrap to underlying stable. ExactOut - Exact amount of tokens out are used for swaps.\n\n@param tokensIn - array to token addresses for swapping as tokens in.\n@param aaveStaticTokens - array contains the addresses of the Aave static tokens that tokenIn will be swapped to. These will be unwrapped.\n@param amountsUnwrapped - amounts of unwrapped tokens out.\n@param rates - The rate used to convert wrappedToken to underlying.\n@param funds - Funding info for swap. Note - recipient should be relayer and sender should be caller.\n@param slippage - Slippage to be applied to swap section. i.e. 5%=50000000000000000.\n@param fetchPools - Set whether SOR will fetch updated pool info.\n@returns Transaction data with calldata. Outputs.amountsIn has the amounts of tokensIn.\n\n```js\nasync relayer.swapUnwrapAaveStaticExactOut(\n    tokensIn: string[],\n    aaveStaticTokens: string[],\n    amountsUnwrapped: BigNumberish[],\n    rates: BigNumberish[],\n    funds: FundManagement,\n    slippage: BigNumberish,\n    fetchPools: FetchPoolsInput = {\n        fetchPools: true,\n        fetchOnChain: false\n    }\n): Promise<TransactionData>\n```\n\n[Example](./examples/relayerSwapUnwrap.ts)\n\n### #exitPoolAndBatchSwap\n\nChains poolExit with batchSwap to final tokens.\n\n@param params:\n@param exiter - Address used to exit pool.\n@param swapRecipient - Address that receives final tokens.\n@param poolId - Id of pool being exited.\n@param exitTokens - Array containing addresses of tokens to receive after exiting pool. (must have the same length and order as the array returned by `getPoolTokens`.)\n@param userData - Encoded exitPool data.\n@param minExitAmountsOut - Minimum amounts of exitTokens to receive when exiting pool.\n@param finalTokensOut - Array containing the addresses of the final tokens out.\n@param slippage - Slippage to be applied to swap section. i.e. 5%=50000000000000000.\n@param fetchPools - Set whether SOR will fetch updated pool info.\n@returns Transaction data with calldata. Outputs.amountsOut has amounts of finalTokensOut returned.\n\n```js\nasync relayer.exitPoolAndBatchSwap(\n    params: ExitAndBatchSwapInput {\n        exiter: string;\n        swapRecipient: string;\n        poolId: string;\n        exitTokens: string[];\n        userData: string;\n        minExitAmountsOut: string[];\n        finalTokensOut: string[];\n        slippage: string;\n        fetchPools: FetchPoolsInput;\n    }\n): Promise<TransactionData>\n```\n\n[Example](./examples/relayerExitPoolAndBatchSwap.ts)\n\n## Licensing\n\n[GNU General Public License Version 3 (GPL v3)](../../LICENSE).\n","browser":"dist/index.umd.js","scripts":{"dev":"rollup -c -w","lint":"eslint ./src --ext .ts --max-warnings 0","node":"npx hardhat node --fork $(grep ALCHEMY_URL .env | cut -d '=' -f2) --fork-block-number 14828550","test":"ts-mocha --paths --recursive -p tsconfig.testing.json 'src/**/*.spec.ts'","build":"rimraf dist && rollup -c","lint:fix":"eslint ./src --ext .ts --max-warnings 0 --fix","test:only":"ts-mocha --paths --recursive -p tsconfig.testing.json","prepublish":"yarn build","examples:run":"TS_NODE_PROJECT='tsconfig.testing.json' ts-node -r tsconfig-paths/register","subgraph:generate":"graphql-codegen --config src/modules/subgraph/codegen.yml -r dotenv/config"},"typings":"dist/index.d.ts","_npmUser":{"name":"defifofum","email":"DeFiFoFum0@gmail.com"},"repository":{"url":"https://github.com/ApeSwapFinance/apeswap-swap-v2-sdk","type":"git","directory":"balancer-js"},"description":"JavaScript SDK for interacting with the Balancer Protocol V2","directories":{},"dependencies":{"axios":"^0.24.0","lodash":"^4.17.21","graphql":"^15.6.1","bignumber.js":"^9.0.2","graphql-request":"^3.5.0","@balancer-labs/sor":"^4.0.1-beta.1","@balancer-labs/typechain":"^1.0.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","mocha":"^8.2.1","dotenv":"^10.0.0","eslint":"^7.9.0","ethers":"^5.0.0","rimraf":"^3.0.2","rollup":"^2.52.8","fishery":"^2.2.2","hardhat":"^2.9.3","ts-node":"^10.4.0","prettier":"^2.1.2","ts-mocha":"^9.0.2","typechain":"^5.1.1","typescript":"^4.0.2","@types/chai":"^4.2.12","@types/node":"^15.12.4","@types/mocha":"^8.0.3","@types/lodash":"^4.14.177","tiny-invariant":"^1.1.0","tsconfig-paths":"^3.12.0","rollup-plugin-dts":"^3.0.2","@ethersproject/abi":"^5.4.0","@rollup/plugin-json":"^4.1.0","@ethersproject/bytes":"^5.4.0","@graphql-codegen/add":"^3.1.0","@graphql-codegen/cli":"^2.3.0","@typechain/ethers-v5":"^7.0.1","@ethersproject/wallet":"^5.5.0","@ethersproject/address":"^5.4.0","eslint-plugin-prettier":"^3.1.4","@ethersproject/solidity":"^5.6.1","@rollup/plugin-commonjs":"^21.0.1","@ethersproject/bignumber":"^5.4.0","@ethersproject/constants":"^5.4.0","@ethersproject/contracts":"^5.4.0","@ethersproject/providers":"^5.4.5","@nomiclabs/hardhat-ethers":"^2.0.5","@rollup/plugin-typescript":"^8.2.1","@typescript-eslint/parser":"^4.1.1","@graphql-codegen/schema-ast":"^2.4.0","@graphql-codegen/typescript":"2.4.0","@rollup/plugin-node-resolve":"^13.0.0","eslint-plugin-mocha-no-only":"^1.1.1","@ethersproject/abstract-signer":"^5.4.0","@georgeroman/balancer-v2-pools":"^0.0.5","@graphql-codegen/introspection":"^2.1.0","@typescript-eslint/eslint-plugin":"^4.1.1","@graphql-codegen/typescript-resolvers":"2.4.1","@graphql-codegen/typescript-operations":"^2.2.0","@graphql-codegen/typescript-document-nodes":"^2.2.0","@graphql-codegen/typescript-graphql-request":"^4.3.0"},"peerDependencies":{"@ethersproject/abi":"^5.4.0","@ethersproject/bytes":"^5.4.0","@ethersproject/address":"^5.4.0","@ethersproject/bignumber":"^5.4.0","@ethersproject/constants":"^5.4.0","@ethersproject/contracts":"^5.4.0","@ethersproject/providers":"^5.4.5","@ethersproject/abstract-signer":"^5.4.0"},"_npmOperationalInternal":{"tmp":"tmp/swap-v2-sdk_0.0.1-alpha.2_1658941468041_0.39030533783776966","host":"s3://npm-registry-packages"}},"0.0.1-alpha.3":{"name":"@ape.swap/swap-v2-sdk","version":"0.0.1-alpha.3","license":"GPL-3.0-only","_id":"@ape.swap/swap-v2-sdk@0.0.1-alpha.3","maintainers":[{"name":"defifofum","email":"DeFiFoFum0@gmail.com"},{"name":"babadrape","email":"babadrape@gmail.com"},{"name":"ixm-759","email":"759ixm@gmail.com"},{"name":"obiedobo","email":"obiedobo@gmail.com"},{"name":"harambe-nakamoto","email":"harambeN@protonmail.com"},{"name":"justus_o","email":"justus.onuoha@innovationupstream.com"},{"name":"apeguru","email":"hello@apeswap.finance"}],"homepage":"https://github.com/ApeSwapFinance/apeswap-swap-v2-sdk/balancer-js#readme","bugs":{"url":"https://github.com/ApeSwapFinance/apeswap-swap-v2-sdk/issues"},"dist":{"shasum":"da75b6af81fb317539fa8e2003b642589b64b61b","tarball":"https://registry.npmjs.org/@ape.swap/swap-v2-sdk/-/swap-v2-sdk-0.0.1-alpha.3.tgz","fileCount":11,"integrity":"sha512-ioKHht2gVPbkrO/i/bHue4aiQC66L0ohXf4oLU2lGeyDJS347U/WS/82N/TjAI/Qm/ku6qNTeyd1oCYuQ/EMsA==","signatures":[{"sig":"MEQCIGMGdlaZv0fmaOqOxoG9JZOBlo4oGv/GxhCASajnpOtuAiBUtfxTenkbkqvv/tbxB8aUmLpSzUOU5NGDPA0T9gOp9w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":3263947,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi4ttUACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoHNA//bqbcVlCBfWAIYnbk6OKFmlHfhmFAJhrYQjVHSrLMUZmJtvb7\r\nuAvJiD0ToJ4fc9FQdE/wnQqr6NRnZKrjRclcaqiTSJfmWPt9Mt4KXtTO9KmV\r\nmoVXXcCYM3bXbcifeCab0kFk2rHawW17aeY0i33vt+ob3wWSpfylqrVC6Pkc\r\nbQry8tM8GOnL66AGFqFwJxtvwVuPGYeCe0t+jY8Fmrl3gFzyb4sDApx5lvkS\r\nrj2PPcqEcI1Gzeqx7I2ySO6HVACfgd4a1aJE/WEgc+nucrMltnCov/nKU0DP\r\nWE36bfmkq0uQ7/cBGsY+z/a0IU7gNri8FiSuESgkKQ32fs6awOlXWOQtniek\r\nQod7+my+JKnrlwR8RZyJLhr62WN8H+hJ6WpAOnWkDW6ohb18aYZmRYSq/5s9\r\n6MPt9DBR+u45azBTUHMs5gGsy7ZX2rYcXpPlOXhKuB/ig4lS1O2AVQuK1AoR\r\nGeFZ42lUvCDhaLf7UuEhN2Jqp7xwDR6Z9SKh0XzcAVxxwIyblB+/osvcKgIE\r\nRfp4bacPPKLYAe17H3KNY5yUhDhQOJrxWIQ7usNtmeVUVKX8w20Y8GSBCjj4\r\neAznMXt9WOfXj0vP2Jmr0vKzaTntp1RQRvUoNRDdXr2Glqq716uE9XhwRJ9Y\r\nGSa4cN+N0a7oxCGlhxrIkiXn+k8oiVAVNFw=\r\n=gcW6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","module":"dist/index.esm.js","readme":"# Balancer Javascript SDK\n\nA JavaScript SDK which provides commonly used utilities for interacting with Balancer Protocol V2.\n\n## Installation\n\n## Getting Started\n\n```js\nimport { BalancerSDK, BalancerSdkConfig, Network } from '@balancer-labs/sdk';\n\nconst config: BalancerSdkConfig = {\n    network: Network.MAINNET,\n    rpcUrl: `https://kovan.infura.io/v3/${process.env.INFURA}`,\n};\nconst balancer = new BalancerSDK(config);\n```\n\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.\n\nInstallation instructions for:\n\n* [Hardhat](https://hardhat.org/getting-started/#installation)\n\n  To start a forked node:\n  ```\n  npm run node\n  ```\n\n* [Anvil](https://github.com/foundry-rs/foundry/tree/master/anvil#installation) - use with caution, still experimental.\n  \n  To start a forked node:\n  ```\n  anvil -f FORKABLE_RPC_URL (optional pinned block: --fork-block-number XXX)\n  ```\n\n## Swaps Module\n\nExposes complete functionality for token swapping. An example of using the module with data fetched from the subgraph:\n\n```js\n// Uses SOR to find optimal route for a trading pair and amount\nconst route = balancer.swaps.findRouteGivenIn({\n    tokenIn,\n    tokenOut,\n    amount,\n    gasPrice,\n    maxPools,\n})\n\n// Prepares transaction attributes based on the route\nconst transactionAttributes = balancer.swaps.buildSwap({\n    userAddress,\n    swapInfo: route,\n    kind: 0, // 0 - givenIn, 1 - givenOut\n    deadline,\n    maxSlippage,\n})\n\n// Extract parameters required for sendTransaction\nconst { to, data, value } = transactionAttributes\n\n// Execution with ethers.js\nconst transactionResponse = await signer.sendTransaction({ to, data, value })\n```\n\n\n## SwapsService\n\nThe SwapsService provides function to query and make swaps using Balancer V2 liquidity.\n\n```js\nconst swaps = new swapService({\n  network: Network;\n  rpcUrl: string;\n});\n```\n\n## Examples\n\nYou can run each example with `npm run examples:run -- examples/exampleName.ts`\n\n### #queryBatchSwap\n\nThe Balancer Vault provides a [method to simulate a call to batchSwap](https://github.com/balancer-labs/balancer-v2-monorepo/blob/master/pkg/vault/contracts/interfaces/IVault.sol#L644).\nThis function performs no checks on the sender or recipient or token balances or approvals. Note that this function is not 'view' (due to implementation details): the client code must explicitly execute eth_call instead of eth_sendTransaction.\n\n@param batchSwap - BatchSwap information used for query.\n@param batchSwap.kind - either exactIn or exactOut.\n@param batchSwap.swaps - sequence of swaps.\n@param batchSwap.assets - array contains the addresses of all assets involved in the swaps.\n@returns Returns an array with the net Vault asset balance deltas. Positive amounts represent tokens (or ETH) sent to the Vault, and negative amounts represent tokens (or ETH) sent by the Vault. Each delta corresponds to the asset at the same index in the `assets` array.\n\n```js\nswaps.queryBatchSwap(batchSwap: {\n    kind: SwapType,\n    swaps: BatchSwapStep[],\n    assets: string[]\n}): Promise<BigNumberish[]>\n```\n\n[Example](./examples/queryBatchSwap.ts)\n\n### #queryBatchSwapWithSor\n\nUses SOR to create and query a batchSwap for multiple tokens in > multiple tokensOut.\n\n@param queryWithSor - Swap information used for querying using SOR.\n@param queryWithSor.tokensIn - Array of addresses of assets in.\n@param queryWithSor.tokensOut - Array of addresses of assets out.\n@param queryWithSor.swapType - Type of Swap, ExactIn/Out.\n@param queryWithSor.amounts - Array of amounts used in swap.\n@param queryWithSor.fetchPools - Set whether SOR will fetch updated pool info.\n@returns Returns amount of tokens swaps along with swap and asset info that can be submitted to a batchSwap call.\n\n```js\nswaps.queryBatchSwapWithSor(queryWithSor: {\n    tokensIn: string[],\n    tokensOut: string[],\n    swapType: SwapType,\n    amounts: BigNumberish[],\n    fetchPools: FetchPoolsInput;\n}):\nPromise<QueryWithSorOutput {\n    returnAmounts: string[];\n    swaps: BatchSwapStep[];\n    assets: string[];\n    deltas: string[];\n}>\n```\n\n### #encodeBatchSwap\n\nStatic method to encode a [batch swap](https://dev.balancer.fi/references/contracts/apis/the-vault#batch-swaps).\n\n_NB: This method doesn't execute a batchSwap -- it returns an [ABI byte string](https://docs.soliditylang.org/en/latest/abi-spec.html) containing the data of the function call on a contract, which can then be sent to the network (ex. [sendTransaction](https://web3js.readthedocs.io/en/v1.2.11/web3-eth.html#sendtransaction)). to be executed. See example for more info._\n\n```js\n/**\n * @param {BatchSwap}           batchSwap - BatchSwap information used for query.\n * @param {SwapType}            batchSwap.kind - either exactIn or exactOut\n * @param {BatchSwapSteps[]}    batchSwap.swaps - sequence of swaps\n * @param {string[]}            batchSwap.assets - array contains the addresses of all assets involved in the swaps\n * @param {FundManagement}      batchSwap.funds - object containing information about where funds should be taken/sent\n * @param {number[]}            batchSwap.limits - limits for each token involved in the swap, where either the maximum number of tokens to send (by passing a positive value) or the minimum amount of tokens to receive (by passing a negative value) is specified\n * @param {string}              batchSwap.deadline -  time (in Unix timestamp) after which it will no longer attempt to make a trade\n * @returns {string}            encodedBatchSwapData - Returns an ABI byte string containing the data of the function call on a contract\n*/\nSwaps.encodeBatchSwap(batchSwap: {\n    kind: SwapType,\n    swaps: BatchSwapStep[],\n    assets: string[],\n    funds: FundManagement,\n    limits: number[],\n    deadline: string\n}): string\n```\n\n[Example](./examples/batchSwap.ts)\n\n### Swap Service: Flash Swaps\n\nA [Flash Swap](https://dev.balancer.fi/resources/swaps/flash-swaps) is a special type of [batch swap](https://dev.balancer.fi/resources/swaps/batch-swaps) where the caller doesn't need to own or provide any of the input tokens -- the caller is essentially taking a \"flash loan\" (an uncollateralized loan) from the Balancer Vault. The full amount of the input token must be returned to the Vault by the end of the batch (plus any swap fees), however any excess of an output tokens can be sent to any address.\n\nIMPORTANT: A \"simple\" flash swap is an arbitrage executed with only two tokens and two pools,\nswapping in the first pool and then back in the second pool for a profit. For more\ncomplex flash swaps, you will have to use batch swap directly.\n\nGotchas:\n\n-   Both pools must have both assets (tokens) for swaps to work\n-   No pool token balances can be zero\n-   If the flash swap isn't profitable, the internal flash loan will fail.\n\n### #encodeSimpleFlashSwap\n\nStatic method to encode a simple flash swap [method for a batchSwap](https://dev.balancer.fi/resources/swaps/flash-swaps).\n\n_NB: This method doesn't execute any swaps -- it returns an [ABI byte string](https://docs.soliditylang.org/en/latest/abi-spec.html) containing the data of the function call on a contract, which can then be sent to the network (ex. [sendTransaction](https://web3js.readthedocs.io/en/v1.2.11/web3-eth.html#sendtransaction)). to be executed. See example for more info._\n\n```js\n/**\n * @param {SimpleFlashSwapParameters}   params - BatchSwap information used for query.\n * @param {string}                      params.flashLoanAmount - initial input amount for the flash loan (first asset)\n * @param {string[]}                    params.poolIds - array of Balancer pool ids\n * @param {string[]}                    params.assets - array of token addresses\n * @param {string}                      params.walletAddress - array of token addresses\n * @returns {string}            encodedBatchSwapData - Returns an ABI byte string containing the data of the function call on a contract\n*/\nSwaps.encodeSimpleFlashSwap(simpleFlashSwap: {\n    flashLoanAmount: string,\n    poolIds: string[],\n    assets: string[]\n    walletAddress: string[]\n}): string\n```\n\n[Example](./examples/flashSwap.ts)\n\n### #querySimpleFlashSwap\n\nMethod to test if a simple flash swap is valid and see potential profits.\n\n```js\n/**\n * @param {SimpleFlashSwapParameters}   params - BatchSwap information used for query.\n * @param {string}                      params.flashLoanAmount - initial input amount for the flash loan (first asset)\n * @param {string[]}                    params.poolIds - array of Balancer pool ids\n * @param {string[]}                    params.assets - array of token addresses\n * @returns {Promise<{profits: Record<string, string>, isProfitable: boolean}>}       Returns an ethersjs transaction response\n*/\nswaps.querySimpleFlashSwap(batchSwap: {\n    kind: SwapType,\n    swaps: BatchSwapStep[],\n    assets: string[]\n}): string\n```\n\n[Example](./examples/querySimpleFlashSwap.ts)\n\n## Pricing Module\n\nExposes Spot Price functionality allowing user to query spot price for token pair.\n\n```js\nconst pricing = new Pricing(sdkConfig);\n```\n\n### #getSpotPrice\n\nCalculates Spot Price for a token pair - for specific pool if ID otherwise finds most liquid path and uses this as reference SP.\n\n@param { string } tokenIn Token in address.\n@param { string } tokenOut Token out address.\n@param { string } poolId Optional - if specified this pool will be used for SP calculation.\n@param { SubgraphPoolBase[] } pools Optional - Pool data. Will be fetched via dataProvider if not supplied.\n@returns  { string } Spot price.\n\n```js\nasync getSpotPrice(\n    tokenIn: string,\n    tokenOut: string,\n    poolId = '',\n    pools: SubgraphPoolBase[] = []\n): Promise<string>\n```\n\n[Example](./examples/spotPrice.ts)\n\n## Join Pool\n\nExposes Join functionality allowing user to join pools.\n\n```js\nconst balancer = new BalancerSDK(sdkConfig);\nconst pool = await balancer.poolsProvider.find(poolId);\nconst { to, functionName, attributes, data } = pool.buildJoin(params);\n```\n\n### #buildJoin\n\nBuilds a join transaction.\n\n```js\n/**\n * @param { string }   joiner - Address used to exit pool.\n * @param { string[] } tokensIn - Token addresses provided for joining pool (same length and order as amountsIn).\n * @param { string[] } amountsIn - Token amounts provided for joining pool in EVM amounts.\n * @param { string }   slippage - Maximum slippage tolerance in bps i.e. 50 = 0.5%.\n * @returns { Promise<JoinPoolAttributes> } Returns join transaction ready to send with signer.sendTransaction.\n*/\nbuildJoin: (\n  joiner: string,\n  tokensIn: string[],\n  amountsIn: string[],\n  slippage: string\n) => Promise<JoinPoolAttributes>;\n```\n\n[Example](./examples/join.ts)\n\n## RelayerService\n\nRelayers are (user opt-in, audited) contracts that can make calls to the vault (with the transaction “sender” being any arbitrary address) and use the sender’s ERC20 vault allowance, internal balance or BPTs on their behalf.\n\n```js\nconst relayer = new relayerService(\n    swapsService: SwapsService;\n    rpcUrl: string;\n);\n```\n\n### #swapUnwrapAaveStaticExactIn\n\nFinds swaps for tokenIn>wrapped Aave static tokens and chains with unwrap to underlying stable. ExactIn - Exact amount of tokenIn to use in swap.\n\n@param tokensIn - array to token addresses for swapping as tokens in.\n@param aaveStaticTokens - array contains the addresses of the Aave static tokens that tokenIn will be swapped to. These will be unwrapped.\n@param amountsIn - amounts to be swapped for each token in.\n@param rates - The rate used to convert wrappedToken to underlying.\n@param funds - Funding info for swap. Note - recipient should be relayer and sender should be caller.\n@param slippage - Slippage to be applied to swap section. i.e. 5%=50000000000000000.\n@param fetchPools - Set whether SOR will fetch updated pool info.\n@returns Transaction data with calldata. Outputs.amountsOut has final amounts out of unwrapped tokens.\n\n```js\nasync relayer.swapUnwrapAaveStaticExactIn(\n    tokensIn: string[],\n    aaveStaticTokens: string[],\n    amountsIn: BigNumberish[],\n    rates: BigNumberish[],\n    funds: FundManagement,\n    slippage: BigNumberish,\n    fetchPools: FetchPoolsInput = {\n        fetchPools: true,\n        fetchOnChain: false\n    }\n): Promise<TransactionData>\n```\n\n[Example](./examples/relayerSwapUnwrap.ts)\n\n### #swapUnwrapAaveStaticExactOut\n\nFinds swaps for tokenIn>wrapped Aave static tokens and chains with unwrap to underlying stable. ExactOut - Exact amount of tokens out are used for swaps.\n\n@param tokensIn - array to token addresses for swapping as tokens in.\n@param aaveStaticTokens - array contains the addresses of the Aave static tokens that tokenIn will be swapped to. These will be unwrapped.\n@param amountsUnwrapped - amounts of unwrapped tokens out.\n@param rates - The rate used to convert wrappedToken to underlying.\n@param funds - Funding info for swap. Note - recipient should be relayer and sender should be caller.\n@param slippage - Slippage to be applied to swap section. i.e. 5%=50000000000000000.\n@param fetchPools - Set whether SOR will fetch updated pool info.\n@returns Transaction data with calldata. Outputs.amountsIn has the amounts of tokensIn.\n\n```js\nasync relayer.swapUnwrapAaveStaticExactOut(\n    tokensIn: string[],\n    aaveStaticTokens: string[],\n    amountsUnwrapped: BigNumberish[],\n    rates: BigNumberish[],\n    funds: FundManagement,\n    slippage: BigNumberish,\n    fetchPools: FetchPoolsInput = {\n        fetchPools: true,\n        fetchOnChain: false\n    }\n): Promise<TransactionData>\n```\n\n[Example](./examples/relayerSwapUnwrap.ts)\n\n### #exitPoolAndBatchSwap\n\nChains poolExit with batchSwap to final tokens.\n\n@param params:\n@param exiter - Address used to exit pool.\n@param swapRecipient - Address that receives final tokens.\n@param poolId - Id of pool being exited.\n@param exitTokens - Array containing addresses of tokens to receive after exiting pool. (must have the same length and order as the array returned by `getPoolTokens`.)\n@param userData - Encoded exitPool data.\n@param minExitAmountsOut - Minimum amounts of exitTokens to receive when exiting pool.\n@param finalTokensOut - Array containing the addresses of the final tokens out.\n@param slippage - Slippage to be applied to swap section. i.e. 5%=50000000000000000.\n@param fetchPools - Set whether SOR will fetch updated pool info.\n@returns Transaction data with calldata. Outputs.amountsOut has amounts of finalTokensOut returned.\n\n```js\nasync relayer.exitPoolAndBatchSwap(\n    params: ExitAndBatchSwapInput {\n        exiter: string;\n        swapRecipient: string;\n        poolId: string;\n        exitTokens: string[];\n        userData: string;\n        minExitAmountsOut: string[];\n        finalTokensOut: string[];\n        slippage: string;\n        fetchPools: FetchPoolsInput;\n    }\n): Promise<TransactionData>\n```\n\n[Example](./examples/relayerExitPoolAndBatchSwap.ts)\n\n## Licensing\n\n[GNU General Public License Version 3 (GPL v3)](../../LICENSE).\n","browser":"dist/index.umd.js","scripts":{"dev":"rollup -c -w","lint":"eslint ./src --ext .ts --max-warnings 0","node":"npx hardhat node --fork $(grep ALCHEMY_URL .env | cut -d '=' -f2) --fork-block-number 14828550","test":"ts-mocha --paths --recursive -p tsconfig.testing.json 'src/**/*.spec.ts'","build":"rimraf dist && rollup -c","lint:fix":"eslint ./src --ext .ts --max-warnings 0 --fix","test:only":"ts-mocha --paths --recursive -p tsconfig.testing.json","prepublish":"yarn build","examples:run":"TS_NODE_PROJECT='tsconfig.testing.json' ts-node -r tsconfig-paths/register","subgraph:generate":"graphql-codegen --config src/modules/subgraph/codegen.yml -r dotenv/config"},"typings":"dist/index.d.ts","_npmUser":{"name":"defifofum","email":"DeFiFoFum0@gmail.com"},"repository":{"url":"https://github.com/ApeSwapFinance/apeswap-swap-v2-sdk","type":"git","directory":"balancer-js"},"description":"JavaScript SDK for interacting with the Balancer Protocol V2","directories":{},"dependencies":{"axios":"^0.24.0","lodash":"^4.17.21","graphql":"^15.6.1","bignumber.js":"^9.0.2","graphql-request":"^3.5.0","@balancer-labs/sor":"^4.0.1-beta.1","@balancer-labs/typechain":"^1.0.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","mocha":"^8.2.1","dotenv":"^10.0.0","eslint":"^7.9.0","ethers":"^5.0.0","rimraf":"^3.0.2","rollup":"^2.52.8","fishery":"^2.2.2","hardhat":"^2.9.3","ts-node":"^10.4.0","prettier":"^2.1.2","ts-mocha":"^9.0.2","typechain":"^5.1.1","typescript":"^4.0.2","@types/chai":"^4.2.12","@types/node":"^15.12.4","@types/mocha":"^8.0.3","@types/lodash":"^4.14.177","tiny-invariant":"^1.1.0","tsconfig-paths":"^3.12.0","rollup-plugin-dts":"^3.0.2","@ethersproject/abi":"^5.4.0","@rollup/plugin-json":"^4.1.0","@ethersproject/bytes":"^5.4.0","@graphql-codegen/add":"^3.1.0","@graphql-codegen/cli":"^2.3.0","@typechain/ethers-v5":"^7.0.1","@ethersproject/wallet":"^5.5.0","@ethersproject/address":"^5.4.0","eslint-plugin-prettier":"^3.1.4","@ethersproject/solidity":"^5.6.1","@rollup/plugin-commonjs":"^21.0.1","@ethersproject/bignumber":"^5.4.0","@ethersproject/constants":"^5.4.0","@ethersproject/contracts":"^5.4.0","@ethersproject/providers":"^5.4.5","@nomiclabs/hardhat-ethers":"^2.0.5","@rollup/plugin-typescript":"^8.2.1","@typescript-eslint/parser":"^4.1.1","@graphql-codegen/schema-ast":"^2.4.0","@graphql-codegen/typescript":"2.4.0","@rollup/plugin-node-resolve":"^13.0.0","eslint-plugin-mocha-no-only":"^1.1.1","@ethersproject/abstract-signer":"^5.4.0","@georgeroman/balancer-v2-pools":"^0.0.5","@graphql-codegen/introspection":"^2.1.0","@typescript-eslint/eslint-plugin":"^4.1.1","@graphql-codegen/typescript-resolvers":"2.4.1","@graphql-codegen/typescript-operations":"^2.2.0","@graphql-codegen/typescript-document-nodes":"^2.2.0","@graphql-codegen/typescript-graphql-request":"^4.3.0"},"peerDependencies":{"@ethersproject/abi":"^5.4.0","@ethersproject/bytes":"^5.4.0","@ethersproject/address":"^5.4.0","@ethersproject/bignumber":"^5.4.0","@ethersproject/constants":"^5.4.0","@ethersproject/contracts":"^5.4.0","@ethersproject/providers":"^5.4.5","@ethersproject/abstract-signer":"^5.4.0"},"_npmOperationalInternal":{"tmp":"tmp/swap-v2-sdk_0.0.1-alpha.3_1659034451917_0.33105843918694267","host":"s3://npm-registry-packages"}},"0.0.1-alpha.4":{"name":"@ape.swap/swap-v2-sdk","version":"0.0.1-alpha.4","license":"GPL-3.0-only","_id":"@ape.swap/swap-v2-sdk@0.0.1-alpha.4","maintainers":[{"name":"defifofum","email":"DeFiFoFum0@gmail.com"},{"name":"babadrape","email":"babadrape@gmail.com"},{"name":"ixm-759","email":"759ixm@gmail.com"},{"name":"obiedobo","email":"obiedobo@gmail.com"},{"name":"harambe-nakamoto","email":"harambeN@protonmail.com"},{"name":"justus_o","email":"justus.onuoha@innovationupstream.com"},{"name":"apeguru","email":"hello@apeswap.finance"}],"homepage":"https://github.com/ApeSwapFinance/apeswap-swap-v2-sdk/balancer-js#readme","bugs":{"url":"https://github.com/ApeSwapFinance/apeswap-swap-v2-sdk/issues"},"dist":{"shasum":"56f475ce1535c8bf432d57f9008a91bfd5a2b563","tarball":"https://registry.npmjs.org/@ape.swap/swap-v2-sdk/-/swap-v2-sdk-0.0.1-alpha.4.tgz","fileCount":11,"integrity":"sha512-g9/hh81ZUNIHXoZSs5okmEuX72Az+drjIzARaauNmzmPsUEFCTE962nuESIGMx2Rwpkniqem72GrDwHApiiF8g==","signatures":[{"sig":"MEUCIHW10bnmUjzT2/QB/CpMKEKCA4/P2ch5krAofHjyrXx2AiEAgH/NgDlP5XSgdqAvUqsbBg+fDKfI4wH42mgLxsSShaY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":3264334,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjA9BNACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqafw//ZSun5yeujXCXGvibLlpPrl2QzyTykBTjvSXq1g/pxAo7DFnE\r\nVLDNWmb0iNEcr3FkdJ9lGyHvxOANrqvNEvMtGJFiVh6XEgh5/qSJk2bCYpSM\r\nogtYbeEhOxe/O2UxFxNAyPoLwSQMVjiSLxLVZyETSmtjdR3gNI+v372y+cLA\r\ngXfLEE9zoHK1tK+lPzLAYzGtoO222a3V++DCuqceOVxOXHrcxOWm4RteX//p\r\n0siLoV+gnBDpsEM5AxdO5YWpr+s1BQQ5CEc64J9N21wyLpNDKRC3Zi/jXv2G\r\nKGqhSt6UkWEIuue9p7oKGeTgKp1RL/TMoA2SnHAP9gaPbqvCM5hDSCPb/qi3\r\nUoY5KQ9Z1EVUx/thhTQX4Styz1lALkVrkcQFKkUNVQtrJD4bQqN5t3GaXpkB\r\n0busdu7PivFqvOqy+zwYf49vTvQnF+jLwjXb1PEzjdhBXcU3uHAELJ17wN9F\r\ndttvgofM0dQmNnIE7MZwSXjNsHaiZu1/IPlsMGu5B8llpHmdGEtUNnOYj0hk\r\nv/1V+R6/8Rz82JWL4L6/xs1JPNUXfGIGA5bdLnUgzEgTe5dzodiN2Ev0eQD0\r\neddnXAqffIYWSSLab8hIWiaj/rSvEIrFRk0IUh1J/fCoaW7wQaOjk2TXdqV0\r\nsAz8ro5OVXv9h2PaMFQkKxxsQXALNh0d0P4=\r\n=61EV\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","module":"dist/index.esm.js","readme":"# Balancer Javascript SDK\n\nA JavaScript SDK which provides commonly used utilities for interacting with Balancer Protocol V2.\n\n## Installation\n\n## Getting Started\n\n```js\nimport { BalancerSDK, BalancerSdkConfig, Network } from '@balancer-labs/sdk';\n\nconst config: BalancerSdkConfig = {\n    network: Network.MAINNET,\n    rpcUrl: `https://kovan.infura.io/v3/${process.env.INFURA}`,\n};\nconst balancer = new BalancerSDK(config);\n```\n\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.\n\nInstallation instructions for:\n\n* [Hardhat](https://hardhat.org/getting-started/#installation)\n\n  To start a forked node:\n  ```\n  npm run node\n  ```\n\n* [Anvil](https://github.com/foundry-rs/foundry/tree/master/anvil#installation) - use with caution, still experimental.\n  \n  To start a forked node:\n  ```\n  anvil -f FORKABLE_RPC_URL (optional pinned block: --fork-block-number XXX)\n  ```\n\n## Swaps Module\n\nExposes complete functionality for token swapping. An example of using the module with data fetched from the subgraph:\n\n```js\n// Uses SOR to find optimal route for a trading pair and amount\nconst route = balancer.swaps.findRouteGivenIn({\n    tokenIn,\n    tokenOut,\n    amount,\n    gasPrice,\n    maxPools,\n})\n\n// Prepares transaction attributes based on the route\nconst transactionAttributes = balancer.swaps.buildSwap({\n    userAddress,\n    swapInfo: route,\n    kind: 0, // 0 - givenIn, 1 - givenOut\n    deadline,\n    maxSlippage,\n})\n\n// Extract parameters required for sendTransaction\nconst { to, data, value } = transactionAttributes\n\n// Execution with ethers.js\nconst transactionResponse = await signer.sendTransaction({ to, data, value })\n```\n\n\n## SwapsService\n\nThe SwapsService provides function to query and make swaps using Balancer V2 liquidity.\n\n```js\nconst swaps = new swapService({\n  network: Network;\n  rpcUrl: string;\n});\n```\n\n## Examples\n\nYou can run each example with `npm run examples:run -- examples/exampleName.ts`\n\n### #queryBatchSwap\n\nThe Balancer Vault provides a [method to simulate a call to batchSwap](https://github.com/balancer-labs/balancer-v2-monorepo/blob/master/pkg/vault/contracts/interfaces/IVault.sol#L644).\nThis function performs no checks on the sender or recipient or token balances or approvals. Note that this function is not 'view' (due to implementation details): the client code must explicitly execute eth_call instead of eth_sendTransaction.\n\n@param batchSwap - BatchSwap information used for query.\n@param batchSwap.kind - either exactIn or exactOut.\n@param batchSwap.swaps - sequence of swaps.\n@param batchSwap.assets - array contains the addresses of all assets involved in the swaps.\n@returns Returns an array with the net Vault asset balance deltas. Positive amounts represent tokens (or ETH) sent to the Vault, and negative amounts represent tokens (or ETH) sent by the Vault. Each delta corresponds to the asset at the same index in the `assets` array.\n\n```js\nswaps.queryBatchSwap(batchSwap: {\n    kind: SwapType,\n    swaps: BatchSwapStep[],\n    assets: string[]\n}): Promise<BigNumberish[]>\n```\n\n[Example](./examples/queryBatchSwap.ts)\n\n### #queryBatchSwapWithSor\n\nUses SOR to create and query a batchSwap for multiple tokens in > multiple tokensOut.\n\n@param queryWithSor - Swap information used for querying using SOR.\n@param queryWithSor.tokensIn - Array of addresses of assets in.\n@param queryWithSor.tokensOut - Array of addresses of assets out.\n@param queryWithSor.swapType - Type of Swap, ExactIn/Out.\n@param queryWithSor.amounts - Array of amounts used in swap.\n@param queryWithSor.fetchPools - Set whether SOR will fetch updated pool info.\n@returns Returns amount of tokens swaps along with swap and asset info that can be submitted to a batchSwap call.\n\n```js\nswaps.queryBatchSwapWithSor(queryWithSor: {\n    tokensIn: string[],\n    tokensOut: string[],\n    swapType: SwapType,\n    amounts: BigNumberish[],\n    fetchPools: FetchPoolsInput;\n}):\nPromise<QueryWithSorOutput {\n    returnAmounts: string[];\n    swaps: BatchSwapStep[];\n    assets: string[];\n    deltas: string[];\n}>\n```\n\n### #encodeBatchSwap\n\nStatic method to encode a [batch swap](https://dev.balancer.fi/references/contracts/apis/the-vault#batch-swaps).\n\n_NB: This method doesn't execute a batchSwap -- it returns an [ABI byte string](https://docs.soliditylang.org/en/latest/abi-spec.html) containing the data of the function call on a contract, which can then be sent to the network (ex. [sendTransaction](https://web3js.readthedocs.io/en/v1.2.11/web3-eth.html#sendtransaction)). to be executed. See example for more info._\n\n```js\n/**\n * @param {BatchSwap}           batchSwap - BatchSwap information used for query.\n * @param {SwapType}            batchSwap.kind - either exactIn or exactOut\n * @param {BatchSwapSteps[]}    batchSwap.swaps - sequence of swaps\n * @param {string[]}            batchSwap.assets - array contains the addresses of all assets involved in the swaps\n * @param {FundManagement}      batchSwap.funds - object containing information about where funds should be taken/sent\n * @param {number[]}            batchSwap.limits - limits for each token involved in the swap, where either the maximum number of tokens to send (by passing a positive value) or the minimum amount of tokens to receive (by passing a negative value) is specified\n * @param {string}              batchSwap.deadline -  time (in Unix timestamp) after which it will no longer attempt to make a trade\n * @returns {string}            encodedBatchSwapData - Returns an ABI byte string containing the data of the function call on a contract\n*/\nSwaps.encodeBatchSwap(batchSwap: {\n    kind: SwapType,\n    swaps: BatchSwapStep[],\n    assets: string[],\n    funds: FundManagement,\n    limits: number[],\n    deadline: string\n}): string\n```\n\n[Example](./examples/batchSwap.ts)\n\n### Swap Service: Flash Swaps\n\nA [Flash Swap](https://dev.balancer.fi/resources/swaps/flash-swaps) is a special type of [batch swap](https://dev.balancer.fi/resources/swaps/batch-swaps) where the caller doesn't need to own or provide any of the input tokens -- the caller is essentially taking a \"flash loan\" (an uncollateralized loan) from the Balancer Vault. The full amount of the input token must be returned to the Vault by the end of the batch (plus any swap fees), however any excess of an output tokens can be sent to any address.\n\nIMPORTANT: A \"simple\" flash swap is an arbitrage executed with only two tokens and two pools,\nswapping in the first pool and then back in the second pool for a profit. For more\ncomplex flash swaps, you will have to use batch swap directly.\n\nGotchas:\n\n-   Both pools must have both assets (tokens) for swaps to work\n-   No pool token balances can be zero\n-   If the flash swap isn't profitable, the internal flash loan will fail.\n\n### #encodeSimpleFlashSwap\n\nStatic method to encode a simple flash swap [method for a batchSwap](https://dev.balancer.fi/resources/swaps/flash-swaps).\n\n_NB: This method doesn't execute any swaps -- it returns an [ABI byte string](https://docs.soliditylang.org/en/latest/abi-spec.html) containing the data of the function call on a contract, which can then be sent to the network (ex. [sendTransaction](https://web3js.readthedocs.io/en/v1.2.11/web3-eth.html#sendtransaction)). to be executed. See example for more info._\n\n```js\n/**\n * @param {SimpleFlashSwapParameters}   params - BatchSwap information used for query.\n * @param {string}                      params.flashLoanAmount - initial input amount for the flash loan (first asset)\n * @param {string[]}                    params.poolIds - array of Balancer pool ids\n * @param {string[]}                    params.assets - array of token addresses\n * @param {string}                      params.walletAddress - array of token addresses\n * @returns {string}            encodedBatchSwapData - Returns an ABI byte string containing the data of the function call on a contract\n*/\nSwaps.encodeSimpleFlashSwap(simpleFlashSwap: {\n    flashLoanAmount: string,\n    poolIds: string[],\n    assets: string[]\n    walletAddress: string[]\n}): string\n```\n\n[Example](./examples/flashSwap.ts)\n\n### #querySimpleFlashSwap\n\nMethod to test if a simple flash swap is valid and see potential profits.\n\n```js\n/**\n * @param {SimpleFlashSwapParameters}   params - BatchSwap information used for query.\n * @param {string}                      params.flashLoanAmount - initial input amount for the flash loan (first asset)\n * @param {string[]}                    params.poolIds - array of Balancer pool ids\n * @param {string[]}                    params.assets - array of token addresses\n * @returns {Promise<{profits: Record<string, string>, isProfitable: boolean}>}       Returns an ethersjs transaction response\n*/\nswaps.querySimpleFlashSwap(batchSwap: {\n    kind: SwapType,\n    swaps: BatchSwapStep[],\n    assets: string[]\n}): string\n```\n\n[Example](./examples/querySimpleFlashSwap.ts)\n\n## Pricing Module\n\nExposes Spot Price functionality allowing user to query spot price for token pair.\n\n```js\nconst pricing = new Pricing(sdkConfig);\n```\n\n### #getSpotPrice\n\nCalculates Spot Price for a token pair - for specific pool if ID otherwise finds most liquid path and uses this as reference SP.\n\n@param { string } tokenIn Token in address.\n@param { string } tokenOut Token out address.\n@param { string } poolId Optional - if specified this pool will be used for SP calculation.\n@param { SubgraphPoolBase[] } pools Optional - Pool data. Will be fetched via dataProvider if not supplied.\n@returns  { string } Spot price.\n\n```js\nasync getSpotPrice(\n    tokenIn: string,\n    tokenOut: string,\n    poolId = '',\n    pools: SubgraphPoolBase[] = []\n): Promise<string>\n```\n\n[Example](./examples/spotPrice.ts)\n\n## Join Pool\n\nExposes Join functionality allowing user to join pools.\n\n```js\nconst balancer = new BalancerSDK(sdkConfig);\nconst pool = await balancer.poolsProvider.find(poolId);\nconst { to, functionName, attributes, data } = pool.buildJoin(params);\n```\n\n### #buildJoin\n\nBuilds a join transaction.\n\n```js\n/**\n * @param { string }   joiner - Address used to exit pool.\n * @param { string[] } tokensIn - Token addresses provided for joining pool (same length and order as amountsIn).\n * @param { string[] } amountsIn - Token amounts provided for joining pool in EVM amounts.\n * @param { string }   slippage - Maximum slippage tolerance in bps i.e. 50 = 0.5%.\n * @returns { Promise<JoinPoolAttributes> } Returns join transaction ready to send with signer.sendTransaction.\n*/\nbuildJoin: (\n  joiner: string,\n  tokensIn: string[],\n  amountsIn: string[],\n  slippage: string\n) => Promise<JoinPoolAttributes>;\n```\n\n[Example](./examples/join.ts)\n\n## RelayerService\n\nRelayers are (user opt-in, audited) contracts that can make calls to the vault (with the transaction “sender” being any arbitrary address) and use the sender’s ERC20 vault allowance, internal balance or BPTs on their behalf.\n\n```js\nconst relayer = new relayerService(\n    swapsService: SwapsService;\n    rpcUrl: string;\n);\n```\n\n### #swapUnwrapAaveStaticExactIn\n\nFinds swaps for tokenIn>wrapped Aave static tokens and chains with unwrap to underlying stable. ExactIn - Exact amount of tokenIn to use in swap.\n\n@param tokensIn - array to token addresses for swapping as tokens in.\n@param aaveStaticTokens - array contains the addresses of the Aave static tokens that tokenIn will be swapped to. These will be unwrapped.\n@param amountsIn - amounts to be swapped for each token in.\n@param rates - The rate used to convert wrappedToken to underlying.\n@param funds - Funding info for swap. Note - recipient should be relayer and sender should be caller.\n@param slippage - Slippage to be applied to swap section. i.e. 5%=50000000000000000.\n@param fetchPools - Set whether SOR will fetch updated pool info.\n@returns Transaction data with calldata. Outputs.amountsOut has final amounts out of unwrapped tokens.\n\n```js\nasync relayer.swapUnwrapAaveStaticExactIn(\n    tokensIn: string[],\n    aaveStaticTokens: string[],\n    amountsIn: BigNumberish[],\n    rates: BigNumberish[],\n    funds: FundManagement,\n    slippage: BigNumberish,\n    fetchPools: FetchPoolsInput = {\n        fetchPools: true,\n        fetchOnChain: false\n    }\n): Promise<TransactionData>\n```\n\n[Example](./examples/relayerSwapUnwrap.ts)\n\n### #swapUnwrapAaveStaticExactOut\n\nFinds swaps for tokenIn>wrapped Aave static tokens and chains with unwrap to underlying stable. ExactOut - Exact amount of tokens out are used for swaps.\n\n@param tokensIn - array to token addresses for swapping as tokens in.\n@param aaveStaticTokens - array contains the addresses of the Aave static tokens that tokenIn will be swapped to. These will be unwrapped.\n@param amountsUnwrapped - amounts of unwrapped tokens out.\n@param rates - The rate used to convert wrappedToken to underlying.\n@param funds - Funding info for swap. Note - recipient should be relayer and sender should be caller.\n@param slippage - Slippage to be applied to swap section. i.e. 5%=50000000000000000.\n@param fetchPools - Set whether SOR will fetch updated pool info.\n@returns Transaction data with calldata. Outputs.amountsIn has the amounts of tokensIn.\n\n```js\nasync relayer.swapUnwrapAaveStaticExactOut(\n    tokensIn: string[],\n    aaveStaticTokens: string[],\n    amountsUnwrapped: BigNumberish[],\n    rates: BigNumberish[],\n    funds: FundManagement,\n    slippage: BigNumberish,\n    fetchPools: FetchPoolsInput = {\n        fetchPools: true,\n        fetchOnChain: false\n    }\n): Promise<TransactionData>\n```\n\n[Example](./examples/relayerSwapUnwrap.ts)\n\n### #exitPoolAndBatchSwap\n\nChains poolExit with batchSwap to final tokens.\n\n@param params:\n@param exiter - Address used to exit pool.\n@param swapRecipient - Address that receives final tokens.\n@param poolId - Id of pool being exited.\n@param exitTokens - Array containing addresses of tokens to receive after exiting pool. (must have the same length and order as the array returned by `getPoolTokens`.)\n@param userData - Encoded exitPool data.\n@param minExitAmountsOut - Minimum amounts of exitTokens to receive when exiting pool.\n@param finalTokensOut - Array containing the addresses of the final tokens out.\n@param slippage - Slippage to be applied to swap section. i.e. 5%=50000000000000000.\n@param fetchPools - Set whether SOR will fetch updated pool info.\n@returns Transaction data with calldata. Outputs.amountsOut has amounts of finalTokensOut returned.\n\n```js\nasync relayer.exitPoolAndBatchSwap(\n    params: ExitAndBatchSwapInput {\n        exiter: string;\n        swapRecipient: string;\n        poolId: string;\n        exitTokens: string[];\n        userData: string;\n        minExitAmountsOut: string[];\n        finalTokensOut: string[];\n        slippage: string;\n        fetchPools: FetchPoolsInput;\n    }\n): Promise<TransactionData>\n```\n\n[Example](./examples/relayerExitPoolAndBatchSwap.ts)\n\n## Licensing\n\n[GNU General Public License Version 3 (GPL v3)](../../LICENSE).\n","browser":"dist/index.umd.js","scripts":{"dev":"rollup -c -w","lint":"eslint ./src --ext .ts --max-warnings 0","node":"npx hardhat node --fork $(grep ALCHEMY_URL .env | cut -d '=' -f2) --fork-block-number 14828550","test":"ts-mocha --paths --recursive -p tsconfig.testing.json 'src/**/*.spec.ts'","build":"rimraf dist && rollup -c","lint:fix":"eslint ./src --ext .ts --max-warnings 0 --fix","test:only":"ts-mocha --paths --recursive -p tsconfig.testing.json","prepublish":"yarn build","examples:run":"TS_NODE_PROJECT='tsconfig.testing.json' ts-node -r tsconfig-paths/register","subgraph:generate":"graphql-codegen --config src/modules/subgraph/codegen.yml -r dotenv/config"},"typings":"dist/index.d.ts","_npmUser":{"name":"defifofum","email":"DeFiFoFum0@gmail.com"},"repository":{"url":"https://github.com/ApeSwapFinance/apeswap-swap-v2-sdk","type":"git","directory":"balancer-js"},"description":"JavaScript SDK for interacting with the Balancer Protocol V2","directories":{},"dependencies":{"axios":"^0.24.0","lodash":"^4.17.21","graphql":"^15.6.1","bignumber.js":"^9.0.2","graphql-request":"^3.5.0","@balancer-labs/sor":"^4.0.1-beta.1","@balancer-labs/typechain":"^1.0.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","mocha":"^8.2.1","dotenv":"^10.0.0","eslint":"^7.9.0","ethers":"^5.0.0","rimraf":"^3.0.2","rollup":"^2.52.8","fishery":"^2.2.2","hardhat":"^2.9.3","ts-node":"^10.4.0","prettier":"^2.1.2","ts-mocha":"^9.0.2","typechain":"^5.1.1","typescript":"^4.0.2","@types/chai":"^4.2.12","@types/node":"^15.12.4","@types/mocha":"^8.0.3","@types/lodash":"^4.14.177","tiny-invariant":"^1.1.0","tsconfig-paths":"^3.12.0","rollup-plugin-dts":"^3.0.2","@ethersproject/abi":"^5.4.0","@rollup/plugin-json":"^4.1.0","@ethersproject/bytes":"^5.4.0","@graphql-codegen/add":"^3.1.0","@graphql-codegen/cli":"^2.3.0","@typechain/ethers-v5":"^7.0.1","@ethersproject/wallet":"^5.5.0","@ethersproject/address":"^5.4.0","eslint-plugin-prettier":"^3.1.4","@ethersproject/solidity":"^5.6.1","@rollup/plugin-commonjs":"^21.0.1","@ethersproject/bignumber":"^5.4.0","@ethersproject/constants":"^5.4.0","@ethersproject/contracts":"^5.4.0","@ethersproject/providers":"^5.4.5","@nomiclabs/hardhat-ethers":"^2.0.5","@rollup/plugin-typescript":"^8.2.1","@typescript-eslint/parser":"^4.1.1","@graphql-codegen/schema-ast":"^2.4.0","@graphql-codegen/typescript":"2.4.0","@rollup/plugin-node-resolve":"^13.0.0","eslint-plugin-mocha-no-only":"^1.1.1","@ethersproject/abstract-signer":"^5.4.0","@georgeroman/balancer-v2-pools":"^0.0.5","@graphql-codegen/introspection":"^2.1.0","@typescript-eslint/eslint-plugin":"^4.1.1","@graphql-codegen/typescript-resolvers":"2.4.1","@graphql-codegen/typescript-operations":"^2.2.0","@graphql-codegen/typescript-document-nodes":"^2.2.0","@graphql-codegen/typescript-graphql-request":"^4.3.0"},"peerDependencies":{"@ethersproject/abi":"^5.4.0","@ethersproject/bytes":"^5.4.0","@ethersproject/address":"^5.4.0","@ethersproject/bignumber":"^5.4.0","@ethersproject/constants":"^5.4.0","@ethersproject/contracts":"^5.4.0","@ethersproject/providers":"^5.4.5","@ethersproject/abstract-signer":"^5.4.0"},"_npmOperationalInternal":{"tmp":"tmp/swap-v2-sdk_0.0.1-alpha.4_1661194317704_0.6225951930840921","host":"s3://npm-registry-packages"}}},"time":{"created":"2022-07-14T18:25:26.962Z","modified":"2025-02-07T18:33:31.955Z","0.0.1-alpha.0":"2022-07-14T18:25:27.411Z","0.0.1-alpha.1":"2022-07-27T16:22:43.421Z","0.0.1-alpha.2":"2022-07-27T17:04:28.324Z","0.0.1-alpha.3":"2022-07-28T18:54:12.184Z","0.0.1-alpha.4":"2022-08-22T18:51:57.885Z"},"bugs":{"url":"https://github.com/ApeSwapFinance/apeswap-swap-v2-sdk/issues"},"license":"GPL-3.0-only","homepage":"https://github.com/ApeSwapFinance/apeswap-swap-v2-sdk/balancer-js#readme","repository":{"url":"https://github.com/ApeSwapFinance/apeswap-swap-v2-sdk","type":"git","directory":"balancer-js"},"description":"JavaScript SDK for interacting with the Balancer Protocol V2","maintainers":[{"email":"dev.efedaniels@gmail.com","name":"efedaniels"},{"email":"apefede09@gmail.com","name":"apefede"},{"email":"hello@apeguru.dev","name":"apeguru"},{"email":"DeFiFoFum0@gmail.com","name":"defifofum"},{"email":"n0mbr3al3at0r10@gmail.com","name":"nombrealeatorio"},{"email":"pathakshivam983@gmail.com","name":"shivammp"},{"email":"doublo54@gmail.com","name":"doublo54"},{"email":"759ixm@gmail.com","name":"ixm-759"}],"readme":"","readmeFilename":""}