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 |
|---|---|---|---|---|
93 | // Finalizes ICO: changes token ownership to founder, allows token transfers/ | function finalizeCrowdsale() onlyOwner public {
finalized = true;
assert(token.finishMinting());
token.setTransferEnabled(true);
token.transferOwnership(owner);
claimEther();
}
| function finalizeCrowdsale() onlyOwner public {
finalized = true;
assert(token.finishMinting());
token.setTransferEnabled(true);
token.transferOwnership(owner);
claimEther();
}
| 50,147 |
167 | // Accrue REWARD to the market by updating the borrow index mToken The market whose borrow index to update / | function updateRewardBorrowIndex(
address mToken,
Exp memory marketBorrowIndex
| function updateRewardBorrowIndex(
address mToken,
Exp memory marketBorrowIndex
| 31,390 |
132 | // Blacklist multiple wallets from buying and selling / | function blacklistMultipleWallets(address[] calldata accounts) external onlyOwner{
require(accounts.length < 800, "Can not blacklist more then 800 address in one transaction");
for (uint256 i; i < accounts.length; ++i) {
isBlacklisted[accounts[i]] = true;
}
}
| function blacklistMultipleWallets(address[] calldata accounts) external onlyOwner{
require(accounts.length < 800, "Can not blacklist more then 800 address in one transaction");
for (uint256 i; i < accounts.length; ++i) {
isBlacklisted[accounts[i]] = true;
}
}
| 13,616 |
4 | // bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1) / | bytes32 internal constant OWNER_KEY =
0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
| bytes32 internal constant OWNER_KEY =
0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
| 5,536 |
32 | // contructor parameters | uint public crowdsaleStartBlock;
address public owner1;
address public owner2;
address public withdrawAddress; // multi-sig wallet that will receive ether
| uint public crowdsaleStartBlock;
address public owner1;
address public owner2;
address public withdrawAddress; // multi-sig wallet that will receive ether
| 44,851 |
9 | // in case something wrong with base token contract | function emergencySettle() external isNotForceStop phaseSettlement preventReentrant {
require(block.timestamp >= _PHASE_CALM_ENDTIME_.add(_SETTLEMENT_EXPIRE_), "NOT_EMERGENCY");
_settle();
_UNUSED_QUOTE_ = _QUOTE_TOKEN_.balanceOf(address(this));
}
| function emergencySettle() external isNotForceStop phaseSettlement preventReentrant {
require(block.timestamp >= _PHASE_CALM_ENDTIME_.add(_SETTLEMENT_EXPIRE_), "NOT_EMERGENCY");
_settle();
_UNUSED_QUOTE_ = _QUOTE_TOKEN_.balanceOf(address(this));
}
| 13,314 |
8 | // Deposits `_amount` `token`, issuing shares to `recipient`. If the/Vault is in Emergency Shutdown, deposits will not be accepted and this/call will fail./Measuring quantity of shares to issues is based on the total/outstanding debt that this contract has ("expected value") instead/of the total balance sheet it has ("estimated value") has important/security considerations, and is done intentionally. If this value were/measured against external systems, it could be purposely manipulated by/an attacker to withdraw more assets than they otherwise should be able/to claim by redeeming their shares./On deposit, this means that shares are issued against the total amount/that the deposited capital can be | function deposit(uint256 _amount, address _recipient) external whenNotPaused nonReentrant returns (uint256) {
_onlyNotEmergencyShutdown();
return _deposit(_amount, _recipient);
}
| function deposit(uint256 _amount, address _recipient) external whenNotPaused nonReentrant returns (uint256) {
_onlyNotEmergencyShutdown();
return _deposit(_amount, _recipient);
}
| 33,752 |
8 | // Creates a new user entity and a connection in one transaction _connectionTo - the address of the entity to connect to _connectionType - hash of the connection type _direction - indicates the direction of the connection type / | function createUserAndConnection(
address _connectionTo,
bytes32 _connectionType,
Direction _direction
)
external returns (address entityAddress)
| function createUserAndConnection(
address _connectionTo,
bytes32 _connectionType,
Direction _direction
)
external returns (address entityAddress)
| 22,320 |
3 | // bsc mainnet olc: 0x00cCe21ccC9197A63519f33002A6B3A71B9A9817 | address public constant olc = address(0x00cCe21ccC9197A63519f33002A6B3A71B9A9817);
| address public constant olc = address(0x00cCe21ccC9197A63519f33002A6B3A71B9A9817);
| 10,925 |
2 | // StdToken inheritance is commented, because no &39;totalSupply&39; needed | contract IMNTP { /*is StdToken */
function balanceOf(address _owner) public constant returns (uint256);
// Additional methods that MNTP contract provides
function lockTransfer(bool _lock) public;
function issueTokens(address _who, uint _tokens) public;
function burnTokens(address _who, uint _tokens) public;
}
| contract IMNTP { /*is StdToken */
function balanceOf(address _owner) public constant returns (uint256);
// Additional methods that MNTP contract provides
function lockTransfer(bool _lock) public;
function issueTokens(address _who, uint _tokens) public;
function burnTokens(address _who, uint _tokens) public;
}
| 38,366 |
8 | // uselessmarketId=>isDistribution | mapping(uint => bool) public marketExtraDistribution;
| mapping(uint => bool) public marketExtraDistribution;
| 20,740 |
14 | // Check if game is over / | function isGameOver()
public
view
returns (bool)
| function isGameOver()
public
view
returns (bool)
| 34,897 |
2 | // Library for reading and writing primitive types to specific storage slots. Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.This library helps with reading and writing to such slots without the need for inline assembly. The functions in this library return Slot structs that contain a `value` member that can be used to read or write. Example usage to set ERC1967 implementation slot:``` | * contract ERC1967 {
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
| * contract ERC1967 {
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
| 4,488 |
72 | // are submissions paused? | bool public submissionPauseStatus;
mapping(address => bool) public canChangeAllowance;
| bool public submissionPauseStatus;
mapping(address => bool) public canChangeAllowance;
| 17,525 |
27 | // Mint tokens if the wallet has been whitelisted | function presaleMint(uint256 amount, bytes32[] calldata proof)
external
payable
paymentProvided(amount)
| function presaleMint(uint256 amount, bytes32[] calldata proof)
external
payable
paymentProvided(amount)
| 17,328 |
47 | // Check the specified wallet whether it is in the whitelist._wallet The address of wallet to check./ | function isWhitelisted(address _wallet) constant public returns (bool) {
return whitelist[_wallet];
}
| function isWhitelisted(address _wallet) constant public returns (bool) {
return whitelist[_wallet];
}
| 8,791 |
59 | // These variables were used in an older version of the contract, left here as gaps to ensure upgrade compatibility | uint256 private ______gap_was_extensionDuration;
uint256 private ______gap_was_goLiveDate;
| uint256 private ______gap_was_extensionDuration;
uint256 private ______gap_was_goLiveDate;
| 78,161 |
115 | // Blacklist or Unblacklist bots or sniper | function blacklistSniper(address botAddress, bool isban) external onlyOwner {
isBot[botAddress] = isban;
}
| function blacklistSniper(address botAddress, bool isban) external onlyOwner {
isBot[botAddress] = isban;
}
| 18,206 |
15 | // current top dog | address private topDog = 0x0;
| address private topDog = 0x0;
| 5,041 |
115 | // Cancelled by proposer or owner. | return ProposalState.Canceled;
| return ProposalState.Canceled;
| 36,161 |
152 | // if call is in profit, | if (profits > 0) {
| if (profits > 0) {
| 31,055 |
81 | // Internal Methods // this is the actual transfer function and it can only be called internally/send _value amount of tokens to _to address from _from address/_to The address of the recipient/_value The amount of token to be transferred/ return a boolean - whether the transfer was successful or not | function doTransfer(address _from, address _to, uint256 _value)
validate_address(_to)
is_not_locked(_from)
internal
| function doTransfer(address _from, address _to, uint256 _value)
validate_address(_to)
is_not_locked(_from)
internal
| 22,723 |
61 | // Initializer – Constructor for Upgradable contracts | function initialize() public initializer {
Ownable.initialize(); // Initialize Parent Contract
}
| function initialize() public initializer {
Ownable.initialize(); // Initialize Parent Contract
}
| 30,339 |
2 | // Address where we're sending old tokens to burn them | address internal burnAddress;
| address internal burnAddress;
| 29,855 |
1 | // Initialization helper for Pair deposit tokens Checks that selected Pairs are valid for trading reward tokens Assigns values to IPair(swapPairToken0) and IPair(swapPairToken1) / | function assignSwapPairSafely(
address _swapPairToken0,
address _swapPairToken1,
address _rewardToken
| function assignSwapPairSafely(
address _swapPairToken0,
address _swapPairToken1,
address _rewardToken
| 23,247 |
10 | // Fallback function to receive Ether.This function is payable and allows the contract to receive ETH. / | receive() external payable {}
/**
* @dev Get the current supply of Shilling tokens held by the contract.
* @return The balance of Shilling tokens held by the contract.
*/
function shillingSupply() external view returns (uint256) {
return uint256(tokenContract.balanceOf(address(this)));
}
| receive() external payable {}
/**
* @dev Get the current supply of Shilling tokens held by the contract.
* @return The balance of Shilling tokens held by the contract.
*/
function shillingSupply() external view returns (uint256) {
return uint256(tokenContract.balanceOf(address(this)));
}
| 32,910 |
20 | // The balance of any account can be calculated from the Transfer events history. However, since we need to keep the balances to validate transfer request, there is no extra cost to also privide a querry function. | return balances[_id][_owner];
| return balances[_id][_owner];
| 20,207 |
1 | // Request to fire one or more NFTs out to a single recipient / | struct Volley {
Mode mode;
address sender;
address recipient;
address tokenContract;
uint256[] tokenIds;
}
| struct Volley {
Mode mode;
address sender;
address recipient;
address tokenContract;
uint256[] tokenIds;
}
| 24,488 |
36 | // Calls to `kill` only have an effect if they are made by the owner. Remove the contract from the blockchain/ | function kill() public onlyOwner {
selfdestruct(owner);
}
| function kill() public onlyOwner {
selfdestruct(owner);
}
| 4,081 |
6 | // Events / |
event SimulationScheduled(uint256 indexed index, address _address);
event SimulationCompleted( uint256 indexed index, string winnerTeam, string logsUrl );
event SimulationCancelled(uint256 indexed index);
|
event SimulationScheduled(uint256 indexed index, address _address);
event SimulationCompleted( uint256 indexed index, string winnerTeam, string logsUrl );
event SimulationCancelled(uint256 indexed index);
| 28,635 |
8 | // Modifier for onlyOwner | modifier onlyOwner() {
require(msg.sender == _owner, "Only the owner can call this function.");
_;
}
| modifier onlyOwner() {
require(msg.sender == _owner, "Only the owner can call this function.");
_;
}
| 8,036 |
12 | // This function lets Bob contend an execution.He has to make a deposit which matches the indicated cost of the verifier,which is checked later. To incentive both parties to do so,the cost of the execution of this function are split between both users.idThe id of the processed contract witnessEvidence brought forward by Bob / | function contest(uint32 id, bytes32 witness) payable public {
uint256 gas_beginning = gasleft();
Agreement storage a = agreements[id];
Contention storage cont = contentions[id];
require(msg.sender == a.bob);
require(a.state == ContractState.ACCEPTED || a.state == ContractState.REVEALED);
cont.revealed_data = (a.state == ContractState.REVEALED);
cont.witness = witness;
cont.verification_fee_made = msg.value/a.gascost;
a.bob_funds += msg.value;
a.current_height = block.number;
a.state = ContractState.CONTENDED;
uint256 fees = (gas_beginning - gasleft() + 28000) * tx.gasprice/2;
if(fees > a.alice_funds){
fees = a.alice_funds;
}
a.alice_funds -= fees;
a.bob_funds += fees;
}
| function contest(uint32 id, bytes32 witness) payable public {
uint256 gas_beginning = gasleft();
Agreement storage a = agreements[id];
Contention storage cont = contentions[id];
require(msg.sender == a.bob);
require(a.state == ContractState.ACCEPTED || a.state == ContractState.REVEALED);
cont.revealed_data = (a.state == ContractState.REVEALED);
cont.witness = witness;
cont.verification_fee_made = msg.value/a.gascost;
a.bob_funds += msg.value;
a.current_height = block.number;
a.state = ContractState.CONTENDED;
uint256 fees = (gas_beginning - gasleft() + 28000) * tx.gasprice/2;
if(fees > a.alice_funds){
fees = a.alice_funds;
}
a.alice_funds -= fees;
a.bob_funds += fees;
}
| 44,995 |
209 | // the optional functions; to access them see {ERC20Detailed}. / | interface IERC20 {
| interface IERC20 {
| 3,400 |
154 | // reduce minimum by valueotherwise remove itaddr destination address timestampEnd "until time" value amount / | function _reduceMinimum(
address addr,
uint256 timestampEnd,
uint256 value
)
internal
| function _reduceMinimum(
address addr,
uint256 timestampEnd,
uint256 value
)
internal
| 3,040 |
113 | // Emit an event with message details | emit MessageSent(
messageId,
destinationChainSelector,
msg.sender,
receiver,
data,
address(linkToken),
fees
);
| emit MessageSent(
messageId,
destinationChainSelector,
msg.sender,
receiver,
data,
address(linkToken),
fees
);
| 16,652 |
31 | // Separate into integer and fractional parts x = x1 + x2, y = y1 + y2 | int256 x1 = integer(x) / fixed1();
int256 x2 = fractional(x);
int256 y1 = integer(y) / fixed1();
int256 y2 = fractional(y);
| int256 x1 = integer(x) / fixed1();
int256 x2 = fractional(x);
int256 y1 = integer(y) / fixed1();
int256 y2 = fractional(y);
| 5,358 |
53 | // add one-sided ETH liquidity to a pool. no vcash | function addLiquidityETH (address to) external payable returns(uint256 liquidity) {
MonoXLibrary.safeTransferETH(address(monoXPool), msg.value);
monoXPool.depositWETH(msg.value);
liquidity = _addLiquidityPair(WETH, 0, msg.value, address(this), to);
}
| function addLiquidityETH (address to) external payable returns(uint256 liquidity) {
MonoXLibrary.safeTransferETH(address(monoXPool), msg.value);
monoXPool.depositWETH(msg.value);
liquidity = _addLiquidityPair(WETH, 0, msg.value, address(this), to);
}
| 55,837 |
13 | // Setter for StrategistGuild a Multi that can do pretty much as much as governance | function setStrategistGuild(address newStrategistGuild) public {
require(msg.sender == governance, "!gov");
strategistGuild = newStrategistGuild;
}
| function setStrategistGuild(address newStrategistGuild) public {
require(msg.sender == governance, "!gov");
strategistGuild = newStrategistGuild;
}
| 41,553 |
74 | // Subtract `elastic` from `total` and update storage./ return newElastic Returns updated `elastic`. | function subElastic(Rebase storage total, uint256 elastic)
internal
returns (uint256 newElastic)
| function subElastic(Rebase storage total, uint256 elastic)
internal
returns (uint256 newElastic)
| 22,516 |
211 | // newRoyaltyForContract can`t be more then 5% | require(newRoyaltyForContract==0 || newRoyaltyForContract<=5);
royaltyForContract = newRoyaltyForContract;
| require(newRoyaltyForContract==0 || newRoyaltyForContract<=5);
royaltyForContract = newRoyaltyForContract;
| 3,244 |
19 | // Allow us to take kind donations from the non-cheap bastards / | function withdraw() external onlyOwner {
payable(owner()).transfer(address(this).balance);
}
| function withdraw() external onlyOwner {
payable(owner()).transfer(address(this).balance);
}
| 3,606 |
192 | // higher 128 bits of blockhash | return ~uint256(2**128 - 1) & uint256(blockhash(block.number - 1));
| return ~uint256(2**128 - 1) & uint256(blockhash(block.number - 1));
| 51,440 |
119 | // Changes which token will be the reward token. This can only happen if there is no balance in reserve held for rewards. If achange is desired despite there being excess rewards, call `withdrawReward()` on behalf of each holder to drain the reserve. / | function setRewardToken(address newToken) external {
// Reentrancy guard.
require(_status == RE_NOT_ENTERED || _status == RE_FROZEN);
require(msg.sender == _owner, "Not owner");
require(newToken != address(0), "Can't be zero address");
require(newToken != address(this), "Can't be this address");
require(_reservedRewardBalance == 0, "Have reserved balance");
_rewardToken = newToken;
}
| function setRewardToken(address newToken) external {
// Reentrancy guard.
require(_status == RE_NOT_ENTERED || _status == RE_FROZEN);
require(msg.sender == _owner, "Not owner");
require(newToken != address(0), "Can't be zero address");
require(newToken != address(this), "Can't be this address");
require(_reservedRewardBalance == 0, "Have reserved balance");
_rewardToken = newToken;
}
| 9,187 |
85 | // buying |
(uint256 wlRoundNumber, , , , , ) = getLGEWhitelistRound();
if (wlRoundNumber > 0) {
WhitelistRound storage wlRound = _lgeWhitelistRounds[wlRoundNumber - 1];
require(wlRound.addresses[recipient], "LGE - Buyer is not whitelisted");
uint256 amountRemaining = 0;
|
(uint256 wlRoundNumber, , , , , ) = getLGEWhitelistRound();
if (wlRoundNumber > 0) {
WhitelistRound storage wlRound = _lgeWhitelistRounds[wlRoundNumber - 1];
require(wlRound.addresses[recipient], "LGE - Buyer is not whitelisted");
uint256 amountRemaining = 0;
| 27,566 |
120 | // 1.1 - Scale the vote by dial weight e.g. 5e171e18 / 1e18100e18 / 1e18 = 50e18 | uint256 amountToChange = (weight * _amount) / SCALE;
| uint256 amountToChange = (weight * _amount) / SCALE;
| 64,197 |
129 | // Calculate arithmetics average of x and y, i.e. (x + y) / 2 rounding down.x signed 64.64-bit fixed point number y signed 64.64-bit fixed point numberreturn signed 64.64-bit fixed point number / | function avg (int128 x, int128 y) internal pure returns (int128) {
return int128 ((int256 (x) + int256 (y)) >> 1);
}
| function avg (int128 x, int128 y) internal pure returns (int128) {
return int128 ((int256 (x) + int256 (y)) >> 1);
}
| 31,889 |
86 | // Perform final checks and return. | availableOrders = _performFinalChecksAndExecuteOrders(
advancedOrders,
executions
);
return (availableOrders, executions);
| availableOrders = _performFinalChecksAndExecuteOrders(
advancedOrders,
executions
);
return (availableOrders, executions);
| 22,847 |
152 | // read the current configuration of the registry / | function getConfig()
external
view
override
returns (
uint32 paymentPremiumPPB,
uint24 blockCountPerTurn,
uint32 checkGasLimit,
uint24 stalenessSeconds,
uint16 gasCeilingMultiplier,
| function getConfig()
external
view
override
returns (
uint32 paymentPremiumPPB,
uint24 blockCountPerTurn,
uint32 checkGasLimit,
uint24 stalenessSeconds,
uint16 gasCeilingMultiplier,
| 28,963 |
5 | // Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call:- if using `revokeRole`, it is the insta master- if using `renounceRole`, it is the role bearer (i.e. `account`) / | event RoleRevoked(
address indexed role,
address indexed account,
address indexed sender
);
| event RoleRevoked(
address indexed role,
address indexed account,
address indexed sender
);
| 8,147 |
4 | // unregister players and choices | player1Choice = "";
player2Choice = "";
player1 = 0;
player2 = 0;
return winner;
| player1Choice = "";
player2Choice = "";
player1 = 0;
player2 = 0;
return winner;
| 16,078 |
35 | // Check if leverage is above minimum leverage | uint256 leverage = (UNIT * position.size) / position.margin;
require(leverage >= UNIT, '!min-leverage');
| uint256 leverage = (UNIT * position.size) / position.margin;
require(leverage >= UNIT, '!min-leverage');
| 7,138 |
38 | // Get a number from a random `seed` at `index`/_hash Randomly generated hash /index Used as salt/ return uint32 Random number | function _randomAt(bytes32 _hash, uint index)
private pure
returns(uint32)
| function _randomAt(bytes32 _hash, uint index)
private pure
returns(uint32)
| 25,946 |
14 | // native core functions |
function transfer(address[2] memory addressArr, uint[2] memory uintArr) external virtual returns(bool success);
function approve(address[2] memory addressArr, uint[2] memory uintArr) external virtual returns(bool success);
function increaseAllowance(address[2] memory addressArr, uint[2] memory uintArr) external virtual returns(bool success);
function decreaseAllowance(address[2] memory addressArr, uint[2] memory uintArr) external virtual returns(bool success);
function transferFrom(address[3] memory addressArr, uint[3] memory uintArr) external virtual returns(bool success);
|
function transfer(address[2] memory addressArr, uint[2] memory uintArr) external virtual returns(bool success);
function approve(address[2] memory addressArr, uint[2] memory uintArr) external virtual returns(bool success);
function increaseAllowance(address[2] memory addressArr, uint[2] memory uintArr) external virtual returns(bool success);
function decreaseAllowance(address[2] memory addressArr, uint[2] memory uintArr) external virtual returns(bool success);
function transferFrom(address[3] memory addressArr, uint[3] memory uintArr) external virtual returns(bool success);
| 12,361 |
364 | // take the reciprocal of a UQ112x112 | function reciprocal(uq112x112 memory self) internal pure returns (uq112x112 memory) {
require(self._x != 0, 'FixedPoint: ZERO_RECIPROCAL');
return uq112x112(uint224(Q224 / self._x));
}
| function reciprocal(uq112x112 memory self) internal pure returns (uq112x112 memory) {
require(self._x != 0, 'FixedPoint: ZERO_RECIPROCAL');
return uq112x112(uint224(Q224 / self._x));
}
| 4,177 |
25 | // A contract for staking tokens | contract AgoraSpace is RankManager {
// Tokens managed by the contract
address public immutable token;
address public immutable stakeToken;
// For timelock
mapping(address => LockedItem[]) internal timelocks;
struct LockedItem {
uint256 expires;
uint256 amount;
uint256 rankId;
}
// For storing balances
struct Balance {
uint256 locked;
uint256 unlocked;
}
mapping(uint256 => mapping(address => Balance)) public rankBalances;
event Deposit(address indexed wallet, uint256 amount);
event Withdraw(address indexed wallet, uint256 amount);
event EmergencyWithdraw(address indexed wallet, uint256 amount);
error InsufficientBalance(uint256 rankId, uint256 available, uint256 required);
error TooManyDeposits();
error NonPositiveAmount();
/// @param _tokenAddress The address of the token to be staked, that the contract accepts
/// @param _stakeTokenAddress The address of the token that's given in return
constructor(address _tokenAddress, address _stakeTokenAddress) {
token = _tokenAddress;
stakeToken = _stakeTokenAddress;
}
/// @notice Accepts tokens, locks them and gives different tokens in return
/// @dev The depositor should approve the contract to manage stakingTokens
/// @dev For minting stakeTokens, this contract should be the owner of them
/// @param _amount The amount to be deposited in the smallest unit of the token
/// @param _rankId The id of the rank to be deposited to
/// @param _consolidate Calls the consolidate function if true
function deposit(
uint256 _amount,
uint256 _rankId,
bool _consolidate
) external notFrozen {
if (_amount < 1) revert NonPositiveAmount();
if (timelocks[msg.sender].length >= 64) revert TooManyDeposits();
if (numOfRanks < 1) revert NoRanks();
if (_rankId >= numOfRanks) revert InvalidRank();
if (
rankBalances[_rankId][msg.sender].unlocked + rankBalances[_rankId][msg.sender].locked + _amount >=
ranks[_rankId].goalAmount
) {
unlockBelow(_rankId, msg.sender);
} else if (_consolidate && _rankId > 0) {
consolidate(_amount, _rankId, msg.sender);
}
LockedItem memory timelockData;
timelockData.expires = block.timestamp + ranks[_rankId].minDuration * 1 minutes;
timelockData.amount = _amount;
timelockData.rankId = _rankId;
timelocks[msg.sender].push(timelockData);
rankBalances[_rankId][msg.sender].locked += _amount;
IAgoraToken(stakeToken).mint(msg.sender, _amount);
IERC20(token).transferFrom(msg.sender, address(this), _amount);
emit Deposit(msg.sender, _amount);
}
/// @notice If the timelock is expired, gives back the staked tokens in return for the tokens obtained while depositing
/// @dev This contract should have sufficient allowance to be able to burn stakeTokens from the user
/// @dev For burning stakeTokens, this contract should be the owner of them
/// @param _amount The amount to be withdrawn in the smallest unit of the token
/// @param _rankId The id of the rank to be withdrawn from
function withdraw(uint256 _amount, uint256 _rankId) external notFrozen {
if (_amount < 1) revert NonPositiveAmount();
uint256 expired = viewExpired(msg.sender, _rankId);
if (rankBalances[_rankId][msg.sender].unlocked + expired < _amount)
revert InsufficientBalance({
rankId: _rankId,
available: rankBalances[_rankId][msg.sender].unlocked + expired,
required: _amount
});
unlockExpired(msg.sender);
rankBalances[_rankId][msg.sender].unlocked -= _amount;
IAgoraToken(stakeToken).burn(msg.sender, _amount);
IERC20(token).transfer(msg.sender, _amount);
emit Withdraw(msg.sender, _amount);
}
/// @notice Checks the locked tokens for an account and unlocks them if they're expired
/// @param _investor The address whose tokens should be checked
function unlockExpired(address _investor) public {
uint256[] memory expired = new uint256[](numOfRanks);
LockedItem[] storage usersLocked = timelocks[_investor];
int256 usersLockedLength = int256(usersLocked.length);
for (int256 i = 0; i < usersLockedLength; i++) {
if (usersLocked[uint256(i)].expires <= block.timestamp) {
// Collect expired amounts per ranks
expired[usersLocked[uint256(i)].rankId] += usersLocked[uint256(i)].amount;
// Remove expired locks
usersLocked[uint256(i)] = usersLocked[uint256(usersLockedLength) - 1];
usersLocked.pop();
usersLockedLength--;
i--;
}
}
// Move expired amounts from locked to unlocked
for (uint256 i = 0; i < numOfRanks; i++) {
if (expired[i] > 0) {
rankBalances[i][_investor].locked -= expired[i];
rankBalances[i][_investor].unlocked += expired[i];
}
}
}
/// @notice Unlocks every deposit below a certain rank
/// @dev Should be called, when the minimum of a rank is reached
/// @param _investor The address whose tokens should be checked
/// @param _rankId The id of the rank to be checked
function unlockBelow(uint256 _rankId, address _investor) internal {
LockedItem[] storage usersLocked = timelocks[_investor];
int256 usersLockedLength = int256(usersLocked.length);
uint256[] memory unlocked = new uint256[](numOfRanks);
for (int256 i = 0; i < usersLockedLength; i++) {
if (usersLocked[uint256(i)].rankId < _rankId) {
// Collect the amount to be unlocked per rank
unlocked[usersLocked[uint256(i)].rankId] += usersLocked[uint256(i)].amount;
// Remove expired locks
usersLocked[uint256(i)] = usersLocked[uint256(usersLockedLength) - 1];
usersLocked.pop();
usersLockedLength--;
i--;
}
}
// Move unlocked amounts from locked to unlocked
for (uint256 i = 0; i < numOfRanks; i++) {
if (unlocked[i] > 0) {
rankBalances[i][_investor].locked -= unlocked[i];
rankBalances[i][_investor].unlocked += unlocked[i];
}
}
}
/// @notice Collects the investments up to a certain rank if it's needed to reach the minimum
/// @dev There must be more than 1 rank
/// @dev The minimum should not be reached with the new deposit
/// @dev The deposited amount must be locked after the function call
/// @param _amount The amount to be deposited
/// @param _rankId The id of the rank to be deposited to
/// @param _investor The address which made the deposit
function consolidate(
uint256 _amount,
uint256 _rankId,
address _investor
) internal {
uint256 consolidateAmount = ranks[_rankId].goalAmount -
rankBalances[_rankId][_investor].unlocked -
rankBalances[_rankId][_investor].locked -
_amount;
uint256 totalBalanceBelow;
uint256 lockedBalance;
uint256 unlockedBalance;
LockedItem[] storage usersLocked = timelocks[_investor];
int256 usersLockedLength = int256(usersLocked.length);
for (uint256 i = 0; i < _rankId; i++) {
lockedBalance = rankBalances[i][_investor].locked;
unlockedBalance = rankBalances[i][_investor].unlocked;
if (lockedBalance > 0) {
totalBalanceBelow += lockedBalance;
rankBalances[i][_investor].locked = 0;
}
if (unlockedBalance > 0) {
totalBalanceBelow += unlockedBalance;
rankBalances[i][_investor].unlocked = 0;
}
}
if (totalBalanceBelow > 0) {
LockedItem memory timelockData;
// Iterate over the locked list and unlock everything below the rank
for (int256 i = 0; i < usersLockedLength; i++) {
if (usersLocked[uint256(i)].rankId < _rankId) {
usersLocked[uint256(i)] = usersLocked[uint256(usersLockedLength) - 1];
usersLocked.pop();
usersLockedLength--;
i--;
}
}
// Create a new locked item and lock it for the rank's duration
timelockData.expires = block.timestamp + ranks[_rankId].minDuration * 1 minutes;
timelockData.rankId = _rankId;
if (totalBalanceBelow > consolidateAmount) {
// Set consolidateAmount as the locked amount
timelockData.amount = consolidateAmount;
rankBalances[_rankId][_investor].locked += consolidateAmount;
rankBalances[_rankId][_investor].unlocked += totalBalanceBelow - consolidateAmount;
} else {
// Set totalBalanceBelow as the locked amount
timelockData.amount = totalBalanceBelow;
rankBalances[_rankId][_investor].locked += totalBalanceBelow;
}
timelocks[_investor].push(timelockData);
}
}
/// @notice Gives back all the staked tokens in exchange for the tokens obtained, regardless of timelock
/// @dev Can only be called when the contract is frozen
function emergencyWithdraw() external {
if (!frozen) revert SpaceIsNotFrozen();
uint256 totalBalance;
uint256 lockedBalance;
uint256 unlockedBalance;
for (uint256 i = 0; i < numOfRanks; i++) {
lockedBalance = rankBalances[i][msg.sender].locked;
unlockedBalance = rankBalances[i][msg.sender].unlocked;
if (lockedBalance > 0) {
totalBalance += lockedBalance;
rankBalances[i][msg.sender].locked = 0;
}
if (unlockedBalance > 0) {
totalBalance += unlockedBalance;
rankBalances[i][msg.sender].unlocked = 0;
}
}
if (totalBalance < 1) revert NonPositiveAmount();
delete timelocks[msg.sender];
IAgoraToken(stakeToken).burn(msg.sender, totalBalance);
IERC20(token).transfer(msg.sender, totalBalance);
emit EmergencyWithdraw(msg.sender, totalBalance);
}
/// @notice Returns all the timelocks a user has in an array
/// @param _wallet The address of the user
/// @return An array containing structs with fields "expires", "amount" and "rankId"
function getTimelocks(address _wallet) external view returns (LockedItem[] memory) {
return timelocks[_wallet];
}
/// @notice Sums the locked tokens for an account by ranks if they were expired
/// @param _investor The address whose tokens should be checked
/// @param _rankId The id of the rank to be checked
/// @return The total amount of expired, but not unlocked tokens in the rank
function viewExpired(address _investor, uint256 _rankId) public view returns (uint256) {
uint256 expiredAmount;
LockedItem[] memory usersLocked = timelocks[_investor];
uint256 usersLockedLength = usersLocked.length;
for (uint256 i = 0; i < usersLockedLength; i++) {
if (usersLocked[i].rankId == _rankId && usersLocked[i].expires <= block.timestamp) {
expiredAmount += usersLocked[i].amount;
}
}
return expiredAmount;
}
}
| contract AgoraSpace is RankManager {
// Tokens managed by the contract
address public immutable token;
address public immutable stakeToken;
// For timelock
mapping(address => LockedItem[]) internal timelocks;
struct LockedItem {
uint256 expires;
uint256 amount;
uint256 rankId;
}
// For storing balances
struct Balance {
uint256 locked;
uint256 unlocked;
}
mapping(uint256 => mapping(address => Balance)) public rankBalances;
event Deposit(address indexed wallet, uint256 amount);
event Withdraw(address indexed wallet, uint256 amount);
event EmergencyWithdraw(address indexed wallet, uint256 amount);
error InsufficientBalance(uint256 rankId, uint256 available, uint256 required);
error TooManyDeposits();
error NonPositiveAmount();
/// @param _tokenAddress The address of the token to be staked, that the contract accepts
/// @param _stakeTokenAddress The address of the token that's given in return
constructor(address _tokenAddress, address _stakeTokenAddress) {
token = _tokenAddress;
stakeToken = _stakeTokenAddress;
}
/// @notice Accepts tokens, locks them and gives different tokens in return
/// @dev The depositor should approve the contract to manage stakingTokens
/// @dev For minting stakeTokens, this contract should be the owner of them
/// @param _amount The amount to be deposited in the smallest unit of the token
/// @param _rankId The id of the rank to be deposited to
/// @param _consolidate Calls the consolidate function if true
function deposit(
uint256 _amount,
uint256 _rankId,
bool _consolidate
) external notFrozen {
if (_amount < 1) revert NonPositiveAmount();
if (timelocks[msg.sender].length >= 64) revert TooManyDeposits();
if (numOfRanks < 1) revert NoRanks();
if (_rankId >= numOfRanks) revert InvalidRank();
if (
rankBalances[_rankId][msg.sender].unlocked + rankBalances[_rankId][msg.sender].locked + _amount >=
ranks[_rankId].goalAmount
) {
unlockBelow(_rankId, msg.sender);
} else if (_consolidate && _rankId > 0) {
consolidate(_amount, _rankId, msg.sender);
}
LockedItem memory timelockData;
timelockData.expires = block.timestamp + ranks[_rankId].minDuration * 1 minutes;
timelockData.amount = _amount;
timelockData.rankId = _rankId;
timelocks[msg.sender].push(timelockData);
rankBalances[_rankId][msg.sender].locked += _amount;
IAgoraToken(stakeToken).mint(msg.sender, _amount);
IERC20(token).transferFrom(msg.sender, address(this), _amount);
emit Deposit(msg.sender, _amount);
}
/// @notice If the timelock is expired, gives back the staked tokens in return for the tokens obtained while depositing
/// @dev This contract should have sufficient allowance to be able to burn stakeTokens from the user
/// @dev For burning stakeTokens, this contract should be the owner of them
/// @param _amount The amount to be withdrawn in the smallest unit of the token
/// @param _rankId The id of the rank to be withdrawn from
function withdraw(uint256 _amount, uint256 _rankId) external notFrozen {
if (_amount < 1) revert NonPositiveAmount();
uint256 expired = viewExpired(msg.sender, _rankId);
if (rankBalances[_rankId][msg.sender].unlocked + expired < _amount)
revert InsufficientBalance({
rankId: _rankId,
available: rankBalances[_rankId][msg.sender].unlocked + expired,
required: _amount
});
unlockExpired(msg.sender);
rankBalances[_rankId][msg.sender].unlocked -= _amount;
IAgoraToken(stakeToken).burn(msg.sender, _amount);
IERC20(token).transfer(msg.sender, _amount);
emit Withdraw(msg.sender, _amount);
}
/// @notice Checks the locked tokens for an account and unlocks them if they're expired
/// @param _investor The address whose tokens should be checked
function unlockExpired(address _investor) public {
uint256[] memory expired = new uint256[](numOfRanks);
LockedItem[] storage usersLocked = timelocks[_investor];
int256 usersLockedLength = int256(usersLocked.length);
for (int256 i = 0; i < usersLockedLength; i++) {
if (usersLocked[uint256(i)].expires <= block.timestamp) {
// Collect expired amounts per ranks
expired[usersLocked[uint256(i)].rankId] += usersLocked[uint256(i)].amount;
// Remove expired locks
usersLocked[uint256(i)] = usersLocked[uint256(usersLockedLength) - 1];
usersLocked.pop();
usersLockedLength--;
i--;
}
}
// Move expired amounts from locked to unlocked
for (uint256 i = 0; i < numOfRanks; i++) {
if (expired[i] > 0) {
rankBalances[i][_investor].locked -= expired[i];
rankBalances[i][_investor].unlocked += expired[i];
}
}
}
/// @notice Unlocks every deposit below a certain rank
/// @dev Should be called, when the minimum of a rank is reached
/// @param _investor The address whose tokens should be checked
/// @param _rankId The id of the rank to be checked
function unlockBelow(uint256 _rankId, address _investor) internal {
LockedItem[] storage usersLocked = timelocks[_investor];
int256 usersLockedLength = int256(usersLocked.length);
uint256[] memory unlocked = new uint256[](numOfRanks);
for (int256 i = 0; i < usersLockedLength; i++) {
if (usersLocked[uint256(i)].rankId < _rankId) {
// Collect the amount to be unlocked per rank
unlocked[usersLocked[uint256(i)].rankId] += usersLocked[uint256(i)].amount;
// Remove expired locks
usersLocked[uint256(i)] = usersLocked[uint256(usersLockedLength) - 1];
usersLocked.pop();
usersLockedLength--;
i--;
}
}
// Move unlocked amounts from locked to unlocked
for (uint256 i = 0; i < numOfRanks; i++) {
if (unlocked[i] > 0) {
rankBalances[i][_investor].locked -= unlocked[i];
rankBalances[i][_investor].unlocked += unlocked[i];
}
}
}
/// @notice Collects the investments up to a certain rank if it's needed to reach the minimum
/// @dev There must be more than 1 rank
/// @dev The minimum should not be reached with the new deposit
/// @dev The deposited amount must be locked after the function call
/// @param _amount The amount to be deposited
/// @param _rankId The id of the rank to be deposited to
/// @param _investor The address which made the deposit
function consolidate(
uint256 _amount,
uint256 _rankId,
address _investor
) internal {
uint256 consolidateAmount = ranks[_rankId].goalAmount -
rankBalances[_rankId][_investor].unlocked -
rankBalances[_rankId][_investor].locked -
_amount;
uint256 totalBalanceBelow;
uint256 lockedBalance;
uint256 unlockedBalance;
LockedItem[] storage usersLocked = timelocks[_investor];
int256 usersLockedLength = int256(usersLocked.length);
for (uint256 i = 0; i < _rankId; i++) {
lockedBalance = rankBalances[i][_investor].locked;
unlockedBalance = rankBalances[i][_investor].unlocked;
if (lockedBalance > 0) {
totalBalanceBelow += lockedBalance;
rankBalances[i][_investor].locked = 0;
}
if (unlockedBalance > 0) {
totalBalanceBelow += unlockedBalance;
rankBalances[i][_investor].unlocked = 0;
}
}
if (totalBalanceBelow > 0) {
LockedItem memory timelockData;
// Iterate over the locked list and unlock everything below the rank
for (int256 i = 0; i < usersLockedLength; i++) {
if (usersLocked[uint256(i)].rankId < _rankId) {
usersLocked[uint256(i)] = usersLocked[uint256(usersLockedLength) - 1];
usersLocked.pop();
usersLockedLength--;
i--;
}
}
// Create a new locked item and lock it for the rank's duration
timelockData.expires = block.timestamp + ranks[_rankId].minDuration * 1 minutes;
timelockData.rankId = _rankId;
if (totalBalanceBelow > consolidateAmount) {
// Set consolidateAmount as the locked amount
timelockData.amount = consolidateAmount;
rankBalances[_rankId][_investor].locked += consolidateAmount;
rankBalances[_rankId][_investor].unlocked += totalBalanceBelow - consolidateAmount;
} else {
// Set totalBalanceBelow as the locked amount
timelockData.amount = totalBalanceBelow;
rankBalances[_rankId][_investor].locked += totalBalanceBelow;
}
timelocks[_investor].push(timelockData);
}
}
/// @notice Gives back all the staked tokens in exchange for the tokens obtained, regardless of timelock
/// @dev Can only be called when the contract is frozen
function emergencyWithdraw() external {
if (!frozen) revert SpaceIsNotFrozen();
uint256 totalBalance;
uint256 lockedBalance;
uint256 unlockedBalance;
for (uint256 i = 0; i < numOfRanks; i++) {
lockedBalance = rankBalances[i][msg.sender].locked;
unlockedBalance = rankBalances[i][msg.sender].unlocked;
if (lockedBalance > 0) {
totalBalance += lockedBalance;
rankBalances[i][msg.sender].locked = 0;
}
if (unlockedBalance > 0) {
totalBalance += unlockedBalance;
rankBalances[i][msg.sender].unlocked = 0;
}
}
if (totalBalance < 1) revert NonPositiveAmount();
delete timelocks[msg.sender];
IAgoraToken(stakeToken).burn(msg.sender, totalBalance);
IERC20(token).transfer(msg.sender, totalBalance);
emit EmergencyWithdraw(msg.sender, totalBalance);
}
/// @notice Returns all the timelocks a user has in an array
/// @param _wallet The address of the user
/// @return An array containing structs with fields "expires", "amount" and "rankId"
function getTimelocks(address _wallet) external view returns (LockedItem[] memory) {
return timelocks[_wallet];
}
/// @notice Sums the locked tokens for an account by ranks if they were expired
/// @param _investor The address whose tokens should be checked
/// @param _rankId The id of the rank to be checked
/// @return The total amount of expired, but not unlocked tokens in the rank
function viewExpired(address _investor, uint256 _rankId) public view returns (uint256) {
uint256 expiredAmount;
LockedItem[] memory usersLocked = timelocks[_investor];
uint256 usersLockedLength = usersLocked.length;
for (uint256 i = 0; i < usersLockedLength; i++) {
if (usersLocked[i].rankId == _rankId && usersLocked[i].expires <= block.timestamp) {
expiredAmount += usersLocked[i].amount;
}
}
return expiredAmount;
}
}
| 19,644 |
77 | // used by hodler contract to transfer users tokens to it | function hodlerTransfer(address _from, uint256 _value) external onlyRole(ROLE_TRANSFER) returns (bool) {
require(_from != address(0));
require(_value > 0);
// hodler
address _hodler = msg.sender;
// update state
balances[_from] = balances[_from].sub(_value);
balances[_hodler] = balances[_hodler].add(_value);
// logs
Transfer(_from, _hodler, _value);
return true;
}
| function hodlerTransfer(address _from, uint256 _value) external onlyRole(ROLE_TRANSFER) returns (bool) {
require(_from != address(0));
require(_value > 0);
// hodler
address _hodler = msg.sender;
// update state
balances[_from] = balances[_from].sub(_value);
balances[_hodler] = balances[_hodler].add(_value);
// logs
Transfer(_from, _hodler, _value);
return true;
}
| 72,509 |
0 | // will be deployed can be known in advance via {computeAddress}. The bytecode for a contract can be obtained from Solidity with`type(contractName).creationCode`. Requirements: - `bytecode` must not be empty.- `salt` must have not been used for `bytecode` already.- the factory must have a balance of at least `amount`.- if `amount` is non-zero, `bytecode` must have a `payable` constructor. / | function deploy(
uint256 amount,
bytes32 salt,
bytes memory bytecode
) public returns (address) {
address addr;
require(address(this).balance >= amount, "Create2: insufficient balance");
require(bytecode.length != 0, "Create2: bytecode length is zero");
assembly {
addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)
| function deploy(
uint256 amount,
bytes32 salt,
bytes memory bytecode
) public returns (address) {
address addr;
require(address(this).balance >= amount, "Create2: insufficient balance");
require(bytecode.length != 0, "Create2: bytecode length is zero");
assembly {
addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)
| 20,840 |
45 | // The main entry-point to DolomiteMargin that allows users and contracts to manage accounts.Take one or more actions on one or more accounts. The msg.sender must be the owner oroperator of all accounts except for those being liquidated, vaporized, or traded with.One call to operate() is considered a singular "operation". Account collateralization isensured only after the completion of the entire operation. accountsA list of all accounts that will be used in this operation. Cannot containduplicates. In each action, the relevant account will be referred-to by itsindex in the list.actions An ordered list of all actions that will be taken in this | function operate(
Account.Info[] calldata accounts,
Actions.ActionArgs[] calldata actions
) external;
| function operate(
Account.Info[] calldata accounts,
Actions.ActionArgs[] calldata actions
) external;
| 45,045 |
28 | // Buys unique items. 유니크 아이템을 구매합니다. | function buyUniqueItem(uint saleId) external;
| function buyUniqueItem(uint saleId) external;
| 2,753 |
3 | // Computes how many tokens can be taken out of a pool if `tokenAmountIn` are sent, given the current balances. The amplification parameter equals: A n^(n-1) | function _calcOutGivenIn(
uint256 amplificationParameter,
uint256[] memory balances,
uint256 tokenIndexIn,
uint256 tokenIndexOut,
uint256 tokenAmountIn
| function _calcOutGivenIn(
uint256 amplificationParameter,
uint256[] memory balances,
uint256 tokenIndexIn,
uint256 tokenIndexOut,
uint256 tokenAmountIn
| 46,591 |
4 | // _anchorRegistry address The address of the anchor registrythat is backing this token's mint method.that ensures that the sender is authorized to mint the token / | function initialize(
address _anchorRegistry
)
public
initializer
| function initialize(
address _anchorRegistry
)
public
initializer
| 26,933 |
56 | // - Parses a syscoin txtxBytes - tx byte array Outputs return output_value - amount sent to the lock address in satoshis return destinationAddress - ethereum destination address | function parseBurnTx(bytes memory txBytes)
public
pure
returns (uint errorCode, uint output_value, address destinationAddress, uint32 assetGuid)
| function parseBurnTx(bytes memory txBytes)
public
pure
returns (uint errorCode, uint output_value, address destinationAddress, uint32 assetGuid)
| 43,997 |
47 | // Event for token purchase logging purchaser who paid for the tokens beneficiary who got the tokens value weis paid for purchase amount amount of tokens purchased / | event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
| event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
| 11,039 |
58 | // add y^05 / 05 - y^06 / 06 | res += (z * (0x092492492492492492492492492492492 - y)) / 0x400000000000000000000000000000000;
z = (z * w) / FIXED_1;
| res += (z * (0x092492492492492492492492492492492 - y)) / 0x400000000000000000000000000000000;
z = (z * w) / FIXED_1;
| 2,491 |
11 | // at this point we know the FD contract owns the deposit NFT because the pool is non-zero, we know the init() function has been called 3. verify the deposit is active | require(fractionalDeposit.active(), "ZeroCouponBond: deposit inactive");
| require(fractionalDeposit.active(), "ZeroCouponBond: deposit inactive");
| 33,682 |
67 | // There must be enough locked tickets to unlock. | require(
lockedBalanceBy[msg.sender][_holder][_projectId] >= _amount,
"TicketBooth::unlock: INSUFFICIENT_FUNDS"
);
| require(
lockedBalanceBy[msg.sender][_holder][_projectId] >= _amount,
"TicketBooth::unlock: INSUFFICIENT_FUNDS"
);
| 81,828 |
204 | // Set the current mintMode: 1 for Blinklist only, 2 for public/ | function setMintMode(uint256 _mode) external onlyOwner {
mintMode = _mode;
}
| function setMintMode(uint256 _mode) external onlyOwner {
mintMode = _mode;
}
| 48,729 |
20 | // Referral Fee | idToAddressIndex[investorToDepostIndex[msg.sender].referrerID].transfer(refToPay);
| idToAddressIndex[investorToDepostIndex[msg.sender].referrerID].transfer(refToPay);
| 6,500 |
10 | // return funds | payable(msg.sender).transfer(bid);
| payable(msg.sender).transfer(bid);
| 42,780 |
267 | // Balance is changed by `_updateBalanceData` to reflect correct reward amount / | function _transferToken(
address from,
address to,
uint128 amount
| function _transferToken(
address from,
address to,
uint128 amount
| 10,158 |
49 | // RatioChance 60 | rarities[2] = [90, 175];
aliases[2] = [1, 0];
| rarities[2] = [90, 175];
aliases[2] = [1, 0];
| 67,942 |
14 | // set base uri when moving metadata | function setBaseURI(string memory newBaseURI) external onlyOwner {
baseURI = newBaseURI;
}
| function setBaseURI(string memory newBaseURI) external onlyOwner {
baseURI = newBaseURI;
}
| 13,262 |
71 | // Aave flash loan functions ends // DyDx flash loan functions // This is entry point for DyDx flash loan _token Token for which we are taking flash loan _amountDesired Flash loan amount _data This will be passed downstream for processing. It can be empty. / | function _doDyDxFlashLoan(
address _token,
uint256 _amountDesired,
bytes memory _data
| function _doDyDxFlashLoan(
address _token,
uint256 _amountDesired,
bytes memory _data
| 17,216 |
83 | // check the locked balance for an address | function lockedBalanceOf(address _owner) public view returns (uint256) {
uint256 result = 0;
for (uint i = 0; i < vestingsOf[_owner].length; i++) {
result += balances[vestingsOf[_owner][i]];
}
return result;
}
| function lockedBalanceOf(address _owner) public view returns (uint256) {
uint256 result = 0;
for (uint i = 0; i < vestingsOf[_owner].length; i++) {
result += balances[vestingsOf[_owner][i]];
}
return result;
}
| 66,798 |
31 | // We'll apply the update next harvest. | nextHarvestDelay = newHarvestDelay;
emit HarvestDelayUpdateScheduled(msg.sender, newHarvestDelay);
| nextHarvestDelay = newHarvestDelay;
emit HarvestDelayUpdateScheduled(msg.sender, newHarvestDelay);
| 6,137 |
4 | // Allows the current owner to transfer control of the contract to a newOwner. _newOwner The address to transfer ownership to. / | function transferOwnership(address _newOwner) public onlyOwner {
require(_newOwner != address(0));
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
| function transferOwnership(address _newOwner) public onlyOwner {
require(_newOwner != address(0));
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
| 36,837 |
4 | // Swap | if (swapcount == 2) {
runUniswap(amount, token1, token0, exchange1);
} else if (swapcount == 3) {
| if (swapcount == 2) {
runUniswap(amount, token1, token0, exchange1);
} else if (swapcount == 3) {
| 504 |
106 | // Check if a prediction was correct for a specific loan and vote id Loan ID choice Outcome prediction / | function wasPredictionCorrect(address id, bool choice) internal view returns (bool) {
if (status(id) == LoanStatus.Settled && choice) {
return true;
}
if (status(id) == LoanStatus.Defaulted && !choice) {
return true;
}
return false;
}
| function wasPredictionCorrect(address id, bool choice) internal view returns (bool) {
if (status(id) == LoanStatus.Settled && choice) {
return true;
}
if (status(id) == LoanStatus.Defaulted && !choice) {
return true;
}
return false;
}
| 11,373 |
184 | // give the "owner_" address the manager role, too | _setupRole(MANAGER_ROLE, owner_);
| _setupRole(MANAGER_ROLE, owner_);
| 63,425 |
113 | // Set the new owner | _token_owners[id] = to;
| _token_owners[id] = to;
| 46,691 |
212 | // setup_fee <= (n/d)(g^2)/2 | uint initGoalInCurrency = _initGoal * _initGoal;
initGoalInCurrency = initGoalInCurrency.mul(_buySlopeNum);
initGoalInCurrency /= 2 * _buySlopeDen;
require(_setupFee <= initGoalInCurrency, "EXCESSIVE_SETUP_FEE");
setupFee = _setupFee;
setupFeeRecipient = _setupFeeRecipient;
| uint initGoalInCurrency = _initGoal * _initGoal;
initGoalInCurrency = initGoalInCurrency.mul(_buySlopeNum);
initGoalInCurrency /= 2 * _buySlopeDen;
require(_setupFee <= initGoalInCurrency, "EXCESSIVE_SETUP_FEE");
setupFee = _setupFee;
setupFeeRecipient = _setupFeeRecipient;
| 7,837 |
43 | // See {ERC20-transfer}. Requirements: - `recipient` cannot be the zero address.- the caller must have a balance of at least `amount`. / | function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
| function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
| 443 |
24 | // Remove last element from the selectors array | ds.facetToSelectors[_facet].selectors.pop();
| ds.facetToSelectors[_facet].selectors.pop();
| 23,745 |
120 | // The quantity to send in order that the sender spends a certain value of tokens. | function priceToSpend(uint value)
external
view
returns (uint)
| function priceToSpend(uint value)
external
view
returns (uint)
| 81,368 |
1 | // month number since epoch | uint256 public currentMonth;
event ReputationEarned(
address staker,
address[] stakingContracts,
uint256 reputation
);
| uint256 public currentMonth;
event ReputationEarned(
address staker,
address[] stakingContracts,
uint256 reputation
);
| 5,081 |
17 | // Calculate the first iteration of the loop in advance. | result = y & 1 > 0 ? x : SCALE;
| result = y & 1 > 0 ? x : SCALE;
| 59,598 |
13 | // address public owner= msg.sender; | string public name = "MelobnBIT223";
string public symbol = "MTTT";
uint8 public decimals = 8;
uint256 public totalSupply;
function ERC223Token()
| string public name = "MelobnBIT223";
string public symbol = "MTTT";
uint8 public decimals = 8;
uint256 public totalSupply;
function ERC223Token()
| 75,415 |
16 | // Retrieves the remaining ETH (the change) to the buyer. | function _refund(uint256 price) internal {
if (msg.value > price) {
payable(msg.sender).transfer(msg.value - price);
}
}
| function _refund(uint256 price) internal {
if (msg.value > price) {
payable(msg.sender).transfer(msg.value - price);
}
}
| 46,313 |
379 | // mapping to return true if Cover Note deposited against coverId / | mapping(uint => CoverNote) public depositedCN;
| mapping(uint => CoverNote) public depositedCN;
| 34,747 |
6 | // The msg.sender address is shifted to the left by 12 bytes to remove the padding Then the address without padding is stored right after the calldata | mstore(calldatasize(), shl(96, caller()))
| mstore(calldatasize(), shl(96, caller()))
| 13,484 |
12 | // : ignore returned minNumOfSignersOverwrite for on-chain quotes | _checkSenderAndPolicyAndQuoteInfo(
borrower,
lenderVault,
onChainQuote.generalQuoteInfo,
onChainQuote.quoteTuples[quoteTupleIdx]
);
mapping(bytes32 => bool)
storage isOnChainQuoteFromVault = isOnChainQuote[lenderVault];
bytes32 onChainQuoteHash = _hashOnChainQuote(onChainQuote);
if (!isOnChainQuoteFromVault[onChainQuoteHash]) {
| _checkSenderAndPolicyAndQuoteInfo(
borrower,
lenderVault,
onChainQuote.generalQuoteInfo,
onChainQuote.quoteTuples[quoteTupleIdx]
);
mapping(bytes32 => bool)
storage isOnChainQuoteFromVault = isOnChainQuote[lenderVault];
bytes32 onChainQuoteHash = _hashOnChainQuote(onChainQuote);
if (!isOnChainQuoteFromVault[onChainQuoteHash]) {
| 38,084 |
20 | // Claims {points, staking rewards} and update the tier, if needed./_tokenId The ID of the membership NFT./This function allows users to claim the rewards + a new tier, if eligible. | function claim(uint256 _tokenId) public whenNotPaused {
uint8 oldTier = tokenData[_tokenId].tier;
uint8 newTier = membershipNFT.claimableTier(_tokenId);
if (oldTier == newTier) {
return;
}
| function claim(uint256 _tokenId) public whenNotPaused {
uint8 oldTier = tokenData[_tokenId].tier;
uint8 newTier = membershipNFT.claimableTier(_tokenId);
if (oldTier == newTier) {
return;
}
| 27,425 |
328 | // Tokens free balance on the indexer stake that can be used for allocations.This function accepts a parameter for extra delegated capacity that takes intoaccount delegated tokens stake Stake data _delegatedCapacity Amount of tokens used from delegators to calculate availabilityreturn Token amount / | function tokensAvailableWithDelegation(Stakes.Indexer memory stake, uint256 _delegatedCapacity)
internal
pure
returns (uint256)
| function tokensAvailableWithDelegation(Stakes.Indexer memory stake, uint256 _delegatedCapacity)
internal
pure
returns (uint256)
| 23,018 |
16 | // batch Air Drop by multiple amount _recipients - Address of the recipient _amounts - Amount to transfer used in this batch / | function batchMultipleAmount(address[] _recipients, uint256[] _amounts) external
onlyAdmin
validBalanceMultiple(_recipients, _amounts)
| function batchMultipleAmount(address[] _recipients, uint256[] _amounts) external
onlyAdmin
validBalanceMultiple(_recipients, _amounts)
| 31,068 |
133 | // Updates chain ids of used networks _sourceChainId chain id for current network _destinationChainId chain id for opposite network / | function setChainIds(uint256 _sourceChainId, uint256 _destinationChainId) external onlyOwner {
_setChainIds(_sourceChainId, _destinationChainId);
}
| function setChainIds(uint256 _sourceChainId, uint256 _destinationChainId) external onlyOwner {
_setChainIds(_sourceChainId, _destinationChainId);
}
| 7,700 |
9 | // Standard mint function | function mintToken(uint256 _amount) public payable {
uint256 supply = totalSupply();
require( saleActive, "Sale isn't active" );
require( _amount > 0 && _amount < 21, "Can only mint between 1 and 20 tokens at once" );
require( supply + _amount + reserved <= MAX_SUPPLY, "Can't mint more than max supply" ); // 1.edited- added reserved
require( msg.value == price * _amount, "Wrong amount of ETH sent" );
for(uint256 i; i < _amount; i++){
_safeMint( msg.sender, supply + i + reserved );// 2.edited- added reserved
}
}
| function mintToken(uint256 _amount) public payable {
uint256 supply = totalSupply();
require( saleActive, "Sale isn't active" );
require( _amount > 0 && _amount < 21, "Can only mint between 1 and 20 tokens at once" );
require( supply + _amount + reserved <= MAX_SUPPLY, "Can't mint more than max supply" ); // 1.edited- added reserved
require( msg.value == price * _amount, "Wrong amount of ETH sent" );
for(uint256 i; i < _amount; i++){
_safeMint( msg.sender, supply + i + reserved );// 2.edited- added reserved
}
}
| 5,680 |
12 | // PriorityQueue Min-heap priority queue implementation. / | contract PriorityQueue {
using PriorityQueueLib for PriorityQueueLib.Queue;
/*
* Modifiers
*/
modifier onlyOwner() {
require(queue.isOwner());
_;
}
/*
* Storage
*/
PriorityQueueLib.Queue queue;
/*
* Public functions
*/
constructor(address _owner)
public
{
queue.init(_owner);
}
function currentSize()
external
view
returns (uint256)
{
return queue.getCurrentSize();
}
function insert(uint256 _element)
onlyOwner
public
{
queue.insert(_element);
}
function minChild(uint256 i)
public
view
returns (uint256)
{
return queue.minChild(i);
}
/**
* @dev Returns the top element of the heap.
* @return The smallest element in the priority queue.
*/
function getMin()
public
view
returns (uint256)
{
return queue.getMin();
}
/**
* @dev Deletes the top element of the heap and shifts everything up.
* @return The smallest element in the priorty queue.
*/
function delMin()
public
returns (uint256)
{
return queue.delMin();
}
}
| contract PriorityQueue {
using PriorityQueueLib for PriorityQueueLib.Queue;
/*
* Modifiers
*/
modifier onlyOwner() {
require(queue.isOwner());
_;
}
/*
* Storage
*/
PriorityQueueLib.Queue queue;
/*
* Public functions
*/
constructor(address _owner)
public
{
queue.init(_owner);
}
function currentSize()
external
view
returns (uint256)
{
return queue.getCurrentSize();
}
function insert(uint256 _element)
onlyOwner
public
{
queue.insert(_element);
}
function minChild(uint256 i)
public
view
returns (uint256)
{
return queue.minChild(i);
}
/**
* @dev Returns the top element of the heap.
* @return The smallest element in the priority queue.
*/
function getMin()
public
view
returns (uint256)
{
return queue.getMin();
}
/**
* @dev Deletes the top element of the heap and shifts everything up.
* @return The smallest element in the priorty queue.
*/
function delMin()
public
returns (uint256)
{
return queue.delMin();
}
}
| 17,854 |
119 | // dev transfer | payable(address(devWallet)).transfer(address(this).balance);
| payable(address(devWallet)).transfer(address(this).balance);
| 9,916 |
33 | // Sale data | bool public saleHasEnded;
bool public minCapReached;
bool public allowRefund;
mapping (address => uint256) public ETHContributed;
uint256 public totalETHRaised;
uint256 public saleStartBlock;
uint256 public saleEndBlock;
uint256 public saleFirstEarlyBirdEndBlock;
uint256 public saleSecondEarlyBirdEndBlock;
uint256 public constant DEV_PORTION = 20; // In percentage
| bool public saleHasEnded;
bool public minCapReached;
bool public allowRefund;
mapping (address => uint256) public ETHContributed;
uint256 public totalETHRaised;
uint256 public saleStartBlock;
uint256 public saleEndBlock;
uint256 public saleFirstEarlyBirdEndBlock;
uint256 public saleSecondEarlyBirdEndBlock;
uint256 public constant DEV_PORTION = 20; // In percentage
| 1,875 |
3 | // Callback before a new agreement is updated. superToken The super token used for the agreement. agreementClass The agreement class address. agreementId The agreementId agreementData The agreement data (non-compressed) ctx The context data.return cbdata A free format in memory data the app can use to pass arbitary information to the after-hook callback. @custom:note - It will be invoked with `staticcall`, no state changes are permitted.- Only revert with a "reason" is permitted. / | function beforeAgreementUpdated(
| function beforeAgreementUpdated(
| 4,901 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.