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
|
---|---|---|---|---|
147 | // This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: ```soliditybytes32 digest = _hashTypedDataV4(keccak256(abi.encode(keccak256("Mail(address to,string contents)"),mailTo,keccak256(bytes(mailContents)))));address signer = ECDSA.recover(digest, signature);``` / | function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);
}
| function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);
}
| 12,266 |
22 | // See {ERC721-_safeTransferFrom}. | function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override(ERC721A) onlyAllowedOperator(from) {
super.safeTransferFrom(from, to, tokenId);
}
| function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override(ERC721A) onlyAllowedOperator(from) {
super.safeTransferFrom(from, to, tokenId);
}
| 38,552 |
584 | // Now approve this AMM update | update.validUntil = 0xffffffff;
bytes32 txHash = AmmUpdateTransaction.hashTx(ctx.exchangeDomainSeparator, update);
ctx.transactionBuffer.approveExchangeTransaction(address(this), txHash);
ctx.tokenBalancesL2[i] = update.balance;
| update.validUntil = 0xffffffff;
bytes32 txHash = AmmUpdateTransaction.hashTx(ctx.exchangeDomainSeparator, update);
ctx.transactionBuffer.approveExchangeTransaction(address(this), txHash);
ctx.tokenBalancesL2[i] = update.balance;
| 24,630 |
84 | // Global accounting | uint256 newStakingShareSeconds =
now
.sub(_lastAccountingTimestampSec)
.mul(_totalStakingShares);
_totalStakingShareSeconds = _totalStakingShareSeconds.add(newStakingShareSeconds);
_lastAccountingTimestampSec = now;
| uint256 newStakingShareSeconds =
now
.sub(_lastAccountingTimestampSec)
.mul(_totalStakingShares);
_totalStakingShareSeconds = _totalStakingShareSeconds.add(newStakingShareSeconds);
_lastAccountingTimestampSec = now;
| 5,179 |
0 | // cotract to use when issuing a CC (Local Currency)/_name string name for CC token that is created./_symbol string symbol for CC token that is created./_decimals uint8 percison for CC token that is created./_totalSupply uint256 total supply of the CC token that is created./_tokenURI string the URI may point to a JSON file that conforms to the "Metadata JSON Schema". | function ColuLocalCurrency(string _name, string _symbol, uint8 _decimals, uint256 _totalSupply, string _tokenURI) public {
require(_totalSupply != 0);
require(bytes(_name).length != 0);
require(bytes(_symbol).length != 0);
totalSupply = _totalSupply;
name = _name;
symbol = _symbol;
decimals = _decimals;
tokenURI = _tokenURI;
balances[msg.sender] = totalSupply;
}
| function ColuLocalCurrency(string _name, string _symbol, uint8 _decimals, uint256 _totalSupply, string _tokenURI) public {
require(_totalSupply != 0);
require(bytes(_name).length != 0);
require(bytes(_symbol).length != 0);
totalSupply = _totalSupply;
name = _name;
symbol = _symbol;
decimals = _decimals;
tokenURI = _tokenURI;
balances[msg.sender] = totalSupply;
}
| 25,718 |
38 | // Withdraw any token, including ether from this wallet to an EOA. _token The address of the token to withdraw. _amount The amount to withdraw.return Success of the withdrawal. / | function withdraw(address _token, uint256 _amount)
external
returns(bool)
| function withdraw(address _token, uint256 _amount)
external
returns(bool)
| 22,655 |
1 | // Calculate the strike amount equivalent to pay for the underlying requested | uint256 amountStrikeToTransfer = _strikeToTransfer(amount);
require(amountStrikeToTransfer > 0, "Amount too low");
| uint256 amountStrikeToTransfer = _strikeToTransfer(amount);
require(amountStrikeToTransfer > 0, "Amount too low");
| 2,065 |
22 | // See {IERC20-transferFrom}. Emits an {Approval} event indicating the updated allowance. This is notrequired by the EIP. See the note at the beginning of {ERC20}. NOTE: Does not update the allowance if the current allowanceis the maximum `uint256`. Requirements: - `from` and `to` cannot be the zero address.- `from` must have a balance of at least `tAmount`.- the caller must have allowance for ``from``'s tokens of at least`tAmount`. / | function transferFrom(address sender, address recipient, uint256 tAmount) public override returns (bool) {
__transfer(sender, recipient, tAmount);
__approve(
sender,
_msgSender(),
_allowances[sender][_msgSender()].sub(
tAmount,
"ERC20: transfer amount exceeds allowance"
)
);
| function transferFrom(address sender, address recipient, uint256 tAmount) public override returns (bool) {
__transfer(sender, recipient, tAmount);
__approve(
sender,
_msgSender(),
_allowances[sender][_msgSender()].sub(
tAmount,
"ERC20: transfer amount exceeds allowance"
)
);
| 30,799 |
2 | // Emitted when the hash of the asset generator is set. | event AssetGeneratorHashSet(bytes32 indexed assetGeneratorHash);
| event AssetGeneratorHashSet(bytes32 indexed assetGeneratorHash);
| 14,915 |
10 | // For safety | i+=1;
length++;
| i+=1;
length++;
| 35,557 |
176 | // Invoke call from manager_module Module to interact with _encodedEncoded byte data / | function invokeManager(address _module, bytes memory _encoded) internal {
manager.interactManager(_module, _encoded);
}
| function invokeManager(address _module, bytes memory _encoded) internal {
manager.interactManager(_module, _encoded);
}
| 29,396 |
29 | // We write the string from rightmost digit to leftmost digit. The following is essentially a do-while loop that also handles the zero case. | for {} 1 {} {
| for {} 1 {} {
| 13,055 |
13 | // -------------------------------------------------------------------------- FACTORY -------------------------------------------------------------------------- | function setFactoryToal(uint256 _value) public onlyContractsMiniGame
| function setFactoryToal(uint256 _value) public onlyContractsMiniGame
| 39,454 |
11 | // This contructor takes the msg.sender (deployer wallet) as the first master admin/ | constructor() internal {
level[msg.sender] = 2; //Set initial admin to contract creator
emit AdminshipUpdated(msg.sender,2);
}
| constructor() internal {
level[msg.sender] = 2; //Set initial admin to contract creator
emit AdminshipUpdated(msg.sender,2);
}
| 27,901 |
35 | // отправить прибыль на контракт собствеников системы | (bool success, ) = theStocksTokenContract.call.value(finaPlatformFee).gas(53000)("");
| (bool success, ) = theStocksTokenContract.call.value(finaPlatformFee).gas(53000)("");
| 12,243 |
9 | // Must match BConst.MIN_BOUND_TOKENS and BConst.MAX_BOUND_TOKENS | uint public constant MIN_ASSET_LIMIT = 2;
uint public constant MAX_ASSET_LIMIT = 8;
uint public constant MAX_UINT = uint(-1);
| uint public constant MIN_ASSET_LIMIT = 2;
uint public constant MAX_ASSET_LIMIT = 8;
uint public constant MAX_UINT = uint(-1);
| 47,035 |
49 | // Underlying asset for this CToken / | address public underlying;
| address public underlying;
| 13,070 |
173 | // Claims all accumulated redemption fees in 3CRV / | function claimRedemptionFee() external {
threeCrv.safeTransfer(feeRecipient, redemptionFees);
redemptionFees = 0;
}
| function claimRedemptionFee() external {
threeCrv.safeTransfer(feeRecipient, redemptionFees);
redemptionFees = 0;
}
| 33,166 |
8 | // object storing data about project for investors in community | bool exists;
uint256 apr; //interest rate for the project (in per thousand)
uint256 repaymentStartDate; //unix timestamp when repayment starts
uint256 repaymentEndDate; //unix timestamp when repayment is late
uint256 investmentNeeded; //total investment requirement in community currency to launch
uint256 investmentCount; // from index 1
mapping(address => InvestmentDetails) investmentDetails; // investor address => InvestmentDetails
| bool exists;
uint256 apr; //interest rate for the project (in per thousand)
uint256 repaymentStartDate; //unix timestamp when repayment starts
uint256 repaymentEndDate; //unix timestamp when repayment is late
uint256 investmentNeeded; //total investment requirement in community currency to launch
uint256 investmentCount; // from index 1
mapping(address => InvestmentDetails) investmentDetails; // investor address => InvestmentDetails
| 6,360 |
102 | // prevents non-authorized addresses from calling this method / | modifier validateAuthorizedSender()
| modifier validateAuthorizedSender()
| 84,014 |
224 | // Save Bid for this order | bidByOrderId[_nftAddress][_orderId] = Bid({
id: bidId,
bidder: msg.sender,
price: _priceInWei,
expiresAt: _expiresAt
});
| bidByOrderId[_nftAddress][_orderId] = Bid({
id: bidId,
bidder: msg.sender,
price: _priceInWei,
expiresAt: _expiresAt
});
| 21,872 |
445 | // Returns the average of two numbers. The result is rounded towardszero. / | function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow, so we distribute
return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);
}
| function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow, so we distribute
return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);
}
| 2,632 |
126 | // Event emitted when the reserves are reduced / | event ReservesReduced(address admin, uint reduceAmount, uint newTotalReserves);
| event ReservesReduced(address admin, uint reduceAmount, uint newTotalReserves);
| 12,731 |
1 | // function send(address recipient, uint256 amount, bytes memory data) public { super.send(recipient,amount,data); _addSlot(_msgSender()); } |
function getWinnerIndex() public view returns (uint256) {
uint256 winnerIndex = 0;
|
function getWinnerIndex() public view returns (uint256) {
uint256 winnerIndex = 0;
| 17,186 |
29 | // 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;
}
| 6,720 |
65 | // Fallback function for funding smart contract. / | function() external payable
| function() external payable
| 54,467 |
20 | // Get count of pending server key retrieval requests. | function serverKeyRetrievalRequestsCount() view external returns (uint256) {
return serverKeyRetrievalRequestsKeys.length;
}
| function serverKeyRetrievalRequestsCount() view external returns (uint256) {
return serverKeyRetrievalRequestsKeys.length;
}
| 42,977 |
21 | // Check if the computed hash (root) is equal to the provided root | return computedHash == root;
| return computedHash == root;
| 11,541 |
137 | // if (MSFun.multiSig(msData, required signatures, "functionName") == true) | * {
* MSFun.deleteProposal(msData, "functionName");
*
* // put function body here
* }
| * {
* MSFun.deleteProposal(msData, "functionName");
*
* // put function body here
* }
| 59,110 |
197 | // --- Offboarding: Current Liquidation Ratio --- | uint256 constant CURRENT_AAVE_MAT = 165 * RAY / 100;
uint256 constant CURRENT_BAL_MAT = 165 * RAY / 100;
uint256 constant CURRENT_COMP_MAT = 165 * RAY / 100;
| uint256 constant CURRENT_AAVE_MAT = 165 * RAY / 100;
uint256 constant CURRENT_BAL_MAT = 165 * RAY / 100;
uint256 constant CURRENT_COMP_MAT = 165 * RAY / 100;
| 21,502 |
21 | // Base exchange rate is set | uint256 public ratePerOneEther = 135;
uint256 public totalUBetCheckAmounts = 0;
| uint256 public ratePerOneEther = 135;
uint256 public totalUBetCheckAmounts = 0;
| 6,383 |
170 | // if (weiValue == 0) throw; | investedAmountOf[msg.sender] = 0;
weiRefunded = safeAdd(weiRefunded,weiValue);
Refund(msg.sender, weiValue);
require(msg.sender.send(weiValue));
| investedAmountOf[msg.sender] = 0;
weiRefunded = safeAdd(weiRefunded,weiValue);
Refund(msg.sender, weiValue);
require(msg.sender.send(weiValue));
| 16,849 |
160 | // return total USDC value of all collateral | return totalCollateral.div(1e18);
| return totalCollateral.div(1e18);
| 56,115 |
730 | // Updates the state variables when a position is increased. - Decreases the available amount in the lowest buckets with available token- Increases the principal amount in those buckets principalAddedAmount of principal added to the positionlentAmountAmount of owedToken lent / | function accountForIncrease(
uint256 principalAdded,
uint256 lentAmount
)
private
| function accountForIncrease(
uint256 principalAdded,
uint256 lentAmount
)
private
| 39,135 |
67 | // Decodes an order and returns the offer and substandard version.minimumReceived The minimum items that the caller must receive. context Context of the order according to SIP-12. / | function _decodeOrder(
SpentItem[] calldata minimumReceived,
bytes calldata context
| function _decodeOrder(
SpentItem[] calldata minimumReceived,
bytes calldata context
| 15,011 |
925 | // The full set of order components, with the exception of the counter, must be supplied when fulfilling more sophisticated orders or groups of orders. The total number of original consideration items must also be supplied, as the caller may specify additional consideration items. / | struct OrderParameters {
address offerer; // 0x00
address zone; // 0x20
OfferItem[] offer; // 0x40
ConsiderationItem[] consideration; // 0x60
OrderType orderType; // 0x80
uint256 startTime; // 0xa0
uint256 endTime; // 0xc0
bytes32 zoneHash; // 0xe0
uint256 salt; // 0x100
bytes32 conduitKey; // 0x120
uint256 totalOriginalConsiderationItems; // 0x140
// offer.length // 0x160
}
| struct OrderParameters {
address offerer; // 0x00
address zone; // 0x20
OfferItem[] offer; // 0x40
ConsiderationItem[] consideration; // 0x60
OrderType orderType; // 0x80
uint256 startTime; // 0xa0
uint256 endTime; // 0xc0
bytes32 zoneHash; // 0xe0
uint256 salt; // 0x100
bytes32 conduitKey; // 0x120
uint256 totalOriginalConsiderationItems; // 0x140
// offer.length // 0x160
}
| 23,826 |
148 | // Get the trait type / | function getTraitType(uint16 index)
private
pure
returns (string memory)
| function getTraitType(uint16 index)
private
pure
returns (string memory)
| 63,090 |
21 | // retrieve the size of the code on target address, this needs assembly | length := extcodesize(_addr)
| length := extcodesize(_addr)
| 50,716 |
209 | // lv3 | (_affIDNext, _comTmp) = updateAff(_pID, _affs, _affIDNext, affLv3_);
if (_comTmp > 0){
_com = (_com.add(_comTmp));
}
| (_affIDNext, _comTmp) = updateAff(_pID, _affs, _affIDNext, affLv3_);
if (_comTmp > 0){
_com = (_com.add(_comTmp));
}
| 22,292 |
27 | // OwnerManager - 管理一组所有者和执行操作的阈值。/Stefan George - <[email protected]> | contract OwnerManager is SelfAuthorized {
event AddedOwner(address owner);
event RemovedOwner(address owner);
event ChangedThreshold(uint256 threshold);
address internal constant SENTINEL_OWNERS = address(0x1);
mapping(address => address) internal owners;
uint256 internal ownerCount;
uint256 internal threshold;
/// @dev Setup function sets initial storage of contract.
/// @param _owners List of Safe owners.
/// @param _threshold Number of required confirmations for a Safe transaction.
function setupOwners(address[] memory _owners, uint256 _threshold) internal {
// Threshold can only be 0 at initialization.
// Check ensures that setup function can only be called once.
require(threshold == 0, "GS200");
// Validate that threshold is smaller than number of added owners.
require(_threshold <= _owners.length, "GS201");
// There has to be at least one Safe owner.
require(_threshold >= 1, "GS202");
// Initializing Safe owners.
address currentOwner = SENTINEL_OWNERS;
for (uint256 i = 0; i < _owners.length; i++) {
// Owner address cannot be null.
address owner = _owners[i];
require(owner != address(0) && owner != SENTINEL_OWNERS && owner != address(this) && currentOwner != owner, "GS203");
// No duplicate owners allowed.
require(owners[owner] == address(0), "GS204");
owners[currentOwner] = owner;
currentOwner = owner;
}
owners[currentOwner] = SENTINEL_OWNERS;
ownerCount = _owners.length;
threshold = _threshold;
}
/// @dev 允许将新所有者添加到保险箱并同时更新阈值。 这只能通过安全事务来完成。
/// @notice 将所有者 `owner` 添加到 Safe 并将阈值更新为 `_threshold`。
/// @param owner 新的所有者地址。
/// @param _threshold 新阈值
function addOwnerWithThreshold(address owner, uint256 _threshold) public authorized {
// 所有者地址不能为空,哨兵或保险箱本身。
require(owner != address(0) && owner != SENTINEL_OWNERS && owner != address(this), "GS203");
// 不允许重复所有者。
require(owners[owner] == address(0), "GS204");
owners[owner] = owners[SENTINEL_OWNERS];
owners[SENTINEL_OWNERS] = owner;
ownerCount++;
emit AddedOwner(owner);
// 如果阈值改变,则改变阈值。
if (threshold != _threshold) changeThreshold(_threshold);
}
/// @dev 允许从保险箱中删除所有者并同时更新阈值。 这只能通过安全事务来完成。
/// @notice 从 Safe 中删除所有者 `owner` 并将阈值更新为 `_threshold`。
/// @param prevOwner Owner 指向链表中要移除的所有者
/// @param owner 要移除的所有者地址。
/// @param _threshold 新阈值。
function removeOwner(
address prevOwner,
address owner,
uint256 _threshold
) public authorized {
// 如果仍然可以达到阈值,则只允许删除所有者。
require(ownerCount - 1 >= _threshold, "GS201");
// 验证所有者地址并检查它是否与所有者索引相对应。
require(owner != address(0) && owner != SENTINEL_OWNERS, "GS203");
require(owners[prevOwner] == owner, "GS205");
owners[prevOwner] = owners[owner];
owners[owner] = address(0);
ownerCount--;
emit RemovedOwner(owner);
// 如果阈值已更改,则更改阈值。
if (threshold != _threshold) changeThreshold(_threshold);
}
/// @dev 允许用另一个地址交换/替换保险箱中的所有者。 这只能通过安全事务来完成。
/// @notice 将保险箱中的所有者 `oldOwner` 替换为 `newOwner`。
/// @param prevOwner Owner 指向链表中要替换的所有者
/// @param oldOwner 要替换的所有者地址。
/// @param newOwner 新所有者地址。
function swapOwner(
address prevOwner,
address oldOwner,
address newOwner
) public authorized {
// 所有者地址不能为空,哨兵或保险箱本身。
require(newOwner != address(0) && newOwner != SENTINEL_OWNERS && newOwner != address(this), "GS203");
// 不允许重复所有者。
require(owners[newOwner] == address(0), "GS204");
// 验证 oldOwner 地址并检查它是否对应于所有者索引。
require(oldOwner != address(0) && oldOwner != SENTINEL_OWNERS, "GS203");
require(owners[prevOwner] == oldOwner, "GS205");
owners[newOwner] = owners[oldOwner];
owners[prevOwner] = newOwner;
owners[oldOwner] = address(0);
emit RemovedOwner(oldOwner);
emit AddedOwner(newOwner);
}
/// @dev 允许更新安全所有者所需的确认次数。 这只能通过安全事务来完成。
/// @notice 将 Safe 的阈值更改为 `_threshold`。
/// @param _threshold 新阈值。
function changeThreshold(uint256 _threshold) public authorized {
// 验证阈值小于所有者数。
require(_threshold <= ownerCount, "GS201");
// 必须至少有一个保险箱所有者。
require(_threshold >= 1, "GS202");
threshold = _threshold;
emit ChangedThreshold(threshold);
}
function getThreshold() public view returns (uint256) {
return threshold;
}
function isOwner(address owner) public view returns (bool) {
return owner != SENTINEL_OWNERS && owners[owner] != address(0);
}
/// @dev 返回所有者数组。
/// @return 安全所有者数组。
function getOwners() public view returns (address[] memory) {
address[] memory array = new address[](ownerCount);
uint256 index = 0;
address currentOwner = owners[SENTINEL_OWNERS];
while (currentOwner != SENTINEL_OWNERS) {
array[index] = currentOwner;
currentOwner = owners[currentOwner];
index++;
}
return array;
}
}
| contract OwnerManager is SelfAuthorized {
event AddedOwner(address owner);
event RemovedOwner(address owner);
event ChangedThreshold(uint256 threshold);
address internal constant SENTINEL_OWNERS = address(0x1);
mapping(address => address) internal owners;
uint256 internal ownerCount;
uint256 internal threshold;
/// @dev Setup function sets initial storage of contract.
/// @param _owners List of Safe owners.
/// @param _threshold Number of required confirmations for a Safe transaction.
function setupOwners(address[] memory _owners, uint256 _threshold) internal {
// Threshold can only be 0 at initialization.
// Check ensures that setup function can only be called once.
require(threshold == 0, "GS200");
// Validate that threshold is smaller than number of added owners.
require(_threshold <= _owners.length, "GS201");
// There has to be at least one Safe owner.
require(_threshold >= 1, "GS202");
// Initializing Safe owners.
address currentOwner = SENTINEL_OWNERS;
for (uint256 i = 0; i < _owners.length; i++) {
// Owner address cannot be null.
address owner = _owners[i];
require(owner != address(0) && owner != SENTINEL_OWNERS && owner != address(this) && currentOwner != owner, "GS203");
// No duplicate owners allowed.
require(owners[owner] == address(0), "GS204");
owners[currentOwner] = owner;
currentOwner = owner;
}
owners[currentOwner] = SENTINEL_OWNERS;
ownerCount = _owners.length;
threshold = _threshold;
}
/// @dev 允许将新所有者添加到保险箱并同时更新阈值。 这只能通过安全事务来完成。
/// @notice 将所有者 `owner` 添加到 Safe 并将阈值更新为 `_threshold`。
/// @param owner 新的所有者地址。
/// @param _threshold 新阈值
function addOwnerWithThreshold(address owner, uint256 _threshold) public authorized {
// 所有者地址不能为空,哨兵或保险箱本身。
require(owner != address(0) && owner != SENTINEL_OWNERS && owner != address(this), "GS203");
// 不允许重复所有者。
require(owners[owner] == address(0), "GS204");
owners[owner] = owners[SENTINEL_OWNERS];
owners[SENTINEL_OWNERS] = owner;
ownerCount++;
emit AddedOwner(owner);
// 如果阈值改变,则改变阈值。
if (threshold != _threshold) changeThreshold(_threshold);
}
/// @dev 允许从保险箱中删除所有者并同时更新阈值。 这只能通过安全事务来完成。
/// @notice 从 Safe 中删除所有者 `owner` 并将阈值更新为 `_threshold`。
/// @param prevOwner Owner 指向链表中要移除的所有者
/// @param owner 要移除的所有者地址。
/// @param _threshold 新阈值。
function removeOwner(
address prevOwner,
address owner,
uint256 _threshold
) public authorized {
// 如果仍然可以达到阈值,则只允许删除所有者。
require(ownerCount - 1 >= _threshold, "GS201");
// 验证所有者地址并检查它是否与所有者索引相对应。
require(owner != address(0) && owner != SENTINEL_OWNERS, "GS203");
require(owners[prevOwner] == owner, "GS205");
owners[prevOwner] = owners[owner];
owners[owner] = address(0);
ownerCount--;
emit RemovedOwner(owner);
// 如果阈值已更改,则更改阈值。
if (threshold != _threshold) changeThreshold(_threshold);
}
/// @dev 允许用另一个地址交换/替换保险箱中的所有者。 这只能通过安全事务来完成。
/// @notice 将保险箱中的所有者 `oldOwner` 替换为 `newOwner`。
/// @param prevOwner Owner 指向链表中要替换的所有者
/// @param oldOwner 要替换的所有者地址。
/// @param newOwner 新所有者地址。
function swapOwner(
address prevOwner,
address oldOwner,
address newOwner
) public authorized {
// 所有者地址不能为空,哨兵或保险箱本身。
require(newOwner != address(0) && newOwner != SENTINEL_OWNERS && newOwner != address(this), "GS203");
// 不允许重复所有者。
require(owners[newOwner] == address(0), "GS204");
// 验证 oldOwner 地址并检查它是否对应于所有者索引。
require(oldOwner != address(0) && oldOwner != SENTINEL_OWNERS, "GS203");
require(owners[prevOwner] == oldOwner, "GS205");
owners[newOwner] = owners[oldOwner];
owners[prevOwner] = newOwner;
owners[oldOwner] = address(0);
emit RemovedOwner(oldOwner);
emit AddedOwner(newOwner);
}
/// @dev 允许更新安全所有者所需的确认次数。 这只能通过安全事务来完成。
/// @notice 将 Safe 的阈值更改为 `_threshold`。
/// @param _threshold 新阈值。
function changeThreshold(uint256 _threshold) public authorized {
// 验证阈值小于所有者数。
require(_threshold <= ownerCount, "GS201");
// 必须至少有一个保险箱所有者。
require(_threshold >= 1, "GS202");
threshold = _threshold;
emit ChangedThreshold(threshold);
}
function getThreshold() public view returns (uint256) {
return threshold;
}
function isOwner(address owner) public view returns (bool) {
return owner != SENTINEL_OWNERS && owners[owner] != address(0);
}
/// @dev 返回所有者数组。
/// @return 安全所有者数组。
function getOwners() public view returns (address[] memory) {
address[] memory array = new address[](ownerCount);
uint256 index = 0;
address currentOwner = owners[SENTINEL_OWNERS];
while (currentOwner != SENTINEL_OWNERS) {
array[index] = currentOwner;
currentOwner = owners[currentOwner];
index++;
}
return array;
}
}
| 20,627 |
114 | // Records which users have contributed throughout the sale | mapping(address => bool) public hasContributed;
DisbursementHandler public disbursementHandler;
uint256 public weiContributed = 0;
uint256 public totalSaleCap;
uint256 public minContribution;
uint256 public minThreshold;
| mapping(address => bool) public hasContributed;
DisbursementHandler public disbursementHandler;
uint256 public weiContributed = 0;
uint256 public totalSaleCap;
uint256 public minContribution;
uint256 public minThreshold;
| 20,035 |
25 | // Internal function that burns an amount of the token of a givenaccount. account The account whose tokens will be burnt. value The amount that will be burnt. / | function _burn(address account, uint256 value) internal {
require(account != 0);
require(value <= _balances[account]);
_totalSupply = _totalSupply.sub(value);
_balances[account] = _balances[account].sub(value);
emit Transfer(account, address(0), value);
}
| function _burn(address account, uint256 value) internal {
require(account != 0);
require(value <= _balances[account]);
_totalSupply = _totalSupply.sub(value);
_balances[account] = _balances[account].sub(value);
emit Transfer(account, address(0), value);
}
| 29,324 |
23 | // get the last index of participant from the current auction Participant[] storage participants = auctionParticipants[_id]; | uint256 lastBidAmount = auction.participant[auction.participant.length - 1].bidRecords;
| uint256 lastBidAmount = auction.participant[auction.participant.length - 1].bidRecords;
| 15,151 |
101 | // Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit ofexchange. The royalty amount is denominated and should be paid in that same unit of exchange. / | function royaltyInfo(
uint256 tokenId,
uint256 salePrice
) external view returns (address receiver, uint256 royaltyAmount);
| function royaltyInfo(
uint256 tokenId,
uint256 salePrice
) external view returns (address receiver, uint256 royaltyAmount);
| 8,932 |
26 | // Initializer // Initializer Fee-on-transfer currency tokens are not supported / | function initialize(
uint64 auctionDuration_,
uint64 timeExtensionWindow_,
uint64 timeExtension_,
uint64 minimumBidBasisPoints_
| function initialize(
uint64 auctionDuration_,
uint64 timeExtensionWindow_,
uint64 timeExtension_,
uint64 minimumBidBasisPoints_
| 13,451 |
50 | // contracts/interfaces/IDebtLockerFactory.sol/ pragma solidity 0.6.11; / | interface IDebtLockerFactory {
function owner(address) external view returns (address);
function isLocker(address) external view returns (bool);
function factoryType() external view returns (uint8);
function newLocker(address) external returns (address);
}
| interface IDebtLockerFactory {
function owner(address) external view returns (address);
function isLocker(address) external view returns (bool);
function factoryType() external view returns (uint8);
function newLocker(address) external returns (address);
}
| 20,820 |
2 | // Owners voting mask per operations | mapping(bytes32 => uint256) public votesMaskByOperation;
mapping(bytes32 => uint256) public votesCountByOperation;
| mapping(bytes32 => uint256) public votesMaskByOperation;
mapping(bytes32 => uint256) public votesCountByOperation;
| 39,415 |
1,389 | // Both minInvestmentAmount and maxInvestmentAmount can be 0 in order to close the fund temporarily | if (minInvestmentAmount == 0) {
return _investmentAmount <= maxInvestmentAmount;
} else if (maxInvestmentAmount == 0) {
| if (minInvestmentAmount == 0) {
return _investmentAmount <= maxInvestmentAmount;
} else if (maxInvestmentAmount == 0) {
| 44,646 |
37 | // Safe IERC20 and ETH transfer library that safely handles missing return values./Modified from Uniswap (https:github.com/Uniswap/uniswap-v3-periphery/blob/main/contracts/libraries/TransferHelper.sol)/ Taken from Solmate | library SafeERC20 {
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 amount
) internal {
(bool success, bytes memory data) = address(token).call(
abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, amount)
);
require(success && (data.length == 0 || abi.decode(data, (bool))), "TRANSFER_FROM_FAILED");
}
function safeTransfer(
IERC20 token,
address to,
uint256 amount
) internal {
(bool success, bytes memory data) = address(token).call(
abi.encodeWithSelector(IERC20.transfer.selector, to, amount)
);
require(success && (data.length == 0 || abi.decode(data, (bool))), "TRANSFER_FAILED");
}
function safeApprove(
IERC20 token,
address to,
uint256 amount
) internal {
(bool success, bytes memory data) = address(token).call(
abi.encodeWithSelector(IERC20.approve.selector, to, amount)
);
require(success && (data.length == 0 || abi.decode(data, (bool))), "APPROVE_FAILED");
}
function safeTransferETH(address to, uint256 amount) internal {
(bool success, ) = to.call{value: amount}(new bytes(0));
require(success, "ETH_TRANSFER_FAILED");
}
}
| library SafeERC20 {
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 amount
) internal {
(bool success, bytes memory data) = address(token).call(
abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, amount)
);
require(success && (data.length == 0 || abi.decode(data, (bool))), "TRANSFER_FROM_FAILED");
}
function safeTransfer(
IERC20 token,
address to,
uint256 amount
) internal {
(bool success, bytes memory data) = address(token).call(
abi.encodeWithSelector(IERC20.transfer.selector, to, amount)
);
require(success && (data.length == 0 || abi.decode(data, (bool))), "TRANSFER_FAILED");
}
function safeApprove(
IERC20 token,
address to,
uint256 amount
) internal {
(bool success, bytes memory data) = address(token).call(
abi.encodeWithSelector(IERC20.approve.selector, to, amount)
);
require(success && (data.length == 0 || abi.decode(data, (bool))), "APPROVE_FAILED");
}
function safeTransferETH(address to, uint256 amount) internal {
(bool success, ) = to.call{value: amount}(new bytes(0));
require(success, "ETH_TRANSFER_FAILED");
}
}
| 46,650 |
63 | // Helper function that checks for ERC777TokensRecipient on the recipient and calls it./May throw according to `_preventLocking`/_operator The address performing the send or mint/_from The address holding the tokens being sent/_to The address of the recipient/_amount The number of tokens to be sent/_userData Data generated by the user to be passed to the recipient/_operatorData Data generated by the operator to be passed to the recipient/_preventLocking `true` if you want this function to throw when tokens are sent to a contract not/implementing `ERC777TokensRecipient`./ERC777 native Send functions MUST set this parameter to `true`, and backwards compatible ERC20 transfer/functions SHOULD set this parameter to | function callRecipient(
address _operator,
address _from,
address _to,
uint256 _amount,
bytes _userData,
bytes _operatorData,
bool _preventLocking
)
internal
| function callRecipient(
address _operator,
address _from,
address _to,
uint256 _amount,
bytes _userData,
bytes _operatorData,
bool _preventLocking
)
internal
| 2,427 |
93 | // Store the updated total supply. | sstore(_TOTAL_SUPPLY_SLOT, totalSupplyAfter)
| sstore(_TOTAL_SUPPLY_SLOT, totalSupplyAfter)
| 1,201 |
721 | // Calculate the denominator for the composition polynomial columns: x - z^2. | let denominator := add(shiftedEvalPoint, minusPointPow)
mstore(add(productsPtr, 0xf20), partialProduct)
mstore(add(valuesPtr, 0xf20), denominator)
partialProduct := mulmod(partialProduct, denominator, PRIME)
| let denominator := add(shiftedEvalPoint, minusPointPow)
mstore(add(productsPtr, 0xf20), partialProduct)
mstore(add(valuesPtr, 0xf20), denominator)
partialProduct := mulmod(partialProduct, denominator, PRIME)
| 77,869 |
329 | // Get exact amounts for base ticks | (cache.amount0, cache.amount1) = pool.amountsForLiquidity(cache.liquidity, cache.tickLower, cache.tickUpper);
| (cache.amount0, cache.amount1) = pool.amountsForLiquidity(cache.liquidity, cache.tickLower, cache.tickUpper);
| 37,902 |
186 | // Emits a {Withdraw} event.//yieldToken The address of the yield token to withdraw./ownerThe address of the account owner to withdraw from./shares The number of shares to burn./recipientThe recipient of the withdrawn shares. This parameter is only used for logging.// return The amount of yield tokens that the burned shares were exchanged for. | function _withdraw(
address yieldToken,
address owner,
uint256 shares,
address recipient
) internal returns (uint256) {
| function _withdraw(
address yieldToken,
address owner,
uint256 shares,
address recipient
) internal returns (uint256) {
| 44,811 |
192 | // no-op if the passed next value isn't greater than the current next value | if (next <= current) return current;
| if (next <= current) return current;
| 2,492 |
310 | // Check if the farmer's health is greater than zero | if (farmerHealth[tokenId] > 0) {
uint256 damage = (uint256(keccak256(abi.encodePacked(block.timestamp, msg.sender))) % (maxDamage - 10)) + 10;
if (farmerHealth[tokenId] > damage) {
farmerHealth[tokenId] -= damage;
} else {
| if (farmerHealth[tokenId] > 0) {
uint256 damage = (uint256(keccak256(abi.encodePacked(block.timestamp, msg.sender))) % (maxDamage - 10)) + 10;
if (farmerHealth[tokenId] > damage) {
farmerHealth[tokenId] -= damage;
} else {
| 19,817 |
21 | // BT_SPAE: staking pool already exists | require(!stakingPools.contains(_stakingPool), "BT_SPAE");
stakingPools.add(_stakingPool);
emit StakingPoolAdded(_stakingPool);
| require(!stakingPools.contains(_stakingPool), "BT_SPAE");
stakingPools.add(_stakingPool);
emit StakingPoolAdded(_stakingPool);
| 20,960 |
10 | // Standard ERC223 function that will handle incoming token transfers._fromToken sender address. _value Amount of tokens. _dataTransaction metadata. / | function tokenFallback(address _from, uint _value, bytes _data) public pure {
TKN memory tkn;
tkn.sender = _from;
tkn.value = _value;
tkn.data = _data;
if(_data.length > 0) {
uint32 u = uint32(_data[3]) + (uint32(_data[2]) << 8) + (uint32(_data[1]) << 16) + (uint32(_data[0]) << 24);
tkn.sig = bytes4(u);
}
/* tkn variable is analogue of msg variable of Ether transaction
* tkn.sender is person who initiated this token transaction (analogue of msg.sender)
* tkn.value the number of tokens that were sent (analogue of msg.value)
* tkn.data is data of token transaction (analogue of msg.data)
* tkn.sig is 4 bytes signature of function
* if data of token transaction is a function execution
*/
}
| function tokenFallback(address _from, uint _value, bytes _data) public pure {
TKN memory tkn;
tkn.sender = _from;
tkn.value = _value;
tkn.data = _data;
if(_data.length > 0) {
uint32 u = uint32(_data[3]) + (uint32(_data[2]) << 8) + (uint32(_data[1]) << 16) + (uint32(_data[0]) << 24);
tkn.sig = bytes4(u);
}
/* tkn variable is analogue of msg variable of Ether transaction
* tkn.sender is person who initiated this token transaction (analogue of msg.sender)
* tkn.value the number of tokens that were sent (analogue of msg.value)
* tkn.data is data of token transaction (analogue of msg.data)
* tkn.sig is 4 bytes signature of function
* if data of token transaction is a function execution
*/
}
| 24,647 |
23 | // Set new token address/_newTokenAddress - Address of new erc20 token. | function setTokenAddress(address _newTokenAddress)
external
onlyMarketManger
| function setTokenAddress(address _newTokenAddress)
external
onlyMarketManger
| 21,408 |
81 | // Extended TPL Jurisdiction Interface. this extends BasicJurisdictionInterface for additional functionality. / | interface ExtendedJurisdictionInterface {
// declare events (NOTE: consider which fields should be indexed)
event ValidatorSigningKeyModified(
address indexed validator,
address newSigningKey
);
event StakeAllocated(
address indexed staker,
uint256 indexed attribute,
uint256 amount
);
event StakeRefunded(
address indexed staker,
uint256 indexed attribute,
uint256 amount
);
event FeePaid(
address indexed recipient,
address indexed payee,
uint256 indexed attribute,
uint256 amount
);
event TransactionRebatePaid(
address indexed submitter,
address indexed payee,
uint256 indexed attribute,
uint256 amount
);
/**
* @notice Add a restricted attribute type with ID `ID` and description
* `description` to the jurisdiction. Restricted attribute types can only be
* removed by the issuing validator or the jurisdiction.
* @param ID uint256 The ID of the restricted attribute type to add.
* @param description string A description of the restricted attribute type.
* @dev Once an attribute type is added with a given ID, the description or the
* restricted status of the attribute type cannot be changed, even if the
* attribute type is removed and added back later.
*/
function addRestrictedAttributeType(uint256 ID, string description) external;
/**
* @notice Enable or disable a restriction for a given attribute type ID `ID`
* that prevents attributes of the given type from being set by operators based
* on the provided value for `onlyPersonal`.
* @param ID uint256 The attribute type ID in question.
* @param onlyPersonal bool Whether the address may only be set personally.
*/
function setAttributeTypeOnlyPersonal(uint256 ID, bool onlyPersonal) external;
/**
* @notice Set a secondary source for a given attribute type ID `ID`, with an
* address `registry` of the secondary source in question and a given
* `sourceAttributeTypeID` for attribute type ID to check on the secondary
* source. The secondary source will only be checked for the given attribute in
* cases where no attribute of the given attribute type ID is assigned locally.
* @param ID uint256 The attribute type ID to set the secondary source for.
* @param attributeRegistry address The secondary attribute registry account.
* @param sourceAttributeTypeID uint256 The attribute type ID on the secondary
* source to check.
* @dev To remove a secondary source on an attribute type, the registry address
* should be set to the null address.
*/
function setAttributeTypeSecondarySource(
uint256 ID,
address attributeRegistry,
uint256 sourceAttributeTypeID
) external;
/**
* @notice Set a minimum required stake for a given attribute type ID `ID` and
* an amount of `stake`, to be locked in the jurisdiction upon assignment of
* attributes of the given type. The stake will be applied toward a transaction
* rebate in the event the attribute is revoked, with the remainder returned to
* the staker.
* @param ID uint256 The attribute type ID to set a minimum required stake for.
* @param minimumRequiredStake uint256 The minimum required funds to lock up.
* @dev To remove a stake requirement from an attribute type, the stake amount
* should be set to 0.
*/
function setAttributeTypeMinimumRequiredStake(
uint256 ID,
uint256 minimumRequiredStake
) external;
/**
* @notice Set a required fee for a given attribute type ID `ID` and an amount
* of `fee`, to be paid to the owner of the jurisdiction upon assignment of
* attributes of the given type.
* @param ID uint256 The attribute type ID to set the required fee for.
* @param fee uint256 The required fee amount to be paid upon assignment.
* @dev To remove a fee requirement from an attribute type, the fee amount
* should be set to 0.
*/
function setAttributeTypeJurisdictionFee(uint256 ID, uint256 fee) external;
/**
* @notice Set the public address associated with a validator signing key, used
* to sign off-chain attribute approvals, as `newSigningKey`.
* @param newSigningKey address The address associated with signing key to set.
*/
function setValidatorSigningKey(address newSigningKey) external;
/**
* @notice Add an attribute of the type with ID `attributeTypeID`, an attribute
* value of `value`, and an associated validator fee of `validatorFee` to
* account of `msg.sender` by passing in a signed attribute approval with
* signature `signature`.
* @param attributeTypeID uint256 The ID of the attribute type to add.
* @param value uint256 The value for the attribute to add.
* @param validatorFee uint256 The fee to be paid to the issuing validator.
* @param signature bytes The signature from the validator attribute approval.
*/
function addAttribute(
uint256 attributeTypeID,
uint256 value,
uint256 validatorFee,
bytes signature
) external payable;
/**
* @notice Remove an attribute of the type with ID `attributeTypeID` from
* account of `msg.sender`.
* @param attributeTypeID uint256 The ID of the attribute type to remove.
*/
function removeAttribute(uint256 attributeTypeID) external;
/**
* @notice Add an attribute of the type with ID `attributeTypeID`, an attribute
* value of `value`, and an associated validator fee of `validatorFee` to
* account `account` by passing in a signed attribute approval with signature
* `signature`.
* @param account address The account to add the attribute to.
* @param attributeTypeID uint256 The ID of the attribute type to add.
* @param value uint256 The value for the attribute to add.
* @param validatorFee uint256 The fee to be paid to the issuing validator.
* @param signature bytes The signature from the validator attribute approval.
* @dev Restricted attribute types can only be removed by issuing validators or
* the jurisdiction itself.
*/
function addAttributeFor(
address account,
uint256 attributeTypeID,
uint256 value,
uint256 validatorFee,
bytes signature
) external payable;
/**
* @notice Remove an attribute of the type with ID `attributeTypeID` from
* account of `account`.
* @param account address The account to remove the attribute from.
* @param attributeTypeID uint256 The ID of the attribute type to remove.
* @dev Restricted attribute types can only be removed by issuing validators or
* the jurisdiction itself.
*/
function removeAttributeFor(address account, uint256 attributeTypeID) external;
/**
* @notice Invalidate a signed attribute approval before it has been set by
* supplying the hash of the approval `hash` and the signature `signature`.
* @param hash bytes32 The hash of the attribute approval.
* @param signature bytes The hash's signature, resolving to the signing key.
* @dev Attribute approvals can only be removed by issuing validators or the
* jurisdiction itself.
*/
function invalidateAttributeApproval(
bytes32 hash,
bytes signature
) external;
/**
* @notice Get the hash of a given attribute approval.
* @param account address The account specified by the attribute approval.
* @param operator address An optional account permitted to submit approval.
* @param attributeTypeID uint256 The ID of the attribute type in question.
* @param value uint256 The value of the attribute in the approval.
* @param fundsRequired uint256 The amount to be included with the approval.
* @param validatorFee uint256 The required fee to be paid to the validator.
* @return The hash of the attribute approval.
*/
function getAttributeApprovalHash(
address account,
address operator,
uint256 attributeTypeID,
uint256 value,
uint256 fundsRequired,
uint256 validatorFee
) external view returns (bytes32 hash);
/**
* @notice Check if a given signed attribute approval is currently valid when
* submitted directly by `msg.sender`.
* @param attributeTypeID uint256 The ID of the attribute type in question.
* @param value uint256 The value of the attribute in the approval.
* @param fundsRequired uint256 The amount to be included with the approval.
* @param validatorFee uint256 The required fee to be paid to the validator.
* @param signature bytes The attribute approval signature, based on a hash of
* the other parameters and the submitting account.
* @return True if the approval is currently valid, false otherwise.
*/
function canAddAttribute(
uint256 attributeTypeID,
uint256 value,
uint256 fundsRequired,
uint256 validatorFee,
bytes signature
) external view returns (bool);
/**
* @notice Check if a given signed attribute approval is currently valid for a
* given account when submitted by the operator at `msg.sender`.
* @param account address The account specified by the attribute approval.
* @param attributeTypeID uint256 The ID of the attribute type in question.
* @param value uint256 The value of the attribute in the approval.
* @param fundsRequired uint256 The amount to be included with the approval.
* @param validatorFee uint256 The required fee to be paid to the validator.
* @param signature bytes The attribute approval signature, based on a hash of
* the other parameters and the submitting account.
* @return True if the approval is currently valid, false otherwise.
*/
function canAddAttributeFor(
address account,
uint256 attributeTypeID,
uint256 value,
uint256 fundsRequired,
uint256 validatorFee,
bytes signature
) external view returns (bool);
/**
* @notice Get comprehensive information on an attribute type with ID
* `attributeTypeID`.
* @param attributeTypeID uint256 The attribute type ID in question.
* @return Information on the attribute type in question.
*/
function getAttributeTypeInformation(
uint256 attributeTypeID
) external view returns (
string description,
bool isRestricted,
bool isOnlyPersonal,
address secondarySource,
uint256 secondaryId,
uint256 minimumRequiredStake,
uint256 jurisdictionFee
);
/**
* @notice Get a validator's signing key.
* @param validator address The account of the validator.
* @return The account referencing the public component of the signing key.
*/
function getValidatorSigningKey(
address validator
) external view returns (
address signingKey
);
}
| interface ExtendedJurisdictionInterface {
// declare events (NOTE: consider which fields should be indexed)
event ValidatorSigningKeyModified(
address indexed validator,
address newSigningKey
);
event StakeAllocated(
address indexed staker,
uint256 indexed attribute,
uint256 amount
);
event StakeRefunded(
address indexed staker,
uint256 indexed attribute,
uint256 amount
);
event FeePaid(
address indexed recipient,
address indexed payee,
uint256 indexed attribute,
uint256 amount
);
event TransactionRebatePaid(
address indexed submitter,
address indexed payee,
uint256 indexed attribute,
uint256 amount
);
/**
* @notice Add a restricted attribute type with ID `ID` and description
* `description` to the jurisdiction. Restricted attribute types can only be
* removed by the issuing validator or the jurisdiction.
* @param ID uint256 The ID of the restricted attribute type to add.
* @param description string A description of the restricted attribute type.
* @dev Once an attribute type is added with a given ID, the description or the
* restricted status of the attribute type cannot be changed, even if the
* attribute type is removed and added back later.
*/
function addRestrictedAttributeType(uint256 ID, string description) external;
/**
* @notice Enable or disable a restriction for a given attribute type ID `ID`
* that prevents attributes of the given type from being set by operators based
* on the provided value for `onlyPersonal`.
* @param ID uint256 The attribute type ID in question.
* @param onlyPersonal bool Whether the address may only be set personally.
*/
function setAttributeTypeOnlyPersonal(uint256 ID, bool onlyPersonal) external;
/**
* @notice Set a secondary source for a given attribute type ID `ID`, with an
* address `registry` of the secondary source in question and a given
* `sourceAttributeTypeID` for attribute type ID to check on the secondary
* source. The secondary source will only be checked for the given attribute in
* cases where no attribute of the given attribute type ID is assigned locally.
* @param ID uint256 The attribute type ID to set the secondary source for.
* @param attributeRegistry address The secondary attribute registry account.
* @param sourceAttributeTypeID uint256 The attribute type ID on the secondary
* source to check.
* @dev To remove a secondary source on an attribute type, the registry address
* should be set to the null address.
*/
function setAttributeTypeSecondarySource(
uint256 ID,
address attributeRegistry,
uint256 sourceAttributeTypeID
) external;
/**
* @notice Set a minimum required stake for a given attribute type ID `ID` and
* an amount of `stake`, to be locked in the jurisdiction upon assignment of
* attributes of the given type. The stake will be applied toward a transaction
* rebate in the event the attribute is revoked, with the remainder returned to
* the staker.
* @param ID uint256 The attribute type ID to set a minimum required stake for.
* @param minimumRequiredStake uint256 The minimum required funds to lock up.
* @dev To remove a stake requirement from an attribute type, the stake amount
* should be set to 0.
*/
function setAttributeTypeMinimumRequiredStake(
uint256 ID,
uint256 minimumRequiredStake
) external;
/**
* @notice Set a required fee for a given attribute type ID `ID` and an amount
* of `fee`, to be paid to the owner of the jurisdiction upon assignment of
* attributes of the given type.
* @param ID uint256 The attribute type ID to set the required fee for.
* @param fee uint256 The required fee amount to be paid upon assignment.
* @dev To remove a fee requirement from an attribute type, the fee amount
* should be set to 0.
*/
function setAttributeTypeJurisdictionFee(uint256 ID, uint256 fee) external;
/**
* @notice Set the public address associated with a validator signing key, used
* to sign off-chain attribute approvals, as `newSigningKey`.
* @param newSigningKey address The address associated with signing key to set.
*/
function setValidatorSigningKey(address newSigningKey) external;
/**
* @notice Add an attribute of the type with ID `attributeTypeID`, an attribute
* value of `value`, and an associated validator fee of `validatorFee` to
* account of `msg.sender` by passing in a signed attribute approval with
* signature `signature`.
* @param attributeTypeID uint256 The ID of the attribute type to add.
* @param value uint256 The value for the attribute to add.
* @param validatorFee uint256 The fee to be paid to the issuing validator.
* @param signature bytes The signature from the validator attribute approval.
*/
function addAttribute(
uint256 attributeTypeID,
uint256 value,
uint256 validatorFee,
bytes signature
) external payable;
/**
* @notice Remove an attribute of the type with ID `attributeTypeID` from
* account of `msg.sender`.
* @param attributeTypeID uint256 The ID of the attribute type to remove.
*/
function removeAttribute(uint256 attributeTypeID) external;
/**
* @notice Add an attribute of the type with ID `attributeTypeID`, an attribute
* value of `value`, and an associated validator fee of `validatorFee` to
* account `account` by passing in a signed attribute approval with signature
* `signature`.
* @param account address The account to add the attribute to.
* @param attributeTypeID uint256 The ID of the attribute type to add.
* @param value uint256 The value for the attribute to add.
* @param validatorFee uint256 The fee to be paid to the issuing validator.
* @param signature bytes The signature from the validator attribute approval.
* @dev Restricted attribute types can only be removed by issuing validators or
* the jurisdiction itself.
*/
function addAttributeFor(
address account,
uint256 attributeTypeID,
uint256 value,
uint256 validatorFee,
bytes signature
) external payable;
/**
* @notice Remove an attribute of the type with ID `attributeTypeID` from
* account of `account`.
* @param account address The account to remove the attribute from.
* @param attributeTypeID uint256 The ID of the attribute type to remove.
* @dev Restricted attribute types can only be removed by issuing validators or
* the jurisdiction itself.
*/
function removeAttributeFor(address account, uint256 attributeTypeID) external;
/**
* @notice Invalidate a signed attribute approval before it has been set by
* supplying the hash of the approval `hash` and the signature `signature`.
* @param hash bytes32 The hash of the attribute approval.
* @param signature bytes The hash's signature, resolving to the signing key.
* @dev Attribute approvals can only be removed by issuing validators or the
* jurisdiction itself.
*/
function invalidateAttributeApproval(
bytes32 hash,
bytes signature
) external;
/**
* @notice Get the hash of a given attribute approval.
* @param account address The account specified by the attribute approval.
* @param operator address An optional account permitted to submit approval.
* @param attributeTypeID uint256 The ID of the attribute type in question.
* @param value uint256 The value of the attribute in the approval.
* @param fundsRequired uint256 The amount to be included with the approval.
* @param validatorFee uint256 The required fee to be paid to the validator.
* @return The hash of the attribute approval.
*/
function getAttributeApprovalHash(
address account,
address operator,
uint256 attributeTypeID,
uint256 value,
uint256 fundsRequired,
uint256 validatorFee
) external view returns (bytes32 hash);
/**
* @notice Check if a given signed attribute approval is currently valid when
* submitted directly by `msg.sender`.
* @param attributeTypeID uint256 The ID of the attribute type in question.
* @param value uint256 The value of the attribute in the approval.
* @param fundsRequired uint256 The amount to be included with the approval.
* @param validatorFee uint256 The required fee to be paid to the validator.
* @param signature bytes The attribute approval signature, based on a hash of
* the other parameters and the submitting account.
* @return True if the approval is currently valid, false otherwise.
*/
function canAddAttribute(
uint256 attributeTypeID,
uint256 value,
uint256 fundsRequired,
uint256 validatorFee,
bytes signature
) external view returns (bool);
/**
* @notice Check if a given signed attribute approval is currently valid for a
* given account when submitted by the operator at `msg.sender`.
* @param account address The account specified by the attribute approval.
* @param attributeTypeID uint256 The ID of the attribute type in question.
* @param value uint256 The value of the attribute in the approval.
* @param fundsRequired uint256 The amount to be included with the approval.
* @param validatorFee uint256 The required fee to be paid to the validator.
* @param signature bytes The attribute approval signature, based on a hash of
* the other parameters and the submitting account.
* @return True if the approval is currently valid, false otherwise.
*/
function canAddAttributeFor(
address account,
uint256 attributeTypeID,
uint256 value,
uint256 fundsRequired,
uint256 validatorFee,
bytes signature
) external view returns (bool);
/**
* @notice Get comprehensive information on an attribute type with ID
* `attributeTypeID`.
* @param attributeTypeID uint256 The attribute type ID in question.
* @return Information on the attribute type in question.
*/
function getAttributeTypeInformation(
uint256 attributeTypeID
) external view returns (
string description,
bool isRestricted,
bool isOnlyPersonal,
address secondarySource,
uint256 secondaryId,
uint256 minimumRequiredStake,
uint256 jurisdictionFee
);
/**
* @notice Get a validator's signing key.
* @param validator address The account of the validator.
* @return The account referencing the public component of the signing key.
*/
function getValidatorSigningKey(
address validator
) external view returns (
address signingKey
);
}
| 42,353 |
206 | // Swaps tokens using Uniswap V3 from Token to swap from to Token to swap to amount Amount of tokens to swap slippage Allowed slippage path Steps to complete the swapreturn result Amount of underlying (`to`) tokens recieved / | function _swapV3(
IERC20 from,
IERC20 to,
uint256 amount,
uint256 slippage,
bytes memory path
| function _swapV3(
IERC20 from,
IERC20 to,
uint256 amount,
uint256 slippage,
bytes memory path
| 65,151 |
35 | // attempted to update or end staking for an nft without an active season | error NoActiveStakingSeason(address nft);
| error NoActiveStakingSeason(address nft);
| 6,082 |
45 | // If the amount being transfered is more than the balance of theaccount the transfer reverts | var previousBalanceFrom = balanceOf(from);
require(previousBalanceFrom >= amount);
| var previousBalanceFrom = balanceOf(from);
require(previousBalanceFrom >= amount);
| 14,410 |
10 | // Because the default division is rounded,And we need the exact hour | uint256 h = current / 1 hours;
if (h * 1 hours > current) {
h = h - 1;
}
| uint256 h = current / 1 hours;
if (h * 1 hours > current) {
h = h - 1;
}
| 50,922 |
12 | // Gets the amount of Entities in the collection/ | function getEntityCount
(
)
external
view
returns(
uint256 entityCount
)
| function getEntityCount
(
)
external
view
returns(
uint256 entityCount
)
| 47,198 |
12 | // Returns the addition of two unsigned integers, reverting onoverflow. Counterpart to Solidity's `+` operator. Requirements: - Addition cannot overflow. / | function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, 'SafeMath: addition overflow');
return c;
}
| function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, 'SafeMath: addition overflow');
return c;
}
| 1,910 |
2 | // string private constant _NAME = ' PausableAccessControl: '; |
bytes32 public constant PAUSER_ROLE = keccak256("ACCESS_CONTROL.PAUSER_ROLE");
constructor(
)internal
AccessControl()
Pausable()
|
bytes32 public constant PAUSER_ROLE = keccak256("ACCESS_CONTROL.PAUSER_ROLE");
constructor(
)internal
AccessControl()
Pausable()
| 26,810 |
4 | // Employee must have started payee The destination address of the funds. / | function withdrawalAllowed(address payee) public view returns (bool);
| function withdrawalAllowed(address payee) public view returns (bool);
| 24,624 |
14 | // Add token values as coins to the machine | coins[msg.sender] = coins[msg.sender].add(_tokenAmount);
| coins[msg.sender] = coins[msg.sender].add(_tokenAmount);
| 13,658 |
28 | // halt the crowdsale should any suspicious behavior of a third-party be identified tokens will be locked for trading until they are listed on exchanges | bool public haltICO = false;
bool public setTrading = false;
| bool public haltICO = false;
bool public setTrading = false;
| 48,556 |
61 | // Performs the power on a specified value, reverts on overflow./ | function safePower(
uint256 a,
uint256 pow
)
internal
pure
returns (uint256)
| function safePower(
uint256 a,
uint256 pow
)
internal
pure
returns (uint256)
| 23,139 |
236 | // The buyer pays fees. | _payFees(sellOrder, msg.sender, buyAmount, orderInfo.orderAmount, false);
| _payFees(sellOrder, msg.sender, buyAmount, orderInfo.orderAmount, false);
| 2,585 |
89 | // if (ownerPetitionSignerArrayCreated[msg.sender][_petitionId] == 0) { |
uint id = petitionsigners.push(PetitionSigner(_petitionId, msg.sender, now)) - 1;
emit NewPetitionSigner(id, _petitionId, msg.sender, now);
petitionSignerMap[msg.sender][_petitionId] = id;
ownerPetitionSignerArrayCreated[msg.sender][_petitionId] = 1;
petitions[_petitionId].totalSignatures = petitions[_petitionId].totalSignatures + 1;
|
uint id = petitionsigners.push(PetitionSigner(_petitionId, msg.sender, now)) - 1;
emit NewPetitionSigner(id, _petitionId, msg.sender, now);
petitionSignerMap[msg.sender][_petitionId] = id;
ownerPetitionSignerArrayCreated[msg.sender][_petitionId] = 1;
petitions[_petitionId].totalSignatures = petitions[_petitionId].totalSignatures + 1;
| 43,223 |
2 | // Event that will be emitted whenever the project starter has received the funds | event CreatorPaid(address recipient);
| event CreatorPaid(address recipient);
| 50,015 |
33 | // Node detail getters | function getNodeAddress() override external view returns (address) { return nodeAddress; }
| function getNodeAddress() override external view returns (address) { return nodeAddress; }
| 57,350 |
113 | // Get the Governance address | function getGovernanceAddress() external view returns (address) {
_requireIsInitialized();
return governanceAddress;
}
| function getGovernanceAddress() external view returns (address) {
_requireIsInitialized();
return governanceAddress;
}
| 17,924 |
21 | // Gets the ETHUSD pair from the Medianizer contractreturn The pair as an uint256 / | function getEthUsdPair() internal view returns (uint256) {
bytes32 pair = _medianizer.read();
return uint256(pair);
}
| function getEthUsdPair() internal view returns (uint256) {
bytes32 pair = _medianizer.read();
return uint256(pair);
}
| 20,538 |
18 | // Get current price and tick from the pool | ( uint160 sqrtPriceX96, int24 currentTick, , , , , ) = pool.slot0();
| ( uint160 sqrtPriceX96, int24 currentTick, , , , , ) = pool.slot0();
| 21,312 |
46 | // method to get if a voting portal is approved by the governance votingPortal address of the voting portal to check if approvedreturn flag indicating the approval status of the voting portal / | function isVotingPortalApproved(
| function isVotingPortalApproved(
| 9,311 |
104 | // 1. main contract will transfer TUBE to this contract 2. update the total reward amount for current session/ | uint conclude_session = session_id;
uint reward_amount = ITubeChief(tube_chief).transferJackpotReward();
session[conclude_session].total_reward = session[conclude_session].total_reward.add(reward_amount);
session[conclude_session].can_claim = true;
session_id = session_id.add(1);
if (!stop_next_session) {
_startPot();
}
| uint conclude_session = session_id;
uint reward_amount = ITubeChief(tube_chief).transferJackpotReward();
session[conclude_session].total_reward = session[conclude_session].total_reward.add(reward_amount);
session[conclude_session].can_claim = true;
session_id = session_id.add(1);
if (!stop_next_session) {
_startPot();
}
| 45,364 |
52 | // Sets approved amount of tokens for spender. Returns success/spender Address of allowed account/value Number of approved tokens/ return Was approval successful? | function approve(address spender, uint value)
public
returns (bool)
| function approve(address spender, uint value)
public
returns (bool)
| 42,603 |
484 | // Rewards stakers on purchase of cover on smart contract. _contractAddress smart contract address. _coverPriceNXM cover price in NXM. / | function pushStakerRewards(address _contractAddress, uint _coverPriceNXM) external onlyInternal {
uint rewardValue = _coverPriceNXM.mul(td.stakerCommissionPer()).div(100);
pooledStaking.accumulateReward(_contractAddress, rewardValue);
}
| function pushStakerRewards(address _contractAddress, uint _coverPriceNXM) external onlyInternal {
uint rewardValue = _coverPriceNXM.mul(td.stakerCommissionPer()).div(100);
pooledStaking.accumulateReward(_contractAddress, rewardValue);
}
| 2,037 |
67 | // Restore the free memory pointer. | mstore(FreeMemoryPointerSlot, freeMemoryPointer)
| mstore(FreeMemoryPointerSlot, freeMemoryPointer)
| 32,830 |
6 | // The publisher is the inital owner / | function Ownership() public {
owner = msg.sender;
}
| function Ownership() public {
owner = msg.sender;
}
| 32,859 |
168 | // Adds stake to a relay and sets its `unstakeDelay`. If the relay does not exist, it is created, and the callerof this function becomes its owner. If the relay already exists, only the owner can call this function. A relaycannot be its own owner. All Ether in this function call will be added to the relay's stake.Its unstake delay will be assigned to `unstakeDelay`, but the new value must be greater or equal to the current one. | * Emits a {Staked} event.
*/
function stake(address relayaddr, uint256 unstakeDelay) external payable;
/**
* @dev Emitted when a relay's stake or unstakeDelay are increased
*/
event Staked(address indexed relay, uint256 stake, uint256 unstakeDelay);
/**
* @dev Registers the caller as a relay.
* The relay must be staked for, and not be a contract (i.e. this function must be called directly from an EOA).
*
* This function can be called multiple times, emitting new {RelayAdded} events. Note that the received
* `transactionFee` is not enforced by {relayCall}.
*
* Emits a {RelayAdded} event.
*/
function registerRelay(uint256 transactionFee, string calldata url) external;
/**
* @dev Emitted when a relay is registered or re-registerd. Looking at these events (and filtering out
* {RelayRemoved} events) lets a client discover the list of available relays.
*/
event RelayAdded(address indexed relay, address indexed owner, uint256 transactionFee, uint256 stake, uint256 unstakeDelay, string url);
/**
* @dev Removes (deregisters) a relay. Unregistered (but staked for) relays can also be removed.
*
* Can only be called by the owner of the relay. After the relay's `unstakeDelay` has elapsed, {unstake} will be
* callable.
*
* Emits a {RelayRemoved} event.
*/
function removeRelayByOwner(address relay) external;
/**
* @dev Emitted when a relay is removed (deregistered). `unstakeTime` is the time when unstake will be callable.
*/
event RelayRemoved(address indexed relay, uint256 unstakeTime);
/** Deletes the relay from the system, and gives back its stake to the owner.
*
* Can only be called by the relay owner, after `unstakeDelay` has elapsed since {removeRelayByOwner} was called.
*
* Emits an {Unstaked} event.
*/
function unstake(address relay) external;
/**
* @dev Emitted when a relay is unstaked for, including the returned stake.
*/
event Unstaked(address indexed relay, uint256 stake);
// States a relay can be in
enum RelayState {
Unknown, // The relay is unknown to the system: it has never been staked for
Staked, // The relay has been staked for, but it is not yet active
Registered, // The relay has registered itself, and is active (can relay calls)
Removed // The relay has been removed by its owner and can no longer relay calls. It must wait for its unstakeDelay to elapse before it can unstake
}
| * Emits a {Staked} event.
*/
function stake(address relayaddr, uint256 unstakeDelay) external payable;
/**
* @dev Emitted when a relay's stake or unstakeDelay are increased
*/
event Staked(address indexed relay, uint256 stake, uint256 unstakeDelay);
/**
* @dev Registers the caller as a relay.
* The relay must be staked for, and not be a contract (i.e. this function must be called directly from an EOA).
*
* This function can be called multiple times, emitting new {RelayAdded} events. Note that the received
* `transactionFee` is not enforced by {relayCall}.
*
* Emits a {RelayAdded} event.
*/
function registerRelay(uint256 transactionFee, string calldata url) external;
/**
* @dev Emitted when a relay is registered or re-registerd. Looking at these events (and filtering out
* {RelayRemoved} events) lets a client discover the list of available relays.
*/
event RelayAdded(address indexed relay, address indexed owner, uint256 transactionFee, uint256 stake, uint256 unstakeDelay, string url);
/**
* @dev Removes (deregisters) a relay. Unregistered (but staked for) relays can also be removed.
*
* Can only be called by the owner of the relay. After the relay's `unstakeDelay` has elapsed, {unstake} will be
* callable.
*
* Emits a {RelayRemoved} event.
*/
function removeRelayByOwner(address relay) external;
/**
* @dev Emitted when a relay is removed (deregistered). `unstakeTime` is the time when unstake will be callable.
*/
event RelayRemoved(address indexed relay, uint256 unstakeTime);
/** Deletes the relay from the system, and gives back its stake to the owner.
*
* Can only be called by the relay owner, after `unstakeDelay` has elapsed since {removeRelayByOwner} was called.
*
* Emits an {Unstaked} event.
*/
function unstake(address relay) external;
/**
* @dev Emitted when a relay is unstaked for, including the returned stake.
*/
event Unstaked(address indexed relay, uint256 stake);
// States a relay can be in
enum RelayState {
Unknown, // The relay is unknown to the system: it has never been staked for
Staked, // The relay has been staked for, but it is not yet active
Registered, // The relay has registered itself, and is active (can relay calls)
Removed // The relay has been removed by its owner and can no longer relay calls. It must wait for its unstakeDelay to elapse before it can unstake
}
| 21,275 |
26 | // Performs a generic transaction. _target The address for the transaction. _data The data of the transaction.Mostly copied from Argent: / | function _invoke(address _target, bytes memory _data) internal returns (bytes memory) {
// External contracts can be compiled with different Solidity versions
// which can cause "revert without reason" when called through,
// for example, a standard IERC20 ABI compiled on the latest version.
// This low-level call avoids that issue.
bool success;
bytes memory _res;
// solhint-disable-next-line avoid-low-level-calls
(success, _res) = _target.call(_data);
if (!success && _res.length > 0) {
// solhint-disable-next-line no-inline-assembly
assembly {
returndatacopy(0, 0, returndatasize())
revert(0, returndatasize())
}
} else if (!success) {
revert("VM: wallet _invoke reverted");
}
return _res;
}
| function _invoke(address _target, bytes memory _data) internal returns (bytes memory) {
// External contracts can be compiled with different Solidity versions
// which can cause "revert without reason" when called through,
// for example, a standard IERC20 ABI compiled on the latest version.
// This low-level call avoids that issue.
bool success;
bytes memory _res;
// solhint-disable-next-line avoid-low-level-calls
(success, _res) = _target.call(_data);
if (!success && _res.length > 0) {
// solhint-disable-next-line no-inline-assembly
assembly {
returndatacopy(0, 0, returndatasize())
revert(0, returndatasize())
}
} else if (!success) {
revert("VM: wallet _invoke reverted");
}
return _res;
}
| 34 |
110 | // affiliate | if(isAffiliate){
address child=msg.sender;
for(uint256 i=0; i<affiliateLevel; i++){
uint256 giftToken=affiliateRate[i].mul(tokens).div(100);
address parent = referral[child];
if(parent != address(0x00)){//has affiliate
referralBalance[child]=referralBalance[child].add(giftToken);
}
| if(isAffiliate){
address child=msg.sender;
for(uint256 i=0; i<affiliateLevel; i++){
uint256 giftToken=affiliateRate[i].mul(tokens).div(100);
address parent = referral[child];
if(parent != address(0x00)){//has affiliate
referralBalance[child]=referralBalance[child].add(giftToken);
}
| 3,594 |
83 | // This is an alternative to {approve} that can be used as a mitigation forproblems described in {BEP20-approve}. 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`. / |
function decreaseAllowance(address spender, uint256 subtractedValue)
public
returns (bool)
{
_approve(
_msgSender(),
spender,
_allowances[_msgSender()][spender].sub(
subtractedValue,
|
function decreaseAllowance(address spender, uint256 subtractedValue)
public
returns (bool)
{
_approve(
_msgSender(),
spender,
_allowances[_msgSender()][spender].sub(
subtractedValue,
| 23,612 |
9 | // Withdraw accumulated balance, called by payee./ | function withdrawPayments() public {
address payee = msg.sender;
uint256 payment = payments[payee];
require(payment != 0);
require(address(this).balance >= payment);
totalPayments = totalPayments.sub(payment);
payments[payee] = 0;
payee.transfer(payment);
}
| function withdrawPayments() public {
address payee = msg.sender;
uint256 payment = payments[payee];
require(payment != 0);
require(address(this).balance >= payment);
totalPayments = totalPayments.sub(payment);
payments[payee] = 0;
payee.transfer(payment);
}
| 17,712 |
61 | // Mints `tokenId` and transfers it to `to`. | * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_holderTokens[to].add(tokenId);
_tokenOwners.set(tokenId, to);
emit Transfer(address(0), to, tokenId);
}
| * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_holderTokens[to].add(tokenId);
_tokenOwners.set(tokenId, to);
emit Transfer(address(0), to, tokenId);
}
| 299 |
10 | // computes e ^ (x / FIXED_1)FIXED_1input range: 0 <= x <= OPT_EXP_MAX_VAL - 1auto-generated via 'PrintFunctionOptimalExp.py'Detailed description:- Rewrite the input as a sum of binary exponents and a single residual r, as small as possible- The exponentiation of each binary exponent is given (pre-calculated)- The exponentiation of r is calculated via Taylor series for e^x, where x = r- The exponentiation of the input is calculated by multiplying the intermediate results above- For example: e^5.521692859 = e^(4 + 1 + 0.5 + 0.021692859) = e^4e^1e^0.5e^0.021692859 / | function optimalExp(uint256 x) public pure returns (uint256) {
uint256 res = 0;
uint256 y;
uint256 z;
z = y = x % 0x10000000000000000000000000000000; // get the input modulo 2^(-3)
z = (z * y) / FIXED_1;
res += z * 0x10e1b3be415a0000; // add y^02 * (20! / 02!)
z = (z * y) / FIXED_1;
res += z * 0x05a0913f6b1e0000; // add y^03 * (20! / 03!)
z = (z * y) / FIXED_1;
res += z * 0x0168244fdac78000; // add y^04 * (20! / 04!)
z = (z * y) / FIXED_1;
res += z * 0x004807432bc18000; // add y^05 * (20! / 05!)
z = (z * y) / FIXED_1;
res += z * 0x000c0135dca04000; // add y^06 * (20! / 06!)
z = (z * y) / FIXED_1;
res += z * 0x0001b707b1cdc000; // add y^07 * (20! / 07!)
z = (z * y) / FIXED_1;
res += z * 0x000036e0f639b800; // add y^08 * (20! / 08!)
z = (z * y) / FIXED_1;
res += z * 0x00000618fee9f800; // add y^09 * (20! / 09!)
z = (z * y) / FIXED_1;
res += z * 0x0000009c197dcc00; // add y^10 * (20! / 10!)
z = (z * y) / FIXED_1;
res += z * 0x0000000e30dce400; // add y^11 * (20! / 11!)
z = (z * y) / FIXED_1;
res += z * 0x000000012ebd1300; // add y^12 * (20! / 12!)
z = (z * y) / FIXED_1;
res += z * 0x0000000017499f00; // add y^13 * (20! / 13!)
z = (z * y) / FIXED_1;
res += z * 0x0000000001a9d480; // add y^14 * (20! / 14!)
z = (z * y) / FIXED_1;
res += z * 0x00000000001c6380; // add y^15 * (20! / 15!)
z = (z * y) / FIXED_1;
res += z * 0x000000000001c638; // add y^16 * (20! / 16!)
z = (z * y) / FIXED_1;
res += z * 0x0000000000001ab8; // add y^17 * (20! / 17!)
z = (z * y) / FIXED_1;
res += z * 0x000000000000017c; // add y^18 * (20! / 18!)
z = (z * y) / FIXED_1;
res += z * 0x0000000000000014; // add y^19 * (20! / 19!)
z = (z * y) / FIXED_1;
res += z * 0x0000000000000001; // add y^20 * (20! / 20!)
res = res / 0x21c3677c82b40000 + y + FIXED_1; // divide by 20! and then add y^1 / 1! + y^0 / 0!
if ((x & 0x010000000000000000000000000000000) != 0)
res = (res * 0x1c3d6a24ed82218787d624d3e5eba95f9) / 0x18ebef9eac820ae8682b9793ac6d1e776; // multiply by e^2^(-3)
if ((x & 0x020000000000000000000000000000000) != 0)
res = (res * 0x18ebef9eac820ae8682b9793ac6d1e778) / 0x1368b2fc6f9609fe7aceb46aa619baed4; // multiply by e^2^(-2)
if ((x & 0x040000000000000000000000000000000) != 0)
res = (res * 0x1368b2fc6f9609fe7aceb46aa619baed5) / 0x0bc5ab1b16779be3575bd8f0520a9f21f; // multiply by e^2^(-1)
if ((x & 0x080000000000000000000000000000000) != 0)
res = (res * 0x0bc5ab1b16779be3575bd8f0520a9f21e) / 0x0454aaa8efe072e7f6ddbab84b40a55c9; // multiply by e^2^(+0)
if ((x & 0x100000000000000000000000000000000) != 0)
res = (res * 0x0454aaa8efe072e7f6ddbab84b40a55c5) / 0x00960aadc109e7a3bf4578099615711ea; // multiply by e^2^(+1)
if ((x & 0x200000000000000000000000000000000) != 0)
res = (res * 0x00960aadc109e7a3bf4578099615711d7) / 0x0002bf84208204f5977f9a8cf01fdce3d; // multiply by e^2^(+2)
if ((x & 0x400000000000000000000000000000000) != 0)
res = (res * 0x0002bf84208204f5977f9a8cf01fdc307) / 0x0000003c6ab775dd0b95b4cbee7e65d11; // multiply by e^2^(+3)
return res;
}
| function optimalExp(uint256 x) public pure returns (uint256) {
uint256 res = 0;
uint256 y;
uint256 z;
z = y = x % 0x10000000000000000000000000000000; // get the input modulo 2^(-3)
z = (z * y) / FIXED_1;
res += z * 0x10e1b3be415a0000; // add y^02 * (20! / 02!)
z = (z * y) / FIXED_1;
res += z * 0x05a0913f6b1e0000; // add y^03 * (20! / 03!)
z = (z * y) / FIXED_1;
res += z * 0x0168244fdac78000; // add y^04 * (20! / 04!)
z = (z * y) / FIXED_1;
res += z * 0x004807432bc18000; // add y^05 * (20! / 05!)
z = (z * y) / FIXED_1;
res += z * 0x000c0135dca04000; // add y^06 * (20! / 06!)
z = (z * y) / FIXED_1;
res += z * 0x0001b707b1cdc000; // add y^07 * (20! / 07!)
z = (z * y) / FIXED_1;
res += z * 0x000036e0f639b800; // add y^08 * (20! / 08!)
z = (z * y) / FIXED_1;
res += z * 0x00000618fee9f800; // add y^09 * (20! / 09!)
z = (z * y) / FIXED_1;
res += z * 0x0000009c197dcc00; // add y^10 * (20! / 10!)
z = (z * y) / FIXED_1;
res += z * 0x0000000e30dce400; // add y^11 * (20! / 11!)
z = (z * y) / FIXED_1;
res += z * 0x000000012ebd1300; // add y^12 * (20! / 12!)
z = (z * y) / FIXED_1;
res += z * 0x0000000017499f00; // add y^13 * (20! / 13!)
z = (z * y) / FIXED_1;
res += z * 0x0000000001a9d480; // add y^14 * (20! / 14!)
z = (z * y) / FIXED_1;
res += z * 0x00000000001c6380; // add y^15 * (20! / 15!)
z = (z * y) / FIXED_1;
res += z * 0x000000000001c638; // add y^16 * (20! / 16!)
z = (z * y) / FIXED_1;
res += z * 0x0000000000001ab8; // add y^17 * (20! / 17!)
z = (z * y) / FIXED_1;
res += z * 0x000000000000017c; // add y^18 * (20! / 18!)
z = (z * y) / FIXED_1;
res += z * 0x0000000000000014; // add y^19 * (20! / 19!)
z = (z * y) / FIXED_1;
res += z * 0x0000000000000001; // add y^20 * (20! / 20!)
res = res / 0x21c3677c82b40000 + y + FIXED_1; // divide by 20! and then add y^1 / 1! + y^0 / 0!
if ((x & 0x010000000000000000000000000000000) != 0)
res = (res * 0x1c3d6a24ed82218787d624d3e5eba95f9) / 0x18ebef9eac820ae8682b9793ac6d1e776; // multiply by e^2^(-3)
if ((x & 0x020000000000000000000000000000000) != 0)
res = (res * 0x18ebef9eac820ae8682b9793ac6d1e778) / 0x1368b2fc6f9609fe7aceb46aa619baed4; // multiply by e^2^(-2)
if ((x & 0x040000000000000000000000000000000) != 0)
res = (res * 0x1368b2fc6f9609fe7aceb46aa619baed5) / 0x0bc5ab1b16779be3575bd8f0520a9f21f; // multiply by e^2^(-1)
if ((x & 0x080000000000000000000000000000000) != 0)
res = (res * 0x0bc5ab1b16779be3575bd8f0520a9f21e) / 0x0454aaa8efe072e7f6ddbab84b40a55c9; // multiply by e^2^(+0)
if ((x & 0x100000000000000000000000000000000) != 0)
res = (res * 0x0454aaa8efe072e7f6ddbab84b40a55c5) / 0x00960aadc109e7a3bf4578099615711ea; // multiply by e^2^(+1)
if ((x & 0x200000000000000000000000000000000) != 0)
res = (res * 0x00960aadc109e7a3bf4578099615711d7) / 0x0002bf84208204f5977f9a8cf01fdce3d; // multiply by e^2^(+2)
if ((x & 0x400000000000000000000000000000000) != 0)
res = (res * 0x0002bf84208204f5977f9a8cf01fdc307) / 0x0000003c6ab775dd0b95b4cbee7e65d11; // multiply by e^2^(+3)
return res;
}
| 10,821 |
95 | // return True if the vaults supported by this gate use transferrable ERC20 tokens/ to represent shares, false otherwise. | function vaultSharesIsERC20() public pure virtual returns (bool);
| function vaultSharesIsERC20() public pure virtual returns (bool);
| 4,024 |
9 | // Info of each user that votes. | mapping(address => mapping(address => UserInfo)) public userInfo;
| mapping(address => mapping(address => UserInfo)) public userInfo;
| 27,363 |
7 | // / the _merkleRoot allowing authentication of all users from snapshot and community vetting | bytes32 public _merkleRoot;
| bytes32 public _merkleRoot;
| 41,243 |
92 | // First in liquidation preference is the cash balance. Take as much cash as allowed. | if (balanceState.storedCashBalance > 0) {
if (balanceState.storedCashBalance >= collateralAssetRemaining) {
balanceState.netCashChange = collateralAssetRemaining.neg();
collateralAssetRemaining = 0;
} else {
| if (balanceState.storedCashBalance > 0) {
if (balanceState.storedCashBalance >= collateralAssetRemaining) {
balanceState.netCashChange = collateralAssetRemaining.neg();
collateralAssetRemaining = 0;
} else {
| 10,697 |
329 | // Bird's BErc20Delegate Contract BTokens which wrap an EIP-20 underlying and are delegated to / | contract BErc20USDCDelegate is BErc20, BDelegateInterface {
/**
* @notice Construct an empty delegate
*/
constructor() public {}
/**
* @notice Called by the delegator on a delegate to initialize it for duty
* @param data The encoded bytes data for any initialization
*/
function _becomeImplementation(bytes memory data) public {
// Shh -- currently unused
data;
// Shh -- we don't ever want this hook to be marked pure
if (false) {
implementation = address(0);
}
require(msg.sender == admin, "only the admin may call _becomeImplementation");
}
/**
* @notice Called by the delegator on a delegate to forfeit its responsibility
*/
function _resignImplementation() public {
// Shh -- we don't ever want this hook to be marked pure
if (false) {
implementation = address(0);
}
require(msg.sender == admin, "only the admin may call _resignImplementation");
}
} | contract BErc20USDCDelegate is BErc20, BDelegateInterface {
/**
* @notice Construct an empty delegate
*/
constructor() public {}
/**
* @notice Called by the delegator on a delegate to initialize it for duty
* @param data The encoded bytes data for any initialization
*/
function _becomeImplementation(bytes memory data) public {
// Shh -- currently unused
data;
// Shh -- we don't ever want this hook to be marked pure
if (false) {
implementation = address(0);
}
require(msg.sender == admin, "only the admin may call _becomeImplementation");
}
/**
* @notice Called by the delegator on a delegate to forfeit its responsibility
*/
function _resignImplementation() public {
// Shh -- we don't ever want this hook to be marked pure
if (false) {
implementation = address(0);
}
require(msg.sender == admin, "only the admin may call _resignImplementation");
}
} | 31,569 |
244 | // SquadOwnable Jack Kasbeer (gh:@jcksber, tw:@satoshigoat, ig:overprivilegd) | contract SquadOwnable is Ownable {
//@dev Ownership - list of squad members (owners)
mapping (address => bool) internal _squad;
constructor() {
//add myself and then client
_squad[0xB9699469c0b4dD7B1Dda11dA7678Fa4eFD51211b] = true;
_squad[0x6b8C6E15818C74895c31A1C91390b3d42B336799] = true;//logik
}
//@dev Custom modifier for multiple owners
modifier isSquad()
{
require(isInSquad(_msgSender()), "SquadOwnable: Caller not part of squad.");
_;
}
//@dev Determine if address `a` is an approved owner
function isInSquad(address a) public view returns (bool)
{
return _squad[a];
}
//@dev Add `a` to the squad
function addToSquad(address a) public onlyOwner
{
require(!isInSquad(a), "SquadOwnable: Address already in squad.");
_squad[a] = true;
}
//@dev Remove `a` from the squad
function removeFromSquad(address a) public onlyOwner
{
require(isInSquad(a), "SquadOwnable: Address already not in squad.");
_squad[a] = false;
}
}
| contract SquadOwnable is Ownable {
//@dev Ownership - list of squad members (owners)
mapping (address => bool) internal _squad;
constructor() {
//add myself and then client
_squad[0xB9699469c0b4dD7B1Dda11dA7678Fa4eFD51211b] = true;
_squad[0x6b8C6E15818C74895c31A1C91390b3d42B336799] = true;//logik
}
//@dev Custom modifier for multiple owners
modifier isSquad()
{
require(isInSquad(_msgSender()), "SquadOwnable: Caller not part of squad.");
_;
}
//@dev Determine if address `a` is an approved owner
function isInSquad(address a) public view returns (bool)
{
return _squad[a];
}
//@dev Add `a` to the squad
function addToSquad(address a) public onlyOwner
{
require(!isInSquad(a), "SquadOwnable: Address already in squad.");
_squad[a] = true;
}
//@dev Remove `a` from the squad
function removeFromSquad(address a) public onlyOwner
{
require(isInSquad(a), "SquadOwnable: Address already not in squad.");
_squad[a] = false;
}
}
| 44,920 |
17 | // calculate pair | DELTA_WETH_PAIR_UNISWAP = address(uint(keccak256(abi.encodePacked(
hex'ff',
0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, // Mainned uniswap factory
keccak256(abi.encodePacked(_deltaToken, WETH)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
| DELTA_WETH_PAIR_UNISWAP = address(uint(keccak256(abi.encodePacked(
hex'ff',
0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, // Mainned uniswap factory
keccak256(abi.encodePacked(_deltaToken, WETH)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
| 64,539 |
1 | // Returns the maximum amount of tokens the broker can sell for the owner/owner The owner for which the broker can spend funds/broker The broker of the owner/token The token to spend/ return The allowance | function getAllowance(
address owner,
address broker,
address token
)
public
view
returns (uint allowance);
| function getAllowance(
address owner,
address broker,
address token
)
public
view
returns (uint allowance);
| 235 |
2 | // Retrieves the pool context object. / | returns (PoolSpecs.PoolCursor memory cursor) {
uint256 POOL_SLOT = 65545;
bytes32 poolHash = PoolSpecs.encodeKey(base, quote, poolIdx);
bytes32 slot = keccak256(abi.encodePacked(poolHash, POOL_SLOT));
uint256 val = CrocSwapDex(dex_).readSlot(uint256(slot));
cursor.hash_ = poolHash;
cursor.head_.feeRate_ = uint16((val & uint256(0xFFFF00)) >> 8);
cursor.head_.protocolTake_ = uint8((val & uint256(0xFF000000)) >> 24);
if (poolTip > cursor.head_.feeRate_) {
cursor.head_.feeRate_ = poolTip;
}
}
| returns (PoolSpecs.PoolCursor memory cursor) {
uint256 POOL_SLOT = 65545;
bytes32 poolHash = PoolSpecs.encodeKey(base, quote, poolIdx);
bytes32 slot = keccak256(abi.encodePacked(poolHash, POOL_SLOT));
uint256 val = CrocSwapDex(dex_).readSlot(uint256(slot));
cursor.hash_ = poolHash;
cursor.head_.feeRate_ = uint16((val & uint256(0xFFFF00)) >> 8);
cursor.head_.protocolTake_ = uint8((val & uint256(0xFF000000)) >> 24);
if (poolTip > cursor.head_.feeRate_) {
cursor.head_.feeRate_ = poolTip;
}
}
| 9,612 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.