npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@rumble-finance/sdk

v1.0.0

Published

JavaScript SDK for interacting with the Rumble Finance Protocol

Downloads

3

Readme

Rumble Javascript SDK

A JavaScript SDK which provides commonly used utilties for interacting with Rumble Protocol V2.

Installation

Getting Started

import { BalancerSDK, ConfigSdk, Network } from '@balancer-labs/sdk';

const config: ConfigSdk = {
    network: Network.MAINNET,
    rpcUrl: `https://kovan.infura.io/v3/${process.env.INFURA}`,
};
const balancer = new BalancerSDK(config);

SwapsService

The SwapsService provides function to query and make swaps using Rumble liquidity.

const swaps = new swapService({
  network: Network;
  rpcUrl: string;
});

queryBatchSwap

The Rumble Vault provides a method to simulate a call to batchSwap. This 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.

@param batchSwap - BatchSwap information used for query. @param batchSwap.kind - either exactIn or exactOut. @param batchSwap.swaps - sequence of swaps. @param batchSwap.assets - array contains the addresses of all assets involved in the swaps. @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.

swaps.queryBatchSwap(batchSwap: {
    kind: SwapType,
    swaps: BatchSwapStep[],
    assets: string[]
}): Promise<BigNumberish[]>

Example

queryBatchSwapWithSor

Uses SOR to create and query a batchSwap for multiple tokens in > multiple tokensOut.

@param queryWithSor - Swap information used for querying using SOR. @param queryWithSor.tokensIn - Array of addresses of assets in. @param queryWithSor.tokensOut - Array of addresses of assets out. @param queryWithSor.swapType - Type of Swap, ExactIn/Out. @param queryWithSor.amounts - Array of amounts used in swap. @param queryWithSor.fetchPools - Set whether SOR will fetch updated pool info. @returns Returns amount of tokens swaps along with swap and asset info that can be submitted to a batchSwap call.

swaps.queryBatchSwapWithSor(queryWithSor: {
    tokensIn: string[],
    tokensOut: string[],
    swapType: SwapType,
    amounts: BigNumberish[],
    fetchPools: FetchPoolsInput;
}):
Promise<QueryWithSorOutput {
    returnAmounts: string[];
    swaps: BatchSwapStep[];
    assets: string[];
    deltas: string[];
}>

Example

RelayerService

Relayers 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.

const relayer = new relayerService(
    swapsService: SwapsService;
    rpcUrl: string;
);

swapUnwrapAaveStaticExactIn

Finds swaps for tokenIn>wrapped Aave static tokens and chains with unwrap to underlying stable. ExactIn - Exact amount of tokenIn to use in swap.

@param tokensIn - array to token addresses for swapping as tokens in. @param aaveStaticTokens - array contains the addresses of the Aave static tokens that tokenIn will be swapped to. These will be unwrapped. @param amountsIn - amounts to be swapped for each token in. @param rates - The rate used to convert wrappedToken to underlying. @param funds - Funding info for swap. Note - recipient should be relayer and sender should be caller. @param slippage - Slippage to be applied to swap section. i.e. 5%=50000000000000000. @param fetchPools - Set whether SOR will fetch updated pool info. @returns Transaction data with calldata. Outputs.amountsOut has final amounts out of unwrapped tokens.

async relayer.swapUnwrapAaveStaticExactIn(
    tokensIn: string[],
    aaveStaticTokens: string[],
    amountsIn: BigNumberish[],
    rates: BigNumberish[],
    funds: FundManagement,
    slippage: BigNumberish,
    fetchPools: FetchPoolsInput = {
        fetchPools: true,
        fetchOnChain: false
    }
): Promise<TransactionData>

Example

swapUnwrapAaveStaticExactOut

Finds swaps for tokenIn>wrapped Aave static tokens and chains with unwrap to underlying stable. ExactOut - Exact amount of tokens out are used for swaps.

@param tokensIn - array to token addresses for swapping as tokens in. @param aaveStaticTokens - array contains the addresses of the Aave static tokens that tokenIn will be swapped to. These will be unwrapped. @param amountsUnwrapped - amounts of unwrapped tokens out. @param rates - The rate used to convert wrappedToken to underlying. @param funds - Funding info for swap. Note - recipient should be relayer and sender should be caller. @param slippage - Slippage to be applied to swap section. i.e. 5%=50000000000000000. @param fetchPools - Set whether SOR will fetch updated pool info. @returns Transaction data with calldata. Outputs.amountsIn has the amounts of tokensIn.

async relayer.swapUnwrapAaveStaticExactOut(
    tokensIn: string[],
    aaveStaticTokens: string[],
    amountsUnwrapped: BigNumberish[],
    rates: BigNumberish[],
    funds: FundManagement,
    slippage: BigNumberish,
    fetchPools: FetchPoolsInput = {
        fetchPools: true,
        fetchOnChain: false
    }
): Promise<TransactionData>

Example

exitPoolAndBatchSwap

Chains poolExit with batchSwap to final tokens.

@param params: @param exiter - Address used to exit pool. @param swapRecipient - Address that receives final tokens. @param poolId - Id of pool being exited. @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.) @param userData - Encoded exitPool data. @param minExitAmountsOut - Minimum amounts of exitTokens to receive when exiting pool. @param finalTokensOut - Array containing the addresses of the final tokens out. @param slippage - Slippage to be applied to swap section. i.e. 5%=50000000000000000. @param fetchPools - Set whether SOR will fetch updated pool info. @returns Transaction data with calldata. Outputs.amountsOut has amounts of finalTokensOut returned.

async relayer.exitPoolAndBatchSwap(
    params: ExitAndBatchSwapInput {
        exiter: string;
        swapRecipient: string;
        poolId: string;
        exitTokens: string[];
        userData: string;
        minExitAmountsOut: string[];
        finalTokensOut: string[];
        slippage: string;
        fetchPools: FetchPoolsInput;
    }
): Promise<TransactionData>

Example

Licensing

GNU General Public License Version 3 (GPL v3).