New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@intercoin/fundcontract

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@intercoin/fundcontract

## Installation

latest
Source
npmnpm
Version
1.0.7
Version published
Maintainers
2
Created
Source

FundContract

Installation

Deploy

Deployment can be done in several ways:

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

In all cases, parameters need to be specified:

nametypedescriptionexample
_sellingTokenaddressaddress of the ITR token0x6Ef5febbD2A56FAb23f18a69d3fB9F4E2A70440B
_timestampsuint256[]array of timestamps (GMT)[1609459200, 1614556800, 1619827200]
_pricesuint256[]array of prices for the exchange in ETH (multiplied by 1e8)[12000000, 15000000, 18000000]
_endTimeuint256the time after which the exchange will be stopped1630454400
_thresholdsuint256[]thresholds of ETH (in wei) that trigger bonuses for group members[10000000000000000000, 25000000000000000000, 50000000000000000000]
_bonusesuint256[]bonuses in percentages (multiplied by 100), e.g., 10%, 20%, 30% or 0.1, 0.2, 0.5[10, 20, 50]
_ownerCanWithdrawenum(never, afterEndTime, anytime)an option representing the owner's ability to withdraw tokens left in the contract1
_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 NameCalled ByDescription
getConfigAnyoneRetrieves data with which the contract was initialized.
receiveAnyoneAn internal method triggered when the contract receives ETH. It exchanges ETH for tokens.
getGroupBonusAnyoneRetrieves the current group bonus.
getTokenPriceAnyoneRetrieves the current token price.
withdrawOwnerWithdraws a specified amount of tokens to a given address.
withdrawAllOwnerWithdraws all tokens to the owner (sender).
claimOwnerClaims a specified amount of ETH to a given address.
claimAllOwnerClaims all ETH to the owner (sender).
setGroupOwnerLinks participants to a group.

getConfig

Returns the parameters with which the contract was initialized.

getGroupBonus

Parameters:

nametypedescription
groupNamestringThe name of the group.

Returns the group bonus as a uint.

getTokenPrice

Returns the token price as a uint.

withdraw

Parameters:

nametypedescription
amountuint256The amount of tokens to withdraw.
addraddressThe address to send the tokens to.

withdrawAll

Withdraws all tokens to the owner.

claim

Parameters:

nametypedescription
amountuint256The amount of tokens to claim.
addraddressThe address to send the tokens to.

claimAll

Claims all ETH to the owner (sender).

setGroup

Parameters:

nametypedescription
addressesaddress[]The addresses that need to be linked with the group.
groupNamestringThe name of the group. If the group doesn't exist, it will be created.

Example

  • Deploy the contract (through the intercoin factory mechanism).
  • Transfer some sellingToken to the contract.
  • 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.
  • 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.
  • 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).

look at the table below
actionpersontotal contributed,
ETH
bonus tokens contributed,
ITR
got by transaction,
ITR
Total balance,
ITR
"BestGroup" Total,
ETH
"BestGroup#2" Bonus,
%
oldnewoldnewmainbonusTotal,
ETH
Bonus,
%
Total,
ETH
Bonus,
%
1 Setup the same group "BestGroup"(setGroup) for Person#1,Person#2 0.00.00.00.0
2Person#1 contributed $5,000Person#105.00.00.010.00.010.05.00.00.00.0
Person#20.00.00.00.00.00.00.0
Person#30.00.00.00.00.00.00.0
Person#40.00.00.00.00.00.00.0
3Person#1 contributed $7,000Person#15.012.00.02.414.02.426.412.010.00.00.0
Person#20.00.00.00.00.00.00.0
Person#30.00.00.00.00.00.00.0
Person#40.00.00.00.00.00.00.0
4Person#2 contributed 25 ETHPerson#112.012.02.44.80.02.428.837.020.00.00.0
Person#20.025.00.010.050.010.060.0
Person#30.00.00.00.00.00.00.0
Person#40.00.00.00.00.00.00.0
5 Setup the same group "BestGroup"(setGroup) for Person#3 37.020.00.00.0
6Person#3 contributed $25,000Person#112.012.04.812.00.07.236.062.050.00.00.0
Person#225.025.010.025.00.015.075.0
Person#30.025.00.025.050.025.075.0
Person#40.00.00.00.00.00.00.0
7Person#4 without any group contributed 25 ETH Person#112.012.04.812.00.07.236.062.050.00.00.0
Person#225.025.010.025.00.015.075.0
Person#30.025.00.025.050.025.075.0
Person#40.025.00.00.050.00.050.0
8 Setup the same group "BestGroup#2"(setGroup) for Person#4 62.050.025.020.0
10Finally Person#112.012.04.812.007.236.062.050.025.020.0
Person#225.025.010.025.00.015.075.0
Person#30.025.00.025.050.025.075.0
Person#425.025.050.010.00.00.060.0

FAQs

Package last updated on 25 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts