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
|
|---|---|---|---|---|
60
|
// ============ External Getter Functions ============ /
|
{
return fees[_moduleAddress][_feeType];
}
|
{
return fees[_moduleAddress][_feeType];
}
| 34,342
|
0
|
// Public variables of the token
|
string public name;
string public symbol;
uint8 public decimals = 8;
uint256 public totalSupply;
address[] public owners;
address[] public admins;
|
string public name;
string public symbol;
uint8 public decimals = 8;
uint256 public totalSupply;
address[] public owners;
address[] public admins;
| 5,593
|
155
|
// Sets governance gNFT token onlyAdmin and only once /
|
function _setGNft(address newGNFT) external {
require(msg.sender == admin, "Only admin");
// can be set only once
require(gNFT == address(0) && newGNFT != address(0), "Invalid gNFT");
gNFT = newGNFT;
emit GNFT(newGNFT);
}
|
function _setGNft(address newGNFT) external {
require(msg.sender == admin, "Only admin");
// can be set only once
require(gNFT == address(0) && newGNFT != address(0), "Invalid gNFT");
gNFT = newGNFT;
emit GNFT(newGNFT);
}
| 27,469
|
253
|
// Transfer staker amount to the gateway.
|
require(
token.transferFrom(staker, address(this), _amount),
"Stake amount must be transferred to gateway"
);
|
require(
token.transferFrom(staker, address(this), _amount),
"Stake amount must be transferred to gateway"
);
| 25,215
|
3
|
// See https:eips.ethereum.org/EIPS/eip-191
|
string private constant EIP191_PREFIX_FOR_EIP712_STRUCTURED_DATA = "\x19\x01";
|
string private constant EIP191_PREFIX_FOR_EIP712_STRUCTURED_DATA = "\x19\x01";
| 16,994
|
16
|
// owner can update the fee amount updateWhiteListedTokenFee, updateTokenFee /
|
function updateFee(uint256 updateTokenFee) external onlyOwner {
tokenFee = updateTokenFee;
}
|
function updateFee(uint256 updateTokenFee) external onlyOwner {
tokenFee = updateTokenFee;
}
| 12,489
|
6
|
// This method relies on extcodesize, which returns 0 for contracts in construction, since the code is only stored at the end of the constructor execution.
|
uint256 size;
assembly {
size := extcodesize(account)
}
|
uint256 size;
assembly {
size := extcodesize(account)
}
| 23,109
|
95
|
// Transfers possession of a token./tokenId_ ID of token to transfer possession of./currentOwner_ Address of current owner./newOwner_ Address of new owner./newPrice_ New price in Wei.
|
function transferToken(
uint256 tokenId_,
address currentOwner_,
address newOwner_,
uint256 newPrice_
|
function transferToken(
uint256 tokenId_,
address currentOwner_,
address newOwner_,
uint256 newPrice_
| 37,508
|
164
|
// transfers LP from the owners wallet to holdersmust approve this contract, on pair contract before calling
|
function ManualLiquidityDistribution(uint256 amount) public onlyOwner {
bool success = IERC20(pair).transferFrom(
msg.sender,
address(dividendTracker),
amount
);
if (success) {
dividendTracker.distributeLPDividends(amount);
}
}
|
function ManualLiquidityDistribution(uint256 amount) public onlyOwner {
bool success = IERC20(pair).transferFrom(
msg.sender,
address(dividendTracker),
amount
);
if (success) {
dividendTracker.distributeLPDividends(amount);
}
}
| 23,987
|
18
|
// Emits the legacy WithdrawalInitiated event followed by the ERC20BridgeInitiatedevent. This is necessary for backwards compatibility with the legacy bridge. @inheritdoc StandardBridge /
|
function _emitERC20BridgeInitiated(
address _localToken,
address _remoteToken,
address _from,
address _to,
uint256 _amount,
bytes memory _extraData
|
function _emitERC20BridgeInitiated(
address _localToken,
address _remoteToken,
address _from,
address _to,
uint256 _amount,
bytes memory _extraData
| 15,817
|
31
|
// Called by a pauser to unpause, returns to normal state. /
|
function unpause() public onlyPauser whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
|
function unpause() public onlyPauser whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
| 39,331
|
368
|
// Emitted when an admin supports a market
|
event MarketListed(CToken cToken);
|
event MarketListed(CToken cToken);
| 21,093
|
4
|
// Returns whether the Pool currently allows swaps (and by extension, non-proportional joins/exits). poolState - The byte32 state of the Pool. /
|
function getSwapEnabled(bytes32 poolState) internal pure returns (bool) {
return poolState.decodeBool(_SWAP_ENABLED_OFFSET);
}
|
function getSwapEnabled(bytes32 poolState) internal pure returns (bool) {
return poolState.decodeBool(_SWAP_ENABLED_OFFSET);
}
| 22,217
|
26
|
// Calls the custom fallback function. Will fail if not implemented, reverting transaction.
|
assert(_to.call.value(0)(bytes4(keccak256(_fallback)), msg.sender, _value, _data));
Transfer(msg.sender, _to, _value, _data);
return true;
|
assert(_to.call.value(0)(bytes4(keccak256(_fallback)), msg.sender, _value, _data));
Transfer(msg.sender, _to, _value, _data);
return true;
| 28,874
|
8
|
// erc20 function to return balance of give address
|
function balanceOf(address sender) constant returns(uint256 balance) {
return balances[sender];
}
|
function balanceOf(address sender) constant returns(uint256 balance) {
return balances[sender];
}
| 20,073
|
19
|
// Transfer several token for a specified addresses _to The array of addresses to transfer to. _value The array of amounts to be transferred. /
|
function massTransfer(address[] memory _to, uint[] memory _value) public returns (bool){
require(_to.length == _value.length);
uint len = _to.length;
for(uint i = 0; i < len; i++){
if(!_transfer(_to[i], _value[i])){
return false;
}
}
return true;
}
|
function massTransfer(address[] memory _to, uint[] memory _value) public returns (bool){
require(_to.length == _value.length);
uint len = _to.length;
for(uint i = 0; i < len; i++){
if(!_transfer(_to[i], _value[i])){
return false;
}
}
return true;
}
| 43,918
|
110
|
// Borrowing power (in dai) of a user for a specific series and collateral./collateral Valid collateral type/user Address of the user vault/ return Borrowing power of an user in dai. powerOf[user](wad) = posted[user](wad)price()(ray)
|
function powerOf(bytes32 collateral, address user) public view returns (uint256) {
// dai = price * collateral
if (collateral == WETH){
(,, uint256 spot,,) = vat.ilks(WETH); // Stability fee and collateralization ratio for Weth
return muld(posted[collateral][user], spot);
} else if (collateral == CHAI) {
uint256 chi = pot.chi();
return muld(posted[collateral][user], chi);
} else {
revert("Controller: Invalid collateral type");
}
}
|
function powerOf(bytes32 collateral, address user) public view returns (uint256) {
// dai = price * collateral
if (collateral == WETH){
(,, uint256 spot,,) = vat.ilks(WETH); // Stability fee and collateralization ratio for Weth
return muld(posted[collateral][user], spot);
} else if (collateral == CHAI) {
uint256 chi = pot.chi();
return muld(posted[collateral][user], chi);
} else {
revert("Controller: Invalid collateral type");
}
}
| 78,334
|
200
|
// Getter for winningChoice in VoteCounter._disputeID ID of the dispute._appeals Which appeal (or 0 for the initial session). return winningChoice The currently winning choice (or 0 if it's tied). Note that 0 can also be return if the majority refuses to arbitrate. /
|
function getWinningChoice(uint _disputeID, uint _appeals) public view returns (uint winningChoice) {
return disputes[_disputeID].voteCounter[_appeals].winningChoice;
}
|
function getWinningChoice(uint _disputeID, uint _appeals) public view returns (uint winningChoice) {
return disputes[_disputeID].voteCounter[_appeals].winningChoice;
}
| 49,068
|
69
|
// Sale Sale is a contract for managing a token crowdsale.Sales have a start and end timestamps, where investors can maketoken purchases and the crowdsale will assign them tokens basedon a token per ETH rate. Funds collected are forwarded to a walletas they arrive. /
|
contract Sale is Pausable, Contactable {
using SafeMath for uint;
// The token being sold
LockableToken public token;
// start and end timestamps where investments are allowed (both inclusive)
uint public startTime;
uint public endTime;
// address where funds are collected
address public wallet;
// the contract, which determine how many token units a buyer gets per wei
PricingStrategy public pricingStrategy;
// amount of raised money in wei
uint public weiRaised;
// amount of tokens that was sold on the crowdsale
uint public tokensSold;
// maximum amount of wei in total, that can be invested
uint public weiMaximumGoal;
// if weiMinimumGoal will not be reached till endTime, investors will be able to refund ETH
uint public weiMinimumGoal;
// minimal amount of ether, that investor can invest
uint public minAmount;
// How many distinct addresses have invested
uint public investorCount;
// how much wei we have returned back to the contract after a failed crowdfund
uint public loadedRefund;
// how much wei we have given back to investors
uint public weiRefunded;
//How much ETH each address has invested to this crowdsale
mapping (address => uint) public investedAmountOf;
// Addresses that are allowed to invest before ICO offical opens
mapping (address => bool) public earlyParticipantWhitelist;
// whether a buyer bought tokens through other currencies
mapping (address => bool) public isExternalBuyer;
address public admin;
modifier onlyOwnerOrAdmin() {
require(msg.sender == owner || msg.sender == admin);
_;
}
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param tokenAmount amount of tokens purchased
*/
event TokenPurchase(
address indexed purchaser,
address indexed beneficiary,
uint value,
uint tokenAmount
);
// a refund was processed for an investor
event Refund(address investor, uint weiAmount);
function Sale(
uint _startTime,
uint _endTime,
PricingStrategy _pricingStrategy,
LockableToken _token,
address _wallet,
uint _weiMaximumGoal,
uint _weiMinimumGoal,
uint _minAmount
) {
require(_startTime >= now);
require(_endTime >= _startTime);
require(_pricingStrategy.isPricingStrategy());
require(address(_token) != 0x0);
require(_wallet != 0x0);
require(_weiMaximumGoal > 0);
require(_weiMinimumGoal > 0);
startTime = _startTime;
endTime = _endTime;
pricingStrategy = _pricingStrategy;
token = _token;
wallet = _wallet;
weiMaximumGoal = _weiMaximumGoal;
weiMinimumGoal = _weiMinimumGoal;
minAmount = _minAmount;
}
// fallback function can be used to buy tokens
function () external payable {
buyTokens(msg.sender);
}
// low level token purchase function
function buyTokens(address beneficiary) public whenNotPaused payable returns (bool) {
uint weiAmount = msg.value;
require(beneficiary != 0x0);
require(validPurchase(weiAmount));
transferTokenToBuyer(beneficiary, weiAmount);
wallet.transfer(weiAmount);
return true;
}
function transferTokenToBuyer(address beneficiary, uint weiAmount) internal {
if (investedAmountOf[beneficiary] == 0) {
// A new investor
investorCount++;
}
// calculate token amount to be created
uint tokenAmount = pricingStrategy.calculateTokenAmount(weiAmount, weiRaised);
investedAmountOf[beneficiary] = investedAmountOf[beneficiary].add(weiAmount);
weiRaised = weiRaised.add(weiAmount);
tokensSold = tokensSold.add(tokenAmount);
token.transferFrom(owner, beneficiary, tokenAmount);
TokenPurchase(msg.sender, beneficiary, weiAmount, tokenAmount);
}
// return true if the transaction can buy tokens
function validPurchase(uint weiAmount) internal view returns (bool) {
bool withinPeriod = (now >= startTime || earlyParticipantWhitelist[msg.sender]) && now <= endTime;
bool withinCap = weiRaised.add(weiAmount) <= weiMaximumGoal;
bool moreThenMinimal = weiAmount >= minAmount;
return withinPeriod && withinCap && moreThenMinimal;
}
// return true if crowdsale event has ended
function hasEnded() external view returns (bool) {
bool capReached = weiRaised >= weiMaximumGoal;
bool afterEndTime = now > endTime;
return capReached || afterEndTime;
}
// get the amount of unsold tokens allocated to this contract;
function getWeiLeft() external view returns (uint) {
return weiMaximumGoal - weiRaised;
}
// return true if the crowdsale has raised enough money to be a successful.
function isMinimumGoalReached() public view returns (bool) {
return weiRaised >= weiMinimumGoal;
}
/**
* allows to add and exclude addresses from earlyParticipantWhitelist for owner
* @param isWhitelisted is true for adding address into whitelist, false - to exclude
*/
function editEarlyParicipantWhitelist(address addr, bool isWhitelisted) external onlyOwnerOrAdmin returns (bool) {
earlyParticipantWhitelist[addr] = isWhitelisted;
return true;
}
// allows to update tokens rate for owner
function setPricingStrategy(PricingStrategy _pricingStrategy) external onlyOwner returns (bool) {
pricingStrategy = _pricingStrategy;
return true;
}
/**
* Allow load refunds back on the contract for the refunding.
*
* The team can transfer the funds back on the smart contract in the case the minimum goal was not reached..
*/
function loadRefund() external payable {
require(msg.value > 0);
require(!isMinimumGoalReached());
loadedRefund = loadedRefund.add(msg.value);
}
/**
* Investors can claim refund.
*
* Note that any refunds from proxy buyers should be handled separately,
* and not through this contract.
*/
function refund() external {
uint256 weiValue = investedAmountOf[msg.sender];
require(!isMinimumGoalReached() && loadedRefund > 0);
require(!isExternalBuyer[msg.sender]);
require(weiValue > 0);
investedAmountOf[msg.sender] = 0;
weiRefunded = weiRefunded.add(weiValue);
Refund(msg.sender, weiValue);
msg.sender.transfer(weiValue);
}
function registerPayment(address beneficiary, uint weiAmount) external onlyOwnerOrAdmin {
require(validPurchase(weiAmount));
isExternalBuyer[beneficiary] = true;
transferTokenToBuyer(beneficiary, weiAmount);
}
function setAdmin(address adminAddress) external onlyOwner {
admin = adminAddress;
}
}
|
contract Sale is Pausable, Contactable {
using SafeMath for uint;
// The token being sold
LockableToken public token;
// start and end timestamps where investments are allowed (both inclusive)
uint public startTime;
uint public endTime;
// address where funds are collected
address public wallet;
// the contract, which determine how many token units a buyer gets per wei
PricingStrategy public pricingStrategy;
// amount of raised money in wei
uint public weiRaised;
// amount of tokens that was sold on the crowdsale
uint public tokensSold;
// maximum amount of wei in total, that can be invested
uint public weiMaximumGoal;
// if weiMinimumGoal will not be reached till endTime, investors will be able to refund ETH
uint public weiMinimumGoal;
// minimal amount of ether, that investor can invest
uint public minAmount;
// How many distinct addresses have invested
uint public investorCount;
// how much wei we have returned back to the contract after a failed crowdfund
uint public loadedRefund;
// how much wei we have given back to investors
uint public weiRefunded;
//How much ETH each address has invested to this crowdsale
mapping (address => uint) public investedAmountOf;
// Addresses that are allowed to invest before ICO offical opens
mapping (address => bool) public earlyParticipantWhitelist;
// whether a buyer bought tokens through other currencies
mapping (address => bool) public isExternalBuyer;
address public admin;
modifier onlyOwnerOrAdmin() {
require(msg.sender == owner || msg.sender == admin);
_;
}
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param tokenAmount amount of tokens purchased
*/
event TokenPurchase(
address indexed purchaser,
address indexed beneficiary,
uint value,
uint tokenAmount
);
// a refund was processed for an investor
event Refund(address investor, uint weiAmount);
function Sale(
uint _startTime,
uint _endTime,
PricingStrategy _pricingStrategy,
LockableToken _token,
address _wallet,
uint _weiMaximumGoal,
uint _weiMinimumGoal,
uint _minAmount
) {
require(_startTime >= now);
require(_endTime >= _startTime);
require(_pricingStrategy.isPricingStrategy());
require(address(_token) != 0x0);
require(_wallet != 0x0);
require(_weiMaximumGoal > 0);
require(_weiMinimumGoal > 0);
startTime = _startTime;
endTime = _endTime;
pricingStrategy = _pricingStrategy;
token = _token;
wallet = _wallet;
weiMaximumGoal = _weiMaximumGoal;
weiMinimumGoal = _weiMinimumGoal;
minAmount = _minAmount;
}
// fallback function can be used to buy tokens
function () external payable {
buyTokens(msg.sender);
}
// low level token purchase function
function buyTokens(address beneficiary) public whenNotPaused payable returns (bool) {
uint weiAmount = msg.value;
require(beneficiary != 0x0);
require(validPurchase(weiAmount));
transferTokenToBuyer(beneficiary, weiAmount);
wallet.transfer(weiAmount);
return true;
}
function transferTokenToBuyer(address beneficiary, uint weiAmount) internal {
if (investedAmountOf[beneficiary] == 0) {
// A new investor
investorCount++;
}
// calculate token amount to be created
uint tokenAmount = pricingStrategy.calculateTokenAmount(weiAmount, weiRaised);
investedAmountOf[beneficiary] = investedAmountOf[beneficiary].add(weiAmount);
weiRaised = weiRaised.add(weiAmount);
tokensSold = tokensSold.add(tokenAmount);
token.transferFrom(owner, beneficiary, tokenAmount);
TokenPurchase(msg.sender, beneficiary, weiAmount, tokenAmount);
}
// return true if the transaction can buy tokens
function validPurchase(uint weiAmount) internal view returns (bool) {
bool withinPeriod = (now >= startTime || earlyParticipantWhitelist[msg.sender]) && now <= endTime;
bool withinCap = weiRaised.add(weiAmount) <= weiMaximumGoal;
bool moreThenMinimal = weiAmount >= minAmount;
return withinPeriod && withinCap && moreThenMinimal;
}
// return true if crowdsale event has ended
function hasEnded() external view returns (bool) {
bool capReached = weiRaised >= weiMaximumGoal;
bool afterEndTime = now > endTime;
return capReached || afterEndTime;
}
// get the amount of unsold tokens allocated to this contract;
function getWeiLeft() external view returns (uint) {
return weiMaximumGoal - weiRaised;
}
// return true if the crowdsale has raised enough money to be a successful.
function isMinimumGoalReached() public view returns (bool) {
return weiRaised >= weiMinimumGoal;
}
/**
* allows to add and exclude addresses from earlyParticipantWhitelist for owner
* @param isWhitelisted is true for adding address into whitelist, false - to exclude
*/
function editEarlyParicipantWhitelist(address addr, bool isWhitelisted) external onlyOwnerOrAdmin returns (bool) {
earlyParticipantWhitelist[addr] = isWhitelisted;
return true;
}
// allows to update tokens rate for owner
function setPricingStrategy(PricingStrategy _pricingStrategy) external onlyOwner returns (bool) {
pricingStrategy = _pricingStrategy;
return true;
}
/**
* Allow load refunds back on the contract for the refunding.
*
* The team can transfer the funds back on the smart contract in the case the minimum goal was not reached..
*/
function loadRefund() external payable {
require(msg.value > 0);
require(!isMinimumGoalReached());
loadedRefund = loadedRefund.add(msg.value);
}
/**
* Investors can claim refund.
*
* Note that any refunds from proxy buyers should be handled separately,
* and not through this contract.
*/
function refund() external {
uint256 weiValue = investedAmountOf[msg.sender];
require(!isMinimumGoalReached() && loadedRefund > 0);
require(!isExternalBuyer[msg.sender]);
require(weiValue > 0);
investedAmountOf[msg.sender] = 0;
weiRefunded = weiRefunded.add(weiValue);
Refund(msg.sender, weiValue);
msg.sender.transfer(weiValue);
}
function registerPayment(address beneficiary, uint weiAmount) external onlyOwnerOrAdmin {
require(validPurchase(weiAmount));
isExternalBuyer[beneficiary] = true;
transferTokenToBuyer(beneficiary, weiAmount);
}
function setAdmin(address adminAddress) external onlyOwner {
admin = adminAddress;
}
}
| 37,324
|
4
|
// NOTE: there is a slight difference here vs. the connext/AppWithCounter contract. Specifically, we want this app to/use the SingleAssetTwoPartyCoinTransferInterpreter
|
function computeOutcome(bytes calldata encodedState)
external
virtual
override
view
returns (bytes memory)
|
function computeOutcome(bytes calldata encodedState)
external
virtual
override
view
returns (bytes memory)
| 30
|
104
|
// claim LP tokens from Farm.
|
function claim(uint256 _pid) external {
require(manager.getPaused() == false, "claim: farm paused");
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount > 0, "claim: amount is equal to 0");
require(user.withdrawTime == 0, "claim: user is unstaking");
updatePool(_pid);
uint256 pendingAmount = user.amount.mul(pool.accERC20PerShare).div(1e36).sub(user.rewardDebt);
erc20Transfer(msg.sender, pendingAmount);
user.rewardDebt = user.amount.mul(pool.accERC20PerShare).div(1e36);
user.lastClaimTime = block.timestamp;
emit Claim(msg.sender, _pid);
}
|
function claim(uint256 _pid) external {
require(manager.getPaused() == false, "claim: farm paused");
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount > 0, "claim: amount is equal to 0");
require(user.withdrawTime == 0, "claim: user is unstaking");
updatePool(_pid);
uint256 pendingAmount = user.amount.mul(pool.accERC20PerShare).div(1e36).sub(user.rewardDebt);
erc20Transfer(msg.sender, pendingAmount);
user.rewardDebt = user.amount.mul(pool.accERC20PerShare).div(1e36);
user.lastClaimTime = block.timestamp;
emit Claim(msg.sender, _pid);
}
| 13,161
|
30
|
// register can only be called through transferAndCall on LINK contract name string of the upkeep to be registered encryptedEmail email address of upkeep contact upkeepContract address to peform upkeep on gasLimit amount of gas to provide the target contract when performing upkeep adminAddress address to cancel upkeep and withdraw remaining funds checkData data passed to the contract when checking for upkeep amount quantity of LINK upkeep is funded with (specified in Juels) source application sending this request /
|
function register(
string memory name,
bytes calldata encryptedEmail,
address upkeepContract,
uint32 gasLimit,
address adminAddress,
bytes calldata checkData,
uint96 amount,
uint8 source
|
function register(
string memory name,
bytes calldata encryptedEmail,
address upkeepContract,
uint32 gasLimit,
address adminAddress,
bytes calldata checkData,
uint96 amount,
uint8 source
| 34,730
|
17
|
// Determining the current status of the contract
|
function currentStanding() private constant returns (State) {
if (isTerminated) {
return this.balance > 0
? State.MONEY_BACK_RUNNING
: State.CLOSED;
} else if (block.number < PRESALE_START) {
return State.BEFORE_START;
} else if (block.number <= PRESALE_END && total_amount < MAX_TOTAL_AMOUNT_GET && !isStopped) {
return State.PRESALE_RUNNING;
} else if (this.balance == 0) {
return State.CLOSED;
} else if (block.number <= WITHDRAWAL_END && total_amount >= MIN_TOTAL_AMOUNT_GET) {
return State.WITHDRAWAL_RUNNING;
} else {
return State.MONEY_BACK_RUNNING;
}
}
|
function currentStanding() private constant returns (State) {
if (isTerminated) {
return this.balance > 0
? State.MONEY_BACK_RUNNING
: State.CLOSED;
} else if (block.number < PRESALE_START) {
return State.BEFORE_START;
} else if (block.number <= PRESALE_END && total_amount < MAX_TOTAL_AMOUNT_GET && !isStopped) {
return State.PRESALE_RUNNING;
} else if (this.balance == 0) {
return State.CLOSED;
} else if (block.number <= WITHDRAWAL_END && total_amount >= MIN_TOTAL_AMOUNT_GET) {
return State.WITHDRAWAL_RUNNING;
} else {
return State.MONEY_BACK_RUNNING;
}
}
| 54,635
|
12
|
// The protocol control center.
|
ProtocolControl internal controlCenter;
|
ProtocolControl internal controlCenter;
| 16,145
|
74
|
// Returns the number of transferable company&39;s tokens /
|
function numOfTransferableCompanysTokens() constant public returns (uint256) {
uint256 unlockedTokens = 0;
for (uint8 i; i < publicOfferingPlans.length; i++) {
PublicOfferingPlan memory plan = publicOfferingPlans[i];
if (plan.unlockCompanysTokensAt <= now) {
unlockedTokens += plan.tokenCount;
}
}
return SafeMath.sub(
balances[company],
initialCompanysTokenAllocation - unlockedTokens);
}
|
function numOfTransferableCompanysTokens() constant public returns (uint256) {
uint256 unlockedTokens = 0;
for (uint8 i; i < publicOfferingPlans.length; i++) {
PublicOfferingPlan memory plan = publicOfferingPlans[i];
if (plan.unlockCompanysTokensAt <= now) {
unlockedTokens += plan.tokenCount;
}
}
return SafeMath.sub(
balances[company],
initialCompanysTokenAllocation - unlockedTokens);
}
| 40,739
|
18
|
// 1. settlement current rewards
|
settlementRewards(strategyAddress, userAddress);
uint256 pendingGrows = growMinter.getPendingRewards(strategyAddress, userAddress);
uint256 currentRewarderBalance = IERC20(growMinter.GROW()).balanceOf(address(growMinter));
if (pendingGrows > currentRewarderBalance) {
growMinter.mintForReward(pendingGrows.sub(currentRewarderBalance));
}
|
settlementRewards(strategyAddress, userAddress);
uint256 pendingGrows = growMinter.getPendingRewards(strategyAddress, userAddress);
uint256 currentRewarderBalance = IERC20(growMinter.GROW()).balanceOf(address(growMinter));
if (pendingGrows > currentRewarderBalance) {
growMinter.mintForReward(pendingGrows.sub(currentRewarderBalance));
}
| 45,059
|
370
|
// send all remaining tokens to the address responsible for dividing them into pools
|
m_token.transfer(m_tokenDistributor, m_token.balanceOf(this));
|
m_token.transfer(m_tokenDistributor, m_token.balanceOf(this));
| 85,819
|
35
|
// allows execution only when transfers aren't disabled
|
modifier transfersAllowed {
assert(transfersEnabled);
_;
}
|
modifier transfersAllowed {
assert(transfersEnabled);
_;
}
| 887
|
21
|
// A FIFO queue for storing addresses
|
contract SessionQueue {
mapping(uint256 => address) private queue;
uint256 private first = 1;
uint256 private last = 0;
/// @dev Push into queue
function enqueue(address data) internal {
last += 1;
queue[last] = data;
}
/// @dev Returns true if the queue has elements in it
function available() internal view returns (bool) {
return last >= first;
}
/// @dev Returns the size of the queue
function depth() internal view returns (uint256) {
return last - first + 1;
}
/// @dev Pops from the head of the queue
function dequeue() internal returns (address data) {
require(last >= first);
// non-empty queue
data = queue[first];
delete queue[first];
first += 1;
}
/// @dev Returns the head of the queue without a pop
function peek() internal view returns (address data) {
require(last >= first);
// non-empty queue
data = queue[first];
}
}
|
contract SessionQueue {
mapping(uint256 => address) private queue;
uint256 private first = 1;
uint256 private last = 0;
/// @dev Push into queue
function enqueue(address data) internal {
last += 1;
queue[last] = data;
}
/// @dev Returns true if the queue has elements in it
function available() internal view returns (bool) {
return last >= first;
}
/// @dev Returns the size of the queue
function depth() internal view returns (uint256) {
return last - first + 1;
}
/// @dev Pops from the head of the queue
function dequeue() internal returns (address data) {
require(last >= first);
// non-empty queue
data = queue[first];
delete queue[first];
first += 1;
}
/// @dev Returns the head of the queue without a pop
function peek() internal view returns (address data) {
require(last >= first);
// non-empty queue
data = queue[first];
}
}
| 9,747
|
26
|
// load destination chain id length
|
chainIdLength := byte(25, blob)
|
chainIdLength := byte(25, blob)
| 18,626
|
76
|
// transfer fee to feeRecipient
|
if (feeAmount > 0) {
token.safeTransfer(feeRecipient, feeAmount);
}
|
if (feeAmount > 0) {
token.safeTransfer(feeRecipient, feeAmount);
}
| 25,051
|
8
|
// Token addresses are sorted in numerical order (ascending) as specified by Balancer
|
if (address(_tokenList[0]) > address(_tokenList[1])) {
projectTokenIndex = 1;
tokenList.push(_tokenList[1]);
tokenList.push(_tokenList[0]);
amounts.push(_amounts[1]);
amounts.push(_amounts[0]);
startWeights.push(_startWeights[1]);
startWeights.push(_startWeights[0]);
|
if (address(_tokenList[0]) > address(_tokenList[1])) {
projectTokenIndex = 1;
tokenList.push(_tokenList[1]);
tokenList.push(_tokenList[0]);
amounts.push(_amounts[1]);
amounts.push(_amounts[0]);
startWeights.push(_startWeights[1]);
startWeights.push(_startWeights[0]);
| 27,628
|
155
|
// distributes remaining BETHNB to Marketing
|
marketingBalance+=distributeETH;
|
marketingBalance+=distributeETH;
| 29,472
|
18
|
// (PSNbs)/(PSNH+((PSNrs+PSNHrt)/rt));
|
return SafeMath.div(SafeMath.mul(PSN,bs),SafeMath.add(PSNH,SafeMath.div(SafeMath.add(SafeMath.mul(PSN,rs),SafeMath.mul(PSNH,rt)),rt)));
|
return SafeMath.div(SafeMath.mul(PSN,bs),SafeMath.add(PSNH,SafeMath.div(SafeMath.add(SafeMath.mul(PSN,rs),SafeMath.mul(PSNH,rt)),rt)));
| 7,691
|
0
|
// Initiate the account with the address of the ERC725Account contract and sets LSP6KeyManager InterfaceId _account The address of the ER725Account to control /
|
constructor(address _account) {
target = _account;
}
|
constructor(address _account) {
target = _account;
}
| 11,017
|
13
|
// Allows to add a delegate./delegate Delegate that should be added.
|
function addDelegate(address delegate) public {
if (delegate == address(0)) revert GasTank__addDelegate_invalidDelegate();
if (delegates[msg.sender].contains(delegate)) revert GasTank__addDelegate_alreadyDelegate();
delegates[msg.sender].add(delegate);
delegatedGasTanks[delegate].add(msg.sender);
delegatesCurrentIndex[msg.sender][delegate] += 1;
emit AddDelegate(msg.sender, delegate);
}
|
function addDelegate(address delegate) public {
if (delegate == address(0)) revert GasTank__addDelegate_invalidDelegate();
if (delegates[msg.sender].contains(delegate)) revert GasTank__addDelegate_alreadyDelegate();
delegates[msg.sender].add(delegate);
delegatedGasTanks[delegate].add(msg.sender);
delegatesCurrentIndex[msg.sender][delegate] += 1;
emit AddDelegate(msg.sender, delegate);
}
| 29,209
|
110
|
// populate the least-significant character
|
result[41 - shift] = char(z & FOUR_BIT_MASK);
z = z >> 4;
|
result[41 - shift] = char(z & FOUR_BIT_MASK);
z = z >> 4;
| 157
|
14
|
// Represents a single stake for a user. A user may have multiple.
|
struct Stake {
uint256 amount;
uint256 stakingTime;
uint256 lastWithdrawTime;
}
|
struct Stake {
uint256 amount;
uint256 stakingTime;
uint256 lastWithdrawTime;
}
| 57,351
|
95
|
// Set the Marketing Tax Receiver Address (marketingAddress)
|
function setMarketingAddress(address _marketingAddress) external onlyOwner {
marketingAddress = _marketingAddress;
}
|
function setMarketingAddress(address _marketingAddress) external onlyOwner {
marketingAddress = _marketingAddress;
}
| 21,783
|
24
|
// maps address to how many tokens they own
|
mapping (address => uint) private ownershipTokenCount;
|
mapping (address => uint) private ownershipTokenCount;
| 29,147
|
4
|
// See {IERC2612Permit-nonces}. /
|
function nonces(address owner) public view override returns (uint256) {
return _nonces[owner].current();
}
|
function nonces(address owner) public view override returns (uint256) {
return _nonces[owner].current();
}
| 12,311
|
55
|
// Allocate rent for data. If the rent payer has enough tokens to create a rent contract, thensomeone can proceed to upload the data to the first storage node. /
|
function storeData(bytes32 contentHash, uint256 mask, uint64 size, uint32 durationAsDays, address owner) public {
uint128 rentPayer = getActiveRentPayer(msg.sender);
// Use active pricing
uint32 activePricingId = prices.length - 1;
uint256 cost = getStorageCost(size, size, activePricingId);
data[contentHash].size = size;
data[contentHash].createdAt = now;
data[contentHash].pricingId = activePricingId;
data[contentHash].contentOwner = owner;
_allocateTokensForData(rentPayerId, cost, contentHash);
emit DataStored(contentHash, mask);
}
|
function storeData(bytes32 contentHash, uint256 mask, uint64 size, uint32 durationAsDays, address owner) public {
uint128 rentPayer = getActiveRentPayer(msg.sender);
// Use active pricing
uint32 activePricingId = prices.length - 1;
uint256 cost = getStorageCost(size, size, activePricingId);
data[contentHash].size = size;
data[contentHash].createdAt = now;
data[contentHash].pricingId = activePricingId;
data[contentHash].contentOwner = owner;
_allocateTokensForData(rentPayerId, cost, contentHash);
emit DataStored(contentHash, mask);
}
| 38,661
|
4
|
// prepare the lookup table
|
let tablePtr := add(table, 1)
|
let tablePtr := add(table, 1)
| 26,857
|
89
|
// returns LP amount, not token amount
|
function burnableLiquidity() public view returns (uint256) {
return IERC20(uniswapV2Pair).balanceOf(address(this));
}
|
function burnableLiquidity() public view returns (uint256) {
return IERC20(uniswapV2Pair).balanceOf(address(this));
}
| 9,853
|
0
|
// Provides addresses of the live contracts implementing certain interfaces. Examples are the Oracle or Store interfaces. /
|
interface FinderInterface {
/**
* @notice Updates the address of the contract that implements `interfaceName`.
* @param interfaceName bytes32 encoding of the interface name that is either changed or registered.
* @param implementationAddress address of the deployed contract that implements the interface.
*/
function changeImplementationAddress(bytes32 interfaceName, address implementationAddress) external;
/**
* @notice Gets the address of the contract that implements the given `interfaceName`.
* @param interfaceName queried interface.
* @return implementationAddress address of the deployed contract that implements the interface.
*/
function getImplementationAddress(bytes32 interfaceName) external view returns (address);
}
|
interface FinderInterface {
/**
* @notice Updates the address of the contract that implements `interfaceName`.
* @param interfaceName bytes32 encoding of the interface name that is either changed or registered.
* @param implementationAddress address of the deployed contract that implements the interface.
*/
function changeImplementationAddress(bytes32 interfaceName, address implementationAddress) external;
/**
* @notice Gets the address of the contract that implements the given `interfaceName`.
* @param interfaceName queried interface.
* @return implementationAddress address of the deployed contract that implements the interface.
*/
function getImplementationAddress(bytes32 interfaceName) external view returns (address);
}
| 17,065
|
137
|
// A function which transfers fees to the `_feeReceiver` Note: function will not revert if underlying transfers fails _proofData decoded rollup proof data _feeReceiver fee beneficiary as described by the rollup provider /
|
function transferFee(bytes memory _proofData, address _feeReceiver) internal {
for (uint256 i = 0; i < NUMBER_OF_ASSETS;) {
uint256 txFee = extractTotalTxFee(_proofData, i);
if (txFee > 0) {
uint256 assetId = extractFeeAssetId(_proofData, i);
if (assetId == ETH_ASSET_ID) {
// We explicitly do not throw if this call fails, as this opens up the possiblity of griefing
// attacks --> engineering a failed fee would invalidate an entire rollup block. As griefing could
// be done by consuming all gas in the `_feeReceiver` fallback only 50K gas is forwarded. We are
// forwarding a bit more gas than in the withdraw function because this code will only be hit
// at most once each rollup-block and we want to give the provider a bit more flexibility.
assembly {
pop(call(50000, _feeReceiver, txFee, 0, 0, 0, 0))
}
} else {
address assetAddress = getSupportedAsset(assetId);
TokenTransfers.transferToDoNotBubbleErrors(
assetAddress, _feeReceiver, txFee, assetGasLimits[assetId]
);
}
}
unchecked {
++i;
}
}
}
|
function transferFee(bytes memory _proofData, address _feeReceiver) internal {
for (uint256 i = 0; i < NUMBER_OF_ASSETS;) {
uint256 txFee = extractTotalTxFee(_proofData, i);
if (txFee > 0) {
uint256 assetId = extractFeeAssetId(_proofData, i);
if (assetId == ETH_ASSET_ID) {
// We explicitly do not throw if this call fails, as this opens up the possiblity of griefing
// attacks --> engineering a failed fee would invalidate an entire rollup block. As griefing could
// be done by consuming all gas in the `_feeReceiver` fallback only 50K gas is forwarded. We are
// forwarding a bit more gas than in the withdraw function because this code will only be hit
// at most once each rollup-block and we want to give the provider a bit more flexibility.
assembly {
pop(call(50000, _feeReceiver, txFee, 0, 0, 0, 0))
}
} else {
address assetAddress = getSupportedAsset(assetId);
TokenTransfers.transferToDoNotBubbleErrors(
assetAddress, _feeReceiver, txFee, assetGasLimits[assetId]
);
}
}
unchecked {
++i;
}
}
}
| 14,701
|
40
|
// For migration purposes between V1 and V2. It can be removed once migrated to V2.
|
uint256 currentStCelo = 0;
uint256 stCeloForWholeGroup = IManager(manager).toStakedCelo(
account.getCeloForGroup(group)
);
if (stCeloForWholeGroup != 0) {
(uint256 specificGroupTotalStCelo, , ) = specificGroupStrategy.getStCeloInGroup(group);
currentStCelo =
stCeloForWholeGroup -
Math.min(stCeloForWholeGroup, specificGroupTotalStCelo);
|
uint256 currentStCelo = 0;
uint256 stCeloForWholeGroup = IManager(manager).toStakedCelo(
account.getCeloForGroup(group)
);
if (stCeloForWholeGroup != 0) {
(uint256 specificGroupTotalStCelo, , ) = specificGroupStrategy.getStCeloInGroup(group);
currentStCelo =
stCeloForWholeGroup -
Math.min(stCeloForWholeGroup, specificGroupTotalStCelo);
| 26,910
|
4
|
// src/deps.sol/ pragma solidity >=0.5.12; // import "dss/lib.sol"; /
|
interface VatLike_11 {
function slip(bytes32, address, int256) external;
}
|
interface VatLike_11 {
function slip(bytes32, address, int256) external;
}
| 43,144
|
161
|
// Uninitialized users should not earn anything yet
|
if (!userIsInitialized[account]) return 0;
|
if (!userIsInitialized[account]) return 0;
| 64,241
|
3
|
// Referral bonus accrual event
|
event RefererBonus(address _from, address _to, uint256 _amount, uint256 _revenue, uint256 _level);
|
event RefererBonus(address _from, address _to, uint256 _amount, uint256 _revenue, uint256 _level);
| 28,668
|
515
|
// Verifies signature. hash order hash v argument from vrs hash. r argument from vrs hash. s argument from vrs hash. /
|
function isValidSignature(bytes32 hash, uint8 v, bytes32 r, bytes32 s) public view returns (bool) {
bytes memory prefix = "\x19Ethereum Signed Message:\n32";
bytes32 prefixedHash = keccak256(abi.encodePacked(prefix, hash));
address a = ecrecover(prefixedHash, v, r, s);
return (a == qd.getAuthQuoteEngine());
}
|
function isValidSignature(bytes32 hash, uint8 v, bytes32 r, bytes32 s) public view returns (bool) {
bytes memory prefix = "\x19Ethereum Signed Message:\n32";
bytes32 prefixedHash = keccak256(abi.encodePacked(prefix, hash));
address a = ecrecover(prefixedHash, v, r, s);
return (a == qd.getAuthQuoteEngine());
}
| 2,057
|
15
|
// Since 0 < logInput <= 1 => logResult <= 0
|
int256 logResult = LogExpMath.ln(int256(logInput));
return(uint256(-logResult) / _ONE_YEAR);
|
int256 logResult = LogExpMath.ln(int256(logInput));
return(uint256(-logResult) / _ONE_YEAR);
| 25,831
|
79
|
// % to holders
|
uint256 public defaultTaxFee = 0;
uint256 public _taxFee = defaultTaxFee;
uint256 private _previousTaxFee = _taxFee;
|
uint256 public defaultTaxFee = 0;
uint256 public _taxFee = defaultTaxFee;
uint256 private _previousTaxFee = _taxFee;
| 853
|
274
|
// opensea / ERC721 functions
|
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory base = _baseURI();
return string(abi.encodePacked(base, uint2str(noundleType[tokenId]), "/", uint2str(noundleOffsetCount[tokenId])));
}
|
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory base = _baseURI();
return string(abi.encodePacked(base, uint2str(noundleType[tokenId]), "/", uint2str(noundleOffsetCount[tokenId])));
}
| 31,153
|
20
|
// --- What percent will be returned to presale after TGE (in percents from TGE sum)
|
uint32 public percentToPresalersFromTGE; // in % * 100, example 10% = 1000
uint256 public weiToPresalersFromTGE; // in wei
|
uint32 public percentToPresalersFromTGE; // in % * 100, example 10% = 1000
uint256 public weiToPresalersFromTGE; // in wei
| 41,338
|
2
|
// constant, not store in ethereum state
|
uint256 maxValueDonate = 100000000000000000;
event DonateETH(address indexed _userAddr, uint256 value);
event Claim(uint256 value);
|
uint256 maxValueDonate = 100000000000000000;
event DonateETH(address indexed _userAddr, uint256 value);
event Claim(uint256 value);
| 4,297
|
120
|
// Gets addresses of underlying token in pool To be used externallyreturn addresses of assets in the pool /
|
function getTokenAddresses()
external
view
override
returns (address[] memory)
|
function getTokenAddresses()
external
view
override
returns (address[] memory)
| 14,794
|
331
|
// only accrue divs before the maturation date. The final div payment will be paid as part of the matureCBOND transaction, so set the maximum number of periods to cash out be one less than the ultimate total.
|
if(currentCashoutInPeriod>=termLengthById[tokenId].div(90 days)){
|
if(currentCashoutInPeriod>=termLengthById[tokenId].div(90 days)){
| 30,191
|
227
|
// return total staking balances for Pool /
|
function stakingTotals() external view returns (uint256[] memory);
|
function stakingTotals() external view returns (uint256[] memory);
| 73,731
|
2
|
// number of bytes required to write down the nonce
|
uint256 nonce_bytes;
|
uint256 nonce_bytes;
| 50,241
|
127
|
// Mapping from token ID to its index in global tokens array. /
|
mapping(uint256 => uint256) internal idToIndex;
|
mapping(uint256 => uint256) internal idToIndex;
| 75,392
|
55
|
// transfer the token amount from this address back to the owner
|
IERC20(tokenSaleInfo.contractAddress).transfer(tokenSaleInfo.receiveAddress, tokenSaleInfo.tokenAmount);
|
IERC20(tokenSaleInfo.contractAddress).transfer(tokenSaleInfo.receiveAddress, tokenSaleInfo.tokenAmount);
| 33,998
|
14
|
// Liquidity Book Encoded Library Lydia Finance Helper contract used for decoding bytes32 sample /
|
library Encoded {
uint256 internal constant MASK_UINT1 = 0x1;
uint256 internal constant MASK_UINT8 = 0xff;
uint256 internal constant MASK_UINT12 = 0xfff;
uint256 internal constant MASK_UINT14 = 0x3fff;
uint256 internal constant MASK_UINT16 = 0xffff;
uint256 internal constant MASK_UINT20 = 0xfffff;
uint256 internal constant MASK_UINT24 = 0xffffff;
uint256 internal constant MASK_UINT40 = 0xffffffffff;
uint256 internal constant MASK_UINT64 = 0xffffffffffffffff;
uint256 internal constant MASK_UINT128 = 0xffffffffffffffffffffffffffffffff;
/**
* @notice Internal function to set a value in an encoded bytes32 using a mask and offset
* @dev This function can overflow
* @param encoded The previous encoded value
* @param value The value to encode
* @param mask The mask
* @param offset The offset
* @return newEncoded The new encoded value
*/
function set(bytes32 encoded, uint256 value, uint256 mask, uint256 offset)
internal
pure
returns (bytes32 newEncoded)
{
assembly {
newEncoded := and(encoded, not(shl(offset, mask)))
newEncoded := or(newEncoded, shl(offset, and(value, mask)))
}
}
/**
* @notice Internal function to set a bool in an encoded bytes32 using an offset
* @dev This function can overflow
* @param encoded The previous encoded value
* @param boolean The bool to encode
* @param offset The offset
* @return newEncoded The new encoded value
*/
function setBool(bytes32 encoded, bool boolean, uint256 offset) internal pure returns (bytes32 newEncoded) {
return set(encoded, boolean ? 1 : 0, MASK_UINT1, offset);
}
/**
* @notice Internal function to decode a bytes32 sample using a mask and offset
* @dev This function can overflow
* @param encoded The encoded value
* @param mask The mask
* @param offset The offset
* @return value The decoded value
*/
function decode(bytes32 encoded, uint256 mask, uint256 offset) internal pure returns (uint256 value) {
assembly {
value := and(shr(offset, encoded), mask)
}
}
/**
* @notice Internal function to decode a bytes32 sample into a bool using an offset
* @dev This function can overflow
* @param encoded The encoded value
* @param offset The offset
* @return boolean The decoded value as a bool
*/
function decodeBool(bytes32 encoded, uint256 offset) internal pure returns (bool boolean) {
assembly {
boolean := and(shr(offset, encoded), MASK_UINT1)
}
}
/**
* @notice Internal function to decode a bytes32 sample into a uint8 using an offset
* @dev This function can overflow
* @param encoded The encoded value
* @param offset The offset
* @return value The decoded value
*/
function decodeUint8(bytes32 encoded, uint256 offset) internal pure returns (uint8 value) {
assembly {
value := and(shr(offset, encoded), MASK_UINT8)
}
}
/**
* @notice Internal function to decode a bytes32 sample into a uint12 using an offset
* @dev This function can overflow
* @param encoded The encoded value
* @param offset The offset
* @return value The decoded value as a uint16, since uint12 is not supported
*/
function decodeUint12(bytes32 encoded, uint256 offset) internal pure returns (uint16 value) {
assembly {
value := and(shr(offset, encoded), MASK_UINT12)
}
}
/**
* @notice Internal function to decode a bytes32 sample into a uint14 using an offset
* @dev This function can overflow
* @param encoded The encoded value
* @param offset The offset
* @return value The decoded value as a uint16, since uint14 is not supported
*/
function decodeUint14(bytes32 encoded, uint256 offset) internal pure returns (uint16 value) {
assembly {
value := and(shr(offset, encoded), MASK_UINT14)
}
}
/**
* @notice Internal function to decode a bytes32 sample into a uint16 using an offset
* @dev This function can overflow
* @param encoded The encoded value
* @param offset The offset
* @return value The decoded value
*/
function decodeUint16(bytes32 encoded, uint256 offset) internal pure returns (uint16 value) {
assembly {
value := and(shr(offset, encoded), MASK_UINT16)
}
}
/**
* @notice Internal function to decode a bytes32 sample into a uint20 using an offset
* @dev This function can overflow
* @param encoded The encoded value
* @param offset The offset
* @return value The decoded value as a uint24, since uint20 is not supported
*/
function decodeUint20(bytes32 encoded, uint256 offset) internal pure returns (uint24 value) {
assembly {
value := and(shr(offset, encoded), MASK_UINT20)
}
}
/**
* @notice Internal function to decode a bytes32 sample into a uint24 using an offset
* @dev This function can overflow
* @param encoded The encoded value
* @param offset The offset
* @return value The decoded value
*/
function decodeUint24(bytes32 encoded, uint256 offset) internal pure returns (uint24 value) {
assembly {
value := and(shr(offset, encoded), MASK_UINT24)
}
}
/**
* @notice Internal function to decode a bytes32 sample into a uint40 using an offset
* @dev This function can overflow
* @param encoded The encoded value
* @param offset The offset
* @return value The decoded value
*/
function decodeUint40(bytes32 encoded, uint256 offset) internal pure returns (uint40 value) {
assembly {
value := and(shr(offset, encoded), MASK_UINT40)
}
}
/**
* @notice Internal function to decode a bytes32 sample into a uint64 using an offset
* @dev This function can overflow
* @param encoded The encoded value
* @param offset The offset
* @return value The decoded value
*/
function decodeUint64(bytes32 encoded, uint256 offset) internal pure returns (uint64 value) {
assembly {
value := and(shr(offset, encoded), MASK_UINT64)
}
}
/**
* @notice Internal function to decode a bytes32 sample into a uint128 using an offset
* @dev This function can overflow
* @param encoded The encoded value
* @param offset The offset
* @return value The decoded value
*/
function decodeUint128(bytes32 encoded, uint256 offset) internal pure returns (uint128 value) {
assembly {
value := and(shr(offset, encoded), MASK_UINT128)
}
}
}
|
library Encoded {
uint256 internal constant MASK_UINT1 = 0x1;
uint256 internal constant MASK_UINT8 = 0xff;
uint256 internal constant MASK_UINT12 = 0xfff;
uint256 internal constant MASK_UINT14 = 0x3fff;
uint256 internal constant MASK_UINT16 = 0xffff;
uint256 internal constant MASK_UINT20 = 0xfffff;
uint256 internal constant MASK_UINT24 = 0xffffff;
uint256 internal constant MASK_UINT40 = 0xffffffffff;
uint256 internal constant MASK_UINT64 = 0xffffffffffffffff;
uint256 internal constant MASK_UINT128 = 0xffffffffffffffffffffffffffffffff;
/**
* @notice Internal function to set a value in an encoded bytes32 using a mask and offset
* @dev This function can overflow
* @param encoded The previous encoded value
* @param value The value to encode
* @param mask The mask
* @param offset The offset
* @return newEncoded The new encoded value
*/
function set(bytes32 encoded, uint256 value, uint256 mask, uint256 offset)
internal
pure
returns (bytes32 newEncoded)
{
assembly {
newEncoded := and(encoded, not(shl(offset, mask)))
newEncoded := or(newEncoded, shl(offset, and(value, mask)))
}
}
/**
* @notice Internal function to set a bool in an encoded bytes32 using an offset
* @dev This function can overflow
* @param encoded The previous encoded value
* @param boolean The bool to encode
* @param offset The offset
* @return newEncoded The new encoded value
*/
function setBool(bytes32 encoded, bool boolean, uint256 offset) internal pure returns (bytes32 newEncoded) {
return set(encoded, boolean ? 1 : 0, MASK_UINT1, offset);
}
/**
* @notice Internal function to decode a bytes32 sample using a mask and offset
* @dev This function can overflow
* @param encoded The encoded value
* @param mask The mask
* @param offset The offset
* @return value The decoded value
*/
function decode(bytes32 encoded, uint256 mask, uint256 offset) internal pure returns (uint256 value) {
assembly {
value := and(shr(offset, encoded), mask)
}
}
/**
* @notice Internal function to decode a bytes32 sample into a bool using an offset
* @dev This function can overflow
* @param encoded The encoded value
* @param offset The offset
* @return boolean The decoded value as a bool
*/
function decodeBool(bytes32 encoded, uint256 offset) internal pure returns (bool boolean) {
assembly {
boolean := and(shr(offset, encoded), MASK_UINT1)
}
}
/**
* @notice Internal function to decode a bytes32 sample into a uint8 using an offset
* @dev This function can overflow
* @param encoded The encoded value
* @param offset The offset
* @return value The decoded value
*/
function decodeUint8(bytes32 encoded, uint256 offset) internal pure returns (uint8 value) {
assembly {
value := and(shr(offset, encoded), MASK_UINT8)
}
}
/**
* @notice Internal function to decode a bytes32 sample into a uint12 using an offset
* @dev This function can overflow
* @param encoded The encoded value
* @param offset The offset
* @return value The decoded value as a uint16, since uint12 is not supported
*/
function decodeUint12(bytes32 encoded, uint256 offset) internal pure returns (uint16 value) {
assembly {
value := and(shr(offset, encoded), MASK_UINT12)
}
}
/**
* @notice Internal function to decode a bytes32 sample into a uint14 using an offset
* @dev This function can overflow
* @param encoded The encoded value
* @param offset The offset
* @return value The decoded value as a uint16, since uint14 is not supported
*/
function decodeUint14(bytes32 encoded, uint256 offset) internal pure returns (uint16 value) {
assembly {
value := and(shr(offset, encoded), MASK_UINT14)
}
}
/**
* @notice Internal function to decode a bytes32 sample into a uint16 using an offset
* @dev This function can overflow
* @param encoded The encoded value
* @param offset The offset
* @return value The decoded value
*/
function decodeUint16(bytes32 encoded, uint256 offset) internal pure returns (uint16 value) {
assembly {
value := and(shr(offset, encoded), MASK_UINT16)
}
}
/**
* @notice Internal function to decode a bytes32 sample into a uint20 using an offset
* @dev This function can overflow
* @param encoded The encoded value
* @param offset The offset
* @return value The decoded value as a uint24, since uint20 is not supported
*/
function decodeUint20(bytes32 encoded, uint256 offset) internal pure returns (uint24 value) {
assembly {
value := and(shr(offset, encoded), MASK_UINT20)
}
}
/**
* @notice Internal function to decode a bytes32 sample into a uint24 using an offset
* @dev This function can overflow
* @param encoded The encoded value
* @param offset The offset
* @return value The decoded value
*/
function decodeUint24(bytes32 encoded, uint256 offset) internal pure returns (uint24 value) {
assembly {
value := and(shr(offset, encoded), MASK_UINT24)
}
}
/**
* @notice Internal function to decode a bytes32 sample into a uint40 using an offset
* @dev This function can overflow
* @param encoded The encoded value
* @param offset The offset
* @return value The decoded value
*/
function decodeUint40(bytes32 encoded, uint256 offset) internal pure returns (uint40 value) {
assembly {
value := and(shr(offset, encoded), MASK_UINT40)
}
}
/**
* @notice Internal function to decode a bytes32 sample into a uint64 using an offset
* @dev This function can overflow
* @param encoded The encoded value
* @param offset The offset
* @return value The decoded value
*/
function decodeUint64(bytes32 encoded, uint256 offset) internal pure returns (uint64 value) {
assembly {
value := and(shr(offset, encoded), MASK_UINT64)
}
}
/**
* @notice Internal function to decode a bytes32 sample into a uint128 using an offset
* @dev This function can overflow
* @param encoded The encoded value
* @param offset The offset
* @return value The decoded value
*/
function decodeUint128(bytes32 encoded, uint256 offset) internal pure returns (uint128 value) {
assembly {
value := and(shr(offset, encoded), MASK_UINT128)
}
}
}
| 28,737
|
15
|
// Standard minting function. Requires msg.value==tokenPrice and mintingNotPaused.
|
function mintToken() public payable {
requireMintingNotPaused();
_generalMint(msg.sender);
}
|
function mintToken() public payable {
requireMintingNotPaused();
_generalMint(msg.sender);
}
| 72,296
|
110
|
// When does the period end?
|
uint public constant END_TIME = BEGIN_TIME + DURATION;
|
uint public constant END_TIME = BEGIN_TIME + DURATION;
| 31,340
|
128
|
// Permissive removal of asset from escrow status after time-out /
|
function permissiveEndEscrow(bytes32 _idxHash) external;
|
function permissiveEndEscrow(bytes32 _idxHash) external;
| 32,909
|
2
|
// Gets the address of the contract that implements the given `interfaceName`. interfaceName queried interface.return implementationAddress Address of the deployed contract that implements the interface. /
|
function getImplementationAddress(bytes32 interfaceName)
external
view
returns (address);
|
function getImplementationAddress(bytes32 interfaceName)
external
view
returns (address);
| 9,909
|
7
|
// --- ERC20 ---
|
function transfer(address dst, uint wad) external returns (bool) {
return transferFrom(msg.sender, dst, wad);
}
|
function transfer(address dst, uint wad) external returns (bool) {
return transferFrom(msg.sender, dst, wad);
}
| 21,228
|
10
|
// Verify claim validity. If not valid, revert. when there's allowlist present --> verifyClaimMerkleProof will verify the maxQuantityInAllowlist value with hashed leaf in the allowlist when there's no allowlist, this check is true --> verifyClaim will check for _quantity being equal/less than the limit
|
bool toVerifyMaxQuantityPerTransaction = _allowlistProof.maxQuantityInAllowlist == 0 ||
claimCondition.merkleRoot == bytes32(0);
verifyClaim(_dropMsgSender(), _quantity, _currency, _pricePerToken, toVerifyMaxQuantityPerTransaction);
if (validMerkleProof && _allowlistProof.maxQuantityInAllowlist > 0) {
|
bool toVerifyMaxQuantityPerTransaction = _allowlistProof.maxQuantityInAllowlist == 0 ||
claimCondition.merkleRoot == bytes32(0);
verifyClaim(_dropMsgSender(), _quantity, _currency, _pricePerToken, toVerifyMaxQuantityPerTransaction);
if (validMerkleProof && _allowlistProof.maxQuantityInAllowlist > 0) {
| 29,616
|
135
|
// Clear approvals from the previous owner
|
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
|
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
| 228
|
1
|
// 10% effective inf rate.
|
constructor()
Chorus(
payable(address(oracle)),
address(collateral),
1,
1000000,
"Note",
"NTO",
105170917901244404,
address(0x1)
|
constructor()
Chorus(
payable(address(oracle)),
address(collateral),
1,
1000000,
"Note",
"NTO",
105170917901244404,
address(0x1)
| 15,760
|
51
|
// Emits Error if _from doesn't trust _to.
|
modifier checkTrust(address _from, address _to) {
if (isTrusted(_from, _to)) {
_;
}
}
|
modifier checkTrust(address _from, address _to) {
if (isTrusted(_from, _to)) {
_;
}
}
| 15,900
|
116
|
// player1 goes next
|
lastBlock[_stack] = uint32(block.number);
lastActor[_stack] = stacks[_counterStack].owner;
|
lastBlock[_stack] = uint32(block.number);
lastActor[_stack] = stacks[_counterStack].owner;
| 24,481
|
245
|
// Subtract all fees the miner pays to the orders
|
feeToMiner = minerFee.mul(feeCtx.ctx.feePercentageBase -
feeCtx.ring.minerFeesToOrdersPercentage) /
feeCtx.ctx.feePercentageBase;
|
feeToMiner = minerFee.mul(feeCtx.ctx.feePercentageBase -
feeCtx.ring.minerFeesToOrdersPercentage) /
feeCtx.ctx.feePercentageBase;
| 32,928
|
0
|
// governance address for the governance contract
|
address public governance;
address public pendingGovernance;
|
address public governance;
address public pendingGovernance;
| 9,872
|
68
|
// Check how much did we get and how much should we send back
|
totalValue = TokenStore(_store).balanceOf(_tokenGive, this);
uint customerValue = safeMul(_amountGive, _amount) / _amountGet;
|
totalValue = TokenStore(_store).balanceOf(_tokenGive, this);
uint customerValue = safeMul(_amountGive, _amount) / _amountGet;
| 31,070
|
4
|
// length returns uint current number of addresses tracked in mapping
|
function length(UserStruct storage map) internal view returns (uint) {
return map.keys.length;
}
|
function length(UserStruct storage map) internal view returns (uint) {
return map.keys.length;
}
| 22,462
|
22
|
// callback that provider will call after Dispatch.query() call/id request id/response1 first provider-specified param/response2 second provider-specified param/response3 third provider-specified param
|
function callback(uint256 id, string response1, string response2, string response3) external;
|
function callback(uint256 id, string response1, string response2, string response3) external;
| 4,915
|
4
|
// 获取某轮次信仰奖励信息/ return 轮次、获胜者列表、获胜者奖金列表
|
function getFaithWinnerInfo()
public
view
returns(uint256, address[] memory, uint256[] memory)
|
function getFaithWinnerInfo()
public
view
returns(uint256, address[] memory, uint256[] memory)
| 53,762
|
42
|
// co-founders
|
address _core1Account,
address _core2Account,
|
address _core1Account,
address _core2Account,
| 8,622
|
96
|
// Emitted on deposit() reserve The address of the underlying asset of the reserve user The address initiating the deposit onBehalfOf The beneficiary of the deposit, receiving the aTokens amount The amount deposited referral The referral code used // Emitted on withdraw() reserve The address of the underlyng asset being withdrawn user The address initiating the withdrawal, owner of aTokens to Address that will receive the underlying amount The amount to be withdrawn // Emitted on borrow() and flashLoan() when debt needs to be opened reserve The address of the underlying asset being borrowed user The address of the user initiating
|
event Paused();
|
event Paused();
| 46,856
|
23
|
// The Ownable constructor sets the original `owner` of the contract to the senderaccount. /
|
constructor () internal {
_owner = msg.sender;
emit OwnershipTransferred(address(0), _owner);
}
|
constructor () internal {
_owner = msg.sender;
emit OwnershipTransferred(address(0), _owner);
}
| 3,148
|
323
|
// r = s^2m / 2
|
_reserve = _supply
.mul(_supply)
.div(DIVIDER) // inverse the operation (Divider instead of multiplier)
.div(2)
.roundedDiv(1e18);
|
_reserve = _supply
.mul(_supply)
.div(DIVIDER) // inverse the operation (Divider instead of multiplier)
.div(2)
.roundedDiv(1e18);
| 19,273
|
5
|
// The `baseURI` is a string that represents the base Uniform Resource Identifier (URI)where the metadata of each token is stored. /
|
string private baseURI;
|
string private baseURI;
| 23,763
|
93
|
// recover signer
|
address signer = ecrecover(operationHash, v, r, s);
|
address signer = ecrecover(operationHash, v, r, s);
| 36,604
|
18
|
// increment balance
|
balances[user] += convertedWadAmount;
totalReserveToken += convertedWadAmount.toUint256();
|
balances[user] += convertedWadAmount;
totalReserveToken += convertedWadAmount.toUint256();
| 14,365
|
67
|
// 取消登记定制的ERC20
|
function unregisterMinterERC20(address ERC20) public isOwner {
require(isMinterERC20(ERC20), "This address is not registered");
delete minterERC20s[ERC20];
}
|
function unregisterMinterERC20(address ERC20) public isOwner {
require(isMinterERC20(ERC20), "This address is not registered");
delete minterERC20s[ERC20];
}
| 1,827
|
3
|
// Emitted when a message is dropped from L1./index The index of message dropped.
|
event DropTransaction(uint256 index);
|
event DropTransaction(uint256 index);
| 34,195
|
938
|
// For internal usage in the logic of the parent contract IncentivizedERC20 /
|
function _getIncentivesController() internal view override returns (IAaveIncentivesController) {
return _incentivesController;
}
|
function _getIncentivesController() internal view override returns (IAaveIncentivesController) {
return _incentivesController;
}
| 39,487
|
130
|
// We need to know how much erc20 token allows our contract to transfer.
|
uint256 aValue = payerContract.allowance(msg.sender, address(this));
require(aValue >= nextPrice);
uint fee = nextPrice.mul(sysFeePermillage).div(1000);
uint oldOwnerRefund = nextPrice.sub(fee);
address oldOwner = ownerOf(_tokenId);
|
uint256 aValue = payerContract.allowance(msg.sender, address(this));
require(aValue >= nextPrice);
uint fee = nextPrice.mul(sysFeePermillage).div(1000);
uint oldOwnerRefund = nextPrice.sub(fee);
address oldOwner = ownerOf(_tokenId);
| 46,591
|
42
|
// time stamp of the ending time of the ico, must return 0 if it depends on the block number
|
function endTime()
public
view
returns(uint)
|
function endTime()
public
view
returns(uint)
| 15,231
|
10
|
// Used to check whether the given address is allowed to equip the desired `Part`. Returns true if a collection may equip asset with `partId`. partId The ID of the part that we are checking targetAddress The address that we are checking for whether the part can be equipped into it or notreturn The status indicating whether the `targetAddress` can be equipped into `Part` with `partId` or not /
|
function checkIsEquippable(
uint64 partId,
address targetAddress
) external view returns (bool);
|
function checkIsEquippable(
uint64 partId,
address targetAddress
) external view returns (bool);
| 12,880
|
27
|
// This mutates `balances` so that they become the post-joinswap balances. The StableMath interfacesare different depending on the swap direction, so we forward to the appropriate low-level join function. /
|
function _doJoinSwap(
bool isGivenIn,
uint256 amount,
uint256[] memory balances,
uint256 indexIn,
uint256 currentAmp,
uint256 actualSupply,
uint256 preJoinExitInvariant
|
function _doJoinSwap(
bool isGivenIn,
uint256 amount,
uint256[] memory balances,
uint256 indexIn,
uint256 currentAmp,
uint256 actualSupply,
uint256 preJoinExitInvariant
| 21,573
|
186
|
// Overridden cross-chain destination address
|
destination_address_override = _destination_address_override;
|
destination_address_override = _destination_address_override;
| 40,054
|
207
|
// Claim all if no amount specified, or Deposit new LP/SAS.
|
function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
// this is claim
if (user.amount > 0) {
uint256 pending =
user.amount.mul(pool.accSAV3XRPperShare).div(1e12).sub(
user.rewardDebt
);
if (pending > 0) {
_saviorContract.giveSAV3XRPreward(msg.sender, pending);
}
} /// Deposit
if (_amount > 0) {
uint256 beforeAmount = pool.stakableToken.balanceOf(address(this));
pool.stakableToken.safeTransferFrom(
address(msg.sender),
address(this),
_amount
);
uint256 _addAmt =
pool.stakableToken.balanceOf(address(this)).sub(beforeAmount);
user.amount = user.amount.add(_addAmt);
}
user.rewardDebt = user.amount.mul(pool.accSAV3XRPperShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
|
function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
// this is claim
if (user.amount > 0) {
uint256 pending =
user.amount.mul(pool.accSAV3XRPperShare).div(1e12).sub(
user.rewardDebt
);
if (pending > 0) {
_saviorContract.giveSAV3XRPreward(msg.sender, pending);
}
} /// Deposit
if (_amount > 0) {
uint256 beforeAmount = pool.stakableToken.balanceOf(address(this));
pool.stakableToken.safeTransferFrom(
address(msg.sender),
address(this),
_amount
);
uint256 _addAmt =
pool.stakableToken.balanceOf(address(this)).sub(beforeAmount);
user.amount = user.amount.add(_addAmt);
}
user.rewardDebt = user.amount.mul(pool.accSAV3XRPperShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
| 32,731
|
43
|
// xEHash => EHash /
|
function swapOut(uint256 amount) external {
require (amount <= balanceOf(msg.sender), "xEHashToken: balance exceeded");
// burn xEHash Token
_burn(msg.sender, amount);
// transfer EHash back to sender
EHashToken.safeTransfer(msg.sender, amount);
// log
emit SwapOut(msg.sender, amount);
// refund ethers
refund();
}
|
function swapOut(uint256 amount) external {
require (amount <= balanceOf(msg.sender), "xEHashToken: balance exceeded");
// burn xEHash Token
_burn(msg.sender, amount);
// transfer EHash back to sender
EHashToken.safeTransfer(msg.sender, amount);
// log
emit SwapOut(msg.sender, amount);
// refund ethers
refund();
}
| 16,639
|
4
|
// Cancellation requests. A map STARK key => asset id => vault id => request timestamp.
|
mapping(uint256 => mapping(uint256 => mapping(uint256 => uint256))) cancellationRequests;
|
mapping(uint256 => mapping(uint256 => mapping(uint256 => uint256))) cancellationRequests;
| 42,075
|
32
|
// logString("advertisement found");
|
voter = Voter({publicKey: voterPublicKey, amountEarned : 0});
|
voter = Voter({publicKey: voterPublicKey, amountEarned : 0});
| 31,198
|
34
|
// if the remainingTransfer is more than the unlocked balance use it all
|
remainingTransfer -= unlockedBalanceOfTimelock(from, i);
timelocks[from][i].tokensTransferred += unlockedBalanceOfTimelock(from, i);
|
remainingTransfer -= unlockedBalanceOfTimelock(from, i);
timelocks[from][i].tokensTransferred += unlockedBalanceOfTimelock(from, i);
| 44,976
|
139
|
// get exchange-specific information
|
function exchangeAdapterIsRegistered(address _adapter) external view returns (bool) {
return exchangeInformation[_adapter].exists;
}
|
function exchangeAdapterIsRegistered(address _adapter) external view returns (bool) {
return exchangeInformation[_adapter].exists;
}
| 47,405
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.