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 🙏

© 2026 – Pkg Stats / Ryan Hefner

kyber-fpr-sdk

v0.1.5

Published

SDK to deploy and operate a Kyber FPR

Readme

Kyber Fed Price Reserve JS SDK

This SDK allows market makers and developers to deploy, maintain and operate an on-chain Kyber Network Fed Price Reserve using Javascript and node.

Useful Links

Installation

Install the package with:

npm install --save kyber-fpr-sdk    

Usage

There are 2 main classes in this SDK.

  • Deployer class allows users to deploy new smart contracts.

  • Reserve class allows users to manage the key market making functions, including permission management, setting and controling quotes and fund security.

Deployer Class

The Deployer class only needs the web3 provider to init. After deployment, it returns a set of addresses for required contracts.

// ethereum Remote Node Provider, for example infura.io
const provider = new Web3.providers.HttpProvider('ethereum-node-url')
const web3 = new Web3(provider)

// initialize account from private key
const account = dpl.web3.eth.accounts.privateKeyToAccount('private-key')
// initialize account from keystore file
// const account = dpl.web3.eth.accounts.decrypt(fs.readFileSync(), "your-keystore-passphrase");

dpl.web3.eth.accounts.wallet.add(account)

const dpl = new Deployer(web3)

let addresses;
(async () =>  { 
    addresses = await dpl.deploy(account)
    console.log(addresses)
})()

Reserve Class

Reserve class allow users to make call to the smart contracts and query its state on the blockchain.

The following example queries the sanityRatesContract's admin and the SanityRates contract:

const reserve = new Reserve(web3, addresses);
const KNCTokenAddress = "0x095c48fbaa566917474c48f745e7a430ffe7bc27";
const ETHTokenAddress = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";

(async () => {
  // get sanityContract address
  console.log('SanityRates contract address is ', await reserve.sanityRates.admin())
  const sanityRates = await reserve.getSanityRate(KNCTokenAddress, ETHTokenAddress)
  console.log('SanityRates for KNC-ETH is ', sanityRates)
})();

Permission Control

More on permission control at permission groups. To set permission with SDK, call to the contract that needs to change account's role with these methods from baseContract. The following example add Operator 0x0a4c79cE84202b03e95B7a692E5D728d83C44c76 to ConversionRates contract

const reserve = new Reserve(web3, addresses);

(async () => {
  // admin operations
  await reserve.ConversionRates.addOperator(adminAccount, '0x0a4c79cE84202b03e95B7a692E5D728d83C44c76');
  console.log(await reserve.ConversionRates.getOperators())
})();

Control Rates

Control rates operations can be called directly as reserve Object's methods. There are 5 operations regarding set rates: setRate, setSanityRates, setReasonableDiff, setQtyStepFuncion and setImbalanceStepFunction. More about the meaning of these operations can be viewed in the onboarding tutorials. The following example set the base rate for KNC token.

const reserve = new Reserve(web3, addresses);
const operatorAccount = web3.eth.accounts.privateKeyToAccount('operatorAccountPrivateKey');
const KNCTokenAddress = "0x095c48fbaa566917474c48f745e7a430ffe7bc27";

(async () => {
  // create rateSetting object and set base buy/ sell rate.
  rate = new RateSetting(KNCTokenAddress, 10000000, 1100000)
  await reserve.setRate( 
    operatorAccount,
    [rate],
    (await web3.eth.getBlockNumber()) + 1
  )
  // should log 10000000 and 1100000 as buy/sell rate
  console.log(await reserve.getBuyRates(KNCTokenAddress, 1,await web3.eth.getBlockNumber()))
  console.log(await reserve.getSellRates(KNCTokenAddress, 1,await web3.eth.getBlockNumber()))
})();

Fund Security

To secure reserve's fund, there are two main operations:

The following example show how to stop trade from the reserve and withdraw 1000 KNC from reserve to a receiver account to secure the fund:

  const reserve = new Reserve(web3, addresses);
  const adminAccount = web3.eth.accounts.privateKeyToAccount('adminAccountPrivateKey');
  const operatorAccount = web3.eth.accounts.privateKeyToAccount('operatorAccountPrivateKey');
  const alerterAccount = web3.eth.accounts.privateKeyToAccount('alerterAccountPrivateKey');
  const receiverAddress = '0x69E3D8B2AE1613bEe2De17C5101E58CDae8a59D4' ;
  const KNCTokenAddress = '0x095c48fbaa566917474c48f745e7a430ffe7bc27';

  (async () => {
    // stop trade. 
    await reserveContract.disableTrade(alerterAccount)
    // approve receiver to receive KNC from this reserve
    await reserveContract.approveWithdrawAddress(operatorAccount,KNCTokenAddress, receiverAddress)
    if (await reserveContract.approvedWithdrawAddresses(receiverAddress, KNCTokenAddress) == true) {
      await reserveContract.withdraw(adminAccount, KNCTokenAddress, 1000)
    } else {
      console.log('cannot withdraw KNC at this moment, please retry again later')
    }
  })();