Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@albean/sdk

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@albean/sdk

  • 0.1.0-beta-6
  • unpublished
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Beanstalk SDK

This is a JavaScript SDK for the Beanstalk web app.

Using the SDK

Create an instance

import { BeanstalkSDK } from "@beanstalk/sdk";

const sdk = new BeanstalkSDK(options);

SDK contructor options:

const options = {
  // etherjs Signer. Optional
  signer,

  // etherjs Provider. Optional
  provider,

  // rpcUrl
  rpcUrl,

  // Data source for balances. Optional, either
  //  - DataSource.LEDGER (default)
  //  - DataSource.SUBGRAPH
  source,

  // bool, print debug output. default `false`
  DEBUG
};
  • options object is optional. If ommited, SDK will use an ethers.getDefaultProvider()
  • If rpcUrl is provided, SDK will use a WebSocketProvider or JsonRpcProvider, depending on the protocol in the url (ws vs http)
  • If signer is provided, sdk.provider will be set to signer.provider

Library Exports

The following objects are available for import from the library:

import {
  BeanstalkSDK,
  Utils,
  TokenValue
  Token,
  NativeToken,
  ERC20Token,
  BeanstalkToken,
  Address,
  ChainID
} from "@beanstalk/sdk";

Example

Swap 1.5 ETH to BEAN
const sdk = new BeanstalkSDK({ signer });

const fromToken = sdk.tokens.ETH;
const toToken = sdk.tokens.BEAN;
const account = signer.address;
const amount = sdk.tokens.ETH.amount(1.5);
const slippage = 0.1; // 0.1% : 0.1/100

const swap = sdk.swap.buildSwap(fromToken, toToken, account);
const est = await swap.estimate(amount);

console.log(`You'd receive ${est.toHuman()} ${toToken.symbol}`);

const txr = await swap.execute(amount, slippage);
await txr.wait();

API Docs

View full API documentation

FAQs

Package last updated on 14 Nov 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc