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

@flooz/trade-sdk

v0.6.1

Published

flooz.trade SDK

Downloads

13

Readme

Flooz.trade SDK

Flooz.trade SDK allows to easily integrate Multichain token swaps on Ethereum Mainnet, Binance Smart Chain & Polygon.

Under the hood it's leveraging 0x API to aggregate & provide the best price across over 70 DEXes.

More information can also be found here.

Getting started

  • Install the @flooz/trade-sdk package:

    yarn add @flooz/sdk
  • Import the SDK:

    import { Flooz } from '@flooz/trade-sdk';

Examples

This walks through, how to setup the SDK & execute swaps & trades. A working example can also be found in the ./examples folder.

Setup currencies

import { Token } from './src/common/token';
import { Ether } from './src/common/ether';

// Initialize native Currencies on each Chain
const ETH = Ether.onChain(1);
const BNB = Ether.onChain(56);
const MATIC = Ether.onChain(137);

// Initialize BSC Token
const BUSD = new Token(56, '0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56', 18, 'BUSD', 'BUSD Token');
const SYA = new Token(56, '0x83A86adf1a7c56e77d36d585B808052e0a2aAD0e', 9, 'SYA', 'Save Your Assets', 10);

// Initialize ETH MAINNET Token
const DAI = new Token(1, '0x6b175474e89094c44da98b954eedeac495271d0f', 18, 'DAI', 'Dai Stablecoin');

// Initialize POLYGON Token
const USDC = new Token(137, '0x2791bca1f2de4661ed88a30c99a7a9449aa84174', 6, 'USDC', 'USD Coin');

Get a quote

Returns a quote with the best price found.

const quote = await new Flooz().getQuote({
	userAddress: '0xb44ac514588BE99870220d12120815bc3D349507',
	sellCurrency: BUSD,
	buyCurrency: SYA,
	sellAmount: BigNumber.from('1000')
	buyAmount: BigNumber.from('0')
	slippage: 0,
)

Get a swap Transaction

Returns a quote with the best price found & a transaction to execute the Transaction for the user on the Blockchain.

const swapTransaction = await new Flooz().getSwapTransaction({
	userAddress: '0xb44ac514588BE99870220d12120815bc3D349507',
	sellCurrency: BUSD,
	buyCurrency: SYA,
	sellAmount: BigNumber.from('1000')
	buyAmount: BigNumber.from('0')
	slippage: 0,
})