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
22
// amount is in amountBuy terms // X /
require(invalidOrder[Y[2]] < X[3]); if (X[6] > 100 finney) X[6] = 100 finney; if (X[7] > 100 finney) X[7] = 100 finney; require(tokens[Y[0]][Y[3]] > X[4]); require(tokens[Y[1]][Y[2]] > (safeMul(X[1], X[4]) / X[0])); tokens[Y[0]][Y[3]] = safeSub(tokens[Y[0]][Y[3]], X[4]); tokens[Y[0]][Y[2]] = safeAdd(tokens[Y[0]][Y[2]], safeMul(X[4], ((1 ether) - X[6])) / (1 ether)); tokens[Y[0]][feeAccount] = safeAdd(tokens[Y[0]][feeAccount], safeMul(X[4], X[6]) / (1 ether)); tokens[Y[1]][Y[2]] = safeSub(tokens[Y[1]][Y[2]], safeMul(X[1], X[4]) / X[0]); tokens[Y[1]][Y[3]] = safeAdd(tokens[Y[1]][Y[3]], safeMul(safeMul(((1 ether) - X[7]), X[1]), X[4]) / X[0] / (1 ether));
require(invalidOrder[Y[2]] < X[3]); if (X[6] > 100 finney) X[6] = 100 finney; if (X[7] > 100 finney) X[7] = 100 finney; require(tokens[Y[0]][Y[3]] > X[4]); require(tokens[Y[1]][Y[2]] > (safeMul(X[1], X[4]) / X[0])); tokens[Y[0]][Y[3]] = safeSub(tokens[Y[0]][Y[3]], X[4]); tokens[Y[0]][Y[2]] = safeAdd(tokens[Y[0]][Y[2]], safeMul(X[4], ((1 ether) - X[6])) / (1 ether)); tokens[Y[0]][feeAccount] = safeAdd(tokens[Y[0]][feeAccount], safeMul(X[4], X[6]) / (1 ether)); tokens[Y[1]][Y[2]] = safeSub(tokens[Y[1]][Y[2]], safeMul(X[1], X[4]) / X[0]); tokens[Y[1]][Y[3]] = safeAdd(tokens[Y[1]][Y[3]], safeMul(safeMul(((1 ether) - X[7]), X[1]), X[4]) / X[0] / (1 ether));
46,988
21
// Settle balance from an account by the agreement. The agreement needs to make sure that the balance delta is balanced afterwards account Account to query. delta Amount of balance delta to be settled Modifiers: - onlyAgreement /
function settleBalance(
function settleBalance(
13,503
21
// transfer batch of tokens between given addresses operator executor of transfer sender sender of tokens recipient receiver of tokens ids token IDs amounts quantities of tokens to transfer data data payload /
function _safeTransferBatch( address operator, address sender, address recipient, uint256[] memory ids, uint256[] memory amounts, bytes memory data
function _safeTransferBatch( address operator, address sender, address recipient, uint256[] memory ids, uint256[] memory amounts, bytes memory data
13,200
161
// Helper to shorten royalties arrays if it is too long /
function _shortenRoyalties(address payable[] storage receivers, uint256[] storage basisPoints, uint256 targetLength) internal { require(receivers.length == basisPoints.length, "CreatorCore: Invalid input"); if (targetLength < receivers.length) { for (uint i = receivers.length; i > targetLength; i--) { receivers.pop(); basisPoints.pop(); } } }
function _shortenRoyalties(address payable[] storage receivers, uint256[] storage basisPoints, uint256 targetLength) internal { require(receivers.length == basisPoints.length, "CreatorCore: Invalid input"); if (targetLength < receivers.length) { for (uint i = receivers.length; i > targetLength; i--) { receivers.pop(); basisPoints.pop(); } } }
37,039
51
// SuperRare bytes4(keccak256('calculateRoyaltyFee(address,uint256,uint256)')) == 0x860110f5
interfaceId == 0x860110f5 ||
interfaceId == 0x860110f5 ||
17,594
124
// solium-enable arg-overflow
function approve( address _approved, uint256 _tokenId ) external payable mustBeValidToken(_tokenId) onlyTokenOwnerOrOperator(_tokenId) whenNotPaused
function approve( address _approved, uint256 _tokenId ) external payable mustBeValidToken(_tokenId) onlyTokenOwnerOrOperator(_tokenId) whenNotPaused
47,548
2
// Total Supply.
uint256 private constant _tTotal = 5000000000*10**9; uint256 private constant MAX = ~uint256(0); uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private constant _tTotal = 5000000000*10**9; uint256 private constant MAX = ~uint256(0); uint256 private _rTotal = (MAX - (MAX % _tTotal));
42,242
101
// Increase the offset to ids by 32.
mstore( BatchTransfer1155Params_ids_head_ptr, ERC1155BatchTransferGenericFailure_ids_offset )
mstore( BatchTransfer1155Params_ids_head_ptr, ERC1155BatchTransferGenericFailure_ids_offset )
33,116
64
// save the block for a timeout
lastBlock[_stack]=uint32(block.number); lastActor[_stack]=stacks[_counterStack].owner; mode[_stack]=1; counterOfStack[_stack]=_counterStack;
lastBlock[_stack]=uint32(block.number); lastActor[_stack]=stacks[_counterStack].owner; mode[_stack]=1; counterOfStack[_stack]=_counterStack;
65,301
605
// Accrue COMP to the market by updating the borrow index cToken The market whose borrow index to update Index is a cumulative sum of the COMP per cToken accrued. /
function updateCompBorrowIndex(address cToken, Exp memory marketBorrowIndex) internal
function updateCompBorrowIndex(address cToken, Exp memory marketBorrowIndex) internal
21,227
2
// Destroys a book/removes the books id from the list and sends to a zero address/_tokenId the id of the book to be burnt
function burn(uint _tokenId) external{ _burn(_tokenId); }
function burn(uint _tokenId) external{ _burn(_tokenId); }
27,795
44
// triggered when liquidity protection is updated_providerliquidity provider_prevPoolAmountprevious amount of pool tokens_prevReserveAmount previous amount of reserve tokens_newPoolAmount new amount of pool tokens_newReserveAmountnew amount of reserve tokens/
event ProtectionUpdated(
event ProtectionUpdated(
23,130
46
// Get this balance of CA
function getBalance() external view returns(uint){ return address(this).balance; }
function getBalance() external view returns(uint){ return address(this).balance; }
11,802
21
// Get and distribute any pending rewards
_getAndDistributeRewardsWithMassUpdate();
_getAndDistributeRewardsWithMassUpdate();
46,480
56
// No `prevId` for hint - ascend list starting from `nextId`
return _ascendList(_troveManager, _NICR, nextId);
return _ascendList(_troveManager, _NICR, nextId);
16,123
4
// Common math tools
library Math { /** * @notice Get non-negative difference of `minuend` and `subtracted`. * @return `minuend - subtracted`if it is non-negative or 0 */ function diffOrZero(uint256 minuend, uint256 subtracted) internal pure returns (uint256) { return minuend > subtracted ? minuend - subtracted : 0; } /** * @notice Get max of `a` and `b`. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @notice Get min of `a` and `b`. */ function min(uint128 a, uint128 b) internal pure returns (uint128) { return a < b ? a : b; } }
library Math { /** * @notice Get non-negative difference of `minuend` and `subtracted`. * @return `minuend - subtracted`if it is non-negative or 0 */ function diffOrZero(uint256 minuend, uint256 subtracted) internal pure returns (uint256) { return minuend > subtracted ? minuend - subtracted : 0; } /** * @notice Get max of `a` and `b`. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @notice Get min of `a` and `b`. */ function min(uint128 a, uint128 b) internal pure returns (uint128) { return a < b ? a : b; } }
20,486
42
// Stake the tokens into stkWAR
IWarlordStaker(stkWar).stake(amount, address(this));
IWarlordStaker(stkWar).stake(amount, address(this));
261
68
// get current active loans in the system/start of the index/count number of loans to return/unsafeOnly boolean if true return unsafe loan only (open for liquidation)
function getActiveLoans( uint256 start, uint256 count, bool unsafeOnly ) external view returns (LoanReturnData[] memory loansData); function getActiveLoansCount() external view returns (uint256);
function getActiveLoans( uint256 start, uint256 count, bool unsafeOnly ) external view returns (LoanReturnData[] memory loansData); function getActiveLoansCount() external view returns (uint256);
718
74
// 用户还款
function repay(address token, uint256 repayAmount) public payable whenUnpaused rewardFor(msg.sender, RewardType.Repay) returns (uint256)
function repay(address token, uint256 repayAmount) public payable whenUnpaused rewardFor(msg.sender, RewardType.Repay) returns (uint256)
23,516
71
// uint256 amountETHMarketing = amountETH__sellFee.marketing / totalSwapFee;
uint256 amountETHLP = amountETH * __sellFee.lp / totalSwapFee; uint256 amountETHBuyback = amountETH * __sellFee.buyback / totalSwapFee;
uint256 amountETHLP = amountETH * __sellFee.lp / totalSwapFee; uint256 amountETHBuyback = amountETH * __sellFee.buyback / totalSwapFee;
43,522
1
// 자원 판매 정보
struct ResourceSale { address seller; address resourceAddress; uint resourceAmount; uint price; string description; uint createTime; }
struct ResourceSale { address seller; address resourceAddress; uint resourceAmount; uint price; string description; uint createTime; }
2,727
133
// subtract voter's information to preserve the participation ratios of other voters compared to the remaining pool of rewards
challenges[_challengeID].winningTokens = challenges[_challengeID].winningTokens.sub(voterTokens); challenges[_challengeID].rewardPool = challenges[_challengeID].rewardPool.sub(reward);
challenges[_challengeID].winningTokens = challenges[_challengeID].winningTokens.sub(voterTokens); challenges[_challengeID].rewardPool = challenges[_challengeID].rewardPool.sub(reward);
11,818
289
// contains a helper function that creates new FarmingRewards contracts in the ElkFarmFactory this is a separate contract so that the FarmFactory contract is not too large /
library ElkV2FactoryHelper { /** * @notice creates a new FarmingRewards contract and transfers ownership to the provided farm manager * @param _abi the abi of the FarmingRewards contract * @param _salt the salt used to create the contract * @param _farmManager the address of the farm manager */ function createFarmContract( bytes memory _abi, bytes32 _salt, address _farmManager ) external returns (address addr) { bytes memory bytecode = abi.encodePacked(type(ElkV2FarmingRewards).creationCode, _abi); assembly { addr := create2(0, add(bytecode, 0x20), mload(bytecode), _salt) if iszero(extcodesize(addr)) { revert(0, 0) } } ElkV2FarmingRewards(addr).transferOwnership(_farmManager); } }
library ElkV2FactoryHelper { /** * @notice creates a new FarmingRewards contract and transfers ownership to the provided farm manager * @param _abi the abi of the FarmingRewards contract * @param _salt the salt used to create the contract * @param _farmManager the address of the farm manager */ function createFarmContract( bytes memory _abi, bytes32 _salt, address _farmManager ) external returns (address addr) { bytes memory bytecode = abi.encodePacked(type(ElkV2FarmingRewards).creationCode, _abi); assembly { addr := create2(0, add(bytecode, 0x20), mload(bytecode), _salt) if iszero(extcodesize(addr)) { revert(0, 0) } } ElkV2FarmingRewards(addr).transferOwnership(_farmManager); } }
26,310
26
// difference in ETH
uint256 difference = (higherPrice - lowerPrice) / higherPrice; uint256 payed_fee = (2 * (amountIn * 3)) / 1000; if (difference > payed_fee) { return true; } else {
uint256 difference = (higherPrice - lowerPrice) / higherPrice; uint256 payed_fee = (2 * (amountIn * 3)) / 1000; if (difference > payed_fee) { return true; } else {
32,507
44
// Interest-bearing ERC20-like token for Lybra protocol. This contract is abstract. To make the contract deployable override the`_getTotalMintedEUSD` function. `Lybra.sol` contract inherits EUSD and definesthe `_getTotalMintedEUSD` function. EUSD balances are dynamic and represent the holder's share in the total amountof Ether controlled by the protocol. Account shares aren't normalized, so thecontract also stores the sum of all shares to calculate each account's token balancewhich equals to: shares[account]_getTotalMintedEUSD() / _getTotalShares() For example, assume that we have: _getTotalMintedEUSD() -> 1000 EUSDsharesOf(user1) -> 100sharesOf(user2) -> 400 Therefore: balanceOf(user1) -> 2 tokens which corresponds 200 EUSDbalanceOf(user2) -> 8 tokens which corresponds 800 EUSD Since balances
abstract contract EUSD is IERC20 { using SafeMath for uint256; uint256 private totalShares; /** * @dev EUSD balances are dynamic and are calculated based on the accounts' shares * and the total supply by the protocol. Account shares aren't * normalized, so the contract also stores the sum of all shares to calculate * each account's token balance which equals to: * * shares[account] * _getTotalMintedEUSD() / _getTotalShares() */ mapping(address => uint256) private shares; /** * @dev Allowances are nominated in tokens, not token shares. */ mapping(address => mapping(address => uint256)) private allowances; /** * @notice An executed shares transfer from `sender` to `recipient`. * * @dev emitted in pair with an ERC20-defined `Transfer` event. */ event TransferShares( address indexed from, address indexed to, uint256 sharesValue ); /** * @notice An executed `burnShares` request * * @dev Reports simultaneously burnt shares amount * and corresponding EUSD amount. * The EUSD amount is calculated twice: before and after the burning incurred rebase. * * @param account holder of the burnt shares * @param preRebaseTokenAmount amount of EUSD the burnt shares corresponded to before the burn * @param postRebaseTokenAmount amount of EUSD the burnt shares corresponded to after the burn * @param sharesAmount amount of burnt shares */ event SharesBurnt( address indexed account, uint256 preRebaseTokenAmount, uint256 postRebaseTokenAmount, uint256 sharesAmount ); /** * @return the name of the token. */ function name() public pure returns (string memory) { return "eUSD"; } /** * @return the symbol of the token, usually a shorter version of the * name. */ function symbol() public pure returns (string memory) { return "eUSD"; } /** * @return the number of decimals for getting user representation of a token amount. */ function decimals() public pure returns (uint8) { return 18; } /** * @return the amount of EUSD in existence. * * @dev Always equals to `_getTotalMintedEUSD()` since token amount * is pegged to the total amount of EUSD controlled by the protocol. */ function totalSupply() public view returns (uint256) { return _getTotalMintedEUSD(); } /** * @return the amount of tokens owned by the `_account`. * * @dev Balances are dynamic and equal the `_account`'s share in the amount of the * total Ether controlled by the protocol. See `sharesOf`. */ function balanceOf(address _account) public view returns (uint256) { return getMintedEUSDByShares(_sharesOf(_account)); } /** * @notice Moves `_amount` tokens from the caller's account to the `_recipient` account. * * @return a boolean value indicating whether the operation succeeded. * Emits a `Transfer` event. * Emits a `TransferShares` event. * * Requirements: * * - `_recipient` cannot be the zero address. * - the caller must have a balance of at least `_amount`. * - the contract must not be paused. * * @dev The `_amount` argument is the amount of tokens, not shares. */ function transfer( address _recipient, uint256 _amount ) public returns (bool) { _transfer(msg.sender, _recipient, _amount); return true; } /** * @return the remaining number of tokens that `_spender` is allowed to spend * on behalf of `_owner` through `transferFrom`. This is zero by default. * * @dev This value changes when `approve` or `transferFrom` is called. */ function allowance( address _owner, address _spender ) public view returns (uint256) { return allowances[_owner][_spender]; } /** * @notice Sets `_amount` as the allowance of `_spender` over the caller's tokens. * * @return a boolean value indicating whether the operation succeeded. * Emits an `Approval` event. * * Requirements: * * - `_spender` cannot be the zero address. * - the contract must not be paused. * * @dev The `_amount` argument is the amount of tokens, not shares. */ function approve(address _spender, uint256 _amount) public returns (bool) { _approve(msg.sender, _spender, _amount); return true; } /** * @notice Moves `_amount` tokens from `_sender` to `_recipient` using the * allowance mechanism. `_amount` is then deducted from the caller's * allowance. * * @return a boolean value indicating whether the operation succeeded. * * Emits a `Transfer` event. * Emits a `TransferShares` event. * Emits an `Approval` event indicating the updated allowance. * * Requirements: * * - `_sender` and `_recipient` cannot be the zero addresses. * - `_sender` must have a balance of at least `_amount`. * - the caller must have allowance for `_sender`'s tokens of at least `_amount`. * - the contract must not be paused. * * @dev The `_amount` argument is the amount of tokens, not shares. */ function transferFrom( address _sender, address _recipient, uint256 _amount ) public returns (bool) { uint256 currentAllowance = allowances[_sender][msg.sender]; require( currentAllowance >= _amount, "TRANSFER_AMOUNT_EXCEEDS_ALLOWANCE" ); _transfer(_sender, _recipient, _amount); _approve(_sender, msg.sender, currentAllowance.sub(_amount)); return true; } /** * @notice Atomically increases the allowance granted to `_spender` by the caller by `_addedValue`. * * This is an alternative to `approve` that can be used as a mitigation for * problems described in: * https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/IERC20.sol#L42 * Emits an `Approval` event indicating the updated allowance. * * Requirements: * * - `_spender` cannot be the the zero address. * - the contract must not be paused. */ function increaseAllowance( address _spender, uint256 _addedValue ) public returns (bool) { _approve( msg.sender, _spender, allowances[msg.sender][_spender].add(_addedValue) ); return true; } /** * @notice Atomically decreases the allowance granted to `_spender` by the caller by `_subtractedValue`. * * This is an alternative to `approve` that can be used as a mitigation for * problems described in: * https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/IERC20.sol#L42 * Emits an `Approval` event indicating the updated allowance. * * Requirements: * * - `_spender` cannot be the zero address. * - `_spender` must have allowance for the caller of at least `_subtractedValue`. * - the contract must not be paused. */ function decreaseAllowance( address _spender, uint256 _subtractedValue ) public returns (bool) { uint256 currentAllowance = allowances[msg.sender][_spender]; require( currentAllowance >= _subtractedValue, "DECREASED_ALLOWANCE_BELOW_ZERO" ); _approve(msg.sender, _spender, currentAllowance.sub(_subtractedValue)); return true; } /** * @return the total amount of shares in existence. * * @dev The sum of all accounts' shares can be an arbitrary number, therefore * it is necessary to store it in order to calculate each account's relative share. */ function getTotalShares() public view returns (uint256) { return _getTotalShares(); } /** * @return the amount of shares owned by `_account`. */ function sharesOf(address _account) public view returns (uint256) { return _sharesOf(_account); } /** * @return the amount of shares that corresponds to `_EUSDAmount` protocol-supplied EUSD. */ function getSharesByMintedEUSD( uint256 _EUSDAmount ) public view returns (uint256) { uint256 totalMintedEUSD = _getTotalMintedEUSD(); if (totalMintedEUSD == 0) { return 0; } else { return _EUSDAmount.mul(_getTotalShares()).div(totalMintedEUSD); } } /** * @return the amount of EUSD that corresponds to `_sharesAmount` token shares. */ function getMintedEUSDByShares( uint256 _sharesAmount ) public view returns (uint256) { uint256 totalSharesAmount = _getTotalShares(); if (totalShares == 0) { return 0; } else { return _sharesAmount.mul(_getTotalMintedEUSD()).div(totalSharesAmount); } } /** * @notice Moves `_sharesAmount` token shares from the caller's account to the `_recipient` account. * * @return amount of transferred tokens. * Emits a `TransferShares` event. * Emits a `Transfer` event. * * Requirements: * * - `_recipient` cannot be the zero address. * - the caller must have at least `_sharesAmount` shares. * - the contract must not be paused. * * @dev The `_sharesAmount` argument is the amount of shares, not tokens. */ function transferShares( address _recipient, uint256 _sharesAmount ) public returns (uint256) { _transferShares(msg.sender, _recipient, _sharesAmount); emit TransferShares(msg.sender, _recipient, _sharesAmount); uint256 tokensAmount = getMintedEUSDByShares(_sharesAmount); emit Transfer(msg.sender, _recipient, tokensAmount); return tokensAmount; } /** * @return the total amount of EUSD. * @dev This is used for calculating tokens from shares and vice versa. * @dev This function is required to be implemented in a derived contract. */ function _getTotalMintedEUSD() internal view virtual returns (uint256); /** * @notice Moves `_amount` tokens from `_sender` to `_recipient`. * Emits a `Transfer` event. * Emits a `TransferShares` event. */ function _transfer( address _sender, address _recipient, uint256 _amount ) internal { uint256 _sharesToTransfer = getSharesByMintedEUSD(_amount); _transferShares(_sender, _recipient, _sharesToTransfer); emit Transfer(_sender, _recipient, _amount); emit TransferShares(_sender, _recipient, _sharesToTransfer); } /** * @notice Sets `_amount` as the allowance of `_spender` over the `_owner` s tokens. * * Emits an `Approval` event. * * Requirements: * * - `_owner` cannot be the zero address. * - `_spender` cannot be the zero address. * - the contract must not be paused. */ function _approve( address _owner, address _spender, uint256 _amount ) internal { require(_owner != address(0), "APPROVE_FROM_ZERO_ADDRESS"); require(_spender != address(0), "APPROVE_TO_ZERO_ADDRESS"); allowances[_owner][_spender] = _amount; emit Approval(_owner, _spender, _amount); } /** * @return the total amount of shares in existence. */ function _getTotalShares() internal view returns (uint256) { return totalShares; } /** * @return the amount of shares owned by `_account`. */ function _sharesOf(address _account) internal view returns (uint256) { return shares[_account]; } /** * @notice Moves `_sharesAmount` shares from `_sender` to `_recipient`. * * Requirements: * * - `_sender` cannot be the zero address. * - `_recipient` cannot be the zero address. * - `_sender` must hold at least `_sharesAmount` shares. * - the contract must not be paused. */ function _transferShares( address _sender, address _recipient, uint256 _sharesAmount ) internal { require(_sender != address(0), "TRANSFER_FROM_THE_ZERO_ADDRESS"); require(_recipient != address(0), "TRANSFER_TO_THE_ZERO_ADDRESS"); uint256 currentSenderShares = shares[_sender]; require( _sharesAmount <= currentSenderShares, "TRANSFER_AMOUNT_EXCEEDS_BALANCE" ); shares[_sender] = currentSenderShares.sub(_sharesAmount); shares[_recipient] = shares[_recipient].add(_sharesAmount); } /** * @notice Creates `_sharesAmount` shares and assigns them to `_recipient`, increasing the total amount of shares. * @dev This doesn't increase the token total supply. * * Requirements: * * - `_recipient` cannot be the zero address. * - the contract must not be paused. */ function _mintShares( address _recipient, uint256 _sharesAmount ) internal returns (uint256 newTotalShares) { require(_recipient != address(0), "MINT_TO_THE_ZERO_ADDRESS"); newTotalShares = _getTotalShares().add(_sharesAmount); totalShares = newTotalShares; shares[_recipient] = shares[_recipient].add(_sharesAmount); // Notice: we're not emitting a Transfer event from the zero address here since shares mint // works by taking the amount of tokens corresponding to the minted shares from all other // token holders, proportionally to their share. The total supply of the token doesn't change // as the result. This is equivalent to performing a send from each other token holder's // address to `address`, but we cannot reflect this as it would require sending an unbounded // number of events. } /** * @notice Destroys `_sharesAmount` shares from `_account`'s holdings, decreasing the total amount of shares. * @dev This doesn't decrease the token total supply. * * Requirements: * * - `_account` cannot be the zero address. * - `_account` must hold at least `_sharesAmount` shares. * - the contract must not be paused. */ function _burnShares( address _account, uint256 _sharesAmount ) internal returns (uint256 newTotalShares) { require(_account != address(0), "BURN_FROM_THE_ZERO_ADDRESS"); uint256 accountShares = shares[_account]; require(_sharesAmount <= accountShares, "BURN_AMOUNT_EXCEEDS_BALANCE"); uint256 preRebaseTokenAmount = getMintedEUSDByShares(_sharesAmount); newTotalShares = _getTotalShares().sub(_sharesAmount); totalShares = newTotalShares; shares[_account] = accountShares.sub(_sharesAmount); uint256 postRebaseTokenAmount = getMintedEUSDByShares(_sharesAmount); emit SharesBurnt( _account, preRebaseTokenAmount, postRebaseTokenAmount, _sharesAmount ); // Notice: we're not emitting a Transfer event to the zero address here since shares burn // works by redistributing the amount of tokens corresponding to the burned shares between // all other token holders. The total supply of the token doesn't change as the result. // This is equivalent to performing a send from `address` to each other token holder address, // but we cannot reflect this as it would require sending an unbounded number of events. // We're emitting `SharesBurnt` event to provide an explicit rebase log record nonetheless. } }
abstract contract EUSD is IERC20 { using SafeMath for uint256; uint256 private totalShares; /** * @dev EUSD balances are dynamic and are calculated based on the accounts' shares * and the total supply by the protocol. Account shares aren't * normalized, so the contract also stores the sum of all shares to calculate * each account's token balance which equals to: * * shares[account] * _getTotalMintedEUSD() / _getTotalShares() */ mapping(address => uint256) private shares; /** * @dev Allowances are nominated in tokens, not token shares. */ mapping(address => mapping(address => uint256)) private allowances; /** * @notice An executed shares transfer from `sender` to `recipient`. * * @dev emitted in pair with an ERC20-defined `Transfer` event. */ event TransferShares( address indexed from, address indexed to, uint256 sharesValue ); /** * @notice An executed `burnShares` request * * @dev Reports simultaneously burnt shares amount * and corresponding EUSD amount. * The EUSD amount is calculated twice: before and after the burning incurred rebase. * * @param account holder of the burnt shares * @param preRebaseTokenAmount amount of EUSD the burnt shares corresponded to before the burn * @param postRebaseTokenAmount amount of EUSD the burnt shares corresponded to after the burn * @param sharesAmount amount of burnt shares */ event SharesBurnt( address indexed account, uint256 preRebaseTokenAmount, uint256 postRebaseTokenAmount, uint256 sharesAmount ); /** * @return the name of the token. */ function name() public pure returns (string memory) { return "eUSD"; } /** * @return the symbol of the token, usually a shorter version of the * name. */ function symbol() public pure returns (string memory) { return "eUSD"; } /** * @return the number of decimals for getting user representation of a token amount. */ function decimals() public pure returns (uint8) { return 18; } /** * @return the amount of EUSD in existence. * * @dev Always equals to `_getTotalMintedEUSD()` since token amount * is pegged to the total amount of EUSD controlled by the protocol. */ function totalSupply() public view returns (uint256) { return _getTotalMintedEUSD(); } /** * @return the amount of tokens owned by the `_account`. * * @dev Balances are dynamic and equal the `_account`'s share in the amount of the * total Ether controlled by the protocol. See `sharesOf`. */ function balanceOf(address _account) public view returns (uint256) { return getMintedEUSDByShares(_sharesOf(_account)); } /** * @notice Moves `_amount` tokens from the caller's account to the `_recipient` account. * * @return a boolean value indicating whether the operation succeeded. * Emits a `Transfer` event. * Emits a `TransferShares` event. * * Requirements: * * - `_recipient` cannot be the zero address. * - the caller must have a balance of at least `_amount`. * - the contract must not be paused. * * @dev The `_amount` argument is the amount of tokens, not shares. */ function transfer( address _recipient, uint256 _amount ) public returns (bool) { _transfer(msg.sender, _recipient, _amount); return true; } /** * @return the remaining number of tokens that `_spender` is allowed to spend * on behalf of `_owner` through `transferFrom`. This is zero by default. * * @dev This value changes when `approve` or `transferFrom` is called. */ function allowance( address _owner, address _spender ) public view returns (uint256) { return allowances[_owner][_spender]; } /** * @notice Sets `_amount` as the allowance of `_spender` over the caller's tokens. * * @return a boolean value indicating whether the operation succeeded. * Emits an `Approval` event. * * Requirements: * * - `_spender` cannot be the zero address. * - the contract must not be paused. * * @dev The `_amount` argument is the amount of tokens, not shares. */ function approve(address _spender, uint256 _amount) public returns (bool) { _approve(msg.sender, _spender, _amount); return true; } /** * @notice Moves `_amount` tokens from `_sender` to `_recipient` using the * allowance mechanism. `_amount` is then deducted from the caller's * allowance. * * @return a boolean value indicating whether the operation succeeded. * * Emits a `Transfer` event. * Emits a `TransferShares` event. * Emits an `Approval` event indicating the updated allowance. * * Requirements: * * - `_sender` and `_recipient` cannot be the zero addresses. * - `_sender` must have a balance of at least `_amount`. * - the caller must have allowance for `_sender`'s tokens of at least `_amount`. * - the contract must not be paused. * * @dev The `_amount` argument is the amount of tokens, not shares. */ function transferFrom( address _sender, address _recipient, uint256 _amount ) public returns (bool) { uint256 currentAllowance = allowances[_sender][msg.sender]; require( currentAllowance >= _amount, "TRANSFER_AMOUNT_EXCEEDS_ALLOWANCE" ); _transfer(_sender, _recipient, _amount); _approve(_sender, msg.sender, currentAllowance.sub(_amount)); return true; } /** * @notice Atomically increases the allowance granted to `_spender` by the caller by `_addedValue`. * * This is an alternative to `approve` that can be used as a mitigation for * problems described in: * https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/IERC20.sol#L42 * Emits an `Approval` event indicating the updated allowance. * * Requirements: * * - `_spender` cannot be the the zero address. * - the contract must not be paused. */ function increaseAllowance( address _spender, uint256 _addedValue ) public returns (bool) { _approve( msg.sender, _spender, allowances[msg.sender][_spender].add(_addedValue) ); return true; } /** * @notice Atomically decreases the allowance granted to `_spender` by the caller by `_subtractedValue`. * * This is an alternative to `approve` that can be used as a mitigation for * problems described in: * https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/IERC20.sol#L42 * Emits an `Approval` event indicating the updated allowance. * * Requirements: * * - `_spender` cannot be the zero address. * - `_spender` must have allowance for the caller of at least `_subtractedValue`. * - the contract must not be paused. */ function decreaseAllowance( address _spender, uint256 _subtractedValue ) public returns (bool) { uint256 currentAllowance = allowances[msg.sender][_spender]; require( currentAllowance >= _subtractedValue, "DECREASED_ALLOWANCE_BELOW_ZERO" ); _approve(msg.sender, _spender, currentAllowance.sub(_subtractedValue)); return true; } /** * @return the total amount of shares in existence. * * @dev The sum of all accounts' shares can be an arbitrary number, therefore * it is necessary to store it in order to calculate each account's relative share. */ function getTotalShares() public view returns (uint256) { return _getTotalShares(); } /** * @return the amount of shares owned by `_account`. */ function sharesOf(address _account) public view returns (uint256) { return _sharesOf(_account); } /** * @return the amount of shares that corresponds to `_EUSDAmount` protocol-supplied EUSD. */ function getSharesByMintedEUSD( uint256 _EUSDAmount ) public view returns (uint256) { uint256 totalMintedEUSD = _getTotalMintedEUSD(); if (totalMintedEUSD == 0) { return 0; } else { return _EUSDAmount.mul(_getTotalShares()).div(totalMintedEUSD); } } /** * @return the amount of EUSD that corresponds to `_sharesAmount` token shares. */ function getMintedEUSDByShares( uint256 _sharesAmount ) public view returns (uint256) { uint256 totalSharesAmount = _getTotalShares(); if (totalShares == 0) { return 0; } else { return _sharesAmount.mul(_getTotalMintedEUSD()).div(totalSharesAmount); } } /** * @notice Moves `_sharesAmount` token shares from the caller's account to the `_recipient` account. * * @return amount of transferred tokens. * Emits a `TransferShares` event. * Emits a `Transfer` event. * * Requirements: * * - `_recipient` cannot be the zero address. * - the caller must have at least `_sharesAmount` shares. * - the contract must not be paused. * * @dev The `_sharesAmount` argument is the amount of shares, not tokens. */ function transferShares( address _recipient, uint256 _sharesAmount ) public returns (uint256) { _transferShares(msg.sender, _recipient, _sharesAmount); emit TransferShares(msg.sender, _recipient, _sharesAmount); uint256 tokensAmount = getMintedEUSDByShares(_sharesAmount); emit Transfer(msg.sender, _recipient, tokensAmount); return tokensAmount; } /** * @return the total amount of EUSD. * @dev This is used for calculating tokens from shares and vice versa. * @dev This function is required to be implemented in a derived contract. */ function _getTotalMintedEUSD() internal view virtual returns (uint256); /** * @notice Moves `_amount` tokens from `_sender` to `_recipient`. * Emits a `Transfer` event. * Emits a `TransferShares` event. */ function _transfer( address _sender, address _recipient, uint256 _amount ) internal { uint256 _sharesToTransfer = getSharesByMintedEUSD(_amount); _transferShares(_sender, _recipient, _sharesToTransfer); emit Transfer(_sender, _recipient, _amount); emit TransferShares(_sender, _recipient, _sharesToTransfer); } /** * @notice Sets `_amount` as the allowance of `_spender` over the `_owner` s tokens. * * Emits an `Approval` event. * * Requirements: * * - `_owner` cannot be the zero address. * - `_spender` cannot be the zero address. * - the contract must not be paused. */ function _approve( address _owner, address _spender, uint256 _amount ) internal { require(_owner != address(0), "APPROVE_FROM_ZERO_ADDRESS"); require(_spender != address(0), "APPROVE_TO_ZERO_ADDRESS"); allowances[_owner][_spender] = _amount; emit Approval(_owner, _spender, _amount); } /** * @return the total amount of shares in existence. */ function _getTotalShares() internal view returns (uint256) { return totalShares; } /** * @return the amount of shares owned by `_account`. */ function _sharesOf(address _account) internal view returns (uint256) { return shares[_account]; } /** * @notice Moves `_sharesAmount` shares from `_sender` to `_recipient`. * * Requirements: * * - `_sender` cannot be the zero address. * - `_recipient` cannot be the zero address. * - `_sender` must hold at least `_sharesAmount` shares. * - the contract must not be paused. */ function _transferShares( address _sender, address _recipient, uint256 _sharesAmount ) internal { require(_sender != address(0), "TRANSFER_FROM_THE_ZERO_ADDRESS"); require(_recipient != address(0), "TRANSFER_TO_THE_ZERO_ADDRESS"); uint256 currentSenderShares = shares[_sender]; require( _sharesAmount <= currentSenderShares, "TRANSFER_AMOUNT_EXCEEDS_BALANCE" ); shares[_sender] = currentSenderShares.sub(_sharesAmount); shares[_recipient] = shares[_recipient].add(_sharesAmount); } /** * @notice Creates `_sharesAmount` shares and assigns them to `_recipient`, increasing the total amount of shares. * @dev This doesn't increase the token total supply. * * Requirements: * * - `_recipient` cannot be the zero address. * - the contract must not be paused. */ function _mintShares( address _recipient, uint256 _sharesAmount ) internal returns (uint256 newTotalShares) { require(_recipient != address(0), "MINT_TO_THE_ZERO_ADDRESS"); newTotalShares = _getTotalShares().add(_sharesAmount); totalShares = newTotalShares; shares[_recipient] = shares[_recipient].add(_sharesAmount); // Notice: we're not emitting a Transfer event from the zero address here since shares mint // works by taking the amount of tokens corresponding to the minted shares from all other // token holders, proportionally to their share. The total supply of the token doesn't change // as the result. This is equivalent to performing a send from each other token holder's // address to `address`, but we cannot reflect this as it would require sending an unbounded // number of events. } /** * @notice Destroys `_sharesAmount` shares from `_account`'s holdings, decreasing the total amount of shares. * @dev This doesn't decrease the token total supply. * * Requirements: * * - `_account` cannot be the zero address. * - `_account` must hold at least `_sharesAmount` shares. * - the contract must not be paused. */ function _burnShares( address _account, uint256 _sharesAmount ) internal returns (uint256 newTotalShares) { require(_account != address(0), "BURN_FROM_THE_ZERO_ADDRESS"); uint256 accountShares = shares[_account]; require(_sharesAmount <= accountShares, "BURN_AMOUNT_EXCEEDS_BALANCE"); uint256 preRebaseTokenAmount = getMintedEUSDByShares(_sharesAmount); newTotalShares = _getTotalShares().sub(_sharesAmount); totalShares = newTotalShares; shares[_account] = accountShares.sub(_sharesAmount); uint256 postRebaseTokenAmount = getMintedEUSDByShares(_sharesAmount); emit SharesBurnt( _account, preRebaseTokenAmount, postRebaseTokenAmount, _sharesAmount ); // Notice: we're not emitting a Transfer event to the zero address here since shares burn // works by redistributing the amount of tokens corresponding to the burned shares between // all other token holders. The total supply of the token doesn't change as the result. // This is equivalent to performing a send from `address` to each other token holder address, // but we cannot reflect this as it would require sending an unbounded number of events. // We're emitting `SharesBurnt` event to provide an explicit rebase log record nonetheless. } }
21,644
5
// Clean the upper 96 bits of `subscriptionOrRegistrantToCopy` in case they are dirty.
subscriptionOrRegistrantToCopy := shr(96, shl(96, subscriptionOrRegistrantToCopy))
subscriptionOrRegistrantToCopy := shr(96, shl(96, subscriptionOrRegistrantToCopy))
7,886
126
// Implementation of IERC777Recipient. /
function tokensReceived( address /*operator*/, address from, address to, uint256 amount, bytes calldata userData, bytes calldata /*operatorData*/
function tokensReceived( address /*operator*/, address from, address to, uint256 amount, bytes calldata userData, bytes calldata /*operatorData*/
9,506
15
// 用户空投数据/
struct Airdrop { address userAddress; }
struct Airdrop { address userAddress; }
12,317
109
// A mapping from owner address to a boolean flag of whether the player recruited the first hero. Note that transferring a hero from other address do not count, the value can get by getPlayerDetails. /
mapping(address => bool) playerToFirstHeroRecruited;
mapping(address => bool) playerToFirstHeroRecruited;
56,679
79
// There must be no confiscation motion already running for this account.
require(targetMotionID[target] == 0);
require(targetMotionID[target] == 0);
584
4
// New curve
Curve curve = new Curve(_name, _symbol, _assets, _assetWeights, address(this)); curve.transferOwnership(msg.sender); curves[curveId] = address(curve); emit NewCurve(msg.sender, curveId, address(curve)); return curve;
Curve curve = new Curve(_name, _symbol, _assets, _assetWeights, address(this)); curve.transferOwnership(msg.sender); curves[curveId] = address(curve); emit NewCurve(msg.sender, curveId, address(curve)); return curve;
41,186
117
// success determines whether the staticcall succeeded and result determines whether the contract at account indicates support of _interfaceId
(bool success, bool result) = _callERC165SupportsInterface(account, interfaceId); return (success && result);
(bool success, bool result) = _callERC165SupportsInterface(account, interfaceId); return (success && result);
2,045
41
// generates a pseudorandom number seed a value ensure different outcomes for different sources in the same blockreturn a pseudorandom value /
function random(uint256 seed) internal view returns (uint256) { return uint256( keccak256( abi.encodePacked( tx.origin, blockhash(block.number - 1), block.timestamp, seed ) ) ); }
function random(uint256 seed) internal view returns (uint256) { return uint256( keccak256( abi.encodePacked( tx.origin, blockhash(block.number - 1), block.timestamp, seed ) ) ); }
14,030
7
// For rate limiting
mapping(address=>uint256) nextRequestAt;
mapping(address=>uint256) nextRequestAt;
7,348
9
// Check whether participating in the votinguser Address to check return bool Whether voting/
function checkVoteNow(address user) public view returns (bool) { if (_myVote[user] == address(0x0)) { return false; } else { Nest_3_VoteContract vote = Nest_3_VoteContract(_myVote[user]); if (vote.checkContractEffective() || vote.checkPersonalAmount(user) == 0) { return false; } return true; } }
function checkVoteNow(address user) public view returns (bool) { if (_myVote[user] == address(0x0)) { return false; } else { Nest_3_VoteContract vote = Nest_3_VoteContract(_myVote[user]); if (vote.checkContractEffective() || vote.checkPersonalAmount(user) == 0) { return false; } return true; } }
13,300
316
// Because too many variables need to be returned, too many variables will be defined, so the structure of tunple is defined
(uint minerIndex, Tunple memory value) = _close(config, sheets, indices[--i], ntokenAddress);
(uint minerIndex, Tunple memory value) = _close(config, sheets, indices[--i], ntokenAddress);
12,680
213
// Set the share of CRV to send to the Community Reserve. crvCommunityReserveShare_ New fee charged on CRV rewards for governance.return True if successfully set. /
function setCrvCommunityReserveShare(uint256 crvCommunityReserveShare_) external onlyGovernance returns (bool)
function setCrvCommunityReserveShare(uint256 crvCommunityReserveShare_) external onlyGovernance returns (bool)
34,350
13
// Use a different function regarding if the bank is using an oracle or not
if (Banks[_bankAddr].usingOracle == true){ _oracleRandom(_bankAddr); } else {
if (Banks[_bankAddr].usingOracle == true){ _oracleRandom(_bankAddr); } else {
28,791
18
// PUBLIC FUNCTIONS //Grant another address the right to transfer token via takeOwnership() and transferFrom()./_to The address to be granted transfer approval. Pass address(0) to/clear all approvals./_tokenId The ID of the Token that can be transferred if this call succeeds./Required for ERC-721 compliance.
function approve( address _to, uint256 _tokenId
function approve( address _to, uint256 _tokenId
894
2
// Get contract service status.return contract service status. /
function getStatus() external view returns (uint8);
function getStatus() external view returns (uint8);
33,195
1
// Struct for info about voting in testament
struct Voting { uint256 approvedVotes; uint256 neededVotes; uint256 confirmationTime; address[] guardians; }
struct Voting { uint256 approvedVotes; uint256 neededVotes; uint256 confirmationTime; address[] guardians; }
24,362
28
// NOTE to integratorsThe `beneficiary_`, of a `_crossTransferWithCalldata(...)` must meet these requirement:- Must be an externally owned account (EOA) or- Must be a contract that implements or is capable of calling:- connext.forceUpdateSlippage(TransferInfo, _slippage) add the destination chain.Refer to 'delegate' argument: // @inheritdoc BaseRouter
function _crossTransferWithCalldata( bytes memory params, address beneficiary ) internal override returns (address beneficiary_)
function _crossTransferWithCalldata( bytes memory params, address beneficiary ) internal override returns (address beneficiary_)
40,910
14
// Marks a flag on a speciic position that indicates that it's liquidityis atomic. I.e. the position size cannot be partially reduced, onlyremoved entirely. /
int24 lowTick, int24 highTick) internal { RangePosition storage pos = lookupPosition(owner, poolIdx, lowTick, highTick); pos.atomicLiq_ = true; }
int24 lowTick, int24 highTick) internal { RangePosition storage pos = lookupPosition(owner, poolIdx, lowTick, highTick); pos.atomicLiq_ = true; }
9,282
0
// _vaultId Id of the vault/_amount Amount of dai to be payed back/_from Where the Dai is pulled from/_mcdManager The manager address we are using
struct Params { uint256 vaultId; uint256 amount; address from; address mcdManager; }
struct Params { uint256 vaultId; uint256 amount; address from; address mcdManager; }
48,709
32
// User accounting state Represents a single stake for a user. A user may have multiple.
struct Stake { uint256 stakingTokens; uint256 timestampSec; }
struct Stake { uint256 stakingTokens; uint256 timestampSec; }
17,839
4
// The bit mask selecting 8th bit from every byte of 32 byte integer - used to check whether a string contains any characters > 128
uint constant internal MSB_BYTES = 0x8080808080808080808080808080808080808080808080808080808080808080;
uint constant internal MSB_BYTES = 0x8080808080808080808080808080808080808080808080808080808080808080;
37,577
350
// Block number that DFL was last accrued at
uint public dflAccrualBlock;
uint public dflAccrualBlock;
6,255
1,296
// Compute the formula!
uint256 amountToMint = ( percentage * totalSupply() ) / ( (_100PERCENT) - percentage );
uint256 amountToMint = ( percentage * totalSupply() ) / ( (_100PERCENT) - percentage );
6,105
137
// We keep a record of how much wei contributed has already been used for allocations
weiAllocated = weiAllocated.add(presaleContributions[contributor]).add(contributions[contributor]);
weiAllocated = weiAllocated.add(presaleContributions[contributor]).add(contributions[contributor]);
54,207
1
// CONSTRUCTOR
constructor() public { lockRequestCount = 0; }
constructor() public { lockRequestCount = 0; }
10,935
94
// update accounting, unlock tokens, etc. /
function update() external virtual;
function update() external virtual;
11,813
15
// Removes implementation and the mappings corresponding to it. /
function _removeImplementationSigs(address implementation_) internal { bytes32 slot_ = _getImplSigsSlot(implementation_); bytes4[] memory sigs_ = getSigsSlot(slot_).value; require(sigs_.length != 0, "implementation-not-exist"); for (uint256 i = 0; i < sigs_.length; i++) { bytes32 sigSlot_ = _getSigsImplSlot(sigs_[i]); delete getAddressSlot(sigSlot_).value; } delete getSigsSlot(slot_).value; emit removeImplementationLog(implementation_); }
function _removeImplementationSigs(address implementation_) internal { bytes32 slot_ = _getImplSigsSlot(implementation_); bytes4[] memory sigs_ = getSigsSlot(slot_).value; require(sigs_.length != 0, "implementation-not-exist"); for (uint256 i = 0; i < sigs_.length; i++) { bytes32 sigSlot_ = _getSigsImplSlot(sigs_[i]); delete getAddressSlot(sigSlot_).value; } delete getSigsSlot(slot_).value; emit removeImplementationLog(implementation_); }
74,189
303
// Encodes the argument json bytes into base64-data uri format json raw json to base64 and turn into a data-uri /
function encodeMetadata(bytes memory json) public pure returns (string memory) {
function encodeMetadata(bytes memory json) public pure returns (string memory) {
41,449
44
// Total Token Allocations
uint256 public totalAllocation = 2 * (10 ** 8) * (10 ** 8); uint256 public teamVestingStages = 8;
uint256 public totalAllocation = 2 * (10 ** 8) * (10 ** 8); uint256 public teamVestingStages = 8;
22,741
13
// create fourth listing and check total listings is 4
market.createListingInStore(200, "Leather Coat", "Mint condition", "", address(this)); uint totalListings = market.totalListings(); Assert.equal(totalListings, 4, "There should be 4 listings stored");
market.createListingInStore(200, "Leather Coat", "Mint condition", "", address(this)); uint totalListings = market.totalListings(); Assert.equal(totalListings, 4, "There should be 4 listings stored");
49,506
43
// Remove sold tokens from total supply count
balances[owner] = safeSub(balances[owner], tokens);
balances[owner] = safeSub(balances[owner], tokens);
18,934
95
// interate until we have some value left for buying
while(value > 0) {
while(value > 0) {
21,174
188
// will receive the remaining tokens to distribute them between CommonSale contract and existing users who participated in the first phase of the sale.
addresses[5] = address(tokenDistributor); token = new TenSetToken(addresses, amounts); companyReserveWallet.setToken(address(token)); companyReserveWallet.setStartDate(STAGE1_START_DATE); companyReserveWallet.setDuration(1440); // 4 years = 48 months = 1440 days companyReserveWallet.setInterval(360); // 12 months = 360 days companyReserveWallet.start();
addresses[5] = address(tokenDistributor); token = new TenSetToken(addresses, amounts); companyReserveWallet.setToken(address(token)); companyReserveWallet.setStartDate(STAGE1_START_DATE); companyReserveWallet.setDuration(1440); // 4 years = 48 months = 1440 days companyReserveWallet.setInterval(360); // 12 months = 360 days companyReserveWallet.start();
41,638
45
// Equivalent Solidity code for emitting the event: emit ProxyDeposit(msg.sender, msg.value);
let logData := mload(0x40) // free memory pointer mstore(logData, caller) // add 'msg.sender' to the log data (first event param) mstore(add(logData, 0x20), callvalue) // add 'msg.value' to the log data (second event param)
let logData := mload(0x40) // free memory pointer mstore(logData, caller) // add 'msg.sender' to the log data (first event param) mstore(add(logData, 0x20), callvalue) // add 'msg.value' to the log data (second event param)
16,838
43
// The address which sets partners and manages the funding (not mandatory)
address moderator;
address moderator;
7,440
45
// --- Getters ---/Get the market price from the system coin oracle/
function getMarketPrice() external view returns (uint256) { (uint256 marketPrice, ) = orcl.getResultWithValidity(); return marketPrice; }
function getMarketPrice() external view returns (uint256) { (uint256 marketPrice, ) = orcl.getResultWithValidity(); return marketPrice; }
55,358
29
// Destroy tokens from other account Remove `_value` tokens from the system irreversibly on behalf of `_from`._from the address of the sender_value the amount of money to burn /
function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply Burn(_from, _value); return true; }
function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply Burn(_from, _value); return true; }
1,586
2
// Validates a resolved order, reverting if invalid/filler The filler of the order
function validate(ResolvedOrder memory resolvedOrder, address filler) internal view { if (address(this) != address(resolvedOrder.info.reactor)) { revert InvalidReactor(); }
function validate(ResolvedOrder memory resolvedOrder, address filler) internal view { if (address(this) != address(resolvedOrder.info.reactor)) { revert InvalidReactor(); }
16,524
3
// toAddress1 대상 주소toAddress2 대상 주소value1 전송할 웨이의 양value2 전송할 웨이의 양tokenContractAddress erc20 토큰 계약의 주소/
function multiTransferToken( address fromAddress, address toAddress1, address toAddress2, uint value1, uint value2, address tokenContractAddress
function multiTransferToken( address fromAddress, address toAddress1, address toAddress2, uint value1, uint value2, address tokenContractAddress
15,035
61
// syntheticId of derivative
address syntheticId;
address syntheticId;
29,295
38
// Opens credit account, borrows funds from the pool and pulls collateral/ without any additional action./ - Performs sanity checks to determine whether opening an account is allowed/ - Wraps ETH to WETH and sends it msg. sender is value > 0/ - Requests CreditManager to open a Credit Account with a specified borrowed amount/ - Transfers collateral in the underlying asset from the user/ - Emits OpenCreditAccount event// More info: https:dev.gearbox.fi/developers/credit/credit_manageropen-credit-account//amount The amount of collateral provided by the borrower/onBehalfOf The address to open an account for. Transfers to it have to be allowed if/ msg.sender != obBehalfOf/leverageFactor Percentage of the
function openCreditAccount( uint256 amount, address onBehalfOf, uint16 leverageFactor, uint16 referralCode
function openCreditAccount( uint256 amount, address onBehalfOf, uint16 leverageFactor, uint16 referralCode
20,619
111
// `(quantity == 1) << _BITPOS_NEXT_INITIALIZED`.
result := shl(_BITPOS_NEXT_INITIALIZED, eq(quantity, 1))
result := shl(_BITPOS_NEXT_INITIALIZED, eq(quantity, 1))
1,720
67
// add y^03(20! / 03!)
z = (z * y) / FIXED_1; res += z * 0x0168244fdac78000;
z = (z * y) / FIXED_1; res += z * 0x0168244fdac78000;
2,500
40
// Sets the address and basis points for royalties.newInfo The struct to configure royalties. /
function setRoyaltyInfo(RoyaltyInfo calldata newInfo) external { // Ensure the sender is only the owner or contract itself. _onlyOwnerOrSelf(); // Revert if the new royalty address is the zero address. if (newInfo.royaltyAddress == address(0)) { revert RoyaltyAddressCannotBeZeroAddress(); } // Revert if the new basis points is greater than 10_000. if (newInfo.royaltyBps > 10_000) { revert InvalidRoyaltyBasisPoints(newInfo.royaltyBps); } // Set the new royalty info. _royaltyInfo = newInfo; // Emit an event with the updated params. emit RoyaltyInfoUpdated(newInfo.royaltyAddress, newInfo.royaltyBps); }
function setRoyaltyInfo(RoyaltyInfo calldata newInfo) external { // Ensure the sender is only the owner or contract itself. _onlyOwnerOrSelf(); // Revert if the new royalty address is the zero address. if (newInfo.royaltyAddress == address(0)) { revert RoyaltyAddressCannotBeZeroAddress(); } // Revert if the new basis points is greater than 10_000. if (newInfo.royaltyBps > 10_000) { revert InvalidRoyaltyBasisPoints(newInfo.royaltyBps); } // Set the new royalty info. _royaltyInfo = newInfo; // Emit an event with the updated params. emit RoyaltyInfoUpdated(newInfo.royaltyAddress, newInfo.royaltyBps); }
2,369
16
// profit is [(smaller supply)(change in price) / (last price)]multiplier
uint256 profit = refSupply.mul(delta).div(_lastPrice).mul(multiplier);
uint256 profit = refSupply.mul(delta).div(_lastPrice).mul(multiplier);
13,306
3
// Emitted when `operator` is made operator for `tokenHolder`. /
event AuthorizedOperator(address indexed operator, address indexed tokenHolder);
event AuthorizedOperator(address indexed operator, address indexed tokenHolder);
959
6
// Initializes contract with initial supply tokens to the creator of the contract /
constructor() public{ balanceOf[msg.sender] = totalSupply; owner = msg.sender; }
constructor() public{ balanceOf[msg.sender] = totalSupply; owner = msg.sender; }
2,675
295
// no need to check allowance bc the contract == token
uint256 balancePrior = balanceOfInvestmentToken(); uint256 sharesToWithdraw = Math.min( _investmentTokenToYShares(_amountIT), yVault.balanceOf(address(this)) ); if (sharesToWithdraw == 0) { return 0; }
uint256 balancePrior = balanceOfInvestmentToken(); uint256 sharesToWithdraw = Math.min( _investmentTokenToYShares(_amountIT), yVault.balanceOf(address(this)) ); if (sharesToWithdraw == 0) { return 0; }
26,537
74
// Returns the lower bound for the maximum tokens that can be minted for this edition.return The configured value. /
function editionMaxMintableLower() external view returns (uint32);
function editionMaxMintableLower() external view returns (uint32);
33,518
176
// Returns the forwarder address stored on the contract.
function getForwarder() public view returns (address) { if (_forwarder == address(0)) { return Registry(registry).forwarder(); } return _forwarder; }
function getForwarder() public view returns (address) { if (_forwarder == address(0)) { return Registry(registry).forwarder(); } return _forwarder; }
19,221
22
// Returns the ClaimTopicsRegistry linked to the current IdentityRegistry. /
function topicsRegistry() external view returns (IClaimTopicsRegistry);
function topicsRegistry() external view returns (IClaimTopicsRegistry);
34,942
190
// constructor=========================================
constructor(address delegate) ERC721("RainCheck", "RC") { _delegate = delegate; }
constructor(address delegate) ERC721("RainCheck", "RC") { _delegate = delegate; }
50,022
9
// delete from project array
uint lastIndex = projects.length - 1; string memory lastProject = projects[lastIndex].project; uint lastAmount = projects[lastIndex].tokens;
uint lastIndex = projects.length - 1; string memory lastProject = projects[lastIndex].project; uint lastAmount = projects[lastIndex].tokens;
41,167
10
// // Emitted when hashed metadata config is set contractAddress Initial contract that emitted event hashedURIData Hashed uri data hashedRotationData Hashed rotation key _supply Supply of tokens to mint w/ reveal /
event HashedMetadataConfigSet(
event HashedMetadataConfigSet(
42,239
113
// Represents 100% base for commissions calculation
uint256 constant public COMMISSION_BASE = 10000;
uint256 constant public COMMISSION_BASE = 10000;
82,909
99
// In the weird case a player wins two jackpots, we of course pay them twice
ZlotsJackpotHoldingContract(zlotsJackpot).payOutWinner(target);
ZlotsJackpotHoldingContract(zlotsJackpot).payOutWinner(target);
82,343
23
// delete the last element
delete operators[operators.length - 1]; emit RemoveOperator(operator);
delete operators[operators.length - 1]; emit RemoveOperator(operator);
33,515
252
// Verify if sessionPubkeyHash was verified already, if not.. let's do it!
if (!provable_randomDS_sessionKeysHashVerified[sessionPubkeyHash]) { provable_randomDS_sessionKeysHashVerified[sessionPubkeyHash] = provable_randomDS_proofVerify__sessionKeyValidity(_proof, sig2offset); }
if (!provable_randomDS_sessionKeysHashVerified[sessionPubkeyHash]) { provable_randomDS_sessionKeysHashVerified[sessionPubkeyHash] = provable_randomDS_proofVerify__sessionKeyValidity(_proof, sig2offset); }
6,318
41
// invoke super function with requires
bool isTransferred = super.transfer(_to, _value); uint256 transferredClaims = dividendPayments[msg.sender].mul(_value).div(oldBalanceFrom); dividendPayments[msg.sender] = dividendPayments[msg.sender].sub(transferredClaims); dividendPayments[_to] = dividendPayments[_to].add(transferredClaims); return isTransferred;
bool isTransferred = super.transfer(_to, _value); uint256 transferredClaims = dividendPayments[msg.sender].mul(_value).div(oldBalanceFrom); dividendPayments[msg.sender] = dividendPayments[msg.sender].sub(transferredClaims); dividendPayments[_to] = dividendPayments[_to].add(transferredClaims); return isTransferred;
17,599
61
// 2-hours update
uint256 public lastUpdateHour; uint256 public updatePeriod; mapping(uint256 => uint112) public epochPrice;
uint256 public lastUpdateHour; uint256 public updatePeriod; mapping(uint256 => uint112) public epochPrice;
29,466
0
// Create a new ballot to choose one of 'candidateNames' startTime_ When the voting process will start endTime_ When the voting process will end /
constructor(uint256 startTime_, uint256 endTime_) { initializeCandidateDatabase_(); initializeVoterDatabase_(); votingStartTime = startTime_; votingEndTime = endTime_; electionChief = msg.sender; }
constructor(uint256 startTime_, uint256 endTime_) { initializeCandidateDatabase_(); initializeVoterDatabase_(); votingStartTime = startTime_; votingEndTime = endTime_; electionChief = msg.sender; }
18,147
76
// Keeps track of mint count with minimal overhead for tokenomics.
uint64 numberMinted;
uint64 numberMinted;
742
3
// Markets Features
struct MarketSettings { bool isExist; // Market is exist or not bool isActive; // Market is open for deposit or not uint256 borrowRate; uint256 borrowRateUpdateTime; uint256 suppliersShareRate; uint256 suppliersShareRateUpdateTime; uint256 promotionRate; }
struct MarketSettings { bool isExist; // Market is exist or not bool isActive; // Market is open for deposit or not uint256 borrowRate; uint256 borrowRateUpdateTime; uint256 suppliersShareRate; uint256 suppliersShareRateUpdateTime; uint256 promotionRate; }
8,858
104
// How many tokens one gets from a certain amount of ethereum.
function ethereumToTokens_(uint _ethereumAmount) public view returns(uint) { require(_ethereumAmount > MIN_ETH_BUYIN, "Tried to buy tokens with too little eth."); if (icoPhase) { return _ethereumAmount.div(tokenPriceInitial_) * 1e18; }
function ethereumToTokens_(uint _ethereumAmount) public view returns(uint) { require(_ethereumAmount > MIN_ETH_BUYIN, "Tried to buy tokens with too little eth."); if (icoPhase) { return _ethereumAmount.div(tokenPriceInitial_) * 1e18; }
3,657
45
// Then we update the payouts array for the buyer with this amount...
payouts[sender] += payoutDiff;
payouts[sender] += payoutDiff;
15,787
363
// Calculates how much token is provided per LP token
function _tokenPerShare(uint256 collected, uint256 tokenPerShareStored) internal view returns (uint256) { uint _totalSupply = totalSupply(); if (_totalSupply > 0) { return tokenPerShareStored .add( collected .mul(1e18) .unsafeDiv(_totalSupply) ); } return tokenPerShareStored; }
function _tokenPerShare(uint256 collected, uint256 tokenPerShareStored) internal view returns (uint256) { uint _totalSupply = totalSupply(); if (_totalSupply > 0) { return tokenPerShareStored .add( collected .mul(1e18) .unsafeDiv(_totalSupply) ); } return tokenPerShareStored; }
17,515
7
// Credits `account` with `amount` collateral Funds come from inside the product, not totals are updated Shortfall is created if more funds are debited from an account than exist self The struct to operate on account Account to credit collateral to amount Amount of collateral to creditreturn newShortfall Any new shortfall incurred during this settlement /
function settleAccount(OptimisticLedger storage self, address account, Fixed18 amount)
function settleAccount(OptimisticLedger storage self, address account, Fixed18 amount)
21,493
1
// Prefix the bytecode with a STOP opcode to ensure it cannot be called.
bytes memory runtimeCode = abi.encodePacked(hex"00", data); bytes memory creationCode = abi.encodePacked(
bytes memory runtimeCode = abi.encodePacked(hex"00", data); bytes memory creationCode = abi.encodePacked(
22,344
31
// Store withdrawal, which should be called when partial exit or full exit is verified
function addWithdraw(Operations.WithdrawNFTData calldata wd) external onlyZksCore { if (!wd.valid) { return; } L1Info memory info1 = infoMapL1[wd.globalId]; // Save L1 L2 mapping data if (info1.tokenContract == address(0x0)) { // first time withdraw if (wd.creatorId != 0) { // internal NFT: create new token info info1 = L1Info({ tokenContract: address(this), tokenId: wd.globalId }); } else { // external NFT: copy token info from externSeqIdMap info1 = externSeqIdMap[wd.seqId]; // validate external require(wd.seqId == infoMapL2[info1.tokenContract][info1.tokenId].seqId, "ZKSeaNFT: invalid seqId"); } // save mapping data infoMapL1[wd.globalId] = info1; L2Info storage info2 = infoMapL2[info1.tokenContract][info1.tokenId]; require(0 == info2.globalId && 0 == info2.creatorId, "ZKSeaNFT: invalid info2 state"); info2.globalId = wd.globalId; info2.creatorId = wd.creatorId; info2.seqId = wd.seqId; info2.isOnL2 = false; } else { // not first time withdraw infoMapL2[info1.tokenContract][info1.tokenId].isOnL2 = false; } // do withdraw if (wd.creatorId != 0) { // internal NFT: mint now mint(wd.target, wd.globalId, wd.uri); } else { // external NFT: prepare to withdraw if (wd.pendingWithdraw) { pendingWithdrawals[firstPendingWithdrawal + numOfPendingWithdrawals] = PendingWithdrawal(wd.target, wd.globalId); numOfPendingWithdrawals = numOfPendingWithdrawals + 1; } else { bytes28 key = packWithdrawKey(wd.target, wd.globalId); toWithdraw[key] = true; } } }
function addWithdraw(Operations.WithdrawNFTData calldata wd) external onlyZksCore { if (!wd.valid) { return; } L1Info memory info1 = infoMapL1[wd.globalId]; // Save L1 L2 mapping data if (info1.tokenContract == address(0x0)) { // first time withdraw if (wd.creatorId != 0) { // internal NFT: create new token info info1 = L1Info({ tokenContract: address(this), tokenId: wd.globalId }); } else { // external NFT: copy token info from externSeqIdMap info1 = externSeqIdMap[wd.seqId]; // validate external require(wd.seqId == infoMapL2[info1.tokenContract][info1.tokenId].seqId, "ZKSeaNFT: invalid seqId"); } // save mapping data infoMapL1[wd.globalId] = info1; L2Info storage info2 = infoMapL2[info1.tokenContract][info1.tokenId]; require(0 == info2.globalId && 0 == info2.creatorId, "ZKSeaNFT: invalid info2 state"); info2.globalId = wd.globalId; info2.creatorId = wd.creatorId; info2.seqId = wd.seqId; info2.isOnL2 = false; } else { // not first time withdraw infoMapL2[info1.tokenContract][info1.tokenId].isOnL2 = false; } // do withdraw if (wd.creatorId != 0) { // internal NFT: mint now mint(wd.target, wd.globalId, wd.uri); } else { // external NFT: prepare to withdraw if (wd.pendingWithdraw) { pendingWithdrawals[firstPendingWithdrawal + numOfPendingWithdrawals] = PendingWithdrawal(wd.target, wd.globalId); numOfPendingWithdrawals = numOfPendingWithdrawals + 1; } else { bytes28 key = packWithdrawKey(wd.target, wd.globalId); toWithdraw[key] = true; } } }
29,998
83
// === CONTROL FUNCTIONS === /
function addBurnAddress(address _address) external onlyOwner { uint8 _idx = _burnAddressExists(_address); require(_idx == 255, "ALREADY_EXISTS"); burnAddresses[_burnIdx] = _address; _burnIdx++; burnAddressCount++; }
function addBurnAddress(address _address) external onlyOwner { uint8 _idx = _burnAddressExists(_address); require(_idx == 255, "ALREADY_EXISTS"); burnAddresses[_burnIdx] = _address; _burnIdx++; burnAddressCount++; }
77,861
20
// ENS resolvers expect that the `key` for text queries is passed in via calldata. Until this is implemented in Solidity, we have to hand-pick the string out of the calldata ourself: https:github.com/ethereum/solidity/issues/13518 Here's the cleaner version once the above is implemented:(, string calldata key) = abi.decode(resolverCalldata[4:], (bytes32, string calldata)); Reminder: the text resolver signature is `text(bytes32 ensNode, string [calldata] key)` Offset math:- 4 bytes for the function selector for `text(bytes32,string)`- 32 bytes for the `ensNode` as bytes32- 32 bytes to encode the offset to start of data part of the dynamic string parameter (see https:docs.soliditylang.org/en/v0.8.20/abi-spec.htmluse-of-dynamic-types)- 32 bytes for the string's
uint256 keyLengthOffset = 4 + 32 + 32; uint256 keyOffset = keyLengthOffset + 32; uint256 keyLength = abi.decode(resolverCalldata[keyLengthOffset:], (uint256)); key = string(resolverCalldata[keyOffset:keyOffset + keyLength]);
uint256 keyLengthOffset = 4 + 32 + 32; uint256 keyOffset = keyLengthOffset + 32; uint256 keyLength = abi.decode(resolverCalldata[keyLengthOffset:], (uint256)); key = string(resolverCalldata[keyOffset:keyOffset + keyLength]);
24,246
71
// Current additionally assignable reward (RNB) of the user (depositor), meaning what wasn't added to UserInfo, but will be upon the next addToTheUsersAssignedReward() call (read only, does not save/alter state)
function calculateUsersAssignableReward() public view returns(uint256) { // --- // --- similar to addToTheUsersAssignedReward(), but without the writes, plus few other modifications // --- uint256 currentStakingDayNumber = getCurrentStakingDayNumber(); uint256 currentStakingDayNumberMinusOne = SafeMath.sub(currentStakingDayNumber, 1); if (currentStakingDayNumber == 0) { return 0; } UserInfo storage user = userInfo[msg.sender]; if (user.lptAmount == 0) { // user.rewardCountedUptoDay = currentStakingDayNumberMinusOne; // different from addToTheUsersAssignedReward return 0; // different from addToTheUsersAssignedReward } // --- uint256 rewardCountedUptoDay = user.rewardCountedUptoDay; uint256 rewardCountedUptoDayNextDay = SafeMath.add(rewardCountedUptoDay, 1); if (!(rewardCountedUptoDayNextDay <= currentStakingDayNumberMinusOne)) { return 0; // different from addToTheUsersAssignedReward } // --- uint256 usersRewardRecently = 0; for (uint256 i = rewardCountedUptoDayNextDay; i <= currentStakingDayNumberMinusOne; i++) { if (dailyTotalLptAmount[i] == 0) { continue; } // logic used here is because of integer division, we improve precision (not perfect solution, good enough) // (sample use 10^4 instead of 10^19 units) // 49.5k = users stake, 80k = total stake, 2k = daily reward) // correct value would be = 1237.5 // (49 500 / 80 000 = 0.61875 = 0) * 2000 = 0; // ((49 500 * 100) / 80 000 = 61,875 = 61) * 2000 = 122000) / 100 = 1220 = 1220 // ((49 500 * 1000) / 80 000 = 618,75 = 618) * 2000 = 1236000) / 1000 = 1236 = 1236 // ((49 500 * 10000) / 80 000 = 6187.5 = 6187) * 2000 = 12374000) / 10000 = 1237.4 = 1237 uint256 raiser = 10000000000000000000; // 10^19 // uint256 rew = (((user.lptAmount.mul(raiser)).div(dailyTotalLptAmount[i])).mul(dailyPlannedErc20RewardAmounts[i])).div(raiser); // with SafeMath: uint256 rew = SafeMath.mul(user.lptAmount, raiser); rew = SafeMath.div(rew, dailyTotalLptAmount[i]); rew = SafeMath.mul(rew, dailyPlannedErc20RewardAmounts[i]); rew = SafeMath.div(rew, raiser); if (dailyErc20RewardAmounts[i] < rew) { // the has to be added amount is less, than the remaining (global), can happen because of slight rounding issues at the very end // not really... more likely the oposite (that some small residue gets left behind) rew = dailyErc20RewardAmounts[i]; } usersRewardRecently = SafeMath.add(usersRewardRecently, rew); // dailyErc20RewardAmounts[i] = SafeMath.sub(dailyErc20RewardAmounts[i], rew); // different from addToTheUsersAssignedReward } // different from addToTheUsersAssignedReward // user.currentlyAssignedRewardAmount = SafeMath.add(user.currentlyAssignedRewardAmount, usersRewardRecently); // currentTotalErc20RewardAmount = SafeMath.sub(currentTotalErc20RewardAmount, usersRewardRecently); // user.rewardCountedUptoDay = currentStakingDayNumberMinusOne; // --- // --- // --- return usersRewardRecently; }
function calculateUsersAssignableReward() public view returns(uint256) { // --- // --- similar to addToTheUsersAssignedReward(), but without the writes, plus few other modifications // --- uint256 currentStakingDayNumber = getCurrentStakingDayNumber(); uint256 currentStakingDayNumberMinusOne = SafeMath.sub(currentStakingDayNumber, 1); if (currentStakingDayNumber == 0) { return 0; } UserInfo storage user = userInfo[msg.sender]; if (user.lptAmount == 0) { // user.rewardCountedUptoDay = currentStakingDayNumberMinusOne; // different from addToTheUsersAssignedReward return 0; // different from addToTheUsersAssignedReward } // --- uint256 rewardCountedUptoDay = user.rewardCountedUptoDay; uint256 rewardCountedUptoDayNextDay = SafeMath.add(rewardCountedUptoDay, 1); if (!(rewardCountedUptoDayNextDay <= currentStakingDayNumberMinusOne)) { return 0; // different from addToTheUsersAssignedReward } // --- uint256 usersRewardRecently = 0; for (uint256 i = rewardCountedUptoDayNextDay; i <= currentStakingDayNumberMinusOne; i++) { if (dailyTotalLptAmount[i] == 0) { continue; } // logic used here is because of integer division, we improve precision (not perfect solution, good enough) // (sample use 10^4 instead of 10^19 units) // 49.5k = users stake, 80k = total stake, 2k = daily reward) // correct value would be = 1237.5 // (49 500 / 80 000 = 0.61875 = 0) * 2000 = 0; // ((49 500 * 100) / 80 000 = 61,875 = 61) * 2000 = 122000) / 100 = 1220 = 1220 // ((49 500 * 1000) / 80 000 = 618,75 = 618) * 2000 = 1236000) / 1000 = 1236 = 1236 // ((49 500 * 10000) / 80 000 = 6187.5 = 6187) * 2000 = 12374000) / 10000 = 1237.4 = 1237 uint256 raiser = 10000000000000000000; // 10^19 // uint256 rew = (((user.lptAmount.mul(raiser)).div(dailyTotalLptAmount[i])).mul(dailyPlannedErc20RewardAmounts[i])).div(raiser); // with SafeMath: uint256 rew = SafeMath.mul(user.lptAmount, raiser); rew = SafeMath.div(rew, dailyTotalLptAmount[i]); rew = SafeMath.mul(rew, dailyPlannedErc20RewardAmounts[i]); rew = SafeMath.div(rew, raiser); if (dailyErc20RewardAmounts[i] < rew) { // the has to be added amount is less, than the remaining (global), can happen because of slight rounding issues at the very end // not really... more likely the oposite (that some small residue gets left behind) rew = dailyErc20RewardAmounts[i]; } usersRewardRecently = SafeMath.add(usersRewardRecently, rew); // dailyErc20RewardAmounts[i] = SafeMath.sub(dailyErc20RewardAmounts[i], rew); // different from addToTheUsersAssignedReward } // different from addToTheUsersAssignedReward // user.currentlyAssignedRewardAmount = SafeMath.add(user.currentlyAssignedRewardAmount, usersRewardRecently); // currentTotalErc20RewardAmount = SafeMath.sub(currentTotalErc20RewardAmount, usersRewardRecently); // user.rewardCountedUptoDay = currentStakingDayNumberMinusOne; // --- // --- // --- return usersRewardRecently; }
21,147
5
// DB for VoterRegistered & Proposals
mapping(address=>Voter) _Voters; // Mapping of voter's addresses Proposal[] _Proposals; // List of Proposals
mapping(address=>Voter) _Voters; // Mapping of voter's addresses Proposal[] _Proposals; // List of Proposals
48,421
328
// Transfer token to the beneficiary
else { TransferController controller = transferController(currency.ct, ""); (bool success,) = address(controller).delegatecall( abi.encodeWithSelector( controller.getApproveSignature(), address(beneficiary), uint256(transferable), currency.ct, currency.id ) ); require(success, "Approval by controller failed [RevenueFund.sol:274]"); beneficiary.receiveTokensTo(address(0), "", transferable, currency.ct, currency.id, "");
else { TransferController controller = transferController(currency.ct, ""); (bool success,) = address(controller).delegatecall( abi.encodeWithSelector( controller.getApproveSignature(), address(beneficiary), uint256(transferable), currency.ct, currency.id ) ); require(success, "Approval by controller failed [RevenueFund.sol:274]"); beneficiary.receiveTokensTo(address(0), "", transferable, currency.ct, currency.id, "");
11,492
307
// chance of burning the donor trait is a flat 1/3
if (rn.generate(1, 3) == 1) { donorBurnt = true; donor.genesis = false;
if (rn.generate(1, 3) == 1) { donorBurnt = true; donor.genesis = false;
3,269