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

@intercoin/fundcontract

v1.0.7

Published

## Installation

Downloads

33

Readme

FundContract

Installation

Deploy

Deployment can be done in several ways:

  1. Through the intercoin factory mechanism.
  2. Deploy FundFactory before and call the method produce.
  3. Deploy FundContract directly on the network and call the method init.

In all cases, parameters need to be specified:

name | type | description | example --|--|--|-- _sellingToken|address|address of the ITR token | 0x6Ef5febbD2A56FAb23f18a69d3fB9F4E2A70440B _timestamps|uint256[] | array of timestamps (GMT) | [1609459200, 1614556800, 1619827200] _prices|uint256[]| array of prices for the exchange in ETH (multiplied by 1e8) | [12000000, 15000000, 18000000] _endTime|uint256| the time after which the exchange will be stopped | 1630454400 _thresholds|uint256[]| thresholds of ETH (in wei) that trigger bonuses for group members | [10000000000000000000, 25000000000000000000, 50000000000000000000] _bonuses|uint256[]| bonuses in percentages (multiplied by 100), e.g., 10%, 20%, 30% or 0.1, 0.2, 0.5 | [10, 20, 50] _ownerCanWithdraw|enum(never, afterEndTime, anytime)| an option representing the owner's ability to withdraw tokens left in the contract| 1 _whitelistData|{address contractAddress, bytes4 method, uint8 role, bool useWhitelist;}| settings for the whitelist. The exchange can only be accessed by whitelisted individuals. For more information, see the Intercoin/Whitelist repository. In example "internal whitelist"| [0x0000000000000000000000000000000000000000,0x95a8c58d,0x4,true]

Overview

Once installed, methods can be used for exchange.

Methods

| Method Name | Called By | Description | |---|---|---| | getConfig | Anyone | Retrieves data with which the contract was initialized. | | receive | Anyone | An internal method triggered when the contract receives ETH. It exchanges ETH for tokens. | | getGroupBonus | Anyone | Retrieves the current group bonus. | | getTokenPrice | Anyone | Retrieves the current token price. | | withdraw | Owner | Withdraws a specified amount of tokens to a given address. | | withdrawAll | Owner | Withdraws all tokens to the owner (sender). | | claim | Owner | Claims a specified amount of ETH to a given address. | | claimAll | Owner | Claims all ETH to the owner (sender). | | setGroup | Owner | Links participants to a group. |

getConfig

Returns the parameters with which the contract was initialized.

getGroupBonus

Parameters: name | type | description --|--|-- groupName|string| The name of the group.

Returns the group bonus as a uint.

getTokenPrice

Returns the token price as a uint.

withdraw

Parameters: name | type | description --|--|-- amount|uint256| The amount of tokens to withdraw. addr|address| The address to send the tokens to.

withdrawAll

Withdraws all tokens to the owner.

claim

Parameters: name | type | description --|--|-- amount|uint256| The amount of tokens to claim. addr|address| The address to send the tokens to.

claimAll

Claims all ETH to the owner (sender).

setGroup

Parameters: name | type | description --|--|-- addresses|address[]| The addresses that need to be linked with the group. groupName|string| The name of the group. If the group doesn't exist, it will be created.

Example

  1. Deploy the contract (through the intercoin factory mechanism).
  2. Transfer some sellingToken to the contract.
  3. Now, any user who sends ETH to the contract will be able to receive sellingToken until the endTime expires or the contract has enough tokens to return.
  4. If the owner adds a user to a group (by calling the setGroup method) and the group reaches the threshold, all group members will receive bonus tokens.
  5. Additionally, if a user acquires tokens without being in a group and then becomes a member of any group, all the contributed tokens will be part of the group and increase the group bonus.

How Bonuses Work

We have created a contract that sends additional tokens to a group of people who contribute more than the specified thresholds. For example: After 10 ETH - 10% bonus After 25 ETH - 20% bonus After 50 ETH - 50% bonus So the initial parameters will be: thresholds = [10_000000000000000000, 25_000000000000000000, 50_000000000000000000] bonuses = [10, 20, 50] Here, the thresholds are set in wei and the bonuses are multiplied by 100. For a better understanding of the math, let's take the variable price_ETH_TOKEN = 10000000 (0.5 ETH = 1 ITR).