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 |
|---|---|---|---|---|
125 | // prevent accidental sending of tokens to this token contract/_self - address of this contract | modifier notSelf(address _self) {
require(
_self != address(this),
"You are trying to send tokens to this token contract"
);
_;
}
| modifier notSelf(address _self) {
require(
_self != address(this),
"You are trying to send tokens to this token contract"
);
_;
}
| 31,548 |
43 | // Returns the collateral token with requested mask and its liquidationThreshold/tokenMask Token mask corresponding to the token | function collateralTokensByMask(uint256 tokenMask)
external
view
returns (address token, uint16 liquidationThreshold);
| function collateralTokensByMask(uint256 tokenMask)
external
view
returns (address token, uint16 liquidationThreshold);
| 26,117 |
187 | // get the total number of minted tokenIds/ | function totalSupply() public view returns (uint256) {
return idCounter.current();
}
| function totalSupply() public view returns (uint256) {
return idCounter.current();
}
| 33,270 |
71 | // Deletes the value of the `uint256` type that mapped to the given key.Only the owner can execute this function. / | function deleteUint(bytes32 _key) external onlyCurrentOwner {
delete uIntStorage[_key];
}
| function deleteUint(bytes32 _key) external onlyCurrentOwner {
delete uIntStorage[_key];
}
| 19,273 |
31 | // Update the pointer at 0x40 again to point at new free memory location so any theoretical allocation doesn't stomp our memory in this call | mstore(0x40, add(_returndataMemoryOffset, returndatasize))
returndatacopy(_returndataMemoryOffset, 0x0, returndatasize)
return(_returndataMemoryOffset, returndatasize)
| mstore(0x40, add(_returndataMemoryOffset, returndatasize))
returndatacopy(_returndataMemoryOffset, 0x0, returndatasize)
return(_returndataMemoryOffset, returndatasize)
| 36,958 |
3 | // All Transaction data, constant and variable | struct TransactionData {
address receivingChainTxManagerAddress;
address user;
address router;
address initiator; // msg.sender of sending side
address sendingAssetId;
address receivingAssetId;
address sendingChainFallback;
address receivingAddress;
address callTo;
bytes32 callDataHash;
bytes32 transactionId;
uint256 sendingChainId;
uint256 receivingChainId;
uint256 amount;
uint256 expiry;
uint256 preparedBlockNumber; // Needed for removal of active blocks on fulfill/cancel
}
| struct TransactionData {
address receivingChainTxManagerAddress;
address user;
address router;
address initiator; // msg.sender of sending side
address sendingAssetId;
address receivingAssetId;
address sendingChainFallback;
address receivingAddress;
address callTo;
bytes32 callDataHash;
bytes32 transactionId;
uint256 sendingChainId;
uint256 receivingChainId;
uint256 amount;
uint256 expiry;
uint256 preparedBlockNumber; // Needed for removal of active blocks on fulfill/cancel
}
| 8,511 |
74 | // Mapping owner address to token count | mapping(address => uint256) private _balances;
| mapping(address => uint256) private _balances;
| 374 |
38 | // lock metadata forever | function lockMetadata() public onlyOwner notLocked {
locked = true;
}
| function lockMetadata() public onlyOwner notLocked {
locked = true;
}
| 4,741 |
59 | // This is 1 in the fixed point units used in this library. Test fixed1() equals 10^digits()Hardcoded to 24 digits. / | function fixed1() public pure returns(int256) {
return 1000000000000000000000000;
}
| function fixed1() public pure returns(int256) {
return 1000000000000000000000000;
}
| 7,279 |
3 | // With this the door code will become permanent! | require(msg.sender == turista, "You are not the tourist!");
require(status == 3, "You first have to claim the door code!");
require(msg.value == (price*numberWeeks)-downPayment, "You have to pay exactly the remaining value!");
status = 1;
| require(msg.sender == turista, "You are not the tourist!");
require(status == 3, "You first have to claim the door code!");
require(msg.value == (price*numberWeeks)-downPayment, "You have to pay exactly the remaining value!");
status = 1;
| 11,869 |
46 | // Pool and Owner minted tokens per second | uint public poolMintRate;
uint public ownerMintRate;
| uint public poolMintRate;
uint public ownerMintRate;
| 79,076 |
0 | // Canonical FOREX token address //The vesting period in seconds at which the FOREX supply for each/Minimum delay (in seconds) between user claims. //Date from which participants can claim their immediate value, and/Mapping of (participant address => participant vesting data) //Total funds required by contract. Used for asserting the contract/Vesting data for participant / | struct Participant {
/* Amount initially claimable at any time from the claimStartDate */
uint256 claimable;
/* Total vested amount released in equal amounts throughout the
vesting period. */
uint256 vestedValue;
/* Date at which the participant last claimed FOREX */
uint256 lastClaimDate;
}
| struct Participant {
/* Amount initially claimable at any time from the claimStartDate */
uint256 claimable;
/* Total vested amount released in equal amounts throughout the
vesting period. */
uint256 vestedValue;
/* Date at which the participant last claimed FOREX */
uint256 lastClaimDate;
}
| 24,421 |
40 | // claim period | bytes32 _claim = _claimId(id,fi);
uint256 _now = block.timestamp;
require((_now - lastClaim[_claim]) >= PERIOD, "ShardAlly: wait one day to claim");
| bytes32 _claim = _claimId(id,fi);
uint256 _now = block.timestamp;
require((_now - lastClaim[_claim]) >= PERIOD, "ShardAlly: wait one day to claim");
| 28,988 |
1 | // Network: KovanOracle: 0xc57b33452b4f7bb189bb5afae9cc4aba1f7a4fd8Job ID: d5270d1c311941d0b08bead21fea7747Fee: 0.1 LINK / | constructor(
address _oracle,
bytes32 _jobId,
uint256 _fee,
uint256 _rewardUnit,
address _link
| constructor(
address _oracle,
bytes32 _jobId,
uint256 _fee,
uint256 _rewardUnit,
address _link
| 51,137 |
12 | // Casts a vote for a candidate. _candidateId The ID of the candidate being voted for. _department The department of the voter. _matriculationNumber The matriculation number of the voter. / | function castVote(uint _candidateId, string memory _department, string memory _matriculationNumber) public onlyVoter onlyDuringElection {
require(_candidateId > 0 && _candidateId <= candidateCount, "Invalid candidate ID");
require(isValidVoterDepartment(_department, _matriculationNumber), "Invalid voter department or matriculation number");
voters[msg.sender].hasVoted = true;
voters[msg.sender].department = _department;
voters[msg.sender].matriculationNumber = _matriculationNumber;
candidates[_candidateId].voteCount++;
emit VoteCasted(_candidateId, candidates[_candidateId].voteCount);
voteTimestamps[msg.sender] = block.timestamp;
}
| function castVote(uint _candidateId, string memory _department, string memory _matriculationNumber) public onlyVoter onlyDuringElection {
require(_candidateId > 0 && _candidateId <= candidateCount, "Invalid candidate ID");
require(isValidVoterDepartment(_department, _matriculationNumber), "Invalid voter department or matriculation number");
voters[msg.sender].hasVoted = true;
voters[msg.sender].department = _department;
voters[msg.sender].matriculationNumber = _matriculationNumber;
candidates[_candidateId].voteCount++;
emit VoteCasted(_candidateId, candidates[_candidateId].voteCount);
voteTimestamps[msg.sender] = block.timestamp;
}
| 8,695 |
76 | // Rounds an `epoch` timestamp to the start of the corresponding period | function _getRoundedEpoch(uint32 epoch) internal pure returns (uint32) {
return (epoch / EPOCH_DURATION) * EPOCH_DURATION;
}
| function _getRoundedEpoch(uint32 epoch) internal pure returns (uint32) {
return (epoch / EPOCH_DURATION) * EPOCH_DURATION;
}
| 38,435 |
0 | // Alkimiya Oracle Addresses Alkimiya Team/ | interface IOracleRegistry {
event OracleRegistered(address token, uint256 oracleType, address oracleAddr);
function getOracleAddress(address _token, uint256 _oracleType) external view returns (address);
}
| interface IOracleRegistry {
event OracleRegistered(address token, uint256 oracleType, address oracleAddr);
function getOracleAddress(address _token, uint256 _oracleType) external view returns (address);
}
| 9,916 |
117 | // 持有者的份额 | uint256 _gen = (_eth.mul(fees_[_team].gen)) / 100;
| uint256 _gen = (_eth.mul(fees_[_team].gen)) / 100;
| 18,676 |
43 | // Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.The call is not executed if the target address is not a contract.from address representing the previous owner of the given token ID to target address that will receive the tokens tokenId uint256 ID of the token to be transferred data bytes optional data to send along with the callreturn bool whether the call correctly returned the expected magic value / | function checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory data)
private returns (bool)
{
if (!isContract(to)) {
return true;
}
| function checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory data)
private returns (bool)
{
if (!isContract(to)) {
return true;
}
| 53,487 |
7 | // Will update the base URL of token's URI _newBaseMetadataURI New base URL of token's URI / | function _setBaseMetadataURI(string memory _newBaseMetadataURI) internal {
baseMetadataURI = _newBaseMetadataURI;
}
| function _setBaseMetadataURI(string memory _newBaseMetadataURI) internal {
baseMetadataURI = _newBaseMetadataURI;
}
| 33,171 |
265 | // Distributes the dev fund for accounts | function distributeDevFund() public override {
uint256 totalMulitplierDistributionAmount = multiplierTokenDevFund;
multiplierTokenDevFund = 0;
// Distribute multiplier dev fund according to percentages
for (uint256 i = 0; i < devCount; i++) {
uint256 devPercentage = devAllocations[devIDs[i]];
uint256 allocation = totalMulitplierDistributionAmount
.mul(devPercentage)
.div(100);
if (allocation > 0) {
multiplierToken.safeTransfer(devIDs[i], allocation);
}
}
// Distribute the staking token rewards
super.distributeDevFund();
}
| function distributeDevFund() public override {
uint256 totalMulitplierDistributionAmount = multiplierTokenDevFund;
multiplierTokenDevFund = 0;
// Distribute multiplier dev fund according to percentages
for (uint256 i = 0; i < devCount; i++) {
uint256 devPercentage = devAllocations[devIDs[i]];
uint256 allocation = totalMulitplierDistributionAmount
.mul(devPercentage)
.div(100);
if (allocation > 0) {
multiplierToken.safeTransfer(devIDs[i], allocation);
}
}
// Distribute the staking token rewards
super.distributeDevFund();
}
| 59,801 |
49 | // Opens long position for shadow asset `_ticker` of size `_volume`/ticker kek/volume kek/assetPrice kek/tokenPrice kek | function OpenLong(
string ticker,
string volume,
string assetPrice,
string tokenPrice)
public
onlyOwner {
uint volumeUint = stringToUint(volume);
| function OpenLong(
string ticker,
string volume,
string assetPrice,
string tokenPrice)
public
onlyOwner {
uint volumeUint = stringToUint(volume);
| 25,429 |
32 | // indicates if global settlement was triggered | function live() external view returns(bool);
| function live() external view returns(bool);
| 59,958 |
3 | // create Payment for Item / | function createPayment(uint256 _itemId) public payable {
uint256 _amountValue = msg.value;
if (itemPayment[_itemId].creator != address(0)) {
require(itemPayment[_itemId].creator == msg.sender, "Mintedgem: invalid-creator");
itemPayment[_itemId].amount += _amountValue;
} else {
itemPayment[_itemId].amount = _amountValue;
itemPayment[_itemId].creator = msg.sender;
}
updateTransactionVolume(msg.sender, _amountValue);
emit PaymentCreated(_itemId, _amountValue);
}
| function createPayment(uint256 _itemId) public payable {
uint256 _amountValue = msg.value;
if (itemPayment[_itemId].creator != address(0)) {
require(itemPayment[_itemId].creator == msg.sender, "Mintedgem: invalid-creator");
itemPayment[_itemId].amount += _amountValue;
} else {
itemPayment[_itemId].amount = _amountValue;
itemPayment[_itemId].creator = msg.sender;
}
updateTransactionVolume(msg.sender, _amountValue);
emit PaymentCreated(_itemId, _amountValue);
}
| 33,710 |
53 | // Public Functions //Disable default function. | function () payable public {
revert();
}
| function () payable public {
revert();
}
| 27,146 |
6 | // Emitted when the amo is set.//underlyingToken The address of the underlying token./amo The address of the amo. | event SetAmo(address underlyingToken, address amo);
| event SetAmo(address underlyingToken, address amo);
| 41,061 |
24 | // No Proxy: Polygon / Ethereum (goerli) | if (address(_proxyRegistryAddress) == operator) {
return true;
}
| if (address(_proxyRegistryAddress) == operator) {
return true;
}
| 2,781 |
125 | // Contract for Federation Coupon System./ | contract FedCoup is StandardToken, Ownable {
/*
* Name of the Federation Coupon System.
*/
string public name = "FedCoup";
/*
* FedCoup currency symbol.
*/
string public symbol = "FET";
uint public decimals = 18;
/*
* constant S,B coupon (federation coupon) division factor as 0.01
*/
uint coupon_mul_factor = 100;
/*
* balance of S coupons for each address
*/
mapping (address => uint) balance_S_coupons;
/*
* balance of B coupons for each address
*/
mapping (address => uint) balance_B_coupons;
/*
* B coupon allowance.
*/
mapping (address => mapping (address => uint)) allowed_B_coupons;
/*
* S coupon allowane.
*/
mapping (address => mapping (address => uint)) allowed_S_coupons;
/*
* The percentage of B coupon allocated while coupon creation.
*/
uint B_coupon_allocation_factor = 50;
/*
* The percentage of S coupon allocated while coupon creation.
*/
uint S_coupon_allocation_factor = 100;
/*
* Whenever coupon created using FedTokens, those tokens will be added here.
* When B coupons accepted with S coupons, the equivalent FedTokens will be substracted here.
*/
uint couponizedFedTokens = 0;
/*
* residual B coupons which accumulated over the period due to B coupon transfers.
*/
uint residualBcoupons = 0;
/*
* residual S coupons which accumulated over the period due to B coupon transfers.
*/
uint residualScoupons = 0;
/*
* Cost of B coupon (in percentage) when transfer to other user.
* This cost necessary, otherwise B coupon will go on circulation loop and it might go on in own curreny mode.
* Using this cost, B coupon crunched back to the system if transfer happens continuously without accepting coupons.
*/
uint transferCostBcoupon = 90;
/*
* Cost of S coupon (in percentage) when transfer to other user.
* This cost necessary to motivate users to sell products (with coupons) instead of transfering S coupons.
* Using this cost, S coupon crunched back to the system if transfer happens continuously without accepting coupons.
*/
uint transferCostScoupon = 1;
/*
* event to log coupon creation.
*/
event CouponsCreated(address indexed owner, uint Bcoupons, uint Scoupons);
/*
* event to log accepted B coupons.
*/
event Accept_B_coupons(address indexed from, address indexed to, uint value);
/*
* event to log accepted S coupons.
*/
event Accept_S_coupons(address indexed from, address indexed to, uint value);
/*
* event to log B coupons transfer.
*/
event Transfer_B_coupons(address indexed from, address indexed to, uint value);
/*
* event to log B coupons transfer.
*/
event Transfer_S_coupons(address indexed from, address indexed to, uint value);
/*
* event to log residual B coupons transfer.
*/
event TransferResidual_B_coupons(address indexed from, address indexed to, uint value);
/*
* event to log residual S coupons transfer.
*/
event TransferResidual_S_coupons(address indexed from, address indexed to, uint value);
event ApprovalBcoupons(address indexed owner, address indexed acceptor, uint value);
event ApprovalScoupons(address indexed owner, address indexed receiver, uint value);
function FedCoup() {
totalSupply = 1000000000 ether;
balances[msg.sender] = totalSupply;
}
/*
* Create coupons for given number of FedCoup tokens.
* _numberOfTokens : given FedCoup token (1 FedCoup token equal to 1 ether with respect to number format)
*/
function createCoupons(uint _numberOfTokens) {
/*
* subtract given token from sender token balance
*/
balances[ msg.sender ] = balances[ msg.sender ].sub( _numberOfTokens );
/*
* B coupon creation for given _numberOfTokens
*
* Formula: number of B coupons =
*
* (B coupon allocation factor/100) * given _numberOfTokens * coupon_mul_factor
*/
uint newBcoupons = B_coupon_allocation_factor.mul( _numberOfTokens.mul( coupon_mul_factor )).div(100);
/*
* S coupon creation for given _numberOfTokens
*
* Formula: number of S coupons =
*
* (S coupon allocation factor/100) * given _numberOfTokens * coupon_mul_factor
*/
uint newScoupons = S_coupon_allocation_factor.mul( _numberOfTokens.mul( coupon_mul_factor )).div(100);
/*
* add new coupons with existing coupon balance
*/
balance_B_coupons[ msg.sender ] = balance_B_coupons[ msg.sender ].add( newBcoupons );
balance_S_coupons[ msg.sender ] = balance_S_coupons[ msg.sender ].add( newScoupons );
/*
* log event
*/
CouponsCreated(msg.sender, newBcoupons, newScoupons);
}
/*
* accept B coupons.
*
* Parameters:
* _from : address of the coupon giver.
* _numberOfBcoupons : number of B coupons (1B coupon equal to 1 ether with respect to format)
*/
function accept_B_coupons(address _from, uint _numberOfBcoupons) onlyPayloadSize(2 * 32) external {
/*
* Restrict if message sender and from address are same.
* Same user cannot accept his own B coupons. The B acceptance should come from other users.
*/
if (msg.sender == _from ) {
throw;
}
/*
* The B coupons which has to be accepted should be allowed by the _from address.
*/
var _allowance = allowed_B_coupons[_from][msg.sender];
/*
* substract B coupons from the giver account.
*/
balance_B_coupons[ _from ] = balance_B_coupons[ _from ].sub( _numberOfBcoupons );
/*
* substract equivalent S coupons from message sender(coupon acceptor) account.
*/
balance_S_coupons[ msg.sender ] = balance_S_coupons[ msg.sender ].sub( _numberOfBcoupons );
/*
* convert accepted B coupons into equivalent FedCoup tokens and add it to sender balance.
*
* Formula: number of tokens =
*
* _numberOfBcoupons
* ------------------------------
* coupon_mul_factor
*
*/
uint _numberOfTokens = _numberOfBcoupons.div( coupon_mul_factor );
/*
* add calcualated tokens to acceptor's account.
*/
balances[ msg.sender ] = balances[ msg.sender ].add( _numberOfTokens );
/*
* substract allowed_B_coupons for the accepted _numberOfBcoupons.
*/
allowed_B_coupons[_from][msg.sender] = _allowance.sub(_numberOfBcoupons);
/*
* log event.
*/
Accept_B_coupons(_from, msg.sender, _numberOfBcoupons);
}
/*
* Transfer B coupons.
*
* Parameters:
* _to: To address where B coupons has to be send
* _numberOfBcoupons: number of B coupons (1 coupon equal to 1 ether)
*/
function transferBcoupons(address _to, uint _numberOfBcoupons) onlyPayloadSize(2 * 32) external {
/*
* substract _numberOfBcoupons from sender account.
*/
balance_B_coupons[ msg.sender ] = balance_B_coupons[ msg.sender ].sub( _numberOfBcoupons );
/*
* calculate transfer cost.
* Formula: B coupon transferCost =
*
* B coupon transfer cost (in percentage) * _numberOfBcoupons
* -----------------------------------------------------------
* 100
*/
uint transferCost = _numberOfBcoupons.mul( transferCostBcoupon ).div( 100 );
/*
* add transfer cost to residual B coupons.
*/
residualBcoupons = residualBcoupons.add( transferCost );
/*
* subtract transfer cost from given _numberOfBcoupons and add it to the TO account.
*/
balance_B_coupons[ _to ] = balance_B_coupons[ _to ].add( _numberOfBcoupons.sub(transferCost) );
/*
* log event
*/
Transfer_B_coupons(msg.sender, _to, _numberOfBcoupons);
}
/*
* Transfer S coupons.
*/
function transferScoupons(address _to, uint _numberOfScoupons) onlyPayloadSize(2 * 32) external {
/*
* substract _numberOfScoupons from sender account.
*/
balance_S_coupons[ msg.sender ] = balance_S_coupons[ msg.sender ].sub( _numberOfScoupons );
/*
* calculate transfer cost.
* Formula: S coupon transferCost =
*
* S coupon transfer cost (in percentage) * _numberOfScoupons
* -----------------------------------------------------------
* 100
*/
uint transferCost = _numberOfScoupons.div( 100 ).mul( transferCostScoupon );
/*
* add transfer cost to residual S coupons.
*/
residualScoupons = residualScoupons.add( transferCost );
/*
* subtract transfer cost from given _numberOfScoupons and add it to the TO account.
*/
balance_S_coupons[ _to ] = balance_S_coupons[ _to ].add( _numberOfScoupons.sub(transferCost) );
/*
* log event.
*/
Transfer_S_coupons(msg.sender, _to, _numberOfScoupons);
}
/*
* Transfer residual B coupons to entities which integrates FedCoup.
* It's investment on entities to integrate FedCoup on their sales lifecycle.
*/
function transferResidualBcoupons(address _to, uint _numberOfBcoupons) external onlyOwner {
/*
* substract transfered _numberOfBcoupons from sender's account.
*/
residualBcoupons = residualBcoupons.sub( _numberOfBcoupons );
/*
* add _numberOfBcoupons to receiver's account.
*/
balance_B_coupons[ _to ] = balance_B_coupons[ _to ].add( _numberOfBcoupons );
/*
* log event.
*/
TransferResidual_B_coupons(msg.sender, _to, _numberOfBcoupons);
}
/*
* Transfer residual B coupons to entities which integrates FedCoup.
* It's investment on entities to integrate FedCoup on their sales lifecycle.
*/
function transferResidualScoupons(address _to, uint _numberOfScoupons) external onlyOwner {
/*
* substract transfered _numberOfScoupons from sender's account.
*/
residualScoupons = residualScoupons.sub( _numberOfScoupons );
/*
* add _numberOfScoupons to receiver's account.
*/
balance_S_coupons[ _to ] = balance_S_coupons[ _to ].add( _numberOfScoupons );
/*
* log event.
*/
TransferResidual_B_coupons(msg.sender, _to, _numberOfScoupons);
}
/*
* Approve B coupons
*
* Parameters:
* _acceptor: address of the acceptor.
* _Bcoupons: number of B coupons has to be accepted from message sender by acceptor.
*/
function approveBcoupons(address _acceptor, uint _Bcoupons) external {
/*
* approve B coupons from message sender to acceptor.
*/
allowed_B_coupons[msg.sender][_acceptor] = _Bcoupons;
/*
* log event.
*/
ApprovalBcoupons(msg.sender, _acceptor, _Bcoupons);
}
/*
* Approve S coupons
*
* Parameters:
* _receiver: address of the receiver.
* _Scoupons: number of S coupons has to be allowed to receiver.
*/
function approveScoupons(address _receiver, uint _Scoupons) external {
/*
* approve S coupons from message sender to receiver.
*/
allowed_S_coupons[msg.sender][_receiver] = _Scoupons;
/*
* log event.
*/
ApprovalScoupons(msg.sender, _receiver, _Scoupons);
}
/*
* Get allowed B coupons from address to acceptor address.
*
* Parameters:
* _from: address of the B coupon sender.
* _acceptor: address of the B coupon acceptor.
*/
function allowanceBcoupons(address _from, address _acceptor) constant external returns (uint remaining) {
return allowed_B_coupons[_from][_acceptor];
}
/*
* Get coupon multiplication factor.
*/
function getCouponMulFactor() constant external returns (uint) {
return coupon_mul_factor;
}
/*
* Set coupon multiplication factor.
*
* Parameters:
* couponMulFactor: The number of coupons for 1 Federation token.
*/
function setCouponMulFactor(uint couponMulFactor) external onlyOwner {
coupon_mul_factor = couponMulFactor;
}
/*
* Get Federation token balance for given address.
*
* Parameters:
* _addr: The address for which the token balance has to be retrieved.
*/
function getTokenBalances(address _addr) constant external returns (uint) {
return balances[ _addr ];
}
/*
* Get B coupon allocation factor which indicates the percentage of
* how many B coupons will be allocated to the user for given Federation token.
*/
function getBcouponAllocationFactor() constant external returns (uint) {
return B_coupon_allocation_factor;
}
/*
* Set B coupon allocation factor.
*
* Parameters:
* BcouponAllocFactor: The B coupon allocation factor in percentage.
*/
function setBcouponAllocationFactor(uint BcouponAllocFactor) external onlyOwner {
B_coupon_allocation_factor = BcouponAllocFactor;
}
/*
* Get S coupon allocation factor which indicates the percentage of
* how many S coupons will be allocated to the user for given Federation token.
*/
function getScouponAllocationFactor() constant external returns (uint) {
return S_coupon_allocation_factor;
}
/*
* Set S coupon allocation factor.
*
* Parameters:
* ScouponAllocFactor: The S coupon allocation factor in percentage.
*/
function setScouponAllocationFactor(uint ScouponAllocFactor) external onlyOwner {
S_coupon_allocation_factor = ScouponAllocFactor;
}
/*
* Get B coupon transfer cost.
*/
function getBcouponTransferCost() constant external returns (uint) {
return transferCostBcoupon;
}
/*
* Set B coupon transfer cost.
*
* Parameters:
* transferCostBcoup: The number B coupons deducted as cost for transfering them.
*/
function setBcouponTransferCost(uint transferCostBcoup) external onlyOwner {
transferCostBcoupon = transferCostBcoup;
}
/*
* Get S coupon transfer cost.
*/
function getScouponTransferCost() constant external returns (uint) {
return transferCostScoupon;
}
/*
* Set S coupon transfer cost.
*/
function setScouponTransferCost(uint transferCostScoup) external onlyOwner {
transferCostScoupon = transferCostScoup;
}
/*
* Get B coupon balance.
*/
function getBcouponBalances(address _addr) constant external returns (uint) {
return balance_B_coupons[ _addr ];
}
/*
* Get S coupon balance.
*/
function getScouponBalances(address _addr) constant external returns (uint) {
return balance_S_coupons[ _addr ];
}
/*
* Get balance of residual B coupons.
*/
function getBalanceOfResidualBcoupons() constant external returns (uint) {
return residualBcoupons;
}
/*************************************************************************************************/
/* Contractors functions
/* ---------------------
/* The contractor functions designed to support future contractor contracts.
/* These contractors might be out of the blockchain or out of the ethereum blockchain etc.
/* The contractors should follow the FedCoup principle wherever they are implemented. The below
/* list functions are the minimal set of functions which directly updates the coupons
/* and tokens for the user. The contractor criteria will be established as a seperate contract.
/*
/* Contractor also responsible for initial coupon distribution to users without
/* any transactio cost. These coupon distribution might be used to promote specific applications
/* which also supports B, S coupons.
/**************************************************************************************************/
address public contractorImpl;
event ContractorTransferBcoupons(address indexed sender, address indexed receiver, uint numberOfBcoupons);
event ContractorTransferScoupons(address indexed sender, address indexed receiver, uint numberOfScoupons);
modifier onlyContractorImpl() {
if (msg.sender == contractorImpl) {
throw;
}
_;
}
function setContractorImpl(address _contractorImplAddr) onlyPayloadSize(2 * 32) onlyOwner {
contractorImpl = _contractorImplAddr;
}
function contractorTransfer_Bcoupon(address _to, uint _numberOfBcoupons) onlyPayloadSize(2 * 32) onlyContractorImpl external {
balance_B_coupons[msg.sender] = balance_B_coupons[msg.sender].sub(_numberOfBcoupons);
balance_B_coupons[_to] = balance_B_coupons[_to].add(_numberOfBcoupons);
/*
* log event.
*/
ContractorTransferBcoupons(msg.sender, _to, _numberOfBcoupons);
}
function contractorTransferFrom_Bcoupon(address _from, address _to, uint _numberOfBcoupons) onlyPayloadSize(2 * 32) onlyContractorImpl external {
/*
* The B coupons which has to be allowed _from address to _to address.
*/
var _allowance = allowed_B_coupons[_from][msg.sender];
/*
* substract B coupons from _from account.
*/
balance_B_coupons[ _from ] = balance_B_coupons[ _from ].sub( _numberOfBcoupons );
/*
* substract allowed_B_coupons for transfered _numberOfBcoupons.
*/
allowed_B_coupons[_from][msg.sender] = _allowance.sub(_numberOfBcoupons);
/*
* log event.
*/
ContractorTransferBcoupons(_from, _to, _numberOfBcoupons);
}
function contractorTransfer_Scoupon(address _to, uint _numberOfScoupons) onlyPayloadSize(2 * 32) onlyContractorImpl external {
balance_S_coupons[msg.sender] = balance_S_coupons[msg.sender].sub(_numberOfScoupons);
balance_S_coupons[_to] = balance_S_coupons[_to].add(_numberOfScoupons);
/*
* log event.
*/
ContractorTransferScoupons(msg.sender, _to, _numberOfScoupons);
}
function contractorTransferFrom_Scoupon(address _from, address _to, uint _numberOfScoupons) onlyPayloadSize(2 * 32) onlyContractorImpl external {
/*
* The S coupons which has to be allowed _from address to _to address.
*/
var _allowance = allowed_S_coupons[_from][msg.sender];
/*
* substract S coupons from _from account.
*/
balance_S_coupons[ _from ] = balance_S_coupons[ _from ].sub( _numberOfScoupons );
/*
* substract allowed_S_coupons for transfered _numberOfScoupons.
*/
allowed_S_coupons[_from][msg.sender] = _allowance.sub(_numberOfScoupons);
/*
* log event.
*/
ContractorTransferScoupons(_from, _to, _numberOfScoupons);
}
} | contract FedCoup is StandardToken, Ownable {
/*
* Name of the Federation Coupon System.
*/
string public name = "FedCoup";
/*
* FedCoup currency symbol.
*/
string public symbol = "FET";
uint public decimals = 18;
/*
* constant S,B coupon (federation coupon) division factor as 0.01
*/
uint coupon_mul_factor = 100;
/*
* balance of S coupons for each address
*/
mapping (address => uint) balance_S_coupons;
/*
* balance of B coupons for each address
*/
mapping (address => uint) balance_B_coupons;
/*
* B coupon allowance.
*/
mapping (address => mapping (address => uint)) allowed_B_coupons;
/*
* S coupon allowane.
*/
mapping (address => mapping (address => uint)) allowed_S_coupons;
/*
* The percentage of B coupon allocated while coupon creation.
*/
uint B_coupon_allocation_factor = 50;
/*
* The percentage of S coupon allocated while coupon creation.
*/
uint S_coupon_allocation_factor = 100;
/*
* Whenever coupon created using FedTokens, those tokens will be added here.
* When B coupons accepted with S coupons, the equivalent FedTokens will be substracted here.
*/
uint couponizedFedTokens = 0;
/*
* residual B coupons which accumulated over the period due to B coupon transfers.
*/
uint residualBcoupons = 0;
/*
* residual S coupons which accumulated over the period due to B coupon transfers.
*/
uint residualScoupons = 0;
/*
* Cost of B coupon (in percentage) when transfer to other user.
* This cost necessary, otherwise B coupon will go on circulation loop and it might go on in own curreny mode.
* Using this cost, B coupon crunched back to the system if transfer happens continuously without accepting coupons.
*/
uint transferCostBcoupon = 90;
/*
* Cost of S coupon (in percentage) when transfer to other user.
* This cost necessary to motivate users to sell products (with coupons) instead of transfering S coupons.
* Using this cost, S coupon crunched back to the system if transfer happens continuously without accepting coupons.
*/
uint transferCostScoupon = 1;
/*
* event to log coupon creation.
*/
event CouponsCreated(address indexed owner, uint Bcoupons, uint Scoupons);
/*
* event to log accepted B coupons.
*/
event Accept_B_coupons(address indexed from, address indexed to, uint value);
/*
* event to log accepted S coupons.
*/
event Accept_S_coupons(address indexed from, address indexed to, uint value);
/*
* event to log B coupons transfer.
*/
event Transfer_B_coupons(address indexed from, address indexed to, uint value);
/*
* event to log B coupons transfer.
*/
event Transfer_S_coupons(address indexed from, address indexed to, uint value);
/*
* event to log residual B coupons transfer.
*/
event TransferResidual_B_coupons(address indexed from, address indexed to, uint value);
/*
* event to log residual S coupons transfer.
*/
event TransferResidual_S_coupons(address indexed from, address indexed to, uint value);
event ApprovalBcoupons(address indexed owner, address indexed acceptor, uint value);
event ApprovalScoupons(address indexed owner, address indexed receiver, uint value);
function FedCoup() {
totalSupply = 1000000000 ether;
balances[msg.sender] = totalSupply;
}
/*
* Create coupons for given number of FedCoup tokens.
* _numberOfTokens : given FedCoup token (1 FedCoup token equal to 1 ether with respect to number format)
*/
function createCoupons(uint _numberOfTokens) {
/*
* subtract given token from sender token balance
*/
balances[ msg.sender ] = balances[ msg.sender ].sub( _numberOfTokens );
/*
* B coupon creation for given _numberOfTokens
*
* Formula: number of B coupons =
*
* (B coupon allocation factor/100) * given _numberOfTokens * coupon_mul_factor
*/
uint newBcoupons = B_coupon_allocation_factor.mul( _numberOfTokens.mul( coupon_mul_factor )).div(100);
/*
* S coupon creation for given _numberOfTokens
*
* Formula: number of S coupons =
*
* (S coupon allocation factor/100) * given _numberOfTokens * coupon_mul_factor
*/
uint newScoupons = S_coupon_allocation_factor.mul( _numberOfTokens.mul( coupon_mul_factor )).div(100);
/*
* add new coupons with existing coupon balance
*/
balance_B_coupons[ msg.sender ] = balance_B_coupons[ msg.sender ].add( newBcoupons );
balance_S_coupons[ msg.sender ] = balance_S_coupons[ msg.sender ].add( newScoupons );
/*
* log event
*/
CouponsCreated(msg.sender, newBcoupons, newScoupons);
}
/*
* accept B coupons.
*
* Parameters:
* _from : address of the coupon giver.
* _numberOfBcoupons : number of B coupons (1B coupon equal to 1 ether with respect to format)
*/
function accept_B_coupons(address _from, uint _numberOfBcoupons) onlyPayloadSize(2 * 32) external {
/*
* Restrict if message sender and from address are same.
* Same user cannot accept his own B coupons. The B acceptance should come from other users.
*/
if (msg.sender == _from ) {
throw;
}
/*
* The B coupons which has to be accepted should be allowed by the _from address.
*/
var _allowance = allowed_B_coupons[_from][msg.sender];
/*
* substract B coupons from the giver account.
*/
balance_B_coupons[ _from ] = balance_B_coupons[ _from ].sub( _numberOfBcoupons );
/*
* substract equivalent S coupons from message sender(coupon acceptor) account.
*/
balance_S_coupons[ msg.sender ] = balance_S_coupons[ msg.sender ].sub( _numberOfBcoupons );
/*
* convert accepted B coupons into equivalent FedCoup tokens and add it to sender balance.
*
* Formula: number of tokens =
*
* _numberOfBcoupons
* ------------------------------
* coupon_mul_factor
*
*/
uint _numberOfTokens = _numberOfBcoupons.div( coupon_mul_factor );
/*
* add calcualated tokens to acceptor's account.
*/
balances[ msg.sender ] = balances[ msg.sender ].add( _numberOfTokens );
/*
* substract allowed_B_coupons for the accepted _numberOfBcoupons.
*/
allowed_B_coupons[_from][msg.sender] = _allowance.sub(_numberOfBcoupons);
/*
* log event.
*/
Accept_B_coupons(_from, msg.sender, _numberOfBcoupons);
}
/*
* Transfer B coupons.
*
* Parameters:
* _to: To address where B coupons has to be send
* _numberOfBcoupons: number of B coupons (1 coupon equal to 1 ether)
*/
function transferBcoupons(address _to, uint _numberOfBcoupons) onlyPayloadSize(2 * 32) external {
/*
* substract _numberOfBcoupons from sender account.
*/
balance_B_coupons[ msg.sender ] = balance_B_coupons[ msg.sender ].sub( _numberOfBcoupons );
/*
* calculate transfer cost.
* Formula: B coupon transferCost =
*
* B coupon transfer cost (in percentage) * _numberOfBcoupons
* -----------------------------------------------------------
* 100
*/
uint transferCost = _numberOfBcoupons.mul( transferCostBcoupon ).div( 100 );
/*
* add transfer cost to residual B coupons.
*/
residualBcoupons = residualBcoupons.add( transferCost );
/*
* subtract transfer cost from given _numberOfBcoupons and add it to the TO account.
*/
balance_B_coupons[ _to ] = balance_B_coupons[ _to ].add( _numberOfBcoupons.sub(transferCost) );
/*
* log event
*/
Transfer_B_coupons(msg.sender, _to, _numberOfBcoupons);
}
/*
* Transfer S coupons.
*/
function transferScoupons(address _to, uint _numberOfScoupons) onlyPayloadSize(2 * 32) external {
/*
* substract _numberOfScoupons from sender account.
*/
balance_S_coupons[ msg.sender ] = balance_S_coupons[ msg.sender ].sub( _numberOfScoupons );
/*
* calculate transfer cost.
* Formula: S coupon transferCost =
*
* S coupon transfer cost (in percentage) * _numberOfScoupons
* -----------------------------------------------------------
* 100
*/
uint transferCost = _numberOfScoupons.div( 100 ).mul( transferCostScoupon );
/*
* add transfer cost to residual S coupons.
*/
residualScoupons = residualScoupons.add( transferCost );
/*
* subtract transfer cost from given _numberOfScoupons and add it to the TO account.
*/
balance_S_coupons[ _to ] = balance_S_coupons[ _to ].add( _numberOfScoupons.sub(transferCost) );
/*
* log event.
*/
Transfer_S_coupons(msg.sender, _to, _numberOfScoupons);
}
/*
* Transfer residual B coupons to entities which integrates FedCoup.
* It's investment on entities to integrate FedCoup on their sales lifecycle.
*/
function transferResidualBcoupons(address _to, uint _numberOfBcoupons) external onlyOwner {
/*
* substract transfered _numberOfBcoupons from sender's account.
*/
residualBcoupons = residualBcoupons.sub( _numberOfBcoupons );
/*
* add _numberOfBcoupons to receiver's account.
*/
balance_B_coupons[ _to ] = balance_B_coupons[ _to ].add( _numberOfBcoupons );
/*
* log event.
*/
TransferResidual_B_coupons(msg.sender, _to, _numberOfBcoupons);
}
/*
* Transfer residual B coupons to entities which integrates FedCoup.
* It's investment on entities to integrate FedCoup on their sales lifecycle.
*/
function transferResidualScoupons(address _to, uint _numberOfScoupons) external onlyOwner {
/*
* substract transfered _numberOfScoupons from sender's account.
*/
residualScoupons = residualScoupons.sub( _numberOfScoupons );
/*
* add _numberOfScoupons to receiver's account.
*/
balance_S_coupons[ _to ] = balance_S_coupons[ _to ].add( _numberOfScoupons );
/*
* log event.
*/
TransferResidual_B_coupons(msg.sender, _to, _numberOfScoupons);
}
/*
* Approve B coupons
*
* Parameters:
* _acceptor: address of the acceptor.
* _Bcoupons: number of B coupons has to be accepted from message sender by acceptor.
*/
function approveBcoupons(address _acceptor, uint _Bcoupons) external {
/*
* approve B coupons from message sender to acceptor.
*/
allowed_B_coupons[msg.sender][_acceptor] = _Bcoupons;
/*
* log event.
*/
ApprovalBcoupons(msg.sender, _acceptor, _Bcoupons);
}
/*
* Approve S coupons
*
* Parameters:
* _receiver: address of the receiver.
* _Scoupons: number of S coupons has to be allowed to receiver.
*/
function approveScoupons(address _receiver, uint _Scoupons) external {
/*
* approve S coupons from message sender to receiver.
*/
allowed_S_coupons[msg.sender][_receiver] = _Scoupons;
/*
* log event.
*/
ApprovalScoupons(msg.sender, _receiver, _Scoupons);
}
/*
* Get allowed B coupons from address to acceptor address.
*
* Parameters:
* _from: address of the B coupon sender.
* _acceptor: address of the B coupon acceptor.
*/
function allowanceBcoupons(address _from, address _acceptor) constant external returns (uint remaining) {
return allowed_B_coupons[_from][_acceptor];
}
/*
* Get coupon multiplication factor.
*/
function getCouponMulFactor() constant external returns (uint) {
return coupon_mul_factor;
}
/*
* Set coupon multiplication factor.
*
* Parameters:
* couponMulFactor: The number of coupons for 1 Federation token.
*/
function setCouponMulFactor(uint couponMulFactor) external onlyOwner {
coupon_mul_factor = couponMulFactor;
}
/*
* Get Federation token balance for given address.
*
* Parameters:
* _addr: The address for which the token balance has to be retrieved.
*/
function getTokenBalances(address _addr) constant external returns (uint) {
return balances[ _addr ];
}
/*
* Get B coupon allocation factor which indicates the percentage of
* how many B coupons will be allocated to the user for given Federation token.
*/
function getBcouponAllocationFactor() constant external returns (uint) {
return B_coupon_allocation_factor;
}
/*
* Set B coupon allocation factor.
*
* Parameters:
* BcouponAllocFactor: The B coupon allocation factor in percentage.
*/
function setBcouponAllocationFactor(uint BcouponAllocFactor) external onlyOwner {
B_coupon_allocation_factor = BcouponAllocFactor;
}
/*
* Get S coupon allocation factor which indicates the percentage of
* how many S coupons will be allocated to the user for given Federation token.
*/
function getScouponAllocationFactor() constant external returns (uint) {
return S_coupon_allocation_factor;
}
/*
* Set S coupon allocation factor.
*
* Parameters:
* ScouponAllocFactor: The S coupon allocation factor in percentage.
*/
function setScouponAllocationFactor(uint ScouponAllocFactor) external onlyOwner {
S_coupon_allocation_factor = ScouponAllocFactor;
}
/*
* Get B coupon transfer cost.
*/
function getBcouponTransferCost() constant external returns (uint) {
return transferCostBcoupon;
}
/*
* Set B coupon transfer cost.
*
* Parameters:
* transferCostBcoup: The number B coupons deducted as cost for transfering them.
*/
function setBcouponTransferCost(uint transferCostBcoup) external onlyOwner {
transferCostBcoupon = transferCostBcoup;
}
/*
* Get S coupon transfer cost.
*/
function getScouponTransferCost() constant external returns (uint) {
return transferCostScoupon;
}
/*
* Set S coupon transfer cost.
*/
function setScouponTransferCost(uint transferCostScoup) external onlyOwner {
transferCostScoupon = transferCostScoup;
}
/*
* Get B coupon balance.
*/
function getBcouponBalances(address _addr) constant external returns (uint) {
return balance_B_coupons[ _addr ];
}
/*
* Get S coupon balance.
*/
function getScouponBalances(address _addr) constant external returns (uint) {
return balance_S_coupons[ _addr ];
}
/*
* Get balance of residual B coupons.
*/
function getBalanceOfResidualBcoupons() constant external returns (uint) {
return residualBcoupons;
}
/*************************************************************************************************/
/* Contractors functions
/* ---------------------
/* The contractor functions designed to support future contractor contracts.
/* These contractors might be out of the blockchain or out of the ethereum blockchain etc.
/* The contractors should follow the FedCoup principle wherever they are implemented. The below
/* list functions are the minimal set of functions which directly updates the coupons
/* and tokens for the user. The contractor criteria will be established as a seperate contract.
/*
/* Contractor also responsible for initial coupon distribution to users without
/* any transactio cost. These coupon distribution might be used to promote specific applications
/* which also supports B, S coupons.
/**************************************************************************************************/
address public contractorImpl;
event ContractorTransferBcoupons(address indexed sender, address indexed receiver, uint numberOfBcoupons);
event ContractorTransferScoupons(address indexed sender, address indexed receiver, uint numberOfScoupons);
modifier onlyContractorImpl() {
if (msg.sender == contractorImpl) {
throw;
}
_;
}
function setContractorImpl(address _contractorImplAddr) onlyPayloadSize(2 * 32) onlyOwner {
contractorImpl = _contractorImplAddr;
}
function contractorTransfer_Bcoupon(address _to, uint _numberOfBcoupons) onlyPayloadSize(2 * 32) onlyContractorImpl external {
balance_B_coupons[msg.sender] = balance_B_coupons[msg.sender].sub(_numberOfBcoupons);
balance_B_coupons[_to] = balance_B_coupons[_to].add(_numberOfBcoupons);
/*
* log event.
*/
ContractorTransferBcoupons(msg.sender, _to, _numberOfBcoupons);
}
function contractorTransferFrom_Bcoupon(address _from, address _to, uint _numberOfBcoupons) onlyPayloadSize(2 * 32) onlyContractorImpl external {
/*
* The B coupons which has to be allowed _from address to _to address.
*/
var _allowance = allowed_B_coupons[_from][msg.sender];
/*
* substract B coupons from _from account.
*/
balance_B_coupons[ _from ] = balance_B_coupons[ _from ].sub( _numberOfBcoupons );
/*
* substract allowed_B_coupons for transfered _numberOfBcoupons.
*/
allowed_B_coupons[_from][msg.sender] = _allowance.sub(_numberOfBcoupons);
/*
* log event.
*/
ContractorTransferBcoupons(_from, _to, _numberOfBcoupons);
}
function contractorTransfer_Scoupon(address _to, uint _numberOfScoupons) onlyPayloadSize(2 * 32) onlyContractorImpl external {
balance_S_coupons[msg.sender] = balance_S_coupons[msg.sender].sub(_numberOfScoupons);
balance_S_coupons[_to] = balance_S_coupons[_to].add(_numberOfScoupons);
/*
* log event.
*/
ContractorTransferScoupons(msg.sender, _to, _numberOfScoupons);
}
function contractorTransferFrom_Scoupon(address _from, address _to, uint _numberOfScoupons) onlyPayloadSize(2 * 32) onlyContractorImpl external {
/*
* The S coupons which has to be allowed _from address to _to address.
*/
var _allowance = allowed_S_coupons[_from][msg.sender];
/*
* substract S coupons from _from account.
*/
balance_S_coupons[ _from ] = balance_S_coupons[ _from ].sub( _numberOfScoupons );
/*
* substract allowed_S_coupons for transfered _numberOfScoupons.
*/
allowed_S_coupons[_from][msg.sender] = _allowance.sub(_numberOfScoupons);
/*
* log event.
*/
ContractorTransferScoupons(_from, _to, _numberOfScoupons);
}
} | 9,475 |
374 | // Emitted when the protocol provider fees bps for a particular `ProtocolControl` is updated. | event ProtocolControlFeeBpsUpdated(address indexed control, uint256 feeBps);
| event ProtocolControlFeeBpsUpdated(address indexed control, uint256 feeBps);
| 16,232 |
557 | // A mapping of all of the user stakes mapped first by pool and then by address. | mapping(address => mapping(uint256 => Stake.Data)) private _stakes;
constructor(
IMintableERC20 _reward,
address _governance
) public {
require(_governance != address(0), "StakingPools: governance address cannot be 0x0");
reward = _reward;
governance = _governance;
| mapping(address => mapping(uint256 => Stake.Data)) private _stakes;
constructor(
IMintableERC20 _reward,
address _governance
) public {
require(_governance != address(0), "StakingPools: governance address cannot be 0x0");
reward = _reward;
governance = _governance;
| 20,345 |
13 | // Manager can upgrade auction code.code . New version of contract code. / | function upgrade(TvmCell code) external override onlyManager accept {
tvm.setcode(code);
tvm.setCurrentCode(code);
onCodeUpgrade();
}
| function upgrade(TvmCell code) external override onlyManager accept {
tvm.setcode(code);
tvm.setCurrentCode(code);
onCodeUpgrade();
}
| 22,743 |
25 | // Wrapping the ERC20 transfer function to avoid missing returns. _tokenAddress The address of bad formed ERC20 token. _to Transfer receiver. _amount Amount to be transfered.return Success of the safeTransfer. / | function _safeTransfer(
address _tokenAddress,
address _to,
uint _amount
)
internal
returns (bool result)
| function _safeTransfer(
address _tokenAddress,
address _to,
uint _amount
)
internal
returns (bool result)
| 41,606 |
9 | // Admin can give '_account' address admin privileges. _account address that should be given admin privileges. / | function addAdmin(address _account) public onlyAdminOrRelay {
_addAdmin(_account);
}
| function addAdmin(address _account) public onlyAdminOrRelay {
_addAdmin(_account);
}
| 47,843 |
39 | // returns the 0 indexed position of the most significant bit of the input x s.t. x >= 2msb and x < 2(msb+1) | function mostSignificantBit(uint256 x) internal pure returns (uint8 r) {
require(x > 0, 'BitMath::mostSignificantBit: zero');
if (x >= 0x100000000000000000000000000000000) {
x >>= 128;
r += 128;
}
if (x >= 0x10000000000000000) {
x >>= 64;
r += 64;
}
if (x >= 0x100000000) {
x >>= 32;
r += 32;
}
if (x >= 0x10000) {
x >>= 16;
r += 16;
}
if (x >= 0x100) {
x >>= 8;
r += 8;
}
if (x >= 0x10) {
x >>= 4;
r += 4;
}
if (x >= 0x4) {
x >>= 2;
r += 2;
}
if (x >= 0x2) r += 1;
}
| function mostSignificantBit(uint256 x) internal pure returns (uint8 r) {
require(x > 0, 'BitMath::mostSignificantBit: zero');
if (x >= 0x100000000000000000000000000000000) {
x >>= 128;
r += 128;
}
if (x >= 0x10000000000000000) {
x >>= 64;
r += 64;
}
if (x >= 0x100000000) {
x >>= 32;
r += 32;
}
if (x >= 0x10000) {
x >>= 16;
r += 16;
}
if (x >= 0x100) {
x >>= 8;
r += 8;
}
if (x >= 0x10) {
x >>= 4;
r += 4;
}
if (x >= 0x4) {
x >>= 2;
r += 2;
}
if (x >= 0x2) r += 1;
}
| 21,683 |
1 | // Non-transferable volleys by recipient address / | mapping(address => Volley[]) public willCallVolleys;
| mapping(address => Volley[]) public willCallVolleys;
| 222 |
177 | // Stakes in liquidity mining pool/incentives address - pool address/wad uint - amount | function stakeInMine(address incentives, uint wad) external {
DSTokenLike(GebIncentivesLike(incentives).stakingToken()).transferFrom(msg.sender, address(this), wad);
_stakeInMine(incentives);
}
| function stakeInMine(address incentives, uint wad) external {
DSTokenLike(GebIncentivesLike(incentives).stakingToken()).transferFrom(msg.sender, address(this), wad);
_stakeInMine(incentives);
}
| 13,006 |
20 | // Sets `amount` as the allowance of `spender` over the `owner`s tokens. This is internal function is equivalent to `approve`, and can be used toe.g. set automatic allowances for certain subsystems, etc. | * Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address _spender, uint256 amount) internal {
require(owner != address(0), "ERC20: approve from the zero address");
require(_spender != address(0), "ERC20: approve to the zero address");
_allowance[owner][_spender] = amount;
emit Approval(owner, _spender, amount);
}
| * Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address _spender, uint256 amount) internal {
require(owner != address(0), "ERC20: approve from the zero address");
require(_spender != address(0), "ERC20: approve to the zero address");
_allowance[owner][_spender] = amount;
emit Approval(owner, _spender, amount);
}
| 14,103 |
536 | // adjustments[15]/mload(0x4fa0), Constraint expression for ecdsa/signature0/exponentiate_key/bit_extraction_end: column21_row3. | let val := /*column21_row3*/ mload(0x39a0)
| let val := /*column21_row3*/ mload(0x39a0)
| 20,853 |
2 | // @custom:security-contact joe.weepa19@bk.ru | contract BETAVERSE is Initializable, ERC20Upgradeable, OwnableUpgradeable, UUPSUpgradeable {
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() initializer {}
function initialize() initializer public {
__ERC20_init("BETAVERSE", "BETA");
__Ownable_init();
__UUPSUpgradeable_init();
_mint(msg.sender, 3000 * 10 ** decimals());
}
function mint(address to, uint256 amount) public onlyOwner {
_mint(to, amount);
}
function _authorizeUpgrade(address newImplementation)
internal
onlyOwner
override
{}
}
| contract BETAVERSE is Initializable, ERC20Upgradeable, OwnableUpgradeable, UUPSUpgradeable {
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() initializer {}
function initialize() initializer public {
__ERC20_init("BETAVERSE", "BETA");
__Ownable_init();
__UUPSUpgradeable_init();
_mint(msg.sender, 3000 * 10 ** decimals());
}
function mint(address to, uint256 amount) public onlyOwner {
_mint(to, amount);
}
function _authorizeUpgrade(address newImplementation)
internal
onlyOwner
override
{}
}
| 16,704 |
6 | // mumbai | registry := 0xff7Ca10aF37178BdD056628eF42fD7F799fAc77c
| registry := 0xff7Ca10aF37178BdD056628eF42fD7F799fAc77c
| 33,879 |
184 | // Address of the contract responsible for post rebase syncs with AMMs | address private _deprecated_rebaseHooksAddr = address(0);
| address private _deprecated_rebaseHooksAddr = address(0);
| 48,063 |
98 | // Function to allow admin to claim other BEP20 tokens sent to this contract (by mistake) | function transferBEP20Tokens(address _tokenAddr, address _to, uint _amount) public onlyOwner {
require(_tokenAddr != address(this), "Cannot transfer out native token");
IERC20(_tokenAddr).transfer(_to, _amount);
}
| function transferBEP20Tokens(address _tokenAddr, address _to, uint _amount) public onlyOwner {
require(_tokenAddr != address(this), "Cannot transfer out native token");
IERC20(_tokenAddr).transfer(_to, _amount);
}
| 22,710 |
19 | // Customerrors | error Unauthorized(address caller);
error DeadlineError(uint deadline);
error CampaignStatusError(uint status);
error LockError();
error TransferError(uint campaignId, uint amount, address recipient);
error InvalidWithdrawValue(uint _request, uint _available);
error EmergencyMode();
error CampaignEmergencyMode(string message);
| error Unauthorized(address caller);
error DeadlineError(uint deadline);
error CampaignStatusError(uint status);
error LockError();
error TransferError(uint campaignId, uint amount, address recipient);
error InvalidWithdrawValue(uint _request, uint _available);
error EmergencyMode();
error CampaignEmergencyMode(string message);
| 17,614 |
5 | // IGovernedContract--------------------------------- | function _destroy(IGovernedContract _newImpl) internal {
v2storage.setOwner(_newImpl);
}
| function _destroy(IGovernedContract _newImpl) internal {
v2storage.setOwner(_newImpl);
}
| 15,432 |
16 | // allows token owner to list a token for lending. Signature for listForLending(string,uint256,uint32,uint104) : `0x3f3d3e39`tokenId id of the token being listed for lending. serialNoserial Number of the token. lendingPeriod timestamp for number of days for which auction will run. amount timestamp for number of days for which auction will run. / | function listForLending(
| function listForLending(
| 13,991 |
5 | // Send money to the contract | wallet.receiveFunds.value(cost);
return bookingId;
| wallet.receiveFunds.value(cost);
return bookingId;
| 40,496 |
12 | // Query in base -> quote direction, if a pool is found then we are selling the base | address[] memory machines = IDODOV2Registry(registry).getDODOPool(takerToken, makerToken);
sellBase = true;
if (machines.length == 0) {
| address[] memory machines = IDODOV2Registry(registry).getDODOPool(takerToken, makerToken);
sellBase = true;
if (machines.length == 0) {
| 8,478 |
1 | // It takes 12 dropCount to reach at 0.2 floor price in Dutch Auction | return
dropCount < 12
? PUBLIC_SALES_START_PRICE - dropCount * priceDropAmount
: priceDropFloor;
| return
dropCount < 12
? PUBLIC_SALES_START_PRICE - dropCount * priceDropAmount
: priceDropFloor;
| 12,406 |
19 | // Method for getting price required for minting per NFT token | function pricePerToken() public view returns (uint256) {
return _pricePerToken;
}
| function pricePerToken() public view returns (uint256) {
return _pricePerToken;
}
| 7,337 |
60 | // else | bool trigger =
block.number >= priorityRequests[firstPriorityRequestId].expirationBlock &&
priorityRequests[firstPriorityRequestId].expirationBlock != 0;
| bool trigger =
block.number >= priorityRequests[firstPriorityRequestId].expirationBlock &&
priorityRequests[firstPriorityRequestId].expirationBlock != 0;
| 38,233 |
69 | // SafeERC20 Wrappers around ERC20 operations that throw on failure (when the tokencontract returns false). Tokens that return no value (and instead revert orthrow on failure) are also supported, non-reverting calls are assumed to besuccessful.To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,which allows you to call the safe operations as `token.safeTransfer(...)`, etc. / | library SafeERC20 {
using SafeMath for uint256;
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
// solhint-disable-next-line max-line-length
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).add(value);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) { // Return data is optional
// solhint-disable-next-line max-line-length
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
| library SafeERC20 {
using SafeMath for uint256;
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
// solhint-disable-next-line max-line-length
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).add(value);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) { // Return data is optional
// solhint-disable-next-line max-line-length
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
| 224 |
149 | // exclude uniswapV2Router from receiving reward. | _excludeAccountFromReward(address(uniswapV2Router));
| _excludeAccountFromReward(address(uniswapV2Router));
| 21,728 |
3 | // https:explorer.optimism.io/address/0x6d4a64C57612841c2C6745dB2a4E4db34F002D20; | address public constant OWNER = 0x6d4a64C57612841c2C6745dB2a4E4db34F002D20;
| address public constant OWNER = 0x6d4a64C57612841c2C6745dB2a4E4db34F002D20;
| 50,579 |
158 | // set accumulatedSeigniorage to it's balance | accumulatedSeigniorage = IERC20(cash).balanceOf(address(this));
initialized = true;
emit Initialized(msg.sender, block.number);
| accumulatedSeigniorage = IERC20(cash).balanceOf(address(this));
initialized = true;
emit Initialized(msg.sender, block.number);
| 2,165 |
4 | // A helper function to check if the operator is allowed. / | modifier onlyAllowedOperator(address from) virtual {
// Allow spending tokens from addresses with balance
// Note that this still allows listings and marketplaces with escrow to transfer tokens if transferred
// from an EOA.
if (from != msg.sender) {
_checkFilterOperator(msg.sender);
}
_;
}
| modifier onlyAllowedOperator(address from) virtual {
// Allow spending tokens from addresses with balance
// Note that this still allows listings and marketplaces with escrow to transfer tokens if transferred
// from an EOA.
if (from != msg.sender) {
_checkFilterOperator(msg.sender);
}
_;
}
| 6,825 |
1 | // Returns the subtraction of two unsigned integers, reverting onoverflow (when the result is negative). Counterpart to Solidity's `-` operator. Requirements:- Subtraction cannot overflow. / | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, 'SafeMath: subtraction overflow');
}
| function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, 'SafeMath: subtraction overflow');
}
| 12,649 |
4 | // Factory for deploying GeneralTransferManager module / | contract TrackedRedemptionFactory is ModuleFactory {
/**
* @notice Constructor
* @param _setupCost Setup cost of module
* @param _usageCost Usage cost of module
* @param _polymathRegistry Address of the Polymath registry
* @param _isCostInPoly true = cost in Poly, false = USD
*/
constructor(
uint256 _setupCost,
uint256 _usageCost,
address _polymathRegistry,
bool _isCostInPoly
)
public ModuleFactory(_setupCost, _usageCost, _polymathRegistry, _isCostInPoly)
{
initialVersion = "3.0.0";
name = "TrackedRedemption";
title = "Tracked Redemption";
description = "Track token redemptions";
typesData.push(5);
tagsData.push("Tracked");
tagsData.push("Redemption");
compatibleSTVersionRange["lowerBound"] = VersionUtils.pack(uint8(3), uint8(0), uint8(0));
compatibleSTVersionRange["upperBound"] = VersionUtils.pack(uint8(3), uint8(0), uint8(0));
}
/**
* @notice Used to launch the Module with the help of factory
* @return Address Contract address of the Module
*/
function deploy(
bytes calldata _data
)
external
returns(address)
{
address trackedRedemption = address(new TrackedRedemption(msg.sender, IPolymathRegistry(polymathRegistry).getAddress("PolyToken")));
_initializeModule(trackedRedemption, _data);
return trackedRedemption;
}
}
| contract TrackedRedemptionFactory is ModuleFactory {
/**
* @notice Constructor
* @param _setupCost Setup cost of module
* @param _usageCost Usage cost of module
* @param _polymathRegistry Address of the Polymath registry
* @param _isCostInPoly true = cost in Poly, false = USD
*/
constructor(
uint256 _setupCost,
uint256 _usageCost,
address _polymathRegistry,
bool _isCostInPoly
)
public ModuleFactory(_setupCost, _usageCost, _polymathRegistry, _isCostInPoly)
{
initialVersion = "3.0.0";
name = "TrackedRedemption";
title = "Tracked Redemption";
description = "Track token redemptions";
typesData.push(5);
tagsData.push("Tracked");
tagsData.push("Redemption");
compatibleSTVersionRange["lowerBound"] = VersionUtils.pack(uint8(3), uint8(0), uint8(0));
compatibleSTVersionRange["upperBound"] = VersionUtils.pack(uint8(3), uint8(0), uint8(0));
}
/**
* @notice Used to launch the Module with the help of factory
* @return Address Contract address of the Module
*/
function deploy(
bytes calldata _data
)
external
returns(address)
{
address trackedRedemption = address(new TrackedRedemption(msg.sender, IPolymathRegistry(polymathRegistry).getAddress("PolyToken")));
_initializeModule(trackedRedemption, _data);
return trackedRedemption;
}
}
| 46,428 |
35 | // This creates a mapping with all data storage | mapping (address => uint256) private _balanceOf;
mapping (address => mapping (address => uint256)) private _allowance;
| mapping (address => uint256) private _balanceOf;
mapping (address => mapping (address => uint256)) private _allowance;
| 26,385 |
142 | // Calculate the reward amount for the current window - Need to consider pendingForApprovalAmount for Auto Approvals | totalAmount = stakeInfo.approvedAmount.add(stakeInfo.pendingForApprovalAmount);
rewardAmount = _calculateRewardAmount(stakeMapIndex, totalAmount);
totalAmount = totalAmount.add(rewardAmount);
| totalAmount = stakeInfo.approvedAmount.add(stakeInfo.pendingForApprovalAmount);
rewardAmount = _calculateRewardAmount(stakeMapIndex, totalAmount);
totalAmount = totalAmount.add(rewardAmount);
| 51,506 |
8 | // Define an internal function '_removeVerifier' to remove this role, called by 'removeHarvester' | function _removeVerifier(address account) internal {
verifiers.remove(account);
emit VerifierRemoved(account);
}
| function _removeVerifier(address account) internal {
verifiers.remove(account);
emit VerifierRemoved(account);
}
| 30,326 |
90 | // generate the uniswap pair path of token -> weth | address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
| address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
| 30,044 |
0 | // General Attributes // Global Mappings / | constructor() public {
}
| constructor() public {
}
| 9,596 |
178 | // Convert token0 to BCNT via UniswapV3 pool | token0.approve(address(converter), receivedToken0Amount);
converter.convertUniV3(address(token0), receivedToken0Amount, 100, address(BCNT), minAmountBCNTReceived, msg.sender, bcntUniV3SwapPath);
emit RewardPaid(msg.sender, compoundedLPRewardAmount);
| token0.approve(address(converter), receivedToken0Amount);
converter.convertUniV3(address(token0), receivedToken0Amount, 100, address(BCNT), minAmountBCNTReceived, msg.sender, bcntUniV3SwapPath);
emit RewardPaid(msg.sender, compoundedLPRewardAmount);
| 6,882 |
30 | // add liquidity to uniswap | addLiquidity(otherHalf, newBalance);
emit SwapAndLiquify(half, newBalance, otherHalf);
| addLiquidity(otherHalf, newBalance);
emit SwapAndLiquify(half, newBalance, otherHalf);
| 5,059 |
11 | // Replaces an existing Signature with empty string | fingerprintSignatureMapping[sha3(digitalFingerprint)] = "";
| fingerprintSignatureMapping[sha3(digitalFingerprint)] = "";
| 43,145 |
412 | // verify allowance decrease doesn't underflow | require(currentVal >= _value, "ERC20: decreased allowance below zero");
| require(currentVal >= _value, "ERC20: decreased allowance below zero");
| 7,118 |
112 | // informs generator of withdrawal (all funds) | function withdrawFunds(address policyBookAddress, uint256 nftIndex) external returns (uint256);
| function withdrawFunds(address policyBookAddress, uint256 nftIndex) external returns (uint256);
| 24,521 |
165 | // Returns `true` if latest update request posted to the Witnet Request Board / has not been solved yet by the Witnet oracle. | function pendingUpdate() external view returns (bool);
| function pendingUpdate() external view returns (bool);
| 38,115 |
8 | // Strong Holder Offering (SHO) contract used to collect funds from SHO lottery winners./DAO Maker/The flow is the following:/ 1. SHO Organizer runs the lottery off-chain./ 2. Once the winners are selected, for every winner, the SHO Organzier signs a message cointaining the SHO information./The signing, as well as the signature storage, is done off-chain./ 3. Winners call this contract passing in the signature and the relevant SHO data. By doing this they confirm their/particiaption in the SHO (i.e. claim their winning spot) and transfer the funds required to participate./ 4. The SHO contract verifies the signature, to make sure it | contract SHO is Ownable, Pausable {
using ECDSA for bytes32;
using SafeERC20 for IERC20;
address public shoOrganizer;
address public depositReceiver;
mapping(string => mapping(address => bool)) public depositsForSho;
mapping(string => uint) public depositedAmount;
event ShoOrganizerChanged(
address oldShoOrganizer,
address newShoOrganizer
);
event DepositReceiverChanged(
address oldDepositReceiver,
address newDepositReceiver
);
event Deposited(
address indexed winner,
string indexed indexedShoId,
string shoId,
IERC20 depositToken,
uint amount,
uint deadline,
address indexed depositReceiver,
address shoOrganizer,
uint maxTotalAmount
);
event RecoveredERC20(
uint amount,
IERC20 token
);
constructor(address _shoOrganizer, address _depositReceiver) {
shoOrganizer = _shoOrganizer;
depositReceiver = _depositReceiver;
emit ShoOrganizerChanged(address(0), _shoOrganizer);
emit DepositReceiverChanged(address(0), _depositReceiver);
}
function setShoOrganizer(address _shoOrganizer) external onlyOwner {
emit ShoOrganizerChanged(shoOrganizer, _shoOrganizer);
shoOrganizer = _shoOrganizer;
}
function setDepositReceiver(address _depositReceiver) external onlyOwner {
emit DepositReceiverChanged(depositReceiver, _depositReceiver);
depositReceiver = _depositReceiver;
}
function pause() external onlyOwner {
_pause();
}
function unpause() external onlyOwner {
_unpause();
}
/// @notice Verifies that the passed SHO data is signed correctly and that the signature comes from the SHO Organizer.
/// If all checks out, the caller is marked in contract storage and funds are transferred from the caller to the predefined
/// fund receiver.
/// @dev Callable by any account. Security is based on the passed signature. Pausable by the owner.
/// @param signature Signature from the SHO Organizer. The message signed contains the winner address and the other parameters
/// passed in the call.
/// @param shoId An opaque SHO identifier.
/// @param depositToken Address of an ERC20-compatible token used for deposits in this SHO. The winner must first set the token
/// allowance of this contract for the `amount` or more.
/// @param amount Amount of tokens the winner is allowed to send. The unit is the base unit of the `depositToken`
/// (i.e. the smallest subdenomination of the token).
/// @param deadline Time until the winners have to call this function (in Unix time).
/// @param maxTotalAmount The maximum amount that can be deposited for a given shoId.
function deposit(
bytes calldata signature,
string calldata shoId,
IERC20 depositToken,
uint amount,
uint deadline,
uint maxTotalAmount
) external whenNotPaused {
address winner = msg.sender;
require(!depositsForSho[shoId][winner], "SHO: this wallet already made a deposit for this SHO");
require(block.timestamp <= deadline, "SHO: the deadline for this SHO has passed");
depositedAmount[shoId] += amount;
require(depositedAmount[shoId] <= maxTotalAmount, "SHO: the maximum amount of deposits have been reached");
bytes32 dataHash = keccak256(abi.encodePacked(winner, shoId, depositToken, amount, deadline, depositReceiver, maxTotalAmount));
require(dataHash.toEthSignedMessageHash().recover(signature) == shoOrganizer, "SHO: signature verification failed");
depositsForSho[shoId][winner] = true;
depositToken.safeTransferFrom(winner, depositReceiver, amount);
emit Deposited(winner, shoId, shoId, depositToken, amount, deadline, depositReceiver, shoOrganizer, maxTotalAmount);
}
/// @notice Recovers any tokens unintentionally sent to this contract. This contract is not meant to hold any funds.
/// @dev The admin can call this to recover any tokens sent mistakenly to this contract by users.
/// @param token ERC20 token address to be recovered.
function recoverERC20(IERC20 token) external onlyOwner {
uint balance = token.balanceOf(address(this));
token.safeTransfer(msg.sender, balance);
emit RecoveredERC20(balance, token);
}
}
| contract SHO is Ownable, Pausable {
using ECDSA for bytes32;
using SafeERC20 for IERC20;
address public shoOrganizer;
address public depositReceiver;
mapping(string => mapping(address => bool)) public depositsForSho;
mapping(string => uint) public depositedAmount;
event ShoOrganizerChanged(
address oldShoOrganizer,
address newShoOrganizer
);
event DepositReceiverChanged(
address oldDepositReceiver,
address newDepositReceiver
);
event Deposited(
address indexed winner,
string indexed indexedShoId,
string shoId,
IERC20 depositToken,
uint amount,
uint deadline,
address indexed depositReceiver,
address shoOrganizer,
uint maxTotalAmount
);
event RecoveredERC20(
uint amount,
IERC20 token
);
constructor(address _shoOrganizer, address _depositReceiver) {
shoOrganizer = _shoOrganizer;
depositReceiver = _depositReceiver;
emit ShoOrganizerChanged(address(0), _shoOrganizer);
emit DepositReceiverChanged(address(0), _depositReceiver);
}
function setShoOrganizer(address _shoOrganizer) external onlyOwner {
emit ShoOrganizerChanged(shoOrganizer, _shoOrganizer);
shoOrganizer = _shoOrganizer;
}
function setDepositReceiver(address _depositReceiver) external onlyOwner {
emit DepositReceiverChanged(depositReceiver, _depositReceiver);
depositReceiver = _depositReceiver;
}
function pause() external onlyOwner {
_pause();
}
function unpause() external onlyOwner {
_unpause();
}
/// @notice Verifies that the passed SHO data is signed correctly and that the signature comes from the SHO Organizer.
/// If all checks out, the caller is marked in contract storage and funds are transferred from the caller to the predefined
/// fund receiver.
/// @dev Callable by any account. Security is based on the passed signature. Pausable by the owner.
/// @param signature Signature from the SHO Organizer. The message signed contains the winner address and the other parameters
/// passed in the call.
/// @param shoId An opaque SHO identifier.
/// @param depositToken Address of an ERC20-compatible token used for deposits in this SHO. The winner must first set the token
/// allowance of this contract for the `amount` or more.
/// @param amount Amount of tokens the winner is allowed to send. The unit is the base unit of the `depositToken`
/// (i.e. the smallest subdenomination of the token).
/// @param deadline Time until the winners have to call this function (in Unix time).
/// @param maxTotalAmount The maximum amount that can be deposited for a given shoId.
function deposit(
bytes calldata signature,
string calldata shoId,
IERC20 depositToken,
uint amount,
uint deadline,
uint maxTotalAmount
) external whenNotPaused {
address winner = msg.sender;
require(!depositsForSho[shoId][winner], "SHO: this wallet already made a deposit for this SHO");
require(block.timestamp <= deadline, "SHO: the deadline for this SHO has passed");
depositedAmount[shoId] += amount;
require(depositedAmount[shoId] <= maxTotalAmount, "SHO: the maximum amount of deposits have been reached");
bytes32 dataHash = keccak256(abi.encodePacked(winner, shoId, depositToken, amount, deadline, depositReceiver, maxTotalAmount));
require(dataHash.toEthSignedMessageHash().recover(signature) == shoOrganizer, "SHO: signature verification failed");
depositsForSho[shoId][winner] = true;
depositToken.safeTransferFrom(winner, depositReceiver, amount);
emit Deposited(winner, shoId, shoId, depositToken, amount, deadline, depositReceiver, shoOrganizer, maxTotalAmount);
}
/// @notice Recovers any tokens unintentionally sent to this contract. This contract is not meant to hold any funds.
/// @dev The admin can call this to recover any tokens sent mistakenly to this contract by users.
/// @param token ERC20 token address to be recovered.
function recoverERC20(IERC20 token) external onlyOwner {
uint balance = token.balanceOf(address(this));
token.safeTransfer(msg.sender, balance);
emit RecoveredERC20(balance, token);
}
}
| 28,611 |
83 | // Returns if the `operator` is allowed to manage all of the assets of `owner`. See {setApprovalForAll} / | function isApprovedForAll(address owner, address operator) external view returns (bool);
| function isApprovedForAll(address owner, address operator) external view returns (bool);
| 6,986 |
18 | // Store the result | let value := mload(0xc0)
| let value := mload(0xc0)
| 34,539 |
8 | // View all aggregated stakes / | function totalStakes() public view returns(uint256) {
uint256 _totalStakes = 0;
for (uint256 s = 0; s < stakeholders.length; s += 1){
_totalStakes = _totalStakes.add(stakes[stakeholders[s]]);
}
return _totalStakes;
}
| function totalStakes() public view returns(uint256) {
uint256 _totalStakes = 0;
for (uint256 s = 0; s < stakeholders.length; s += 1){
_totalStakes = _totalStakes.add(stakes[stakeholders[s]]);
}
return _totalStakes;
}
| 44,463 |
14 | // solium-disable-next-line security/no-inline-assembly | assembly {
if eq(call(gas, proxy, 0, add(data, 0x20), mload(data), 0, 0), 0) { revert(0, 0) }
| assembly {
if eq(call(gas, proxy, 0, add(data, 0x20), mload(data), 0, 0), 0) { revert(0, 0) }
| 33,296 |
3 | // funcion envia moneda existente | function send(address receiver, uint amount) public {
if (amount > balances[msg.sender])
revert InsufficentBalance({
requested: amount,
available: balances[msg.sender]
});
balances [msg.sender] -= amount;
balances[receiver] += amount;
emit Sent(msg.sender, receiver, amount);
}
| function send(address receiver, uint amount) public {
if (amount > balances[msg.sender])
revert InsufficentBalance({
requested: amount,
available: balances[msg.sender]
});
balances [msg.sender] -= amount;
balances[receiver] += amount;
emit Sent(msg.sender, receiver, amount);
}
| 25,140 |
6 | // naive, no-calculation swapper.- the exchange rate is fixed at construction- mints new tokens at will... | contract TestUniswap is IUniswap {
IERC20 public token;
uint256 public rateMult;
uint256 public rateDiv;
constructor(
uint256 _rateMult,
uint256 _rateDiv,
address tokenAddress
) public payable {
token = IERC20(tokenAddress);
rateMult = _rateMult;
rateDiv = _rateDiv;
require(msg.value > 0, 'must specify liquidity');
require(rateMult != 0 && rateDiv != 0, 'bad mult,div');
}
// solhint-disable-next-line no-empty-blocks
receive() external payable {}
function tokenAddress() external view override returns (address out) {
return address(token);
}
function tokenToEthSwapOutput(
uint256 ethBought,
uint256 maxTokens,
uint256 deadline
) public override returns (uint256 out) {
(maxTokens, deadline);
uint256 tokensToSell = getTokenToEthOutputPrice(ethBought);
require(address(this).balance > ethBought, 'not enough liquidity');
token.transferFrom(msg.sender, address(this), tokensToSell);
msg.sender.send(ethBought);
return tokensToSell;
}
function getTokenToEthInputPrice(uint256 tokensSold)
external
view
override
returns (uint256 out)
{
return tokensSold * (rateDiv / rateMult);
}
function tokenToEthTransferOutput(
uint256 ethBought,
uint256 maxTokens,
uint256 deadline,
address payable recipient
) external override returns (uint256 out) {
(maxTokens, deadline, recipient);
require(address(this).balance > ethBought, 'not enough liquidity');
uint256 tokensToSell = getTokenToEthOutputPrice(ethBought);
token.transferFrom(msg.sender, address(this), tokensToSell);
recipient.transfer(ethBought);
return tokensToSell;
}
function getTokenToEthOutputPrice(uint256 ethBought) public view override returns (uint256 out) {
return (ethBought * rateMult) / rateDiv;
}
}
| contract TestUniswap is IUniswap {
IERC20 public token;
uint256 public rateMult;
uint256 public rateDiv;
constructor(
uint256 _rateMult,
uint256 _rateDiv,
address tokenAddress
) public payable {
token = IERC20(tokenAddress);
rateMult = _rateMult;
rateDiv = _rateDiv;
require(msg.value > 0, 'must specify liquidity');
require(rateMult != 0 && rateDiv != 0, 'bad mult,div');
}
// solhint-disable-next-line no-empty-blocks
receive() external payable {}
function tokenAddress() external view override returns (address out) {
return address(token);
}
function tokenToEthSwapOutput(
uint256 ethBought,
uint256 maxTokens,
uint256 deadline
) public override returns (uint256 out) {
(maxTokens, deadline);
uint256 tokensToSell = getTokenToEthOutputPrice(ethBought);
require(address(this).balance > ethBought, 'not enough liquidity');
token.transferFrom(msg.sender, address(this), tokensToSell);
msg.sender.send(ethBought);
return tokensToSell;
}
function getTokenToEthInputPrice(uint256 tokensSold)
external
view
override
returns (uint256 out)
{
return tokensSold * (rateDiv / rateMult);
}
function tokenToEthTransferOutput(
uint256 ethBought,
uint256 maxTokens,
uint256 deadline,
address payable recipient
) external override returns (uint256 out) {
(maxTokens, deadline, recipient);
require(address(this).balance > ethBought, 'not enough liquidity');
uint256 tokensToSell = getTokenToEthOutputPrice(ethBought);
token.transferFrom(msg.sender, address(this), tokensToSell);
recipient.transfer(ethBought);
return tokensToSell;
}
function getTokenToEthOutputPrice(uint256 ethBought) public view override returns (uint256 out) {
return (ethBought * rateMult) / rateDiv;
}
}
| 264 |
283 | // Emits an {Approval} event. / | function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId); // internal owner
}
| function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId); // internal owner
}
| 1,882 |
46 | // Must transfer the entire block value or leave at least 5 | require(newBlockValue == 0 || newBlockValue >= 5 finney);
require(sourceTileClaimer == _msgSender);
require(destTileClaimer == _msgSender);
require(_moveAmount >= 1 finney); // Can't be less
require(_moveAmount % 1 finney == 0); // Move amount must be in multiples of 1 finney
| require(newBlockValue == 0 || newBlockValue >= 5 finney);
require(sourceTileClaimer == _msgSender);
require(destTileClaimer == _msgSender);
require(_moveAmount >= 1 finney); // Can't be less
require(_moveAmount % 1 finney == 0); // Move amount must be in multiples of 1 finney
| 18,360 |
22 | // Calculate the DOMAIN_SEPARATOR | function _calculateDomainSeparator(uint256 chainId) private view returns (bytes32) {
return keccak256(
abi.encode(
DOMAIN_SEPARATOR_SIGNATURE_HASH,
chainId,
address(this)
)
);
}
| function _calculateDomainSeparator(uint256 chainId) private view returns (bytes32) {
return keccak256(
abi.encode(
DOMAIN_SEPARATOR_SIGNATURE_HASH,
chainId,
address(this)
)
);
}
| 19,908 |
4 | // Create contract using a minimal proxy and call initializer | bytes memory initializer = abi.encodeWithSignature(
"initialize(address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,uint8,bool)",
_owner,
_beneficiary,
_token,
_managedAmount,
_startTime,
_endTime,
_periods,
_releaseStartTime,
| bytes memory initializer = abi.encodeWithSignature(
"initialize(address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,uint8,bool)",
_owner,
_beneficiary,
_token,
_managedAmount,
_startTime,
_endTime,
_periods,
_releaseStartTime,
| 10,913 |
58 | // gives square root of given x./ | function sqrt(uint256 x)
internal
pure
returns (uint256 y)
| function sqrt(uint256 x)
internal
pure
returns (uint256 y)
| 28,860 |
27 | // Deposit to PowerPerpetual. | amount = finalBalance.sub(initialBalance);
perpetual.deposit(transfer.account, amount);
| amount = finalBalance.sub(initialBalance);
perpetual.deposit(transfer.account, amount);
| 17,444 |
4 | // Withdraws the already delisted from marketplace asset./ Burns the asset and transfers the original metaverse asset represented by the asset to the asset owner./ Pays out any unclaimed rent to consumer if set, otherwise it is paid to the owner of the LandWorks NFT/_assetId The target _assetId | function withdraw(uint256 _assetId) external;
| function withdraw(uint256 _assetId) external;
| 568 |
17 | // Sets asset proxy address./ Can be set only once./function is final, and must not be overridden./_proxy asset proxy contract address./ return success. | function init(ChronoBankAssetProxy _proxy) public returns(bool) {
if (address(proxy) != 0x0) {
return false;
}
proxy = _proxy;
return true;
}
| function init(ChronoBankAssetProxy _proxy) public returns(bool) {
if (address(proxy) != 0x0) {
return false;
}
proxy = _proxy;
return true;
}
| 43,322 |
158 | // res += val(coefficients[14] + coefficients[15]adjustments[1]). | res := addmod(res,
mulmod(val,
add(/*coefficients[14]*/ mload(0x600),
mulmod(/*coefficients[15]*/ mload(0x620),
| res := addmod(res,
mulmod(val,
add(/*coefficients[14]*/ mload(0x600),
mulmod(/*coefficients[15]*/ mload(0x620),
| 20,693 |
84 | // Calculate collateral pool shares | uint256 shares = 0;
if (pool == 0) {
shares = _amount;
pool = _amount;
} else {
| uint256 shares = 0;
if (pool == 0) {
shares = _amount;
pool = _amount;
} else {
| 11,341 |
107 | // Instantiate DebtLocker if it doesn't exist withing this factory | if (debtLocker == address(0)) {
debtLocker = IDebtLockerFactory(dlFactory).newLocker(loan);
debtLockers[loan][dlFactory] = debtLocker;
}
| if (debtLocker == address(0)) {
debtLocker = IDebtLockerFactory(dlFactory).newLocker(loan);
debtLockers[loan][dlFactory] = debtLocker;
}
| 20,824 |
23 | // Do reverse order of fees charged in joinswap_ExternAmountIn, this way``` pAo == joinswap_ExternAmountIn(Ti, joinswap_PoolAmountOut(pAo, Ti)) ```uint tAi = tAiAfterFee / (1 - (1-weightTi)swapFee) ; | uint zar = bmul(bsub(BONE, normalizedWeight), swapFee);
tokenAmountIn = bdiv(tokenAmountInAfterFee, bsub(BONE, zar));
return tokenAmountIn;
| uint zar = bmul(bsub(BONE, normalizedWeight), swapFee);
tokenAmountIn = bdiv(tokenAmountInAfterFee, bsub(BONE, zar));
return tokenAmountIn;
| 49,871 |
27 | // See {IDynamicBlueprint.prepareBlueprintAndCreateSale} / | function prepareBlueprintAndCreateSale(
BlueprintPreparationConfig calldata config,
IStorefront.Sale memory sale,
address storefront
) external override onlyRole(MINTER_ROLE) {
require(blueprint.prepared == false, "already prepared");
require(hasRole(STOREFRONT_MINTER_ROLE, storefront), "Storefront not authorized to mint");
blueprint.capacity = config._capacity;
_setupBlueprint(config._baseTokenUri, config._blueprintMetaData, config._isSoulbound);
| function prepareBlueprintAndCreateSale(
BlueprintPreparationConfig calldata config,
IStorefront.Sale memory sale,
address storefront
) external override onlyRole(MINTER_ROLE) {
require(blueprint.prepared == false, "already prepared");
require(hasRole(STOREFRONT_MINTER_ROLE, storefront), "Storefront not authorized to mint");
blueprint.capacity = config._capacity;
_setupBlueprint(config._baseTokenUri, config._blueprintMetaData, config._isSoulbound);
| 35,862 |
5 | // 批量mint,地址不足自动创建target mint合约地址times mint的次数data mint的inputdata/ | function batch_mint(address target, uint8 times, bytes calldata data) external payable{
fooyao.batch_mint{value: msg.value}(msg.sender, target, times, data);
}
| function batch_mint(address target, uint8 times, bytes calldata data) external payable{
fooyao.batch_mint{value: msg.value}(msg.sender, target, times, data);
}
| 46,975 |
3 | // Transfers ownership of the contract to a new account (`newOwner`).Can only be called by the current owner. _newOwner address of the new owner / | function transferOwnership(address _newOwner) external virtual onlyOwner {
if (_newOwner == address(0)) {
revert Ownable__NewOwnerIsZeroAddress();
}
_transferOwnership(_newOwner);
}
| function transferOwnership(address _newOwner) external virtual onlyOwner {
if (_newOwner == address(0)) {
revert Ownable__NewOwnerIsZeroAddress();
}
_transferOwnership(_newOwner);
}
| 5,963 |
14 | // reset staking time | stakes[i].startDate = block.timestamp;
| stakes[i].startDate = block.timestamp;
| 51,774 |
1 | // Recover ETH stored in the contract to The destination address amount Amount to be sentonly callable by `owner()` / | function recoverEth(address payable to, uint256 amount) external override onlyOwner {
_recoverEth(to, amount);
}
| function recoverEth(address payable to, uint256 amount) external override onlyOwner {
_recoverEth(to, amount);
}
| 1,979 |
2 | // Returns the total amount of Pool tokens, including those that are not currently in the Vault ('managed'). / | function total(bytes32 balance) internal pure returns (uint256) {
// Since 'cash' and 'managed' are 112 bit values, we don't need checked arithmetic. Additionally, `toBalance`
// ensures that 'total' always fits in 112 bits.
return cash(balance) + managed(balance);
}
| function total(bytes32 balance) internal pure returns (uint256) {
// Since 'cash' and 'managed' are 112 bit values, we don't need checked arithmetic. Additionally, `toBalance`
// ensures that 'total' always fits in 112 bits.
return cash(balance) + managed(balance);
}
| 21,161 |
10 | // hold all details of the winner | WinningContestDetails[] private winningContests;
| WinningContestDetails[] private winningContests;
| 14,382 |
43 | // first uncom | mintRandom(13,2,2);
mintRandom(17,1,1);
if(founderpackcap1 > 0){
mintRandom(3,1,1);
sickgain = sickbonusbase * 2;
xpgain = userxpgainbase * 2;
founderpackcap1 --;
| mintRandom(13,2,2);
mintRandom(17,1,1);
if(founderpackcap1 > 0){
mintRandom(3,1,1);
sickgain = sickbonusbase * 2;
xpgain = userxpgainbase * 2;
founderpackcap1 --;
| 12,046 |
20 | // string memory tempImage = string(abi.encodePacked("https:storage.googleapis.com/opensea-prod.appspot.com/puffs/", uint2str(bagID),".png")); | string memory tempImage = unrevealed;
if (isMechRevealed[bagID])
{
tempImage = string(abi.encodePacked(baseTokenURI(), uint2str(bagID), ".png"));
}
| string memory tempImage = unrevealed;
if (isMechRevealed[bagID])
{
tempImage = string(abi.encodePacked(baseTokenURI(), uint2str(bagID), ".png"));
}
| 18,969 |
40 | // RequestHashStorage This contract is the entry point to retrieve all the hashes of the request network system./ | contract RequestHashStorage is WhitelistedRole {
// Event to declare a new hash
event NewHash(string hash, address hashSubmitter, bytes feesParameters);
/**
* @notice Declare a new hash
* @param _hash hash to store
* @param _feesParameters Parameters use to compute the fees. This is a bytes to stay generic, the structure is on the charge of the hashSubmitter contracts.
*/
function declareNewHash(string calldata _hash, bytes calldata _feesParameters)
external
onlyWhitelisted
{
// Emit event for log
emit NewHash(_hash, msg.sender, _feesParameters);
}
// Fallback function returns funds to the sender
function()
external
{
revert("not payable fallback");
}
}
| contract RequestHashStorage is WhitelistedRole {
// Event to declare a new hash
event NewHash(string hash, address hashSubmitter, bytes feesParameters);
/**
* @notice Declare a new hash
* @param _hash hash to store
* @param _feesParameters Parameters use to compute the fees. This is a bytes to stay generic, the structure is on the charge of the hashSubmitter contracts.
*/
function declareNewHash(string calldata _hash, bytes calldata _feesParameters)
external
onlyWhitelisted
{
// Emit event for log
emit NewHash(_hash, msg.sender, _feesParameters);
}
// Fallback function returns funds to the sender
function()
external
{
revert("not payable fallback");
}
}
| 25,801 |
24 | // we are not accepting enough data to overflow on `_tokenIds` | for (uint256 i = 0; i < _tokenIds.length; i++) {
super._mint(_account, _tokenIds[i]);
emit LogMinted(_account, _tokenIds[i]);
}
| for (uint256 i = 0; i < _tokenIds.length; i++) {
super._mint(_account, _tokenIds[i]);
emit LogMinted(_account, _tokenIds[i]);
}
| 36,609 |
20 | // First check most recent balance | if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
return checkpoints[account][nCheckpoints - 1].votes;
}
| if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
return checkpoints[account][nCheckpoints - 1].votes;
}
| 3,098 |
4 | // anyUSDC -> L1 USDC IUChildERC20 withdraw MaticBridge Bridge | IUChildERC20(address(collateral_token)).withdraw(token_amount);
| IUChildERC20(address(collateral_token)).withdraw(token_amount);
| 29,507 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.