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

nerveswap-sdk

v1.0.19

Published

nerve swap nerveswap nerveswap-sdk

Downloads

28

Readme

NERVESWAP SDK

Start

import nerveswap, { mainnet, testnet } from 'nerveswap-sdk
mainnet() // set up the network, default is mainnet

EVM to NERVE

Check token allowance

const needAuth = await nerveswap.evm.checkAuth({
  provider: 'ethereum', // the wallet collected to the dapp, ex: ethereum/NaboxWallet
  tokenContract: '',
  multySignContract: '',
  address: '', // your evm address
  amount: '' // transfer amount, ex: 1000000000000000000
})

Approve token

nerveswap.evm.approve({
  provider: 'ethereum',
  tokenContract: '',
  multySignContract: '',
  address: ''
});

Cross to NERVE

nerveswap.evm.crossIn({
  provider: 'ethereum',
  multySignContract: '',
  nerveAddress: '', // your nerve address
  amount: '',
  from: '', // your evm address
  tokenContract: ''
})

Get address and pub

/**
 * @param {object} param
 * @param {string} param.provider the wallet collected to the dapp, ex: ethereum/NaboxWallet
 * @param {string} param.address the collected address
 * @param {string} [param.message] the sign message, default is Generate Multi-chain Address
 * @returns {Promise<{address: { NERVE: string, NULS: string, EVM: string, TRON: string }, pub: string}>}
 */
nerveswap.getAccount(param)

NERVE Transfer

Transfer transaction

/**
 * @param {object} param
 * @param {string} param.provider
 * @param {string} param.from
 * @param {string} param.to
 * @param {number} param.assetChainId
 * @param {number} param.assetId
 * @param {string} param.amount
 * @param {string} [param.remark]
 * @param {number} param.type  -2|10  transfer type, default is 2. set to 10 when the target address 
 * @param {string} param.EVMAddress the sign address
 * @param {string} param.pub the pub of the sign address
 * @returns {Promise<{hash: string} | {error: {code: number, message: string}}>}
 */
nerveswap.transfer.transfer(param)

Withdrawal to L1, add withdrawal fee

/**
 * @param {object} param
 * @param {string} param.provider
 * @param {string} param.from
 * @param {number} param.assetChainId
 * @param {number} param.assetId
 * @param {string} param.amount
 * @param {object} param.feeInfo the withdrawal fee info
 * @param {string} param.feeInfo.amount
 * @param {number} param.feeInfo.assetChainId
 * @param {number} param.feeInfo.assetId
 * @param {string} param.heterogeneousAddress // L1 target address
 * @param {number} param.heterogeneousChainId
 * @param {string} [param.remark]
 * @param {string} param.EVMAddress
 * @param {string} param.pub
 * @returns {Promise<{hash: string} | {error: {code: number, message: string}}>}
 */
nerveswap.transfer.withdrawal(param)

/**
 * @param {object} param
 * @param {string} param.provider
 * @param {string} param.from
 * @param {string} param.amount
 * @param {number} param.assetChainId
 * @param {number} param.assetId
 * @param {string} param.txHash the hash of the withdrawal tx
 * @param {string} [param.remark]
 * @param {string} param.EVMAddress
 * @param {string} param.pub
 * @returns {Promise<{hash: string} | {error: {code: number, message: string}}>}
 */
nerveswap.transfer.addFee(param)

Nerve Swap

const swap = new nerveswap.swap()

Calculate the number of swaps

/**
 * @param {object} param
 * @param {string} param.fromAssetKey
 * @param {string} param.toAssetKey
 * @param {string} param.amount
 * @param {string} [param.direction = from | to] default is from
 * @returns {Promise<{amount: string, priceImpact: string, routes: string[], fee: string}>}
 */
swap.getSwapInfo(param)

Send swap tx

/**
 * @param {object} param
 * @param {string} param.provider
 * @param {string} param.from
 * @param {string} param.fromAssetKey
 * @param {string} param.toAssetKey
 * @param {string} param.amount
 * @param {string} [param.slippage='0.5']
 * @param {string} [param.remark]
 * @param {string} param.EVMAddress
 * @param {string} param.pub
 * @returns {Promise<{hash: string} | {error: {code: number, message: string}}>}
 */
swap.swapTrade(param)

Nerve Liquidity

Send create liquidity pair tx

/**
 * @param {object} param
 * @param {string} param.provider
 * @param {string} param.from
 * @param {object} param.tokenA
 * @param {number} param.tokenA.assetChainId
 * @param {number} param.tokenA.assetId
 * @param {object} param.tokenB
 * @param {number} param.tokenB.assetChainId
 * @param {number} param.tokenB.assetId
 * @param {string} [param.remark]
 * @param {string} param.EVMAddress
 * @param {string} param.pub
 * @returns {Promise<{hash: string} | {error: {code: number, message: string}}>}
 */
nerveswap.liquidity.createPair(param)

Cal the amount of add liquidity

/**
 * @param {object} param
 * @param {string} param.tokenAKey ex: 5-1
 * @param {string} param.tokenBKey ex: 2-1
 * @param {string} param.amount
 * @param {string} [param.direction= from | to]
 * @param {boolean} [param.refresh] force to refresh
 * @returns {Promise<string>}
 */
nerveswap.liquidity.calAddLiquidity(param)

Send add liquidity tx

/**
 * @param {object} param
 * @param {string} param.provider
 * @param {string} param.from
 * @param {object} param.tokenA
 * @param {number} param.tokenA.assetChainId
 * @param {number} param.tokenA.assetId
 * @param {string} param.tokenA.amount
 * @param {object} param.tokenB
 * @param {number} param.tokenB.assetChainId
 * @param {number} param.tokenB.assetId
 * @param {string} param.tokenB.amount
 * @param {string} [param.remark]
 * @param {string} param.EVMAddress
 * @param {string} param.pub
 * @returns {Promise<{hash: string} | {error: {code: number, message: string}}>}
 */
nerveswap.liquidity.addLiquidity(param)

Cal the amount of remove liquidity

/**
 * @param {object} param
 * @param {string} param.tokenAKey
 * @param {string} param.tokenBKey
 * @param {string} param.amount
 * @param {boolean} [param.refresh]
 * @returns {Promise<{tokenAAmount: string, tokenBAmount: string}>}
 */
nerveswap.liquidity.calRemoveLiquidity(param)

Send remove liquidity tx

/**
 * @param {object} param
 * @param {string} param.provider
 * @param {string} param.from
 * @param {string} param.removeAmount
 * @param {object} param.tokenA
 * @param {number} param.tokenA.assetChainId
 * @param {number} param.tokenA.assetId
 * @param {object} param.tokenB
 * @param {number} param.tokenB.assetChainId
 * @param {number} param.tokenB.assetId
 * @param {object} param.tokenLP the liquidity pair info
 * @param {number} param.tokenLP.assetChainId
 * @param {number} param.tokenLP.assetId
 * @param {string} [param.remark]
 * @param {string} param.EVMAddress
 * @param {string} param.pub
 * @returns {Promise<{hash: string} | {error: {code: number, message: string}}>}
 */
nerveswap.liquidity.removeLiquidity(param)

Farm

Send farm stake tx

/**
 * @param {object} param
 * @param {string} param.provider
 * @param {string} param.from
 * @param {string} param.amount
 * @param {numbrt} param.assetChainId
 * @param {numbrt} param.assetId
 * @param {string} param.farmHash
 * @param {string} [param.remark]
 * @param {string} param.EVMAddress
 * @param {string} param.pub
 * @returns {Promise<{hash: string} | {error: {code: number, message: string}}>}
 */
nerveswap.farm.stake(param)

Claim

/**
 * @param {object} param
 * @param {string} param.provider
 * @param {string} param.from
 * @param {numbrt} param.assetChainId
 * @param {numbrt} param.assetId
 * @param {string} param.farmHash
 * @param {string} [param.remark]
 * @param {string} param.EVMAddress
 * @param {string} param.pub
 * @returns {Promise<{hash: string} | {error: {code: number, message: string}}>}
 */
nerveswap.farm.claim(param)

Unstake

/**
 * @param {object} param
 * @param {string} param.provider
 * @param {string} param.from
 * @param {string} param.amount
 * @param {numbrt} param.assetChainId
 * @param {numbrt} param.assetId
 * @param {string} param.farmHash
 * @param {string} [param.remark]
 * @param {string} param.EVMAddress
 * @param {string} param.pub
 * @returns {Promise<{hash: string} | {error: {code: number, message: string}}>}
 */
nerveswap.farm.withdrawal(param)