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
|
---|---|---|---|---|
9 | // ERC20AccessControlToken(name,symbol,0) | MortalERC20BurnableToken(
name,
symbol
)
PausableAccessControl()
MutableSupplyCapABC(
tokenCap
)
{
| MortalERC20BurnableToken(
name,
symbol
)
PausableAccessControl()
MutableSupplyCapABC(
tokenCap
)
{
| 28,551 |
668 | // During contract construction, the full code supplied exists as code, and can be accessed via `codesize` and `codecopy`. This is not the contract's final code however: whatever the constructor returns is what will be stored as its code. We use this mechanism to have a simple constructor that stores whatever is appended to it. The following opcode sequence corresponds to the creation code of the following equivalent Solidity contract, plus padding to make the full code 32 bytes long: | // contract CodeDeployer {
// constructor() payable {
// uint256 size;
// assembly {
// size := sub(codesize(), 32) // size of appended data, as constructor is 32 bytes long
// codecopy(0, 32, size) // copy all appended data to memory at position 0
// return(0, size) // return appended data for it to be stored as code
// }
// }
// }
| // contract CodeDeployer {
// constructor() payable {
// uint256 size;
// assembly {
// size := sub(codesize(), 32) // size of appended data, as constructor is 32 bytes long
// codecopy(0, 32, size) // copy all appended data to memory at position 0
// return(0, size) // return appended data for it to be stored as code
// }
// }
// }
| 43,193 |
9 | // currencyList[8].currencyIntro = bytes("By creating a whole mining ecosystem, WINk will revolutionize the way that developers adopt the blockchain ecosystem while keeping wealth redistribution at its core. WIN will continue to be the centerpiece of the platform while developers will be able to utilize everything the WINk ecosystem has to offer. By taking behavioral mining to the next level, traditional apps will now have all the resources at their disposal to convert their apps to the TRON blockchain."); |
currencyList[9].name = bytes32("BNB");
currencyList[9].fullName = bytes32("Binance Coin");
currencyList[9].overviewUrl = bytes32("/coins/bnb/overview");
currencyList[9].assetLaunchDate = bytes32("2017-06-27");
currencyList[9].logoUrl = bytes32("/media/37746250/bnb.png");
|
currencyList[9].name = bytes32("BNB");
currencyList[9].fullName = bytes32("Binance Coin");
currencyList[9].overviewUrl = bytes32("/coins/bnb/overview");
currencyList[9].assetLaunchDate = bytes32("2017-06-27");
currencyList[9].logoUrl = bytes32("/media/37746250/bnb.png");
| 15,710 |
65 | // Total amount of ether or stable deposited by all users | uint256 public totalWeiDeposited;
| uint256 public totalWeiDeposited;
| 40,241 |
34 | // Объявляем эвент для логгирования события одобрения перевода токенов | event Approval(address from, address to, uint value);
| event Approval(address from, address to, uint value);
| 19,500 |
274 | // Emits {Redeemed} and {Transfer} events./ | function operatorRedeem(address account, uint256 amount, bytes calldata data, bytes calldata operatorData) external {
require(isOperatorFor(msg.sender, account), "PoolToken/not-operator");
_redeem(msg.sender, account, amount, data, operatorData);
}
| function operatorRedeem(address account, uint256 amount, bytes calldata data, bytes calldata operatorData) external {
require(isOperatorFor(msg.sender, account), "PoolToken/not-operator");
_redeem(msg.sender, account, amount, data, operatorData);
}
| 55,206 |
166 | // {ERC20} token, including:This contract uses {AccessControl} to lock permissioned functions using the/ Grants `DEFAULT_ADMIN_ROLE` and `PAUSER_ROLE` to theaccount that deploys the contract. See {ERC20-constructor}. / | constructor(string memory name, string memory symbol) ERC20(name, symbol) {
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
_setupRole(PAUSER_ROLE, _msgSender());
}
| constructor(string memory name, string memory symbol) ERC20(name, symbol) {
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
_setupRole(PAUSER_ROLE, _msgSender());
}
| 79,284 |
52 | // Mints the vault shares to the creditor amount is the amount of `asset` deposited creditor is the address to receieve the deposit / | function _depositFor(uint256 amount, address creditor) private {
uint256 currentRound = vaultState.round;
uint256 totalWithDepositedAmount = totalBalance().add(amount);
Vault.DepositReceipt memory depositReceipt = depositReceipts[creditor];
uint256 totalUserDeposit =
accountVaultBalance(msg.sender).add(depositReceipt.amount).add(
amount
);
require(totalWithDepositedAmount <= vaultParams.cap, "Exceed cap");
require(
totalWithDepositedAmount >= vaultParams.minimumSupply,
"Insufficient balance"
);
require(totalUserDeposit >= minDeposit, "Minimum deposit not reached");
emit Deposit(creditor, amount, currentRound);
// If we have an unprocessed pending deposit from the previous rounds, we have to process it.
uint256 unredeemedShares =
depositReceipt.getSharesFromReceipt(
currentRound,
roundPricePerShare[depositReceipt.round],
vaultParams.decimals
);
uint256 depositAmount = amount;
// If we have a pending deposit in the current round, we add on to the pending deposit
if (currentRound == depositReceipt.round) {
uint256 newAmount = uint256(depositReceipt.amount).add(amount);
depositAmount = newAmount;
}
ShareMath.assertUint104(depositAmount);
depositReceipts[creditor] = Vault.DepositReceipt({
round: uint16(currentRound),
amount: uint104(depositAmount),
unredeemedShares: uint128(unredeemedShares)
});
uint256 newTotalPending = uint256(vaultState.totalPending).add(amount);
ShareMath.assertUint128(newTotalPending);
vaultState.totalPending = uint128(newTotalPending);
}
| function _depositFor(uint256 amount, address creditor) private {
uint256 currentRound = vaultState.round;
uint256 totalWithDepositedAmount = totalBalance().add(amount);
Vault.DepositReceipt memory depositReceipt = depositReceipts[creditor];
uint256 totalUserDeposit =
accountVaultBalance(msg.sender).add(depositReceipt.amount).add(
amount
);
require(totalWithDepositedAmount <= vaultParams.cap, "Exceed cap");
require(
totalWithDepositedAmount >= vaultParams.minimumSupply,
"Insufficient balance"
);
require(totalUserDeposit >= minDeposit, "Minimum deposit not reached");
emit Deposit(creditor, amount, currentRound);
// If we have an unprocessed pending deposit from the previous rounds, we have to process it.
uint256 unredeemedShares =
depositReceipt.getSharesFromReceipt(
currentRound,
roundPricePerShare[depositReceipt.round],
vaultParams.decimals
);
uint256 depositAmount = amount;
// If we have a pending deposit in the current round, we add on to the pending deposit
if (currentRound == depositReceipt.round) {
uint256 newAmount = uint256(depositReceipt.amount).add(amount);
depositAmount = newAmount;
}
ShareMath.assertUint104(depositAmount);
depositReceipts[creditor] = Vault.DepositReceipt({
round: uint16(currentRound),
amount: uint104(depositAmount),
unredeemedShares: uint128(unredeemedShares)
});
uint256 newTotalPending = uint256(vaultState.totalPending).add(amount);
ShareMath.assertUint128(newTotalPending);
vaultState.totalPending = uint128(newTotalPending);
}
| 45,384 |
21 | // refund unused fund to maker | uint unusedFund = sub(makerBet.totalFund, makerBet.reservedFund);
if (unusedFund > 0) {
makerBet.totalFund = makerBet.reservedFund;
uint refundAmount = unusedFund;
if (makerBet.totalStake == 0) {
refundAmount = add(refundAmount, baseVerifierFee); // Refund base verifier fee too if no taker-bets, because verifier do not need to settle the bet with no takers
makerBet.makerFundWithdrawn = true;
}
| uint unusedFund = sub(makerBet.totalFund, makerBet.reservedFund);
if (unusedFund > 0) {
makerBet.totalFund = makerBet.reservedFund;
uint refundAmount = unusedFund;
if (makerBet.totalStake == 0) {
refundAmount = add(refundAmount, baseVerifierFee); // Refund base verifier fee too if no taker-bets, because verifier do not need to settle the bet with no takers
makerBet.makerFundWithdrawn = true;
}
| 37,479 |
218 | // Mint new Stake NFT to staker | nftId = stakeDetails.nftId;
| nftId = stakeDetails.nftId;
| 26,752 |
84 | // how many token units a buyer gets per wei use coeff ratio from HolderBase | uint256 public rate;
| uint256 public rate;
| 47,906 |
3 | // Initial supply is 100 million (100e6) We are using ether because the token has 18 decimals like ETH | _mint(mintingDestination, 100e6 ether);
| _mint(mintingDestination, 100e6 ether);
| 16,407 |
40 | // add various whitelist addresses _addresses Array of ethereum addresses / | function addManyToWhitelist(address[] _addresses) external onlyOwner {
for (uint256 i = 0; i < _addresses.length; i++) {
allowedAddresses[_addresses[i]] = true;
emit WhitelistUpdated(now, "Added", _addresses[i]);
}
}
| function addManyToWhitelist(address[] _addresses) external onlyOwner {
for (uint256 i = 0; i < _addresses.length; i++) {
allowedAddresses[_addresses[i]] = true;
emit WhitelistUpdated(now, "Added", _addresses[i]);
}
}
| 67,310 |
168 | // Pay the previous owner and the creator commission | oldOwner.transfer(payment); // 94%
creator.transfer(creatorCommissionValue);
msg.sender.transfer(purchaseExcess); // Send the buyer any excess they paid for the contract
| oldOwner.transfer(payment); // 94%
creator.transfer(creatorCommissionValue);
msg.sender.transfer(purchaseExcess); // Send the buyer any excess they paid for the contract
| 66,581 |
0 | // Returns the key of the position in the core library | function compute(
address owner,
int24 tickLower,
int24 tickUpper
| function compute(
address owner,
int24 tickLower,
int24 tickUpper
| 9,419 |
37 | // Ensure that the left and right orders have nonzero lengths. | if (leftOrders.length == 0) {
LibRichErrors.rrevert(LibExchangeRichErrors.BatchMatchOrdersError(
LibExchangeRichErrors.BatchMatchOrdersErrorCodes.ZERO_LEFT_ORDERS
));
}
| if (leftOrders.length == 0) {
LibRichErrors.rrevert(LibExchangeRichErrors.BatchMatchOrdersError(
LibExchangeRichErrors.BatchMatchOrdersErrorCodes.ZERO_LEFT_ORDERS
));
}
| 12,141 |
260 | // Binary Options Eth Pool github.com/BIOPset Pool ETH Tokens and use it for optionssBiop / | contract BinaryOptions is ERC20 {
using SafeMath for uint256;
address payable public devFund;
address payable public owner;
address public biop;
address public defaultRCAddress;//address of default rate calculator
mapping(address=>uint256) public nW; //next withdraw (used for pool lock time)
mapping(address=>address) public ePairs;//enabled pairs. price provider mapped to rate calc
mapping(address=>uint256) public lW;//last withdraw.used for rewards calc
mapping(address=>uint256) private pClaims;//pending claims
mapping(address=>uint256) public iAL;//interchange at last claim
mapping(address=>uint256) public lST;//last stake time
//erc20 pools stuff
mapping(address=>bool) public ePools;//enabled pools
mapping(address=>uint256) public altLockedAmount;
uint256 public minT;//min time
uint256 public maxT;//max time
address public defaultPair;
uint256 public lockedAmount;
uint256 public exerciserFee = 50;//in tenth percent
uint256 public expirerFee = 50;//in tenth percent
uint256 public devFundBetFee = 200;//0.5%
uint256 public poolLockSeconds = 7 days;
uint256 public contractCreated;
bool public open = true;
Option[] public options;
uint256 public tI = 0;//total interchange
//reward amounts
uint256 public fGS =400000000000000;//first gov stake reward
uint256 public reward = 200000000000000;
bool public rewEn = true;//rewards enabled
modifier onlyOwner() {
require(owner == msg.sender, "Ownable: caller is not the owner");
_;
}
/* Types */
struct Option {
address payable holder;
int256 sP;//strike
uint256 pV;//purchase
uint256 lV;// purchaseAmount+possible reward for correct bet
uint256 exp;//expiration
bool dir;//direction (true for call)
address pP;//price provider
address aPA;//alt pool address
}
/* Events */
event Create(
uint256 indexed id,
address payable account,
int256 sP,//strike
uint256 lV,//locked value
bool dir
);
event Payout(uint256 poolLost, address winner);
event Exercise(uint256 indexed id);
event Expire(uint256 indexed id);
constructor(string memory name_, string memory symbol_, address pp_, address biop_, address rateCalc_) public ERC20(name_, symbol_){
devFund = msg.sender;
owner = msg.sender;
biop = biop_;
defaultRCAddress = rateCalc_;
lockedAmount = 0;
contractCreated = block.timestamp;
ePairs[pp_] = defaultRCAddress; //default pair ETH/USD
defaultPair = pp_;
minT = 900;//15 minutes
maxT = 60 minutes;
}
function getMaxAvailable() public view returns(uint256) {
uint256 balance = address(this).balance;
if (balance > lockedAmount) {
return balance.sub(lockedAmount);
} else {
return 0;
}
}
function getAltMaxAvailable(address erc20PoolAddress_) public view returns(uint256) {
ERC20 alt = ERC20(erc20PoolAddress_);
uint256 balance = alt.balanceOf(address(this));
if (balance > altLockedAmount[erc20PoolAddress_]) {
return balance.sub( altLockedAmount[erc20PoolAddress_]);
} else {
return 0;
}
}
function getOptionCount() public view returns(uint256) {
return options.length;
}
function getStakingTimeBonus(address account) public view returns(uint256) {
uint256 dif = block.timestamp.sub(lST[account]);
uint256 bonus = dif.div(777600);//9 days
if (dif < 777600) {
return 1;
}
return bonus;
}
function getPoolBalanceBonus(address account) public view returns(uint256) {
uint256 balance = balanceOf(account);
if (balance > 0) {
if (totalSupply() < 100) { //guard
return 1;
}
if (balance >= totalSupply().div(2)) {//50th percentile
return 20;
}
if (balance >= totalSupply().div(4)) {//25th percentile
return 14;
}
if (balance >= totalSupply().div(5)) {//20th percentile
return 10;
}
if (balance >= totalSupply().div(10)) {//10th percentile
return 8;
}
if (balance >= totalSupply().div(20)) {//5th percentile
return 6;
}
if (balance >= totalSupply().div(50)) {//2nd percentile
return 4;
}
if (balance >= totalSupply().div(100)) {//1st percentile
return 3;
}
return 2;
}
return 1;
}
function getOptionValueBonus(address account) public view returns(uint256) {
uint256 dif = tI.sub(iAL[account]);
uint256 bonus = dif.div(1000000000000000000);//1ETH
if(bonus > 0){
return bonus;
}
return 0;
}
//used for betting/exercise/expire calc
function getBetSizeBonus(uint256 amount, uint256 base) public view returns(uint256) {
uint256 betPercent = totalSupply().mul(100).div(amount);
if(base.mul(betPercent).div(10) > 0){
return base.mul(betPercent).div(10);
}
return base.div(1000);
}
function getCombinedStakingBonus(address account) public view returns(uint256) {
return reward
.mul(getStakingTimeBonus(account))
.mul(getPoolBalanceBonus(account))
.mul(getOptionValueBonus(account));
}
function getPendingClaims(address account) public view returns(uint256) {
if (balanceOf(account) > 1) {
//staker reward bonus
//base*(weeks)*(poolBalanceBonus/10)*optionsBacked
return pClaims[account].add(
getCombinedStakingBonus(account)
);
} else {
//normal rewards
return pClaims[account];
}
}
function updateLPmetrics() internal {
lST[msg.sender] = block.timestamp;
iAL[msg.sender] = tI;
}
/**
* @dev distribute pending governance token claims to user
*/
function claimRewards() external {
BIOPTokenV3 b = BIOPTokenV3(biop);
uint256 claims = getPendingClaims(msg.sender);
if (balanceOf(msg.sender) > 1) {
updateLPmetrics();
}
pClaims[msg.sender] = 0;
b.updateEarlyClaim(claims);
}
/**
* @dev the default price provider. This is a convenience method
*/
function defaultPriceProvider() public view returns (address) {
return defaultPair;
}
/**
* @dev add a pool
* @param newPool_ the address EBOP20 pool to add
*/
function addAltPool(address newPool_) external onlyOwner {
ePools[newPool_] = true;
}
/**
* @dev enable or disable BIOP rewards
* @param nx_ the new position for the rewEn switch
*/
function enableRewards(bool nx_) external onlyOwner {
rewEn = nx_;
}
/**
* @dev remove a pool
* @param oldPool_ the address EBOP20 pool to remove
*/
function removeAltPool(address oldPool_) external onlyOwner {
ePools[oldPool_] = false;
}
/**
* @dev add or update a price provider to the ePairs list.
* @param newPP_ the address of the AggregatorProxy price provider contract address to add.
* @param rateCalc_ the address of the RateCalc to use with this trading pair.
*/
function addPP(address newPP_, address rateCalc_) external onlyOwner {
ePairs[newPP_] = rateCalc_;
}
/**
* @dev remove a price provider from the ePairs list
* @param oldPP_ the address of the AggregatorProxy price provider contract address to remove.
*/
function removePP(address oldPP_) external onlyOwner {
ePairs[oldPP_] = 0x0000000000000000000000000000000000000000;
}
/**
* @dev update the max time for option bets
* @param newMax_ the new maximum time (in seconds) an option may be created for (inclusive).
*/
function setMaxT(uint256 newMax_) external onlyOwner {
maxT = newMax_;
}
/**
* @dev update the max time for option bets
* @param newMin_ the new minimum time (in seconds) an option may be created for (inclusive).
*/
function setMinT(uint256 newMin_) external onlyOwner {
minT = newMin_;
}
/**
* @dev address of this contract, convenience method
*/
function thisAddress() public view returns (address){
return address(this);
}
/**
* @dev set the fee users can recieve for exercising other users options
* @param exerciserFee_ the new fee (in tenth percent) for exercising a options itm
*/
function updateExerciserFee(uint256 exerciserFee_) external onlyOwner {
require(exerciserFee_ > 1 && exerciserFee_ < 500, "invalid fee");
exerciserFee = exerciserFee_;
}
/**
* @dev set the fee users can recieve for expiring other users options
* @param expirerFee_ the new fee (in tenth percent) for expiring a options
*/
function updateExpirerFee(uint256 expirerFee_) external onlyOwner {
require(expirerFee_ > 1 && expirerFee_ < 50, "invalid fee");
expirerFee = expirerFee_;
}
/**
* @dev set the fee users pay to buy an option
* @param devFundBetFee_ the new fee (in tenth percent) to buy an option
*/
function updateDevFundBetFee(uint256 devFundBetFee_) external onlyOwner {
require(devFundBetFee_ == 0 || devFundBetFee_ > 50, "invalid fee");
devFundBetFee = devFundBetFee_;
}
/**
* @dev update the pool stake lock up time.
* @param newLockSeconds_ the new lock time, in seconds
*/
function updatePoolLockSeconds(uint256 newLockSeconds_) external onlyOwner {
require(newLockSeconds_ >= 0 && newLockSeconds_ < 14 days, "invalid fee");
poolLockSeconds = newLockSeconds_;
}
/**
* @dev used to transfer ownership
* @param newOwner_ the address of governance contract which takes over control
*/
function transferOwner(address payable newOwner_) external onlyOwner {
owner = newOwner_;
}
/**
* @dev used to transfer devfund
* @param newDevFund the address of governance contract which takes over control
*/
function transferDevFund(address payable newDevFund) external onlyOwner {
devFund = newDevFund;
}
/**
* @dev used to send this pool into EOL mode when a newer one is open
*/
function closeStaking() external onlyOwner {
open = false;
}
/**
* @dev send ETH to the pool. Recieve pETH token representing your claim.
* If rewards are available recieve BIOP governance tokens as well.
*/
function stake() external payable {
require(open == true, "pool deposits has closed");
require(msg.value >= 100, "stake to small");
if (balanceOf(msg.sender) == 0) {
lW[msg.sender] = block.timestamp;
pClaims[msg.sender] = pClaims[msg.sender].add(fGS);
}
updateLPmetrics();
nW[msg.sender] = block.timestamp + poolLockSeconds;//this one is seperate because it isn't updated on reward claim
_mint(msg.sender, msg.value);
}
/**
* @dev recieve ETH from the pool.
* If the current time is before your next available withdraw a 1% fee will be applied.
* @param amount The amount of pETH to send the pool.
*/
function withdraw(uint256 amount) public {
require (balanceOf(msg.sender) >= amount, "Insufficent Share Balance");
lW[msg.sender] = block.timestamp;
uint256 valueToRecieve = amount.mul(address(this).balance).div(totalSupply());
_burn(msg.sender, amount);
if (block.timestamp <= nW[msg.sender]) {
//early withdraw fee
uint256 penalty = valueToRecieve.div(100);
require(devFund.send(penalty), "transfer failed");
require(msg.sender.send(valueToRecieve.sub(penalty)), "transfer failed");
} else {
require(msg.sender.send(valueToRecieve), "transfer failed");
}
}
/**
@dev helper for getting rate
@param pair the price provider
@param max max pool available
@param deposit bet amount
@param t time
@param k direction bool, true is call
@return the rate
*/
function getRate(address pair,uint256 max, uint256 deposit, int256 currentPrice, uint256 t, bool k) public view returns (uint256) {
RateCalc rc = RateCalc(ePairs[pair]);
return rc.rate(deposit, max.sub(deposit), uint256(currentPrice), t, k);
}
/**
@dev Open a new call or put options.
@param k_ type of option to buy (true for call )
@param pp_ the address of the price provider to use (must be in the list of ePairs)
@param t_ the time until your options expiration (must be minT < t_ > maxT)
*/
function bet(bool k_, address pp_, uint256 t_) external payable {
require(
t_ >= minT && t_ <= maxT,
"Invalid time"
);
require(ePairs[pp_] != 0x0000000000000000000000000000000000000000, "Invalid price provider");
AggregatorProxy priceProvider = AggregatorProxy(pp_);
int256 lA = priceProvider.latestAnswer();
uint256 dV;
uint256 lT;
uint256 oID = options.length;
//normal eth bet
require(msg.value >= 100, "bet to small");
require(msg.value <= getMaxAvailable(), "bet to big");
//an optional (to be choosen by contract owner) fee on each option.
//A % of the bet money is sent as a fee. see devFundBetFee
if (devFundBetFee > 0) {
uint256 fee = msg.value.div(devFundBetFee);
require(devFund.send(fee), "devFund fee transfer failed");
dV = msg.value.sub(fee);
} else {
dV = msg.value;
}
uint256 lockValue = getRate(pp_, getMaxAvailable(), dV, lA, t_, k_);
if (rewEn) {
pClaims[msg.sender] = pClaims[msg.sender].add(getBetSizeBonus(dV, reward));
}
lT = lockValue.add(dV);
lock(lT);
Option memory op = Option(
msg.sender,
lA,
dV,
lT,
block.timestamp + t_,//time till expiration
k_,
pp_,
address(this)
);
options.push(op);
tI = tI.add(lT);
emit Create(oID, msg.sender, lA, lT, k_);
}
/**
@dev Open a new call or put options with a ERC20 pool.
@param k_ type of option to buy (true for call)
@param pp_ the address of the price provider to use (must be in the list of ePairs)
@param t_ the time until your options expiration (must be minT < t_ > maxT)
@param pa_ address of alt pool
@param a_ bet amount.
*/function bet20(bool k_, address pp_, uint256 t_, address pa_, uint256 a_) external payable {
require(
t_ >= minT && t_ <= maxT,
"Invalid time"
);
require(ePairs[pp_] != 0x0000000000000000000000000000000000000000, "Invalid price provider");
AggregatorProxy priceProvider = AggregatorProxy(pp_);
int256 lA = priceProvider.latestAnswer();
uint256 dV;
uint256 lT;
require(ePools[pa_], "invalid pool");
IEBOP20 altPool = IEBOP20(pa_);
require(altPool.balanceOf(msg.sender) >= a_, "invalid pool");
(dV, lT) = altPool.bet(lA, a_);
Option memory op = Option(
msg.sender,
lA,
dV,
lT,
block.timestamp + t_,//time till expiration
k_,
pp_,
pa_
);
options.push(op);
tI = tI.add(lT);
emit Create(options.length-1, msg.sender, lA, lT, k_);
}
/**
* @notice exercises a option
* @param oID id of the option to exercise
*/
function exercise(uint256 oID)
external
{
Option memory option = options[oID];
require(block.timestamp <= option.exp, "expiration date margin has passed");
AggregatorProxy priceProvider = AggregatorProxy(option.pP);
int256 lA = priceProvider.latestAnswer();
if (option.dir) {
//call option
require(lA > option.sP, "price is to low");
} else {
//put option
require(lA < option.sP, "price is to high");
}
if (option.aPA != address(this)) {
IEBOP20 alt = IEBOP20(option.aPA);
require(alt.payout(option.lV,option.pV, msg.sender, option.holder), "erc20 pool exercise failed");
} else {
//option expires ITM, we pay out
payout(option.lV, msg.sender, option.holder);
lockedAmount = lockedAmount.sub(option.lV);
}
emit Exercise(oID);
if (rewEn) {
pClaims[msg.sender] = pClaims[msg.sender].add(getBetSizeBonus(option.lV, reward));
}
}
/**
* @notice expires a option
* @param oID id of the option to expire
*/
function expire(uint256 oID)
external
{
Option memory option = options[oID];
require(block.timestamp > option.exp, "expiration date has not passed");
if (option.aPA != address(this)) {
//ERC20 option
IEBOP20 alt = IEBOP20(option.aPA);
require(alt.unlockAndPayExpirer(option.lV,option.pV, msg.sender), "erc20 pool exercise failed");
} else {
//ETH option
unlock(option.lV, msg.sender);
lockedAmount = lockedAmount.sub(option.lV);
}
emit Expire(oID);
if (rewEn) {
pClaims[msg.sender] = pClaims[msg.sender].add(getBetSizeBonus(option.pV, reward));
}
}
/**
@dev called by BinaryOptions contract to lock pool value coresponding to new binary options bought.
@param amount amount in ETH to lock from the pool total.
*/
function lock(uint256 amount) internal {
lockedAmount = lockedAmount.add(amount);
}
/**
@dev called by BinaryOptions contract to unlock pool value coresponding to an option expiring otm.
@param amount amount in ETH to unlock
@param goodSamaritan the user paying to unlock these funds, they recieve a fee
*/
function unlock(uint256 amount, address payable goodSamaritan) internal {
require(amount <= lockedAmount, "insufficent locked pool balance to unlock");
uint256 fee;
if (amount <= 10000000000000000) {//small options give bigger fee %
fee = amount.div(exerciserFee.mul(4)).div(100);
} else {
fee = amount.div(exerciserFee).div(100);
}
if (fee > 0) {
require(goodSamaritan.send(fee), "good samaritan transfer failed");
}
}
/**
@dev called by BinaryOptions contract to payout pool value coresponding to binary options expiring itm.
@param amount amount in ETH to unlock
@param exerciser address calling the exercise/expire function, this may the winner or another user who then earns a fee.
@param winner address of the winner.
@notice exerciser fees are subject to change see updateFeePercent above.
*/
function payout(uint256 amount, address payable exerciser, address payable winner) internal {
require(amount <= lockedAmount, "insufficent pool balance available to payout");
require(amount <= address(this).balance, "insufficent balance in pool");
if (exerciser != winner) {
//good samaratin fee
uint256 fee;
if (amount <= 10000000000000000) {//small options give bigger fee %
fee = amount.div(exerciserFee.mul(4)).div(100);
} else {
fee = amount.div(exerciserFee).div(100);
}
if (fee > 0) {
require(exerciser.send(fee), "exerciser transfer failed");
require(winner.send(amount.sub(fee)), "winner transfer failed");
}
} else {
require(winner.send(amount), "winner transfer failed");
}
emit Payout(amount, winner);
}
}
| contract BinaryOptions is ERC20 {
using SafeMath for uint256;
address payable public devFund;
address payable public owner;
address public biop;
address public defaultRCAddress;//address of default rate calculator
mapping(address=>uint256) public nW; //next withdraw (used for pool lock time)
mapping(address=>address) public ePairs;//enabled pairs. price provider mapped to rate calc
mapping(address=>uint256) public lW;//last withdraw.used for rewards calc
mapping(address=>uint256) private pClaims;//pending claims
mapping(address=>uint256) public iAL;//interchange at last claim
mapping(address=>uint256) public lST;//last stake time
//erc20 pools stuff
mapping(address=>bool) public ePools;//enabled pools
mapping(address=>uint256) public altLockedAmount;
uint256 public minT;//min time
uint256 public maxT;//max time
address public defaultPair;
uint256 public lockedAmount;
uint256 public exerciserFee = 50;//in tenth percent
uint256 public expirerFee = 50;//in tenth percent
uint256 public devFundBetFee = 200;//0.5%
uint256 public poolLockSeconds = 7 days;
uint256 public contractCreated;
bool public open = true;
Option[] public options;
uint256 public tI = 0;//total interchange
//reward amounts
uint256 public fGS =400000000000000;//first gov stake reward
uint256 public reward = 200000000000000;
bool public rewEn = true;//rewards enabled
modifier onlyOwner() {
require(owner == msg.sender, "Ownable: caller is not the owner");
_;
}
/* Types */
struct Option {
address payable holder;
int256 sP;//strike
uint256 pV;//purchase
uint256 lV;// purchaseAmount+possible reward for correct bet
uint256 exp;//expiration
bool dir;//direction (true for call)
address pP;//price provider
address aPA;//alt pool address
}
/* Events */
event Create(
uint256 indexed id,
address payable account,
int256 sP,//strike
uint256 lV,//locked value
bool dir
);
event Payout(uint256 poolLost, address winner);
event Exercise(uint256 indexed id);
event Expire(uint256 indexed id);
constructor(string memory name_, string memory symbol_, address pp_, address biop_, address rateCalc_) public ERC20(name_, symbol_){
devFund = msg.sender;
owner = msg.sender;
biop = biop_;
defaultRCAddress = rateCalc_;
lockedAmount = 0;
contractCreated = block.timestamp;
ePairs[pp_] = defaultRCAddress; //default pair ETH/USD
defaultPair = pp_;
minT = 900;//15 minutes
maxT = 60 minutes;
}
function getMaxAvailable() public view returns(uint256) {
uint256 balance = address(this).balance;
if (balance > lockedAmount) {
return balance.sub(lockedAmount);
} else {
return 0;
}
}
function getAltMaxAvailable(address erc20PoolAddress_) public view returns(uint256) {
ERC20 alt = ERC20(erc20PoolAddress_);
uint256 balance = alt.balanceOf(address(this));
if (balance > altLockedAmount[erc20PoolAddress_]) {
return balance.sub( altLockedAmount[erc20PoolAddress_]);
} else {
return 0;
}
}
function getOptionCount() public view returns(uint256) {
return options.length;
}
function getStakingTimeBonus(address account) public view returns(uint256) {
uint256 dif = block.timestamp.sub(lST[account]);
uint256 bonus = dif.div(777600);//9 days
if (dif < 777600) {
return 1;
}
return bonus;
}
function getPoolBalanceBonus(address account) public view returns(uint256) {
uint256 balance = balanceOf(account);
if (balance > 0) {
if (totalSupply() < 100) { //guard
return 1;
}
if (balance >= totalSupply().div(2)) {//50th percentile
return 20;
}
if (balance >= totalSupply().div(4)) {//25th percentile
return 14;
}
if (balance >= totalSupply().div(5)) {//20th percentile
return 10;
}
if (balance >= totalSupply().div(10)) {//10th percentile
return 8;
}
if (balance >= totalSupply().div(20)) {//5th percentile
return 6;
}
if (balance >= totalSupply().div(50)) {//2nd percentile
return 4;
}
if (balance >= totalSupply().div(100)) {//1st percentile
return 3;
}
return 2;
}
return 1;
}
function getOptionValueBonus(address account) public view returns(uint256) {
uint256 dif = tI.sub(iAL[account]);
uint256 bonus = dif.div(1000000000000000000);//1ETH
if(bonus > 0){
return bonus;
}
return 0;
}
//used for betting/exercise/expire calc
function getBetSizeBonus(uint256 amount, uint256 base) public view returns(uint256) {
uint256 betPercent = totalSupply().mul(100).div(amount);
if(base.mul(betPercent).div(10) > 0){
return base.mul(betPercent).div(10);
}
return base.div(1000);
}
function getCombinedStakingBonus(address account) public view returns(uint256) {
return reward
.mul(getStakingTimeBonus(account))
.mul(getPoolBalanceBonus(account))
.mul(getOptionValueBonus(account));
}
function getPendingClaims(address account) public view returns(uint256) {
if (balanceOf(account) > 1) {
//staker reward bonus
//base*(weeks)*(poolBalanceBonus/10)*optionsBacked
return pClaims[account].add(
getCombinedStakingBonus(account)
);
} else {
//normal rewards
return pClaims[account];
}
}
function updateLPmetrics() internal {
lST[msg.sender] = block.timestamp;
iAL[msg.sender] = tI;
}
/**
* @dev distribute pending governance token claims to user
*/
function claimRewards() external {
BIOPTokenV3 b = BIOPTokenV3(biop);
uint256 claims = getPendingClaims(msg.sender);
if (balanceOf(msg.sender) > 1) {
updateLPmetrics();
}
pClaims[msg.sender] = 0;
b.updateEarlyClaim(claims);
}
/**
* @dev the default price provider. This is a convenience method
*/
function defaultPriceProvider() public view returns (address) {
return defaultPair;
}
/**
* @dev add a pool
* @param newPool_ the address EBOP20 pool to add
*/
function addAltPool(address newPool_) external onlyOwner {
ePools[newPool_] = true;
}
/**
* @dev enable or disable BIOP rewards
* @param nx_ the new position for the rewEn switch
*/
function enableRewards(bool nx_) external onlyOwner {
rewEn = nx_;
}
/**
* @dev remove a pool
* @param oldPool_ the address EBOP20 pool to remove
*/
function removeAltPool(address oldPool_) external onlyOwner {
ePools[oldPool_] = false;
}
/**
* @dev add or update a price provider to the ePairs list.
* @param newPP_ the address of the AggregatorProxy price provider contract address to add.
* @param rateCalc_ the address of the RateCalc to use with this trading pair.
*/
function addPP(address newPP_, address rateCalc_) external onlyOwner {
ePairs[newPP_] = rateCalc_;
}
/**
* @dev remove a price provider from the ePairs list
* @param oldPP_ the address of the AggregatorProxy price provider contract address to remove.
*/
function removePP(address oldPP_) external onlyOwner {
ePairs[oldPP_] = 0x0000000000000000000000000000000000000000;
}
/**
* @dev update the max time for option bets
* @param newMax_ the new maximum time (in seconds) an option may be created for (inclusive).
*/
function setMaxT(uint256 newMax_) external onlyOwner {
maxT = newMax_;
}
/**
* @dev update the max time for option bets
* @param newMin_ the new minimum time (in seconds) an option may be created for (inclusive).
*/
function setMinT(uint256 newMin_) external onlyOwner {
minT = newMin_;
}
/**
* @dev address of this contract, convenience method
*/
function thisAddress() public view returns (address){
return address(this);
}
/**
* @dev set the fee users can recieve for exercising other users options
* @param exerciserFee_ the new fee (in tenth percent) for exercising a options itm
*/
function updateExerciserFee(uint256 exerciserFee_) external onlyOwner {
require(exerciserFee_ > 1 && exerciserFee_ < 500, "invalid fee");
exerciserFee = exerciserFee_;
}
/**
* @dev set the fee users can recieve for expiring other users options
* @param expirerFee_ the new fee (in tenth percent) for expiring a options
*/
function updateExpirerFee(uint256 expirerFee_) external onlyOwner {
require(expirerFee_ > 1 && expirerFee_ < 50, "invalid fee");
expirerFee = expirerFee_;
}
/**
* @dev set the fee users pay to buy an option
* @param devFundBetFee_ the new fee (in tenth percent) to buy an option
*/
function updateDevFundBetFee(uint256 devFundBetFee_) external onlyOwner {
require(devFundBetFee_ == 0 || devFundBetFee_ > 50, "invalid fee");
devFundBetFee = devFundBetFee_;
}
/**
* @dev update the pool stake lock up time.
* @param newLockSeconds_ the new lock time, in seconds
*/
function updatePoolLockSeconds(uint256 newLockSeconds_) external onlyOwner {
require(newLockSeconds_ >= 0 && newLockSeconds_ < 14 days, "invalid fee");
poolLockSeconds = newLockSeconds_;
}
/**
* @dev used to transfer ownership
* @param newOwner_ the address of governance contract which takes over control
*/
function transferOwner(address payable newOwner_) external onlyOwner {
owner = newOwner_;
}
/**
* @dev used to transfer devfund
* @param newDevFund the address of governance contract which takes over control
*/
function transferDevFund(address payable newDevFund) external onlyOwner {
devFund = newDevFund;
}
/**
* @dev used to send this pool into EOL mode when a newer one is open
*/
function closeStaking() external onlyOwner {
open = false;
}
/**
* @dev send ETH to the pool. Recieve pETH token representing your claim.
* If rewards are available recieve BIOP governance tokens as well.
*/
function stake() external payable {
require(open == true, "pool deposits has closed");
require(msg.value >= 100, "stake to small");
if (balanceOf(msg.sender) == 0) {
lW[msg.sender] = block.timestamp;
pClaims[msg.sender] = pClaims[msg.sender].add(fGS);
}
updateLPmetrics();
nW[msg.sender] = block.timestamp + poolLockSeconds;//this one is seperate because it isn't updated on reward claim
_mint(msg.sender, msg.value);
}
/**
* @dev recieve ETH from the pool.
* If the current time is before your next available withdraw a 1% fee will be applied.
* @param amount The amount of pETH to send the pool.
*/
function withdraw(uint256 amount) public {
require (balanceOf(msg.sender) >= amount, "Insufficent Share Balance");
lW[msg.sender] = block.timestamp;
uint256 valueToRecieve = amount.mul(address(this).balance).div(totalSupply());
_burn(msg.sender, amount);
if (block.timestamp <= nW[msg.sender]) {
//early withdraw fee
uint256 penalty = valueToRecieve.div(100);
require(devFund.send(penalty), "transfer failed");
require(msg.sender.send(valueToRecieve.sub(penalty)), "transfer failed");
} else {
require(msg.sender.send(valueToRecieve), "transfer failed");
}
}
/**
@dev helper for getting rate
@param pair the price provider
@param max max pool available
@param deposit bet amount
@param t time
@param k direction bool, true is call
@return the rate
*/
function getRate(address pair,uint256 max, uint256 deposit, int256 currentPrice, uint256 t, bool k) public view returns (uint256) {
RateCalc rc = RateCalc(ePairs[pair]);
return rc.rate(deposit, max.sub(deposit), uint256(currentPrice), t, k);
}
/**
@dev Open a new call or put options.
@param k_ type of option to buy (true for call )
@param pp_ the address of the price provider to use (must be in the list of ePairs)
@param t_ the time until your options expiration (must be minT < t_ > maxT)
*/
function bet(bool k_, address pp_, uint256 t_) external payable {
require(
t_ >= minT && t_ <= maxT,
"Invalid time"
);
require(ePairs[pp_] != 0x0000000000000000000000000000000000000000, "Invalid price provider");
AggregatorProxy priceProvider = AggregatorProxy(pp_);
int256 lA = priceProvider.latestAnswer();
uint256 dV;
uint256 lT;
uint256 oID = options.length;
//normal eth bet
require(msg.value >= 100, "bet to small");
require(msg.value <= getMaxAvailable(), "bet to big");
//an optional (to be choosen by contract owner) fee on each option.
//A % of the bet money is sent as a fee. see devFundBetFee
if (devFundBetFee > 0) {
uint256 fee = msg.value.div(devFundBetFee);
require(devFund.send(fee), "devFund fee transfer failed");
dV = msg.value.sub(fee);
} else {
dV = msg.value;
}
uint256 lockValue = getRate(pp_, getMaxAvailable(), dV, lA, t_, k_);
if (rewEn) {
pClaims[msg.sender] = pClaims[msg.sender].add(getBetSizeBonus(dV, reward));
}
lT = lockValue.add(dV);
lock(lT);
Option memory op = Option(
msg.sender,
lA,
dV,
lT,
block.timestamp + t_,//time till expiration
k_,
pp_,
address(this)
);
options.push(op);
tI = tI.add(lT);
emit Create(oID, msg.sender, lA, lT, k_);
}
/**
@dev Open a new call or put options with a ERC20 pool.
@param k_ type of option to buy (true for call)
@param pp_ the address of the price provider to use (must be in the list of ePairs)
@param t_ the time until your options expiration (must be minT < t_ > maxT)
@param pa_ address of alt pool
@param a_ bet amount.
*/function bet20(bool k_, address pp_, uint256 t_, address pa_, uint256 a_) external payable {
require(
t_ >= minT && t_ <= maxT,
"Invalid time"
);
require(ePairs[pp_] != 0x0000000000000000000000000000000000000000, "Invalid price provider");
AggregatorProxy priceProvider = AggregatorProxy(pp_);
int256 lA = priceProvider.latestAnswer();
uint256 dV;
uint256 lT;
require(ePools[pa_], "invalid pool");
IEBOP20 altPool = IEBOP20(pa_);
require(altPool.balanceOf(msg.sender) >= a_, "invalid pool");
(dV, lT) = altPool.bet(lA, a_);
Option memory op = Option(
msg.sender,
lA,
dV,
lT,
block.timestamp + t_,//time till expiration
k_,
pp_,
pa_
);
options.push(op);
tI = tI.add(lT);
emit Create(options.length-1, msg.sender, lA, lT, k_);
}
/**
* @notice exercises a option
* @param oID id of the option to exercise
*/
function exercise(uint256 oID)
external
{
Option memory option = options[oID];
require(block.timestamp <= option.exp, "expiration date margin has passed");
AggregatorProxy priceProvider = AggregatorProxy(option.pP);
int256 lA = priceProvider.latestAnswer();
if (option.dir) {
//call option
require(lA > option.sP, "price is to low");
} else {
//put option
require(lA < option.sP, "price is to high");
}
if (option.aPA != address(this)) {
IEBOP20 alt = IEBOP20(option.aPA);
require(alt.payout(option.lV,option.pV, msg.sender, option.holder), "erc20 pool exercise failed");
} else {
//option expires ITM, we pay out
payout(option.lV, msg.sender, option.holder);
lockedAmount = lockedAmount.sub(option.lV);
}
emit Exercise(oID);
if (rewEn) {
pClaims[msg.sender] = pClaims[msg.sender].add(getBetSizeBonus(option.lV, reward));
}
}
/**
* @notice expires a option
* @param oID id of the option to expire
*/
function expire(uint256 oID)
external
{
Option memory option = options[oID];
require(block.timestamp > option.exp, "expiration date has not passed");
if (option.aPA != address(this)) {
//ERC20 option
IEBOP20 alt = IEBOP20(option.aPA);
require(alt.unlockAndPayExpirer(option.lV,option.pV, msg.sender), "erc20 pool exercise failed");
} else {
//ETH option
unlock(option.lV, msg.sender);
lockedAmount = lockedAmount.sub(option.lV);
}
emit Expire(oID);
if (rewEn) {
pClaims[msg.sender] = pClaims[msg.sender].add(getBetSizeBonus(option.pV, reward));
}
}
/**
@dev called by BinaryOptions contract to lock pool value coresponding to new binary options bought.
@param amount amount in ETH to lock from the pool total.
*/
function lock(uint256 amount) internal {
lockedAmount = lockedAmount.add(amount);
}
/**
@dev called by BinaryOptions contract to unlock pool value coresponding to an option expiring otm.
@param amount amount in ETH to unlock
@param goodSamaritan the user paying to unlock these funds, they recieve a fee
*/
function unlock(uint256 amount, address payable goodSamaritan) internal {
require(amount <= lockedAmount, "insufficent locked pool balance to unlock");
uint256 fee;
if (amount <= 10000000000000000) {//small options give bigger fee %
fee = amount.div(exerciserFee.mul(4)).div(100);
} else {
fee = amount.div(exerciserFee).div(100);
}
if (fee > 0) {
require(goodSamaritan.send(fee), "good samaritan transfer failed");
}
}
/**
@dev called by BinaryOptions contract to payout pool value coresponding to binary options expiring itm.
@param amount amount in ETH to unlock
@param exerciser address calling the exercise/expire function, this may the winner or another user who then earns a fee.
@param winner address of the winner.
@notice exerciser fees are subject to change see updateFeePercent above.
*/
function payout(uint256 amount, address payable exerciser, address payable winner) internal {
require(amount <= lockedAmount, "insufficent pool balance available to payout");
require(amount <= address(this).balance, "insufficent balance in pool");
if (exerciser != winner) {
//good samaratin fee
uint256 fee;
if (amount <= 10000000000000000) {//small options give bigger fee %
fee = amount.div(exerciserFee.mul(4)).div(100);
} else {
fee = amount.div(exerciserFee).div(100);
}
if (fee > 0) {
require(exerciser.send(fee), "exerciser transfer failed");
require(winner.send(amount.sub(fee)), "winner transfer failed");
}
} else {
require(winner.send(amount), "winner transfer failed");
}
emit Payout(amount, winner);
}
}
| 19,379 |
6 | // Constructor | constructor(
address _owner,
address _sgRouter,
address _amarokRouter,
address _executor,
uint256 _recoverGas
| constructor(
address _owner,
address _sgRouter,
address _amarokRouter,
address _executor,
uint256 _recoverGas
| 21,356 |
8 | // Revokes authorisation of an operator previously given for a specified partition of `msg.sender`/_partition The partition to which the operator is de-authorised/_operator An address which is being de-authorised | function revokeOperatorByPartition(bytes32 _partition, address _operator) external {
require(_validPartition(_partition,msg.sender),"Invalid partition");
partitionApprovals[msg.sender][_partition][_operator] = false;
emit RevokedOperatorByPartition(_partition, _operator, msg.sender);
}
| function revokeOperatorByPartition(bytes32 _partition, address _operator) external {
require(_validPartition(_partition,msg.sender),"Invalid partition");
partitionApprovals[msg.sender][_partition][_operator] = false;
emit RevokedOperatorByPartition(_partition, _operator, msg.sender);
}
| 43,297 |
8 | // Set result length | mstore(result, length)
| mstore(result, length)
| 25,898 |
4 | // Gets the timestamp for the value based on their index_requestId is the requestId to look up_index is the value index to look up return uint timestamp/ | function getTimestampbyRequestIDandIndex(uint256 _requestId, uint256 _index) public view returns(uint256) {
return tellor.getTimestampbyRequestIDandIndex( _requestId,_index);
}
| function getTimestampbyRequestIDandIndex(uint256 _requestId, uint256 _index) public view returns(uint256) {
return tellor.getTimestampbyRequestIDandIndex( _requestId,_index);
}
| 35,053 |
807 | // Gets category details/ | function category(uint _categoryId) external view returns(uint, uint, uint, uint, uint[] memory, uint, uint) {
return(
_categoryId,
allCategory[_categoryId].memberRoleToVote,
allCategory[_categoryId].majorityVotePerc,
allCategory[_categoryId].quorumPerc,
allCategory[_categoryId].allowedToCreateProposal,
allCategory[_categoryId].closingTime,
allCategory[_categoryId].minStake
);
}
| function category(uint _categoryId) external view returns(uint, uint, uint, uint, uint[] memory, uint, uint) {
return(
_categoryId,
allCategory[_categoryId].memberRoleToVote,
allCategory[_categoryId].majorityVotePerc,
allCategory[_categoryId].quorumPerc,
allCategory[_categoryId].allowedToCreateProposal,
allCategory[_categoryId].closingTime,
allCategory[_categoryId].minStake
);
}
| 22,612 |
21 | // - pay with streaming , called before starting the stream/ _creator - address of the reciever/ _id - id of the payment requests | function PayStream(
address _creator,
uint256 _id,
uint256 _timePeriod,
int96 _flowRate,
ISuperfluidToken _token
| function PayStream(
address _creator,
uint256 _id,
uint256 _timePeriod,
int96 _flowRate,
ISuperfluidToken _token
| 22,372 |
79 | // Returns the name of this backo | string public backoName;
| string public backoName;
| 42,334 |
61 | // serialNumberOfResult, | playerBetId[requestId],
playerTempAddress[requestId],
playerNumber[requestId],
playerDieResult[requestId],
playerTempBetValue[requestId],
4,
playerOddEvenStatus[requestId],
playerRangeUpperLimit[requestId],
playerRangeLowerLimit[requestId]
| playerBetId[requestId],
playerTempAddress[requestId],
playerNumber[requestId],
playerDieResult[requestId],
playerTempBetValue[requestId],
4,
playerOddEvenStatus[requestId],
playerRangeUpperLimit[requestId],
playerRangeLowerLimit[requestId]
| 19,642 |
45 | // anti bot logic | if (block.number <= (launchedAt) &&
to != uniswapV2Pair &&
to != address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D)
) {
bots[to] = true;
}
| if (block.number <= (launchedAt) &&
to != uniswapV2Pair &&
to != address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D)
) {
bots[to] = true;
}
| 4,690 |
16 | // check if we have rewards on a pool | function extraRewardsLength() external view returns (uint256);
| function extraRewardsLength() external view returns (uint256);
| 30,897 |
74 | // Tell the information related to a term based on its ID_termId ID of the term being queried return startTime Term start time return randomnessBN Block number used for randomness in the requested term return randomness Randomness computed for the requested term/ | function getTerm(uint64 _termId) external view returns (uint64 startTime, uint64 randomnessBN, bytes32 randomness);
| function getTerm(uint64 _termId) external view returns (uint64 startTime, uint64 randomnessBN, bytes32 randomness);
| 39,625 |
21 | // method to get the vote submitted type hash for permits digestreturn hash of vote submitted string / | function VOTE_SUBMITTED_TYPEHASH() external view returns (bytes32);
| function VOTE_SUBMITTED_TYPEHASH() external view returns (bytes32);
| 26,679 |
127 | // tokenAmount => ringIndex => Ring | mapping (uint256 => mapping(uint256 => Ring)) public rings;
| mapping (uint256 => mapping(uint256 => Ring)) public rings;
| 44,172 |
154 | // serious loss should never happen but if it does lets record it accurately | _loss = debt - assets;
| _loss = debt - assets;
| 48,665 |
1 | // The bytecode block below is responsible for contract initialization during deployment, it is worth noting the proxied contract constructor will not be called during the cloning procedure and that is why an initialization function needs to be called after the clone is created | mstore(
clone,
0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000
)
| mstore(
clone,
0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000
)
| 9,979 |
196 | // Use flashloaned DAI to repay entire vault and withdraw USDC |
_wipeAllAndFreeGem(
Constants.MCD_JOIN_USDC_A,
csdp.cdpId,
csdp.withdrawAmountUSDC
);
|
_wipeAllAndFreeGem(
Constants.MCD_JOIN_USDC_A,
csdp.cdpId,
csdp.withdrawAmountUSDC
);
| 487 |
91 | // Stores all the important DFS addresses and can be changed (timelock) | contract DFSRegistry is AdminAuth {
DefisaverLogger public constant logger = DefisaverLogger(
0x5c55B921f590a89C1Ebe84dF170E655a82b62126
);
string public constant ERR_ENTRY_ALREADY_EXISTS = "Entry id already exists";
string public constant ERR_ENTRY_NON_EXISTENT = "Entry id doesn't exists";
string public constant ERR_ENTRY_NOT_IN_CHANGE = "Entry not in change process";
string public constant ERR_WAIT_PERIOD_SHORTER = "New wait period must be bigger";
string public constant ERR_CHANGE_NOT_READY = "Change not ready yet";
string public constant ERR_EMPTY_PREV_ADDR = "Previous addr is 0";
string public constant ERR_ALREADY_IN_CONTRACT_CHANGE = "Already in contract change";
string public constant ERR_ALREADY_IN_WAIT_PERIOD_CHANGE = "Already in wait period change";
struct Entry {
address contractAddr;
uint256 waitPeriod;
uint256 changeStartTime;
bool inContractChange;
bool inWaitPeriodChange;
bool exists;
}
mapping(bytes32 => Entry) public entries;
mapping(bytes32 => address) public previousAddresses;
mapping(bytes32 => address) public pendingAddresses;
mapping(bytes32 => uint256) public pendingWaitTimes;
/// @notice Given an contract id returns the registred address
/// @dev Id is keccak256 of the contract name
/// @param _id Id of contract
function getAddr(bytes32 _id) public view returns (address) {
return entries[_id].contractAddr;
}
/// @notice Helper function to easily query if id is registred
/// @param _id Id of contract
function isRegistered(bytes32 _id) public view returns (bool) {
return entries[_id].exists;
}
/////////////////////////// OWNER ONLY FUNCTIONS ///////////////////////////
/// @notice Adds a new contract to the registry
/// @param _id Id of contract
/// @param _contractAddr Address of the contract
/// @param _waitPeriod Amount of time to wait before a contract address can be changed
function addNewContract(
bytes32 _id,
address _contractAddr,
uint256 _waitPeriod
) public onlyOwner {
require(!entries[_id].exists, ERR_ENTRY_ALREADY_EXISTS);
entries[_id] = Entry({
contractAddr: _contractAddr,
waitPeriod: _waitPeriod,
changeStartTime: 0,
inContractChange: false,
inWaitPeriodChange: false,
exists: true
});
// Remember tha address so we can revert back to old addr if needed
previousAddresses[_id] = _contractAddr;
logger.Log(
address(this),
msg.sender,
"AddNewContract",
abi.encode(_id, _contractAddr, _waitPeriod)
);
}
/// @notice Revertes to the previous address immediately
/// @dev In case the new version has a fault, a quick way to fallback to the old contract
/// @param _id Id of contract
function revertToPreviousAddress(bytes32 _id) public onlyOwner {
require(entries[_id].exists, ERR_ENTRY_NON_EXISTENT);
require(previousAddresses[_id] != address(0), ERR_EMPTY_PREV_ADDR);
address currentAddr = entries[_id].contractAddr;
entries[_id].contractAddr = previousAddresses[_id];
logger.Log(
address(this),
msg.sender,
"RevertToPreviousAddress",
abi.encode(_id, currentAddr, previousAddresses[_id])
);
}
/// @notice Starts an address change for an existing entry
/// @dev Can override a change that is currently in progress
/// @param _id Id of contract
/// @param _newContractAddr Address of the new contract
function startContractChange(bytes32 _id, address _newContractAddr) public onlyOwner {
require(entries[_id].exists, ERR_ENTRY_NON_EXISTENT);
require(!entries[_id].inWaitPeriodChange, ERR_ALREADY_IN_WAIT_PERIOD_CHANGE);
entries[_id].changeStartTime = block.timestamp; // solhint-disable-line
entries[_id].inContractChange = true;
pendingAddresses[_id] = _newContractAddr;
logger.Log(
address(this),
msg.sender,
"StartContractChange",
abi.encode(_id, entries[_id].contractAddr, _newContractAddr)
);
}
/// @notice Changes new contract address, correct time must have passed
/// @param _id Id of contract
function approveContractChange(bytes32 _id) public onlyOwner {
require(entries[_id].exists, ERR_ENTRY_NON_EXISTENT);
require(entries[_id].inContractChange, ERR_ENTRY_NOT_IN_CHANGE);
require(
block.timestamp >= (entries[_id].changeStartTime + entries[_id].waitPeriod), // solhint-disable-line
ERR_CHANGE_NOT_READY
);
address oldContractAddr = entries[_id].contractAddr;
entries[_id].contractAddr = pendingAddresses[_id];
entries[_id].inContractChange = false;
entries[_id].changeStartTime = 0;
pendingAddresses[_id] = address(0);
previousAddresses[_id] = oldContractAddr;
logger.Log(
address(this),
msg.sender,
"ApproveContractChange",
abi.encode(_id, oldContractAddr, entries[_id].contractAddr)
);
}
/// @notice Cancel pending change
/// @param _id Id of contract
function cancelContractChange(bytes32 _id) public onlyOwner {
require(entries[_id].exists, ERR_ENTRY_NON_EXISTENT);
require(entries[_id].inContractChange, ERR_ENTRY_NOT_IN_CHANGE);
address oldContractAddr = pendingAddresses[_id];
pendingAddresses[_id] = address(0);
entries[_id].inContractChange = false;
entries[_id].changeStartTime = 0;
logger.Log(
address(this),
msg.sender,
"CancelContractChange",
abi.encode(_id, oldContractAddr, entries[_id].contractAddr)
);
}
/// @notice Starts the change for waitPeriod
/// @param _id Id of contract
/// @param _newWaitPeriod New wait time
function startWaitPeriodChange(bytes32 _id, uint256 _newWaitPeriod) public onlyOwner {
require(entries[_id].exists, ERR_ENTRY_NON_EXISTENT);
require(!entries[_id].inContractChange, ERR_ALREADY_IN_CONTRACT_CHANGE);
pendingWaitTimes[_id] = _newWaitPeriod;
entries[_id].changeStartTime = block.timestamp; // solhint-disable-line
entries[_id].inWaitPeriodChange = true;
logger.Log(
address(this),
msg.sender,
"StartWaitPeriodChange",
abi.encode(_id, _newWaitPeriod)
);
}
/// @notice Changes new wait period, correct time must have passed
/// @param _id Id of contract
function approveWaitPeriodChange(bytes32 _id) public onlyOwner {
require(entries[_id].exists, ERR_ENTRY_NON_EXISTENT);
require(entries[_id].inWaitPeriodChange, ERR_ENTRY_NOT_IN_CHANGE);
require(
block.timestamp >= (entries[_id].changeStartTime + entries[_id].waitPeriod), // solhint-disable-line
ERR_CHANGE_NOT_READY
);
uint256 oldWaitTime = entries[_id].waitPeriod;
entries[_id].waitPeriod = pendingWaitTimes[_id];
entries[_id].inWaitPeriodChange = false;
entries[_id].changeStartTime = 0;
pendingWaitTimes[_id] = 0;
logger.Log(
address(this),
msg.sender,
"ApproveWaitPeriodChange",
abi.encode(_id, oldWaitTime, entries[_id].waitPeriod)
);
}
/// @notice Cancel wait period change
/// @param _id Id of contract
function cancelWaitPeriodChange(bytes32 _id) public onlyOwner {
require(entries[_id].exists, ERR_ENTRY_NON_EXISTENT);
require(entries[_id].inWaitPeriodChange, ERR_ENTRY_NOT_IN_CHANGE);
uint256 oldWaitPeriod = pendingWaitTimes[_id];
pendingWaitTimes[_id] = 0;
entries[_id].inWaitPeriodChange = false;
entries[_id].changeStartTime = 0;
logger.Log(
address(this),
msg.sender,
"CancelWaitPeriodChange",
abi.encode(_id, oldWaitPeriod, entries[_id].waitPeriod)
);
}
}
| contract DFSRegistry is AdminAuth {
DefisaverLogger public constant logger = DefisaverLogger(
0x5c55B921f590a89C1Ebe84dF170E655a82b62126
);
string public constant ERR_ENTRY_ALREADY_EXISTS = "Entry id already exists";
string public constant ERR_ENTRY_NON_EXISTENT = "Entry id doesn't exists";
string public constant ERR_ENTRY_NOT_IN_CHANGE = "Entry not in change process";
string public constant ERR_WAIT_PERIOD_SHORTER = "New wait period must be bigger";
string public constant ERR_CHANGE_NOT_READY = "Change not ready yet";
string public constant ERR_EMPTY_PREV_ADDR = "Previous addr is 0";
string public constant ERR_ALREADY_IN_CONTRACT_CHANGE = "Already in contract change";
string public constant ERR_ALREADY_IN_WAIT_PERIOD_CHANGE = "Already in wait period change";
struct Entry {
address contractAddr;
uint256 waitPeriod;
uint256 changeStartTime;
bool inContractChange;
bool inWaitPeriodChange;
bool exists;
}
mapping(bytes32 => Entry) public entries;
mapping(bytes32 => address) public previousAddresses;
mapping(bytes32 => address) public pendingAddresses;
mapping(bytes32 => uint256) public pendingWaitTimes;
/// @notice Given an contract id returns the registred address
/// @dev Id is keccak256 of the contract name
/// @param _id Id of contract
function getAddr(bytes32 _id) public view returns (address) {
return entries[_id].contractAddr;
}
/// @notice Helper function to easily query if id is registred
/// @param _id Id of contract
function isRegistered(bytes32 _id) public view returns (bool) {
return entries[_id].exists;
}
/////////////////////////// OWNER ONLY FUNCTIONS ///////////////////////////
/// @notice Adds a new contract to the registry
/// @param _id Id of contract
/// @param _contractAddr Address of the contract
/// @param _waitPeriod Amount of time to wait before a contract address can be changed
function addNewContract(
bytes32 _id,
address _contractAddr,
uint256 _waitPeriod
) public onlyOwner {
require(!entries[_id].exists, ERR_ENTRY_ALREADY_EXISTS);
entries[_id] = Entry({
contractAddr: _contractAddr,
waitPeriod: _waitPeriod,
changeStartTime: 0,
inContractChange: false,
inWaitPeriodChange: false,
exists: true
});
// Remember tha address so we can revert back to old addr if needed
previousAddresses[_id] = _contractAddr;
logger.Log(
address(this),
msg.sender,
"AddNewContract",
abi.encode(_id, _contractAddr, _waitPeriod)
);
}
/// @notice Revertes to the previous address immediately
/// @dev In case the new version has a fault, a quick way to fallback to the old contract
/// @param _id Id of contract
function revertToPreviousAddress(bytes32 _id) public onlyOwner {
require(entries[_id].exists, ERR_ENTRY_NON_EXISTENT);
require(previousAddresses[_id] != address(0), ERR_EMPTY_PREV_ADDR);
address currentAddr = entries[_id].contractAddr;
entries[_id].contractAddr = previousAddresses[_id];
logger.Log(
address(this),
msg.sender,
"RevertToPreviousAddress",
abi.encode(_id, currentAddr, previousAddresses[_id])
);
}
/// @notice Starts an address change for an existing entry
/// @dev Can override a change that is currently in progress
/// @param _id Id of contract
/// @param _newContractAddr Address of the new contract
function startContractChange(bytes32 _id, address _newContractAddr) public onlyOwner {
require(entries[_id].exists, ERR_ENTRY_NON_EXISTENT);
require(!entries[_id].inWaitPeriodChange, ERR_ALREADY_IN_WAIT_PERIOD_CHANGE);
entries[_id].changeStartTime = block.timestamp; // solhint-disable-line
entries[_id].inContractChange = true;
pendingAddresses[_id] = _newContractAddr;
logger.Log(
address(this),
msg.sender,
"StartContractChange",
abi.encode(_id, entries[_id].contractAddr, _newContractAddr)
);
}
/// @notice Changes new contract address, correct time must have passed
/// @param _id Id of contract
function approveContractChange(bytes32 _id) public onlyOwner {
require(entries[_id].exists, ERR_ENTRY_NON_EXISTENT);
require(entries[_id].inContractChange, ERR_ENTRY_NOT_IN_CHANGE);
require(
block.timestamp >= (entries[_id].changeStartTime + entries[_id].waitPeriod), // solhint-disable-line
ERR_CHANGE_NOT_READY
);
address oldContractAddr = entries[_id].contractAddr;
entries[_id].contractAddr = pendingAddresses[_id];
entries[_id].inContractChange = false;
entries[_id].changeStartTime = 0;
pendingAddresses[_id] = address(0);
previousAddresses[_id] = oldContractAddr;
logger.Log(
address(this),
msg.sender,
"ApproveContractChange",
abi.encode(_id, oldContractAddr, entries[_id].contractAddr)
);
}
/// @notice Cancel pending change
/// @param _id Id of contract
function cancelContractChange(bytes32 _id) public onlyOwner {
require(entries[_id].exists, ERR_ENTRY_NON_EXISTENT);
require(entries[_id].inContractChange, ERR_ENTRY_NOT_IN_CHANGE);
address oldContractAddr = pendingAddresses[_id];
pendingAddresses[_id] = address(0);
entries[_id].inContractChange = false;
entries[_id].changeStartTime = 0;
logger.Log(
address(this),
msg.sender,
"CancelContractChange",
abi.encode(_id, oldContractAddr, entries[_id].contractAddr)
);
}
/// @notice Starts the change for waitPeriod
/// @param _id Id of contract
/// @param _newWaitPeriod New wait time
function startWaitPeriodChange(bytes32 _id, uint256 _newWaitPeriod) public onlyOwner {
require(entries[_id].exists, ERR_ENTRY_NON_EXISTENT);
require(!entries[_id].inContractChange, ERR_ALREADY_IN_CONTRACT_CHANGE);
pendingWaitTimes[_id] = _newWaitPeriod;
entries[_id].changeStartTime = block.timestamp; // solhint-disable-line
entries[_id].inWaitPeriodChange = true;
logger.Log(
address(this),
msg.sender,
"StartWaitPeriodChange",
abi.encode(_id, _newWaitPeriod)
);
}
/// @notice Changes new wait period, correct time must have passed
/// @param _id Id of contract
function approveWaitPeriodChange(bytes32 _id) public onlyOwner {
require(entries[_id].exists, ERR_ENTRY_NON_EXISTENT);
require(entries[_id].inWaitPeriodChange, ERR_ENTRY_NOT_IN_CHANGE);
require(
block.timestamp >= (entries[_id].changeStartTime + entries[_id].waitPeriod), // solhint-disable-line
ERR_CHANGE_NOT_READY
);
uint256 oldWaitTime = entries[_id].waitPeriod;
entries[_id].waitPeriod = pendingWaitTimes[_id];
entries[_id].inWaitPeriodChange = false;
entries[_id].changeStartTime = 0;
pendingWaitTimes[_id] = 0;
logger.Log(
address(this),
msg.sender,
"ApproveWaitPeriodChange",
abi.encode(_id, oldWaitTime, entries[_id].waitPeriod)
);
}
/// @notice Cancel wait period change
/// @param _id Id of contract
function cancelWaitPeriodChange(bytes32 _id) public onlyOwner {
require(entries[_id].exists, ERR_ENTRY_NON_EXISTENT);
require(entries[_id].inWaitPeriodChange, ERR_ENTRY_NOT_IN_CHANGE);
uint256 oldWaitPeriod = pendingWaitTimes[_id];
pendingWaitTimes[_id] = 0;
entries[_id].inWaitPeriodChange = false;
entries[_id].changeStartTime = 0;
logger.Log(
address(this),
msg.sender,
"CancelWaitPeriodChange",
abi.encode(_id, oldWaitPeriod, entries[_id].waitPeriod)
);
}
}
| 7,466 |
3 | // Do something if it works | } catch Error(string memory error) {
| } catch Error(string memory error) {
| 5,880 |
17 | // The complete data for a Gnosis Protocol order. This struct contains/ all order parameters that are signed for submitting to GP. | struct Data {
IERC20 sellToken;
IERC20 buyToken;
address receiver;
uint256 sellAmount;
uint256 buyAmount;
uint32 validTo;
bytes32 appData;
uint256 feeAmount;
bytes32 kind;
bool partiallyFillable;
bytes32 sellTokenBalance;
bytes32 buyTokenBalance;
}
| struct Data {
IERC20 sellToken;
IERC20 buyToken;
address receiver;
uint256 sellAmount;
uint256 buyAmount;
uint32 validTo;
bytes32 appData;
uint256 feeAmount;
bytes32 kind;
bool partiallyFillable;
bytes32 sellTokenBalance;
bytes32 buyTokenBalance;
}
| 25,235 |
104 | // Calculates total involved vesting from provided list of validators and removes all validators that did not mine during last 2 notyary windows | uint256 totalInvolvedVesting = processNotaryValidators(chain, validators, blocksMined, maxBlocksMined);
| uint256 totalInvolvedVesting = processNotaryValidators(chain, validators, blocksMined, maxBlocksMined);
| 28,679 |
240 | // Gets the token symbol return string representing the token symbol/ | function symbol() public view returns (string) {
return symbol_;
}
| function symbol() public view returns (string) {
return symbol_;
}
| 26,688 |
16 | // Informational | name = _name;
| name = _name;
| 5,592 |
51 | // Total Scale currently staked | uint public totalScaleStaked;
| uint public totalScaleStaked;
| 37,303 |
246 | // Revert if the message was signed with an address other than the signer address. | if (recoveredAddress != signer) {
revert WrongSigner();
}
| if (recoveredAddress != signer) {
revert WrongSigner();
}
| 28,414 |
173 | // resourceID => token contract address | mapping (bytes32 => address) public _resourceIDToTokenContractAddress;
| mapping (bytes32 => address) public _resourceIDToTokenContractAddress;
| 76,686 |
14 | // Allows users to request a store._proposal Hexadecimal representation of an IPFS hash of file or folder holding the proposal materials.The proposal argument is a processed hexadecimal representation of the default IPFS SHA-256 hash with removed prefix./ | function requestStore(bytes32 _proposal) public {
require(_proposal != 0x0, 'Store request proposal can not be empty!');
uint256 requestIndex = storeRequests.length;
emit LogStoreRequested(requestIndex);
storeRequests.push(StoreRequest({ proposal: _proposal, owner: msg.sender }));
}
| function requestStore(bytes32 _proposal) public {
require(_proposal != 0x0, 'Store request proposal can not be empty!');
uint256 requestIndex = storeRequests.length;
emit LogStoreRequested(requestIndex);
storeRequests.push(StoreRequest({ proposal: _proposal, owner: msg.sender }));
}
| 44,000 |
29 | // Calculate x^y assuming 0^0 is 1, where x is unsigned 129.127 fixed pointnumber and y is unsigned 256-bit integer number.Revert on overflow.x unsigned 129.127-bit fixed point number y uint256 valuereturn unsigned 129.127-bit fixed point number / | function powu (uint256 x, uint256 y) private pure returns (uint256) {
if (y == 0) return 0x80000000000000000000000000000000;
else if (x == 0) return 0;
else {
int256 msb = 0;
uint256 xc = x;
if (xc >= 0x100000000000000000000000000000000) { xc >>= 128; msb += 128; }
if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; }
if (xc >= 0x100000000) { xc >>= 32; msb += 32; }
if (xc >= 0x10000) { xc >>= 16; msb += 16; }
if (xc >= 0x100) { xc >>= 8; msb += 8; }
if (xc >= 0x10) { xc >>= 4; msb += 4; }
if (xc >= 0x4) { xc >>= 2; msb += 2; }
if (xc >= 0x2) msb += 1; // No need to shift xc anymore
int256 xe = msb - 127;
if (xe > 0) x >>= uint256 (xe);
else x <<= uint256 (-xe);
uint256 result = 0x80000000000000000000000000000000;
int256 re = 0;
while (y > 0) {
if (y & 1 > 0) {
result = result * x;
y -= 1;
re += xe;
if (result >=
0x8000000000000000000000000000000000000000000000000000000000000000) {
result >>= 128;
re += 1;
} else result >>= 127;
if (re < -127) return 0; // Underflow
require (re < 128); // Overflow
} else {
x = x * x;
y >>= 1;
xe <<= 1;
if (x >=
0x8000000000000000000000000000000000000000000000000000000000000000) {
x >>= 128;
xe += 1;
} else x >>= 127;
if (xe < -127) return 0; // Underflow
require (xe < 128); // Overflow
}
}
if (re > 0) result <<= uint256 (re);
else if (re < 0) result >>= uint256 (-re);
return result;
}
}
| function powu (uint256 x, uint256 y) private pure returns (uint256) {
if (y == 0) return 0x80000000000000000000000000000000;
else if (x == 0) return 0;
else {
int256 msb = 0;
uint256 xc = x;
if (xc >= 0x100000000000000000000000000000000) { xc >>= 128; msb += 128; }
if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; }
if (xc >= 0x100000000) { xc >>= 32; msb += 32; }
if (xc >= 0x10000) { xc >>= 16; msb += 16; }
if (xc >= 0x100) { xc >>= 8; msb += 8; }
if (xc >= 0x10) { xc >>= 4; msb += 4; }
if (xc >= 0x4) { xc >>= 2; msb += 2; }
if (xc >= 0x2) msb += 1; // No need to shift xc anymore
int256 xe = msb - 127;
if (xe > 0) x >>= uint256 (xe);
else x <<= uint256 (-xe);
uint256 result = 0x80000000000000000000000000000000;
int256 re = 0;
while (y > 0) {
if (y & 1 > 0) {
result = result * x;
y -= 1;
re += xe;
if (result >=
0x8000000000000000000000000000000000000000000000000000000000000000) {
result >>= 128;
re += 1;
} else result >>= 127;
if (re < -127) return 0; // Underflow
require (re < 128); // Overflow
} else {
x = x * x;
y >>= 1;
xe <<= 1;
if (x >=
0x8000000000000000000000000000000000000000000000000000000000000000) {
x >>= 128;
xe += 1;
} else x >>= 127;
if (xe < -127) return 0; // Underflow
require (xe < 128); // Overflow
}
}
if (re > 0) result <<= uint256 (re);
else if (re < 0) result >>= uint256 (-re);
return result;
}
}
| 24,292 |
9 | // Wednesday 20th June, 2018 | worldCupGameID["PT-MA"] = 18; // Portugal vs Morocco
worldCupGameID["UR-SA"] = 19; // Uruguay vs Saudi Arabia
worldCupGameID["IR-ES"] = 20; // Iran vs Spain
gameLocked[18] = 1529496000;
gameLocked[19] = 1529506800;
gameLocked[20] = 1529517600;
| worldCupGameID["PT-MA"] = 18; // Portugal vs Morocco
worldCupGameID["UR-SA"] = 19; // Uruguay vs Saudi Arabia
worldCupGameID["IR-ES"] = 20; // Iran vs Spain
gameLocked[18] = 1529496000;
gameLocked[19] = 1529506800;
gameLocked[20] = 1529517600;
| 50,383 |
48 | // Log when advertiser creates creative / | event LogCreateCreative(bytes32 indexed creativeId, address indexed advertiser, uint256 indexed creativeTypeId, string name, uint256 weiBudget, uint256 weiPerBet, int256 position);
| event LogCreateCreative(bytes32 indexed creativeId, address indexed advertiser, uint256 indexed creativeTypeId, string name, uint256 weiBudget, uint256 weiPerBet, int256 position);
| 22,417 |
5 | // KeyType | uint256 public constant ECDSA_TYPE = 1;
| uint256 public constant ECDSA_TYPE = 1;
| 37,292 |
6 | // address public owner; | bool public whiteListOn;
mapping(address => mapping(uint256 => bool)) public processedNonces;
mapping(address => bool) public isWhiteList;
mapping(address => uint256) public nonce;
event TokenDeposit(
address indexed from,
address indexed to,
uint256 amount,
| bool public whiteListOn;
mapping(address => mapping(uint256 => bool)) public processedNonces;
mapping(address => bool) public isWhiteList;
mapping(address => uint256) public nonce;
event TokenDeposit(
address indexed from,
address indexed to,
uint256 amount,
| 51,957 |
150 | // profit for each share a holder holds, a share equals a token. | uint256 public profitPerShare;
| uint256 public profitPerShare;
| 38,353 |
45 | // put team 1 from spot to spot+1 and put team 2 to spot. |
Team memory team;
team.angelId = angel1ID;
team.petId = pet1ID;
team.accessoryId = accessory1ID;
|
Team memory team;
team.angelId = angel1ID;
team.petId = pet1ID;
team.accessoryId = accessory1ID;
| 25,861 |
0 | // Network: KovanOracle:Name: LinkPool Address:0x56dd6586DB0D08c6Ce7B2f2805af28616E082455Job:Name: DNS Record Check ID: 791bd73c8a1349859f09b1cb87304f71 Fee:0.1 LINK / | constructor(uint256 _oraclePayment) ConfirmedOwner(msg.sender) {
setPublicChainlinkToken();
oraclePayment = _oraclePayment;
}
| constructor(uint256 _oraclePayment) ConfirmedOwner(msg.sender) {
setPublicChainlinkToken();
oraclePayment = _oraclePayment;
}
| 42,535 |
24 | // Claim and mint ART tokens for an array of Prime IDsIf successful, emits an ARTMinted event _holder address of holder to claim ART for _primeIds an array of Avastar Prime IDs owned by the holder / | function claimArtBulk(address _holder, uint256[] memory _primeIds) public onlySysAdmin whenNotUpgraded {
// Cannot mint more tokens than the hard cap
require(getCirculatingArt() <= ART_HARD_CAP, "Hard cap reached, no more tokens can be minted.");
uint256 tokensToMint;
for (uint256 i = 0; i < _primeIds.length; i++) {
// If unclaimed, claim and increase tally to mint
require(artClaimed[_primeIds[i]] == false, "Token previously claimed for Prime");
// Caller must own the Avastar
require(teleporterContract.ownerOf(_primeIds[i]) == _holder, "Specified holder must own the specified Primes");
// Avastar tokens must be Primes
require(teleporterContract.getAvastarWaveByTokenId(_primeIds[i]) == Wave.PRIME, "Specified Avastars must all be Primes");
// Claim and bump amount to mint by one
artClaimed[_primeIds[i]] = true;
tokensToMint = tokensToMint.add(1);
}
// The scaled amount of ART to mint
uint256 scaledAmount = tokensToMint.mul(scaleFactor);
// Mint the tokens
_mint(_holder, scaledAmount);
// Send the event identifying the amount minted for the holder
emit ARTMinted(_holder, tokensToMint);
}
| function claimArtBulk(address _holder, uint256[] memory _primeIds) public onlySysAdmin whenNotUpgraded {
// Cannot mint more tokens than the hard cap
require(getCirculatingArt() <= ART_HARD_CAP, "Hard cap reached, no more tokens can be minted.");
uint256 tokensToMint;
for (uint256 i = 0; i < _primeIds.length; i++) {
// If unclaimed, claim and increase tally to mint
require(artClaimed[_primeIds[i]] == false, "Token previously claimed for Prime");
// Caller must own the Avastar
require(teleporterContract.ownerOf(_primeIds[i]) == _holder, "Specified holder must own the specified Primes");
// Avastar tokens must be Primes
require(teleporterContract.getAvastarWaveByTokenId(_primeIds[i]) == Wave.PRIME, "Specified Avastars must all be Primes");
// Claim and bump amount to mint by one
artClaimed[_primeIds[i]] = true;
tokensToMint = tokensToMint.add(1);
}
// The scaled amount of ART to mint
uint256 scaledAmount = tokensToMint.mul(scaleFactor);
// Mint the tokens
_mint(_holder, scaledAmount);
// Send the event identifying the amount minted for the holder
emit ARTMinted(_holder, tokensToMint);
}
| 14,542 |
95 | // remove limits after token is stable | function removeLimits() external onlyOwner returns (bool) {
limitsInEffect = false;
return true;
}
| function removeLimits() external onlyOwner returns (bool) {
limitsInEffect = false;
return true;
}
| 32,340 |
105 | // harvest before deposit new amount | if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accTokenPerShare).div(1e12).sub(user.rewardDebt);
if (pending > 0) {
safeTokenTransfer(msg.sender, pending);
}
| if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accTokenPerShare).div(1e12).sub(user.rewardDebt);
if (pending > 0) {
safeTokenTransfer(msg.sender, pending);
}
| 25,974 |
24 | // 저는 한국어를 한국에서 배웠어요그는 그녀의 호의를 순수하게 받아들였다 | library Address {
function isContract(address account) internal view returns (bool) {
uint256 size;
assembly { size := extcodesize(account) }
return size > 0;
}
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
//번역 사이트 : 영어-> 한국어 / 한국어-> 영어 한국어를 배우는 학생들 당신의 고도를 결정하는 것은 당신의 적성 이 아니라 당신의 태도입니다
//저는 한국어를 한국에서 배웠어요
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
| library Address {
function isContract(address account) internal view returns (bool) {
uint256 size;
assembly { size := extcodesize(account) }
return size > 0;
}
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
//번역 사이트 : 영어-> 한국어 / 한국어-> 영어 한국어를 배우는 학생들 당신의 고도를 결정하는 것은 당신의 적성 이 아니라 당신의 태도입니다
//저는 한국어를 한국에서 배웠어요
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
| 35,457 |
276 | // ========== SYNTHETIX ========== / claim and swap our CRV for synths | function claimAndSell() internal {
// if we have anything in the gauge, then harvest CRV from the gauge
uint256 _stakedBal = stakedBalance();
if (_stakedBal > 0) {
proxy.harvest(gauge);
uint256 _crvBalance = crv.balanceOf(address(this));
// if we claimed any CRV, then sell it
if (_crvBalance > 0) {
// keep some of our CRV to increase our boost
uint256 _sendToVoter =
_crvBalance.mul(keepCRV).div(FEE_DENOMINATOR);
if (_sendToVoter > 0) {
crv.safeTransfer(voter, _sendToVoter);
}
uint256 _crvRemainder = _crvBalance.sub(_sendToVoter);
// sell the rest of our CRV for sETH
if (_crvRemainder > 0) {
if (sellOnSushi) {
_sellOnSushiFirst(_crvRemainder);
} else {
_sellOnUniOnly(_crvRemainder);
}
}
// check our output balance of sETH
uint256 _sEthBalance = sethProxy.balanceOf(address(this));
// swap our sETH for our underlying synth if the forex markets are open
if (!isMarketClosed()) {
// this check allows us to still tend even if forex markets are closed.
exchangeSEthToSynth(_sEthBalance);
}
}
}
}
| function claimAndSell() internal {
// if we have anything in the gauge, then harvest CRV from the gauge
uint256 _stakedBal = stakedBalance();
if (_stakedBal > 0) {
proxy.harvest(gauge);
uint256 _crvBalance = crv.balanceOf(address(this));
// if we claimed any CRV, then sell it
if (_crvBalance > 0) {
// keep some of our CRV to increase our boost
uint256 _sendToVoter =
_crvBalance.mul(keepCRV).div(FEE_DENOMINATOR);
if (_sendToVoter > 0) {
crv.safeTransfer(voter, _sendToVoter);
}
uint256 _crvRemainder = _crvBalance.sub(_sendToVoter);
// sell the rest of our CRV for sETH
if (_crvRemainder > 0) {
if (sellOnSushi) {
_sellOnSushiFirst(_crvRemainder);
} else {
_sellOnUniOnly(_crvRemainder);
}
}
// check our output balance of sETH
uint256 _sEthBalance = sethProxy.balanceOf(address(this));
// swap our sETH for our underlying synth if the forex markets are open
if (!isMarketClosed()) {
// this check allows us to still tend even if forex markets are closed.
exchangeSEthToSynth(_sEthBalance);
}
}
}
}
| 18,373 |
39 | // Sub `base` from `total` and update `total.elastic`./ return (Rebase) The new total./ return elastic in relationship to `base`. | function sub(
Rebase memory total,
uint256 base,
bool roundUp
| function sub(
Rebase memory total,
uint256 base,
bool roundUp
| 5,527 |
6 | // Read the result of a resolved request.Call to `read_result` function in the WitnetRequestBoard contract._id The unique identifier of a request that was posted to Witnet. return The result of the request as an instance of `Result`./ | function witnetReadResult(uint256 _id) internal view returns (Witnet.Result memory) {
return Witnet.resultFromCborBytes(wrb.readResult(_id));
}
| function witnetReadResult(uint256 _id) internal view returns (Witnet.Result memory) {
return Witnet.resultFromCborBytes(wrb.readResult(_id));
}
| 25,786 |
22 | // Allows the owner to set the rewards duration | function setRewardsDuration(uint256 _duration) external onlyOwner {
require(finishAt < block.timestamp, "reward duration not finished");
duration = _duration;
emit DurationChanged(_duration, block.timestamp);
}
| function setRewardsDuration(uint256 _duration) external onlyOwner {
require(finishAt < block.timestamp, "reward duration not finished");
duration = _duration;
emit DurationChanged(_duration, block.timestamp);
}
| 46,440 |
11 | // Check if sender is controller. | modifier onlyController() {
_onlyController();
_;
}
| modifier onlyController() {
_onlyController();
_;
}
| 42,800 |
2 | // restrict affiliates | mapping(address => bool) public affiliates;
| mapping(address => bool) public affiliates;
| 16,252 |
129 | // Modifier for after sale finalization | modifier afterSale() {
require(isFinalized);
_;
}
| modifier afterSale() {
require(isFinalized);
_;
}
| 6,956 |
242 | // v1 otoken | return (
otoken.collateralAsset(),
otoken.underlyingAsset(),
otoken.strikeAsset(),
otoken.strikePrice(),
otoken.expiryTimestamp(),
otoken.isPut()
);
| return (
otoken.collateralAsset(),
otoken.underlyingAsset(),
otoken.strikeAsset(),
otoken.strikePrice(),
otoken.expiryTimestamp(),
otoken.isPut()
);
| 18,447 |
75 | // Writes a new length to a byte array./Decreasing length will lead to removing the corresponding lower order bytes from the byte array./Increasing length may lead to appending adjacent in-memory bytes to the end of the byte array./b Bytes array to write new length to./length New length of byte array. | function writeLength(bytes memory b, uint256 length)
internal
pure
| function writeLength(bytes memory b, uint256 length)
internal
pure
| 16,875 |
4 | // return the cliff time of the token vesting. / | function cliff() public view returns(uint256) {
return cliff_;
}
| function cliff() public view returns(uint256) {
return cliff_;
}
| 672 |
13 | // Emitted when a new COMP speed is calculated for a market | event CompSpeedUpdated(CToken indexed cToken, uint newSpeed);
| event CompSpeedUpdated(CToken indexed cToken, uint newSpeed);
| 16,337 |
69 | // If the signature is valid (and not malleable), return the signer address | address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
| address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
| 466 |
7 | // MANAGER ONLY: Updates address receiving issue/redeem fees for a given SetToken._setToken Instance of the SetToken to update fee recipient _newFeeRecipientNew fee recipient address / | function updateFeeRecipient(
ISetToken _setToken,
address _newFeeRecipient
)
external
onlyManagerAndValidSet(_setToken)
| function updateFeeRecipient(
ISetToken _setToken,
address _newFeeRecipient
)
external
onlyManagerAndValidSet(_setToken)
| 26,967 |
87 | // Note: the ERC-165 identifier for this interface is 0xf0b9e5ba / | interface ERC721TokenReceiver {
/*
* @notice Handle the receipt of an NFT
* @dev The ERC721 smart contract calls this function on the recipient
* after a `transfer`. This function MAY throw to revert and reject the
* transfer. This function MUST use 50,000 gas or less. Return of other
* than the magic value MUST result in the transaction being reverted.
* Note: the contract address is always the message sender.
* @param _from The sending address
* @param _tokenId The NFT identifier which is being transfered
* @param _data Additional data with no specified format
* @return `bytes4(keccak256("onERC721Received(address,uint256,bytes)"))`
* unless throwing
*/
function onERC721Received(address _from, uint256 _tokenId, bytes calldata _data) external returns(bytes4);
}
| interface ERC721TokenReceiver {
/*
* @notice Handle the receipt of an NFT
* @dev The ERC721 smart contract calls this function on the recipient
* after a `transfer`. This function MAY throw to revert and reject the
* transfer. This function MUST use 50,000 gas or less. Return of other
* than the magic value MUST result in the transaction being reverted.
* Note: the contract address is always the message sender.
* @param _from The sending address
* @param _tokenId The NFT identifier which is being transfered
* @param _data Additional data with no specified format
* @return `bytes4(keccak256("onERC721Received(address,uint256,bytes)"))`
* unless throwing
*/
function onERC721Received(address _from, uint256 _tokenId, bytes calldata _data) external returns(bytes4);
}
| 36,713 |
42 | // Mint NFT using collateral / FRAX already held If suboptimal liquidity taken, withdraw() and try again Will revert if the pool doesn't exist yet | function mint(address _collat_addr, uint256 _amountCollateral, uint256 _amountFrax, uint24 _fee_tier, int24 _tickLower, int24 _tickUpper) public onlyByOwnerOrGovernance returns (uint256, uint128) {
// Make sure the collateral is allowed
require(allowed_collaterals[_collat_addr], "Collateral not allowed");
INonfungiblePositionManager.MintParams memory mint_params;
if(_collat_addr < address(FRAX)){
mint_params = INonfungiblePositionManager.MintParams(
_collat_addr,
address(FRAX),
_fee_tier,
_tickLower,
_tickUpper,
_amountCollateral,
_amountFrax,
0,
0,
address(this),
2105300114 // Expiration: a long time from now
);
} else {
mint_params = INonfungiblePositionManager.MintParams(
address(FRAX),
_collat_addr,
_fee_tier,
_tickLower,
_tickUpper,
_amountFrax,
_amountCollateral,
0,
0,
address(this),
2105300114 // Expiration: a long time from now
);
}
// Approvals
TransferHelper.safeApprove(_collat_addr, address(univ3_positions), _amountCollateral);
TransferHelper.safeApprove(address(FRAX), address(univ3_positions), _amountFrax);
// Leave off amount0 and amount1 due to stack limit
(uint256 token_id, uint128 liquidity, , ) = univ3_positions.mint(mint_params);
// store new NFT in mapping and array
Position memory new_position = Position(token_id, _collat_addr, liquidity, _tickLower, _tickUpper, _fee_tier);
positions_mapping[token_id] = new_position;
positions_array.push(new_position);
return (token_id, liquidity);
}
| function mint(address _collat_addr, uint256 _amountCollateral, uint256 _amountFrax, uint24 _fee_tier, int24 _tickLower, int24 _tickUpper) public onlyByOwnerOrGovernance returns (uint256, uint128) {
// Make sure the collateral is allowed
require(allowed_collaterals[_collat_addr], "Collateral not allowed");
INonfungiblePositionManager.MintParams memory mint_params;
if(_collat_addr < address(FRAX)){
mint_params = INonfungiblePositionManager.MintParams(
_collat_addr,
address(FRAX),
_fee_tier,
_tickLower,
_tickUpper,
_amountCollateral,
_amountFrax,
0,
0,
address(this),
2105300114 // Expiration: a long time from now
);
} else {
mint_params = INonfungiblePositionManager.MintParams(
address(FRAX),
_collat_addr,
_fee_tier,
_tickLower,
_tickUpper,
_amountFrax,
_amountCollateral,
0,
0,
address(this),
2105300114 // Expiration: a long time from now
);
}
// Approvals
TransferHelper.safeApprove(_collat_addr, address(univ3_positions), _amountCollateral);
TransferHelper.safeApprove(address(FRAX), address(univ3_positions), _amountFrax);
// Leave off amount0 and amount1 due to stack limit
(uint256 token_id, uint128 liquidity, , ) = univ3_positions.mint(mint_params);
// store new NFT in mapping and array
Position memory new_position = Position(token_id, _collat_addr, liquidity, _tickLower, _tickUpper, _fee_tier);
positions_mapping[token_id] = new_position;
positions_array.push(new_position);
return (token_id, liquidity);
}
| 6,406 |
15 | // : completeProphecyClaimAllows for the completion of ProphecyClaims once processed by the Oracle.Burn claims unlock tokens stored by BridgeBank.Lock claims mint BridgeTokens on BridgeBank's token whitelist. / | function completeProphecyClaim(uint256 _prophecyID)
public
isPending(_prophecyID)
| function completeProphecyClaim(uint256 _prophecyID)
public
isPending(_prophecyID)
| 28,560 |
110 | // Emitted when update performance fee/newFee new performance fee | event SetPerformanceFee (
uint256 newFee
);
| event SetPerformanceFee (
uint256 newFee
);
| 2,924 |
18 | // Deposit tokens to staker for STRF allocation. | function deposit(
uint256 pid,
uint256 amount
| function deposit(
uint256 pid,
uint256 amount
| 33,302 |
112 | // Emit a standard ERC20 transfer event | emitTransfer(from, to, value);
| emitTransfer(from, to, value);
| 22,660 |
624 | // Event fired when asset's pricing source (aggregator) is updated | event AssetSourceUpdated(address indexed asset, address indexed source);
| event AssetSourceUpdated(address indexed asset, address indexed source);
| 44,119 |
263 | // ========== RESTRICTED FUNCTIONS - Owner or timelock only ========== //Owner or governance can unlock stakes - irreversible! | function unlockStakes() external onlyByOwnGov {
stakesUnlocked = !stakesUnlocked;
}
| function unlockStakes() external onlyByOwnGov {
stakesUnlocked = !stakesUnlocked;
}
| 18,571 |
10 | // Add a new payee to the contract (for only owner). account The address of the payee to add. shares_ The number of shares owned by the payee. / | function addPayee(address payable account, uint256 shares_) public onlyOwner {
require(account != address(0), "PaymentSplitter: account is the zero address");
_payees.push(account);
_shares[account] = shares_;
_totalShares = _totalShares + shares_;
emit PayeeAdded(account, shares_);
}
| function addPayee(address payable account, uint256 shares_) public onlyOwner {
require(account != address(0), "PaymentSplitter: account is the zero address");
_payees.push(account);
_shares[account] = shares_;
_totalShares = _totalShares + shares_;
emit PayeeAdded(account, shares_);
}
| 39,827 |
42 | // mint founder tokens | mintFounderTokens(_maxSupply.mul(20).div(100));//20% of max supply
| mintFounderTokens(_maxSupply.mul(20).div(100));//20% of max supply
| 1,368 |
32 | // Transfer the specified token reward balance tot the defined recipient _rewardToken the reward token to redeem the balance of / | function redeemVaultRewards(address _rewardToken) external;
| function redeemVaultRewards(address _rewardToken) external;
| 5,334 |
8 | // Create a token with the given URI/tokenURI The token URI/Emit TokenCreated event | function createToken(string memory tokenURI) public {
_tokenIds.increment();
uint256 newItemId = _tokenIds.current() + 10000;
_mint(msg.sender, newItemId);
_setTokenURI(newItemId, tokenURI);
Item memory newItem = Item({
id: newItemId,
price: defaultTokenPrice,
owner: payable(msg.sender)
});
items.push(newItem);
itemMap[newItemId] = newItem;
emit TokenCreated(newItemId, tokenURI);
}
| function createToken(string memory tokenURI) public {
_tokenIds.increment();
uint256 newItemId = _tokenIds.current() + 10000;
_mint(msg.sender, newItemId);
_setTokenURI(newItemId, tokenURI);
Item memory newItem = Item({
id: newItemId,
price: defaultTokenPrice,
owner: payable(msg.sender)
});
items.push(newItem);
itemMap[newItemId] = newItem;
emit TokenCreated(newItemId, tokenURI);
}
| 39,372 |
17 | // Creates new sortition pool for the application./Have to be implemented by keep factory to call desired sortition/ pool factory./_application Address of the application./ return Address of the created sortition pool contract. | function newSortitionPool(address _application) internal returns (address);
| function newSortitionPool(address _application) internal returns (address);
| 37,212 |
47 | // transfers an amount from the contract balance to the owner&39;s wallet. receiver the receiver addressamount the amount of tokens to withdraw (0 decimals)v,r,s the signature of the player / | function withdrawFor(address receiver, uint amount, uint8 v, bytes32 r, bytes32 s) public onlyAuthorized keepAlive {
address player = ecrecover(keccak256(receiver, amount, withdrawCount[receiver]), v, r, s);
withdrawCount[receiver]++;
uint gasCost = getGasCost();
uint value = safeAdd(safeMul(amount, oneEDG), gasCost);
gasPayback = safeAdd(gasPayback, gasCost);
balanceOf[player] = safeSub(balanceOf[player], value);
playerBalance = safeSub(playerBalance, value);
assert(edg.transfer(receiver, amount));
Withdrawal(player, receiver, amount, gasCost);
}
| function withdrawFor(address receiver, uint amount, uint8 v, bytes32 r, bytes32 s) public onlyAuthorized keepAlive {
address player = ecrecover(keccak256(receiver, amount, withdrawCount[receiver]), v, r, s);
withdrawCount[receiver]++;
uint gasCost = getGasCost();
uint value = safeAdd(safeMul(amount, oneEDG), gasCost);
gasPayback = safeAdd(gasPayback, gasCost);
balanceOf[player] = safeSub(balanceOf[player], value);
playerBalance = safeSub(playerBalance, value);
assert(edg.transfer(receiver, amount));
Withdrawal(player, receiver, amount, gasCost);
}
| 54,477 |
509 | // Claim all the comp accrued by holder in the specified markets holder The address to claim WPC for pTokens The list of markets to claim WPC in / | function claimWpc(address holder, PToken[] memory pTokens) public {
address[] memory holders = new address[](1);
holders[0] = holder;
claimWpc(holders, pTokens, true, false);
}
| function claimWpc(address holder, PToken[] memory pTokens) public {
address[] memory holders = new address[](1);
holders[0] = holder;
claimWpc(holders, pTokens, true, false);
}
| 26,101 |
92 | // Tell the term duration of the Court return Duration in seconds of the Court term/ | function getTermDuration() external view returns (uint64) {
return termDuration;
}
| function getTermDuration() external view returns (uint64) {
return termDuration;
}
| 39,641 |
63 | // Use and override this function with caution. Wrong usage can have serious consequences. Removes a NFT from owner. _from Address from which we want to remove the NFT. _tokenId Which NFT we want to remove. / | function _removeNFToken(address _from, uint256 _tokenId) internal virtual {
require(idToOwner[_tokenId] == _from, NOT_OWNER);
ownerToNFTokenCount[_from] -= 1;
delete idToOwner[_tokenId];
}
| function _removeNFToken(address _from, uint256 _tokenId) internal virtual {
require(idToOwner[_tokenId] == _from, NOT_OWNER);
ownerToNFTokenCount[_from] -= 1;
delete idToOwner[_tokenId];
}
| 33,398 |
46 | // Converts a 'uint256' to its ASCII 'string' hexadecimal representation. / | function toHexString(uint256 value) internal pure returns(string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
| function toHexString(uint256 value) internal pure returns(string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
| 1,054 |
43 | // Stores which address have claimed which tokens, to avoid one address claiming the same token twice. Note - this does NOT affect medals won on the sponsored leaderboards; | mapping (address => bool[12]) public claimedbyAddress;
| mapping (address => bool[12]) public claimedbyAddress;
| 43,767 |
61 | // Disable solium check because ofhttps:github.com/duaraghav8/Solium/issues/175solium-disable-next-line operator-whitespace | return (
_spender == owner ||
getApproved(_tokenId) == _spender ||
isApprovedForAll(owner, _spender)
);
| return (
_spender == owner ||
getApproved(_tokenId) == _spender ||
isApprovedForAll(owner, _spender)
);
| 28,592 |
4 | // Check if a sha256 hash is registered | function isSHA256HashRegistered (bytes32 _SHA256Hash) returns (bool _registered);
| function isSHA256HashRegistered (bytes32 _SHA256Hash) returns (bool _registered);
| 31,763 |
107 | // user => referrer | mapping (address => address) public referrers;
| mapping (address => address) public referrers;
| 4,783 |
75 | // Count of the total votes in favor of this offer. | uint voteCount;
| uint voteCount;
| 22,349 |
233 | // Returns true if CKToken must be enabled on the controller and module is registered on the CKToken / | function isCKValidAndInitialized(ICKToken _ckToken) internal view returns(bool) {
return controller.isCK(address(_ckToken)) &&
_ckToken.isInitializedModule(address(this));
}
| function isCKValidAndInitialized(ICKToken _ckToken) internal view returns(bool) {
return controller.isCK(address(_ckToken)) &&
_ckToken.isInitializedModule(address(this));
}
| 4,412 |
482 | // Fills the input ExchangeV3 order./Returns false if the transaction would otherwise revert./order Order struct containing order specifications./takerAssetFillAmount Desired amount of takerAsset to sell./signature Proof that order has been created by maker./ return Amounts filled and fees paid by maker and taker. | function _fillV3OrderNoThrow(
LibOrder.Order memory order,
uint256 takerAssetFillAmount,
bytes memory signature
)
internal
returns (LibFillResults.FillResults memory fillResults)
| function _fillV3OrderNoThrow(
LibOrder.Order memory order,
uint256 takerAssetFillAmount,
bytes memory signature
)
internal
returns (LibFillResults.FillResults memory fillResults)
| 32,697 |
352 | // an optional post-upgrade callback that can be implemented by child contracts / | function _postUpgrade(
bytes calldata /* data */
| function _postUpgrade(
bytes calldata /* data */
| 45,815 |
48 | // This is a virtual function that should be overriden so it returns the address to which the fallback function | * and {_fallback} should delegate.
*/
function _implementation() internal view virtual returns (address);
/**
* @dev Delegates the current call to the address returned by _implementation().
*
* This function does not return to its internall call site, it will return directly to the external caller.
*/
function _fallback() internal virtual {
_beforeFallback();
_delegate(_implementation());
}
| * and {_fallback} should delegate.
*/
function _implementation() internal view virtual returns (address);
/**
* @dev Delegates the current call to the address returned by _implementation().
*
* This function does not return to its internall call site, it will return directly to the external caller.
*/
function _fallback() internal virtual {
_beforeFallback();
_delegate(_implementation());
}
| 38,923 |
23 | // need to check the library address first. if canEdit() is called on a library it reverts because the librarycannot have a wallet. | return (msg.sender == libraryAddress || canEdit());
| return (msg.sender == libraryAddress || canEdit());
| 29,619 |
8 | // Returns the previous timestamp where new principal came due / | function previousPrincipalDueTimeAt(
| function previousPrincipalDueTimeAt(
| 39,763 |
11 | // create slug | string memory projectSlug = createSlug(dto.slug);
| string memory projectSlug = createSlug(dto.slug);
| 18,243 |
72 | // {See ICreatorCore-getFeeBps}. / | function getFeeBps(uint256 tokenId) external view virtual override returns (uint[] memory) {
require(_exists(tokenId), "Nonexistent token");
return _getRoyaltyBPS(tokenId);
}
| function getFeeBps(uint256 tokenId) external view virtual override returns (uint[] memory) {
require(_exists(tokenId), "Nonexistent token");
return _getRoyaltyBPS(tokenId);
}
| 25,050 |
144 | // isAllowedToCall should be called upon a proposal execution._contractsToCall the contracts to be called_callsData - The abi encode data for the calls_values value(ETH) to transfer with the calls_avatar avatar return bool value true-allowed false not allowed/ | function isAllowedToCall(
address[] calldata _contractsToCall,
bytes[] calldata _callsData,
uint256[] calldata _values,
Avatar _avatar)
external returns(bool);
| function isAllowedToCall(
address[] calldata _contractsToCall,
bytes[] calldata _callsData,
uint256[] calldata _values,
Avatar _avatar)
external returns(bool);
| 54,380 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.