Crates.io | balancer_sdk |
lib.rs | balancer_sdk |
version | 0.1.16-alpha |
source | src |
created_at | 2022-06-14 14:36:51.787057 |
updated_at | 2022-06-16 16:08:23.121299 |
description | A Rust SDK which provides commonly used utilties for interacting with Balancer Protocol V2 |
homepage | https://crates.io/crates/balancer_sdk |
repository | https://github.com/drewdrewthis/balancer-sdk/tree/develop/balancer-rs |
max_upload_size | |
id | 605863 |
size | 954,352 |
This project was funded by the Balancer Grants subDAO. Read the press release on Medium.
DISCLAIMER: While balancer-rs is intended to be a useful tool to simplify interacting with Balancer V2 Smart Contracts, this package is an ALPHA-build and should be considered as such. Use at your own risk! This package is capable of sending Ethereum (or EVM compatible) tokens controlled by whatever private key you provide. User assumes all liability for using this software; contributors to this package are not liable for any undesirable results. Users are STRONGLY encouraged to experiment with this package on testnets before using it on mainnet with valuable assets.
There isn’t currently any Rust support in the Balancer ecosystem, so this SDK is a great way to attract Rust developers, as well as bring a popular, fast, and secure language to the growing collection of SDKs Balancer provides. Specifically, the Rust SDK will provide full Rust language support for interacting with:
For complete usage documentation, including all interfaces, definitions, and extensive usage examples, see the Rust Doc
balancer-rs has been tested on:
The balancer-rs sdk can be installed as a crate from https://crates.io/crates/balancer_sdk. Simply add the following to your [dependencies]
in your Rust project's Cargo.toml
file:
[dependencies]
balancer_sdk = "*"
Once installed, you will be able to use the Balancer Rust module as follows:
An example of how to get the WETH address from the Vault contract API
#[tokio::main]
async fn main() {
let rpc_url = "https://rpc.flashbots.net/";
let transport = ethcontract::web3::transports::Http::new(rpc_url).unwrap();
let web3 = ethcontract::Web3::new(transport);
let vault_instance = balancer_sdk::vault::Vault::new(web3);
let weth_address = vault_instance.weth().call().await.unwrap();
}
./tests
To run tests:
$ cargo test -all
TBD
Balancer continues to add new pool types that have new contract APIs. To add support for a new pool:
build.rs
script like the otherscargo build
The GIT repository contains a number of complete and working examples which can be found in the ./examples
directory.
To run an example:
$ cargo run --example [name]