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
128
// add to sender balance sheet
_balances[msg.sender] = _balances[msg.sender].add(_amount);
_balances[msg.sender] = _balances[msg.sender].add(_amount);
29,968
330
// Create lock (legacy)This deploys a lock for a creator. It also keeps track of the deployed lock. _expirationDuration the duration of the lock (pass type(uint).max for unlimited duration) _tokenAddress set to the ERC20 token address, or 0 for ETH. _keyPrice the price of each key _maxNumberOfKeys the maximum nimbers of keys to be edited _lockName the name of the lockparam _salt [deprec] -- kept only for backwards copatibilityThis may be implemented as a sequence ID or with RNG. It's used with `create2`to know the lock's address before the transaction is mined. internally call `createUpgradeableLock` /
function createLock( uint _expirationDuration, address _tokenAddress, uint _keyPrice, uint _maxNumberOfKeys, string calldata _lockName, bytes12 // _salt
function createLock( uint _expirationDuration, address _tokenAddress, uint _keyPrice, uint _maxNumberOfKeys, string calldata _lockName, bytes12 // _salt
13,542
62
// Claim asset, transfer the given amount assets to receiver
function claim(address receiver, uint amount) external returns (uint);
function claim(address receiver, uint amount) external returns (uint);
53,208
14
// Validate semantically incomplete statements number
require(semIncompleteNum <= statementsNum);
require(semIncompleteNum <= statementsNum);
14,152
162
// Execute order
(, , , bytes memory signature) = __decodeZeroExOrderArgs(encodedZeroExOrderArgs); IZeroExV2(EXCHANGE).fillOrder(order, takerAssetFillAmount, signature);
(, , , bytes memory signature) = __decodeZeroExOrderArgs(encodedZeroExOrderArgs); IZeroExV2(EXCHANGE).fillOrder(order, takerAssetFillAmount, signature);
82,776
173
// Returns an URI for a given token ID /
function tokenURI(uint256 _tokenId) public view override returns (string memory) { return string(abi.encodePacked(baseTokenURI, _tokenId.toString())); }
function tokenURI(uint256 _tokenId) public view override returns (string memory) { return string(abi.encodePacked(baseTokenURI, _tokenId.toString())); }
64,001
3
// initialize lending pool with credit system /
function initialize(address _creditContract) public initializer { _grantRole(DEFAULT_ADMIN_ROLE, _msgSender()); creditContract = CreditSystem(_creditContract); }
function initialize(address _creditContract) public initializer { _grantRole(DEFAULT_ADMIN_ROLE, _msgSender()); creditContract = CreditSystem(_creditContract); }
37,683
15
// Do not allow deleting any outputs that have already been finalized.
require( block.timestamp - l2Outputs[_l2OutputIndex].timestamp < FINALIZATION_PERIOD_SECONDS, "L2OutputOracle: cannot delete outputs that have already been finalized" ); uint256 prevNextL2OutputIndex = nextOutputIndex();
require( block.timestamp - l2Outputs[_l2OutputIndex].timestamp < FINALIZATION_PERIOD_SECONDS, "L2OutputOracle: cannot delete outputs that have already been finalized" ); uint256 prevNextL2OutputIndex = nextOutputIndex();
23,798
104
// memberAddr The member address to look upreturn The delegate key address for memberAddr at the second last checkpoint number /
function getPreviousDelegateKey(address memberAddr) external view returns (address)
function getPreviousDelegateKey(address memberAddr) external view returns (address)
15,870
11
// Finalize contract /
function finalize() public isInitialized { require(getBlockNumber() >= startBlock); require(msg.sender == owner || getBlockNumber() > endBlock); finalizedBlock = getBlockNumber(); finalizedTime = now; Finalized(); }
function finalize() public isInitialized { require(getBlockNumber() >= startBlock); require(msg.sender == owner || getBlockNumber() > endBlock); finalizedBlock = getBlockNumber(); finalizedTime = now; Finalized(); }
198
18
// Pools
uint256 internal constant MIN_AMP = 300; uint256 internal constant MAX_AMP = 301; uint256 internal constant MIN_WEIGHT = 302; uint256 internal constant MAX_STABLE_TOKENS = 303; uint256 internal constant MAX_IN_RATIO = 304; uint256 internal constant MAX_OUT_RATIO = 305; uint256 internal constant MIN_BPT_IN_FOR_TOKEN_OUT = 306; uint256 internal constant MAX_OUT_BPT_FOR_TOKEN_IN = 307; uint256 internal constant NORMALIZED_WEIGHT_INVARIANT = 308; uint256 internal constant INVALID_TOKEN = 309;
uint256 internal constant MIN_AMP = 300; uint256 internal constant MAX_AMP = 301; uint256 internal constant MIN_WEIGHT = 302; uint256 internal constant MAX_STABLE_TOKENS = 303; uint256 internal constant MAX_IN_RATIO = 304; uint256 internal constant MAX_OUT_RATIO = 305; uint256 internal constant MIN_BPT_IN_FOR_TOKEN_OUT = 306; uint256 internal constant MAX_OUT_BPT_FOR_TOKEN_IN = 307; uint256 internal constant NORMALIZED_WEIGHT_INVARIANT = 308; uint256 internal constant INVALID_TOKEN = 309;
3,294
129
// Updates gem metadata info. Must only be called by the gem manager.
function updateGemInfo( uint kind, string calldata name, string calldata color
function updateGemInfo( uint kind, string calldata name, string calldata color
41,242
21
// DSMath.wpow
function bpowi(uint a, uint n) internal pure returns (uint)
function bpowi(uint a, uint n) internal pure returns (uint)
30,380
7
// A library for performing overflow-safe math, courtesy of DappHub: https:github.com/dapphub/ds-math/blob/d0ef6d6a5f/src/math.sol Modified to include only the essentials
library SafeMath { function add(uint256 x, uint256 y) internal pure returns (uint256 z) { require((z = x + y) >= x, "MATH:ADD_OVERFLOW"); } function sub(uint256 x, uint256 y) internal pure returns (uint256 z) { require((z = x - y) <= x, "MATH:SUB_UNDERFLOW"); } }
library SafeMath { function add(uint256 x, uint256 y) internal pure returns (uint256 z) { require((z = x + y) >= x, "MATH:ADD_OVERFLOW"); } function sub(uint256 x, uint256 y) internal pure returns (uint256 z) { require((z = x - y) <= x, "MATH:SUB_UNDERFLOW"); } }
29,242
127
// Calculate natural logarithm of x.Return NaN on negative x excluding -0.x quadruple precision numberreturn quadruple precision number /
function ln(bytes16 x) internal pure returns (bytes16) { return mul(log_2(x), 0x3FFE62E42FEFA39EF35793C7673007E5); }
function ln(bytes16 x) internal pure returns (bytes16) { return mul(log_2(x), 0x3FFE62E42FEFA39EF35793C7673007E5); }
50,938
20
// mark act as seen
used |= (1 << act);
used |= (1 << act);
21,093
2
// Store
mapping(uint => Candidate) public candidates; mapping(address => bool) public voters;
mapping(uint => Candidate) public candidates; mapping(address => bool) public voters;
45,946
6
// Closes a loan by doing a deposit loanId the id of the loan receiver the receiver of the remainder depositAmount defines how much of the position should be closed. It is denominated in loan tokens.depositAmount > principal, the complete loan will be closedelse deposit amount (partial closure) /
{ return _closeWithDeposit(loanId, receiver, depositAmount); }
{ return _closeWithDeposit(loanId, receiver, depositAmount); }
52,989
3
// relayer/miner might submit the TX with higher priorityFee, but the user should not pay above what he signed for.
function gasPrice(UserOperation calldata userOp) internal view returns (uint256) { unchecked { uint256 maxFeePerGas = userOp.maxFeePerGas; uint256 maxPriorityFeePerGas = userOp.maxPriorityFeePerGas; if (maxFeePerGas == maxPriorityFeePerGas) { //legacy mode (for networks that don't support basefee opcode) return maxFeePerGas; } return min(maxFeePerGas, maxPriorityFeePerGas + block.basefee); } }
function gasPrice(UserOperation calldata userOp) internal view returns (uint256) { unchecked { uint256 maxFeePerGas = userOp.maxFeePerGas; uint256 maxPriorityFeePerGas = userOp.maxPriorityFeePerGas; if (maxFeePerGas == maxPriorityFeePerGas) { //legacy mode (for networks that don't support basefee opcode) return maxFeePerGas; } return min(maxFeePerGas, maxPriorityFeePerGas + block.basefee); } }
24,254
1
// ------------------------------------------------------------------------- STATE MODIFYING FUNCTIONS-------------------------------------------------------------------------
function numbersDrawn(bytes32 _requestId, uint256 _randomNumber) external;
function numbersDrawn(bytes32 _requestId, uint256 _randomNumber) external;
11,513
158
// Allows the fund manager to connect to a new Oracle_newOracleaddress of new fund value Oracle contract/
function setNewFundValueOracle(address _newOracle) public onlyOwner { // Require permitted Oracle require(permittedAddresses.isMatchTypes(_newOracle, 5), "WRONG_ADDRESS"); // Set new fundValueOracle = IFundValueOracle(_newOracle); }
function setNewFundValueOracle(address _newOracle) public onlyOwner { // Require permitted Oracle require(permittedAddresses.isMatchTypes(_newOracle, 5), "WRONG_ADDRESS"); // Set new fundValueOracle = IFundValueOracle(_newOracle); }
28,907
24
// ------------------------------------------------------------------------ Handle ETH ------------------------------------------------------------------------
function () public payable { if (msg.value !=0 ) { if(!owner.send(msg.value)) { revert(); } } }
function () public payable { if (msg.value !=0 ) { if(!owner.send(msg.value)) { revert(); } } }
26,070
25
// Overflow proof multiplication
// function mul(uint a, uint b) internal pure returns (uint) { // if (a == 0) return 0; // uint c = a * b; // require(c / a == b, "MUL_OVERFLOW"); // return c; // }
// function mul(uint a, uint b) internal pure returns (uint) { // if (a == 0) return 0; // uint c = a * b; // require(c / a == b, "MUL_OVERFLOW"); // return c; // }
54,839
79
// Do reverse order of fees charged in joinswap_ExternAmountIn, this way ``` pAo == joinswap_ExternAmountIn(Ti, joinswap_PoolAmountOut(pAo, Ti)) ```uint tAi = tAiAfterFee / (1 - (1-weightTi)swapFee) ;
uint256 zar = bmul(bsub(BONE, normalizedWeight), swapFee); tokenAmountIn = bdiv(tokenAmountInAfterFee, bsub(BONE, zar)); return tokenAmountIn;
uint256 zar = bmul(bsub(BONE, normalizedWeight), swapFee); tokenAmountIn = bdiv(tokenAmountInAfterFee, bsub(BONE, zar)); return tokenAmountIn;
47,974
227
// issueId => nomatch
mapping (uint256 => uint256) public nomatch;
mapping (uint256 => uint256) public nomatch;
42,166
248
// Uniswap router
ISwap internal constant uniswapRouter = ISwap(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
ISwap internal constant uniswapRouter = ISwap(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
3,354
16
// Exposes the ability to override the msg sender.
function _dropMsgSender() internal virtual returns (address) { return msg.sender; }
function _dropMsgSender() internal virtual returns (address) { return msg.sender; }
13,733
77
// Convert the ETH to ERC20 erc20ToBurn is the amount of the ERC20 tokens converted by Kyber that will be burned
uint erc20ToBurn = kyberContract.trade.value(ethToConvert)(
uint erc20ToBurn = kyberContract.trade.value(ethToConvert)(
76,041
144
// Only taking payment in multiple of 1 ether, as 1 ether = 1 token
uint etherReceived = msg.value/(10**18);
uint etherReceived = msg.value/(10**18);
23,295
130
// SFI GENERATION / v0: pool generates SFI based on subsidy schedule v1: pool is distributed SFI generated by the strategy contract v1: pools each get an amount of SFI generated depending on the total liquidity added within each interval
TrancheUint256 public TRANCHE_SFI_MULTIPLIER = TrancheUint256({ S: 90000, AA: 0, A: 10000 });
TrancheUint256 public TRANCHE_SFI_MULTIPLIER = TrancheUint256({ S: 90000, AA: 0, A: 10000 });
18,292
16
// The price of a token in the public sale in 1/100,000 ETH - e.g. 1 = 0.00001 ETH, 100,000 = 1 ETH - multiply by 10^13 to get correct wei amount
uint32 publicPrice;
uint32 publicPrice;
21,204
173
// Calculates the funds value in deposited token return The current total fund value/
function calculateFundValue() public override view returns (uint256) { // Convert ETH balance to core ERC20 uint256 ethBalance = exchangePortal.getValue( address(ETH_TOKEN_ADDRESS), coreFundAsset, address(this).balance ); // If the fund only contains ether, return the funds ether balance converted in core ERC20 if (tokenAddresses.length == 1) return ethBalance; // Otherwise, we get the value of all the other tokens in ether via exchangePortal // Calculate value for ERC20 address[] memory fromAddresses = new address[](tokenAddresses.length - 2); // sub ETH + curernt core ERC20 uint256[] memory amounts = new uint256[](tokenAddresses.length - 2); uint8 index = 0; // get all ERC20 addresses and balance for (uint8 i = 2; i < tokenAddresses.length; i++) { fromAddresses[index] = tokenAddresses[i]; amounts[index] = IERC20(tokenAddresses[i]).balanceOf(address(this)); index++; } // Ask the Exchange Portal for the value of all the funds tokens in core coin uint256 tokensValue = exchangePortal.getTotalValue(fromAddresses, amounts, coreFundAsset); // Get curernt core ERC20 token balance uint256 currentERC20 = IERC20(coreFundAsset).balanceOf(address(this)); // Sum ETH in ERC20 + Current ERC20 Token + ERC20 in ERC20 return ethBalance + currentERC20 + tokensValue; }
function calculateFundValue() public override view returns (uint256) { // Convert ETH balance to core ERC20 uint256 ethBalance = exchangePortal.getValue( address(ETH_TOKEN_ADDRESS), coreFundAsset, address(this).balance ); // If the fund only contains ether, return the funds ether balance converted in core ERC20 if (tokenAddresses.length == 1) return ethBalance; // Otherwise, we get the value of all the other tokens in ether via exchangePortal // Calculate value for ERC20 address[] memory fromAddresses = new address[](tokenAddresses.length - 2); // sub ETH + curernt core ERC20 uint256[] memory amounts = new uint256[](tokenAddresses.length - 2); uint8 index = 0; // get all ERC20 addresses and balance for (uint8 i = 2; i < tokenAddresses.length; i++) { fromAddresses[index] = tokenAddresses[i]; amounts[index] = IERC20(tokenAddresses[i]).balanceOf(address(this)); index++; } // Ask the Exchange Portal for the value of all the funds tokens in core coin uint256 tokensValue = exchangePortal.getTotalValue(fromAddresses, amounts, coreFundAsset); // Get curernt core ERC20 token balance uint256 currentERC20 = IERC20(coreFundAsset).balanceOf(address(this)); // Sum ETH in ERC20 + Current ERC20 Token + ERC20 in ERC20 return ethBalance + currentERC20 + tokensValue; }
19,126
86
// The maximum `quantity` that can be minted with `_mintERC2309`. This limit is to prevent overflows on the address data entries. For a limit of 5000, a total of 3.689e15 calls to `_mintERC2309` is required to cause an overflow, which is unrealistic.
uint256 private constant MAX_MINT_ERC2309_QUANTITY_LIMIT = 5000;
uint256 private constant MAX_MINT_ERC2309_QUANTITY_LIMIT = 5000;
1,594
4
// Emitted when transfer/Transfer some stuff/foo Amount of stuff
event Transfer(uint256 foo);
event Transfer(uint256 foo);
50,951
68
// Token standard API https:github.com/ethereum/EIPs/issues/20
contract ERC20Events { event Transfer( address indexed from, address indexed to, uint256 value); event Approval( address indexed owner, address indexed spender, uint256 value); }
contract ERC20Events { event Transfer( address indexed from, address indexed to, uint256 value); event Approval( address indexed owner, address indexed spender, uint256 value); }
56,695
25
// Deposits tokens into ZenMaster to earn staking rewards /
function _earn() internal { uint256 bal = available(); if (bal > 0) { IZenMaster(zenmaster).enterStaking(bal); } }
function _earn() internal { uint256 bal = available(); if (bal > 0) { IZenMaster(zenmaster).enterStaking(bal); } }
27,677
29
// Emits a {Transfer} event.Releases AI Pod data associated with the tokenId on-chain See {ERC721._burn}tokenId token ID to burn /
function burn(uint64 tokenId) public {
function burn(uint64 tokenId) public {
34,742
9
// Fill an OTC order for up to `takerTokenFillAmount` taker tokens./Unwraps bought WETH into ETH. before sending it to /the taker./order The OTC order./makerSignature The order signature from the maker./takerTokenFillAmount Maximum taker token amount to fill this/order with./ return takerTokenFilledAmount How much taker token was filled./ return makerTokenFilledAmount How much maker token was filled.
function fillOtcOrderForEth( LibNativeOrder.OtcOrder memory order, LibSignature.Signature memory makerSignature, uint128 takerTokenFillAmount ) public override returns (uint128 takerTokenFilledAmount, uint128 makerTokenFilledAmount)
function fillOtcOrderForEth( LibNativeOrder.OtcOrder memory order, LibSignature.Signature memory makerSignature, uint128 takerTokenFillAmount ) public override returns (uint128 takerTokenFilledAmount, uint128 makerTokenFilledAmount)
13,016
7
// Raffle created. NFT rewards can be added, or taken back by organiser, raffle metadata and data is collected on OST chain./
Created,
Created,
30,228
43
// Function to distribute tokens _to The address that will receive the distributed tokens. _amount The amount of tokens to distribute. /
function distribute(address _to, uint256 _amount) public onlyDistributor canDistribute { require(balances[address(this)] >= _amount); balances[address(this)] = balances[address(this)].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Distribute(_to, _amount); emit Transfer(address(0), _to, _amount); }
function distribute(address _to, uint256 _amount) public onlyDistributor canDistribute { require(balances[address(this)] >= _amount); balances[address(this)] = balances[address(this)].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Distribute(_to, _amount); emit Transfer(address(0), _to, _amount); }
14,436
8
// Self Permit/Functionality to call permit on any EIP-2612-compliant token for use in the route/These functions are expected to be embedded in multicalls to allow EOAs to approve a contract and call a function/ that requires an approval in a single transaction.
abstract contract SelfPermit is ISelfPermit { /// @inheritdoc ISelfPermit function selfPermit( address token, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public payable override { IERC20Permit(token).permit(msg.sender, address(this), value, deadline, v, r, s); } /// @inheritdoc ISelfPermit function selfPermitIfNecessary( address token, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external payable override { if (IERC20(token).allowance(msg.sender, address(this)) < value) selfPermit(token, value, deadline, v, r, s); } /// @inheritdoc ISelfPermit function selfPermitAllowed( address token, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) public payable override { IERC20PermitAllowed(token).permit(msg.sender, address(this), nonce, expiry, true, v, r, s); } /// @inheritdoc ISelfPermit function selfPermitAllowedIfNecessary( address token, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) external payable override { if (IERC20(token).allowance(msg.sender, address(this)) < type(uint256).max) selfPermitAllowed(token, nonce, expiry, v, r, s); } }
abstract contract SelfPermit is ISelfPermit { /// @inheritdoc ISelfPermit function selfPermit( address token, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public payable override { IERC20Permit(token).permit(msg.sender, address(this), value, deadline, v, r, s); } /// @inheritdoc ISelfPermit function selfPermitIfNecessary( address token, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external payable override { if (IERC20(token).allowance(msg.sender, address(this)) < value) selfPermit(token, value, deadline, v, r, s); } /// @inheritdoc ISelfPermit function selfPermitAllowed( address token, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) public payable override { IERC20PermitAllowed(token).permit(msg.sender, address(this), nonce, expiry, true, v, r, s); } /// @inheritdoc ISelfPermit function selfPermitAllowedIfNecessary( address token, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) external payable override { if (IERC20(token).allowance(msg.sender, address(this)) < type(uint256).max) selfPermitAllowed(token, nonce, expiry, v, r, s); } }
13,096
8
// Standard SafeMath, stripped down to just add/sub/mul/div /
library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } }
library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } }
10,240
153
// View function to see pending Bols on frontend.
function pendingBol(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accBolPerShare = pool.accBolPerShare; if (block.number > pool.lastRewardBlock && pool.lpSupply != 0 && totalAllocPoint > 0) { uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number); uint256 bolReward = multiplier.mul(BolPerBlock).mul(pool.allocPoint).div(totalAllocPoint); accBolPerShare = accBolPerShare.add(bolReward.mul(1e18).div(pool.lpSupply)); } return user.amount.mul(accBolPerShare).div(1e18).sub(user.rewardDebt); }
function pendingBol(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accBolPerShare = pool.accBolPerShare; if (block.number > pool.lastRewardBlock && pool.lpSupply != 0 && totalAllocPoint > 0) { uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number); uint256 bolReward = multiplier.mul(BolPerBlock).mul(pool.allocPoint).div(totalAllocPoint); accBolPerShare = accBolPerShare.add(bolReward.mul(1e18).div(pool.lpSupply)); } return user.amount.mul(accBolPerShare).div(1e18).sub(user.rewardDebt); }
31,007
32
// Approve a new borrower.borrower Address of new borrower./
function addBorrower(address borrower) external onlyOwner { approved[borrower] = true; }
function addBorrower(address borrower) external onlyOwner { approved[borrower] = true; }
43,794
34
// Contribution is accepted contributor address The recipient of the tokens value uint256 The amount of contributed ETH amount uint256 The amount of tokens /
event ContributionAccepted(address indexed contributor, uint256 value, uint256 amount);
event ContributionAccepted(address indexed contributor, uint256 value, uint256 amount);
48,422
64
// Destroys `amount` tokens from `account`, deducting from the caller's allowance.
* See {BEP20-_burn} and {BEP20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public virtual { uint256 decreasedAllowance = _allowances[account][_msgSender()].sub(amount, "BEP20: burn amount exceeds allowance"); _approve(account, _msgSender(), decreasedAllowance); _burn(account, amount); }
* See {BEP20-_burn} and {BEP20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public virtual { uint256 decreasedAllowance = _allowances[account][_msgSender()].sub(amount, "BEP20: burn amount exceeds allowance"); _approve(account, _msgSender(), decreasedAllowance); _burn(account, amount); }
629
348
// Set royalty wallet address
function setRoyaltyAddress(address _address) public onlyOwner { royaltyAddress = _address; }
function setRoyaltyAddress(address _address) public onlyOwner { royaltyAddress = _address; }
53,929
38
// NOTE: decreasing array length will automatically clean up the storage slots occupied bythe out-of-bounds elements
userList.length = len.sub(1); delete userStakeMap[user]; contractSingleStakeSum = contractSingleStakeSum.sub(singleStakeSum[user]); delete singleStakeSum[user];
userList.length = len.sub(1); delete userStakeMap[user]; contractSingleStakeSum = contractSingleStakeSum.sub(singleStakeSum[user]); delete singleStakeSum[user];
14,645
102
// 团队业绩统计
_user = user; top = fromaddr[user]; for(uint n=1;n<=generation_team;n++){ if(top != address(0) && top != _user){ setteam(top,_mint_account); _user = top; top = fromaddr[top]; continue; }
_user = user; top = fromaddr[user]; for(uint n=1;n<=generation_team;n++){ if(top != address(0) && top != _user){ setteam(top,_mint_account); _user = top; top = fromaddr[top]; continue; }
49,069
13
// assert(b > 0);
require(b > 0); uint256 c = a / b;
require(b > 0); uint256 c = a / b;
57,763
68
// Method to activate withdrawal of funds even in between of sale. The WIthdrawal will only be activate iff totalFunding has reached 10,000 ether /
function activateWithdrawal()public onlyOwner _saleNotEnded _contractUp { require(totalFunding >= 10000 ether); vault.activateWithdrawal(); }
function activateWithdrawal()public onlyOwner _saleNotEnded _contractUp { require(totalFunding >= 10000 ether); vault.activateWithdrawal(); }
32,540
204
// Removes a role from an account. Should only use when circumventing admin checking. If account does not already have the role, no event is emitted. role Encoding of the role to remove.
* @param account Address to remove the {role} from. */ function revokeRole(bytes32 role, address account) internal { if (!hasRole(role, account)) return; s().roles[role][account] = false; emit RoleRevoked(role, account, msg.sender); }
* @param account Address to remove the {role} from. */ function revokeRole(bytes32 role, address account) internal { if (!hasRole(role, account)) return; s().roles[role][account] = false; emit RoleRevoked(role, account, msg.sender); }
44,287
96
// Return address of YZY Token contract /
function yzyAddress() external view returns (address) { return _yzyAddress; }
function yzyAddress() external view returns (address) { return _yzyAddress; }
907
295
// Deletes the pair for the given NFT, base token, and merkle root./nft The NFT contract address./baseToken The base token contract address./merkleRoot The merkle root for the valid tokenIds.
function destroy(address nft, address baseToken, bytes32 merkleRoot) public { // check that a pair can only destroy itself require(msg.sender == pairs[nft][baseToken][merkleRoot], "Only pair can destroy itself"); // delete the pair delete pairs[nft][baseToken][merkleRoot]; emit Destroy(nft, baseToken, merkleRoot); }
function destroy(address nft, address baseToken, bytes32 merkleRoot) public { // check that a pair can only destroy itself require(msg.sender == pairs[nft][baseToken][merkleRoot], "Only pair can destroy itself"); // delete the pair delete pairs[nft][baseToken][merkleRoot]; emit Destroy(nft, baseToken, merkleRoot); }
3,747
166
// Accrue interest for `owner` and return the underlying balance.owner The address of the account to queryreturn The amount of underlying owned by `owner` /
function balanceOfUnderlying(address owner) external returns (uint256);
function balanceOfUnderlying(address owner) external returns (uint256);
52,356
150
// AMO Minter related
amo_minter_address = _amo_minter_address; amo_minter = IFraxAMOMinter(_amo_minter_address);
amo_minter_address = _amo_minter_address; amo_minter = IFraxAMOMinter(_amo_minter_address);
62,215
27
// Fire Transfer event for ERC-20 compliance. Adjust totalSupply.
Transfer(address(0), _accounts[i], _balances[i]); totalSupply = totalSupply.add(_balances[i]);
Transfer(address(0), _accounts[i], _balances[i]); totalSupply = totalSupply.add(_balances[i]);
31,925
216
// calculate asset profits of this amount
uint holderAssetProfit = ratio.mul(optionAmount) .div(1e12); // remember to div by 1e12 previous mul-ed return holderAssetProfit.mul(99).div(100);
uint holderAssetProfit = ratio.mul(optionAmount) .div(1e12); // remember to div by 1e12 previous mul-ed return holderAssetProfit.mul(99).div(100);
41,898
0
// `_token`:tokenId => token contract address`_token`:tokenId => token name`_storage`:tokenId => storage contract address IDs: 0 for ASTO, 1 for LP tokens, see `init()` below /
mapping(uint256 => IERC20) private _token; mapping(uint256 => string) private _tokenName; mapping(uint256 => StakingStorage) private _storage; mapping(uint256 => uint256) public totalStakedAmount; mapping(address => bool) public lbaMigrated; constructor( address controller, address signer, uint256 _lbaStakeTime
mapping(uint256 => IERC20) private _token; mapping(uint256 => string) private _tokenName; mapping(uint256 => StakingStorage) private _storage; mapping(uint256 => uint256) public totalStakedAmount; mapping(address => bool) public lbaMigrated; constructor( address controller, address signer, uint256 _lbaStakeTime
3,428
18
// VaultVesting A token holder contract that can release its token balance gradually like atypical vesting scheme, with a cliff and vesting period. Optionally revocable by theowner. /
contract VaultVesting is Ownable { using SafeMath for uint256; using SafeERC20 for ERC20; ERC20 public token; address public reserveWallet; uint[] public vestingPeriod; uint[] public vestingReleaseRatio; uint256 public currentDeposit; uint256 public limitTotalDeposit; event Released(address indexed beneficiary, uint256 amount); event Deposited(address indexed beneficiary, uint256 amount); mapping(address => uint256) public deposited; mapping(address => uint256) public released; /** * @param _token Token to store in vault * @param _limitTotalDeposit Number of token accept to store in vault * @param _vestingPeriod array of timestamp for each vesting period * @param _vestingReleaseRatio array of releasable percentage for each vesting period * @param _reserveWallet reserve address to transfer remaining token to */ function VaultVesting( ERC20 _token, uint256 _limitTotalDeposit, uint256[] _vestingPeriod, uint256[] _vestingReleaseRatio, address _reserveWallet ) public { require(_vestingPeriod.length > 0); require(_vestingPeriod.length == _vestingReleaseRatio.length); token = _token; reserveWallet = _reserveWallet; vestingPeriod = _vestingPeriod; vestingReleaseRatio = _vestingReleaseRatio; limitTotalDeposit = _limitTotalDeposit; } /** * @param beneficiary Beneficiary address * @param tokenAmount amount to deposit */ function deposit(address beneficiary, uint256 tokenAmount) onlyOwner public { uint256 newTotalDeposit = currentDeposit.add(tokenAmount); // Token must transfer to vault before setup deposit require(newTotalDeposit <= token.balanceOf(this)); require(newTotalDeposit <= limitTotalDeposit); currentDeposit = currentDeposit.add(tokenAmount); deposited[beneficiary] = deposited[beneficiary].add(tokenAmount); emit Deposited(beneficiary, tokenAmount); } /** * @param _beneficiaries Beneficiary address * @param _tokenAmounts amount to deposit */ function depositMany(address[] _beneficiaries, uint256[] _tokenAmounts) onlyOwner public { require(_beneficiaries.length == _tokenAmounts.length); for (uint256 i = 0; i < _beneficiaries.length; i++) { deposit(_beneficiaries[i], _tokenAmounts[i]); } } /** * @notice Proxy transfers vested tokens to beneficiary. */ function releaseFor(address beneficiary) public { uint256 unreleased = releasableAmount(beneficiary); require(unreleased > 0); released[beneficiary] = released[beneficiary].add(unreleased); token.safeTransfer(beneficiary, unreleased); emit Released(beneficiary, unreleased); } /** * @notice Transfers vested tokens to sender. */ function release() public { releaseFor(msg.sender); } /** * @dev Calculates the amount that has already vested but hasn't been released yet. * @param beneficiary address which is being vested */ function releasableAmount(address beneficiary) public view returns (uint256) { return vestedAmount(beneficiary).sub(released[beneficiary]); } /** * @dev Calculates the amount that has already vested. * @param beneficiary depositor address */ function vestedAmount(address beneficiary) public view returns (uint256) { uint256 depositedValue = deposited[beneficiary]; if (block.timestamp < vestingPeriod[0]) { // Not release before begining of first vested release return 0; } else if (block.timestamp > vestingPeriod[vestingPeriod.length-1]) { // Release all deposit at the end of vesting period return depositedValue; } else { for (uint i = vestingPeriod.length;i > 0;i--) { if (block.timestamp > vestingPeriod[i-1]) { return depositedValue.mul(vestingReleaseRatio[i-1]).div(100); } } } return 0; } /** * @dev Show remaining token in vault of beneficiary * @param beneficiary depositor address */ function getCurrentDeposit(address beneficiary) constant external returns (uint256) { return deposited[beneficiary].sub(released[beneficiary]); } /** * @dev Show total token in vault */ function getTotalDeposit() constant external returns (uint256) { return token.balanceOf(this); } /** * @dev Show maximum number allowed to deposit to vault */ function getVaultLimit() constant external returns (uint256) { return limitTotalDeposit; } /** * @dev Destroy vault and transfer all token to reserve wallet * TODO: Do we need this? */ function destroy() external onlyOwner { // Can destroy after vesting period require(block.timestamp > vestingPeriod[vestingPeriod.length-1]); // Transfer all remain token to wallet before destroy token.safeTransfer(reserveWallet, token.balanceOf(this)); selfdestruct(owner); } /** * @dev EmergencyDrain transfer all token to reserve wallet * @dev ETH balance is always expected to be 0. * but in case something went wrong, we use this function to extract the eth. * @dev Transfer any token that trafer to this address to reserve wallet * TODO: Do we need this? * @param anyToken Token address that want to drain to reserve wallet */ function emergencyDrain(ERC20 anyToken) external onlyOwner returns(bool) { require(now > vestingPeriod[vestingPeriod.length-1]); uint256 balance = address(this).balance; if (balance > 0) { reserveWallet.transfer(balance); } if (anyToken != address(0x0)) { assert(anyToken.transfer(reserveWallet, anyToken.balanceOf(this))); } return true; } }
contract VaultVesting is Ownable { using SafeMath for uint256; using SafeERC20 for ERC20; ERC20 public token; address public reserveWallet; uint[] public vestingPeriod; uint[] public vestingReleaseRatio; uint256 public currentDeposit; uint256 public limitTotalDeposit; event Released(address indexed beneficiary, uint256 amount); event Deposited(address indexed beneficiary, uint256 amount); mapping(address => uint256) public deposited; mapping(address => uint256) public released; /** * @param _token Token to store in vault * @param _limitTotalDeposit Number of token accept to store in vault * @param _vestingPeriod array of timestamp for each vesting period * @param _vestingReleaseRatio array of releasable percentage for each vesting period * @param _reserveWallet reserve address to transfer remaining token to */ function VaultVesting( ERC20 _token, uint256 _limitTotalDeposit, uint256[] _vestingPeriod, uint256[] _vestingReleaseRatio, address _reserveWallet ) public { require(_vestingPeriod.length > 0); require(_vestingPeriod.length == _vestingReleaseRatio.length); token = _token; reserveWallet = _reserveWallet; vestingPeriod = _vestingPeriod; vestingReleaseRatio = _vestingReleaseRatio; limitTotalDeposit = _limitTotalDeposit; } /** * @param beneficiary Beneficiary address * @param tokenAmount amount to deposit */ function deposit(address beneficiary, uint256 tokenAmount) onlyOwner public { uint256 newTotalDeposit = currentDeposit.add(tokenAmount); // Token must transfer to vault before setup deposit require(newTotalDeposit <= token.balanceOf(this)); require(newTotalDeposit <= limitTotalDeposit); currentDeposit = currentDeposit.add(tokenAmount); deposited[beneficiary] = deposited[beneficiary].add(tokenAmount); emit Deposited(beneficiary, tokenAmount); } /** * @param _beneficiaries Beneficiary address * @param _tokenAmounts amount to deposit */ function depositMany(address[] _beneficiaries, uint256[] _tokenAmounts) onlyOwner public { require(_beneficiaries.length == _tokenAmounts.length); for (uint256 i = 0; i < _beneficiaries.length; i++) { deposit(_beneficiaries[i], _tokenAmounts[i]); } } /** * @notice Proxy transfers vested tokens to beneficiary. */ function releaseFor(address beneficiary) public { uint256 unreleased = releasableAmount(beneficiary); require(unreleased > 0); released[beneficiary] = released[beneficiary].add(unreleased); token.safeTransfer(beneficiary, unreleased); emit Released(beneficiary, unreleased); } /** * @notice Transfers vested tokens to sender. */ function release() public { releaseFor(msg.sender); } /** * @dev Calculates the amount that has already vested but hasn't been released yet. * @param beneficiary address which is being vested */ function releasableAmount(address beneficiary) public view returns (uint256) { return vestedAmount(beneficiary).sub(released[beneficiary]); } /** * @dev Calculates the amount that has already vested. * @param beneficiary depositor address */ function vestedAmount(address beneficiary) public view returns (uint256) { uint256 depositedValue = deposited[beneficiary]; if (block.timestamp < vestingPeriod[0]) { // Not release before begining of first vested release return 0; } else if (block.timestamp > vestingPeriod[vestingPeriod.length-1]) { // Release all deposit at the end of vesting period return depositedValue; } else { for (uint i = vestingPeriod.length;i > 0;i--) { if (block.timestamp > vestingPeriod[i-1]) { return depositedValue.mul(vestingReleaseRatio[i-1]).div(100); } } } return 0; } /** * @dev Show remaining token in vault of beneficiary * @param beneficiary depositor address */ function getCurrentDeposit(address beneficiary) constant external returns (uint256) { return deposited[beneficiary].sub(released[beneficiary]); } /** * @dev Show total token in vault */ function getTotalDeposit() constant external returns (uint256) { return token.balanceOf(this); } /** * @dev Show maximum number allowed to deposit to vault */ function getVaultLimit() constant external returns (uint256) { return limitTotalDeposit; } /** * @dev Destroy vault and transfer all token to reserve wallet * TODO: Do we need this? */ function destroy() external onlyOwner { // Can destroy after vesting period require(block.timestamp > vestingPeriod[vestingPeriod.length-1]); // Transfer all remain token to wallet before destroy token.safeTransfer(reserveWallet, token.balanceOf(this)); selfdestruct(owner); } /** * @dev EmergencyDrain transfer all token to reserve wallet * @dev ETH balance is always expected to be 0. * but in case something went wrong, we use this function to extract the eth. * @dev Transfer any token that trafer to this address to reserve wallet * TODO: Do we need this? * @param anyToken Token address that want to drain to reserve wallet */ function emergencyDrain(ERC20 anyToken) external onlyOwner returns(bool) { require(now > vestingPeriod[vestingPeriod.length-1]); uint256 balance = address(this).balance; if (balance > 0) { reserveWallet.transfer(balance); } if (anyToken != address(0x0)) { assert(anyToken.transfer(reserveWallet, anyToken.balanceOf(this))); } return true; } }
2,075
21
// if market is not listed, cannot join move along
results[i] = uint(Error.MARKET_NOT_LISTED); continue;
results[i] = uint(Error.MARKET_NOT_LISTED); continue;
35,279
9
// DETAILS ⋯ If msg.sender has claimed a freeMint, then make sure he can mint 5
if (claimedMint[msg.sender] == true) { require (balanceOf(msg.sender) < nftPerAddressLimit + 1);
if (claimedMint[msg.sender] == true) { require (balanceOf(msg.sender) < nftPerAddressLimit + 1);
17,515
42
// startTime = 1518651000;new Date("Feb 14 2018 23:30:00 GMT").getTime() / 1000;
startTime = now; // for testing we use now endTime = startTime + 75 days; // ICO end on Apr 30 2018 00:00:00 GMT
startTime = now; // for testing we use now endTime = startTime + 75 days; // ICO end on Apr 30 2018 00:00:00 GMT
4,637
96
// move address in last position to deleted contributor's spot
if (lastCIndex > 0) { tokenIndexToGroup[_tokenId].addressToContributorArrIndex[group.contributorArr[lastCIndex]] = cIndex; tokenIndexToGroup[_tokenId].contributorArr[cIndex] = group.contributorArr[lastCIndex]; }
if (lastCIndex > 0) { tokenIndexToGroup[_tokenId].addressToContributorArrIndex[group.contributorArr[lastCIndex]] = cIndex; tokenIndexToGroup[_tokenId].contributorArr[cIndex] = group.contributorArr[lastCIndex]; }
29,823
282
// Load the quantity filled so far for a partially filled orders Invalidating an order nonce will not clear partial fill quantities for earlier orders becausethe gas cost would potentially be unboundorderHash The order hash as originally signed by placing wallet that uniquely identifies an order return For partially filled orders, the amount filled so far in pips. For orders in all other states, 0 /
function loadPartiallyFilledOrderQuantityInPips(bytes32 orderHash) external view returns (uint64)
function loadPartiallyFilledOrderQuantityInPips(bytes32 orderHash) external view returns (uint64)
5,307
100
// setup the staking round
function setRewardRound(uint round, uint reward, uint start, uint end) external onlyOwner
function setRewardRound(uint round, uint reward, uint start, uint end) external onlyOwner
14,087
24
// The initial values allowed per day are copied from this array
uint256[6] public limitPerDay;
uint256[6] public limitPerDay;
47,658
1,121
// https:etherscan.io/address/0xEF285D339c91aDf1dD7DE0aEAa6250805FD68258;
Synth existingSynth = Synth(0xEF285D339c91aDf1dD7DE0aEAa6250805FD68258);
Synth existingSynth = Synth(0xEF285D339c91aDf1dD7DE0aEAa6250805FD68258);
81,508
137
// Withdraw a quantity of bAsset from the cache. _receiver Address to which the bAsset should be sent _bAsset Address of the bAsset _amount Units of bAsset to withdraw /
function withdrawRaw( address _receiver, address _bAsset, uint256 _amount
function withdrawRaw( address _receiver, address _bAsset, uint256 _amount
75,645
2
// From /common/ModuleManager.sol
mapping(address => address) internal modules;
mapping(address => address) internal modules;
15,462
10
// Owner manager is responsible for setting/updating an "owner" fieldRole ROLE_OWNER_MANAGER allows updating the "owner" field (executing `setOwner` function) /
uint32 public constant ROLE_OWNER_MANAGER = 0x0040_0000;
uint32 public constant ROLE_OWNER_MANAGER = 0x0040_0000;
42,678
217
// Move assets from one Strategy to another _strategyFromAddress Address of Strategy to move assets from. _strategyToAddress Address of Strategy to move assets to. _assets Array of asset address that will be moved _amounts Array of amounts of each corresponding asset to move. /
function reallocate( address _strategyFromAddress, address _strategyToAddress, address[] calldata _assets, uint256[] calldata _amounts
function reallocate( address _strategyFromAddress, address _strategyToAddress, address[] calldata _assets, uint256[] calldata _amounts
5,248
4
// ensure handle is valid and available
bytes16 handleLower = toLower(_handle); require(handleIsTaken(handleLower) == false, "Handle is already taken"); uint userId = UserStorageInterface( registry.getContract(userStorageRegistryKey) ).addUser(_owner, _handle, handleLower); emit AddUser(userId, _handle, _owner); return userId;
bytes16 handleLower = toLower(_handle); require(handleIsTaken(handleLower) == false, "Handle is already taken"); uint userId = UserStorageInterface( registry.getContract(userStorageRegistryKey) ).addUser(_owner, _handle, handleLower); emit AddUser(userId, _handle, _owner); return userId;
505
117
// subtract existing balance from boostedSupply
boostedTotalSupply = boostedTotalSupply.sub(boostedBalances[user]);
boostedTotalSupply = boostedTotalSupply.sub(boostedBalances[user]);
50,872
10
// Number of frames available to purchase
(frames, ethToTransfer) = crowdsaleContract.calculateFrames(ethAmount);
(frames, ethToTransfer) = crowdsaleContract.calculateFrames(ethAmount);
14,640
1
// is everything ok?
require(campaign.deadline < block.timestamp,"The deadline should be a date in the future."); campaign.owner = _owner; campaign.title = _title; campaign.description = _description; campaign.target = _target; campaign.deadline = _deadline; campaign.amountCollected = 0; campaign.image = _image;
require(campaign.deadline < block.timestamp,"The deadline should be a date in the future."); campaign.owner = _owner; campaign.title = _title; campaign.description = _description; campaign.target = _target; campaign.deadline = _deadline; campaign.amountCollected = 0; campaign.image = _image;
17,763
42
// revert if _engine doesn't have access to mint or the tokenId is invalid. _tokenId tokenId _engine address intending to mint / burn /
function checkEngineAccessAndTokenId(uint256 _tokenId, address _engine) external view { // check tokenId _isValidTokenIdToMint(_tokenId); // check engine access uint8 engineId = _tokenId.parseEngineId(); if (_engine != engines[engineId]) revert PM_Not_Authorized_Engine(); }
function checkEngineAccessAndTokenId(uint256 _tokenId, address _engine) external view { // check tokenId _isValidTokenIdToMint(_tokenId); // check engine access uint8 engineId = _tokenId.parseEngineId(); if (_engine != engines[engineId]) revert PM_Not_Authorized_Engine(); }
31,400
65
// Store the function selector of `ApproveFailed()`.
mstore(0x00, 0x3e3f8f73)
mstore(0x00, 0x3e3f8f73)
24,382
175
// is the customer in the ambassador list?
hasRole(AMBASSADOR_ROLE, msg.sender) &&
hasRole(AMBASSADOR_ROLE, msg.sender) &&
73,818
56
// save a backup of the current contract-registry before replacing it
prevRegistry = registry;
prevRegistry = registry;
20,305
128
// return ERC20 address from Uniswap exchange address_exchange address of uniswap exchane/
function getTokenByUniswapExchange(address _exchange) external view returns(address)
function getTokenByUniswapExchange(address _exchange) external view returns(address)
12,243
38
// Unpause the major functions
function unpause() external onlyRole(ROLE_MANAGER) { _unpause(); }
function unpause() external onlyRole(ROLE_MANAGER) { _unpause(); }
35,474
14
// Consume one quota for transaction sending
if (quota > 1) { quota -= 1; } else {
if (quota > 1) { quota -= 1; } else {
35,157
43
// Returns whether `tokenId` exists. /
function _exists(uint256 tokenId) internal view virtual returns (bool) { return tokenId < _owners.length; }
function _exists(uint256 tokenId) internal view virtual returns (bool) { return tokenId < _owners.length; }
2,992
15
// Removes an address from the access list _user The address to remove /
function removeAccess(address _user) external onlyOwner()
function removeAccess(address _user) external onlyOwner()
14,872
15
// check minimum timestamp
if(currentUser.timestamp < _minTimestamp) { return false; }
if(currentUser.timestamp < _minTimestamp) { return false; }
20,824
16
// Return e ^ (x / FIXED_1)FIXED_1 Input range: 0 <= x <= OPT_EXP_MAX_VAL - 1 Auto-generated via 'PrintFunctionOptimalExp.py' /
function optimalExp(uint256 x) internal pure returns (uint256) { uint256 res = 0; uint256 y; uint256 z; z = y = x % 0x10000000000000000000000000000000; z = z * y / FIXED_1; res += z * 0x10e1b3be415a0000; // add y^02 * (20! / 02!) z = z * y / FIXED_1; res += z * 0x05a0913f6b1e0000; // add y^03 * (20! / 03!) z = z * y / FIXED_1; res += z * 0x0168244fdac78000; // add y^04 * (20! / 04!) z = z * y / FIXED_1; res += z * 0x004807432bc18000; // add y^05 * (20! / 05!) z = z * y / FIXED_1; res += z * 0x000c0135dca04000; // add y^06 * (20! / 06!) z = z * y / FIXED_1; res += z * 0x0001b707b1cdc000; // add y^07 * (20! / 07!) z = z * y / FIXED_1; res += z * 0x000036e0f639b800; // add y^08 * (20! / 08!) z = z * y / FIXED_1; res += z * 0x00000618fee9f800; // add y^09 * (20! / 09!) z = z * y / FIXED_1; res += z * 0x0000009c197dcc00; // add y^10 * (20! / 10!) z = z * y / FIXED_1; res += z * 0x0000000e30dce400; // add y^11 * (20! / 11!) z = z * y / FIXED_1; res += z * 0x000000012ebd1300; // add y^12 * (20! / 12!) z = z * y / FIXED_1; res += z * 0x0000000017499f00; // add y^13 * (20! / 13!) z = z * y / FIXED_1; res += z * 0x0000000001a9d480; // add y^14 * (20! / 14!) z = z * y / FIXED_1; res += z * 0x00000000001c6380; // add y^15 * (20! / 15!) z = z * y / FIXED_1; res += z * 0x000000000001c638; // add y^16 * (20! / 16!) z = z * y / FIXED_1; res += z * 0x0000000000001ab8; // add y^17 * (20! / 17!) z = z * y / FIXED_1; res += z * 0x000000000000017c; // add y^18 * (20! / 18!) z = z * y / FIXED_1; res += z * 0x0000000000000014; // add y^19 * (20! / 19!) z = z * y / FIXED_1; res += z * 0x0000000000000001; // add y^20 * (20! / 20!) res = res / 0x21c3677c82b40000 + y + FIXED_1; // divide by 20! and then add y^1 / 1! + y^0 / 0! if ((x & 0x010000000000000000000000000000000) != 0) { res = res * 0x1c3d6a24ed82218787d624d3e5eba95f9 / 0x18ebef9eac820ae8682b9793ac6d1e776; } if ((x & 0x020000000000000000000000000000000) != 0) { res = res * 0x18ebef9eac820ae8682b9793ac6d1e778 / 0x1368b2fc6f9609fe7aceb46aa619baed4; } if ((x & 0x040000000000000000000000000000000) != 0) { res = res * 0x1368b2fc6f9609fe7aceb46aa619baed5 / 0x0bc5ab1b16779be3575bd8f0520a9f21f; } if ((x & 0x080000000000000000000000000000000) != 0) { res = res * 0x0bc5ab1b16779be3575bd8f0520a9f21e / 0x0454aaa8efe072e7f6ddbab84b40a55c9; } if ((x & 0x100000000000000000000000000000000) != 0) { res = res * 0x0454aaa8efe072e7f6ddbab84b40a55c5 / 0x00960aadc109e7a3bf4578099615711ea; } if ((x & 0x200000000000000000000000000000000) != 0) { res = res * 0x00960aadc109e7a3bf4578099615711d7 / 0x0002bf84208204f5977f9a8cf01fdce3d; } if ((x & 0x400000000000000000000000000000000) != 0) { res = res * 0x0002bf84208204f5977f9a8cf01fdc307 / 0x0000003c6ab775dd0b95b4cbee7e65d11; } return res; }
function optimalExp(uint256 x) internal pure returns (uint256) { uint256 res = 0; uint256 y; uint256 z; z = y = x % 0x10000000000000000000000000000000; z = z * y / FIXED_1; res += z * 0x10e1b3be415a0000; // add y^02 * (20! / 02!) z = z * y / FIXED_1; res += z * 0x05a0913f6b1e0000; // add y^03 * (20! / 03!) z = z * y / FIXED_1; res += z * 0x0168244fdac78000; // add y^04 * (20! / 04!) z = z * y / FIXED_1; res += z * 0x004807432bc18000; // add y^05 * (20! / 05!) z = z * y / FIXED_1; res += z * 0x000c0135dca04000; // add y^06 * (20! / 06!) z = z * y / FIXED_1; res += z * 0x0001b707b1cdc000; // add y^07 * (20! / 07!) z = z * y / FIXED_1; res += z * 0x000036e0f639b800; // add y^08 * (20! / 08!) z = z * y / FIXED_1; res += z * 0x00000618fee9f800; // add y^09 * (20! / 09!) z = z * y / FIXED_1; res += z * 0x0000009c197dcc00; // add y^10 * (20! / 10!) z = z * y / FIXED_1; res += z * 0x0000000e30dce400; // add y^11 * (20! / 11!) z = z * y / FIXED_1; res += z * 0x000000012ebd1300; // add y^12 * (20! / 12!) z = z * y / FIXED_1; res += z * 0x0000000017499f00; // add y^13 * (20! / 13!) z = z * y / FIXED_1; res += z * 0x0000000001a9d480; // add y^14 * (20! / 14!) z = z * y / FIXED_1; res += z * 0x00000000001c6380; // add y^15 * (20! / 15!) z = z * y / FIXED_1; res += z * 0x000000000001c638; // add y^16 * (20! / 16!) z = z * y / FIXED_1; res += z * 0x0000000000001ab8; // add y^17 * (20! / 17!) z = z * y / FIXED_1; res += z * 0x000000000000017c; // add y^18 * (20! / 18!) z = z * y / FIXED_1; res += z * 0x0000000000000014; // add y^19 * (20! / 19!) z = z * y / FIXED_1; res += z * 0x0000000000000001; // add y^20 * (20! / 20!) res = res / 0x21c3677c82b40000 + y + FIXED_1; // divide by 20! and then add y^1 / 1! + y^0 / 0! if ((x & 0x010000000000000000000000000000000) != 0) { res = res * 0x1c3d6a24ed82218787d624d3e5eba95f9 / 0x18ebef9eac820ae8682b9793ac6d1e776; } if ((x & 0x020000000000000000000000000000000) != 0) { res = res * 0x18ebef9eac820ae8682b9793ac6d1e778 / 0x1368b2fc6f9609fe7aceb46aa619baed4; } if ((x & 0x040000000000000000000000000000000) != 0) { res = res * 0x1368b2fc6f9609fe7aceb46aa619baed5 / 0x0bc5ab1b16779be3575bd8f0520a9f21f; } if ((x & 0x080000000000000000000000000000000) != 0) { res = res * 0x0bc5ab1b16779be3575bd8f0520a9f21e / 0x0454aaa8efe072e7f6ddbab84b40a55c9; } if ((x & 0x100000000000000000000000000000000) != 0) { res = res * 0x0454aaa8efe072e7f6ddbab84b40a55c5 / 0x00960aadc109e7a3bf4578099615711ea; } if ((x & 0x200000000000000000000000000000000) != 0) { res = res * 0x00960aadc109e7a3bf4578099615711d7 / 0x0002bf84208204f5977f9a8cf01fdce3d; } if ((x & 0x400000000000000000000000000000000) != 0) { res = res * 0x0002bf84208204f5977f9a8cf01fdc307 / 0x0000003c6ab775dd0b95b4cbee7e65d11; } return res; }
39,146
32
// Replace Gitcoin feed key on MANAUSD Oracle
address[] memory drops = new address[](1); drops[0] = GITCOIN_FEED_OLD; MedianAbstract(MEDIAN_MANAUSD).drop(drops); address[] memory lifts = new address[](1); lifts[0] = GITCOIN_FEED_NEW; MedianAbstract(MEDIAN_MANAUSD).lift(lifts);
address[] memory drops = new address[](1); drops[0] = GITCOIN_FEED_OLD; MedianAbstract(MEDIAN_MANAUSD).drop(drops); address[] memory lifts = new address[](1); lifts[0] = GITCOIN_FEED_NEW; MedianAbstract(MEDIAN_MANAUSD).lift(lifts);
38,182
36
// function update from initial Smart contract
function claim() external returns (bool) { require(_claimUnlocked(), "claiming not allowed yet"); if (!_initialClaimDone[msg.sender]) { require(claimable[msg.sender] > 0, "nothing to claim"); } else { require( (_firstVestingAmount[msg.sender] > 0 && block.timestamp >= firstVestingUnlockTimestamp) || (_secondVestingAmount[msg.sender] > 0 && block.timestamp >= secondVestingUnlockTimestamp), // || // (_thirdVestingAmount[msg.sender] > 0 && // block.timestamp >= thirdVestingUnlockTimestamp) // , "nothing to claim for the moment" ); } uint256 amount; if (!_initialClaimDone[msg.sender]) { _initialClaimDone[msg.sender] = true; uint256 _toClaim = claimable[msg.sender].mul(multiplier); claimable[msg.sender] = 0; amount = _toClaim.mul(3000).div(10000); _toClaim = _toClaim.sub(amount); _firstVestingAmount[msg.sender] = _toClaim.div(2); _secondVestingAmount[msg.sender] = _toClaim.div(2); //_thirdVestingAmount[msg.sender] = _toClaim.div(4); } else if ( _firstVestingAmount[msg.sender] > 0 && block.timestamp >= firstVestingUnlockTimestamp ) { amount = _firstVestingAmount[msg.sender]; _firstVestingAmount[msg.sender] = 0; } else if ( _secondVestingAmount[msg.sender] > 0 && block.timestamp >= secondVestingUnlockTimestamp ) { amount = _secondVestingAmount[msg.sender]; _secondVestingAmount[msg.sender] = 0; } // else if ( // _thirdVestingAmount[msg.sender] > 0 && // block.timestamp >= thirdVestingUnlockTimestamp // ) { // amount = _thirdVestingAmount[msg.sender]; // _thirdVestingAmount[msg.sender] = 0; // } claimed[msg.sender] = claimed[msg.sender].add(amount); totalOwed = totalOwed.sub(amount); return token.transfer(msg.sender, amount); }
function claim() external returns (bool) { require(_claimUnlocked(), "claiming not allowed yet"); if (!_initialClaimDone[msg.sender]) { require(claimable[msg.sender] > 0, "nothing to claim"); } else { require( (_firstVestingAmount[msg.sender] > 0 && block.timestamp >= firstVestingUnlockTimestamp) || (_secondVestingAmount[msg.sender] > 0 && block.timestamp >= secondVestingUnlockTimestamp), // || // (_thirdVestingAmount[msg.sender] > 0 && // block.timestamp >= thirdVestingUnlockTimestamp) // , "nothing to claim for the moment" ); } uint256 amount; if (!_initialClaimDone[msg.sender]) { _initialClaimDone[msg.sender] = true; uint256 _toClaim = claimable[msg.sender].mul(multiplier); claimable[msg.sender] = 0; amount = _toClaim.mul(3000).div(10000); _toClaim = _toClaim.sub(amount); _firstVestingAmount[msg.sender] = _toClaim.div(2); _secondVestingAmount[msg.sender] = _toClaim.div(2); //_thirdVestingAmount[msg.sender] = _toClaim.div(4); } else if ( _firstVestingAmount[msg.sender] > 0 && block.timestamp >= firstVestingUnlockTimestamp ) { amount = _firstVestingAmount[msg.sender]; _firstVestingAmount[msg.sender] = 0; } else if ( _secondVestingAmount[msg.sender] > 0 && block.timestamp >= secondVestingUnlockTimestamp ) { amount = _secondVestingAmount[msg.sender]; _secondVestingAmount[msg.sender] = 0; } // else if ( // _thirdVestingAmount[msg.sender] > 0 && // block.timestamp >= thirdVestingUnlockTimestamp // ) { // amount = _thirdVestingAmount[msg.sender]; // _thirdVestingAmount[msg.sender] = 0; // } claimed[msg.sender] = claimed[msg.sender].add(amount); totalOwed = totalOwed.sub(amount); return token.transfer(msg.sender, amount); }
73,890
237
// We still alow anyone to withdraw these funds for the account owner
function withdrawFromMerkleTree( ExchangeData.State storage S, ExchangeData.MerkleProof calldata merkleProof ) public
function withdrawFromMerkleTree( ExchangeData.State storage S, ExchangeData.MerkleProof calldata merkleProof ) public
57,532
107
// enable/disable transfer
function enableTransfer(bool state) public onlyOwner { isTransferable = state; }
function enableTransfer(bool state) public onlyOwner { isTransferable = state; }
22,046
18
// determine if addr has roleaddr addressroleName the name of the role return bool/
function hasRole(RolesManager storage rolesManager, address addr, string memory roleName) internal view returns (bool)
function hasRole(RolesManager storage rolesManager, address addr, string memory roleName) internal view returns (bool)
56,375
84
// 既に承認済みの場合はエラーを返す
require(!hasConfirmed(type_, confirmer, proposalId));
require(!hasConfirmed(type_, confirmer, proposalId));
76,188
92
// Change the name and symbol of the token /
function setTokenDetails(string memory _name, string memory _symbol, bool _stakeOpen, uint256 _stakeDuration) public onlyOwner { name = _name; symbol = _symbol; stakeOpen = _stakeOpen; stakeDuration = _stakeDuration; }
function setTokenDetails(string memory _name, string memory _symbol, bool _stakeOpen, uint256 _stakeDuration) public onlyOwner { name = _name; symbol = _symbol; stakeOpen = _stakeOpen; stakeDuration = _stakeDuration; }
68,895
30
// Encode token address with chainId /
function _encodeTokenWithChainId(address _token, uint256 _chainId) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_token, _chainId)); }
function _encodeTokenWithChainId(address _token, uint256 _chainId) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_token, _chainId)); }
25,265
8
// withdraw address
address payable immutable public withdrawAddress;
address payable immutable public withdrawAddress;
41,135
8
// Require a valid location
require(bytes(_location).length > 0);
require(bytes(_location).length > 0);
41,176
27
// Make some basic checks before attempting to liquidate an account. - Require that the msg.sender has the permission to use the liquidator account - Require that the liquid account is liquidatable based on the accounts global value (all assets held and owed, not just what's being liquidated) /
function checkRequirements( Constants memory constants, uint256 heldMarket, uint256 owedMarket, address[] memory tokenPath ) private view
function checkRequirements( Constants memory constants, uint256 heldMarket, uint256 owedMarket, address[] memory tokenPath ) private view
50,848
34
// internally returns the number of mints of an address
function _mintOf(address _owner) internal view returns (uint256) { return _numberMinted(_owner); }
function _mintOf(address _owner) internal view returns (uint256) { return _numberMinted(_owner); }
53,476
5
// Reverts if non-permissed account calls./ Permissioned accounts are: owner, pool manager, and account manager
modifier onlyPermissioned() { require( msg.sender == owner() || msg.sender == addressRegistry.poolManagerAddress() || msg.sender == addressRegistry.lpSafeAddress(), "PERMISSIONED_ONLY" ); _; }
modifier onlyPermissioned() { require( msg.sender == owner() || msg.sender == addressRegistry.poolManagerAddress() || msg.sender == addressRegistry.lpSafeAddress(), "PERMISSIONED_ONLY" ); _; }
35,227