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

fr-bonus

v1.0.1

Published

FR Bonus library

Downloads

2

Readme

ICO bonus based on Wings FR

This repository explains how to give bonus to ICO participaints based on participant FR (Forecasting Raiting), contains examples and library for usage and integrate to your ICO contracts.

Introduction

Each forecaster on Wings platform has FR, that can be increasing/decrasing with time and forecasts accuracy, based on it, we can give additional bonus to people, who holds large FR, and do very quality forecasts.

This repo contains explanation how to do a bonus for such participants, include library that calculate bonus based on max FR (you can take max FR on FR list portal), participant FR and max bonus.

To get more details see examples.

Installation

Requirements:

  • Nodejs
  • Truffle
  • RPC Node (Testrpc/Parity/Get)

Installation with NPM:

npm install fr-bonus  

Tests

Launch:

USER_STORAGE=0x94B2F026A75BE2556C78A6D1f573bD79Fdfb1962  truffle test

Important: Test Example.js woun't work without provided User storage contract address, use default User Storage address on mainnet: 0x94B2F026A75BE2556C78A6D1f573bD79Fdfb1962.

Migrations

Standard truffle migrations, see details in migrations folder.

Examples

This path describing example, how you can integrate FRBonus lib to your ICO contract and make it possible to give bonus based on FR.

First what you need to do is add FRBonus library to your smart contracts, let's do it with npm:

npm install fr-bonus  

Once installed do import of FRBonus library and IUserStorage interface to your smart contracts:

import "./IUserStorage.sol";
import "./FRBonus.sol";

So let's see on libraries and contracts:

  • FRBonus:
    • getBonus(uint64 _maxFr, uint64 _usrFR, uint256 _maxBonus) public returns (uint256) - Function that returns bonus, based on maximum FR (you can take it from FR list portal), user FR (take from IUserStorage), and max bonus you are ready to provide (in percents, e.g. 1%-100%). Returns bonus in percent.
  • IUserStorage:
    • getFR(address _account) public constant returns(uint64 FR) - Takes user account address and returns FR of this account.

Important: IUserStorage interface should be initialize by User Storage address deployed on mainnet network, address is: 0x94B2F026A75BE2556C78A6D1f573bD79Fdfb1962.

Let's try to add it to our code so:

uint256 public maxFRBonus = 20; // Max bonus we are ready to allocate
uint64 public maxFR = 771; // Maximum FR take from FR list portal - https://wings-utilities.com/

uint256 bonus = FRBonus.getBonus(maxFR, IUserStorage(userStorage).getFR(msg.sender), maxFRBonus); // take a bonus, will be some percent %.

See how we take FR of participant:

IUserStorage(userStorage).getFR(msg.sender)

userStorage is address and should be: 0x94B2F026A75BE2556C78A6D1f573bD79Fdfb1962.

It's all, then you can use your bonus to increase allocation of tokens for participant.

For more details look at our example contracts.

License

MIT.