Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@georgeroman/balancer-v2-pools
Advanced tools
balancer-v2-pools
Simple SDK for simulating the exact on-chain behaviour of various Balancer v2 pools.
In order to keep things as lean as possible, all dependencies of this package are marked as peer dependencies. In order to only use the math functions provided by this package (eg. WeightedMath
, StableMath
, LinearMath
), it's not required to install any of these peer dependencies. However, for using the high-level pool classes/helpers all peer dependencies must get installed (eg. via npm-install-peers).
import { JsonRpcProvider } from "@ethersproject/providers";
import { WeightedPool } from "@georgeroman/balancer-v2-pools";
const provider = new JsonRpcProvider(process.env.RPC_ENDPOINT);
// WETH/DAI 60/40 on Mainnet
const pool = await WeightedPool.initFromOnchain(
provider,
"0x0b09dea16768f0799065c475be02919503cb2a3500020000000000000000001a",
"mainnet"
);
// Swap
const amountOut = pool.swapGivenIn("WETH", "DAI", "100");
// Join
const bptOut = pool.joinExactTokensInForBptOut({
WETH: "1",
DAI: "2000",
});
// Exit
const tokensOut = pool.exitExactBptInForTokensOut("1.23");
Mainnet forking is used for testing in order to make sure the SDK exactly match the EVM. Make sure to have a .env
file in the root directory, containing the following definitions (the given block number must include the instances of the pools used in the tests):
RPC_URL=
BLOCK_NUMBER=
The setup I recommend for deterministic tests is the following:
RPC_URL=https://eth-mainnet.alchemyapi.io/v2/${ALCHEMY_KEY}
BLOCK_NUMBER=13128465
To execute the tests locally, simply run:
# Install dependencies
npm install
# Run tests
npm test
FAQs
<code>balancer-v2-pools</code>
The npm package @georgeroman/balancer-v2-pools receives a total of 87 weekly downloads. As such, @georgeroman/balancer-v2-pools popularity was classified as not popular.
We found that @georgeroman/balancer-v2-pools demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.