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
- to query and listen to some platform-related content information
- Quickly invoke the platform function contract and participate in the auction
- 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
toBignumber
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.