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

bounce-sdk-beta

v1.2.3

Published

Bounce finance quick building applications

Downloads

9

Readme

bounce-sdk-beta

Official Site: https://app.bounce.finance

Node SDK for quick calls to Bounce functions

Introduction

Token decentralized auction platform, including fixed swap auctions, Dutch-style auctions and sealed bid auctions.

Using bounce-sdk-beta allows you to quickly invoke platform-related functions

  1. to query and listen to some platform-related content information
  2. Quickly invoke the platform function contract and participate in the auction
  3. other related toolkits, the latest verified contract address and ABI

Quick Start

To run the tests, follow these steps. You must have at least node v10 installed

Installation package

npm install bounce-sdk-beta
or
yarn add bounce-sdk-beta

This library comes with typescript type definitions, no need to install additional @types package

Usage

You can export methods, types, or class directly for use in your project

import { BounceClient } from "bounce-sdk-beta"
import { SupportChain } from "bounce-sdk-beta/dist/types"

interface IUniversalResponse {
    code: number, msg: string
}

export const bounceClientExamples = async () => {
    const bounceClient = new BounceClient(SupportChain.Mainnet)

    interface IPoolsResponse extends IUniversalResponse {
        data: Record<string, { total: 13, list: any[] | null }>
    }
    // query all pools
    const pools = await bounceClient.getPools<IPoolsResponse>()
}

Methods Guide

Bouncer

Platform user examples to quickly invoke platform-related contract methods

constructor(provider: ethers.providers.JsonRpcProvider, signer: ethers.Wallet)
  • provider: Node providers instantiated using Rpc nodes
  • Instantiated web3 wallet using private key

Attributes

| name | type | params | return | | ----------- | -------- | ------------------------------------------------------------ | ------ | | getBalance | Call | token: Currency | Wei | | allowance | Call | token: Currencyspender: string | Wei | | approve | Write | token: Currencyspender: stringwei_amount: string = MAX_ALLOWANCE | | | signMessage | Function | msgStr: string | String | | swap | Write | params: {poolType: PoolTypepoolId: number payment: numbermerkleProofs?: string[]} | | | reverse | Write | params: {poolType: PoolTypepoolId: numberreverseAmount0: number } | |

Example

import { Bouncer, Currency } from "bounce-sdk-beta"
import { SupportChain } from "bounce-sdk-beta/dist/types"

const signer = ethers.Wallet('your parvateKey')
const provider = new ethers.providers.JsonRpcProvider(ChainState[CHAIN_ID].rpcUrls[0])
const bouncer = new Bouncer(provider, signer)

const swapTransaction = await bouncer.swap({
    poolType: 'FIXED_SWAP',
    poolId: 15,
    payment: 0.0001
})

const swapTransactionRes = await swapTransaction.wait()

BounceClient

Rpc client, query Rpc public method class

constructor(chainId: SupportChain)
  • chainId: Corresponding chain ID

Attributes

| name | type | params | return | | ------------- | --------- | ------------------------------------------------------------ | ------ | | getPools | Axis post | options: {offset?: number,limit?: number,category?: 1,creatorAddress?: string,creatorName?: string,orderBy?: "openTs",poolId?: string,poolName?: string,poolStatusFrontend?: null,token0Address?: string} | | | getProfile | Axis post | params: { userId: number } | | | getInvest | Axis post | params: {limit: number, offset: number, userId: number} | | | getPoolDetail | Axis post | poolType: PoolType poolId: number chainId: SupportChain | |

Example

import { BounceClient } from "bounce-sdk-beta"
import { SupportChain } from "bounce-sdk-beta/dist/types"

const bounceClient = new BounceClient(SupportChain.Mainnet)
// query all pools
const pools = await bounceClient.getPools<IPoolsResponse>()

Currency

Quickly construct a Currency class for Erc20 Token, you can very easily call the base ERC20 methods using the default RPC of the corresponding chain, such as balanceOf, approve, transfer...

constructor(tokenAddress: string, chainId: SupportChain) 
  • tokenAddress: Address of the Erc20 token contract you want to construct
  • chainId: Corresponding chain ID

Attributes

| name | type | params | return | | ----------- | ------- | ------------------------------------------------------------ | -------------------------- | | address | Address | | String | | name | | | String | | symbol | | | String | | decimals | | | Number | | totalSupply | Call | none | Wei | | balanceOf | Call | none | Wei | | allowance | Call | token: Currencyspender: string | Wei | | approve | Write | signer: ethers.Wallet |ethers.providers.JsonRpcSigner spender: stringwei_amount: string = MAX_ALLOWANCE | ethers.ContractTransaction |

Example

import { Currency } from "bounce-sdk-beta"
import { SupportChain } from "bounce-sdk-beta/dist/types"

const busd = new Currency(TokenContractAddr[CHAIN_ID].BUSD as string, CHAIN_ID)
const approveTransaction = await bouncer.approve(
  busd,
  LogicContractAddr[CHAIN_ID].BounceFixedSwap,
  bn_toWei(0.88)
)

const approveTransactionRes = await approveTransaction.wait()

Contracts

For some wrapper methods and properties related to web3, you can safely get the verified information from here

SupportChain

export enum SupportChain {
    Mainnet = 1,
    Binance = 56,
    Arbitrum = 42161
}

Currently only Mainnet, Binance, Arbitrum are supported

ChainState

export const ChainState: Record<SupportChain, IChainConfig> 

Return the generic chain configuration for supported chains

LogicContractAddr

export const LogicContractAddr: Record<SupportChain, { [key in LogicContractType]: string }>

Return verified logic contract address information

TokenContractAddr

type TokenContracType = 'AUCTION' | "USDT" | 'USDC' | "DAI" | 'BUSD' | 'ARB' | 'ETH' | 'WBTC' | 'WETH' | 'UNI'

export const TokenContractAddr: Record<SupportChain, { [key in TokenContracType]?: string }> 

Return verified token contract address information

Tool Library

Bn.ts

  • wrapperBn: Wrap number | string | BigNumber | EBignumber to Bignumber

  • bn_fromWei: Quickly convert cognitive quantities into wei quantities

  • bn_toWei: Quickly convert wei number to cognitive quantity

  • GWEI: EBignumber.from(10).pow(9)

  • ETHER: EBignumber.from(10).pow(18)

License

This project is licensed under the MIT License - see the LICENSE file for details.