Unnamed: 0 int64 0 7.36k | comments stringlengths 3 35.2k | code_string stringlengths 1 527k | code stringlengths 1 527k | __index_level_0__ int64 0 88.6k |
|---|---|---|---|---|
23 | // add address to the list | minters.push(_account);
| minters.push(_account);
| 37,065 |
14 | // Update UniV3 observations/desToken Token to be priced/quoteToken Token used for pricing/data Dex parameters | function updateV3Observation(address desToken, address quoteToken, bytes memory data) external override {
if (data.toDex() == DexData.DEX_UNIV3) {
increaseV3Observation(desToken, quoteToken, data.toFee());
}
}
| function updateV3Observation(address desToken, address quoteToken, bytes memory data) external override {
if (data.toDex() == DexData.DEX_UNIV3) {
increaseV3Observation(desToken, quoteToken, data.toFee());
}
}
| 2,152 |
10 | // ํน์ NFT ํ ํฐ ์์ด๋์ ๋ํ ์ถ๊ฐ์ ์ธ NFT ํ ํฐ ๋ฐํ(owner๋ง ํธ์ถ ๊ฐ๋ฅ) | function addTokenSupply(uint256 tokenId, uint256 amount) public onlyOwner nonReentrant {
_mint(msg.sender, tokenId, amount, '');
}
| function addTokenSupply(uint256 tokenId, uint256 amount) public onlyOwner nonReentrant {
_mint(msg.sender, tokenId, amount, '');
}
| 29,273 |
10 | // uint256 ico_finish = 1512565200; | uint256 ico_finish = 1513774800;
| uint256 ico_finish = 1513774800;
| 13,634 |
124 | // --- CDP Confiscation --- | function grab(bytes32 i, address u, address v, address w, int dink, int dart) external note auth {
Urn storage urn = urns[i][u];
Ilk storage ilk = ilks[i];
urn.ink = _add(urn.ink, dink);
urn.art = _add(urn.art, dart);
ilk.Art = _add(ilk.Art, dart);
int dtab = _mul(ilk.rate, dart);
gem[i][v] = _sub(gem[i][v], dink);
sin[w] = _sub(sin[w], dtab);
vice = _sub(vice, dtab);
}
| function grab(bytes32 i, address u, address v, address w, int dink, int dart) external note auth {
Urn storage urn = urns[i][u];
Ilk storage ilk = ilks[i];
urn.ink = _add(urn.ink, dink);
urn.art = _add(urn.art, dart);
ilk.Art = _add(ilk.Art, dart);
int dtab = _mul(ilk.rate, dart);
gem[i][v] = _sub(gem[i][v], dink);
sin[w] = _sub(sin[w], dtab);
vice = _sub(vice, dtab);
}
| 7,845 |
7 | // Emitted when the price oracle sentinel is updated. oldAddress The old address of the PriceOracleSentinel newAddress The new address of the PriceOracleSentinel / | event PriceOracleSentinelUpdated(address indexed oldAddress, address indexed newAddress);
| event PriceOracleSentinelUpdated(address indexed oldAddress, address indexed newAddress);
| 36,390 |
9 | // Salvages a token. We should not be able to salvage CRV and 3CRV (underlying)./ | function salvage(address recipient, address token, uint256 amount) public onlyGovernance {
// To make sure that governance cannot come in and take away the coins
require(!unsalvagableTokens[token], "token is defined as not salvageable");
IERC20(token).safeTransfer(recipient, amount);
}
| function salvage(address recipient, address token, uint256 amount) public onlyGovernance {
// To make sure that governance cannot come in and take away the coins
require(!unsalvagableTokens[token], "token is defined as not salvageable");
IERC20(token).safeTransfer(recipient, amount);
}
| 6,240 |
6 | // what is the ETH/USD conversion rate? | function getConversionRate(uint256 ethAmount) public view returns(uint256){
uint256 ethPrice = getPrice();
uint256 ethAmountInUsd = (ethPrice * ethAmount) / 10**18;
return ethAmountInUsd;
}
| function getConversionRate(uint256 ethAmount) public view returns(uint256){
uint256 ethPrice = getPrice();
uint256 ethAmountInUsd = (ethPrice * ethAmount) / 10**18;
return ethAmountInUsd;
}
| 12,165 |
73 | // Change WETH Token address. Call by only Governance. / | function changeWethTokenAddress(address wethAddress_)
external
onlyGovernance
| function changeWethTokenAddress(address wethAddress_)
external
onlyGovernance
| 892 |
164 | // returns the address of the LendingPoolLiquidationManager. Since the manager is used through delegateCall within the LendingPool contract, the proxy contract pattern does not work properly hence the addresses are changed directly. return the address of the Lending pool liquidation manager/ | function getLendingPoolLiquidationManager() public view returns (address) {
return getAddress(LENDING_POOL_LIQUIDATION_MANAGER);
}
| function getLendingPoolLiquidationManager() public view returns (address) {
return getAddress(LENDING_POOL_LIQUIDATION_MANAGER);
}
| 9,026 |
4 | // Pending brains of Unitroller/ | address public pendingComptrollerImplementation;
| address public pendingComptrollerImplementation;
| 19,676 |
90 | // Mint LP's here. | defPair.mint(address(this));
| defPair.mint(address(this));
| 12,672 |
3 | // Stores tokens standard | string public tokenStandard = "CAT-1400";
| string public tokenStandard = "CAT-1400";
| 7,289 |
35 | // pl1lockedAmount = pl1lockedAmount.sub(lockedLiquidity[lpId].marginAmount.add(lockedLiquidity[lpId].marginFee)); | }
| }
| 30,232 |
51 | // Submit transcode receipt and invoke transcoding verification _jobId Job identifier _segmentNumber Segment sequence number in stream _dataStorageHash Content-addressed storage hash of segment data _dataHashes Hash of segment data and hash of transcoded segment data _broadcasterSig Broadcaster's signature over segment hash _proof Merkle proof for transcode receipt / | function verify(
uint256 _jobId,
uint256 _claimId,
uint256 _segmentNumber,
string _dataStorageHash,
bytes32[2] _dataHashes,
bytes _broadcasterSig,
bytes _proof
)
external
| function verify(
uint256 _jobId,
uint256 _claimId,
uint256 _segmentNumber,
string _dataStorageHash,
bytes32[2] _dataHashes,
bytes _broadcasterSig,
bytes _proof
)
external
| 2,356 |
19 | // Currency name. / | string public name;
| string public name;
| 48,509 |
10 | // Returns the debt ceiling of the reserve asset The address of the underlying asset of the reservereturn The debt ceiling of the reserve / | function getDebtCeiling(address asset) external view returns (uint256) {
return IPool(ADDRESSES_PROVIDER.getPool()).getConfiguration(asset).getDebtCeiling();
}
| function getDebtCeiling(address asset) external view returns (uint256) {
return IPool(ADDRESSES_PROVIDER.getPool()).getConfiguration(asset).getDebtCeiling();
}
| 4,425 |
78 | // Swaps `amounts[path.length-1]` `path[path.length-1]` to `to` on this chain Triggered by `anySwapOutExactTokensForTokens` | function anySwapInExactTokensForTokens(
bytes32 txs,
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline,
uint fromChainID
| function anySwapInExactTokensForTokens(
bytes32 txs,
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline,
uint fromChainID
| 63,247 |
7 | // Emitted when a vote is cast without params. Note: `support` values should be seen as buckets. Their interpretation depends on the voting module used. / | event VoteCast(address indexed voter, uint256 proposalId, uint8 support, uint256 weight, string reason);
| event VoteCast(address indexed voter, uint256 proposalId, uint8 support, uint256 weight, string reason);
| 9,896 |
11 | // ERC20Basic Simpler version of ERC20 interface / | interface ERC20Basic {
function balanceOf(address who) external view returns (uint256 balance);
function transfer(address to, uint256 value) external returns (bool trans1);
function allowance(address owner, address spender) external view returns (uint256 remaining);
function transferFrom(address from, address to, uint256 value) external returns (bool trans);
function approve(address spender, uint256 value) external returns (bool hello);
event Approval(address indexed owner, address indexed spender, uint256 value);
event Transfer(address indexed from, address indexed to, uint256 value);
}
| interface ERC20Basic {
function balanceOf(address who) external view returns (uint256 balance);
function transfer(address to, uint256 value) external returns (bool trans1);
function allowance(address owner, address spender) external view returns (uint256 remaining);
function transferFrom(address from, address to, uint256 value) external returns (bool trans);
function approve(address spender, uint256 value) external returns (bool hello);
event Approval(address indexed owner, address indexed spender, uint256 value);
event Transfer(address indexed from, address indexed to, uint256 value);
}
| 23,908 |
13 | // if vendor for asset already exists overwrite startBlock with the value that vendor initally held instead | if (addr != address(0)) {
| if (addr != address(0)) {
| 47,667 |
14 | // Emitted when governance class tokens are activated. | event Activated(address indexed owner, uint256 indexed tokenId);
| event Activated(address indexed owner, uint256 indexed tokenId);
| 23,750 |
16 | // Submits a new score for a player. Restricted to caller of createLeaderboard(). | function submitScore(uint256 leaderboardId, address player, uint256 newScore) external;
| function submitScore(uint256 leaderboardId, address player, uint256 newScore) external;
| 9,415 |
18 | // Returns whether the prize period is over/ return True if the prize period is over, false otherwise | function isPrizePeriodOver() external view returns (bool) {
return _isPrizePeriodOver();
}
| function isPrizePeriodOver() external view returns (bool) {
return _isPrizePeriodOver();
}
| 31,839 |
15 | // Interface for contracts conforming to ERC-721 / | contract ERC721Interface {
function ownerOf(uint256 assetId) public view returns (address);
function safeTransferFrom(address from, address to, uint256 assetId) public;
function isAuthorized(address operator, uint256 assetId) public view returns (bool);
}
| contract ERC721Interface {
function ownerOf(uint256 assetId) public view returns (address);
function safeTransferFrom(address from, address to, uint256 assetId) public;
function isAuthorized(address operator, uint256 assetId) public view returns (bool);
}
| 16,503 |
35 | // cancel timelocked action _index uint256 / | function nullify(uint256 _index) external onlyGovernor {
permissionQueue[_index].nullify = true;
}
| function nullify(uint256 _index) external onlyGovernor {
permissionQueue[_index].nullify = true;
}
| 61,974 |
30 | // ============ External Imports ============ | import {Address} from "@openzeppelin/contracts/utils/Address.sol";
/**
* @title UpgradeBeaconProxy
* @notice
* Proxy contract which delegates all logic, including initialization,
* to an implementation contract.
* The implementation contract is stored within an Upgrade Beacon contract;
* the implementation contract can be changed by performing an upgrade on the Upgrade Beacon contract.
* The Upgrade Beacon contract for this Proxy is immutably specified at deployment.
* @dev This implementation combines the gas savings of keeping the UpgradeBeacon address outside of contract storage
* found in 0age's implementation:
* https://github.com/dharma-eng/dharma-smart-wallet/blob/master/contracts/proxies/smart-wallet/UpgradeBeaconProxyV1.sol
* With the added safety checks that the UpgradeBeacon and implementation are contracts at time of deployment
* found in OpenZeppelin's implementation:
* https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/proxy/beacon/BeaconProxy.sol
*/
contract UpgradeBeaconProxy {
// ============ Immutables ============
// Upgrade Beacon address is immutable (therefore not kept in contract storage)
address private immutable upgradeBeacon;
// ============ Constructor ============
/**
* @notice Validate that the Upgrade Beacon is a contract, then set its
* address immutably within this contract.
* Validate that the implementation is also a contract,
* Then call the initialization function defined at the implementation.
* The deployment will revert and pass along the
* revert reason if the initialization function reverts.
* @param _upgradeBeacon Address of the Upgrade Beacon to be stored immutably in the contract
* @param _initializationCalldata Calldata supplied when calling the initialization function
*/
constructor(address _upgradeBeacon, bytes memory _initializationCalldata)
payable
{
// Validate the Upgrade Beacon is a contract
require(Address.isContract(_upgradeBeacon), "beacon !contract");
// set the Upgrade Beacon
upgradeBeacon = _upgradeBeacon;
// Validate the implementation is a contract
address _implementation = _getImplementation(_upgradeBeacon);
require(
Address.isContract(_implementation),
"beacon implementation !contract"
);
// Call the initialization function on the implementation
if (_initializationCalldata.length > 0) {
_initialize(_implementation, _initializationCalldata);
}
}
// ============ External Functions ============
/**
* @notice Forwards all calls with data to _fallback()
* No public functions are declared on the contract, so all calls hit fallback
*/
fallback() external payable {
_fallback();
}
/**
* @notice Forwards all calls with no data to _fallback()
*/
receive() external payable {
_fallback();
}
// ============ Private Functions ============
/**
* @notice Call the initialization function on the implementation
* Used at deployment to initialize the proxy
* based on the logic for initialization defined at the implementation
* @param _implementation - Contract to which the initalization is delegated
* @param _initializationCalldata - Calldata supplied when calling the initialization function
*/
function _initialize(
address _implementation,
bytes memory _initializationCalldata
) private {
// Delegatecall into the implementation, supplying initialization calldata.
(bool _ok, ) = _implementation.delegatecall(_initializationCalldata);
// Revert and include revert data if delegatecall to implementation reverts.
if (!_ok) {
assembly {
returndatacopy(0, 0, returndatasize())
revert(0, returndatasize())
}
}
}
/**
* @notice Delegates function calls to the implementation contract returned by the Upgrade Beacon
*/
function _fallback() private {
_delegate(_getImplementation());
}
/**
* @notice Delegate function execution to the implementation contract
* @dev This is a low level function that doesn't return to its internal
* call site. It will return whatever is returned by the implementation to the
* external caller, reverting and returning the revert data if implementation
* reverts.
* @param _implementation - Address to which the function execution is delegated
*/
function _delegate(address _implementation) private {
assembly {
// Copy msg.data. We take full control of memory in this inline assembly
// block because it will not return to Solidity code. We overwrite the
// Solidity scratch pad at memory position 0.
calldatacopy(0, 0, calldatasize())
// Delegatecall to the implementation, supplying calldata and gas.
// Out and outsize are set to zero - instead, use the return buffer.
let result := delegatecall(
gas(),
_implementation,
0,
calldatasize(),
0,
0
)
// Copy the returned data from the return buffer.
returndatacopy(0, 0, returndatasize())
switch result
// Delegatecall returns 0 on error.
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
/**
* @notice Call the Upgrade Beacon to get the current implementation contract address
* @return _implementation Address of the current implementation.
*/
function _getImplementation()
private
view
returns (address _implementation)
{
_implementation = _getImplementation(upgradeBeacon);
}
/**
* @notice Call the Upgrade Beacon to get the current implementation contract address
* @dev _upgradeBeacon is passed as a parameter so that
* we can also use this function in the constructor,
* where we can't access immutable variables.
* @param _upgradeBeacon Address of the UpgradeBeacon storing the current implementation
* @return _implementation Address of the current implementation.
*/
function _getImplementation(address _upgradeBeacon)
private
view
returns (address _implementation)
{
// Get the current implementation address from the upgrade beacon.
(bool _ok, bytes memory _returnData) = _upgradeBeacon.staticcall("");
// Revert and pass along revert message if call to upgrade beacon reverts.
require(_ok, string(_returnData));
// Set the implementation to the address returned from the upgrade beacon.
_implementation = abi.decode(_returnData, (address));
}
}
| import {Address} from "@openzeppelin/contracts/utils/Address.sol";
/**
* @title UpgradeBeaconProxy
* @notice
* Proxy contract which delegates all logic, including initialization,
* to an implementation contract.
* The implementation contract is stored within an Upgrade Beacon contract;
* the implementation contract can be changed by performing an upgrade on the Upgrade Beacon contract.
* The Upgrade Beacon contract for this Proxy is immutably specified at deployment.
* @dev This implementation combines the gas savings of keeping the UpgradeBeacon address outside of contract storage
* found in 0age's implementation:
* https://github.com/dharma-eng/dharma-smart-wallet/blob/master/contracts/proxies/smart-wallet/UpgradeBeaconProxyV1.sol
* With the added safety checks that the UpgradeBeacon and implementation are contracts at time of deployment
* found in OpenZeppelin's implementation:
* https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/proxy/beacon/BeaconProxy.sol
*/
contract UpgradeBeaconProxy {
// ============ Immutables ============
// Upgrade Beacon address is immutable (therefore not kept in contract storage)
address private immutable upgradeBeacon;
// ============ Constructor ============
/**
* @notice Validate that the Upgrade Beacon is a contract, then set its
* address immutably within this contract.
* Validate that the implementation is also a contract,
* Then call the initialization function defined at the implementation.
* The deployment will revert and pass along the
* revert reason if the initialization function reverts.
* @param _upgradeBeacon Address of the Upgrade Beacon to be stored immutably in the contract
* @param _initializationCalldata Calldata supplied when calling the initialization function
*/
constructor(address _upgradeBeacon, bytes memory _initializationCalldata)
payable
{
// Validate the Upgrade Beacon is a contract
require(Address.isContract(_upgradeBeacon), "beacon !contract");
// set the Upgrade Beacon
upgradeBeacon = _upgradeBeacon;
// Validate the implementation is a contract
address _implementation = _getImplementation(_upgradeBeacon);
require(
Address.isContract(_implementation),
"beacon implementation !contract"
);
// Call the initialization function on the implementation
if (_initializationCalldata.length > 0) {
_initialize(_implementation, _initializationCalldata);
}
}
// ============ External Functions ============
/**
* @notice Forwards all calls with data to _fallback()
* No public functions are declared on the contract, so all calls hit fallback
*/
fallback() external payable {
_fallback();
}
/**
* @notice Forwards all calls with no data to _fallback()
*/
receive() external payable {
_fallback();
}
// ============ Private Functions ============
/**
* @notice Call the initialization function on the implementation
* Used at deployment to initialize the proxy
* based on the logic for initialization defined at the implementation
* @param _implementation - Contract to which the initalization is delegated
* @param _initializationCalldata - Calldata supplied when calling the initialization function
*/
function _initialize(
address _implementation,
bytes memory _initializationCalldata
) private {
// Delegatecall into the implementation, supplying initialization calldata.
(bool _ok, ) = _implementation.delegatecall(_initializationCalldata);
// Revert and include revert data if delegatecall to implementation reverts.
if (!_ok) {
assembly {
returndatacopy(0, 0, returndatasize())
revert(0, returndatasize())
}
}
}
/**
* @notice Delegates function calls to the implementation contract returned by the Upgrade Beacon
*/
function _fallback() private {
_delegate(_getImplementation());
}
/**
* @notice Delegate function execution to the implementation contract
* @dev This is a low level function that doesn't return to its internal
* call site. It will return whatever is returned by the implementation to the
* external caller, reverting and returning the revert data if implementation
* reverts.
* @param _implementation - Address to which the function execution is delegated
*/
function _delegate(address _implementation) private {
assembly {
// Copy msg.data. We take full control of memory in this inline assembly
// block because it will not return to Solidity code. We overwrite the
// Solidity scratch pad at memory position 0.
calldatacopy(0, 0, calldatasize())
// Delegatecall to the implementation, supplying calldata and gas.
// Out and outsize are set to zero - instead, use the return buffer.
let result := delegatecall(
gas(),
_implementation,
0,
calldatasize(),
0,
0
)
// Copy the returned data from the return buffer.
returndatacopy(0, 0, returndatasize())
switch result
// Delegatecall returns 0 on error.
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
/**
* @notice Call the Upgrade Beacon to get the current implementation contract address
* @return _implementation Address of the current implementation.
*/
function _getImplementation()
private
view
returns (address _implementation)
{
_implementation = _getImplementation(upgradeBeacon);
}
/**
* @notice Call the Upgrade Beacon to get the current implementation contract address
* @dev _upgradeBeacon is passed as a parameter so that
* we can also use this function in the constructor,
* where we can't access immutable variables.
* @param _upgradeBeacon Address of the UpgradeBeacon storing the current implementation
* @return _implementation Address of the current implementation.
*/
function _getImplementation(address _upgradeBeacon)
private
view
returns (address _implementation)
{
// Get the current implementation address from the upgrade beacon.
(bool _ok, bytes memory _returnData) = _upgradeBeacon.staticcall("");
// Revert and pass along revert message if call to upgrade beacon reverts.
require(_ok, string(_returnData));
// Set the implementation to the address returned from the upgrade beacon.
_implementation = abi.decode(_returnData, (address));
}
}
| 16,485 |
15 | // How much native currency did we just swap into? | uint256 newBalance = address(this).balance;
| uint256 newBalance = address(this).balance;
| 34,422 |
6 | // function mint(address to) external returns (uint liquidity); | function burn(address to) external returns (uint amount0, uint amount1);
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function skim(address to) external;
function sync() external;
function initialize(address, address) external;
| function burn(address to) external returns (uint amount0, uint amount1);
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function skim(address to) external;
function sync() external;
function initialize(address, address) external;
| 22,034 |
71 | // -- APPLICATION ENTRY POINTS --/ |
function adminInitialSet()
public
|
function adminInitialSet()
public
| 44,672 |
102 | // account for deposit | uint value = treasury.valueOf( token, amount );
accountingFor( token, amount, value, true );
IERC20(token).approve(address(curve3Pool), amount); // approve curve pool to spend tokens
uint curveAmount = curve3Pool.add_liquidity(curveToken, amounts, minAmount); // deposit into curve
IERC20( curveToken ).approve( address(booster), curveAmount ); // approve to deposit to convex
booster.deposit( pidForReserve[ token ], curveAmount, true ); // deposit into convex
| uint value = treasury.valueOf( token, amount );
accountingFor( token, amount, value, true );
IERC20(token).approve(address(curve3Pool), amount); // approve curve pool to spend tokens
uint curveAmount = curve3Pool.add_liquidity(curveToken, amounts, minAmount); // deposit into curve
IERC20( curveToken ).approve( address(booster), curveAmount ); // approve to deposit to convex
booster.deposit( pidForReserve[ token ], curveAmount, true ); // deposit into convex
| 31,331 |
2 | // the current supply rate. Expressed in ray | uint128 currentLiquidityRate;
| uint128 currentLiquidityRate;
| 2,508 |
50 | // setPool _pid the pool id _allocPoint the pool allocation point _registered does this pool is registered (default true). _depositPause pause pool deposit (default false).This parameter can be used by the UI to include or exclude the pool _descriptionHash the hash of the pool description. / | function setPool(uint256 _pid,
uint256 _allocPoint,
bool _registered,
bool _depositPause,
string memory _descriptionHash)
| function setPool(uint256 _pid,
uint256 _allocPoint,
bool _registered,
bool _depositPause,
string memory _descriptionHash)
| 13,628 |
153 | // Check if the name string is valid (Alphanumeric and spaces without leading or trailing space) / | function validateName(string memory str) public pure returns (bool){
bytes memory b = bytes(str);
if(b.length < 1) return false;
if(b.length > 16) return false; // Cannot be longer than 16 characters
if(b[0] == 0x20) return false; // Leading space
if (b[b.length - 1] == 0x20) return false; // Trailing space
bytes1 lastChar = b[0];
for(uint i; i<b.length; i++){
bytes1 char = b[i];
if (char == 0x20 || lastChar == 0x20) return false; // Cannot contain spaces
if(
!(char >= 0x30 && char <= 0x39) && //9-0
!(char >= 0x41 && char <= 0x5A) && //A-Z
!(char >= 0x61 && char <= 0x7A) //a-z
)
return false;
lastChar = char;
}
return true;
}
| function validateName(string memory str) public pure returns (bool){
bytes memory b = bytes(str);
if(b.length < 1) return false;
if(b.length > 16) return false; // Cannot be longer than 16 characters
if(b[0] == 0x20) return false; // Leading space
if (b[b.length - 1] == 0x20) return false; // Trailing space
bytes1 lastChar = b[0];
for(uint i; i<b.length; i++){
bytes1 char = b[i];
if (char == 0x20 || lastChar == 0x20) return false; // Cannot contain spaces
if(
!(char >= 0x30 && char <= 0x39) && //9-0
!(char >= 0x41 && char <= 0x5A) && //A-Z
!(char >= 0x61 && char <= 0x7A) //a-z
)
return false;
lastChar = char;
}
return true;
}
| 11,156 |
122 | // user activity details: | mapping(address => Staking[]) public stakings;
mapping(address => Loan[]) public loans;
mapping(address => uint256) public launchReward;
| mapping(address => Staking[]) public stakings;
mapping(address => Loan[]) public loans;
mapping(address => uint256) public launchReward;
| 30,241 |
14 | // decode a uq112x112 into a uint with 18 decimals of precision | function decode112with18(uq112x112 memory self) internal pure returns (uint) {
return uint(self._x) / 5192296858534827;
}
| function decode112with18(uq112x112 memory self) internal pure returns (uint) {
return uint(self._x) / 5192296858534827;
}
| 30,638 |
41 | // Upgrade the backing implementation of the proxy and call a functionon the new implementation.This is useful to initialize the proxied contract. newImplementation Address of the new implementation. data Data to send as msg.data in the low level call.It should include the signature and the parameters of the function to be called, as described in / | function upgradeToAndCall(address newImplementation, bytes calldata data)
external
payable
ifAdmin
| function upgradeToAndCall(address newImplementation, bytes calldata data)
external
payable
ifAdmin
| 548 |
9 | // solhint-disable avoid-low-level-calls slither-disable-next-line low-level-calls | (bool success, ) = to.call{ value: value }("");
| (bool success, ) = to.call{ value: value }("");
| 8,982 |
2 | // store voted accounts | mapping(address => bool) public voters;
| mapping(address => bool) public voters;
| 40,855 |
120 | // Checks whether the period in which the crowdsale is open has already elapsed.return Whether crowdsale period has elapsed / | function hasClosed() public view returns (bool) {
// solhint-disable-next-line not-rely-on-time
return _openingTime > 0 && _isStopped;
}
| function hasClosed() public view returns (bool) {
// solhint-disable-next-line not-rely-on-time
return _openingTime > 0 && _isStopped;
}
| 24,466 |
10 | // 3D state by tokenId | mapping(uint256 => ThreeDState) public tokenThreeDState;
| mapping(uint256 => ThreeDState) public tokenThreeDState;
| 16,034 |
158 | // If token was not sold, return ownership to the seller | transferToken(auctionId, address(this), auction.seller);
| transferToken(auctionId, address(this), auction.seller);
| 79,549 |
36 | // Block-scoping these variables saves some gas. | uint256 stopped_;
uint256 zph_;
assembly {
let slot1 := sload(1)
stopped_ := and(slot1, 0xff )
hop_ := and(shr(8, slot1), 0xffff)
zph_ := shr(24, slot1)
}
| uint256 stopped_;
uint256 zph_;
assembly {
let slot1 := sload(1)
stopped_ := and(slot1, 0xff )
hop_ := and(shr(8, slot1), 0xffff)
zph_ := shr(24, slot1)
}
| 54,388 |
133 | // APIS Crowd Pre-Sale ํ ํฐ์ ํ๋ฆฌ์ธ์ผ์ ์ํํ๊ธฐ ์ํ ์ปจํธ๋ํธ / | contract ApisCrowdSale is Ownable {
// ์์์ ์๋ฆฌ์. Eth 18์๋ฆฌ์ ๋ง์ถ๋ค
uint8 public constant decimals = 18;
// ํฌ๋ผ์ฐ๋ ์ธ์ผ์ ํ๋งค ๋ชฉํ๋(APIS)
uint256 public fundingGoal;
// ํ์ฌ ์งํํ๋ ํ๋งค ๋ชฉํ๋
// QTUM๊ณผ ๊ณต๋์ผ๋ก ํ๋งค๊ฐ ์งํ๋๊ธฐ ๋๋ฌธ์, QTUM ์ชฝ ์ปจํธ๋ ํธ์ ํฉ์ฐํ ํ๋งค๋์ด ์ด ํ๋งค๋ชฉํ๋ฅผ ๋์ง ์๋๋ก ํ๊ธฐ ์ํจ
uint256 public fundingGoalCurrent;
// 1 ETH์ผ๋ก ์ด ์ ์๋ APIS์ ๊ฐฏ์
uint256 public priceOfApisPerFund;
// ๋ฐ๊ธ๋ Apis ๊ฐฏ์ (์์ฝ + ๋ฐํ)
//uint256 public totalSoldApis;
// ๋ฐํ ๋๊ธฐ์ค์ธ APIS ๊ฐฏ์
//uint256 public totalReservedApis;
// ๋ฐํ๋์ ์ถ๊ธ๋ APIS ๊ฐฏ์
//uint256 public totalWithdrawedApis;
// ์
๊ธ๋ ํฌ์๊ธ์ ์ด์ก (์์ฝ + ๋ฐํ)
//uint256 public totalReceivedFunds;
// ๊ตฌ๋งค ํ์ ์ ํฌ์๊ธ์ ์ด์ก
//uint256 public totalReservedFunds;
// ๊ตฌ๋งค ํ์ ๋ ํฌ์๊ธ์ ์ด์ก
//uint256 public totalPaidFunds;
// ํ๋งค๊ฐ ์์๋๋ ์๊ฐ
uint public startTime;
// ํ๋งค๊ฐ ์ข
๋ฃ๋๋ ์๊ฐ
uint public endTime;
// ํ๋งค๊ฐ ์กฐ๊ธฐ์ ์ข
๋ฃ๋ ๊ฒฝ์ฐ๋ฅผ ๋๋นํ๊ธฐ ์ํจ
bool closed = false;
SaleStatus public saleStatus;
// APIS ํ ํฐ ์ปจํธ๋ ํธ
ApisToken internal tokenReward;
// ํ์ดํธ๋ฆฌ์คํธ ์ปจํธ๋ ํธ
WhiteList internal whiteList;
mapping (address => Property) public fundersProperty;
/**
* @dev APIS ํ ํฐ ๊ตฌ๋งค์์ ์์ฐ ํํฉ์ ์ ๋ฆฌํ๊ธฐ ์ํ ๊ตฌ์กฐ์ฒด
*/
struct Property {
uint256 reservedFunds; // ์
๊ธํ์ง๋ง ์์ง APIS๋ก ๋ณํ๋์ง ์์ Eth (ํ๋ถ ๊ฐ๋ฅ)
uint256 paidFunds; // APIS๋ก ๋ณํ๋ Eth (ํ๋ถ ๋ถ๊ฐ)
uint256 reservedApis; // ๋ฐ์ ์์ ์ธ ํ ํฐ
uint256 withdrawedApis; // ์ด๋ฏธ ๋ฐ์ ํ ํฐ
uint purchaseTime; // ๊ตฌ์
ํ ์๊ฐ
}
/**
* @dev ํ์ฌ ์ธ์ผ์ ์งํ ํํฉ์ ํ์ธํ ์ ์๋ค.
* totalSoldApis ๋ฐ๊ธ๋ Apis ๊ฐฏ์ (์์ฝ + ๋ฐํ)
* totalReservedApis ๋ฐํ ๋๊ธฐ ์ค์ธ Apis
* totalWithdrawedApis ๋ฐํ๋์ ์ถ๊ธ๋ APIS ๊ฐฏ์
*
* totalReceivedFunds ์
๊ธ๋ ํฌ์๊ธ์ ์ด์ก (์์ฝ + ๋ฐํ)
* totalReservedFunds ๊ตฌ๋งค ํ์ ์ ํฌ์๊ธ์ ์ด์ก
* ttotalPaidFunds ๊ตฌ๋งค ํ์ ๋ ํฌ์๊ธ์ ์ด์ก
*/
struct SaleStatus {
uint256 totalReservedFunds;
uint256 totalPaidFunds;
uint256 totalReceivedFunds;
uint256 totalReservedApis;
uint256 totalWithdrawedApis;
uint256 totalSoldApis;
}
/**
* @dev APIS๋ฅผ ๊ตฌ์
ํ๊ธฐ ์ํ Eth์ ์
๊ธํ์ ๋ ๋ฐ์ํ๋ ์ด๋ฒคํธ
* @param beneficiary APIS๋ฅผ ๊ตฌ๋งคํ๊ณ ์ ํ๋ ์ง๊ฐ์ ์ฃผ์
* @param amountOfFunds ์
๊ธํ Eth์ ์ (wei)
* @param amountOfApis ํฌ์๊ธ์ ์์ํ๋ APIS ํ ํฐ์ ์ (wei)
*/
event ReservedApis(address beneficiary, uint256 amountOfFunds, uint256 amountOfApis);
/**
* @dev ํฌ๋ผ์ฐ๋ ์ธ์ผ ์ปจํธ๋ ํธ์์ Eth์ด ์ธ์ถ๋์์ ๋ ๋ฐ์ํ๋ ์ด๋ฒคํธ
* @param addr ๋ฐ๋ ์ง๊ฐ์ ์ฃผ์
* @param amount ์ก๊ธ๋๋ ์(wei)
*/
event WithdrawalFunds(address addr, uint256 amount);
/**
* @dev ๊ตฌ๋งค์์๊ฒ ํ ํฐ์ด ๋ฐ๊ธ๋์์ ๋ ๋ฐ์ํ๋ ์ด๋ฒคํธ
* @param funder ํ ํฐ์ ๋ฐ๋ ์ง๊ฐ์ ์ฃผ์
* @param amountOfFunds ์
๊ธํ ํฌ์๊ธ์ ์ (wei)
* @param amountOfApis ๋ฐ๊ธ ๋ฐ๋ ํ ํฐ์ ์ (wei)
*/
event WithdrawalApis(address funder, uint256 amountOfFunds, uint256 amountOfApis);
/**
* @dev ํฌ์๊ธ ์
๊ธ ํ, ์์ง ํ ํฐ์ ๋ฐ๊ธ๋ฐ์ง ์์ ์ํ์์, ํ๋ถ ์ฒ๋ฆฌ๋ฅผ ํ์ ๋ ๋ฐ์ํ๋ ์ด๋ฒคํธ
* @param _backer ํ๋ถ ์ฒ๋ฆฌ๋ฅผ ์งํํ๋ ์ง๊ฐ์ ์ฃผ์
* @param _amountFunds ํ๋ถํ๋ ํฌ์๊ธ์ ์
* @param _amountApis ์ทจ์๋๋ APIS ์
*/
event Refund(address _backer, uint256 _amountFunds, uint256 _amountApis);
/**
* @dev ํฌ๋ผ์ฐ๋ ์ธ์ผ ์งํ ์ค์๋ง ๋์ํ๋๋ก ์ ํํ๊ณ , APIS์ ๊ฐ๊ฒฉ๋ ์ค์ ๋์ด์ผ๋ง ํ๋ค.
*/
modifier onSale() {
require(now >= startTime);
require(now < endTime);
require(closed == false);
require(priceOfApisPerFund > 0);
require(fundingGoalCurrent > 0);
_;
}
/**
* @dev ํฌ๋ผ์ฐ๋ ์ธ์ผ ์ข
๋ฃ ํ์๋ง ๋์ํ๋๋ก ์ ํ
*/
modifier onFinished() {
require(now >= endTime || closed == true);
_;
}
/**
* @dev ํ์ดํธ๋ฆฌ์คํธ์ ๋ฑ๋ก๋์ด์์ด์ผํ๊ณ ์์ง ๊ตฌ๋งค์๋ฃ ๋์ง ์์ ํฌ์๊ธ์ด ์์ด์ผ๋ง ํ๋ค.
*/
modifier claimable() {
require(whiteList.isInWhiteList(msg.sender) == true);
require(fundersProperty[msg.sender].reservedFunds > 0);
_;
}
/**
* @dev ํฌ๋ผ์ฐ๋ ์ธ์ผ ์ปจํธ๋ ํธ๋ฅผ ์์ฑํ๋ค.
* @param _fundingGoalApis ํ๋งคํ๋ ํ ํฐ์ ์ (APIS ๋จ์)
* @param _startTime ํฌ๋ผ์ฐ๋ ์ธ์ผ์ ์์ํ๋ ์๊ฐ
* @param _endTime ํฌ๋ผ์ฐ๋ ์ธ์ผ์ ์ข
๋ฃํ๋ ์๊ฐ
* @param _addressOfApisTokenUsedAsReward APIS ํ ํฐ์ ์ปจํธ๋ ํธ ์ฃผ์
* @param _addressOfWhiteList WhiteList ์ปจํธ๋ ํธ ์ฃผ์
*/
function ApisCrowdSale (
uint256 _fundingGoalApis,
uint _startTime,
uint _endTime,
address _addressOfApisTokenUsedAsReward,
address _addressOfWhiteList
) public {
require (_fundingGoalApis > 0);
require (_startTime > now);
require (_endTime > _startTime);
require (_addressOfApisTokenUsedAsReward != 0x0);
require (_addressOfWhiteList != 0x0);
fundingGoal = _fundingGoalApis * 10 ** uint256(decimals);
startTime = _startTime;
endTime = _endTime;
// ํ ํฐ ์ค๋งํธ์ปจํธ๋ ํธ๋ฅผ ๋ถ๋ฌ์จ๋ค
tokenReward = ApisToken(_addressOfApisTokenUsedAsReward);
// ํ์ดํธ ๋ฆฌ์คํธ๋ฅผ ๊ฐ์ ธ์จ๋ค
whiteList = WhiteList(_addressOfWhiteList);
}
/**
* @dev ํ๋งค ์ข
๋ฃ๋ 1ํ๋ง ๊ฐ๋ฅํ๋๋ก ์ ์ฝํ๋ค. ์ข
๋ฃ ํ ๋ค์ ํ๋งค ์ค์ผ๋ก ๋ณ๊ฒฝํ ์ ์๋ค
*/
function closeSale(bool _closed) onlyOwner public {
require (closed == false);
closed = _closed;
}
/**
* @dev ํฌ๋ผ์ฐ๋ ์ธ์ผ ์์ ์ ์ 1Eth์ ํด๋นํ๋ APIS ๋์ ์ค์ ํ๋ค.
*/
function setPriceOfApis(uint256 price) onlyOwner public {
require(priceOfApisPerFund == 0);
priceOfApisPerFund = price;
}
/**
* @dev ํ ์์ ์์ ํ๋งค ๊ฐ๋ฅํ ๋ชฉํ๋์ ์์ ํ๋ค.
* @param _currentFundingGoalAPIS ํ ์์ ์ ํ๋งค ๋ชฉํ๋์ ์ด ํ๋งค๋ ์ ์ด์์ด์ด์ผ๋ง ํ๋ค.
*/
function setCurrentFundingGoal(uint256 _currentFundingGoalAPIS) onlyOwner public {
uint256 fundingGoalCurrentWei = _currentFundingGoalAPIS * 10 ** uint256(decimals);
require(fundingGoalCurrentWei >= saleStatus.totalSoldApis);
fundingGoalCurrent = fundingGoalCurrentWei;
}
/**
* @dev APIS ์๊ณ ๋ฅผ ํ์ธํ๋ค
* @param _addr ์๊ณ ๋ฅผ ํ์ธํ๋ ค๋ ์ง๊ฐ์ ์ฃผ์
* @return balance ์ง๊ฐ์ ๋ค์ APIS ์๊ณ (wei)
*/
function balanceOf(address _addr) public view returns (uint256 balance) {
return tokenReward.balanceOf(_addr);
}
/**
* @dev ํ์ดํธ๋ฆฌ์คํธ ๋ฑ๋ก ์ฌ๋ถ๋ฅผ ํ์ธํ๋ค
* @param _addr ๋ฑ๋ก ์ฌ๋ถ๋ฅผ ํ์ธํ๋ ค๋ ์ฃผ์
* @return addrIsInWhiteList true : ๋ฑ๋ก๋์์, false : ๋ฑ๋ก๋์ด์์ง ์์
*/
function whiteListOf(address _addr) public view returns (string message) {
if(whiteList.isInWhiteList(_addr) == true) {
return "The address is in whitelist.";
} else {
return "The address is *NOT* in whitelist.";
}
}
/**
* @dev ์ ๋ฌ๋ฐ์ ์ง๊ฐ์ด APIS ์ง๊ธ ์์ฒญ์ด ๊ฐ๋ฅํ์ง ํ์ธํ๋ค.
* @param _addr ํ์ธํ๋ ์ฃผ์
* @return message ๊ฒฐ๊ณผ ๋ฉ์์ง
*/
function isClaimable(address _addr) public view returns (string message) {
if(fundersProperty[_addr].reservedFunds == 0) {
return "The address has no claimable balance.";
}
if(whiteList.isInWhiteList(_addr) == false) {
return "The address must be registered with KYC and Whitelist";
}
else {
return "The address can claim APIS!";
}
}
/**
* @dev ํฌ๋ผ์ฐ๋ ์ธ์ผ ์ปจํธ๋ ํธ๋ก ๋ฐ๋ก ํฌ์๊ธ์ ์ก๊ธํ๋ ๊ฒฝ์ฐ, buyToken์ผ๋ก ์ฐ๊ฒฐํ๋ค
*/
function () onSale public payable {
buyToken(msg.sender);
}
/**
* @dev ํ ํฐ์ ๊ตฌ์
ํ๊ธฐ ์ํด Qtum์ ์
๊ธ๋ฐ๋๋ค.
* @param _beneficiary ํ ํฐ์ ๋ฐ๊ฒ ๋ ์ง๊ฐ์ ์ฃผ์
*/
function buyToken(address _beneficiary) onSale public payable {
// ์ฃผ์ ํ์ธ
require(_beneficiary != 0x0);
// ํฌ๋ผ์ฐ๋ ์ธ์ผ ์ปจํธ๋ ํธ์ ํ ํฐ ์ก๊ธ ๊ธฐ๋ฅ์ด ์ ์ง๋์ด์์ผ๋ฉด ํ๋งคํ์ง ์๋๋ค
bool isLocked = false;
uint timeLock = 0;
(isLocked, timeLock) = tokenReward.isWalletLocked_Send(this);
require(isLocked == false);
uint256 amountFunds = msg.value;
uint256 reservedApis = amountFunds * priceOfApisPerFund;
// ๋ชฉํ ๊ธ์ก์ ๋์ด์์ง ๋ชปํ๋๋ก ํ๋ค
require(saleStatus.totalSoldApis + reservedApis <= fundingGoalCurrent);
require(saleStatus.totalSoldApis + reservedApis <= fundingGoal);
// ํฌ์์์ ์์ฐ์ ์
๋ฐ์ดํธํ๋ค
fundersProperty[_beneficiary].reservedFunds += amountFunds;
fundersProperty[_beneficiary].reservedApis += reservedApis;
fundersProperty[_beneficiary].purchaseTime = now;
// ์ด์ก๋ค์ ์
๋ฐ์ดํธํ๋ค
saleStatus.totalReceivedFunds += amountFunds;
saleStatus.totalReservedFunds += amountFunds;
saleStatus.totalSoldApis += reservedApis;
saleStatus.totalReservedApis += reservedApis;
// ํ์ดํธ๋ฆฌ์คํธ์ ๋ฑ๋ก๋์ด์์ผ๋ฉด ๋ฐ๋ก ์ถ๊ธํ๋ค
if(whiteList.isInWhiteList(_beneficiary) == true) {
withdrawal(_beneficiary);
}
else {
// ํ ํฐ ๋ฐํ ์์ฝ ์ด๋ฒคํธ ๋ฐ์
ReservedApis(_beneficiary, amountFunds, reservedApis);
}
}
/**
* @dev ๊ด๋ฆฌ์์ ์ํด์ ํ ํฐ์ ๋ฐ๊ธํ๋ค. ํ์ง๋ง ๊ธฐ๋ณธ ์๊ฑด์ ๊ฐ์ถฐ์ผ๋ง ๊ฐ๋ฅํ๋ค
*
* @param _target ํ ํฐ ๋ฐ๊ธ์ ์ฒญ๊ตฌํ๋ ค๋ ์ง๊ฐ ์ฃผ์
*/
function claimApis(address _target) public {
// ํ์ดํธ ๋ฆฌ์คํธ์ ์์ด์ผ๋ง ํ๊ณ
require(whiteList.isInWhiteList(_target) == true);
// ์์ฝ๋ ํฌ์๊ธ์ด ์์ด์ผ๋ง ํ๋ค.
require(fundersProperty[_target].reservedFunds > 0);
withdrawal(_target);
}
/**
* @dev ์์ฝํ ํ ํฐ์ ์ค์ ์ง๊ธ์ ์์ฒญํ๋๋ก ํ๋ค.
*
* APIS๋ฅผ ๊ตฌ๋งคํ๊ธฐ ์ํด Qtum์ ์
๊ธํ ๊ฒฝ์ฐ, ๊ด๋ฆฌ์์ ๊ฒํ ๋ฅผ ์ํ 7์ผ์ ์ ์๊ธฐ๊ฐ์ด ์กด์ฌํ๋ค.
* ์ ์๊ธฐ๊ฐ์ด ์ง๋๋ฉด ํ ํฐ ์ง๊ธ์ ์๊ตฌํ ์ ์๋ค.
*/
function claimMyApis() claimable public {
withdrawal(msg.sender);
}
/**
* @dev ๊ตฌ๋งค์์๊ฒ ํ ํฐ์ ์ง๊ธํ๋ค.
* @param funder ํ ํฐ์ ์ง๊ธํ ์ง๊ฐ์ ์ฃผ์
*/
function withdrawal(address funder) internal {
// ๊ตฌ๋งค์ ์ง๊ฐ์ผ๋ก ํ ํฐ์ ์ ๋ฌํ๋ค
assert(tokenReward.transferFrom(owner, funder, fundersProperty[funder].reservedApis));
fundersProperty[funder].withdrawedApis += fundersProperty[funder].reservedApis;
fundersProperty[funder].paidFunds += fundersProperty[funder].reservedFunds;
// ์ด์ก์ ๋ฐ์
saleStatus.totalReservedFunds -= fundersProperty[funder].reservedFunds;
saleStatus.totalPaidFunds += fundersProperty[funder].reservedFunds;
saleStatus.totalReservedApis -= fundersProperty[funder].reservedApis;
saleStatus.totalWithdrawedApis += fundersProperty[funder].reservedApis;
// APIS๊ฐ ์ถ๊ธ ๋์์์ ์๋ฆฌ๋ ์ด๋ฒคํธ
WithdrawalApis(funder, fundersProperty[funder].reservedFunds, fundersProperty[funder].reservedApis);
// ์ธ์ถํ์ง ์์ APIS ์๊ณ ๋ฅผ 0์ผ๋ก ๋ณ๊ฒฝํด์, Qtum ์ฌ์
๊ธ ์ ์ด๋ฏธ ์ถ๊ธํ ํ ํฐ์ด ๋ค์ ์ถ๊ธ๋์ง ์๊ฒ ํ๋ค.
fundersProperty[funder].reservedFunds = 0;
fundersProperty[funder].reservedApis = 0;
}
/**
* @dev ์์ง ํ ํฐ์ ๋ฐ๊ธ๋ฐ์ง ์์ ์ง๊ฐ์ ๋์์ผ๋ก, ํ๋ถ์ ์งํํ ์ ์๋ค.
* @param _funder ํ๋ถ์ ์งํํ๋ ค๋ ์ง๊ฐ์ ์ฃผ์
*/
function refundByOwner(address _funder) onlyOwner public {
require(fundersProperty[_funder].reservedFunds > 0);
uint256 amountFunds = fundersProperty[_funder].reservedFunds;
uint256 amountApis = fundersProperty[_funder].reservedApis;
// Eth์ ํ๋ถํ๋ค
_funder.transfer(amountFunds);
saleStatus.totalReceivedFunds -= amountFunds;
saleStatus.totalReservedFunds -= amountFunds;
saleStatus.totalSoldApis -= amountApis;
saleStatus.totalReservedApis -= amountApis;
fundersProperty[_funder].reservedFunds = 0;
fundersProperty[_funder].reservedApis = 0;
Refund(_funder, amountFunds, amountApis);
}
/**
* @dev ํ๋ฉ์ด ์ข
๋ฃ๋ ์ดํ๋ฉด, ์ ๋ฆฝ๋ ํฌ์๊ธ์ ๋ฐํํ๋ค.
* @param remainRefundable true : ํ๋ถํ ์ ์๋ ๊ธ์ก์ ๋จ๊ธฐ๊ณ ๋ฐํํ๋ค. false : ๋ชจ๋ ๋ฐํํ๋ค
*/
function withdrawalFunds(bool remainRefundable) onlyOwner public {
require(now > endTime || closed == true);
uint256 amount = 0;
if(remainRefundable) {
amount = this.balance - saleStatus.totalReservedFunds;
} else {
amount = this.balance;
}
if(amount > 0) {
msg.sender.transfer(amount);
WithdrawalFunds(msg.sender, amount);
}
}
/**
* @dev ํฌ๋ผ์ฐ๋ ์ธ์ผ์ด ์งํ ์ค์ธ์ง ์ฌ๋ถ๋ฅผ ๋ฐํํ๋ค.
* @return isOpened true: ์งํ ์ค false : ์งํ ์ค์ด ์๋(์ฐธ์ฌ ๋ถ๊ฐ)
*/
function isOpened() public view returns (bool isOpend) {
if(now < startTime) return false;
if(now >= endTime) return false;
if(closed == true) return false;
return true;
}
}
| contract ApisCrowdSale is Ownable {
// ์์์ ์๋ฆฌ์. Eth 18์๋ฆฌ์ ๋ง์ถ๋ค
uint8 public constant decimals = 18;
// ํฌ๋ผ์ฐ๋ ์ธ์ผ์ ํ๋งค ๋ชฉํ๋(APIS)
uint256 public fundingGoal;
// ํ์ฌ ์งํํ๋ ํ๋งค ๋ชฉํ๋
// QTUM๊ณผ ๊ณต๋์ผ๋ก ํ๋งค๊ฐ ์งํ๋๊ธฐ ๋๋ฌธ์, QTUM ์ชฝ ์ปจํธ๋ ํธ์ ํฉ์ฐํ ํ๋งค๋์ด ์ด ํ๋งค๋ชฉํ๋ฅผ ๋์ง ์๋๋ก ํ๊ธฐ ์ํจ
uint256 public fundingGoalCurrent;
// 1 ETH์ผ๋ก ์ด ์ ์๋ APIS์ ๊ฐฏ์
uint256 public priceOfApisPerFund;
// ๋ฐ๊ธ๋ Apis ๊ฐฏ์ (์์ฝ + ๋ฐํ)
//uint256 public totalSoldApis;
// ๋ฐํ ๋๊ธฐ์ค์ธ APIS ๊ฐฏ์
//uint256 public totalReservedApis;
// ๋ฐํ๋์ ์ถ๊ธ๋ APIS ๊ฐฏ์
//uint256 public totalWithdrawedApis;
// ์
๊ธ๋ ํฌ์๊ธ์ ์ด์ก (์์ฝ + ๋ฐํ)
//uint256 public totalReceivedFunds;
// ๊ตฌ๋งค ํ์ ์ ํฌ์๊ธ์ ์ด์ก
//uint256 public totalReservedFunds;
// ๊ตฌ๋งค ํ์ ๋ ํฌ์๊ธ์ ์ด์ก
//uint256 public totalPaidFunds;
// ํ๋งค๊ฐ ์์๋๋ ์๊ฐ
uint public startTime;
// ํ๋งค๊ฐ ์ข
๋ฃ๋๋ ์๊ฐ
uint public endTime;
// ํ๋งค๊ฐ ์กฐ๊ธฐ์ ์ข
๋ฃ๋ ๊ฒฝ์ฐ๋ฅผ ๋๋นํ๊ธฐ ์ํจ
bool closed = false;
SaleStatus public saleStatus;
// APIS ํ ํฐ ์ปจํธ๋ ํธ
ApisToken internal tokenReward;
// ํ์ดํธ๋ฆฌ์คํธ ์ปจํธ๋ ํธ
WhiteList internal whiteList;
mapping (address => Property) public fundersProperty;
/**
* @dev APIS ํ ํฐ ๊ตฌ๋งค์์ ์์ฐ ํํฉ์ ์ ๋ฆฌํ๊ธฐ ์ํ ๊ตฌ์กฐ์ฒด
*/
struct Property {
uint256 reservedFunds; // ์
๊ธํ์ง๋ง ์์ง APIS๋ก ๋ณํ๋์ง ์์ Eth (ํ๋ถ ๊ฐ๋ฅ)
uint256 paidFunds; // APIS๋ก ๋ณํ๋ Eth (ํ๋ถ ๋ถ๊ฐ)
uint256 reservedApis; // ๋ฐ์ ์์ ์ธ ํ ํฐ
uint256 withdrawedApis; // ์ด๋ฏธ ๋ฐ์ ํ ํฐ
uint purchaseTime; // ๊ตฌ์
ํ ์๊ฐ
}
/**
* @dev ํ์ฌ ์ธ์ผ์ ์งํ ํํฉ์ ํ์ธํ ์ ์๋ค.
* totalSoldApis ๋ฐ๊ธ๋ Apis ๊ฐฏ์ (์์ฝ + ๋ฐํ)
* totalReservedApis ๋ฐํ ๋๊ธฐ ์ค์ธ Apis
* totalWithdrawedApis ๋ฐํ๋์ ์ถ๊ธ๋ APIS ๊ฐฏ์
*
* totalReceivedFunds ์
๊ธ๋ ํฌ์๊ธ์ ์ด์ก (์์ฝ + ๋ฐํ)
* totalReservedFunds ๊ตฌ๋งค ํ์ ์ ํฌ์๊ธ์ ์ด์ก
* ttotalPaidFunds ๊ตฌ๋งค ํ์ ๋ ํฌ์๊ธ์ ์ด์ก
*/
struct SaleStatus {
uint256 totalReservedFunds;
uint256 totalPaidFunds;
uint256 totalReceivedFunds;
uint256 totalReservedApis;
uint256 totalWithdrawedApis;
uint256 totalSoldApis;
}
/**
* @dev APIS๋ฅผ ๊ตฌ์
ํ๊ธฐ ์ํ Eth์ ์
๊ธํ์ ๋ ๋ฐ์ํ๋ ์ด๋ฒคํธ
* @param beneficiary APIS๋ฅผ ๊ตฌ๋งคํ๊ณ ์ ํ๋ ์ง๊ฐ์ ์ฃผ์
* @param amountOfFunds ์
๊ธํ Eth์ ์ (wei)
* @param amountOfApis ํฌ์๊ธ์ ์์ํ๋ APIS ํ ํฐ์ ์ (wei)
*/
event ReservedApis(address beneficiary, uint256 amountOfFunds, uint256 amountOfApis);
/**
* @dev ํฌ๋ผ์ฐ๋ ์ธ์ผ ์ปจํธ๋ ํธ์์ Eth์ด ์ธ์ถ๋์์ ๋ ๋ฐ์ํ๋ ์ด๋ฒคํธ
* @param addr ๋ฐ๋ ์ง๊ฐ์ ์ฃผ์
* @param amount ์ก๊ธ๋๋ ์(wei)
*/
event WithdrawalFunds(address addr, uint256 amount);
/**
* @dev ๊ตฌ๋งค์์๊ฒ ํ ํฐ์ด ๋ฐ๊ธ๋์์ ๋ ๋ฐ์ํ๋ ์ด๋ฒคํธ
* @param funder ํ ํฐ์ ๋ฐ๋ ์ง๊ฐ์ ์ฃผ์
* @param amountOfFunds ์
๊ธํ ํฌ์๊ธ์ ์ (wei)
* @param amountOfApis ๋ฐ๊ธ ๋ฐ๋ ํ ํฐ์ ์ (wei)
*/
event WithdrawalApis(address funder, uint256 amountOfFunds, uint256 amountOfApis);
/**
* @dev ํฌ์๊ธ ์
๊ธ ํ, ์์ง ํ ํฐ์ ๋ฐ๊ธ๋ฐ์ง ์์ ์ํ์์, ํ๋ถ ์ฒ๋ฆฌ๋ฅผ ํ์ ๋ ๋ฐ์ํ๋ ์ด๋ฒคํธ
* @param _backer ํ๋ถ ์ฒ๋ฆฌ๋ฅผ ์งํํ๋ ์ง๊ฐ์ ์ฃผ์
* @param _amountFunds ํ๋ถํ๋ ํฌ์๊ธ์ ์
* @param _amountApis ์ทจ์๋๋ APIS ์
*/
event Refund(address _backer, uint256 _amountFunds, uint256 _amountApis);
/**
* @dev ํฌ๋ผ์ฐ๋ ์ธ์ผ ์งํ ์ค์๋ง ๋์ํ๋๋ก ์ ํํ๊ณ , APIS์ ๊ฐ๊ฒฉ๋ ์ค์ ๋์ด์ผ๋ง ํ๋ค.
*/
modifier onSale() {
require(now >= startTime);
require(now < endTime);
require(closed == false);
require(priceOfApisPerFund > 0);
require(fundingGoalCurrent > 0);
_;
}
/**
* @dev ํฌ๋ผ์ฐ๋ ์ธ์ผ ์ข
๋ฃ ํ์๋ง ๋์ํ๋๋ก ์ ํ
*/
modifier onFinished() {
require(now >= endTime || closed == true);
_;
}
/**
* @dev ํ์ดํธ๋ฆฌ์คํธ์ ๋ฑ๋ก๋์ด์์ด์ผํ๊ณ ์์ง ๊ตฌ๋งค์๋ฃ ๋์ง ์์ ํฌ์๊ธ์ด ์์ด์ผ๋ง ํ๋ค.
*/
modifier claimable() {
require(whiteList.isInWhiteList(msg.sender) == true);
require(fundersProperty[msg.sender].reservedFunds > 0);
_;
}
/**
* @dev ํฌ๋ผ์ฐ๋ ์ธ์ผ ์ปจํธ๋ ํธ๋ฅผ ์์ฑํ๋ค.
* @param _fundingGoalApis ํ๋งคํ๋ ํ ํฐ์ ์ (APIS ๋จ์)
* @param _startTime ํฌ๋ผ์ฐ๋ ์ธ์ผ์ ์์ํ๋ ์๊ฐ
* @param _endTime ํฌ๋ผ์ฐ๋ ์ธ์ผ์ ์ข
๋ฃํ๋ ์๊ฐ
* @param _addressOfApisTokenUsedAsReward APIS ํ ํฐ์ ์ปจํธ๋ ํธ ์ฃผ์
* @param _addressOfWhiteList WhiteList ์ปจํธ๋ ํธ ์ฃผ์
*/
function ApisCrowdSale (
uint256 _fundingGoalApis,
uint _startTime,
uint _endTime,
address _addressOfApisTokenUsedAsReward,
address _addressOfWhiteList
) public {
require (_fundingGoalApis > 0);
require (_startTime > now);
require (_endTime > _startTime);
require (_addressOfApisTokenUsedAsReward != 0x0);
require (_addressOfWhiteList != 0x0);
fundingGoal = _fundingGoalApis * 10 ** uint256(decimals);
startTime = _startTime;
endTime = _endTime;
// ํ ํฐ ์ค๋งํธ์ปจํธ๋ ํธ๋ฅผ ๋ถ๋ฌ์จ๋ค
tokenReward = ApisToken(_addressOfApisTokenUsedAsReward);
// ํ์ดํธ ๋ฆฌ์คํธ๋ฅผ ๊ฐ์ ธ์จ๋ค
whiteList = WhiteList(_addressOfWhiteList);
}
/**
* @dev ํ๋งค ์ข
๋ฃ๋ 1ํ๋ง ๊ฐ๋ฅํ๋๋ก ์ ์ฝํ๋ค. ์ข
๋ฃ ํ ๋ค์ ํ๋งค ์ค์ผ๋ก ๋ณ๊ฒฝํ ์ ์๋ค
*/
function closeSale(bool _closed) onlyOwner public {
require (closed == false);
closed = _closed;
}
/**
* @dev ํฌ๋ผ์ฐ๋ ์ธ์ผ ์์ ์ ์ 1Eth์ ํด๋นํ๋ APIS ๋์ ์ค์ ํ๋ค.
*/
function setPriceOfApis(uint256 price) onlyOwner public {
require(priceOfApisPerFund == 0);
priceOfApisPerFund = price;
}
/**
* @dev ํ ์์ ์์ ํ๋งค ๊ฐ๋ฅํ ๋ชฉํ๋์ ์์ ํ๋ค.
* @param _currentFundingGoalAPIS ํ ์์ ์ ํ๋งค ๋ชฉํ๋์ ์ด ํ๋งค๋ ์ ์ด์์ด์ด์ผ๋ง ํ๋ค.
*/
function setCurrentFundingGoal(uint256 _currentFundingGoalAPIS) onlyOwner public {
uint256 fundingGoalCurrentWei = _currentFundingGoalAPIS * 10 ** uint256(decimals);
require(fundingGoalCurrentWei >= saleStatus.totalSoldApis);
fundingGoalCurrent = fundingGoalCurrentWei;
}
/**
* @dev APIS ์๊ณ ๋ฅผ ํ์ธํ๋ค
* @param _addr ์๊ณ ๋ฅผ ํ์ธํ๋ ค๋ ์ง๊ฐ์ ์ฃผ์
* @return balance ์ง๊ฐ์ ๋ค์ APIS ์๊ณ (wei)
*/
function balanceOf(address _addr) public view returns (uint256 balance) {
return tokenReward.balanceOf(_addr);
}
/**
* @dev ํ์ดํธ๋ฆฌ์คํธ ๋ฑ๋ก ์ฌ๋ถ๋ฅผ ํ์ธํ๋ค
* @param _addr ๋ฑ๋ก ์ฌ๋ถ๋ฅผ ํ์ธํ๋ ค๋ ์ฃผ์
* @return addrIsInWhiteList true : ๋ฑ๋ก๋์์, false : ๋ฑ๋ก๋์ด์์ง ์์
*/
function whiteListOf(address _addr) public view returns (string message) {
if(whiteList.isInWhiteList(_addr) == true) {
return "The address is in whitelist.";
} else {
return "The address is *NOT* in whitelist.";
}
}
/**
* @dev ์ ๋ฌ๋ฐ์ ์ง๊ฐ์ด APIS ์ง๊ธ ์์ฒญ์ด ๊ฐ๋ฅํ์ง ํ์ธํ๋ค.
* @param _addr ํ์ธํ๋ ์ฃผ์
* @return message ๊ฒฐ๊ณผ ๋ฉ์์ง
*/
function isClaimable(address _addr) public view returns (string message) {
if(fundersProperty[_addr].reservedFunds == 0) {
return "The address has no claimable balance.";
}
if(whiteList.isInWhiteList(_addr) == false) {
return "The address must be registered with KYC and Whitelist";
}
else {
return "The address can claim APIS!";
}
}
/**
* @dev ํฌ๋ผ์ฐ๋ ์ธ์ผ ์ปจํธ๋ ํธ๋ก ๋ฐ๋ก ํฌ์๊ธ์ ์ก๊ธํ๋ ๊ฒฝ์ฐ, buyToken์ผ๋ก ์ฐ๊ฒฐํ๋ค
*/
function () onSale public payable {
buyToken(msg.sender);
}
/**
* @dev ํ ํฐ์ ๊ตฌ์
ํ๊ธฐ ์ํด Qtum์ ์
๊ธ๋ฐ๋๋ค.
* @param _beneficiary ํ ํฐ์ ๋ฐ๊ฒ ๋ ์ง๊ฐ์ ์ฃผ์
*/
function buyToken(address _beneficiary) onSale public payable {
// ์ฃผ์ ํ์ธ
require(_beneficiary != 0x0);
// ํฌ๋ผ์ฐ๋ ์ธ์ผ ์ปจํธ๋ ํธ์ ํ ํฐ ์ก๊ธ ๊ธฐ๋ฅ์ด ์ ์ง๋์ด์์ผ๋ฉด ํ๋งคํ์ง ์๋๋ค
bool isLocked = false;
uint timeLock = 0;
(isLocked, timeLock) = tokenReward.isWalletLocked_Send(this);
require(isLocked == false);
uint256 amountFunds = msg.value;
uint256 reservedApis = amountFunds * priceOfApisPerFund;
// ๋ชฉํ ๊ธ์ก์ ๋์ด์์ง ๋ชปํ๋๋ก ํ๋ค
require(saleStatus.totalSoldApis + reservedApis <= fundingGoalCurrent);
require(saleStatus.totalSoldApis + reservedApis <= fundingGoal);
// ํฌ์์์ ์์ฐ์ ์
๋ฐ์ดํธํ๋ค
fundersProperty[_beneficiary].reservedFunds += amountFunds;
fundersProperty[_beneficiary].reservedApis += reservedApis;
fundersProperty[_beneficiary].purchaseTime = now;
// ์ด์ก๋ค์ ์
๋ฐ์ดํธํ๋ค
saleStatus.totalReceivedFunds += amountFunds;
saleStatus.totalReservedFunds += amountFunds;
saleStatus.totalSoldApis += reservedApis;
saleStatus.totalReservedApis += reservedApis;
// ํ์ดํธ๋ฆฌ์คํธ์ ๋ฑ๋ก๋์ด์์ผ๋ฉด ๋ฐ๋ก ์ถ๊ธํ๋ค
if(whiteList.isInWhiteList(_beneficiary) == true) {
withdrawal(_beneficiary);
}
else {
// ํ ํฐ ๋ฐํ ์์ฝ ์ด๋ฒคํธ ๋ฐ์
ReservedApis(_beneficiary, amountFunds, reservedApis);
}
}
/**
* @dev ๊ด๋ฆฌ์์ ์ํด์ ํ ํฐ์ ๋ฐ๊ธํ๋ค. ํ์ง๋ง ๊ธฐ๋ณธ ์๊ฑด์ ๊ฐ์ถฐ์ผ๋ง ๊ฐ๋ฅํ๋ค
*
* @param _target ํ ํฐ ๋ฐ๊ธ์ ์ฒญ๊ตฌํ๋ ค๋ ์ง๊ฐ ์ฃผ์
*/
function claimApis(address _target) public {
// ํ์ดํธ ๋ฆฌ์คํธ์ ์์ด์ผ๋ง ํ๊ณ
require(whiteList.isInWhiteList(_target) == true);
// ์์ฝ๋ ํฌ์๊ธ์ด ์์ด์ผ๋ง ํ๋ค.
require(fundersProperty[_target].reservedFunds > 0);
withdrawal(_target);
}
/**
* @dev ์์ฝํ ํ ํฐ์ ์ค์ ์ง๊ธ์ ์์ฒญํ๋๋ก ํ๋ค.
*
* APIS๋ฅผ ๊ตฌ๋งคํ๊ธฐ ์ํด Qtum์ ์
๊ธํ ๊ฒฝ์ฐ, ๊ด๋ฆฌ์์ ๊ฒํ ๋ฅผ ์ํ 7์ผ์ ์ ์๊ธฐ๊ฐ์ด ์กด์ฌํ๋ค.
* ์ ์๊ธฐ๊ฐ์ด ์ง๋๋ฉด ํ ํฐ ์ง๊ธ์ ์๊ตฌํ ์ ์๋ค.
*/
function claimMyApis() claimable public {
withdrawal(msg.sender);
}
/**
* @dev ๊ตฌ๋งค์์๊ฒ ํ ํฐ์ ์ง๊ธํ๋ค.
* @param funder ํ ํฐ์ ์ง๊ธํ ์ง๊ฐ์ ์ฃผ์
*/
function withdrawal(address funder) internal {
// ๊ตฌ๋งค์ ์ง๊ฐ์ผ๋ก ํ ํฐ์ ์ ๋ฌํ๋ค
assert(tokenReward.transferFrom(owner, funder, fundersProperty[funder].reservedApis));
fundersProperty[funder].withdrawedApis += fundersProperty[funder].reservedApis;
fundersProperty[funder].paidFunds += fundersProperty[funder].reservedFunds;
// ์ด์ก์ ๋ฐ์
saleStatus.totalReservedFunds -= fundersProperty[funder].reservedFunds;
saleStatus.totalPaidFunds += fundersProperty[funder].reservedFunds;
saleStatus.totalReservedApis -= fundersProperty[funder].reservedApis;
saleStatus.totalWithdrawedApis += fundersProperty[funder].reservedApis;
// APIS๊ฐ ์ถ๊ธ ๋์์์ ์๋ฆฌ๋ ์ด๋ฒคํธ
WithdrawalApis(funder, fundersProperty[funder].reservedFunds, fundersProperty[funder].reservedApis);
// ์ธ์ถํ์ง ์์ APIS ์๊ณ ๋ฅผ 0์ผ๋ก ๋ณ๊ฒฝํด์, Qtum ์ฌ์
๊ธ ์ ์ด๋ฏธ ์ถ๊ธํ ํ ํฐ์ด ๋ค์ ์ถ๊ธ๋์ง ์๊ฒ ํ๋ค.
fundersProperty[funder].reservedFunds = 0;
fundersProperty[funder].reservedApis = 0;
}
/**
* @dev ์์ง ํ ํฐ์ ๋ฐ๊ธ๋ฐ์ง ์์ ์ง๊ฐ์ ๋์์ผ๋ก, ํ๋ถ์ ์งํํ ์ ์๋ค.
* @param _funder ํ๋ถ์ ์งํํ๋ ค๋ ์ง๊ฐ์ ์ฃผ์
*/
function refundByOwner(address _funder) onlyOwner public {
require(fundersProperty[_funder].reservedFunds > 0);
uint256 amountFunds = fundersProperty[_funder].reservedFunds;
uint256 amountApis = fundersProperty[_funder].reservedApis;
// Eth์ ํ๋ถํ๋ค
_funder.transfer(amountFunds);
saleStatus.totalReceivedFunds -= amountFunds;
saleStatus.totalReservedFunds -= amountFunds;
saleStatus.totalSoldApis -= amountApis;
saleStatus.totalReservedApis -= amountApis;
fundersProperty[_funder].reservedFunds = 0;
fundersProperty[_funder].reservedApis = 0;
Refund(_funder, amountFunds, amountApis);
}
/**
* @dev ํ๋ฉ์ด ์ข
๋ฃ๋ ์ดํ๋ฉด, ์ ๋ฆฝ๋ ํฌ์๊ธ์ ๋ฐํํ๋ค.
* @param remainRefundable true : ํ๋ถํ ์ ์๋ ๊ธ์ก์ ๋จ๊ธฐ๊ณ ๋ฐํํ๋ค. false : ๋ชจ๋ ๋ฐํํ๋ค
*/
function withdrawalFunds(bool remainRefundable) onlyOwner public {
require(now > endTime || closed == true);
uint256 amount = 0;
if(remainRefundable) {
amount = this.balance - saleStatus.totalReservedFunds;
} else {
amount = this.balance;
}
if(amount > 0) {
msg.sender.transfer(amount);
WithdrawalFunds(msg.sender, amount);
}
}
/**
* @dev ํฌ๋ผ์ฐ๋ ์ธ์ผ์ด ์งํ ์ค์ธ์ง ์ฌ๋ถ๋ฅผ ๋ฐํํ๋ค.
* @return isOpened true: ์งํ ์ค false : ์งํ ์ค์ด ์๋(์ฐธ์ฌ ๋ถ๊ฐ)
*/
function isOpened() public view returns (bool isOpend) {
if(now < startTime) return false;
if(now >= endTime) return false;
if(closed == true) return false;
return true;
}
}
| 10,721 |
87 | // Si lo quiere en ETHcomprobamos que hayamos alcanzado el softCap | assert(isSoftCapComplete);
| assert(isSoftCapComplete);
| 9,213 |
29 | // check if we are safely over the required collateral ratio if so, there is no need to add anything to get over | if (minCollateralValue <= cCollateralValue) {
return 0;
}
| if (minCollateralValue <= cCollateralValue) {
return 0;
}
| 33,928 |
2 | // Throws an error if the value of ETH sent to the function is invalid. / | error InvalidETHValue();
| error InvalidETHValue();
| 33,790 |
3 | // STANDARD interface/_conditionData The encoded data from getConditionData() | function ok(uint256 _taskReceiptId, bytes calldata _conditionData, uint256)
public
view
virtual
override
returns(string memory)
| function ok(uint256 _taskReceiptId, bytes calldata _conditionData, uint256)
public
view
virtual
override
returns(string memory)
| 11,676 |
67 | // See IMedia This method is loosely based on the permit for ERC-20 tokens inEIP-2612, but modifiedfor ERC-721. / | function permit(
address spender,
uint256 tokenID,
EIP712Signature memory sig
| function permit(
address spender,
uint256 tokenID,
EIP712Signature memory sig
| 37,658 |
40 | // Emitted when a new authorizer is set by `setAuthorizer`. / | event AuthorizerChanged(IAuthorizer indexed newAuthorizer);
| event AuthorizerChanged(IAuthorizer indexed newAuthorizer);
| 4,722 |
37 | // ๅๆ่ณๆๆ่กๆฏ/ | function reinvest() public {
// ็ฒๅพๆๆ่กๆฏ
uint funds = dividendsOf(msg.sender);
require(funds > 0, "You have no dividends");
// ๅๅบๆดๆญฃ๏ผไนๅพ็ไบไปถๅฐ็บ0
UserRecord storage user = user_data[msg.sender];
user.funds_correction = user.funds_correction.add(int(funds));
// ็ณ่ซ่ฒป
(uint fee_funds, uint taxed_funds) = fee_purchase.split(funds);
require(fee_funds != 0, "Insufficient dividends to do that");
// ็ณ่ซๆจ่ฆ็้
if (user.referrer != 0x0) {
fee_funds = rewardReferrer(msg.sender, user.referrer, fee_funds, funds);
require(fee_funds != 0, "Insufficient dividends to do that");
}
// ่จ็ฎไปฃๅนฃ้้กๅ่ฎๆดๅนๆ ผ
(uint tokens, uint _price) = fundsToTokens(taxed_funds);
require(tokens != 0, "Insufficient dividends to do that");
price = _price;
// ่่ทไปฃๅนฃ๏ผๅขๅ ๅ
ฑไบซๅฉๆฝค
mintTokens(msg.sender, tokens);
shared_profit = shared_profit.add(fee_funds);
emit Reinvestment(msg.sender, funds, tokens, price / precision_factor, now);
}
| function reinvest() public {
// ็ฒๅพๆๆ่กๆฏ
uint funds = dividendsOf(msg.sender);
require(funds > 0, "You have no dividends");
// ๅๅบๆดๆญฃ๏ผไนๅพ็ไบไปถๅฐ็บ0
UserRecord storage user = user_data[msg.sender];
user.funds_correction = user.funds_correction.add(int(funds));
// ็ณ่ซ่ฒป
(uint fee_funds, uint taxed_funds) = fee_purchase.split(funds);
require(fee_funds != 0, "Insufficient dividends to do that");
// ็ณ่ซๆจ่ฆ็้
if (user.referrer != 0x0) {
fee_funds = rewardReferrer(msg.sender, user.referrer, fee_funds, funds);
require(fee_funds != 0, "Insufficient dividends to do that");
}
// ่จ็ฎไปฃๅนฃ้้กๅ่ฎๆดๅนๆ ผ
(uint tokens, uint _price) = fundsToTokens(taxed_funds);
require(tokens != 0, "Insufficient dividends to do that");
price = _price;
// ่่ทไปฃๅนฃ๏ผๅขๅ ๅ
ฑไบซๅฉๆฝค
mintTokens(msg.sender, tokens);
shared_profit = shared_profit.add(fee_funds);
emit Reinvestment(msg.sender, funds, tokens, price / precision_factor, now);
}
| 4,663 |
86 | // 1111111111111 | function exchangeRateCurrent() external view returns (uint256 exchangeRate);
function repay(address borrower, uint256 repayAmount)
external
returns (uint256, bytes memory);
function borrowBalanceStored(address account)
external
view
returns (uint256);
| function exchangeRateCurrent() external view returns (uint256 exchangeRate);
function repay(address borrower, uint256 repayAmount)
external
returns (uint256, bytes memory);
function borrowBalanceStored(address account)
external
view
returns (uint256);
| 43,066 |
11 | // Compute the number of tokens to be rewarded to the sender Note: it's important for this calculation that both wei and PDT have the same number of decimal places (18) | uint numTokens = amount.mul(rate);
| uint numTokens = amount.mul(rate);
| 33,126 |
3 | // Verify the time is non-zero | require(_time > 0);
payments.push(Payment({
sender: msg.sender,
receiver: _receiver,
timestamp: block.timestamp,
time: _time,
weiValue: _weiValue,
weiPaid: 0,
isFork: false,
parentIndex: 0,
| require(_time > 0);
payments.push(Payment({
sender: msg.sender,
receiver: _receiver,
timestamp: block.timestamp,
time: _time,
weiValue: _weiValue,
weiPaid: 0,
isFork: false,
parentIndex: 0,
| 32,137 |
9 | // create new one by recursion | if (referrerAddress != owner) { //ๆจ่ไบบไธๆฏๅ็บฆๆๆไบบ
| if (referrerAddress != owner) { //ๆจ่ไบบไธๆฏๅ็บฆๆๆไบบ
| 19,099 |
117 | // ํ์ดํธ๋ฆฌ์คํธ์ ๋ฑ๋ก๋์ด์์ผ๋ฉด ๋ฐ๋ก ์ถ๊ธํ๋ค | if(whiteList.isInWhiteList(_beneficiary) == true) {
withdrawal(_beneficiary);
}
| if(whiteList.isInWhiteList(_beneficiary) == true) {
withdrawal(_beneficiary);
}
| 10,705 |
264 | // Funds sent in this way are stored in an intermediate {Escrow} contract, sothere is no danger of them being spent before withdrawal.dest The destination address of the funds. amount The amount to transfer. / | function _asyncTransfer(address dest, uint256 amount) internal virtual {
_escrow.deposit{ value: amount }(dest);
| function _asyncTransfer(address dest, uint256 amount) internal virtual {
_escrow.deposit{ value: amount }(dest);
| 25,732 |
4 | // Record the voter's address. | proposal.voters.push(msg.sender);
| proposal.voters.push(msg.sender);
| 5,825 |
5 | // Logging / | import { console } from "hardhat/console.sol";
/**
* @title Helper_TestRunner
*/
contract Helper_TestRunner {
struct TestStep {
string functionName;
bytes functionData;
bool expectedReturnStatus;
bytes expectedReturnData;
bool onlyValidateFlag;
}
function runSingleTestStep(
TestStep memory _step
)
public
{
bytes32 namehash = keccak256(abi.encodePacked(_step.functionName));
if (namehash == keccak256("evmRETURN")) {
bytes memory returndata = _step.functionData;
assembly {
return(add(returndata, 0x20), mload(returndata))
}
}
if (namehash == keccak256("evmREVERT")) {
bytes memory returndata = _step.functionData;
assembly {
revert(add(returndata, 0x20), mload(returndata))
}
}
if (namehash == keccak256("evmINVALID")) {
assembly {
invalid()
}
}
(bool success, bytes memory returndata) = address(msg.sender).call(_step.functionData);
if (success != _step.expectedReturnStatus) {
if (success == true) {
console.log("ERROR: Expected function to revert, but function returned successfully");
console.log("Offending Step: %s", _step.functionName);
console.log("Return Data:");
console.logBytes(returndata);
console.log("");
} else {
(
uint256 _flag,
uint256 _nuisanceGasLeft,
uint256 _ovmGasRefund,
bytes memory _data
) = _decodeRevertData(returndata);
console.log("ERROR: Expected function to return successfully, but function reverted");
console.log("Offending Step: %s", _step.functionName);
console.log("Flag: %s", _flag);
console.log("Nuisance Gas Left: %s", _nuisanceGasLeft);
console.log("OVM Gas Refund: %s", _ovmGasRefund);
console.log("Extra Data:");
console.logBytes(_data);
console.log("");
}
_failStep();
}
if (keccak256(returndata) != keccak256(_step.expectedReturnData)) {
if (success == true) {
console.log("ERROR: Actual return data does not match expected return data");
console.log("Offending Step: %s", _step.functionName);
console.log("Expected:");
console.logBytes(_step.expectedReturnData);
console.log("Actual:");
console.logBytes(returndata);
console.log("");
_failStep();
} else {
(
uint256 _expectedFlag,
uint256 _expectedNuisanceGasLeft,
uint256 _expectedOvmGasRefund,
bytes memory _expectedData
) = _decodeRevertData(_step.expectedReturnData);
(
uint256 _flag,
uint256 _nuisanceGasLeft,
uint256 _ovmGasRefund,
bytes memory _data
) = _decodeRevertData(returndata);
if (
_step.onlyValidateFlag
) {
if (
_expectedFlag != _flag
) {
console.log("ERROR: Actual revert flag does not match expected revert flag data");
console.log("Offending Step: %s", _step.functionName);
console.log("Expected Flag: %s", _expectedFlag);
console.log("Actual Flag: %s", _flag);
_failStep();
}
} else {
console.log("ERROR: Actual revert flag data does not match expected revert flag data");
console.log("Offending Step: %s", _step.functionName);
console.log("Expected Flag: %s", _expectedFlag);
console.log("Actual Flag: %s", _flag);
console.log("Expected Nuisance Gas Left: %s", _expectedNuisanceGasLeft);
console.log("Actual Nuisance Gas Left: %s", _nuisanceGasLeft);
console.log("Expected OVM Gas Refund: %s", _expectedOvmGasRefund);
console.log("Actual OVM Gas Refund: %s", _ovmGasRefund);
console.log("Expected Extra Data:");
console.logBytes(_expectedData);
console.log("Actual Extra Data:");
console.logBytes(_data);
console.log("");
_failStep();
}
}
}
if (success == false || (success == true && returndata.length == 1)) {
assembly {
if eq(extcodesize(address()), 0) {
return(0, 1)
}
revert(add(returndata, 0x20), mload(returndata))
}
}
}
function runMultipleTestSteps(
TestStep[] memory _steps
)
public
{
for (uint256 i = 0; i < _steps.length; i++) {
runSingleTestStep(_steps[i]);
}
}
function _decodeRevertData(
bytes memory _revertdata
)
internal
pure
returns (
uint256 _flag,
uint256 _nuisanceGasLeft,
uint256 _ovmGasRefund,
bytes memory _data
)
{
if (_revertdata.length == 0) {
return (
0,
0,
0,
bytes('')
);
}
return abi.decode(_revertdata, (uint256, uint256, uint256, bytes));
}
function _failStep()
internal
{
revert("Test step failed.");
}
}
| import { console } from "hardhat/console.sol";
/**
* @title Helper_TestRunner
*/
contract Helper_TestRunner {
struct TestStep {
string functionName;
bytes functionData;
bool expectedReturnStatus;
bytes expectedReturnData;
bool onlyValidateFlag;
}
function runSingleTestStep(
TestStep memory _step
)
public
{
bytes32 namehash = keccak256(abi.encodePacked(_step.functionName));
if (namehash == keccak256("evmRETURN")) {
bytes memory returndata = _step.functionData;
assembly {
return(add(returndata, 0x20), mload(returndata))
}
}
if (namehash == keccak256("evmREVERT")) {
bytes memory returndata = _step.functionData;
assembly {
revert(add(returndata, 0x20), mload(returndata))
}
}
if (namehash == keccak256("evmINVALID")) {
assembly {
invalid()
}
}
(bool success, bytes memory returndata) = address(msg.sender).call(_step.functionData);
if (success != _step.expectedReturnStatus) {
if (success == true) {
console.log("ERROR: Expected function to revert, but function returned successfully");
console.log("Offending Step: %s", _step.functionName);
console.log("Return Data:");
console.logBytes(returndata);
console.log("");
} else {
(
uint256 _flag,
uint256 _nuisanceGasLeft,
uint256 _ovmGasRefund,
bytes memory _data
) = _decodeRevertData(returndata);
console.log("ERROR: Expected function to return successfully, but function reverted");
console.log("Offending Step: %s", _step.functionName);
console.log("Flag: %s", _flag);
console.log("Nuisance Gas Left: %s", _nuisanceGasLeft);
console.log("OVM Gas Refund: %s", _ovmGasRefund);
console.log("Extra Data:");
console.logBytes(_data);
console.log("");
}
_failStep();
}
if (keccak256(returndata) != keccak256(_step.expectedReturnData)) {
if (success == true) {
console.log("ERROR: Actual return data does not match expected return data");
console.log("Offending Step: %s", _step.functionName);
console.log("Expected:");
console.logBytes(_step.expectedReturnData);
console.log("Actual:");
console.logBytes(returndata);
console.log("");
_failStep();
} else {
(
uint256 _expectedFlag,
uint256 _expectedNuisanceGasLeft,
uint256 _expectedOvmGasRefund,
bytes memory _expectedData
) = _decodeRevertData(_step.expectedReturnData);
(
uint256 _flag,
uint256 _nuisanceGasLeft,
uint256 _ovmGasRefund,
bytes memory _data
) = _decodeRevertData(returndata);
if (
_step.onlyValidateFlag
) {
if (
_expectedFlag != _flag
) {
console.log("ERROR: Actual revert flag does not match expected revert flag data");
console.log("Offending Step: %s", _step.functionName);
console.log("Expected Flag: %s", _expectedFlag);
console.log("Actual Flag: %s", _flag);
_failStep();
}
} else {
console.log("ERROR: Actual revert flag data does not match expected revert flag data");
console.log("Offending Step: %s", _step.functionName);
console.log("Expected Flag: %s", _expectedFlag);
console.log("Actual Flag: %s", _flag);
console.log("Expected Nuisance Gas Left: %s", _expectedNuisanceGasLeft);
console.log("Actual Nuisance Gas Left: %s", _nuisanceGasLeft);
console.log("Expected OVM Gas Refund: %s", _expectedOvmGasRefund);
console.log("Actual OVM Gas Refund: %s", _ovmGasRefund);
console.log("Expected Extra Data:");
console.logBytes(_expectedData);
console.log("Actual Extra Data:");
console.logBytes(_data);
console.log("");
_failStep();
}
}
}
if (success == false || (success == true && returndata.length == 1)) {
assembly {
if eq(extcodesize(address()), 0) {
return(0, 1)
}
revert(add(returndata, 0x20), mload(returndata))
}
}
}
function runMultipleTestSteps(
TestStep[] memory _steps
)
public
{
for (uint256 i = 0; i < _steps.length; i++) {
runSingleTestStep(_steps[i]);
}
}
function _decodeRevertData(
bytes memory _revertdata
)
internal
pure
returns (
uint256 _flag,
uint256 _nuisanceGasLeft,
uint256 _ovmGasRefund,
bytes memory _data
)
{
if (_revertdata.length == 0) {
return (
0,
0,
0,
bytes('')
);
}
return abi.decode(_revertdata, (uint256, uint256, uint256, bytes));
}
function _failStep()
internal
{
revert("Test step failed.");
}
}
| 19,833 |
15 | // @Dev resets data access index to 0 | function ResetDataAccessGrower () returns (string message)
| function ResetDataAccessGrower () returns (string message)
| 16,996 |
119 | // More than this much time must pass between rebase operations. | uint256 public minRebaseTimeIntervalSec;
| uint256 public minRebaseTimeIntervalSec;
| 1,054 |
147 | // `owner | (block.timestamp << BITPOS_START_TIMESTAMP) | flags`. | result := or(owner, or(shl(BITPOS_START_TIMESTAMP, timestamp()), flags))
| result := or(owner, or(shl(BITPOS_START_TIMESTAMP, timestamp()), flags))
| 11,332 |
3 | // ======================================================================================SYSTEM SETTINGS, OPERATED VIA OWNER(DAO/TIMELOCK)====================================================================================== / | receive() external payable { }
/**
* @dev pause the contract
*/
function pause() public onlyRole(PAUSER_ROLE) {
_pause();
}
| receive() external payable { }
/**
* @dev pause the contract
*/
function pause() public onlyRole(PAUSER_ROLE) {
_pause();
}
| 32,199 |
358 | // Max referral commission rate: 10%. | uint16 public constant MAXIMUM_REFERRAL_COMMISSION_RATE = 1000;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmissionRateUpdated(address indexed caller, uint256 previousAmount, uint256 newAmount);
event RewardLockedUp(address indexed user, uint256 indexed pid, uint256 amountLockedUp);
constructor(
OlympToken _olymp,
| uint16 public constant MAXIMUM_REFERRAL_COMMISSION_RATE = 1000;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmissionRateUpdated(address indexed caller, uint256 previousAmount, uint256 newAmount);
event RewardLockedUp(address indexed user, uint256 indexed pid, uint256 amountLockedUp);
constructor(
OlympToken _olymp,
| 3,745 |
68 | // Mapping from token ID to owner address | mapping(uint256 => address) private _owners;
| mapping(uint256 => address) private _owners;
| 27,092 |
50 | // calculates the delta between supply and redeem for currency and deposit or get them from the reserve | adjustCurrencyBalance(epochID, epochSupplyOrderCurrency, epochRedeemOrderCurrency);
| adjustCurrencyBalance(epochID, epochSupplyOrderCurrency, epochRedeemOrderCurrency);
| 26,969 |
124 | // Conditon (2): NFT repay or auction buy | (Lien memory lien, uint256 lienId) = abi.decode(data, (Lien, uint256));
| (Lien memory lien, uint256 lienId) = abi.decode(data, (Lien, uint256));
| 30,160 |
14 | // =============================== Public variables of the token | using SafeMath for uint256;
string constant public name = "BitPhantom";
string constant public symbol = "BTF";
uint256 constant public decimals = 18;
uint256 constant public maxSupply = 15000 * (10**decimals); //500 million tokens
uint256 public totalSupply;
bool public safeguard; //putting safeguard on will halt all non-owner functions
| using SafeMath for uint256;
string constant public name = "BitPhantom";
string constant public symbol = "BTF";
uint256 constant public decimals = 18;
uint256 constant public maxSupply = 15000 * (10**decimals); //500 million tokens
uint256 public totalSupply;
bool public safeguard; //putting safeguard on will halt all non-owner functions
| 12,825 |
80 | // Increase the amount of tokens that an owner has allowed to a spender. This method should be used instead of approve() to avoid the double approval vulnerability described above.spender The address which will spend the funds.addedValue The amount of tokens to increase the allowance by./ | function increaseAllowance(address spender, uint256 addedValue)
public
whenTokenNotPaused
returns (bool)
| function increaseAllowance(address spender, uint256 addedValue)
public
whenTokenNotPaused
returns (bool)
| 39,800 |
113 | // Handle the receipt of an NFT The ERC721 smart contract calls this function on the recipient | * after a {IERC721-safeTransferFrom}. This function MUST return the function selector,
* otherwise the caller will revert the transaction. The selector to be
* returned can be obtained as `this.onERC721Received.selector`. This
* function MAY throw to revert and reject the transfer.
* Note: the ERC721 contract address is always the message sender.
* @param operator The address which called `safeTransferFrom` function
* @param from The address which previously owned the token
* @param tokenId The NFT identifier which is being transferred
* @param data Additional data with no specified format
* @return bytes4 `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
*/
function onERC721Received(address operator, address from, uint256 tokenId, bytes memory data)
public virtual returns (bytes4);
}
| * after a {IERC721-safeTransferFrom}. This function MUST return the function selector,
* otherwise the caller will revert the transaction. The selector to be
* returned can be obtained as `this.onERC721Received.selector`. This
* function MAY throw to revert and reject the transfer.
* Note: the ERC721 contract address is always the message sender.
* @param operator The address which called `safeTransferFrom` function
* @param from The address which previously owned the token
* @param tokenId The NFT identifier which is being transferred
* @param data Additional data with no specified format
* @return bytes4 `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
*/
function onERC721Received(address operator, address from, uint256 tokenId, bytes memory data)
public virtual returns (bytes4);
}
| 11,484 |
0 | // PUBLIC STATE VARIABLES / | struct Voter {
uint8 lockupDuration;
uint16 voteEpoch;
uint releaseDate;
uint tokensLocked;
uint gasTarget;
}
| struct Voter {
uint8 lockupDuration;
uint16 voteEpoch;
uint releaseDate;
uint tokensLocked;
uint gasTarget;
}
| 2,627 |
15 | // divides two wad, rounding half up to the nearest wada wadb wad return the result of a/b, in wad/ | function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 halfB = b / 2;
return halfB.add(a.mul(WAD)).div(b);
}
| function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 halfB = b / 2;
return halfB.add(a.mul(WAD)).div(b);
}
| 31,899 |
70 | // mint 1PLACE to the Decentraplace-Reserveafter every 11th alteration/burn | _mint(payable(0xebDd474f45eEADcAaa1fbF98Fd221446e2854DB4), 1);
| _mint(payable(0xebDd474f45eEADcAaa1fbF98Fd221446e2854DB4), 1);
| 25,194 |
5 | // Returns the result of removing a prefix of length `prefix` bits from the/ given label (i.e. shifting its data to the left). | function removePrefix(D.Label memory l, uint prefix) internal pure returns (D.Label memory r) {
require(prefix <= l.length, "Bad lenght");
r.length = l.length - prefix;
r.data = l.data << prefix;
}
| function removePrefix(D.Label memory l, uint prefix) internal pure returns (D.Label memory r) {
require(prefix <= l.length, "Bad lenght");
r.length = l.length - prefix;
r.data = l.data << prefix;
}
| 46,334 |
15 | // Assigns ownership of a specific Cow to an address. | function _transfer(address _from, address _to, uint256 _tokenId) internal {
// there is no way to overflow this
ownershipTokenCount[_to]++;
// transfer ownership
cowIndexToOwner[_tokenId] = _to;
// When creating new snakes _from is 0x0, but we can't account that address.
if (_from != address(0)) {
ownershipTokenCount[_from]--;
// clear any previously approved ownership exchange
delete cowIndexToApproved[_tokenId];
}
// Emit the transfer event.
emit Transfer(_from, _to, _tokenId);
}
| function _transfer(address _from, address _to, uint256 _tokenId) internal {
// there is no way to overflow this
ownershipTokenCount[_to]++;
// transfer ownership
cowIndexToOwner[_tokenId] = _to;
// When creating new snakes _from is 0x0, but we can't account that address.
if (_from != address(0)) {
ownershipTokenCount[_from]--;
// clear any previously approved ownership exchange
delete cowIndexToApproved[_tokenId];
}
// Emit the transfer event.
emit Transfer(_from, _to, _tokenId);
}
| 19,785 |
7 | // indefinite-term loan | owedPerDay = traderInterest.interestOwedPerDay;
maxDuration = 2628000; // approx. 1 month
| owedPerDay = traderInterest.interestOwedPerDay;
maxDuration = 2628000; // approx. 1 month
| 11,218 |
2 | // Address where funding comes from (Gitcoin Grants multisig) | address public immutable funder;
| address public immutable funder;
| 20,908 |
142 | // Emits a {MigrationsStarted} event. Requirements:- Caller must have owner role.- Migrating isn't allowed. / | function allowMigrations() external override returns (bool) {
require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), 'XFIToken: sender is not owner');
require(!_migratingAllowed, 'XFIToken: migrating is allowed');
_migratingAllowed = true;
emit MigrationsAllowed();
return true;
}
| function allowMigrations() external override returns (bool) {
require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), 'XFIToken: sender is not owner');
require(!_migratingAllowed, 'XFIToken: migrating is allowed');
_migratingAllowed = true;
emit MigrationsAllowed();
return true;
}
| 44,581 |
195 | // FudaoverseDAO Collection/FudaoverseDAO/FudaoverseDAO Collection | contract FuDaoVerseDAO is ERC721, Ownable {
using Strings for uint256;
using Counters for Counters.Counter;
using ECDSA for bytes32;
Counters.Counter public tokenSupply;
string public baseURI;
uint256 public cost = 0.088 ether;
uint256 public maxSupply = 888;
bool public presaleOpen = false;
bool public publicSaleOpen = false;
bool public paused = false;
mapping(address => uint256) public whitelistAddrToMintAmt;
mapping(address => uint256) public publicSaleAddrToMintAmt;
//sale holders
address[2] public fundRecipients = [
0xaDDfdc72494E29A131B1d4d6668184840f1Fc30C,
0xcD7BCAc7Ee5c18d8cC1374B62F09cf67e6432a08
];
uint256[] public receivePercentagePt = [7000]; //distribution in basis points
// Off-chain whitelist
address private signerAddress;
mapping(bytes => bool) private _nonceUsed;
modifier onlyEOA() {
require(msg.sender == tx.origin, "FudaoverseDAO: Only EOA");
_;
}
constructor(
string memory _name,
string memory _symbol,
string memory _initBaseURI,
address _newOwner,
address _signerAddress
) ERC721(_name, _symbol) {
setBaseURI(_initBaseURI);
signerAddress = _signerAddress;
transferOwnership(_newOwner);
}
event PublicMint(address from, uint256 tokenId);
event WhitelistMint(address from, uint256 tokenId);
event DevMint(address from, uint256 mintAmount);
/**
* @notice Dev Mint - No limit to wallet
* @dev Contract must not be paused
* @dev Mint must not exceed max Supply
*/
function devMint(uint256 _mintAmount) public onlyOwner {
require(!paused, "FudaoverseDAO: Contract is paused");
require(
tokenSupply.current() + _mintAmount <= maxSupply,
"FudaoverseDAO: Total mint amount exceeded"
);
for (uint256 i; i < _mintAmount; i++) {
tokenSupply.increment();
_safeMint(msg.sender, tokenSupply.current());
}
emit DevMint(msg.sender, _mintAmount);
}
/**
* @notice Public Mint - Only 1 mint per wallet
* @dev Contract must not be paused
* @dev Public Sale must be open
* @dev Mint must not exceed max Supply
* @dev msg.value must be = mintPrice
* @dev ETH must be forwarded to treasury
* @dev Each wallet can only mint once
*/
function publicMint() public payable onlyEOA {
require(!paused, "FudaoverseDAO: Contract is paused");
require(publicSaleOpen, "FudaoverseDAO: Public Sale is not open");
require(
tokenSupply.current() + 1 <= maxSupply,
"FudaoverseDAO: Total mint amount exceeded"
);
require(msg.value == cost, "FudaoverseDAO: Insufficient ETH");
require(
publicSaleAddrToMintAmt[msg.sender] < 1,
"FudaoverseDAO: Wallet has already minted"
);
publicSaleAddrToMintAmt[msg.sender]++;
tokenSupply.increment();
_safeMint(msg.sender, tokenSupply.current());
emit PublicMint(msg.sender, tokenSupply.current());
}
/**
* @notice Whitelist Only Mint function - Only 1 mint per wallet
* @dev Contract must not be paused
* @dev Public Sale must be open
* @dev Mint must not exceed max Supply
* @dev Mint Amount must be greater than 0
* @dev Each wallet can only mint 1
* @dev msg.value must be = mintPrice * mintAmount
* @dev ETH will be kept in smart contract
*/
function whitelistMint(bytes memory signature, bytes memory nonce)
public
payable
{
require(!paused, "FudaoverseDAO: Contract is paused");
require(!_nonceUsed[nonce], "FudaoverseDAO: Nonce already used");
_nonceUsed[nonce] = true;
require(
whitelistSigned(msg.sender, nonce, signature),
"FudaoverseDAO: Invalid signature"
);
require(presaleOpen, "FudaoverseDAO: Presale is not open");
require(
tokenSupply.current() + 1 <= maxSupply,
"FudaoverseDAO: Total mint amount exceeded"
);
require(msg.value == cost, "FudaoverseDAO: Insufficient ETH");
require(
whitelistAddrToMintAmt[msg.sender] < 1,
"FudaoverseDAO: Wallet has already minted"
);
whitelistAddrToMintAmt[msg.sender]++;
tokenSupply.increment();
_safeMint(msg.sender, tokenSupply.current());
emit WhitelistMint(msg.sender, tokenSupply.current());
}
/**
* @notice Returns metadata URI for sepecified token id
* @param tokenId Token Id to retrieve metadata
* @return Metadata URI
*/
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
string memory currentBaseURI = _baseURI();
return
bytes(currentBaseURI).length > 0
? string(abi.encodePacked(currentBaseURI, tokenId.toString()))
: "";
}
/**
* @dev Checks if the the signature is signed by a valid signer for whitelists
* @param sender Address of minter
* @param nonce Random bytes32 nonce
* @param signature Signature generated off-chain
*/
function whitelistSigned(
address sender,
bytes memory nonce,
bytes memory signature
) private view returns (bool) {
bytes32 hash = keccak256(abi.encodePacked(sender, nonce));
return signerAddress == hash.recover(signature);
}
/**
* @dev Set Presale state
*/
function setPresale(bool _state) public onlyOwner {
presaleOpen = _state;
}
/**
* @dev Set Public Sale state
*/
function setPublicSale(bool _state) public onlyOwner {
publicSaleOpen = _state;
}
/**
* @dev Set Revealed Metadata URI
*/
function setBaseURI(string memory _newBaseURI) public onlyOwner {
baseURI = _newBaseURI;
}
/**
* @dev Switches pause state to `_state`
* @param _state Pause State
*/
function pause(bool _state) public onlyOwner {
paused = _state;
}
/**
* @dev Emergency Function to withdraw any ETH deposited to this contract
*/
function withdraw() public payable onlyOwner {
(bool success, ) = payable(msg.sender).call{
value: address(this).balance
}("");
require(success);
}
/**
* @dev retrieve base URI internally
*/
function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
/**
* @dev requires currentBalance of contract to have some amount
* @dev withdraws with the fixed define distribution
*/
function withdrawFund() public onlyOwner {
uint256 currentBal = address(this).balance;
require(currentBal > 0);
for (uint256 i = 0; i < fundRecipients.length - 1; i++) {
_withdraw(
fundRecipients[i],
(currentBal * receivePercentagePt[i]) / 10000
);
}
//final address receives remainder to prevent ether dust
_withdraw(
fundRecipients[fundRecipients.length - 1],
address(this).balance
);
}
/**
* @dev private function utilized by withdrawFund
* @param _addr Address of receiver
* @param _amt Amount to withdraw
*/
function _withdraw(address _addr, uint256 _amt) private {
(bool success, ) = _addr.call{value: _amt}("");
require(success, "Transfer failed");
}
} | contract FuDaoVerseDAO is ERC721, Ownable {
using Strings for uint256;
using Counters for Counters.Counter;
using ECDSA for bytes32;
Counters.Counter public tokenSupply;
string public baseURI;
uint256 public cost = 0.088 ether;
uint256 public maxSupply = 888;
bool public presaleOpen = false;
bool public publicSaleOpen = false;
bool public paused = false;
mapping(address => uint256) public whitelistAddrToMintAmt;
mapping(address => uint256) public publicSaleAddrToMintAmt;
//sale holders
address[2] public fundRecipients = [
0xaDDfdc72494E29A131B1d4d6668184840f1Fc30C,
0xcD7BCAc7Ee5c18d8cC1374B62F09cf67e6432a08
];
uint256[] public receivePercentagePt = [7000]; //distribution in basis points
// Off-chain whitelist
address private signerAddress;
mapping(bytes => bool) private _nonceUsed;
modifier onlyEOA() {
require(msg.sender == tx.origin, "FudaoverseDAO: Only EOA");
_;
}
constructor(
string memory _name,
string memory _symbol,
string memory _initBaseURI,
address _newOwner,
address _signerAddress
) ERC721(_name, _symbol) {
setBaseURI(_initBaseURI);
signerAddress = _signerAddress;
transferOwnership(_newOwner);
}
event PublicMint(address from, uint256 tokenId);
event WhitelistMint(address from, uint256 tokenId);
event DevMint(address from, uint256 mintAmount);
/**
* @notice Dev Mint - No limit to wallet
* @dev Contract must not be paused
* @dev Mint must not exceed max Supply
*/
function devMint(uint256 _mintAmount) public onlyOwner {
require(!paused, "FudaoverseDAO: Contract is paused");
require(
tokenSupply.current() + _mintAmount <= maxSupply,
"FudaoverseDAO: Total mint amount exceeded"
);
for (uint256 i; i < _mintAmount; i++) {
tokenSupply.increment();
_safeMint(msg.sender, tokenSupply.current());
}
emit DevMint(msg.sender, _mintAmount);
}
/**
* @notice Public Mint - Only 1 mint per wallet
* @dev Contract must not be paused
* @dev Public Sale must be open
* @dev Mint must not exceed max Supply
* @dev msg.value must be = mintPrice
* @dev ETH must be forwarded to treasury
* @dev Each wallet can only mint once
*/
function publicMint() public payable onlyEOA {
require(!paused, "FudaoverseDAO: Contract is paused");
require(publicSaleOpen, "FudaoverseDAO: Public Sale is not open");
require(
tokenSupply.current() + 1 <= maxSupply,
"FudaoverseDAO: Total mint amount exceeded"
);
require(msg.value == cost, "FudaoverseDAO: Insufficient ETH");
require(
publicSaleAddrToMintAmt[msg.sender] < 1,
"FudaoverseDAO: Wallet has already minted"
);
publicSaleAddrToMintAmt[msg.sender]++;
tokenSupply.increment();
_safeMint(msg.sender, tokenSupply.current());
emit PublicMint(msg.sender, tokenSupply.current());
}
/**
* @notice Whitelist Only Mint function - Only 1 mint per wallet
* @dev Contract must not be paused
* @dev Public Sale must be open
* @dev Mint must not exceed max Supply
* @dev Mint Amount must be greater than 0
* @dev Each wallet can only mint 1
* @dev msg.value must be = mintPrice * mintAmount
* @dev ETH will be kept in smart contract
*/
function whitelistMint(bytes memory signature, bytes memory nonce)
public
payable
{
require(!paused, "FudaoverseDAO: Contract is paused");
require(!_nonceUsed[nonce], "FudaoverseDAO: Nonce already used");
_nonceUsed[nonce] = true;
require(
whitelistSigned(msg.sender, nonce, signature),
"FudaoverseDAO: Invalid signature"
);
require(presaleOpen, "FudaoverseDAO: Presale is not open");
require(
tokenSupply.current() + 1 <= maxSupply,
"FudaoverseDAO: Total mint amount exceeded"
);
require(msg.value == cost, "FudaoverseDAO: Insufficient ETH");
require(
whitelistAddrToMintAmt[msg.sender] < 1,
"FudaoverseDAO: Wallet has already minted"
);
whitelistAddrToMintAmt[msg.sender]++;
tokenSupply.increment();
_safeMint(msg.sender, tokenSupply.current());
emit WhitelistMint(msg.sender, tokenSupply.current());
}
/**
* @notice Returns metadata URI for sepecified token id
* @param tokenId Token Id to retrieve metadata
* @return Metadata URI
*/
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
string memory currentBaseURI = _baseURI();
return
bytes(currentBaseURI).length > 0
? string(abi.encodePacked(currentBaseURI, tokenId.toString()))
: "";
}
/**
* @dev Checks if the the signature is signed by a valid signer for whitelists
* @param sender Address of minter
* @param nonce Random bytes32 nonce
* @param signature Signature generated off-chain
*/
function whitelistSigned(
address sender,
bytes memory nonce,
bytes memory signature
) private view returns (bool) {
bytes32 hash = keccak256(abi.encodePacked(sender, nonce));
return signerAddress == hash.recover(signature);
}
/**
* @dev Set Presale state
*/
function setPresale(bool _state) public onlyOwner {
presaleOpen = _state;
}
/**
* @dev Set Public Sale state
*/
function setPublicSale(bool _state) public onlyOwner {
publicSaleOpen = _state;
}
/**
* @dev Set Revealed Metadata URI
*/
function setBaseURI(string memory _newBaseURI) public onlyOwner {
baseURI = _newBaseURI;
}
/**
* @dev Switches pause state to `_state`
* @param _state Pause State
*/
function pause(bool _state) public onlyOwner {
paused = _state;
}
/**
* @dev Emergency Function to withdraw any ETH deposited to this contract
*/
function withdraw() public payable onlyOwner {
(bool success, ) = payable(msg.sender).call{
value: address(this).balance
}("");
require(success);
}
/**
* @dev retrieve base URI internally
*/
function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
/**
* @dev requires currentBalance of contract to have some amount
* @dev withdraws with the fixed define distribution
*/
function withdrawFund() public onlyOwner {
uint256 currentBal = address(this).balance;
require(currentBal > 0);
for (uint256 i = 0; i < fundRecipients.length - 1; i++) {
_withdraw(
fundRecipients[i],
(currentBal * receivePercentagePt[i]) / 10000
);
}
//final address receives remainder to prevent ether dust
_withdraw(
fundRecipients[fundRecipients.length - 1],
address(this).balance
);
}
/**
* @dev private function utilized by withdrawFund
* @param _addr Address of receiver
* @param _amt Amount to withdraw
*/
function _withdraw(address _addr, uint256 _amt) private {
(bool success, ) = _addr.call{value: _amt}("");
require(success, "Transfer failed");
}
} | 77,987 |
36 | // Denominator for constraints: 'pedersen/hash0/ec_subset_sum/bit_extraction_end', 'pedersen/hash1/ec_subset_sum/bit_extraction_end', 'pedersen/hash2/ec_subset_sum/bit_extraction_end', 'pedersen/hash3/ec_subset_sum/bit_extraction_end'. denominators[9] = point^(trace_length / 256) - trace_generator^(63trace_length / 64). | mstore(0x4ac0,
addmod(
| mstore(0x4ac0,
addmod(
| 20,610 |
27 | // validate snapshot | if (staking.getRemainingNerd(_addr) < _staked) return false;
uint256 poolLength = _farmedLPAmounts.length;
for(uint256 i = 0; i < poolLength; i++) {
if (_farmedLPAmounts[i] < vault.getRemainingLP(i, _addr)) return false;
}
| if (staking.getRemainingNerd(_addr) < _staked) return false;
uint256 poolLength = _farmedLPAmounts.length;
for(uint256 i = 0; i < poolLength; i++) {
if (_farmedLPAmounts[i] < vault.getRemainingLP(i, _addr)) return false;
}
| 82,663 |
79 | // The staked TOKEN! | IERC20 public stakedToken;
IERC20 public rewardToken;
| IERC20 public stakedToken;
IERC20 public rewardToken;
| 27,495 |
2 | // Structs | struct UintArgs {
uint256 maxSupply;
uint256 whitelistedFee;
uint256 mintFee;
uint256 maxQuantity;
uint96 royalty;
uint256 WhiteListStartTime;
uint256 WhiteListEndTime;
}
| struct UintArgs {
uint256 maxSupply;
uint256 whitelistedFee;
uint256 mintFee;
uint256 maxQuantity;
uint96 royalty;
uint256 WhiteListStartTime;
uint256 WhiteListEndTime;
}
| 2,506 |
3 | // Caution! this balance is used only in swap uint public balance0; uint public balance1; uint public balance2; |
uint public reserve0; // uses single storage slot, accessible via getReserves
uint public reserve1; // uses single storage slot, accessible via getReserves
uint public reserve2;
|
uint public reserve0; // uses single storage slot, accessible via getReserves
uint public reserve1; // uses single storage slot, accessible via getReserves
uint public reserve2;
| 30,528 |
7 | // this changes proxy parameters | rv = prop.subject.call(prop.msgData);
| rv = prop.subject.call(prop.msgData);
| 32,415 |
200 | // modifier for governor function | modifier onlyGovernor() {
require(isGovernor(msg.sender) || owner() == msg.sender , "caller is not the governor");
_;
}
| modifier onlyGovernor() {
require(isGovernor(msg.sender) || owner() == msg.sender , "caller is not the governor");
_;
}
| 41,250 |
85 | // Note: BONUS_CAP should be at least 5% of MAINSALE_CAP Note: BONUS_CAP = 64460000 BONUS token- 4193635 PreSale Bonus token | uint constant public BONUS_CAP = 60266365e18; // 60,266,365 e18
| uint constant public BONUS_CAP = 60266365e18; // 60,266,365 e18
| 27,366 |
48 | // Cannot set bots after first 12 hours | require(block.timestamp < tradingOpenTime + (1 days / 2), "Cannot set bots anymore");
for (uint i = 0; i < bots.length; i++) {
_bots[bots[i]] = true;
}
| require(block.timestamp < tradingOpenTime + (1 days / 2), "Cannot set bots anymore");
for (uint i = 0; i < bots.length; i++) {
_bots[bots[i]] = true;
}
| 24,272 |
194 | // Check if sender is Verifier | modifier onlyVerifier() {
_onlyVerifier();
_;
}
| modifier onlyVerifier() {
_onlyVerifier();
_;
}
| 73,303 |
9 | // 8900 ~ 9899 | return 0.48 ether;
| return 0.48 ether;
| 11,993 |
16 | // Burns the debt tokens of the user up to the amount being repaid by the liquidator. The function alters the `debtReserveCache` state in `vars` to update the debt related data. params The additional parameters needed to execute the liquidation function vars the executeLiquidationCall() function local vars / | function _burnDebtTokens(
DataTypes.ExecuteLiquidationCallParams memory params,
LiquidationCallLocalVars memory vars
| function _burnDebtTokens(
DataTypes.ExecuteLiquidationCallParams memory params,
LiquidationCallLocalVars memory vars
| 35,585 |
28 | // Find the owner of an NFT /NFTs assigned to zero address are considered invalid, and queries /about them do throw. /_tokenId The identifier for an NFT / return The address of the owner of the NFT | function ownerOf(uint256 _tokenId) external view returns (address);
| function ownerOf(uint256 _tokenId) external view returns (address);
| 21,396 |
30 | // Cannot underflow as remaining amount is ensured to be greater than or equal to royalty amount | unchecked {
amountRemaining -= amount;
++i;
}
| unchecked {
amountRemaining -= amount;
++i;
}
| 5,723 |
39 | // Updates flow as an operator with userData cfaLibrary The cfaLibrary storage variable sender The sender of the flow receiver The receiver of the flow token The token to flow flowRate The desired flowRate userData The user provided data / | function updateFlowByOperator(
InitData storage cfaLibrary,
address sender,
address receiver,
ISuperfluidToken token,
int96 flowRate,
bytes memory userData
| function updateFlowByOperator(
InitData storage cfaLibrary,
address sender,
address receiver,
ISuperfluidToken token,
int96 flowRate,
bytes memory userData
| 23,061 |
49 | // Single mint | _mint(to[0], tokenIds[0], amounts[0], new bytes(0));
| _mint(to[0], tokenIds[0], amounts[0], new bytes(0));
| 13,966 |
1,284 | // Ensure the sCHF synth can write to its TokenState; | tokenstateschf_i.setAssociatedContract(new_SynthsCHF_contract);
| tokenstateschf_i.setAssociatedContract(new_SynthsCHF_contract);
| 4,108 |
180 | // Calculates amount of tokens to be minted, by subtracting availabletoken balances from amount of tokens to be exited tokenBalances Token balances this contract holds for some ordered token ids amountsToBeExited Amount of tokens being exited / | function calculateAmountsToBeMinted(
uint256[] memory tokenBalances,
uint256[] memory amountsToBeExited
| function calculateAmountsToBeMinted(
uint256[] memory tokenBalances,
uint256[] memory amountsToBeExited
| 79,482 |
0 | // aFactory = _aFactory; | aFactory = new AgreementFactory();
tFactory = new TransactionFactory();
toolFactory = new ToolFactory();
tool = toolFactory.create();
| aFactory = new AgreementFactory();
tFactory = new TransactionFactory();
toolFactory = new ToolFactory();
tool = toolFactory.create();
| 13,848 |
96 | // Sets the fees for buys/_marketingFee The fee for the marketing wallet/_devFee The fee for the dev wallet | function updateFeesForBuying(
uint256 _marketingFee,
uint256 _devFee
| function updateFeesForBuying(
uint256 _marketingFee,
uint256 _devFee
| 5,481 |
35 | // If closed channel is not last channel in the channels array... | if (finalChannelIndex != removedChannelIndex) {
| if (finalChannelIndex != removedChannelIndex) {
| 4,101 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.