1.2.3 • Published 1 year ago

bounce-sdk-beta v1.2.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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

nametypeparamsreturn
getBalanceCalltoken: CurrencyWei
allowanceCalltoken: Currencyspender: stringWei
approveWritetoken: Currencyspender: stringwei_amount: string = MAX_ALLOWANCE
signMessageFunctionmsgStr: stringString
swapWriteparams: {poolType: PoolTypepoolId: number payment: numbermerkleProofs?: string[]}
reverseWriteparams: {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

nametypeparamsreturn
getPoolsAxis postoptions: {offset?: number,limit?: number,category?: 1,creatorAddress?: string,creatorName?: string,orderBy?: "openTs",poolId?: string,poolName?: string,poolStatusFrontend?: null,token0Address?: string}
getProfileAxis postparams: { userId: number }
getInvestAxis postparams: {limit: number, offset: number, userId: number}
getPoolDetailAxis postpoolType: 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

nametypeparamsreturn
addressAddressString
nameString
symbolString
decimalsNumber
totalSupplyCallnoneWei
balanceOfCallnoneWei
allowanceCalltoken: Currencyspender: stringWei
approveWritesigner: ethers.Wallet |ethers.providers.JsonRpcSigner spender: stringwei_amount: string = MAX_ALLOWANCEethers.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.

1.2.3

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.2.0

1 year ago

1.1.18

1 year ago

1.1.17

1 year ago

1.1.16

1 year ago

1.1.15

1 year ago

1.1.14

1 year ago

1.1.13

1 year ago

1.1.12

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago