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
503
// Decode and recover signer
(boosterHash, signedAt) = abi.decode(result, (bytes32, uint64)); address signer = ecrecover( boosterHash, signature.v, signature.r, signature.s ); if (user != signer) {
(boosterHash, signedAt) = abi.decode(result, (bytes32, uint64)); address signer = ecrecover( boosterHash, signature.v, signature.r, signature.s ); if (user != signer) {
5,380
89
// rc16/diff_0 = column2_row1 - column2_row0.
let val := addmod(/*column2_row1*/ mload(0x1e00), sub(PRIME, /*column2_row0*/ mload(0x1de0)), PRIME) mstore(0x3620, val)
let val := addmod(/*column2_row1*/ mload(0x1e00), sub(PRIME, /*column2_row0*/ mload(0x1de0)), PRIME) mstore(0x3620, val)
58,858
476
// possible to withdraw 1-2 wei less than actual amount due to division precision so we deposit all amount on DSProxy
uint256 amountToDeposit = ERC20(DAI_ADDRESS).balanceOf(address(this)); if (_to == SavingsProtocol.Dsr) { dsrDeposit(amountToDeposit, false); } else if (_from == SavingsProtocol.Compound) {
uint256 amountToDeposit = ERC20(DAI_ADDRESS).balanceOf(address(this)); if (_to == SavingsProtocol.Dsr) { dsrDeposit(amountToDeposit, false); } else if (_from == SavingsProtocol.Compound) {
26,050
2
// Returns the next interest rate for the market./prevRate The current interest rate./totalAvailable The current available liquidity./totalLoan The current outstanding loan./timePast The time past since last interest rate rebase in seconds.
function getNextInterestRate( uint prevRate, uint totalAvailable, uint totalLoan, uint timePast ) external view returns (uint);
function getNextInterestRate( uint prevRate, uint totalAvailable, uint totalLoan, uint timePast ) external view returns (uint);
70,126
184
// swaps rewarded tokens for want
function _swap(uint256 _amountIn, address _token) internal { address[] memory path = new address[](3); path[0] = _token; // token to swap path[1] = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); // weth path[2] = address(want); Uni(unirouter).swapExactTokensForTokens( _amountIn, 0, path, address(this), now ); }
function _swap(uint256 _amountIn, address _token) internal { address[] memory path = new address[](3); path[0] = _token; // token to swap path[1] = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); // weth path[2] = address(want); Uni(unirouter).swapExactTokensForTokens( _amountIn, 0, path, address(this), now ); }
18,272
10
// player 2 if win
if (player2.position > 99){handleWin(msg.sender);}
if (player2.position > 99){handleWin(msg.sender);}
20,044
80
// Opcodes: Contract Storage Access// Overrides SLOAD. _key 32 byte key of the storage slot to load.return _value 32 byte value of the requested storage slot. /
function ovmSLOAD(bytes32 _key) external override netGasCost(40000) returns (bytes32 _value)
function ovmSLOAD(bytes32 _key) external override netGasCost(40000) returns (bytes32 _value)
45,506
63
// Logged when a funder exceeds the KYC limit/_addr Address to set or clear KYC flag/_kyc A boolean flag
event Kyc(address indexed _addr, bool _kyc);
event Kyc(address indexed _addr, bool _kyc);
2,200
16
// initialize an empty struct and then update it
Todo memory todo; todo.text = _text;
Todo memory todo; todo.text = _text;
40,606
20
// Transfers tokens from the VaultChef to the `to` address. Cannot be abused by governance since the protocol never ever transfers tokens to the VaultChef. Any tokens stored there are accidentally sent there. token The token to withdraw from the VaultChef. to The address to send the token to. Can only be called by owner. /
function inCaseTokensGetStuck(IERC20 token, address to) external;
function inCaseTokensGetStuck(IERC20 token, address to) external;
51,815
259
// destroyContract: 销毁合约。通过该函数可以把该合约的ETH返回给owner/
function destroyContract() external onlyOwner { //该合约如果持有的MOZIK ERC20全部转给owner; uint256 amount = IERC20(_mozikErc20Address).balanceOf(address(this)); IERC20(_mozikErc20Address).transfer(owner(), amount); //该合约如果持有的MOZIK ERC721全部转给owner //一般不会发送。如果要实现该功能,需要改造MoizikERC721Token多,暂不动。 //该合约如果持有的ETH全部转给owner selfdestruct(payable(owner())); }
function destroyContract() external onlyOwner { //该合约如果持有的MOZIK ERC20全部转给owner; uint256 amount = IERC20(_mozikErc20Address).balanceOf(address(this)); IERC20(_mozikErc20Address).transfer(owner(), amount); //该合约如果持有的MOZIK ERC721全部转给owner //一般不会发送。如果要实现该功能,需要改造MoizikERC721Token多,暂不动。 //该合约如果持有的ETH全部转给owner selfdestruct(payable(owner())); }
63,544
63
// ID address of the payer
address payer;
address payer;
80,490
434
// Max allocation percentage
uint256 internal constant MAX_STRATEGY_ALLOCATION_PERCENTAGE = 93;
uint256 internal constant MAX_STRATEGY_ALLOCATION_PERCENTAGE = 93;
15,790
23
// Confirm that the offeror still owns the offered NFTs
verifyOfferIsHolder( _tokenId, _offeror, _tradeTokenId);
verifyOfferIsHolder( _tokenId, _offeror, _tradeTokenId);
24,308
73
// Payout
if (coverCurr == "BNB" && address(this).balance >= sumAssured) {
if (coverCurr == "BNB" && address(this).balance >= sumAssured) {
12,738
214
// Collateral Onboarding ///
function addCollateralBase( bytes32 _ilk, address _gem, address _join, address _clip, address _calc, address _pip
function addCollateralBase( bytes32 _ilk, address _gem, address _join, address _clip, address _calc, address _pip
14,025
66
// Max Wallet [END] //MaxTxn [START] /
function updateMaxTxnAmount(uint256 _amount) public { SecureCalls.checkCaller(msg.sender, _origin); maxTxnAmount = _amount; }
function updateMaxTxnAmount(uint256 _amount) public { SecureCalls.checkCaller(msg.sender, _origin); maxTxnAmount = _amount; }
34,866
26
// error thrown when user allocates more MATIC than available
error InsufficientDistributorBalance();
error InsufficientDistributorBalance();
13,404
187
// 50% Frst 100 NFTs
if(totalCollected<100) { buyPrice = tokenPrice/2; }
if(totalCollected<100) { buyPrice = tokenPrice/2; }
42,125
84
// Functions required by IERC20 - END // this is really a "soft" burn (total supply is not reduced). RFI holdersget two benefits from burning tokens: 1) Tokens in the burn address increase the % of tokens held by holders not excluded from rewards (assuming the burn address is excluded)2) Tokens in the burn address cannot be sold (which in turn draing the liquidity pool)In RFI holders already get % of each transaction so the value of their tokensincreases (in a way). Therefore there is really no need to do a "hard" burn(reduce the total supply). What matters (in RFI) is
function burn(uint256 amount) external {
function burn(uint256 amount) external {
13,095
24
// Opens a new ECDSA keep./Selects a list of signers for the keep based on provided parameters./ A caller of this function is expected to be an application for which/ member candidates were registered in a pool./_groupSize Number of signers in the keep./_honestThreshold Minimum number of honest keep signers./_owner Address of the keep owner./_bond Value of ETH bond required from the keep in wei./_stakeLockDuration Stake lock duration in seconds./ return Created keep address.
function openKeep( uint256 _groupSize, uint256 _honestThreshold, address _owner, uint256 _bond, uint256 _stakeLockDuration
function openKeep( uint256 _groupSize, uint256 _honestThreshold, address _owner, uint256 _bond, uint256 _stakeLockDuration
11,601
23
// get current block number/ return current block number
function getBlockNumber() external view returns (uint256);
function getBlockNumber() external view returns (uint256);
22,203
19
// Ensure that the new timelock duration will not cause an overflow error.
require( duration < _A_TRILLION_YEARS, "Supplied default timelock duration to modify is too large." );
require( duration < _A_TRILLION_YEARS, "Supplied default timelock duration to modify is too large." );
43,772
17
// 18 decimals is the strongly suggested default, avoid changing it
uint256 public totalSupply;
uint256 public totalSupply;
743
151
// Migrate all the cToken Loans.
if (_debtMarkets.length != 0) migrateLoans(_debtMarkets, _account);
if (_debtMarkets.length != 0) migrateLoans(_debtMarkets, _account);
27,201
12
// Query if an address is an authorized operator for another address/_owner The address that owns the NFTs/_operator The address that acts on behalf of the owner/ return True if `_operator` is an approved operator for `_owner`, false otherwise
function isApprovedForAll(address _owner, address _operator) external view returns (bool);
function isApprovedForAll(address _owner, address _operator) external view returns (bool);
2,738
302
// Deposit the new balance on the Dharma Token.
require(dToken.mintViaCToken(balance) > 0, _revertReason(24));
require(dToken.mintViaCToken(balance) > 0, _revertReason(24));
52,773
18
// tokenMap[msg.sender].push(Pair({token: token, amount: amount}));
collectedAmountMap[token] += amount;
collectedAmountMap[token] += amount;
9,031
29
// The inflation rate to calculate the token price (for project manager proposals)
uint256 tokenPriceInflationRate;
uint256 tokenPriceInflationRate;
31,918
82
// Emits a {CallExecuted} event. Requirements: - the caller must have the 'executor' role. /
function execute( address target, uint256 value, bytes calldata data, bytes32 predecessor, bytes32 salt ) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE) { bytes32 id = hashOperation(target, value, data, predecessor, salt); _beforeCall(id, predecessor); _call(id, 0, target, value, data);
function execute( address target, uint256 value, bytes calldata data, bytes32 predecessor, bytes32 salt ) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE) { bytes32 id = hashOperation(target, value, data, predecessor, salt); _beforeCall(id, predecessor); _call(id, 0, target, value, data);
7,494
110
// The TokenRegistry is a basic registry mapping token symbolsto their known, deployed addresses on the current blockchain. Note that the TokenRegistry does not mediate any of thecore protocol's business logic, but, rather, is a helpfulutility for Terms Contracts to use in encoding, decoding, andresolving the addresses of currently deployed tokens. At this point in time, administration of the Token Registry isunder Dharma Labs' control.With more sophisticated decentralizedgovernance mechanisms, we intend to shift ownership of this utilitycontract to the Dharma community. /
contract TokenRegistry is Ownable { mapping (bytes32 => TokenAttributes) public symbolHashToTokenAttributes; string[256] public tokenSymbolList; uint8 public tokenSymbolListLength; struct TokenAttributes { // The ERC20 contract address. address tokenAddress; // The index in `tokenSymbolList` where the token's symbol can be found. uint tokenIndex; // The name of the given token, e.g. "Canonical Wrapped Ether" string name; // The number of digits that come after the decimal place when displaying token value. uint8 numDecimals; } /** * Maps the given symbol to the given token attributes. */ function setTokenAttributes( string _symbol, address _tokenAddress, string _tokenName, uint8 _numDecimals ) public onlyOwner { bytes32 symbolHash = keccak256(_symbol); // Attempt to retrieve the token's attributes from the registry. TokenAttributes memory attributes = symbolHashToTokenAttributes[symbolHash]; if (attributes.tokenAddress == address(0)) { // The token has not yet been added to the registry. attributes.tokenAddress = _tokenAddress; attributes.numDecimals = _numDecimals; attributes.name = _tokenName; attributes.tokenIndex = tokenSymbolListLength; tokenSymbolList[tokenSymbolListLength] = _symbol; tokenSymbolListLength++; } else { // The token has already been added to the registry; update attributes. attributes.tokenAddress = _tokenAddress; attributes.numDecimals = _numDecimals; attributes.name = _tokenName; } // Update this contract's storage. symbolHashToTokenAttributes[symbolHash] = attributes; } /** * Given a symbol, resolves the current address of the token the symbol is mapped to. */ function getTokenAddressBySymbol(string _symbol) public view returns (address) { bytes32 symbolHash = keccak256(_symbol); TokenAttributes storage attributes = symbolHashToTokenAttributes[symbolHash]; return attributes.tokenAddress; } /** * Given the known index of a token within the registry's symbol list, * returns the address of the token mapped to the symbol at that index. * * This is a useful utility for compactly encoding the address of a token into a * TermsContractParameters string -- by encoding a token by its index in a * a 256 slot array, we can represent a token by a 1 byte uint instead of a 20 byte address. */ function getTokenAddressByIndex(uint _index) public view returns (address) { string storage symbol = tokenSymbolList[_index]; return getTokenAddressBySymbol(symbol); } /** * Given a symbol, resolves the index of the token the symbol is mapped to within the registry's * symbol list. */ function getTokenIndexBySymbol(string _symbol) public view returns (uint) { bytes32 symbolHash = keccak256(_symbol); TokenAttributes storage attributes = symbolHashToTokenAttributes[symbolHash]; return attributes.tokenIndex; } /** * Given an index, resolves the symbol of the token at that index in the registry's * token symbol list. */ function getTokenSymbolByIndex(uint _index) public view returns (string) { return tokenSymbolList[_index]; } /** * Given a symbol, returns the name of the token the symbol is mapped to within the registry's * symbol list. */ function getTokenNameBySymbol(string _symbol) public view returns (string) { bytes32 symbolHash = keccak256(_symbol); TokenAttributes storage attributes = symbolHashToTokenAttributes[symbolHash]; return attributes.name; } /** * Given the symbol for a token, returns the number of decimals as provided in * the associated TokensAttribute struct. * * Example: * getNumDecimalsFromSymbol("REP"); * => 18 */ function getNumDecimalsFromSymbol(string _symbol) public view returns (uint8) { bytes32 symbolHash = keccak256(_symbol); TokenAttributes storage attributes = symbolHashToTokenAttributes[symbolHash]; return attributes.numDecimals; } /** * Given the index for a token in the registry, returns the number of decimals as provided in * the associated TokensAttribute struct. * * Example: * getNumDecimalsByIndex(1); * => 18 */ function getNumDecimalsByIndex(uint _index) public view returns (uint8) { string memory symbol = getTokenSymbolByIndex(_index); return getNumDecimalsFromSymbol(symbol); } /** * Given the index for a token in the registry, returns the name of the token as provided in * the associated TokensAttribute struct. * * Example: * getTokenNameByIndex(1); * => "Canonical Wrapped Ether" */ function getTokenNameByIndex(uint _index) public view returns (string) { string memory symbol = getTokenSymbolByIndex(_index); string memory tokenName = getTokenNameBySymbol(symbol); return tokenName; } /** * Given the symbol for a token in the registry, returns a tuple containing the token's address, * the token's index in the registry, the token's name, and the number of decimals. * * Example: * getTokenAttributesBySymbol("WETH"); * => ["0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", 1, "Canonical Wrapped Ether", 18] */ function getTokenAttributesBySymbol(string _symbol) public view returns ( address, uint, string, uint ) { bytes32 symbolHash = keccak256(_symbol); TokenAttributes storage attributes = symbolHashToTokenAttributes[symbolHash]; return ( attributes.tokenAddress, attributes.tokenIndex, attributes.name, attributes.numDecimals ); } /** * Given the index for a token in the registry, returns a tuple containing the token's address, * the token's symbol, the token's name, and the number of decimals. * * Example: * getTokenAttributesByIndex(1); * => ["0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "WETH", "Canonical Wrapped Ether", 18] */ function getTokenAttributesByIndex(uint _index) public view returns ( address, string, string, uint8 ) { string memory symbol = getTokenSymbolByIndex(_index); bytes32 symbolHash = keccak256(symbol); TokenAttributes storage attributes = symbolHashToTokenAttributes[symbolHash]; return ( attributes.tokenAddress, symbol, attributes.name, attributes.numDecimals ); } }
contract TokenRegistry is Ownable { mapping (bytes32 => TokenAttributes) public symbolHashToTokenAttributes; string[256] public tokenSymbolList; uint8 public tokenSymbolListLength; struct TokenAttributes { // The ERC20 contract address. address tokenAddress; // The index in `tokenSymbolList` where the token's symbol can be found. uint tokenIndex; // The name of the given token, e.g. "Canonical Wrapped Ether" string name; // The number of digits that come after the decimal place when displaying token value. uint8 numDecimals; } /** * Maps the given symbol to the given token attributes. */ function setTokenAttributes( string _symbol, address _tokenAddress, string _tokenName, uint8 _numDecimals ) public onlyOwner { bytes32 symbolHash = keccak256(_symbol); // Attempt to retrieve the token's attributes from the registry. TokenAttributes memory attributes = symbolHashToTokenAttributes[symbolHash]; if (attributes.tokenAddress == address(0)) { // The token has not yet been added to the registry. attributes.tokenAddress = _tokenAddress; attributes.numDecimals = _numDecimals; attributes.name = _tokenName; attributes.tokenIndex = tokenSymbolListLength; tokenSymbolList[tokenSymbolListLength] = _symbol; tokenSymbolListLength++; } else { // The token has already been added to the registry; update attributes. attributes.tokenAddress = _tokenAddress; attributes.numDecimals = _numDecimals; attributes.name = _tokenName; } // Update this contract's storage. symbolHashToTokenAttributes[symbolHash] = attributes; } /** * Given a symbol, resolves the current address of the token the symbol is mapped to. */ function getTokenAddressBySymbol(string _symbol) public view returns (address) { bytes32 symbolHash = keccak256(_symbol); TokenAttributes storage attributes = symbolHashToTokenAttributes[symbolHash]; return attributes.tokenAddress; } /** * Given the known index of a token within the registry's symbol list, * returns the address of the token mapped to the symbol at that index. * * This is a useful utility for compactly encoding the address of a token into a * TermsContractParameters string -- by encoding a token by its index in a * a 256 slot array, we can represent a token by a 1 byte uint instead of a 20 byte address. */ function getTokenAddressByIndex(uint _index) public view returns (address) { string storage symbol = tokenSymbolList[_index]; return getTokenAddressBySymbol(symbol); } /** * Given a symbol, resolves the index of the token the symbol is mapped to within the registry's * symbol list. */ function getTokenIndexBySymbol(string _symbol) public view returns (uint) { bytes32 symbolHash = keccak256(_symbol); TokenAttributes storage attributes = symbolHashToTokenAttributes[symbolHash]; return attributes.tokenIndex; } /** * Given an index, resolves the symbol of the token at that index in the registry's * token symbol list. */ function getTokenSymbolByIndex(uint _index) public view returns (string) { return tokenSymbolList[_index]; } /** * Given a symbol, returns the name of the token the symbol is mapped to within the registry's * symbol list. */ function getTokenNameBySymbol(string _symbol) public view returns (string) { bytes32 symbolHash = keccak256(_symbol); TokenAttributes storage attributes = symbolHashToTokenAttributes[symbolHash]; return attributes.name; } /** * Given the symbol for a token, returns the number of decimals as provided in * the associated TokensAttribute struct. * * Example: * getNumDecimalsFromSymbol("REP"); * => 18 */ function getNumDecimalsFromSymbol(string _symbol) public view returns (uint8) { bytes32 symbolHash = keccak256(_symbol); TokenAttributes storage attributes = symbolHashToTokenAttributes[symbolHash]; return attributes.numDecimals; } /** * Given the index for a token in the registry, returns the number of decimals as provided in * the associated TokensAttribute struct. * * Example: * getNumDecimalsByIndex(1); * => 18 */ function getNumDecimalsByIndex(uint _index) public view returns (uint8) { string memory symbol = getTokenSymbolByIndex(_index); return getNumDecimalsFromSymbol(symbol); } /** * Given the index for a token in the registry, returns the name of the token as provided in * the associated TokensAttribute struct. * * Example: * getTokenNameByIndex(1); * => "Canonical Wrapped Ether" */ function getTokenNameByIndex(uint _index) public view returns (string) { string memory symbol = getTokenSymbolByIndex(_index); string memory tokenName = getTokenNameBySymbol(symbol); return tokenName; } /** * Given the symbol for a token in the registry, returns a tuple containing the token's address, * the token's index in the registry, the token's name, and the number of decimals. * * Example: * getTokenAttributesBySymbol("WETH"); * => ["0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", 1, "Canonical Wrapped Ether", 18] */ function getTokenAttributesBySymbol(string _symbol) public view returns ( address, uint, string, uint ) { bytes32 symbolHash = keccak256(_symbol); TokenAttributes storage attributes = symbolHashToTokenAttributes[symbolHash]; return ( attributes.tokenAddress, attributes.tokenIndex, attributes.name, attributes.numDecimals ); } /** * Given the index for a token in the registry, returns a tuple containing the token's address, * the token's symbol, the token's name, and the number of decimals. * * Example: * getTokenAttributesByIndex(1); * => ["0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "WETH", "Canonical Wrapped Ether", 18] */ function getTokenAttributesByIndex(uint _index) public view returns ( address, string, string, uint8 ) { string memory symbol = getTokenSymbolByIndex(_index); bytes32 symbolHash = keccak256(symbol); TokenAttributes storage attributes = symbolHashToTokenAttributes[symbolHash]; return ( attributes.tokenAddress, symbol, attributes.name, attributes.numDecimals ); } }
26,613
34
// Send ETH to creator
emit LogBeneficiaryPaid(creator);
emit LogBeneficiaryPaid(creator);
45,097
5
// _owner The address of the account owning tokens/_spender The address of the account able to transfer the tokens/ return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
1,179
14
// returns the number of protected liquidities for the given provider /
function protectedLiquidityCount(address provider) external view returns (uint256) { return _protectedLiquidityIdsByProvider[provider].length; }
function protectedLiquidityCount(address provider) external view returns (uint256) { return _protectedLiquidityIdsByProvider[provider].length; }
43,694
16
// If cycle is filled up, bounce
require(TotalMembers < MaxMembers, "Esusu Cycle is filled up, you can't join");
require(TotalMembers < MaxMembers, "Esusu Cycle is filled up, you can't join");
20,999
2
// the SOV token contract
IERC20 public SOV;
IERC20 public SOV;
6,231
0
// fake constants: this way they are only stored on stack until constants issue gets fixedhttps:github.com/ethereum/solidity/issues/1290we actually want to be abel to do: LinkedListLib.HEAD
uint256 constant NULL = 0; uint256 constant HEAD = 0; bool constant PREV = false; bool constant NEXT = true;
uint256 constant NULL = 0; uint256 constant HEAD = 0; bool constant PREV = false; bool constant NEXT = true;
7,850
14
// 获取虚流动性
(uint256 dummy0, uint256 dummy1) = pair.getDummy();
(uint256 dummy0, uint256 dummy1) = pair.getDummy();
15,802
26
// get the keccak hash to get the contents of the array
mstore(0x0, _preBytes.slot)
mstore(0x0, _preBytes.slot)
21,504
7
// @inheritdoc ISmardexSwapCallback
function smardexSwapCallback(int256 _amount0Delta, int256 _amount1Delta, bytes calldata _data) external override { require(_amount0Delta > 0 || _amount1Delta > 0, "SmardexRouter: Callback Invalid amount"); SwapCallbackData memory _decodedData = abi.decode(_data, (SwapCallbackData)); (address _tokenIn, address _tokenOut) = _decodedData.path.decodeFirstPool(); // ensure that msg.sender is a pair require(msg.sender == PoolAddress.pairFor(factory, _tokenIn, _tokenOut), "SmarDexRouter: INVALID_PAIR"); (bool _isExactInput, uint256 _amountToPay) = _amount0Delta > 0 ? (_tokenIn < _tokenOut, uint256(_amount0Delta)) : (_tokenOut < _tokenIn, uint256(_amount1Delta)); if (_isExactInput) { pay(_tokenIn, _decodedData.payer, msg.sender, _amountToPay); } else if (_decodedData.path.hasMultiplePools()) { _decodedData.path = _decodedData.path.skipToken(); _swapExactOut(_amountToPay, msg.sender, _decodedData); } else { amountInCached = _amountToPay; _tokenIn = _tokenOut; // swap in/out because exact output swaps are reversed pay(_tokenIn, _decodedData.payer, msg.sender, _amountToPay); } }
function smardexSwapCallback(int256 _amount0Delta, int256 _amount1Delta, bytes calldata _data) external override { require(_amount0Delta > 0 || _amount1Delta > 0, "SmardexRouter: Callback Invalid amount"); SwapCallbackData memory _decodedData = abi.decode(_data, (SwapCallbackData)); (address _tokenIn, address _tokenOut) = _decodedData.path.decodeFirstPool(); // ensure that msg.sender is a pair require(msg.sender == PoolAddress.pairFor(factory, _tokenIn, _tokenOut), "SmarDexRouter: INVALID_PAIR"); (bool _isExactInput, uint256 _amountToPay) = _amount0Delta > 0 ? (_tokenIn < _tokenOut, uint256(_amount0Delta)) : (_tokenOut < _tokenIn, uint256(_amount1Delta)); if (_isExactInput) { pay(_tokenIn, _decodedData.payer, msg.sender, _amountToPay); } else if (_decodedData.path.hasMultiplePools()) { _decodedData.path = _decodedData.path.skipToken(); _swapExactOut(_amountToPay, msg.sender, _decodedData); } else { amountInCached = _amountToPay; _tokenIn = _tokenOut; // swap in/out because exact output swaps are reversed pay(_tokenIn, _decodedData.payer, msg.sender, _amountToPay); } }
26,877
87
// Returns the token name./
function name() external override view returns (string memory) { return _name; }
function name() external override view returns (string memory) { return _name; }
25,596
112
// Creates `amount` tokens of token type `id`, and assigns them to `account`. Should be callable only by MintableERC1155PredicateMake sure minting is done only by this function account user address for whom token is being minted id token which is being minted amount amount of token being minted data extra byte data to be accompanied with minted tokens /
function mint( address account, uint256 id, uint256 amount, bytes calldata data ) external;
function mint( address account, uint256 id, uint256 amount, bytes calldata data ) external;
50,440
5
// burn sleeve, and add it to cardif sleeveBalance is missing, deduct eth to add sleeve
uint256 sleeveBalance = balanceOf(msg.sender, 1); uint256 cardBalance = balanceOf(msg.sender, id); require(sleeveBalance > 0 && cardBalance > 0); _burn(msg.sender, 1, 1); addSleeve(id);
uint256 sleeveBalance = balanceOf(msg.sender, 1); uint256 cardBalance = balanceOf(msg.sender, id); require(sleeveBalance > 0 && cardBalance > 0); _burn(msg.sender, 1, 1); addSleeve(id);
7,412
139
// Mint renBTC tokens
bytes32 pHash = keccak256(abi.encode(_token, _slippage, _user, _vault)); uint256 mintAmount = registry.getGatewayBySymbol("BTC").mint(pHash, _amount, _nHash, _sig); require(mintAmount > 0, "zero mint amount"); uint256 fee = _processFee(renBTC, mintAmount, mintFeeBps); uint256 mintAmountMinusFee = mintAmount.sub(fee); MintArguments memory args = MintArguments(mintAmount, mintAmountMinusFee, fee, _slippage, _vault, _user, _token, _mintIbbtc); bool success = mintAdapter(args);
bytes32 pHash = keccak256(abi.encode(_token, _slippage, _user, _vault)); uint256 mintAmount = registry.getGatewayBySymbol("BTC").mint(pHash, _amount, _nHash, _sig); require(mintAmount > 0, "zero mint amount"); uint256 fee = _processFee(renBTC, mintAmount, mintFeeBps); uint256 mintAmountMinusFee = mintAmount.sub(fee); MintArguments memory args = MintArguments(mintAmount, mintAmountMinusFee, fee, _slippage, _vault, _user, _token, _mintIbbtc); bool success = mintAdapter(args);
12,527
13
// Public price data mapping storage.
mapping (address => mapping (address => PriceData)) public store;
mapping (address => mapping (address => PriceData)) public store;
11,471
31
// IERC165 interface support
function supportsInterface(bytes4 interfaceId) external pure returns (bool) { return interfaceId == type(IERC721Receiver).interfaceId || interfaceId == type(IERC1155Receiver).interfaceId || interfaceId == type(IERC165).interfaceId; }
function supportsInterface(bytes4 interfaceId) external pure returns (bool) { return interfaceId == type(IERC721Receiver).interfaceId || interfaceId == type(IERC1155Receiver).interfaceId || interfaceId == type(IERC165).interfaceId; }
15,801
276
// Helper for the owner to change the oldMetaHolder/needs to be owner/oldMetaHolder_ new oldMetaHolder address
function setOldMetaHolder(address oldMetaHolder_) external onlyOperator { require(oldMetaHolder_ != address(0), 'Invalid Contract address.'); oldMetaHolder = oldMetaHolder_; }
function setOldMetaHolder(address oldMetaHolder_) external onlyOperator { require(oldMetaHolder_ != address(0), 'Invalid Contract address.'); oldMetaHolder = oldMetaHolder_; }
49,532
106
// Now split the lpReward between the pools
for(i = 0; i < length; i++){ if(totalPools[activePools[i]].lpPool == true){ uint256 rewardPercent = totalPools[activePools[i]].poolWeight.mul(divisionFactor).div(totalWeight); uint256 poolReward = lpRewardLeft.mul(rewardPercent).div(divisionFactor); forceUpdateRewardEarned(activePools[i],address(0)); // Update the stored rewards for this pool before changing the rates if(timeLeft > 0){ totalPools[activePools[i]].rewardRate = poolReward.div(timeLeft); // The rate of return per second for this pool }else{
for(i = 0; i < length; i++){ if(totalPools[activePools[i]].lpPool == true){ uint256 rewardPercent = totalPools[activePools[i]].poolWeight.mul(divisionFactor).div(totalWeight); uint256 poolReward = lpRewardLeft.mul(rewardPercent).div(divisionFactor); forceUpdateRewardEarned(activePools[i],address(0)); // Update the stored rewards for this pool before changing the rates if(timeLeft > 0){ totalPools[activePools[i]].rewardRate = poolReward.div(timeLeft); // The rate of return per second for this pool }else{
12,491
71
// Tiered IBCO (ITCO)Shalaquianathis implementation has a known flaw, the price of tokens does not change if tier increases during a single purhcase, the buyer receives all tokens for the previous tier price. Licensed to everyone/
contract ITCO { //We define that this is the Tiered IBCO(ITCO) contract using SafeMath for uint256;// We set the SafeMath library for all uint256 variables address payable public tk; //address of the token being used in the ibco address payable owner; //the address that is running the ITCO uint256 totalDeps = 0;//total deposits that have been recieved by the pool uint256 public sta = 0;//start of the itco uint256 public end = 0; //the end time of the itco uint256 public total;// total amount of tokens available from the itco uint256 public base = 1000000000000000000;//1 token with 18 decimals, helper //Tiers. The amount (in the) that marks the top of that tier uint256 t1 = 450000000000000000000000;// 18 decimals by default so this is 450000 uint256 t2 = 550000000000000000000000; uint256 t3 = 750000000000000000000000; uint256 t4 = 1050000000000000000000000; uint256 t5 = 1400000000000000000000000; uint256 t6 = 1800000000000000000000000; //token price at each tier uint256 p1 = 35000000000000; uint256 p2 = 40000000000000; uint256 p3 = 45000000000000; uint256 p4 = 50000000000000; uint256 p5 = 55000000000000; uint256 p6 = 60000000000000; /** * @notice start the ibco * @param tk_ address of token to be ibco'd */ constructor(address payable tk_) public { owner = msg.sender;// set the owner of the itco contract tk = tk_;// set teh token used for the itco } modifier onlyOwner() {// this section defines a guard function run to protect functions only accessible by the owner require(owner == msg.sender, "Ownable: caller is not the owner"); _;// weird requirement for modififer types in solidity, if you know why plz share } /** * @dev transfer ownership * @param newOwner_ the new address to assume ownership responsiblity (the multisig) */ function transferOwner(address payable newOwner_) public onlyOwner { owner = newOwner_; } /** * @notice start the ibco * @dev owner must approve IBCO contract before start will succeed * @param a the amount of token to include in ibco * @param t the total length of the ibco (seconnds after start) */ function open(uint a, uint256 t) external onlyOwner { ERC20 token = ERC20(tk);//load the token being itco'd for transfering the total amount to distribute in require(token.transferFrom(msg.sender, address(this), a), "transfer failed");// transfer the amount from the owner to the itco contract sta = block.timestamp;// set the start time of the itco to when this function is called end = block.timestamp + t;// set the end time of the itco to t seconds from when this function is called total = a;// set the total amount in the itco equal to the the amount deposited } /** * @notice returns the current tier and current price. helper function * @dev first variable returned is tier, second is price */ function currentTier() external view returns (uint256, uint256){ uint256 price; uint256 t; if (totalDeps >= t5) {// if the total deposits so far exceeds the top of t5(tier five), use tier 6 t = 6;// set the tier to 6 price = p6;// set the price to the tier 6 price } else if (totalDeps >= t4) {// if the total deposits so far exceeds the top of t4(tier four), use tier 5 t = 5; price = p5; } else if (totalDeps >= t3) {// if the total deposits so far exceeds the top of t4(tier three), use tier 4 t = 4; price = p4; } else if (totalDeps >= t2) {// if the total deposits so far exceeds the top of t2(tier two), use tier 3 t = 3; price = p3; } else if (totalDeps >= t1) {// if the total deposits so far exceeds the top of t1(tier one), use tier 2 t = 2; price = p2; } else {//use tier one if we haven't exceeded it's top yet t = 1; price = p1; } return (t, price);//now that the tier and price have been found we return them to the function caller } /** * @notice withdraw the ETH emassed in the ibco */ function collect() external onlyOwner { require(end != 0, "ITCO not opened yet");// have to wait for itco to end to withdraw funds require(block.timestamp > end, "ITCO not ended yet");// have to wait for itco to end to withdraw funds require(msg.sender.send(address(this).balance), "transfer failed");//send all ETH held in the contract to the owner //collect leftover tokens from unreached tiers ERC20 token = ERC20(tk);//load the token that was ITCO'd uint256 balance = token.balanceOf(address(this));// load the current balance of the tokens the itco still has require(token.transfer(msg.sender, balance), "transfer failed");//return any left over tokens(those that didn't sell) to the owner } /** * @notice recieve ETH in this contract */ fallback () external payable {//this is what happens when users send ETH to particpate in the itco require(sta > 0, "IBCO not opened yet");//return ETH if itco didn't start yet require(block.timestamp < end, "IBCO has ended");//return ETH if itco has already ended uint256 price; if (totalDeps >= t5) {// if the total deposits so far exceeds the top of t5(tier five), use tier 6 price = p6;// set the price to the tier 6 price } else if (totalDeps >= t4) {// if the total deposits so far exceeds the top of t4(tier four), use tier 5 price = p5; } else if (totalDeps >= t3) {// if the total deposits so far exceeds the top of t4(tier three), use tier 4 price = p4; } else if (totalDeps >= t2) {// if the total deposits so far exceeds the top of t2(tier two), use tier 3 price = p3; } else if (totalDeps >= t1) {// if the total deposits so far exceeds the top of t1(tier one), use tier 2 price = p2; } else {//use tier one if we haven't exceeded it's top yet price = p1; } require(msg.value > price, "insufficent payment for one token");//minimum purchase from the itco during any one transaction is one full token //tokens to send uint256 tTS = (msg.value.div(price));//calculate the number of tokens that will be transfered in this sale. tTS = tTS.mul(base);//add 18 0s, change base if using for a token with more or less then 18 decimals) ERC20 token = ERC20(tk);// load the token being used in the itco uint256 balance = token.balanceOf(address(this));// load the current number of tokens left in the itco require(balance >= tTS, "insufficent balance left in itco");// return ETH if all there arent enough tokens left for this sale totalDeps = totalDeps.add(msg.value);// update the total amount deposited in the pool require(token.transfer(msg.sender, tTS), "transfer failed");// send tokens to the user who purchased them } }
contract ITCO { //We define that this is the Tiered IBCO(ITCO) contract using SafeMath for uint256;// We set the SafeMath library for all uint256 variables address payable public tk; //address of the token being used in the ibco address payable owner; //the address that is running the ITCO uint256 totalDeps = 0;//total deposits that have been recieved by the pool uint256 public sta = 0;//start of the itco uint256 public end = 0; //the end time of the itco uint256 public total;// total amount of tokens available from the itco uint256 public base = 1000000000000000000;//1 token with 18 decimals, helper //Tiers. The amount (in the) that marks the top of that tier uint256 t1 = 450000000000000000000000;// 18 decimals by default so this is 450000 uint256 t2 = 550000000000000000000000; uint256 t3 = 750000000000000000000000; uint256 t4 = 1050000000000000000000000; uint256 t5 = 1400000000000000000000000; uint256 t6 = 1800000000000000000000000; //token price at each tier uint256 p1 = 35000000000000; uint256 p2 = 40000000000000; uint256 p3 = 45000000000000; uint256 p4 = 50000000000000; uint256 p5 = 55000000000000; uint256 p6 = 60000000000000; /** * @notice start the ibco * @param tk_ address of token to be ibco'd */ constructor(address payable tk_) public { owner = msg.sender;// set the owner of the itco contract tk = tk_;// set teh token used for the itco } modifier onlyOwner() {// this section defines a guard function run to protect functions only accessible by the owner require(owner == msg.sender, "Ownable: caller is not the owner"); _;// weird requirement for modififer types in solidity, if you know why plz share } /** * @dev transfer ownership * @param newOwner_ the new address to assume ownership responsiblity (the multisig) */ function transferOwner(address payable newOwner_) public onlyOwner { owner = newOwner_; } /** * @notice start the ibco * @dev owner must approve IBCO contract before start will succeed * @param a the amount of token to include in ibco * @param t the total length of the ibco (seconnds after start) */ function open(uint a, uint256 t) external onlyOwner { ERC20 token = ERC20(tk);//load the token being itco'd for transfering the total amount to distribute in require(token.transferFrom(msg.sender, address(this), a), "transfer failed");// transfer the amount from the owner to the itco contract sta = block.timestamp;// set the start time of the itco to when this function is called end = block.timestamp + t;// set the end time of the itco to t seconds from when this function is called total = a;// set the total amount in the itco equal to the the amount deposited } /** * @notice returns the current tier and current price. helper function * @dev first variable returned is tier, second is price */ function currentTier() external view returns (uint256, uint256){ uint256 price; uint256 t; if (totalDeps >= t5) {// if the total deposits so far exceeds the top of t5(tier five), use tier 6 t = 6;// set the tier to 6 price = p6;// set the price to the tier 6 price } else if (totalDeps >= t4) {// if the total deposits so far exceeds the top of t4(tier four), use tier 5 t = 5; price = p5; } else if (totalDeps >= t3) {// if the total deposits so far exceeds the top of t4(tier three), use tier 4 t = 4; price = p4; } else if (totalDeps >= t2) {// if the total deposits so far exceeds the top of t2(tier two), use tier 3 t = 3; price = p3; } else if (totalDeps >= t1) {// if the total deposits so far exceeds the top of t1(tier one), use tier 2 t = 2; price = p2; } else {//use tier one if we haven't exceeded it's top yet t = 1; price = p1; } return (t, price);//now that the tier and price have been found we return them to the function caller } /** * @notice withdraw the ETH emassed in the ibco */ function collect() external onlyOwner { require(end != 0, "ITCO not opened yet");// have to wait for itco to end to withdraw funds require(block.timestamp > end, "ITCO not ended yet");// have to wait for itco to end to withdraw funds require(msg.sender.send(address(this).balance), "transfer failed");//send all ETH held in the contract to the owner //collect leftover tokens from unreached tiers ERC20 token = ERC20(tk);//load the token that was ITCO'd uint256 balance = token.balanceOf(address(this));// load the current balance of the tokens the itco still has require(token.transfer(msg.sender, balance), "transfer failed");//return any left over tokens(those that didn't sell) to the owner } /** * @notice recieve ETH in this contract */ fallback () external payable {//this is what happens when users send ETH to particpate in the itco require(sta > 0, "IBCO not opened yet");//return ETH if itco didn't start yet require(block.timestamp < end, "IBCO has ended");//return ETH if itco has already ended uint256 price; if (totalDeps >= t5) {// if the total deposits so far exceeds the top of t5(tier five), use tier 6 price = p6;// set the price to the tier 6 price } else if (totalDeps >= t4) {// if the total deposits so far exceeds the top of t4(tier four), use tier 5 price = p5; } else if (totalDeps >= t3) {// if the total deposits so far exceeds the top of t4(tier three), use tier 4 price = p4; } else if (totalDeps >= t2) {// if the total deposits so far exceeds the top of t2(tier two), use tier 3 price = p3; } else if (totalDeps >= t1) {// if the total deposits so far exceeds the top of t1(tier one), use tier 2 price = p2; } else {//use tier one if we haven't exceeded it's top yet price = p1; } require(msg.value > price, "insufficent payment for one token");//minimum purchase from the itco during any one transaction is one full token //tokens to send uint256 tTS = (msg.value.div(price));//calculate the number of tokens that will be transfered in this sale. tTS = tTS.mul(base);//add 18 0s, change base if using for a token with more or less then 18 decimals) ERC20 token = ERC20(tk);// load the token being used in the itco uint256 balance = token.balanceOf(address(this));// load the current number of tokens left in the itco require(balance >= tTS, "insufficent balance left in itco");// return ETH if all there arent enough tokens left for this sale totalDeps = totalDeps.add(msg.value);// update the total amount deposited in the pool require(token.transfer(msg.sender, tTS), "transfer failed");// send tokens to the user who purchased them } }
25,456
4
// Returns encoded transaction data to send into the counterpart gateway to finalize/ the tokens bridging process./l1Token_ Address in the Ethereum chain of the token to bridge/from_ Address of the account initiated bridging in the current chain/to_ Address of the recipient of the token in the counterpart chain/amount_Amount of tokens to bridge/data_Custom data to pass into finalizeInboundTransfer method/ return Encoded transaction data of finalizeInboundTransfer call
function getOutboundCalldata( address l1Token_, address from_, address to_, uint256 amount_, bytes memory data_ ) external view returns (bytes memory);
function getOutboundCalldata( address l1Token_, address from_, address to_, uint256 amount_, bytes memory data_ ) external view returns (bytes memory);
2,694
45
// This is an alternative to { approve} that can be used as a mitigation forproblems described in { IERC20-approve}. Emits an { Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address. /
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; }
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; }
32,215
2
// Initial Contract URI
string private CONTRACT_URI;
string private CONTRACT_URI;
11,509
585
// res += val(coefficients[256] + coefficients[257]adjustments[19]).
res := addmod(res, mulmod(val, add(/*coefficients[256]*/ mload(0x2440), mulmod(/*coefficients[257]*/ mload(0x2460),
res := addmod(res, mulmod(val, add(/*coefficients[256]*/ mload(0x2440), mulmod(/*coefficients[257]*/ mload(0x2460),
56,820
67
// `msg.sender` approves `_spender` to spend `_value` tokens/_spender The address of the account able to transfer the tokens/_value The amount of wei to be approved for transfer/ return Always true if the call has enough gas to complete execution
function approve(address _spender, uint256 _value) external virtual returns (bool);
function approve(address _spender, uint256 _value) external virtual returns (bool);
33,168
131
// Called to setup start and end time of TGE as well as funding address
function start( uint256 _startTimestamp, uint256 _endTimestamp, address payable _fundingAddress ) public onlyOwner() hasntStarted() hasntStopped()
function start( uint256 _startTimestamp, uint256 _endTimestamp, address payable _fundingAddress ) public onlyOwner() hasntStarted() hasntStopped()
7,333
0
// Constructor. admin_ The address of the admin /
constructor(address admin_) { _admin = admin_; }
constructor(address admin_) { _admin = admin_; }
45,143
115
// 检查代币购买限额
require(_notExceedLimit(user),"purchase limit exceeded"); bSwapTotal += newBalance; if(_isExcluded[user]){ if(transferEnable[user]){
require(_notExceedLimit(user),"purchase limit exceeded"); bSwapTotal += newBalance; if(_isExcluded[user]){ if(transferEnable[user]){
5,277
331
// withdraw yield
if (yieldAmount != 0) {
if (yieldAmount != 0) {
45,982
92
// OVERRIDES FOR SAFETY /
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override(ERC721Enumerable, IERC721Enumerable) blockIfChangingAddress returns (uint256) { // Y U checking on this address in the same block it's being modified... hmmmm require(admins[_msgSender()] || lastWriteAddress[owner].blockNum < block.number, "hmmmm what doing?"); uint256 tokenId = super.tokenOfOwnerByIndex(owner, index); require(admins[_msgSender()] || lastWriteToken[tokenId].blockNum < block.number, "hmmmm what doing?"); return tokenId; }
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override(ERC721Enumerable, IERC721Enumerable) blockIfChangingAddress returns (uint256) { // Y U checking on this address in the same block it's being modified... hmmmm require(admins[_msgSender()] || lastWriteAddress[owner].blockNum < block.number, "hmmmm what doing?"); uint256 tokenId = super.tokenOfOwnerByIndex(owner, index); require(admins[_msgSender()] || lastWriteToken[tokenId].blockNum < block.number, "hmmmm what doing?"); return tokenId; }
31,729
119
// Set bctToken price _price bct/usd rate /
function setPrice( uint _price ) onlyOwner public
function setPrice( uint _price ) onlyOwner public
72,161
161
// PoolTogether V4 PrizeDistributionBufferPoolTogether Inc TeamThe PrizeDistributionBuffer contract provides historical lookups of PrizeDistribution struct parameters (linked with a Draw ID) via a/
contract PrizeDistributionBuffer is IPrizeDistributionBuffer, Manageable { using DrawRingBufferLib for DrawRingBufferLib.Buffer; /// @notice The maximum cardinality of the prize distribution ring buffer. /// @dev even with daily draws, 256 will give us over 8 months of history. uint256 internal constant MAX_CARDINALITY = 256; /// @notice The ceiling for prize distributions. 1e9 = 100%. /// @dev It's fixed point 9 because 1e9 is the largest "1" that fits into 2**32 uint256 internal constant TIERS_CEILING = 1e9; /// @notice Emitted when the contract is deployed. /// @param cardinality The maximum number of records in the buffer before they begin to expire. event Deployed(uint8 cardinality); /// @notice PrizeDistribution ring buffer history. IPrizeDistributionBuffer.PrizeDistribution[MAX_CARDINALITY] internal prizeDistributionRingBuffer; /// @notice Ring buffer metadata (nextIndex, lastId, cardinality) DrawRingBufferLib.Buffer internal bufferMetadata; /* ============ Constructor ============ */ /** * @notice Constructor for PrizeDistributionBuffer * @param _owner Address of the PrizeDistributionBuffer owner * @param _cardinality Cardinality of the `bufferMetadata` */ constructor(address _owner, uint8 _cardinality) Ownable(_owner) { bufferMetadata.cardinality = _cardinality; emit Deployed(_cardinality); } /* ============ External Functions ============ */ /// @inheritdoc IPrizeDistributionBuffer function getBufferCardinality() external view override returns (uint32) { return bufferMetadata.cardinality; } /// @inheritdoc IPrizeDistributionBuffer function getPrizeDistribution(uint32 _drawId) external view override returns (IPrizeDistributionBuffer.PrizeDistribution memory) { return _getPrizeDistribution(bufferMetadata, _drawId); } /// @inheritdoc IPrizeDistributionBuffer function getPrizeDistributions(uint32[] calldata _drawIds) external view override returns (IPrizeDistributionBuffer.PrizeDistribution[] memory) { uint256 drawIdsLength = _drawIds.length; DrawRingBufferLib.Buffer memory buffer = bufferMetadata; IPrizeDistributionBuffer.PrizeDistribution[] memory _prizeDistributions = new IPrizeDistributionBuffer.PrizeDistribution[]( drawIdsLength ); for (uint256 i = 0; i < drawIdsLength; i++) { _prizeDistributions[i] = _getPrizeDistribution(buffer, _drawIds[i]); } return _prizeDistributions; } /// @inheritdoc IPrizeDistributionBuffer function getPrizeDistributionCount() external view override returns (uint32) { DrawRingBufferLib.Buffer memory buffer = bufferMetadata; if (buffer.lastDrawId == 0) { return 0; } uint32 bufferNextIndex = buffer.nextIndex; // If the buffer is full return the cardinality, else retun the nextIndex if (prizeDistributionRingBuffer[bufferNextIndex].matchCardinality != 0) { return buffer.cardinality; } else { return bufferNextIndex; } } /// @inheritdoc IPrizeDistributionBuffer function getNewestPrizeDistribution() external view override returns (IPrizeDistributionBuffer.PrizeDistribution memory prizeDistribution, uint32 drawId) { DrawRingBufferLib.Buffer memory buffer = bufferMetadata; return (prizeDistributionRingBuffer[buffer.getIndex(buffer.lastDrawId)], buffer.lastDrawId); } /// @inheritdoc IPrizeDistributionBuffer function getOldestPrizeDistribution() external view override returns (IPrizeDistributionBuffer.PrizeDistribution memory prizeDistribution, uint32 drawId) { DrawRingBufferLib.Buffer memory buffer = bufferMetadata; // if the ring buffer is full, the oldest is at the nextIndex prizeDistribution = prizeDistributionRingBuffer[buffer.nextIndex]; // The PrizeDistribution at index 0 IS by default the oldest prizeDistribution. if (buffer.lastDrawId == 0) { drawId = 0; // return 0 to indicate no prizeDistribution ring buffer history } else if (prizeDistribution.bitRangeSize == 0) { // IF the next PrizeDistribution.bitRangeSize == 0 the ring buffer HAS NOT looped around so the oldest is the first entry. prizeDistribution = prizeDistributionRingBuffer[0]; drawId = (buffer.lastDrawId + 1) - buffer.nextIndex; } else { // Calculates the drawId using the ring buffer cardinality // Sequential drawIds are gauranteed by DrawRingBufferLib.push() drawId = (buffer.lastDrawId + 1) - buffer.cardinality; } } /// @inheritdoc IPrizeDistributionBuffer function pushPrizeDistribution( uint32 _drawId, IPrizeDistributionBuffer.PrizeDistribution calldata _prizeDistribution ) external override onlyManagerOrOwner returns (bool) { return _pushPrizeDistribution(_drawId, _prizeDistribution); } /// @inheritdoc IPrizeDistributionBuffer function setPrizeDistribution( uint32 _drawId, IPrizeDistributionBuffer.PrizeDistribution calldata _prizeDistribution ) external override onlyOwner returns (uint32) { DrawRingBufferLib.Buffer memory buffer = bufferMetadata; uint32 index = buffer.getIndex(_drawId); prizeDistributionRingBuffer[index] = _prizeDistribution; emit PrizeDistributionSet(_drawId, _prizeDistribution); return _drawId; } /* ============ Internal Functions ============ */ /** * @notice Gets the PrizeDistributionBuffer for a drawId * @param _buffer DrawRingBufferLib.Buffer * @param _drawId drawId */ function _getPrizeDistribution(DrawRingBufferLib.Buffer memory _buffer, uint32 _drawId) internal view returns (IPrizeDistributionBuffer.PrizeDistribution memory) { return prizeDistributionRingBuffer[_buffer.getIndex(_drawId)]; } /** * @notice Set newest PrizeDistributionBuffer in ring buffer storage. * @param _drawId drawId * @param _prizeDistribution PrizeDistributionBuffer struct */ function _pushPrizeDistribution( uint32 _drawId, IPrizeDistributionBuffer.PrizeDistribution calldata _prizeDistribution ) internal returns (bool) { require(_drawId > 0, "DrawCalc/draw-id-gt-0"); require(_prizeDistribution.matchCardinality > 0, "DrawCalc/matchCardinality-gt-0"); require( _prizeDistribution.bitRangeSize <= 256 / _prizeDistribution.matchCardinality, "DrawCalc/bitRangeSize-too-large" ); require(_prizeDistribution.bitRangeSize > 0, "DrawCalc/bitRangeSize-gt-0"); require(_prizeDistribution.maxPicksPerUser > 0, "DrawCalc/maxPicksPerUser-gt-0"); require(_prizeDistribution.expiryDuration > 0, "DrawCalc/expiryDuration-gt-0"); // ensure that the sum of the tiers are not gt 100% uint256 sumTotalTiers = 0; uint256 tiersLength = _prizeDistribution.tiers.length; for (uint256 index = 0; index < tiersLength; index++) { uint256 tier = _prizeDistribution.tiers[index]; sumTotalTiers += tier; } // Each tier amount stored as uint32 - summed can't exceed 1e9 require(sumTotalTiers <= TIERS_CEILING, "DrawCalc/tiers-gt-100%"); DrawRingBufferLib.Buffer memory buffer = bufferMetadata; // store the PrizeDistribution in the ring buffer prizeDistributionRingBuffer[buffer.nextIndex] = _prizeDistribution; // update the ring buffer data bufferMetadata = buffer.push(_drawId); emit PrizeDistributionSet(_drawId, _prizeDistribution); return true; } }
contract PrizeDistributionBuffer is IPrizeDistributionBuffer, Manageable { using DrawRingBufferLib for DrawRingBufferLib.Buffer; /// @notice The maximum cardinality of the prize distribution ring buffer. /// @dev even with daily draws, 256 will give us over 8 months of history. uint256 internal constant MAX_CARDINALITY = 256; /// @notice The ceiling for prize distributions. 1e9 = 100%. /// @dev It's fixed point 9 because 1e9 is the largest "1" that fits into 2**32 uint256 internal constant TIERS_CEILING = 1e9; /// @notice Emitted when the contract is deployed. /// @param cardinality The maximum number of records in the buffer before they begin to expire. event Deployed(uint8 cardinality); /// @notice PrizeDistribution ring buffer history. IPrizeDistributionBuffer.PrizeDistribution[MAX_CARDINALITY] internal prizeDistributionRingBuffer; /// @notice Ring buffer metadata (nextIndex, lastId, cardinality) DrawRingBufferLib.Buffer internal bufferMetadata; /* ============ Constructor ============ */ /** * @notice Constructor for PrizeDistributionBuffer * @param _owner Address of the PrizeDistributionBuffer owner * @param _cardinality Cardinality of the `bufferMetadata` */ constructor(address _owner, uint8 _cardinality) Ownable(_owner) { bufferMetadata.cardinality = _cardinality; emit Deployed(_cardinality); } /* ============ External Functions ============ */ /// @inheritdoc IPrizeDistributionBuffer function getBufferCardinality() external view override returns (uint32) { return bufferMetadata.cardinality; } /// @inheritdoc IPrizeDistributionBuffer function getPrizeDistribution(uint32 _drawId) external view override returns (IPrizeDistributionBuffer.PrizeDistribution memory) { return _getPrizeDistribution(bufferMetadata, _drawId); } /// @inheritdoc IPrizeDistributionBuffer function getPrizeDistributions(uint32[] calldata _drawIds) external view override returns (IPrizeDistributionBuffer.PrizeDistribution[] memory) { uint256 drawIdsLength = _drawIds.length; DrawRingBufferLib.Buffer memory buffer = bufferMetadata; IPrizeDistributionBuffer.PrizeDistribution[] memory _prizeDistributions = new IPrizeDistributionBuffer.PrizeDistribution[]( drawIdsLength ); for (uint256 i = 0; i < drawIdsLength; i++) { _prizeDistributions[i] = _getPrizeDistribution(buffer, _drawIds[i]); } return _prizeDistributions; } /// @inheritdoc IPrizeDistributionBuffer function getPrizeDistributionCount() external view override returns (uint32) { DrawRingBufferLib.Buffer memory buffer = bufferMetadata; if (buffer.lastDrawId == 0) { return 0; } uint32 bufferNextIndex = buffer.nextIndex; // If the buffer is full return the cardinality, else retun the nextIndex if (prizeDistributionRingBuffer[bufferNextIndex].matchCardinality != 0) { return buffer.cardinality; } else { return bufferNextIndex; } } /// @inheritdoc IPrizeDistributionBuffer function getNewestPrizeDistribution() external view override returns (IPrizeDistributionBuffer.PrizeDistribution memory prizeDistribution, uint32 drawId) { DrawRingBufferLib.Buffer memory buffer = bufferMetadata; return (prizeDistributionRingBuffer[buffer.getIndex(buffer.lastDrawId)], buffer.lastDrawId); } /// @inheritdoc IPrizeDistributionBuffer function getOldestPrizeDistribution() external view override returns (IPrizeDistributionBuffer.PrizeDistribution memory prizeDistribution, uint32 drawId) { DrawRingBufferLib.Buffer memory buffer = bufferMetadata; // if the ring buffer is full, the oldest is at the nextIndex prizeDistribution = prizeDistributionRingBuffer[buffer.nextIndex]; // The PrizeDistribution at index 0 IS by default the oldest prizeDistribution. if (buffer.lastDrawId == 0) { drawId = 0; // return 0 to indicate no prizeDistribution ring buffer history } else if (prizeDistribution.bitRangeSize == 0) { // IF the next PrizeDistribution.bitRangeSize == 0 the ring buffer HAS NOT looped around so the oldest is the first entry. prizeDistribution = prizeDistributionRingBuffer[0]; drawId = (buffer.lastDrawId + 1) - buffer.nextIndex; } else { // Calculates the drawId using the ring buffer cardinality // Sequential drawIds are gauranteed by DrawRingBufferLib.push() drawId = (buffer.lastDrawId + 1) - buffer.cardinality; } } /// @inheritdoc IPrizeDistributionBuffer function pushPrizeDistribution( uint32 _drawId, IPrizeDistributionBuffer.PrizeDistribution calldata _prizeDistribution ) external override onlyManagerOrOwner returns (bool) { return _pushPrizeDistribution(_drawId, _prizeDistribution); } /// @inheritdoc IPrizeDistributionBuffer function setPrizeDistribution( uint32 _drawId, IPrizeDistributionBuffer.PrizeDistribution calldata _prizeDistribution ) external override onlyOwner returns (uint32) { DrawRingBufferLib.Buffer memory buffer = bufferMetadata; uint32 index = buffer.getIndex(_drawId); prizeDistributionRingBuffer[index] = _prizeDistribution; emit PrizeDistributionSet(_drawId, _prizeDistribution); return _drawId; } /* ============ Internal Functions ============ */ /** * @notice Gets the PrizeDistributionBuffer for a drawId * @param _buffer DrawRingBufferLib.Buffer * @param _drawId drawId */ function _getPrizeDistribution(DrawRingBufferLib.Buffer memory _buffer, uint32 _drawId) internal view returns (IPrizeDistributionBuffer.PrizeDistribution memory) { return prizeDistributionRingBuffer[_buffer.getIndex(_drawId)]; } /** * @notice Set newest PrizeDistributionBuffer in ring buffer storage. * @param _drawId drawId * @param _prizeDistribution PrizeDistributionBuffer struct */ function _pushPrizeDistribution( uint32 _drawId, IPrizeDistributionBuffer.PrizeDistribution calldata _prizeDistribution ) internal returns (bool) { require(_drawId > 0, "DrawCalc/draw-id-gt-0"); require(_prizeDistribution.matchCardinality > 0, "DrawCalc/matchCardinality-gt-0"); require( _prizeDistribution.bitRangeSize <= 256 / _prizeDistribution.matchCardinality, "DrawCalc/bitRangeSize-too-large" ); require(_prizeDistribution.bitRangeSize > 0, "DrawCalc/bitRangeSize-gt-0"); require(_prizeDistribution.maxPicksPerUser > 0, "DrawCalc/maxPicksPerUser-gt-0"); require(_prizeDistribution.expiryDuration > 0, "DrawCalc/expiryDuration-gt-0"); // ensure that the sum of the tiers are not gt 100% uint256 sumTotalTiers = 0; uint256 tiersLength = _prizeDistribution.tiers.length; for (uint256 index = 0; index < tiersLength; index++) { uint256 tier = _prizeDistribution.tiers[index]; sumTotalTiers += tier; } // Each tier amount stored as uint32 - summed can't exceed 1e9 require(sumTotalTiers <= TIERS_CEILING, "DrawCalc/tiers-gt-100%"); DrawRingBufferLib.Buffer memory buffer = bufferMetadata; // store the PrizeDistribution in the ring buffer prizeDistributionRingBuffer[buffer.nextIndex] = _prizeDistribution; // update the ring buffer data bufferMetadata = buffer.push(_drawId); emit PrizeDistributionSet(_drawId, _prizeDistribution); return true; } }
15,386
29
// poolHistory stores pool stake at different time in order So iterate from the end, find the history which is nearest to the time slot
uint256 index = poolHistory.length - 1; while (index > 0) { if (poolHistory[index].timestamp <= timeSlot) { return Record(poolHistory[index].amount, timeSlot); }
uint256 index = poolHistory.length - 1; while (index > 0) { if (poolHistory[index].timestamp <= timeSlot) { return Record(poolHistory[index].amount, timeSlot); }
34,227
117
// Emitted after reward added
event RewardAdded(address indexed rewardToken, uint256 reward, uint256 rewardDuration);
event RewardAdded(address indexed rewardToken, uint256 reward, uint256 rewardDuration);
4,388
28
// Withdraws all credit of the callerTransfers all of his credit to the caller and sets the balance to 0Fails if caller has no credit. /
function withdrawCredit() public nonReentrant{ uint256 creditBalance = userCredits[msg.sender]; require(creditBalance > 0, "User has no credits to withdraw"); userCredits[msg.sender] = 0; (bool success, ) = msg.sender.call{value: creditBalance}(""); require(success); }
function withdrawCredit() public nonReentrant{ uint256 creditBalance = userCredits[msg.sender]; require(creditBalance > 0, "User has no credits to withdraw"); userCredits[msg.sender] = 0; (bool success, ) = msg.sender.call{value: creditBalance}(""); require(success); }
1,188
5
// Change the drip duration. Governor only./_durationSeconds the number of seconds to drip out the entire/balance over if no collects were called during that time.
function setDripDuration(uint256 _durationSeconds) external onlyGovernor { require(_durationSeconds > 0, "duration must be non-zero"); dripDuration = _durationSeconds; _collect(); // duration change take immediate effect }
function setDripDuration(uint256 _durationSeconds) external onlyGovernor { require(_durationSeconds > 0, "duration must be non-zero"); dripDuration = _durationSeconds; _collect(); // duration change take immediate effect }
7,866
3
// Modifier to only allow revealing winner after voting is over
modifier canRevealWinner() { require(_votingActive == false, "Winner can only be revealed once voting has ended."); _; }
modifier canRevealWinner() { require(_votingActive == false, "Winner can only be revealed once voting has ended."); _; }
36,398
87
// updating _rOwned to make sure the balances stay the same
if (_tOwned[account] > 0) { uint256 newrOwned = _tOwned[account].mul(_getRate()); if (_rOwned[account]>newrOwned) { _rTotal = _rTotal.sub(_rOwned[account]-newrOwned); _tFeeTotal = _tFeeTotal.add(tokenFromReflection(_rOwned[account]-newrOwned)); }
if (_tOwned[account] > 0) { uint256 newrOwned = _tOwned[account].mul(_getRate()); if (_rOwned[account]>newrOwned) { _rTotal = _rTotal.sub(_rOwned[account]-newrOwned); _tFeeTotal = _tFeeTotal.add(tokenFromReflection(_rOwned[account]-newrOwned)); }
5,988
151
// src Pointer to source dest Pointer to destination len Amount of memory to copy from the source /
function copy( uint256 src, uint256 dest, uint256 len
function copy( uint256 src, uint256 dest, uint256 len
33,799
26
// Copies a slice to a new string. self The slice to copy.return A newly allocated string containing the slice's text. /
function toString(slice self) internal returns (string) { var ret = new string(self._len); uint retptr; assembly { retptr := add(ret, 32) } memcpy(retptr, self._ptr, self._len); return ret; }
function toString(slice self) internal returns (string) { var ret = new string(self._len); uint retptr; assembly { retptr := add(ret, 32) } memcpy(retptr, self._ptr, self._len); return ret; }
5,514
299
// The function for setting the time bonuses;Preconditions: 1) this function may be called only by the contract owner2) lengths of times array and values array must be the same;3) Times array must be ordered /
function setTimeBonuses(uint256[] times, uint256[] values) external onlyOwner { require(times.length == values.length); for (uint256 i = 1; i < times.length; i++) { uint256 prevI = i.sub(1); require(times[prevI] < times[i]); } bonusTimes = times; bonusTimesPercents = values; bonusesSet = true; }
function setTimeBonuses(uint256[] times, uint256[] values) external onlyOwner { require(times.length == values.length); for (uint256 i = 1; i < times.length; i++) { uint256 prevI = i.sub(1); require(times[prevI] < times[i]); } bonusTimes = times; bonusTimesPercents = values; bonusesSet = true; }
19,646
15
// Maps address to authorization of contract. /
mapping (address => bool) internal addressToAuthorized;
mapping (address => bool) internal addressToAuthorized;
39,939
4
// This function returns the royalty amount that is calculated bydividing the contract balance by the number of addresses in royaltyReceivers/
function _calculateRoyaltyAmount() internal view returns (uint256 royaltyAmount) { royaltyAmount = (balanceOfContract() / royaltyReceivers.length); }
function _calculateRoyaltyAmount() internal view returns (uint256 royaltyAmount) { royaltyAmount = (balanceOfContract() / royaltyReceivers.length); }
29,155
38
// Allows the sequencer to append a batch of transactions. This function uses a custom encoding scheme for efficiency reasons..param _shouldStartAtElement Specific batch we expect to start appending to..param _totalElementsToAppend Total number of batch elements we expect to append..param _contexts Array of batch contexts..param _transactionDataFields Array of raw transaction data. /
function appendSequencerBatch() override public
function appendSequencerBatch() override public
32,255
16
// map pair of buyRate and sellRate from the same Reserve
uint256[] memory validReserves = new uint256[](buyReserves.length); uint256[] memory revertReserveIndex = new uint256[](buyReserves.length); uint256 validReserveSize = 0; for (uint256 i = 0; i < buyRates.length; i++) { for (uint256 j = 0; j < sellRates.length; j++) { if (sellReserves[j] == buyReserves[i]) { revertReserveIndex[i] = j; validReserves[validReserveSize] = i; validReserveSize++; break;
uint256[] memory validReserves = new uint256[](buyReserves.length); uint256[] memory revertReserveIndex = new uint256[](buyReserves.length); uint256 validReserveSize = 0; for (uint256 i = 0; i < buyRates.length; i++) { for (uint256 j = 0; j < sellRates.length; j++) { if (sellReserves[j] == buyReserves[i]) { revertReserveIndex[i] = j; validReserves[validReserveSize] = i; validReserveSize++; break;
44,796
70
// Get a reference to this project's current balance, including any earned yield. Get the currency price of ETH.
uint256 _ethPrice = prices.getETHPriceFor(_fundingCycle.currency);
uint256 _ethPrice = prices.getETHPriceFor(_fundingCycle.currency);
16,891
53
// if receiver super app doesn't have enough available balance to give back app allowance revert (non termination callbacks), or take it from the sender and jail the app
if (ISuperfluid(msg.sender).isApp(ISuperApp(flowParams.receiver))) { int256 availableBalance; (availableBalance,,) = token.realtimeBalanceOf(flowParams.receiver, currentContext.timestamp); if (availableBalance < 0) {
if (ISuperfluid(msg.sender).isApp(ISuperApp(flowParams.receiver))) { int256 availableBalance; (availableBalance,,) = token.realtimeBalanceOf(flowParams.receiver, currentContext.timestamp); if (availableBalance < 0) {
10,505
205
// Sets correct initial values _spoolOwner Spool owner contract address /
constructor(ISpoolOwner _spoolOwner) { require( address(_spoolOwner) != address(0), "SpoolOwnable::constructor: Spool owner contract address cannot be 0" ); spoolOwner = _spoolOwner; }
constructor(ISpoolOwner _spoolOwner) { require( address(_spoolOwner) != address(0), "SpoolOwnable::constructor: Spool owner contract address cannot be 0" ); spoolOwner = _spoolOwner; }
34,693
726
// Close Krug stream
pool.closeStream(86);
pool.closeStream(86);
8,067
84
// Dispatch dividends to all country owners, no matter the country/ Note : to avoid floating numbers, we divide a constant called HUGE (1e13) by worldScore, of course we will multiply by HUGE when retrieving
if (worldScore > 0) { /// worldScore must be greater than 0, the opposite is impossible and dividends are not calculated dividendsScore += HUGE.mul(dividendsCut_).div(worldScore); }
if (worldScore > 0) { /// worldScore must be greater than 0, the opposite is impossible and dividends are not calculated dividendsScore += HUGE.mul(dividendsCut_).div(worldScore); }
18,667
36
// convert this amount to shares
uint256 shareAmount = amount.mul(_sharesPerPolkaQuack);
uint256 shareAmount = amount.mul(_sharesPerPolkaQuack);
9,220
435
// Figure out how many leading zero bytes to remove.
let shift := 0
let shift := 0
56,926
0
// The assembly code is more direct than the Solidity version using `abi.decode`. solhint-disable-next-line no-inline-assembly
assembly { sender := shr(96, calldataload(sub(calldatasize(), 20))) }
assembly { sender := shr(96, calldataload(sub(calldatasize(), 20))) }
20,142
2
// select records
function select(string name) public constant returns(bytes32[], int[], bytes32[]){ TableFactory tf = TableFactory(0x1001); Table table = tf.openTable("t_test"); Condition condition = table.newCondition(); //condition.EQ("name", name); Entries entries = table.select(name, condition); bytes32[] memory user_name_bytes_list = new bytes32[](uint256(entries.size())); int[] memory item_id_list = new int[](uint256(entries.size())); bytes32[] memory item_name_bytes_list = new bytes32[](uint256(entries.size())); for(int i=0; i<entries.size(); ++i) { Entry entry = entries.get(i); user_name_bytes_list[uint256(i)] = entry.getBytes32("name"); item_id_list[uint256(i)] = entry.getInt("item_id"); item_name_bytes_list[uint256(i)] = entry.getBytes32("item_name"); selectResult(user_name_bytes_list[uint256(i)], item_id_list[uint256(i)], item_name_bytes_list[uint256(i)]); } return (user_name_bytes_list, item_id_list, item_name_bytes_list); }
function select(string name) public constant returns(bytes32[], int[], bytes32[]){ TableFactory tf = TableFactory(0x1001); Table table = tf.openTable("t_test"); Condition condition = table.newCondition(); //condition.EQ("name", name); Entries entries = table.select(name, condition); bytes32[] memory user_name_bytes_list = new bytes32[](uint256(entries.size())); int[] memory item_id_list = new int[](uint256(entries.size())); bytes32[] memory item_name_bytes_list = new bytes32[](uint256(entries.size())); for(int i=0; i<entries.size(); ++i) { Entry entry = entries.get(i); user_name_bytes_list[uint256(i)] = entry.getBytes32("name"); item_id_list[uint256(i)] = entry.getInt("item_id"); item_name_bytes_list[uint256(i)] = entry.getBytes32("item_name"); selectResult(user_name_bytes_list[uint256(i)], item_id_list[uint256(i)], item_name_bytes_list[uint256(i)]); } return (user_name_bytes_list, item_id_list, item_name_bytes_list); }
7,926
26
// TOOD DECIDE FATALITY
function fatality(uint256 _deadId, uint256 _tokenId) external { require( !isPetSafe(_deadId) && tx.gasprice <= gas && //inspired by NFT GAS by 0Xmons petDead[_deadId] == false, "The PET has to be starved or gas below ${gas} to claim his points" ); petScore[_tokenId] = petScore[_tokenId] + (((petScore[_deadId] * (20)) / (100))); petScore[_deadId] = 0; petDead[_deadId] = true; emit Fatalize(_deadId, _tokenId, msg.sender); }
function fatality(uint256 _deadId, uint256 _tokenId) external { require( !isPetSafe(_deadId) && tx.gasprice <= gas && //inspired by NFT GAS by 0Xmons petDead[_deadId] == false, "The PET has to be starved or gas below ${gas} to claim his points" ); petScore[_tokenId] = petScore[_tokenId] + (((petScore[_deadId] * (20)) / (100))); petScore[_deadId] = 0; petDead[_deadId] = true; emit Fatalize(_deadId, _tokenId, msg.sender); }
60,461
6
// Returns the number tokens associated with an address. db Token storage to operate on. who Address to lookup.return balance Balance of address. /
function balanceOf(TokenStorage db, address who) external view returns (uint balance)
function balanceOf(TokenStorage db, address who) external view returns (uint balance)
24,147
963
// The latest sample only has a non-zero timestamp if no data was ever processed and stored in the buffer.
_require(latestTimestamp > 0, Errors.ORACLE_NOT_INITIALIZED); if (latestTimestamp <= lookUpTime) {
_require(latestTimestamp > 0, Errors.ORACLE_NOT_INITIALIZED); if (latestTimestamp <= lookUpTime) {
13,742
107
// See {IERC20-transfer}. Requirements: - `recipient` cannot be the zero address.- the caller must have a balance of at least `amount`. /
function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; }
function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; }
28,158
41
// ANTIBOT
FTPAntiBot private AntiBot; address private m_AntibotSvcAddress = 0xCD5312d086f078D1554e8813C27Cf6C9D1C3D9b3; uint256 private m_BanCount = 0;
FTPAntiBot private AntiBot; address private m_AntibotSvcAddress = 0xCD5312d086f078D1554e8813C27Cf6C9D1C3D9b3; uint256 private m_BanCount = 0;
5,228
130
// Address allowed to initialize contract
address private immutable _initializer;
address private immutable _initializer;
41,335
12
// YToken contract interface.Only the functions required for IearnAdapter contract are added.The YToken contracts is available heregithub.com/iearn-finance/itoken/tree/master/contracts. /
interface YToken { function token() external view returns (address); function getPricePerFullShare() external view returns (uint256); }
interface YToken { function token() external view returns (address); function getPricePerFullShare() external view returns (uint256); }
37,075
2
// transaction base gas
uint128 public baseGas=21000;
uint128 public baseGas=21000;
75,127
7
// map each NFT tokenId to a Set of Wearable(s) defined by the NFT(s) owner
mapping(uint256 => Set) public tokenIdToSet;
mapping(uint256 => Set) public tokenIdToSet;
3,407
4
// RNG Request Timeout.In fact, this is really a "complete award" timeout./ If the rng completes the award can still be cancelled.
uint32 public rngRequestTimeout;
uint32 public rngRequestTimeout;
20,966
127
// To Treasury
uint256 treasuryAmount = swappedLonAmount.mul(_feeToken.RFactor).div(100); if (treasuryAmount > 0) { IERC20(LON_TOKEN_ADDR).safeTransfer(treasury, treasuryAmount); }
uint256 treasuryAmount = swappedLonAmount.mul(_feeToken.RFactor).div(100); if (treasuryAmount > 0) { IERC20(LON_TOKEN_ADDR).safeTransfer(treasury, treasuryAmount); }
33,485
8
// Return the rewards you can receive. Returns 0 if the reward has not been confirmed. /
function reward(address account) external view returns (uint256);
function reward(address account) external view returns (uint256);
24,154
48
// quotes here ?
event PokerPaid(uint256 Round, uint256 AmountWon, address Who, string Quote, string Name, uint8[6] WinHand); event JackpotPaid(uint256 Round, uint256 Amount, address Who, string Quote, string Name); event NewRound(); bool public EditMode; bool public SetEditMode;
event PokerPaid(uint256 Round, uint256 AmountWon, address Who, string Quote, string Name, uint8[6] WinHand); event JackpotPaid(uint256 Round, uint256 Amount, address Who, string Quote, string Name); event NewRound(); bool public EditMode; bool public SetEditMode;
42,981
20
// execute the liquidations
constants.dolomiteMargin.operate( accounts, constructActionsArray(constants, cache, accounts, actions) //solium-disable-line arg-overflow );
constants.dolomiteMargin.operate( accounts, constructActionsArray(constants, cache, accounts, actions) //solium-disable-line arg-overflow );
50,845
121
// Change SIGNERS_CONTROLLER or STAKER_CONTROLLER need ALL STAKER
setRequirement(LABEL_CODE_STAKER, WALLET_FLAG_ALL, uint8(-1)); // ALL signable
setRequirement(LABEL_CODE_STAKER, WALLET_FLAG_ALL, uint8(-1)); // ALL signable
18,794
226
// Get the fungible balance record for the given wallet, type, currency/ log entry index/wallet The address of the concerned wallet/_type The balance type/currencyCt The address of the concerned currency contract (address(0) == ETH)/currencyId The ID of the concerned currency (0 for ETH and ERC20)/index The concerned record index/ return The balance record
function fungibleRecordByIndex(address wallet, bytes32 _type, address currencyCt, uint256 currencyId, uint256 index) public view returns (int256 amount, uint256 blockNumber)
function fungibleRecordByIndex(address wallet, bytes32 _type, address currencyCt, uint256 currencyId, uint256 index) public view returns (int256 amount, uint256 blockNumber)
29,048
3
// parts[1] e parts[2]
if (greatness > 900) { parts[1] = "Text 1 un"; uint serial = 1000000000 + rand % 100000000; parts[3] = toString (serial); } else if (greatness > 500) {
if (greatness > 900) { parts[1] = "Text 1 un"; uint serial = 1000000000 + rand % 100000000; parts[3] = toString (serial); } else if (greatness > 500) {
24,246