Invest Contract
About
Stats
Public Functions
59
Event Types
20
Code Size
26,958 bytes
Library Use
Uses SafeMath for uint256.
Uses BlockwellQuill for BlockwellQuill.Data.
Events (20) keyboard_arrow_up
State Variables (21) keyboard_arrow_up
Functions
addAttorney keyboard_arrow_up
Modifiers help
onlyAdminOrAttorney checks for the following:
One or more of the following:
-null - ORnull
Source Code
function addAttorney(address account) public onlyAdminOrAttorney {
_add(ATTORNEY, account);
}
removeAttorney keyboard_arrow_up
Modifiers help
onlyAdminOrAttorney checks for the following:
One or more of the following:
-null - ORnull
Source Code
function removeAttorney(address account) public onlyAdminOrAttorney {
_remove(ATTORNEY, account);
}
isAttorney keyboard_arrow_up
addAdmin keyboard_arrow_up
Modifiers help
onlyAdminOrAttorney checks for the following:
One or more of the following:
-null - ORnull
Source Code
function addAdmin(address account) public onlyAdminOrAttorney {
_addAdmin(account);
}
removeAdmin keyboard_arrow_up
Modifiers help
onlyAdminOrAttorney checks for the following:
One or more of the following:
-null - ORnull
Source Code
function removeAdmin(address account) public onlyAdminOrAttorney {
_remove(ADMIN, account);
}
isAdmin keyboard_arrow_up
addKycAdder keyboard_arrow_up
Modifiers help
onlyAdminOrAttorney checks for the following:
One or more of the following:
-null - ORnull
Source Code
function addKycAdder(address account) public onlyAdminOrAttorney {
_add(KYC_ADDER, account);
}
removeKycAdder keyboard_arrow_up
Modifiers help
onlyAdminOrAttorney checks for the following:
One or more of the following:
-null - ORnull
Source Code
function removeKycAdder(address account) public onlyAdminOrAttorney {
_remove(KYC_ADDER, account);
}
isKycAdder keyboard_arrow_up
addListener keyboard_arrow_up
Modifiers help
onlyAdminOrAttorney checks for the following:
One or more of the following:
-null - ORnull
Source Code
function addListener(address account) public onlyAdminOrAttorney {
_add(LISTENER, account);
}
removeListener keyboard_arrow_up
Modifiers help
onlyAdminOrAttorney checks for the following:
One or more of the following:
-null - ORnull
Source Code
function removeListener(address account) public onlyAdminOrAttorney {
_remove(LISTENER, account);
}
isListener keyboard_arrow_up
addOracle keyboard_arrow_up
Modifiers help
onlyAdminOrAttorney checks for the following:
One or more of the following:
-null - ORnull
Source Code
function addOracle(address account) public onlyAdminOrAttorney {
_add(ORACLE, account);
}
removeOracle keyboard_arrow_up
Modifiers help
onlyAdminOrAttorney checks for the following:
One or more of the following:
-null - ORnull
Source Code
function removeOracle(address account) public onlyAdminOrAttorney {
_remove(ORACLE, account);
}
isOracle keyboard_arrow_up
paused keyboard_arrow_up
pausedByAttorney keyboard_arrow_up
constructor keyboard_arrow_up
Parameters help
This function has no parameters.
Modifiers help
whenNotPaused checks for the following:
Source Code
function() public payable whenNotPaused {
if (!isAdmin(msg.sender)) {
uint256 give = msg.value.div(price).mul(10**uint256(decimals));
emit Payment(address(0x0), msg.sender, msg.value, price, bytes32(0));
_assetPaid(address(0x0), msg.sender, msg.value);
_increase(msg.sender, give, address(0x0), msg.value);
}
}
applyTokenPayment keyboard_arrow_up
Parameters help
Modifiers help
onlyListener checks for the following:
null
whenNotPaused checks for the following:
Source Code
function applyTokenPayment(
address from,
uint256 value,
address tokenAddress,
bytes32 transactionHash
) public onlyListener whenNotPaused {
if (!isAdmin(from)) {
_tokenPayment(from, value, tokenAddress, transactionHash);
}
}
isKycVerified keyboard_arrow_up
kycVerify keyboard_arrow_up
Modifiers help
onlyKycAdder checks for the following:
null
Requirements help
Source Code
function kycVerify(address account) public onlyKycAdder {
User storage user = users[account];
require(!user.kycVerified, "User already KYC Verified");
address asset;
for (uint256 i = 0; i < user.assetList.length; i++) {
asset = user.assetList[i];
unlockedAssets[asset] = unlockedAssets[asset].add(user.assets[asset]);
emit AssetUnlocked(asset, account, user.assets[asset]);
}
user.kycVerified = true;
emit KycVerified(account);
}
kycRemoveVerification keyboard_arrow_up
Modifiers help
onlyAdmin checks for the following:
null
Source Code
function kycRemoveVerification(address account) public onlyAdmin {
User storage user = users[account];
require(user.kycVerified, "User not KYC verified");
address asset;
for (uint256 i = 0; i < user.assetList.length; i++) {
asset = user.assetList[i];
unlockedAssets[asset] = unlockedAssets[asset].sub(user.assets[asset]);
emit AssetLocked(asset, account, user.assets[asset]);
}
user.kycVerified = false;
emit KycVerificationRemoved(account);
}
refund keyboard_arrow_up
Modifiers help
onlyAdminOrAttorney checks for the following:
One or more of the following:
-null - ORnull
Source Code
function refund(
address asset,
address to,
uint256 value
) public onlyAdminOrAttorney {
_returnAsset(asset, to, value);
_assetRefunded(asset, to, value);
}
refundAllAssets keyboard_arrow_up
Modifiers help
onlyAdminOrAttorney checks for the following:
One or more of the following:
-null - ORnull
Source Code
function refundAllAssets(address to) public onlyAdminOrAttorney {
User storage user = users[to];
for (uint256 i = 0; i < user.assetList.length; i++) {
refund(user.assetList[i], to, user.assets[user.assetList[i]]);
}
delete user.assetList;
_decrease(to, user.balance);
}
returnAsset keyboard_arrow_up
Modifiers help
onlyAdminOrAttorney checks for the following:
One or more of the following:
-null - ORnull
Source Code
function returnAsset(
address asset,
address to,
uint256 value
) public onlyAdminOrAttorney {
_returnAsset(asset, to, value);
emit AssetReturned(asset, to, value);
}
decrease keyboard_arrow_up
Modifiers help
onlyAdminOrAttorney checks for the following:
One or more of the following:
-null - ORnull
Source Code
function decrease(address account, uint256 value) public onlyAdminOrAttorney {
_decrease(account, value);
}
getAssetList keyboard_arrow_up
getAssetAmounts keyboard_arrow_up
Source Code
function getAssetAmounts(address account) public view returns (uint256[]) {
User storage user = users[account];
uint256[] memory totals = new uint256[](user.assetList.length);
for (uint256 i = 0; i < user.assetList.length; i++) {
totals[i] = user.assets[user.assetList[i]];
}
return totals;
}
getAmount keyboard_arrow_up
setPrice keyboard_arrow_up
Modifiers help
onlyAdminOrOracle checks for the following:
One or more of the following:
-null - ORnull
Source Code
function setPrice(uint256 newPrice) public onlyAdminOrOracle {
price = newPrice;
emit PriceSet(price);
}
setTokenPrice keyboard_arrow_up
removeToken keyboard_arrow_up
Modifiers help
onlyAdminOrAttorney checks for the following:
One or more of the following:
-null - ORnull
Requirements help
Source Code
function removeToken(address tokenAddress) public onlyAdminOrAttorney {
Token storage token = tokens[tokenAddress];
require(
token.price > 0,
"Token must exist in the contract for it to be removed"
);
require(
tokenList[token.index] == tokenAddress,
"Token index must match the listed one"
);
address replacement = tokenList[tokenList.length - 1];
if (replacement != tokenAddress) {
// Move the last element into the slot we're removing
tokenList[token.index] = replacement;
tokens[replacement].index = token.index;
}
tokenList.length--;
delete (tokens[tokenAddress]);
emit TokenPriceRemoved(tokenAddress);
}
getTokenPrice keyboard_arrow_up
getTokenTotal keyboard_arrow_up
Source Code
function getTokenTotal(address tokenAddress, uint256 value)
public
view
returns (uint256)
{
Token storage token = tokens[tokenAddress];
return value.div(token.price).mul(10**uint256(decimals));
}
getTokenList keyboard_arrow_up
getTokenPrices keyboard_arrow_up
Parameters help
This function has no parameters.
Source Code
function getTokenPrices() public view returns (uint256[]) {
uint256[] memory prices = new uint256[](tokenList.length);
for (uint256 i = 0; i < tokenList.length; i++) {
prices[i] = tokens[tokenList[i]].price;
}
return prices;
}
setBwQuill1 keyboard_arrow_up
Modifiers help
onlyAdminOrKycAdder checks for the following:
One or more of the following:
-null - ORnull
Source Code
function setBwQuill1(address account, string value) public onlyAdminOrKycAdder {
bwQuill1.setString(account, value);
emit BwQuillSet(1, account, value);
}
getBwQuill1 keyboard_arrow_up
setBwQuill2 keyboard_arrow_up
Modifiers help
onlyAdminOrAttorney checks for the following:
One or more of the following:
-null - ORnull
Source Code
function setBwQuill2(address account, string value) public onlyAdminOrAttorney {
bwQuill2.setString(account, value);
emit BwQuillSet(2, account, value);
}
getBwQuill2 keyboard_arrow_up
setBwQuill3 keyboard_arrow_up
Modifiers help
onlyAdminOrAttorney checks for the following:
One or more of the following:
-null - ORnull
Source Code
function setBwQuill3(address account, string value) public onlyAdminOrAttorney {
bwQuill3.setString(account, value);
emit BwQuillSet(3, account, value);
}
getBwQuill3 keyboard_arrow_up
setBwChalk1 keyboard_arrow_up
Modifiers help
onlyAdminOrKycAdder checks for the following:
One or more of the following:
-null - ORnull
Source Code
function setBwChalk1(address account, uint256 value)
public
onlyAdminOrKycAdder
{
bwChalk1.setUint256(account, value);
emit BwChalkSet(1, account, value);
}
getBwChalk1 keyboard_arrow_up
setBwChalk2 keyboard_arrow_up
Modifiers help
onlyAdminOrAttorney checks for the following:
One or more of the following:
-null - ORnull
Source Code
function setBwChalk2(address account, uint256 value)
public
onlyAdminOrAttorney
{
bwChalk2.setUint256(account, value);
emit BwChalkSet(2, account, value);
}
getBwChalk2 keyboard_arrow_up
setBwAddress1 keyboard_arrow_up
Modifiers help
onlyAdminOrKycAdder checks for the following:
One or more of the following:
-null - ORnull
Source Code
function setBwAddress1(address account, address value)
public
onlyAdminOrKycAdder
{
bwAddress1.setAddress(account, value);
emit BwAddressSet(1, account, value);
}
getBwAddress1 keyboard_arrow_up
setBwAddress2 keyboard_arrow_up
Modifiers help
onlyAdminOrAttorney checks for the following:
One or more of the following:
-null - ORnull
Source Code
function setBwAddress2(address account, address value)
public
onlyAdminOrAttorney
{
bwAddress2.setAddress(account, value);
emit BwAddressSet(2, account, value);
}
getBwAddress2 keyboard_arrow_up
pause keyboard_arrow_up
unpause keyboard_arrow_up
Parameters help
This function has no parameters.
Modifiers help
whenPaused checks for the following:
Source Code
function unpause() public whenPaused {
if (!isAttorney(msg.sender)) {
require(isAdmin(msg.sender), "Must be an admin or attorney");
require(
!pausedByAttorney(),
"Only attorneys can unpause after an attorney has paused"
);
}
_unpause();
}
totalSupply keyboard_arrow_up
balanceOf keyboard_arrow_up
availableToWithdraw keyboard_arrow_up
withdrawTokens keyboard_arrow_up
withdrawEther keyboard_arrow_up
tokensWithdrawn keyboard_arrow_up
Internal Functions
Internal functions are parts of the contract that can't be used directly, but instead are used by the public functions listed above.
internal Invest.init keyboard_arrow_up
internal Invest._returnAsset keyboard_arrow_up
Source Code
function _returnAsset(
address asset,
address to,
uint256 value
) internal {
if (asset == address(0x0)) {
to.transfer(value);
} else {
Erc20 token = Erc20(asset);
require(token.transfer(to, value));
}
}
internal Invest._withdrawAsset keyboard_arrow_up
Requirements help
Source Code
function _withdrawAsset(address asset, uint256 value) internal {
require(
availableToWithdraw(asset) >= value,
"Cannot withdraw more than is unlocked"
);
withdrawnAssets[asset] = withdrawnAssets[asset].add(value);
emit Withdraw(asset, msg.sender, value);
}
internal Invest._tokenPayment keyboard_arrow_up
Parameters help
Source Code
function _tokenPayment(
address from,
uint256 value,
address tokenAddress,
bytes32 transactionHash
) internal {
uint256 tokenPrice = getTokenPrice(tokenAddress);
uint256 give = getTokenTotal(tokenAddress, value);
emit Payment(tokenAddress, from, value, tokenPrice, transactionHash);
_increase(from, give, tokenAddress, value);
_assetPaid(tokenAddress, from, value);
}
internal Invest._assetPaid keyboard_arrow_up
Source Code
function _assetPaid(
address asset,
address account,
uint256 value
) internal {
User storage user = users[account];
// No reason to record the asset if it's 0 value
if (value > 0) {
uint256 paid = user.assets[asset];
if (paid > 0) {
user.assets[asset] = paid.add(value);
} else {
user.assetList.push(asset);
user.assets[asset] = value;
}
if (user.kycVerified) {
unlockedAssets[asset] = unlockedAssets[asset].add(value);
emit AssetUnlocked(asset, account, value);
}
}
}
internal Invest._assetRefunded keyboard_arrow_up
Source Code
function _assetRefunded(
address asset,
address account,
uint256 value
) internal {
User storage user = users[account];
user.assets[asset] = user.assets[asset].sub(value);
if (user.kycVerified) {
unlockedAssets[asset] = unlockedAssets[asset].sub(value);
emit AssetLocked(asset, account, value);
require(
unlockedAssets[asset] >= withdrawnAssets[asset],
"Cannot refund assets to KYC Verified users without unlocked assets available"
);
}
emit Refund(asset, account, value);
}
internal Invest._setTokenPrice keyboard_arrow_up
Requirements help
Source Code
function _setTokenPrice(address tokenAddress, uint256 tokenPrice) internal {
require(tokenPrice > 0, "Token price must be higher than 0");
Token storage token = tokens[tokenAddress];
if (token.price > 0) {
token.price = tokenPrice;
} else {
tokenList.push(tokenAddress);
token.price = tokenPrice;
token.index = tokenList.length - 1;
}
emit TokenPriceSet(tokenAddress, tokenPrice);
}
internal Invest._increase keyboard_arrow_up
Parameters help
Source Code
function _increase(
address account,
uint256 value,
address asset,
uint256 assetValue
) internal {
User storage user = users[account];
if (limited) {
remainingSupply = remainingSupply.sub(value);
} else {
totalTokenSupply = totalTokenSupply.add(value);
}
user.balance = user.balance.add(value);
emit Increase(account, value, asset, assetValue);
}
internal Invest._decrease keyboard_arrow_up
Source Code
function _decrease(address account, uint256 value) internal {
User storage user = users[account];
user.balance = user.balance.sub(value);
if (limited) {
remainingSupply = remainingSupply.add(value);
} else {
totalTokenSupply = totalTokenSupply.sub(value);
}
emit Decrease(account, value);
}