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
|
---|---|---|---|---|
14 | // See {IERC20-transferFrom}. Emits an {Approval} event indicating the updated allowance. This is notrequired by the EIP. See the note at the beginning of {ERC20}. / | function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
| function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
| 29,859 |
8 | // mostly helps with function identification if disassembled | logCall(numcalls, numcallsinternal);
| logCall(numcalls, numcallsinternal);
| 41,146 |
20 | // The maximum tick that may be passed to getSqrtRatioAtTick computed from log base 1.0001 of 2128 | int24 internal constant MAX_TICK = -MIN_TICK;
| int24 internal constant MAX_TICK = -MIN_TICK;
| 4,351 |
5 | // Event to emit upon purchase | event mint(uint256 id, address mintFrom, address mintTo);
constructor(
string memory name,
string memory symbol,
uint256 price,
address payable _indecent,
address payable _tdb,
address payable _bf
)
| event mint(uint256 id, address mintFrom, address mintTo);
constructor(
string memory name,
string memory symbol,
uint256 price,
address payable _indecent,
address payable _tdb,
address payable _bf
)
| 25,811 |
164 | // payout for claiming | function payouts(address payable _to, uint256 _amount, address token) external onlyOperator {
require(_to != address(0),"_to is zero");
if (token != ETHEREUM) {
IERC20(token).safeTransfer(_to, _amount);
} else {
_to.transfer(_amount);
}
emit ePayouts(_to, _amount);
}
| function payouts(address payable _to, uint256 _amount, address token) external onlyOperator {
require(_to != address(0),"_to is zero");
if (token != ETHEREUM) {
IERC20(token).safeTransfer(_to, _amount);
} else {
_to.transfer(_amount);
}
emit ePayouts(_to, _amount);
}
| 77,478 |
50 | // TODO: What should we do with this? Should it be allowed? Should it be a canary? | function echidna_price() public view returns(bool) {
uint price = priceFeedTestnet.getPrice();
if (price == 0) {
return false;
}
// Uncomment to check that the condition is meaningful
//else return false;
return true;
}
| function echidna_price() public view returns(bool) {
uint price = priceFeedTestnet.getPrice();
if (price == 0) {
return false;
}
// Uncomment to check that the condition is meaningful
//else return false;
return true;
}
| 18,693 |
5 | // transfer the tokens to this contract | bool success = SOV.transferFrom(_sender, address(this), _amount);
require(success);
| bool success = SOV.transferFrom(_sender, address(this), _amount);
require(success);
| 51,379 |
6 | // What percentage does the smart conract take as a processing fee | uint constant internal HOUSE_EDGE_PERCENT = 1;
| uint constant internal HOUSE_EDGE_PERCENT = 1;
| 17,835 |
34 | // Linearly interpolate between last updated price (with corresponding timestamp) and current price (with current timestamp) to imply price at the timestamp we are updating | return _currentPrice.mul(_updateInterval)
.add(_previousLoggedDataPoint.mul(_timeFromExpectedUpdate))
.div(timeFromLastUpdate);
| return _currentPrice.mul(_updateInterval)
.add(_previousLoggedDataPoint.mul(_timeFromExpectedUpdate))
.div(timeFromLastUpdate);
| 13,937 |
157 | // Safety function to be able to recover tokens if they are sent to this contract by mistake / | function withdrawTokensTo(address erc20Address, address recipient) external onlyOwner {
uint256 tokenBalance = IERC20(erc20Address).balanceOf(address(this));
require(tokenBalance > 0, "No tokens");
IERC20(erc20Address).safeTransfer(recipient, tokenBalance);
}
| function withdrawTokensTo(address erc20Address, address recipient) external onlyOwner {
uint256 tokenBalance = IERC20(erc20Address).balanceOf(address(this));
require(tokenBalance > 0, "No tokens");
IERC20(erc20Address).safeTransfer(recipient, tokenBalance);
}
| 2,377 |
44 | // ========== FARM CALLBACKS ========== // onDeposit() is used to control fees and accessibility instead having animplementation in each farm contract Deposit is only allowed, if farm is open and not not paused._amount tokens the user wants to deposit return fee returns the deposit fee (1e18 factor) / | function onDeposit(uint256 _amount)
external
view
override
returns (uint256 fee)
| function onDeposit(uint256 _amount)
external
view
override
returns (uint256 fee)
| 59,926 |
13 | // function to check if the crowdsale has ended/self Stored crowdsale from crowdsale contract/ return success | function crowdsaleEnded(CrowdsaleStorage storage self) public view returns (bool) {
return now > self.endTime;
}
| function crowdsaleEnded(CrowdsaleStorage storage self) public view returns (bool) {
return now > self.endTime;
}
| 49,635 |
40 | // Take tokens out from circulation | totalSupply = totalSupply.sub(value);
totalUpgraded = totalUpgraded.add(value);
| totalSupply = totalSupply.sub(value);
totalUpgraded = totalUpgraded.add(value);
| 32,746 |
68 | // Execute hold and keep open. / | function executeHoldAndKeepOpen(address token, bytes32 holdId, uint256 value, bytes32 secret) external returns (bool) {
return _executeHold(
token,
holdId,
msg.sender,
value,
secret,
true
);
}
| function executeHoldAndKeepOpen(address token, bytes32 holdId, uint256 value, bytes32 secret) external returns (bool) {
return _executeHold(
token,
holdId,
msg.sender,
value,
secret,
true
);
}
| 7,120 |
36 | // Extended to 36 months | endTime = endTimeExtended;
extended = true;
MiningExtended(endTime, swapTime, swapEndTime);
| endTime = endTimeExtended;
extended = true;
MiningExtended(endTime, swapTime, swapEndTime);
| 24,098 |
152 | // returns (uint nodeIndex) | {
| {
| 57,235 |
278 | // Determine whether a sender delegate is authorizedauthorizer address Address doing the authorizationdelegate address Address being authorized return bool True if a delegate is authorized to send/ | function isSenderAuthorized(
address authorizer,
address delegate
| function isSenderAuthorized(
address authorizer,
address delegate
| 26,362 |
7 | // Sends a token to the specified addr, works with Eth also/If amount is type(uint).max it will send proxy balance/If weth address is set it will unwrap by default/_tokenAddr Address of token, use 0xEeee... for eth/_to Where the tokens are sent/_amount Amount of tokens, can be type(uint).max | function _sendToken(address _tokenAddr, address _to, uint _amount) internal returns (uint) {
if (_amount == type(uint256).max) {
_amount = _tokenAddr.getBalance(address(this));
}
// unwrap and send eth
if (_tokenAddr == TokenUtils.WETH_ADDR) {
TokenUtils.withdrawWeth(_amount);
_tokenAddr = TokenUtils.ETH_ADDR;
}
_tokenAddr.withdrawTokens(_to, _amount);
return _amount;
}
| function _sendToken(address _tokenAddr, address _to, uint _amount) internal returns (uint) {
if (_amount == type(uint256).max) {
_amount = _tokenAddr.getBalance(address(this));
}
// unwrap and send eth
if (_tokenAddr == TokenUtils.WETH_ADDR) {
TokenUtils.withdrawWeth(_amount);
_tokenAddr = TokenUtils.ETH_ADDR;
}
_tokenAddr.withdrawTokens(_to, _amount);
return _amount;
}
| 53,756 |
3 | // 00b3e97c6c661eabfda5dc35ede44a934c3aa990a005d4a73cdcaf8652686661ffb247222a65bcd8bab5b5bf94aeec02246c6fae4accc5913846ae95deba8206c33e06ba914f7b0be0171aeefe0d1397b2d8d43afe9596b1d95409cb9883a4c9ca566b18ccf847d03d9b83c446e4c3de81dff7c6ebd65ba77b3dcba58487053963d222425f184e41a7354c627506ce375046426f87544b204dfdb627aafa1b716c134eeb9cc36c90d0b70e3b8b48250a178907d2b54654af4176209d15a6631c4ca48f08c81b3aa7cb1c9129ee186c9e81f40066f797921603011ed644614faad15508406840180bab3935e35a2d53b2c038da69cb190644239197317b5a6e9e75 | if (msg.sender != owner) throw;
CAmodulus = _CAmodulus;
| if (msg.sender != owner) throw;
CAmodulus = _CAmodulus;
| 10,557 |
3 | // The total number of tokens minted by address. | mapping(address => uint256) _totalMintedByUser;
| mapping(address => uint256) _totalMintedByUser;
| 37,358 |
112 | // AlpacaVaultAdapterWithIndirection//A vault adapter implementation which wraps a vesper vault. | contract VesperLinkVaultAdapterWithIndirection is VesperLinkVaultAdapter {
using SafeERC20 for IDetailedERC20;
using SafeMath for uint256;
constructor(IVesperPool _vault, IPoolRewards _vspPool, address _admin,
IUniswapV2Router02 _uniV2Router, IDetailedERC20 _vesperToken)
VesperLinkVaultAdapter(_vault,_vspPool,_admin,_uniV2Router,_vesperToken) public {
}
/// @dev Sends vault tokens and alpaca token to the recipient
///
/// This function reverts if the caller is not the admin.
///
/// @param _recipient the account to send the tokens to.
/// @param _amount the amount of tokens to send.
function indirectWithdraw(address _recipient, uint256 _amount) external onlyAdmin {
vault.transfer(_recipient, _tokensToShares(_amount));
// claim vsp token from staking pool
vspPool.claimReward(address(this));
// transfer vsp to recipient
vesperToken.transfer(_recipient, vesperToken.balanceOf(address(this)));
}
} | contract VesperLinkVaultAdapterWithIndirection is VesperLinkVaultAdapter {
using SafeERC20 for IDetailedERC20;
using SafeMath for uint256;
constructor(IVesperPool _vault, IPoolRewards _vspPool, address _admin,
IUniswapV2Router02 _uniV2Router, IDetailedERC20 _vesperToken)
VesperLinkVaultAdapter(_vault,_vspPool,_admin,_uniV2Router,_vesperToken) public {
}
/// @dev Sends vault tokens and alpaca token to the recipient
///
/// This function reverts if the caller is not the admin.
///
/// @param _recipient the account to send the tokens to.
/// @param _amount the amount of tokens to send.
function indirectWithdraw(address _recipient, uint256 _amount) external onlyAdmin {
vault.transfer(_recipient, _tokensToShares(_amount));
// claim vsp token from staking pool
vspPool.claimReward(address(this));
// transfer vsp to recipient
vesperToken.transfer(_recipient, vesperToken.balanceOf(address(this)));
}
} | 3,701 |
2 | // event sent when the random number is generated by the VRF | event RandomNumberCreated(
uint256 indexed idFromMetawin,
uint256 randomNumber,
uint256 normalizedRandomNumber
);
| event RandomNumberCreated(
uint256 indexed idFromMetawin,
uint256 randomNumber,
uint256 normalizedRandomNumber
);
| 31,820 |
2 | // Hashed rotation key data / | bytes internal _hashedRotationKeyData;
| bytes internal _hashedRotationKeyData;
| 45,095 |
115 | // Overrides adding new minters so that only governance can authorized them./ | function addMinter(address _minter) public onlyGovernance {
super.addMinter(_minter);
}
| function addMinter(address _minter) public onlyGovernance {
super.addMinter(_minter);
}
| 11,140 |
179 | // Get token Ids of all tokens owned by _owner | function walletOfOwner(address _owner)
external
view
returns (uint256[] memory)
| function walletOfOwner(address _owner)
external
view
returns (uint256[] memory)
| 6,380 |
10 | // Assign winner | uint index = randomness % riders.length;
lastWinner = riders[index];
| uint index = randomness % riders.length;
lastWinner = riders[index];
| 51,962 |
4 | // Keep track of used signatures to prevent reuse before expiration. | mapping(address => mapping(bytes32 => bool)) private _sigUsage;
| mapping(address => mapping(bytes32 => bool)) private _sigUsage;
| 17,573 |
6 | // Allow an address to purchase multiple challenges/ Buying an challenge typically mints it, it will throw if an challenge has reached its maximum quantity/ _to Address to send the challenges once purchased/ _challengeIds The identifiers of the challenges to be purchased/ _quantities The quantities of each challenge to be bought | function purchaseChallengesWithPrtcle(
address _to,
uint256[] calldata _challengeIds,
uint256[] calldata _quantities
| function purchaseChallengesWithPrtcle(
address _to,
uint256[] calldata _challengeIds,
uint256[] calldata _quantities
| 12,951 |
77 | // NOT synchronized!!! / | {
var fn = matchingEnabled ? _offeru : super.offer;
return fn(pay_amt, pay_gem, buy_amt, buy_gem);
}
| {
var fn = matchingEnabled ? _offeru : super.offer;
return fn(pay_amt, pay_gem, buy_amt, buy_gem);
}
| 39,527 |
3 | // StabilityBoard | rates.grantPermission(stabilityBoardProxyAddress, "StabilityBoard");
feeAccount.grantPermission(stabilityBoardProxyAddress, "StabilityBoard");
interestEarnedAccount.grantPermission(stabilityBoardProxyAddress, "StabilityBoard");
tokenAEur.grantPermission(stabilityBoardProxyAddress, "StabilityBoard");
augmintReserves.grantPermission(stabilityBoardProxyAddress, "StabilityBoard");
monetarySupervisor.grantPermission(stabilityBoardProxyAddress, "StabilityBoard");
loanManager.grantPermission(stabilityBoardProxyAddress, "StabilityBoard");
locker.grantPermission(stabilityBoardProxyAddress, "StabilityBoard");
exchange.grantPermission(stabilityBoardProxyAddress, "StabilityBoard");
| rates.grantPermission(stabilityBoardProxyAddress, "StabilityBoard");
feeAccount.grantPermission(stabilityBoardProxyAddress, "StabilityBoard");
interestEarnedAccount.grantPermission(stabilityBoardProxyAddress, "StabilityBoard");
tokenAEur.grantPermission(stabilityBoardProxyAddress, "StabilityBoard");
augmintReserves.grantPermission(stabilityBoardProxyAddress, "StabilityBoard");
monetarySupervisor.grantPermission(stabilityBoardProxyAddress, "StabilityBoard");
loanManager.grantPermission(stabilityBoardProxyAddress, "StabilityBoard");
locker.grantPermission(stabilityBoardProxyAddress, "StabilityBoard");
exchange.grantPermission(stabilityBoardProxyAddress, "StabilityBoard");
| 14,474 |
33 | // https:github.com/ethereum-optimism/optimism/blob/eaa371a0184b56b7ca6d9eb9cb0a2b78b2ccd864/op-bindings/predeploys/addresses.goL6-L21 | vm.assume(addr < address(0x4200000000000000000000000000000000000000) || addr > address(0x4200000000000000000000000000000000000800));
| vm.assume(addr < address(0x4200000000000000000000000000000000000000) || addr > address(0x4200000000000000000000000000000000000800));
| 30,409 |
167 | // For collecting minted Hedron data | struct Archive {
string hedronType;
uint256 tokenId;
}
| struct Archive {
string hedronType;
uint256 tokenId;
}
| 64,550 |
118 | // private function to allocate DYP to be disbursed calculated according to time passed | function disburseTokens() private {
uint amount = getPendingDisbursement();
if (contractBalance < amount) {
amount = contractBalance;
}
if (amount == 0 || totalTokens == 0) return;
tokensToBeSwapped = tokensToBeSwapped.add(amount);
contractBalance = contractBalance.sub(amount);
lastDisburseTime = now;
}
| function disburseTokens() private {
uint amount = getPendingDisbursement();
if (contractBalance < amount) {
amount = contractBalance;
}
if (amount == 0 || totalTokens == 0) return;
tokensToBeSwapped = tokensToBeSwapped.add(amount);
contractBalance = contractBalance.sub(amount);
lastDisburseTime = now;
}
| 9,119 |
20 | // Record the supply cap of each item being created in the group. | uint256 fullCollectionSize = 0;
for (uint256 i = 0; i < groupSize; i++) {
uint256 itemInitialSupply = initialSupply[i];
uint256 itemMaximumSupply = _maximumSupply[i];
fullCollectionSize = fullCollectionSize.add(itemMaximumSupply);
require(itemMaximumSupply > 0,
"You cannot create an item which is never mintable.");
require(itemInitialSupply <= itemMaximumSupply,
"You cannot create an item which exceeds its own supply cap.");
| uint256 fullCollectionSize = 0;
for (uint256 i = 0; i < groupSize; i++) {
uint256 itemInitialSupply = initialSupply[i];
uint256 itemMaximumSupply = _maximumSupply[i];
fullCollectionSize = fullCollectionSize.add(itemMaximumSupply);
require(itemMaximumSupply > 0,
"You cannot create an item which is never mintable.");
require(itemInitialSupply <= itemMaximumSupply,
"You cannot create an item which exceeds its own supply cap.");
| 40,387 |
178 | // Private function to remove a token from this extension"s token tracking data structures.This has O(1) time complexity, but alters the order of the _allTokens array. tokenId uint256 ID of the token to be removed from the tokens list / | function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
// To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = _allTokens.length - 1;
uint256 tokenIndex = _allTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
// rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
// an "if" statement (like in _removeTokenFromOwnerEnumeration)
uint256 lastTokenId = _allTokens[lastTokenIndex];
_allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token"s index
// This also deletes the contents at the last position of the array
delete _allTokensIndex[tokenId];
_allTokens.pop();
}
| function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
// To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = _allTokens.length - 1;
uint256 tokenIndex = _allTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
// rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
// an "if" statement (like in _removeTokenFromOwnerEnumeration)
uint256 lastTokenId = _allTokens[lastTokenIndex];
_allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token"s index
// This also deletes the contents at the last position of the array
delete _allTokensIndex[tokenId];
_allTokens.pop();
}
| 18,767 |
231 | // Remove the token from the owner list | for (uint i = 0; i < ownerToToken[from].length; i++) {
if (ownerToToken[from][i] == tokenId) {
ownerToToken[from][i] = ownerToToken[from][ownerToToken[from].length - 1];
ownerToToken[from].pop();
ownerToToken[to].push(tokenId);
| for (uint i = 0; i < ownerToToken[from].length; i++) {
if (ownerToToken[from][i] == tokenId) {
ownerToToken[from][i] = ownerToToken[from][ownerToToken[from].length - 1];
ownerToToken[from].pop();
ownerToToken[to].push(tokenId);
| 49,458 |
40 | // / | return (
| return (
| 21,368 |
22 | // Allows users to borrow a specific `amount` of the reserve underlying asset, provided that the borroweralready supplied enough collateral, or he was given enough allowance by a credit delegator on thecorresponding debt token (StableDebtToken or VariableDebtToken)- E.g. User borrows 100 USDC passing as `onBehalfOf` his own address, receiving the 100 USDC in his walletand 100 stable/variable debt tokens, depending on the `interestRateMode` asset The address of the underlying asset to borrow amount The amount to be borrowed interestRateMode The interest rate mode at which the user wants to borrow: 1 for Stable, 2 for Variable referralCode The code used to | function borrow(
| function borrow(
| 18,731 |
0 | // ========== CONSTANT VARIABLES ========== // ========== STATE VARIABLES ========== // ========== EVENTS ========== // ========== MODIFIERS ========== / | modifier accrue {
IStrategyVBNB(strategyVBNB).updateBalance();
if (now > lastAccrueTime) {
uint interest = pendingInterest();
glbDebtVal = glbDebtVal.add(interest);
reservedBNB = reservedBNB.add(interest.mul(config.getReservePoolBps()).div(10000));
lastAccrueTime = now;
}
_;
IStrategyVBNB(strategyVBNB).updateBalance();
}
| modifier accrue {
IStrategyVBNB(strategyVBNB).updateBalance();
if (now > lastAccrueTime) {
uint interest = pendingInterest();
glbDebtVal = glbDebtVal.add(interest);
reservedBNB = reservedBNB.add(interest.mul(config.getReservePoolBps()).div(10000));
lastAccrueTime = now;
}
_;
IStrategyVBNB(strategyVBNB).updateBalance();
}
| 37,360 |
228 | // abusing underflow here =_= | for (uint8 i = 15; i < 255 ; i -= 1) {
uint8 _byte = uint8(_b >> (i * 8));
second |= byteHex(_byte);
if (i != 0) {
second <<= 16;
}
| for (uint8 i = 15; i < 255 ; i -= 1) {
uint8 _byte = uint8(_b >> (i * 8));
second |= byteHex(_byte);
if (i != 0) {
second <<= 16;
}
| 50,736 |
20 | // Emitted when new token is breed from same owners. / | event breedSelf(
address indexed selfAddress, // msg.sender address
uint256 motherTokenId,
uint256 donorTokenId,
string tokenURI, // child seed uri
uint256 newTokenId, // new minted child id
uint256 sktFeePrice // fee to skt wallet
);
| event breedSelf(
address indexed selfAddress, // msg.sender address
uint256 motherTokenId,
uint256 donorTokenId,
string tokenURI, // child seed uri
uint256 newTokenId, // new minted child id
uint256 sktFeePrice // fee to skt wallet
);
| 24,995 |
8 | // create a new functionSelectors array for selector | facets_[numFacets].facetAddress = facetAddress_;
facets_[numFacets].functionSelectors = new bytes4[](selectorCount);
facets_[numFacets].functionSelectors[0] = selector;
numFacetSelectors[numFacets] = 1;
numFacets++;
| facets_[numFacets].facetAddress = facetAddress_;
facets_[numFacets].functionSelectors = new bytes4[](selectorCount);
facets_[numFacets].functionSelectors[0] = selector;
numFacetSelectors[numFacets] = 1;
numFacets++;
| 5,837 |
196 | // This will pay DAO 10% of the initial sale. ============================================================================= | if(daoShare > 0){
(bool dao, ) = payable(daoAccount).call{value: (address(this).balance * daoShare) / 100}("");
| if(daoShare > 0){
(bool dao, ) = payable(daoAccount).call{value: (address(this).balance * daoShare) / 100}("");
| 11,836 |
92 | // Privileged function to de authorize an address/who The address to remove authorization from | function deauthorize(address who) external onlyOwner {
authorized[who] = false;
}
| function deauthorize(address who) external onlyOwner {
authorized[who] = false;
}
| 53,654 |
19 | // All new recipients must have shares | require(shares > 0);
outletShares.push(shares);
uint256 outlet = outletShares.length-1;
outletRecipient[outlet] = newRecipient;
outletLookup[newRecipient] = outlet;
outletController[outlet][owner()] = true;
| require(shares > 0);
outletShares.push(shares);
uint256 outlet = outletShares.length-1;
outletRecipient[outlet] = newRecipient;
outletLookup[newRecipient] = outlet;
outletController[outlet][owner()] = true;
| 39,008 |
3 | // compose a set of the same child ERC721s into a KODA tokens/Caller must own both KODA and child NFT tokens | function composeNFTsIntoKodaTokens(uint256[] calldata _kodaTokenIds, address _nft, uint256[] calldata _nftTokenIds) external {
uint256 totalKodaTokens = _kodaTokenIds.length;
require(totalKodaTokens > 0 && totalKodaTokens == _nftTokenIds.length, "Invalid list");
IERC721 nftContract = IERC721(_nft);
for (uint i = 0; i < totalKodaTokens; i++) {
uint256 _kodaTokenId = _kodaTokenIds[i];
uint256 _nftTokenId = _nftTokenIds[i];
require(
IERC721(address(this)).ownerOf(_kodaTokenId) == nftContract.ownerOf(_nftTokenId),
"Owner mismatch"
);
kodaTokenComposedNFT[_kodaTokenId] = ComposedNFT(_nft, _nftTokenId);
composedNFTsToKodaToken[_nft][_nftTokenId] = _kodaTokenId;
nftContract.transferFrom(_msgSender(), address(this), _nftTokenId);
emit ReceivedChild(_msgSender(), _kodaTokenId, _nft, _nftTokenId);
}
}
| function composeNFTsIntoKodaTokens(uint256[] calldata _kodaTokenIds, address _nft, uint256[] calldata _nftTokenIds) external {
uint256 totalKodaTokens = _kodaTokenIds.length;
require(totalKodaTokens > 0 && totalKodaTokens == _nftTokenIds.length, "Invalid list");
IERC721 nftContract = IERC721(_nft);
for (uint i = 0; i < totalKodaTokens; i++) {
uint256 _kodaTokenId = _kodaTokenIds[i];
uint256 _nftTokenId = _nftTokenIds[i];
require(
IERC721(address(this)).ownerOf(_kodaTokenId) == nftContract.ownerOf(_nftTokenId),
"Owner mismatch"
);
kodaTokenComposedNFT[_kodaTokenId] = ComposedNFT(_nft, _nftTokenId);
composedNFTsToKodaToken[_nft][_nftTokenId] = _kodaTokenId;
nftContract.transferFrom(_msgSender(), address(this), _nftTokenId);
emit ReceivedChild(_msgSender(), _kodaTokenId, _nft, _nftTokenId);
}
}
| 45,416 |
21 | // Approve and then communicate the approved contract in a single tx // Сall the receiveApproval function on the contract you want to be notified. // This crafts the function signature manually so one doesn't have to include a contract in here just for this. // receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData) // it is assumed when one does this that the call should succeed, otherwise one would use vanilla approve instead. / | function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
| function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
| 18,338 |
225 | // Unpauses token transfers / | function unpause() external onlyOwners {
_unpause();
}
| function unpause() external onlyOwners {
_unpause();
}
| 15,680 |
0 | // Fired when the throne is taken by someone / | event ThroneTaken(address prevOwner, address newOwner, uint32 prevOwnerTimeSpent, uint32 round, uint256 timestamp);
event WinnerChosen(address winner, uint256 prize, uint32 totalTimeSpent, uint32 round, uint32 totalPlayers, uint256 timestamp);
event TimeBoosterUsed(address user, uint8 bonusUsed, uint32 round, uint256 timestamp);
| event ThroneTaken(address prevOwner, address newOwner, uint32 prevOwnerTimeSpent, uint32 round, uint256 timestamp);
event WinnerChosen(address winner, uint256 prize, uint32 totalTimeSpent, uint32 round, uint32 totalPlayers, uint256 timestamp);
event TimeBoosterUsed(address user, uint8 bonusUsed, uint32 round, uint256 timestamp);
| 29,724 |
302 | // Performs a deep copy of a byte array onto another byte array of greater than or equal length./dest Byte array that will be overwritten with source bytes./source Byte array to copy onto dest bytes. | function deepCopyBytes(
bytes memory dest,
bytes memory source
)
internal
pure
{
uint256 sourceLen = source.length;
| function deepCopyBytes(
bytes memory dest,
bytes memory source
)
internal
pure
{
uint256 sourceLen = source.length;
| 8,824 |
35 | // make the swap | arcadiumSwapRouter.swapExactTokensForTokensSupportingFeeOnTransferTokens(
totalTokenBalance,
0, // accept any amount of tokens
path,
address(this),
block.timestamp
)
| arcadiumSwapRouter.swapExactTokensForTokensSupportingFeeOnTransferTokens(
totalTokenBalance,
0, // accept any amount of tokens
path,
address(this),
block.timestamp
)
| 33,735 |
33 | // XUSD AlphaHomora Strategy Investment strategy for investing stablecoins via AlphaHomora/CREAM XUSD.fi Inc / | import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { IERC20, InitializableAbstractStrategy } from "../utils/InitializableAbstractStrategy.sol";
import { IVault } from "../interfaces/IVault.sol";
import { ICERC20 } from "../interfaces/alphaHomora/ICERC20.sol";
import { ISafeBox } from "../interfaces/alphaHomora/ISafeBox.sol";
import { IAlphaIncentiveDistributor } from "../interfaces/alphaHomora/IAlphaIncentiveDistributor.sol";
contract AlphaHomoraStrategy is InitializableAbstractStrategy {
using SafeERC20 for IERC20;
address[] public incentiveDistributorAddresses;
mapping(address => bytes32[]) internal _proofs;
mapping(address => uint256) internal _amounts;
function initialize(
address _platformAddress, // dead
address _vaultAddress,
address[] calldata _rewardTokenAddresses, // [ALPHA, WAVAX]
address[] calldata _assets,
address[] calldata _pTokens,
address[] calldata _incentiveDistributorAddresses // [ALPHAcontrollerAddr, WAVAXcontrollerAddr]
) external onlyGovernor initializer {
require(
_rewardTokenAddresses.length ==
_incentiveDistributorAddresses.length,
"not 1:1 rewards-to-incentives"
);
incentiveDistributorAddresses = _incentiveDistributorAddresses;
InitializableAbstractStrategy._initialize(
_platformAddress,
_vaultAddress,
_rewardTokenAddresses,
_assets,
_pTokens
);
}
event SkippedWithdrawal(address asset, uint256 amount);
/**
* @dev Collect accumulated WAVAX+ALPHA and send to Vault.
*/
function collectRewardTokens() external override onlyVault nonReentrant {
for (uint256 i = 0; i < rewardTokenAddresses.length; i++) {
IAlphaIncentiveDistributor _incentiveDistributor = IAlphaIncentiveDistributor(
incentiveDistributorAddresses[i]
);
require(_incentiveDistributor.token() == rewardTokenAddresses[i]);
uint256 _amount = _amounts[rewardTokenAddresses[i]];
if (_amount == 0) {
continue;
}
bytes32[] memory _proof = _proofs[rewardTokenAddresses[i]];
uint256 _claimed = _incentiveDistributor.claimed(address(this));
if (_claimed < _amount) {
/* Claim _amount - _claimed reward tokens */
_incentiveDistributor.claim(address(this), _amount, _proof);
/* // Transfer rewards to Vault */
IERC20 rewardToken = IERC20(rewardTokenAddresses[i]);
uint256 balance = rewardToken.balanceOf(address(this));
emit RewardTokenCollected(
vaultAddress,
rewardTokenAddresses[i],
balance
);
rewardToken.safeTransfer(vaultAddress, balance);
}
}
}
/**
* @dev Deposit asset into AlphaHomora
* @param _asset Address of asset to deposit
* @param _amount Amount of asset to deposit
*/
function deposit(address _asset, uint256 _amount)
external
override
onlyVault
nonReentrant
{
_deposit(_asset, _amount);
}
/**
* @dev Deposit asset into AlphaHomorax
* @param _asset Address of asset to deposit
* @param _amount Amount of asset to deposit
*/
function _deposit(address _asset, uint256 _amount) internal {
require(_amount > 0, "Must deposit something");
ISafeBox safeBox = _getSafeBoxFor(_asset);
emit Deposit(_asset, address(safeBox), _amount);
safeBox.deposit(_amount);
}
/**
* @dev Deposit the entire balance of any supported asset into AlphaHomora
*/
function depositAll() external override onlyVault nonReentrant {
for (uint256 i = 0; i < assetsMapped.length; i++) {
uint256 balance = IERC20(assetsMapped[i]).balanceOf(address(this));
if (balance > 0) {
_deposit(assetsMapped[i], balance);
}
}
}
/**
* @dev Withdraw asset from AlphaHomora
* @param _recipient Address to receive withdrawn asset
* @param _asset Address of asset to withdraw
* @param _amount Amount of asset to withdraw
*/
function withdraw(
address _recipient,
address _asset,
uint256 _amount
) external override onlyVault nonReentrant {
require(_amount > 0, "Must withdraw something");
require(_recipient != address(0), "Must specify recipient");
ISafeBox safeBox = _getSafeBoxFor(_asset);
ICERC20 cToken = _getCTokenFor(_asset);
uint256 cTokensToRedeem = _convertUnderlyingToCToken(cToken, _amount);
emit Withdrawal(_asset, address(safeBox), cTokensToRedeem);
if (cTokensToRedeem == 0) {
emit SkippedWithdrawal(_asset, _amount);
return;
}
emit Withdrawal(_asset, address(cToken.underlying()), _amount);
uint256 balanceBefore = IERC20(_asset).balanceOf(address(this));
safeBox.withdraw(cTokensToRedeem);
uint256 balanceAfter = IERC20(_asset).balanceOf(address(this));
require(
_amount <= balanceAfter - balanceBefore,
"Did not withdraw enough"
);
IERC20(_asset).safeTransfer(_recipient, _amount);
}
/**
* @dev Remove all assets from platform and send all of that asset to Vault contract.
*/
function withdrawAll() external override onlyVaultOrGovernor nonReentrant {
for (uint256 i = 0; i < assetsMapped.length; i++) {
IERC20 asset = IERC20(assetsMapped[i]);
ISafeBox safeBox = _getSafeBoxFor(assetsMapped[i]);
ICERC20 cToken = _getCTokenFor(assetsMapped[i]);
uint256 balance = cToken.balanceOf(address(this));
// Redeem entire balance of safeBox
if (balance > 0) {
safeBox.withdraw(balance);
// Transfer entire balance to Vault, including any already held
asset.safeTransfer(
vaultAddress,
asset.balanceOf(address(this))
);
}
}
}
/**
* @dev Get the total asset value held in the platform
* This includes any interest that was generated since depositing
* CREAM exchange rate between the cToken and asset gradually increases,
* causing the cToken to be worth more corresponding asset.
* @param _asset Address of the asset
* @return balance Total value of the asset in the platform
*/
function checkBalance(address _asset)
external
view
override
returns (uint256 balance)
{
// Balance is always with token cToken decimals
address safeBoxAddr = assetToPToken[_asset];
require(safeBoxAddr != address(0));
ISafeBox _safeBox = _getSafeBoxFor(_asset);
ICERC20 _cToken = _safeBox.cToken();
balance = _checkBalance(safeBoxAddr, _cToken);
}
/**
* @dev Get the total asset value held in the platform
* underlying = (cTokenAmt * exchangeRate) / 1e18
* @param _cToken cToken for which to check balance
* @return balance Total value of the asset in the platform
*/
function _checkBalance(address _safeBox, ICERC20 _cToken)
internal
view
returns (uint256 balance)
{
uint256 safeBoxBalance = IERC20(_safeBox).balanceOf(address(this));
uint256 exchangeRate = _cToken.exchangeRateStored();
// e.g. 50e8*205316390724364402565641705 / 1e18 = 1.0265..e18
balance = (safeBoxBalance * exchangeRate) / 1e18;
}
/**
* @dev Returns bool indicating whether asset is supported by strategy
* @param _asset Address of the asset
*/
function supportsAsset(address _asset)
external
view
override
returns (bool)
{
return assetToPToken[_asset] != address(0);
}
/**
* @dev Approve the spending of all assets by their corresponding cToken,
* if for some reason is it necessary.
*/
function safeApproveAllTokens() external override {
uint256 assetCount = assetsMapped.length;
for (uint256 i = 0; i < assetCount; i++) {
address asset = assetsMapped[i];
address cToken = assetToPToken[asset];
// Safe approval
IERC20(asset).safeApprove(cToken, 0);
IERC20(asset).safeApprove(cToken, type(uint256).max);
}
}
/**
* @dev Internal method to respond to the addition of new asset / cTokens
* We need to approve the cToken and give it permission to spend the asset
* @param _asset Address of the asset to approve
* @param _cToken The cToken for the approval
*/
function _abstractSetPToken(address _asset, address _cToken)
internal
override
{
// Safe approval
IERC20(_asset).safeApprove(_cToken, 0);
IERC20(_asset).safeApprove(_cToken, type(uint256).max);
}
/**
* @dev Get the SafeBox token wrap ISafeBox interface for this asset.
* Fails if the SafeBbox doesn't exist in our mappings.
* @param _asset Address of the asset
* @return Corresponding SafeBox to this asset
*/
function _getSafeBoxFor(address _asset) internal view returns (ISafeBox) {
address safeBox = assetToPToken[_asset];
require(safeBox != address(0), "safeBox does not exist");
return ISafeBox(safeBox);
}
/**
* @dev Get the cToken wrapped in the ICERC20 interface for this asset.
* Fails if the cToken doesn't exist in our mappings.
* @param _asset Address of the asset
* @return Corresponding cToken to this asset
*/
function _getCTokenFor(address _asset) internal view returns (ICERC20) {
ISafeBox safeBox = _getSafeBoxFor(_asset);
return ICERC20(safeBox.cToken());
}
/**
* @dev Converts an underlying amount into cToken amount
* cTokenAmt = (underlying * 1e18) / exchangeRate
* @param _cToken cToken for which to change
* @param _underlying Amount of underlying to convert
* @return amount Equivalent amount of cTokens
*/
function _convertUnderlyingToCToken(ICERC20 _cToken, uint256 _underlying)
internal
view
returns (uint256 amount)
{
uint256 exchangeRate = _cToken.exchangeRateStored();
// e.g. 1e18*1e18 / 205316390724364402565641705 = 50e8
// e.g. 1e8*1e18 / 205316390724364402565641705 = 0.45 or 0
amount = (_underlying * 1e18) / exchangeRate;
}
/**
* @dev Sets the reward amount and merkle proof from off-chain.
* @param _rewardTokenAddress The reward token address
* @param proof the MerkleProof provided by AlphaHomora
* @param amount The accumulated (total) amount of rewards.
*/
function setProofAndAmount(
address _rewardTokenAddress,
bytes32[] calldata proof,
uint256 amount
) external onlyGovernorOrStrategist {
_proofs[_rewardTokenAddress] = proof;
_amounts[_rewardTokenAddress] = amount;
}
function getProofAndAmount(address _rewardTokenAddress)
external
view
returns (bytes32[] memory, uint256)
{
return (_proofs[_rewardTokenAddress], _amounts[_rewardTokenAddress]);
}
modifier onlyGovernorOrStrategist() {
require(
msg.sender == IVault(vaultAddress).strategistAddr() || isGovernor(),
"Caller is not the Strategist or Governor"
);
_;
}
}
| import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { IERC20, InitializableAbstractStrategy } from "../utils/InitializableAbstractStrategy.sol";
import { IVault } from "../interfaces/IVault.sol";
import { ICERC20 } from "../interfaces/alphaHomora/ICERC20.sol";
import { ISafeBox } from "../interfaces/alphaHomora/ISafeBox.sol";
import { IAlphaIncentiveDistributor } from "../interfaces/alphaHomora/IAlphaIncentiveDistributor.sol";
contract AlphaHomoraStrategy is InitializableAbstractStrategy {
using SafeERC20 for IERC20;
address[] public incentiveDistributorAddresses;
mapping(address => bytes32[]) internal _proofs;
mapping(address => uint256) internal _amounts;
function initialize(
address _platformAddress, // dead
address _vaultAddress,
address[] calldata _rewardTokenAddresses, // [ALPHA, WAVAX]
address[] calldata _assets,
address[] calldata _pTokens,
address[] calldata _incentiveDistributorAddresses // [ALPHAcontrollerAddr, WAVAXcontrollerAddr]
) external onlyGovernor initializer {
require(
_rewardTokenAddresses.length ==
_incentiveDistributorAddresses.length,
"not 1:1 rewards-to-incentives"
);
incentiveDistributorAddresses = _incentiveDistributorAddresses;
InitializableAbstractStrategy._initialize(
_platformAddress,
_vaultAddress,
_rewardTokenAddresses,
_assets,
_pTokens
);
}
event SkippedWithdrawal(address asset, uint256 amount);
/**
* @dev Collect accumulated WAVAX+ALPHA and send to Vault.
*/
function collectRewardTokens() external override onlyVault nonReentrant {
for (uint256 i = 0; i < rewardTokenAddresses.length; i++) {
IAlphaIncentiveDistributor _incentiveDistributor = IAlphaIncentiveDistributor(
incentiveDistributorAddresses[i]
);
require(_incentiveDistributor.token() == rewardTokenAddresses[i]);
uint256 _amount = _amounts[rewardTokenAddresses[i]];
if (_amount == 0) {
continue;
}
bytes32[] memory _proof = _proofs[rewardTokenAddresses[i]];
uint256 _claimed = _incentiveDistributor.claimed(address(this));
if (_claimed < _amount) {
/* Claim _amount - _claimed reward tokens */
_incentiveDistributor.claim(address(this), _amount, _proof);
/* // Transfer rewards to Vault */
IERC20 rewardToken = IERC20(rewardTokenAddresses[i]);
uint256 balance = rewardToken.balanceOf(address(this));
emit RewardTokenCollected(
vaultAddress,
rewardTokenAddresses[i],
balance
);
rewardToken.safeTransfer(vaultAddress, balance);
}
}
}
/**
* @dev Deposit asset into AlphaHomora
* @param _asset Address of asset to deposit
* @param _amount Amount of asset to deposit
*/
function deposit(address _asset, uint256 _amount)
external
override
onlyVault
nonReentrant
{
_deposit(_asset, _amount);
}
/**
* @dev Deposit asset into AlphaHomorax
* @param _asset Address of asset to deposit
* @param _amount Amount of asset to deposit
*/
function _deposit(address _asset, uint256 _amount) internal {
require(_amount > 0, "Must deposit something");
ISafeBox safeBox = _getSafeBoxFor(_asset);
emit Deposit(_asset, address(safeBox), _amount);
safeBox.deposit(_amount);
}
/**
* @dev Deposit the entire balance of any supported asset into AlphaHomora
*/
function depositAll() external override onlyVault nonReentrant {
for (uint256 i = 0; i < assetsMapped.length; i++) {
uint256 balance = IERC20(assetsMapped[i]).balanceOf(address(this));
if (balance > 0) {
_deposit(assetsMapped[i], balance);
}
}
}
/**
* @dev Withdraw asset from AlphaHomora
* @param _recipient Address to receive withdrawn asset
* @param _asset Address of asset to withdraw
* @param _amount Amount of asset to withdraw
*/
function withdraw(
address _recipient,
address _asset,
uint256 _amount
) external override onlyVault nonReentrant {
require(_amount > 0, "Must withdraw something");
require(_recipient != address(0), "Must specify recipient");
ISafeBox safeBox = _getSafeBoxFor(_asset);
ICERC20 cToken = _getCTokenFor(_asset);
uint256 cTokensToRedeem = _convertUnderlyingToCToken(cToken, _amount);
emit Withdrawal(_asset, address(safeBox), cTokensToRedeem);
if (cTokensToRedeem == 0) {
emit SkippedWithdrawal(_asset, _amount);
return;
}
emit Withdrawal(_asset, address(cToken.underlying()), _amount);
uint256 balanceBefore = IERC20(_asset).balanceOf(address(this));
safeBox.withdraw(cTokensToRedeem);
uint256 balanceAfter = IERC20(_asset).balanceOf(address(this));
require(
_amount <= balanceAfter - balanceBefore,
"Did not withdraw enough"
);
IERC20(_asset).safeTransfer(_recipient, _amount);
}
/**
* @dev Remove all assets from platform and send all of that asset to Vault contract.
*/
function withdrawAll() external override onlyVaultOrGovernor nonReentrant {
for (uint256 i = 0; i < assetsMapped.length; i++) {
IERC20 asset = IERC20(assetsMapped[i]);
ISafeBox safeBox = _getSafeBoxFor(assetsMapped[i]);
ICERC20 cToken = _getCTokenFor(assetsMapped[i]);
uint256 balance = cToken.balanceOf(address(this));
// Redeem entire balance of safeBox
if (balance > 0) {
safeBox.withdraw(balance);
// Transfer entire balance to Vault, including any already held
asset.safeTransfer(
vaultAddress,
asset.balanceOf(address(this))
);
}
}
}
/**
* @dev Get the total asset value held in the platform
* This includes any interest that was generated since depositing
* CREAM exchange rate between the cToken and asset gradually increases,
* causing the cToken to be worth more corresponding asset.
* @param _asset Address of the asset
* @return balance Total value of the asset in the platform
*/
function checkBalance(address _asset)
external
view
override
returns (uint256 balance)
{
// Balance is always with token cToken decimals
address safeBoxAddr = assetToPToken[_asset];
require(safeBoxAddr != address(0));
ISafeBox _safeBox = _getSafeBoxFor(_asset);
ICERC20 _cToken = _safeBox.cToken();
balance = _checkBalance(safeBoxAddr, _cToken);
}
/**
* @dev Get the total asset value held in the platform
* underlying = (cTokenAmt * exchangeRate) / 1e18
* @param _cToken cToken for which to check balance
* @return balance Total value of the asset in the platform
*/
function _checkBalance(address _safeBox, ICERC20 _cToken)
internal
view
returns (uint256 balance)
{
uint256 safeBoxBalance = IERC20(_safeBox).balanceOf(address(this));
uint256 exchangeRate = _cToken.exchangeRateStored();
// e.g. 50e8*205316390724364402565641705 / 1e18 = 1.0265..e18
balance = (safeBoxBalance * exchangeRate) / 1e18;
}
/**
* @dev Returns bool indicating whether asset is supported by strategy
* @param _asset Address of the asset
*/
function supportsAsset(address _asset)
external
view
override
returns (bool)
{
return assetToPToken[_asset] != address(0);
}
/**
* @dev Approve the spending of all assets by their corresponding cToken,
* if for some reason is it necessary.
*/
function safeApproveAllTokens() external override {
uint256 assetCount = assetsMapped.length;
for (uint256 i = 0; i < assetCount; i++) {
address asset = assetsMapped[i];
address cToken = assetToPToken[asset];
// Safe approval
IERC20(asset).safeApprove(cToken, 0);
IERC20(asset).safeApprove(cToken, type(uint256).max);
}
}
/**
* @dev Internal method to respond to the addition of new asset / cTokens
* We need to approve the cToken and give it permission to spend the asset
* @param _asset Address of the asset to approve
* @param _cToken The cToken for the approval
*/
function _abstractSetPToken(address _asset, address _cToken)
internal
override
{
// Safe approval
IERC20(_asset).safeApprove(_cToken, 0);
IERC20(_asset).safeApprove(_cToken, type(uint256).max);
}
/**
* @dev Get the SafeBox token wrap ISafeBox interface for this asset.
* Fails if the SafeBbox doesn't exist in our mappings.
* @param _asset Address of the asset
* @return Corresponding SafeBox to this asset
*/
function _getSafeBoxFor(address _asset) internal view returns (ISafeBox) {
address safeBox = assetToPToken[_asset];
require(safeBox != address(0), "safeBox does not exist");
return ISafeBox(safeBox);
}
/**
* @dev Get the cToken wrapped in the ICERC20 interface for this asset.
* Fails if the cToken doesn't exist in our mappings.
* @param _asset Address of the asset
* @return Corresponding cToken to this asset
*/
function _getCTokenFor(address _asset) internal view returns (ICERC20) {
ISafeBox safeBox = _getSafeBoxFor(_asset);
return ICERC20(safeBox.cToken());
}
/**
* @dev Converts an underlying amount into cToken amount
* cTokenAmt = (underlying * 1e18) / exchangeRate
* @param _cToken cToken for which to change
* @param _underlying Amount of underlying to convert
* @return amount Equivalent amount of cTokens
*/
function _convertUnderlyingToCToken(ICERC20 _cToken, uint256 _underlying)
internal
view
returns (uint256 amount)
{
uint256 exchangeRate = _cToken.exchangeRateStored();
// e.g. 1e18*1e18 / 205316390724364402565641705 = 50e8
// e.g. 1e8*1e18 / 205316390724364402565641705 = 0.45 or 0
amount = (_underlying * 1e18) / exchangeRate;
}
/**
* @dev Sets the reward amount and merkle proof from off-chain.
* @param _rewardTokenAddress The reward token address
* @param proof the MerkleProof provided by AlphaHomora
* @param amount The accumulated (total) amount of rewards.
*/
function setProofAndAmount(
address _rewardTokenAddress,
bytes32[] calldata proof,
uint256 amount
) external onlyGovernorOrStrategist {
_proofs[_rewardTokenAddress] = proof;
_amounts[_rewardTokenAddress] = amount;
}
function getProofAndAmount(address _rewardTokenAddress)
external
view
returns (bytes32[] memory, uint256)
{
return (_proofs[_rewardTokenAddress], _amounts[_rewardTokenAddress]);
}
modifier onlyGovernorOrStrategist() {
require(
msg.sender == IVault(vaultAddress).strategistAddr() || isGovernor(),
"Caller is not the Strategist or Governor"
);
_;
}
}
| 44,411 |
200 | // if there is nothing to swap, return | if(amount == 0)
return 0;
| if(amount == 0)
return 0;
| 5,690 |
5 | // console.log("%s %s", _currency, NATIVE_TOKEN);console.log("%s %s", _amount, msg.value); |
if (_currency == NATIVE_TOKEN) {
if (_from == address(this)) {
|
if (_currency == NATIVE_TOKEN) {
if (_from == address(this)) {
| 17,631 |
30 | // Call parents constructor with current constructors argument | contract C6_1_ParentConstructor{
uint256 public parentVal;
constructor(uint256 _parentValue){
parentVal = _parentValue;
}
}
| contract C6_1_ParentConstructor{
uint256 public parentVal;
constructor(uint256 _parentValue){
parentVal = _parentValue;
}
}
| 3,019 |
248 | // Similar to EIP20 transfer, except it handles a False result from `transferFrom` and returns an explanatory error code rather than reverting.If caller has not called `checkTransferIn`, this may revert due to insufficient balance or insufficient allowance. If caller has called `checkTransferIn` prior to this call, and it returned Error.NO_ERROR, this should not revert in normal conditions.Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value. / | function doTransferIn(address from, uint amount) internal returns (Error) {
EIP20NonStandardInterface token = EIP20NonStandardInterface(underlying);
bool result;
token.transferFrom(from, address(this), amount);
// solium-disable-next-line security/no-inline-assembly
assembly {
switch returndatasize()
case 0 { // This is a non-standard ERC-20
result := not(0) // set result to true
}
case 32 { // This is a complaint ERC-20
returndatacopy(0, 0, 32)
result := mload(0) // Set `result = returndata` of external call
}
default { // This is an excessively non-compliant ERC-20, revert.
revert(0, 0)
}
}
if (!result) {
return Error.TOKEN_TRANSFER_IN_FAILED;
}
return Error.NO_ERROR;
}
| function doTransferIn(address from, uint amount) internal returns (Error) {
EIP20NonStandardInterface token = EIP20NonStandardInterface(underlying);
bool result;
token.transferFrom(from, address(this), amount);
// solium-disable-next-line security/no-inline-assembly
assembly {
switch returndatasize()
case 0 { // This is a non-standard ERC-20
result := not(0) // set result to true
}
case 32 { // This is a complaint ERC-20
returndatacopy(0, 0, 32)
result := mload(0) // Set `result = returndata` of external call
}
default { // This is an excessively non-compliant ERC-20, revert.
revert(0, 0)
}
}
if (!result) {
return Error.TOKEN_TRANSFER_IN_FAILED;
}
return Error.NO_ERROR;
}
| 23,872 |
169 | // Check pay token | require(payTokens[_payTokenName] != ADDRESS_NULL, "not support this address pay token");
Order memory order = orderByOrderId[_nftAddress][_orderId];
| require(payTokens[_payTokenName] != ADDRESS_NULL, "not support this address pay token");
Order memory order = orderByOrderId[_nftAddress][_orderId];
| 21,833 |
285 | // return discounted price of blind aworld nft | function _getBundleCryptidPrice(uint256 mintNumber) internal view returns (uint256) {
uint256 bundlePrice = mintNumber * awCryptidPrice;
if (mintNumber == 3) {
return threeBundleCryptidPrice;
} else if (mintNumber == 10) {
return tenBundleCryptidPrice;
} else {
return bundlePrice;
}
}
| function _getBundleCryptidPrice(uint256 mintNumber) internal view returns (uint256) {
uint256 bundlePrice = mintNumber * awCryptidPrice;
if (mintNumber == 3) {
return threeBundleCryptidPrice;
} else if (mintNumber == 10) {
return tenBundleCryptidPrice;
} else {
return bundlePrice;
}
}
| 37,958 |
390 | // with greatness > 19 add nickname prefix | if (greatness >= 19) {
if (greatness == 19) {
output = string(abi.encodePacked('"', nicknames[deterministic % (nicknames.length)], '" ', output));
} else {
| if (greatness >= 19) {
if (greatness == 19) {
output = string(abi.encodePacked('"', nicknames[deterministic % (nicknames.length)], '" ', output));
} else {
| 36,984 |
157 | // mint token | _mint(collector_address, tokenId);
_setTokenURI(tokenId, tokenURI);
_setTokenIPFSHash(tokenId, ipfsHash);
| _mint(collector_address, tokenId);
_setTokenURI(tokenId, tokenURI);
_setTokenIPFSHash(tokenId, ipfsHash);
| 50,171 |
35 | // Ensure a single SLOAD while avoiding solc's excessive bitmasking bureaucracy. | uint256 hop_;
{
| uint256 hop_;
{
| 32,768 |
96 | // checks if the Maker credit line increase could violate the pool constraints-> make function pure and call with current pool values approxNav | function validate(uint juniorSupplyDAI, uint juniorRedeemDAI, uint seniorSupplyDAI, uint seniorRedeemDAI) public view returns(int) {
uint newAssets = safeSub(safeSub(safeAdd(safeAdd(safeAdd(assessor.totalBalance(), assessor.getNAV()), seniorSupplyDAI),
juniorSupplyDAI), juniorRedeemDAI), seniorRedeemDAI);
uint expectedSeniorAsset = assessor.calcExpectedSeniorAsset(seniorRedeemDAI, seniorSupplyDAI,
assessor.seniorBalance(), assessor.seniorDebt());
return coordinator.validateRatioConstraints(newAssets, expectedSeniorAsset);
}
| function validate(uint juniorSupplyDAI, uint juniorRedeemDAI, uint seniorSupplyDAI, uint seniorRedeemDAI) public view returns(int) {
uint newAssets = safeSub(safeSub(safeAdd(safeAdd(safeAdd(assessor.totalBalance(), assessor.getNAV()), seniorSupplyDAI),
juniorSupplyDAI), juniorRedeemDAI), seniorRedeemDAI);
uint expectedSeniorAsset = assessor.calcExpectedSeniorAsset(seniorRedeemDAI, seniorSupplyDAI,
assessor.seniorBalance(), assessor.seniorDebt());
return coordinator.validateRatioConstraints(newAssets, expectedSeniorAsset);
}
| 22,319 |
1 | // 这里把 Your ticker 改成你想要的代笔简写,如BTC,LTC, DOGE 如 string public token_ticker = "BTC"; | string public token_ticker = "GLO";
| string public token_ticker = "GLO";
| 175 |
9 | // Constructor initializes the isOwner mapping. / | function MultiSigWallet() public {
isAuthorised[0xF748D2322ADfE0E9f9b262Df6A2aD6CBF79A541A] = true; //account 1
isAuthorised[0x4BbBbDd42c7aab36BeA6A70a0cB35d6C20Be474E] = true; //account 2
isAuthorised[0x2E661Be8C26925DDAFc25EEe3971efb8754E6D90] = true; //account 3
isAuthorised[0x1ee9b4b8c9cA6637eF5eeCEE62C9e56072165AAF] = true; //account 4
}
| function MultiSigWallet() public {
isAuthorised[0xF748D2322ADfE0E9f9b262Df6A2aD6CBF79A541A] = true; //account 1
isAuthorised[0x4BbBbDd42c7aab36BeA6A70a0cB35d6C20Be474E] = true; //account 2
isAuthorised[0x2E661Be8C26925DDAFc25EEe3971efb8754E6D90] = true; //account 3
isAuthorised[0x1ee9b4b8c9cA6637eF5eeCEE62C9e56072165AAF] = true; //account 4
}
| 29,139 |
20 | // Set paramaters for the reward distribution _rewardPerBlock The reward token amount per a block _decrementUnitPerBlock The decerement amount of the reward token per a block / | function _setParams(uint256 _rewardPerBlock, uint256 _decrementUnitPerBlock) internal {
emit SetRewardParams(_rewardPerBlock, _decrementUnitPerBlock);
rewardPerBlock = _rewardPerBlock;
decrementUnitPerBlock = _decrementUnitPerBlock;
}
| function _setParams(uint256 _rewardPerBlock, uint256 _decrementUnitPerBlock) internal {
emit SetRewardParams(_rewardPerBlock, _decrementUnitPerBlock);
rewardPerBlock = _rewardPerBlock;
decrementUnitPerBlock = _decrementUnitPerBlock;
}
| 11,197 |
107 | // Returns array of modules./start Start of the page./pageSize Maximum number of modules that should be returned./ return Array of modules. | function getModulesPaginated(address start, uint256 pageSize)
public
view
returns (address[] memory array, address next)
| function getModulesPaginated(address start, uint256 pageSize)
public
view
returns (address[] memory array, address next)
| 23,661 |
5 | // The Chainlink VRF has a max gas of 200,000 gas (computation units) | address nftOwner = requestIdToSender[requestId];
uint256 tokenId = requestIdToTokenId[requestId];
_safeMint(nftOwner, tokenId);
tokenIdToRandomNumber[tokenId] = randomNumber;
emit CreatedUnfinishedRandomSVG(tokenId, randomNumber);
| address nftOwner = requestIdToSender[requestId];
uint256 tokenId = requestIdToTokenId[requestId];
_safeMint(nftOwner, tokenId);
tokenIdToRandomNumber[tokenId] = randomNumber;
emit CreatedUnfinishedRandomSVG(tokenId, randomNumber);
| 37,158 |
4 | // Returns the tokenURI for a given _tokenId | function tokenURI(uint256 _tokenId)
public
view
override
returns (string memory)
| function tokenURI(uint256 _tokenId)
public
view
override
returns (string memory)
| 21,865 |
114 | // Checks the amount of input tokens to output tokens _input The address of the token being converted _output The address of the token to be converted to _inputAmount The input amount of tokens that are being converted / | function convert_rate(
address _input,
address _output,
uint256 _inputAmount
| function convert_rate(
address _input,
address _output,
uint256 _inputAmount
| 64,861 |
178 | // If the result is a tie, no parties are incoherent and no need to move tokens. Note that 0 (refuse to arbitrate) winning is not a tie. | if (winningChoice==0 && (dispute.voteCounter[dispute.appeals].voteCount[0] != dispute.voteCounter[dispute.appeals].winningCount)) {
| if (winningChoice==0 && (dispute.voteCounter[dispute.appeals].voteCount[0] != dispute.voteCounter[dispute.appeals].winningCount)) {
| 76,100 |
77 | // yes - just execute the call. | _to.transfer(_value);
return 0;
| _to.transfer(_value);
return 0;
| 34,201 |
103 | // Creates a Chainlink request to the specified oracle address Generates and stores a request ID, increments the local nonce, and uses `transferAndCall` tosend LINK which creates a request on the target oracle contract.Emits ChainlinkRequested event. oracleAddress The address of the oracle for the request req The initialized Chainlink Request payment The amount of LINK to send for the requestreturn requestId The request ID / | function sendChainlinkRequestTo(
address oracleAddress,
Chainlink.Request memory req,
uint256 payment
| function sendChainlinkRequestTo(
address oracleAddress,
Chainlink.Request memory req,
uint256 payment
| 35,240 |
22 | // Works for Bancor assets and old bancor pools | function getRatioByPath(address _from, address _to, uint256 _amount) public view returns(uint256) {
BancorNetworkInterface bancorNetwork = BancorNetworkInterface(
getBancorContractAddresByName("BancorNetwork")
);
// get Bancor path array
address[] memory path = bancorNetwork.conversionPath(_from, _to);
// get Ratio
return bancorNetwork.rateByPath(path, _amount);
}
| function getRatioByPath(address _from, address _to, uint256 _amount) public view returns(uint256) {
BancorNetworkInterface bancorNetwork = BancorNetworkInterface(
getBancorContractAddresByName("BancorNetwork")
);
// get Bancor path array
address[] memory path = bancorNetwork.conversionPath(_from, _to);
// get Ratio
return bancorNetwork.rateByPath(path, _amount);
}
| 12,851 |
35 | // Addition to ERC20 token methods. It allows to approve the transfer of value and execute a call with the sent data.Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:_spender The address that will spend the funds. _value The amount of tokens to be spent. _data ABI-encoded contract call to call `_to` address. return true if the call function was executed | function approveAndCall(
address _spender,
uint256 _value,
bytes _data
)
public
payable
returns (bool)
| function approveAndCall(
address _spender,
uint256 _value,
bytes _data
)
public
payable
returns (bool)
| 19,628 |
122 | // Restake is to be called weekly. It unstakes 7% of what's currently staked, then restakes. _lastId Frontend must submit last ID because it doesn't work direct from Nexus Mutual./ | {
// All Nexus functions.
uint256 withdrawn = _withdrawNxm();
// This will unstake from all unstaking protocols
uint256 unstaked = _unstakeNxm(_lastId);
// This will stake for all protocols, including unstaking protocols
uint256 staked = _stakeNxm();
startProtocol = startProtocol + bucketSize >= protocols.length ? checkpointProtocol + (startProtocol + bucketSize) % protocols.length : startProtocol + bucketSize;
lastRestake = block.timestamp;
emit Restake(withdrawn, unstaked, staked, aum(), block.timestamp);
}
| {
// All Nexus functions.
uint256 withdrawn = _withdrawNxm();
// This will unstake from all unstaking protocols
uint256 unstaked = _unstakeNxm(_lastId);
// This will stake for all protocols, including unstaking protocols
uint256 staked = _stakeNxm();
startProtocol = startProtocol + bucketSize >= protocols.length ? checkpointProtocol + (startProtocol + bucketSize) % protocols.length : startProtocol + bucketSize;
lastRestake = block.timestamp;
emit Restake(withdrawn, unstaked, staked, aum(), block.timestamp);
}
| 62,700 |
471 | // Either early expiration is enabled and it's before the expiration time or it's after the expiration time. | require(
(enableEarlyExpiration && getCurrentTime() < expirationTimestamp) ||
getCurrentTime() >= expirationTimestamp,
"Cannot settle"
);
| require(
(enableEarlyExpiration && getCurrentTime() < expirationTimestamp) ||
getCurrentTime() >= expirationTimestamp,
"Cannot settle"
);
| 7,944 |
82 | // this method might be overridden for implementing any sale logic.return Actual rate. / | function getRate(uint amount) internal constant returns (uint);
function getBaseRate() internal constant returns (uint);
| function getRate(uint amount) internal constant returns (uint);
function getBaseRate() internal constant returns (uint);
| 14,567 |
3 | // Integer division of two numbers, truncating the quotient./ | function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
| function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
| 1,765 |
74 | // enforce max sell restrictions. | require(nextPrivateWalletSellDate[from] <= block.timestamp, "Cannot sell yet");
require(amount <= getPrivateSaleMaxSell(), "Attempting to sell over max sell amount. Check max.");
nextPrivateWalletSellDate[from] = block.timestamp + 24 hours;
| require(nextPrivateWalletSellDate[from] <= block.timestamp, "Cannot sell yet");
require(amount <= getPrivateSaleMaxSell(), "Attempting to sell over max sell amount. Check max.");
nextPrivateWalletSellDate[from] = block.timestamp + 24 hours;
| 5,866 |
307 | // assigned (and available on the emitted {IERC721-Transfer} event), and the tokenURI autogenerated based on the base URI passed at construction.Requirements: - the caller must have the `MINTER_ROLE`. / | function mintByAdmin(address to, string memory _tokenURI) public onlyOwner {
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
require(newItemId <= maxSupply);
_mint(to, newItemId);
_setTokenURI(newItemId, _tokenURI);
}
| function mintByAdmin(address to, string memory _tokenURI) public onlyOwner {
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
require(newItemId <= maxSupply);
_mint(to, newItemId);
_setTokenURI(newItemId, _tokenURI);
}
| 3,248 |
113 | // calculate current mining state | function getMiningState(uint _blockNum) public view returns(uint, uint){
require(_blockNum >= miningStateBlock, "_blockNum must be >= miningStateBlock");
uint blockNumber = _blockNum;
if(_blockNum>endMiningBlockNum){ //if current block.number is bigger than the end of program, only update the state to endMiningBlockNum
blockNumber = endMiningBlockNum;
}
uint deltaBlocks = blockNumber.sub(miningStateBlock);
uint _miningStateBlock = miningStateBlock;
uint _miningStateIndex = miningStateIndex;
if (deltaBlocks > 0 && totalStaked > 0) {
uint tadAccrued = deltaBlocks.mul(tadPerBlock);
uint ratio = tadAccrued.mul(1e18).div(totalStaked); //multiple ratio to 1e18 to prevent rounding error
_miningStateIndex = miningStateIndex.add(ratio); //index is 1e18 precision
_miningStateBlock = blockNumber;
}
return (_miningStateIndex, _miningStateBlock);
}
| function getMiningState(uint _blockNum) public view returns(uint, uint){
require(_blockNum >= miningStateBlock, "_blockNum must be >= miningStateBlock");
uint blockNumber = _blockNum;
if(_blockNum>endMiningBlockNum){ //if current block.number is bigger than the end of program, only update the state to endMiningBlockNum
blockNumber = endMiningBlockNum;
}
uint deltaBlocks = blockNumber.sub(miningStateBlock);
uint _miningStateBlock = miningStateBlock;
uint _miningStateIndex = miningStateIndex;
if (deltaBlocks > 0 && totalStaked > 0) {
uint tadAccrued = deltaBlocks.mul(tadPerBlock);
uint ratio = tadAccrued.mul(1e18).div(totalStaked); //multiple ratio to 1e18 to prevent rounding error
_miningStateIndex = miningStateIndex.add(ratio); //index is 1e18 precision
_miningStateBlock = blockNumber;
}
return (_miningStateIndex, _miningStateBlock);
}
| 11,313 |
8 | // The Lootmart contract is used to calculate the token ID, guaranteeing the correct supply for each helm | ILoot private ogLootContract;
ILmart private lmartContract;
IRiftData private riftDataContract;
IHelmsMetadata public metadataContract;
| ILoot private ogLootContract;
ILmart private lmartContract;
IRiftData private riftDataContract;
IHelmsMetadata public metadataContract;
| 45,353 |
32 | // Set tokenURI, contentURI and withdrawOnBurn to the same as source token | _setTokenURI(claimTokenId, _tokenURIs[tokenId]);
_contentURIs[claimTokenId] = _contentURIs[tokenId];
_withdrawOnBurn[claimTokenId] = _withdrawOnBurn[tokenId];
| _setTokenURI(claimTokenId, _tokenURIs[tokenId]);
_contentURIs[claimTokenId] = _contentURIs[tokenId];
_withdrawOnBurn[claimTokenId] = _withdrawOnBurn[tokenId];
| 40,710 |
33 | // check allowance | require(
BUSD.allowance(beneficiary, address(this)) >= busdAmount,
"Contract not approved to transfer BUSD"
);
| require(
BUSD.allowance(beneficiary, address(this)) >= busdAmount,
"Contract not approved to transfer BUSD"
);
| 21,211 |
86 | // Current min quorum votes using Noun total supply / | function minQuorumVotes() public view returns (uint256) {
return bps2Uint(getDynamicQuorumParamsAt(block.number).minQuorumVotesBPS, nouns.totalSupply());
}
| function minQuorumVotes() public view returns (uint256) {
return bps2Uint(getDynamicQuorumParamsAt(block.number).minQuorumVotesBPS, nouns.totalSupply());
}
| 26,617 |
38 | // Extends the end time of an auction if we are within the grace period. | function _maybeExtendTime (uint64 auctionId, Auction storage auction) internal {
uint64 gracePeriodStart = auction.endTimestamp - BIDDING_GRACE_PERIOD;
uint64 _now = uint64(block.timestamp);
if (_now > gracePeriodStart) {
auction.endTimestamp = uint32(_now + BIDDING_GRACE_PERIOD);
emit AuctionExtended(auctionId, auction.endTimestamp);
}
}
| function _maybeExtendTime (uint64 auctionId, Auction storage auction) internal {
uint64 gracePeriodStart = auction.endTimestamp - BIDDING_GRACE_PERIOD;
uint64 _now = uint64(block.timestamp);
if (_now > gracePeriodStart) {
auction.endTimestamp = uint32(_now + BIDDING_GRACE_PERIOD);
emit AuctionExtended(auctionId, auction.endTimestamp);
}
}
| 34,435 |
31 | // n.b. that the operator takes the gem and might not be the same operator who brought the gem | function free(uint256 wad) external operator {
require(wad <= 2**255, "RwaUrn/overflow");
vat.frob(gemJoin.ilk(), address(this), address(this), address(this), -int256(wad), 0);
gemJoin.exit(msg.sender, wad);
emit Free(msg.sender, wad);
}
| function free(uint256 wad) external operator {
require(wad <= 2**255, "RwaUrn/overflow");
vat.frob(gemJoin.ilk(), address(this), address(this), address(this), -int256(wad), 0);
gemJoin.exit(msg.sender, wad);
emit Free(msg.sender, wad);
}
| 7,856 |
99 | // allow sender to mint for "to" | return _purchase(msg.sender, to, tokenIn, maxAmount, amountIn, proof);
| return _purchase(msg.sender, to, tokenIn, maxAmount, amountIn, proof);
| 32,967 |
76 | // Emitted when an aToken is initialized underlyingAsset The address of the underlying asset pool The address of the associated lending pool treasury The address of the treasury incentivesController The address of the incentives controller for this aToken eTokenDecimals the decimals of the underlying eTokenName the name of the aToken eTokenSymbol the symbol of the aToken params A set of encoded parameters for additional initialization // Initializes the aToken pool The address of the lending pool where this aToken will be used treasury The address of the Aave treasury, receiving the fees on this aToken underlyingAsset The address of the underlying | function initialize(
ILendingPool pool,
address treasury,
address underlyingAsset,
IEaveIncentivesController incentivesController,
uint8 eTokenDecimals,
string calldata eTokenName,
string calldata eTokenSymbol,
bytes calldata params
) external;
| function initialize(
ILendingPool pool,
address treasury,
address underlyingAsset,
IEaveIncentivesController incentivesController,
uint8 eTokenDecimals,
string calldata eTokenName,
string calldata eTokenSymbol,
bytes calldata params
) external;
| 73,475 |
77 | // Construct the token. This token must be created through a team multisig wallet, so that it is owned by that wallet._name Token name _symbol Token symbol - should be all caps _initialSupply How many tokens we start with _decimals Number of decimal places _mintable Are new tokens created over the crowdsale or do we distribute only the initial supply? Note that when the token becomes transferable the minting always ends. / | function CrowdsaleToken(string _name, string _symbol, uint _initialSupply, uint8 _decimals, bool _mintable)
public
UpgradeableToken(msg.sender)
| function CrowdsaleToken(string _name, string _symbol, uint _initialSupply, uint8 _decimals, bool _mintable)
public
UpgradeableToken(msg.sender)
| 38,519 |
113 | // override for get eth only after finalization | function _forwardFunds() internal {
}
| function _forwardFunds() internal {
}
| 52,379 |
93 | // uint load = getDivdLoad();/v2 begin | uint load = getDivdLoad();
| uint load = getDivdLoad();
| 6,280 |
891 | // deposit eth on behalf of proxy | DSProxy(payable(proxy)).execute{value: ethAmount}(AAVE_BASIC_PROXY, abi.encodeWithSignature("deposit(address,address,uint256)", market, ETH_ADDR, ethAmount));
| DSProxy(payable(proxy)).execute{value: ethAmount}(AAVE_BASIC_PROXY, abi.encodeWithSignature("deposit(address,address,uint256)", market, ETH_ADDR, ethAmount));
| 49,460 |
6 | // See {IClaimIssuer-isClaimRevoked}. / | function isClaimRevoked(
bytes memory sig
) public view override returns (bool) {
return _revokedClaims[sig];
}
| function isClaimRevoked(
bytes memory sig
) public view override returns (bool) {
return _revokedClaims[sig];
}
| 19,428 |
259 | // The Governance token | Treats public govToken;
| Treats public govToken;
| 50,637 |
45 | // Gets the balance of the specified address._addr The address to query the the balance of. return An uint256 representing the amount owned by the passed address./ | function balanceOf(address _addr) public view returns (uint256) {
return balances[_addr];
}
| function balanceOf(address _addr) public view returns (uint256) {
return balances[_addr];
}
| 17,825 |
68 | // Sends all the marketing ETH to the marketingWallet | (bool sent,)=marketingWallet.call{value:address(this).balance}("");
| (bool sent,)=marketingWallet.call{value:address(this).balance}("");
| 7,946 |
108 | // _protocols List of the 10 protocols we're using. _wNxm Address of the wNxm contract. _arNxm Address of the arNxm contract. _nxmMaster Address of Nexus' master address (to fetch others). _rewardManager Address of the ReferralRewards smart contract./ | {
require(address(arNxm) == address(0), "Contract has already been initialized.");
for (uint256 i = 0; i < _protocols.length; i++) protocols.push(_protocols[i]);
Ownable.initializeOwnable();
wNxm = IERC20(_wNxm);
nxm = IERC20(_nxm);
arNxm = IERC20(_arNxm);
nxmMaster = INxmMaster(_nxmMaster);
rewardManager = IRewardManager(_rewardManager);
// unstakePercent = 100;
adminPercent = 0;
referPercent = 25;
reserveAmount = 30 ether;
pauseDuration = 10 days;
beneficiary = msg.sender;
restakePeriod = 3 days;
rewardDuration = 9 days;
// Approve to wrap and send funds to reward manager.
arNxm.approve( _rewardManager, uint256(-1) );
}
| {
require(address(arNxm) == address(0), "Contract has already been initialized.");
for (uint256 i = 0; i < _protocols.length; i++) protocols.push(_protocols[i]);
Ownable.initializeOwnable();
wNxm = IERC20(_wNxm);
nxm = IERC20(_nxm);
arNxm = IERC20(_arNxm);
nxmMaster = INxmMaster(_nxmMaster);
rewardManager = IRewardManager(_rewardManager);
// unstakePercent = 100;
adminPercent = 0;
referPercent = 25;
reserveAmount = 30 ether;
pauseDuration = 10 days;
beneficiary = msg.sender;
restakePeriod = 3 days;
rewardDuration = 9 days;
// Approve to wrap and send funds to reward manager.
arNxm.approve( _rewardManager, uint256(-1) );
}
| 62,503 |
24 | // stake amount of GMI tokens to Staking Pool/ this method can called by anyone/ _projectIdid of the project/ _amountamount of the tokens to be staked | function stake(uint256 _projectId, uint256 _amount) external validProject(_projectId) {
StakeInfo storage stakeInfo = projects[_projectId].stakeInfo;
require(!isAlreadyStaked(_projectId, _msgSender()), "You already staking");
require(block.number >= stakeInfo.startBlockNumber, "Staking has not started yet");
require(block.number <= stakeInfo.endBlockNumber, "Staking has ended");
require(_amount >= stakeInfo.minStakeAmount, "Not enough stake amount");
require(_amount <= stakeInfo.maxStakeAmount, "Amount exceed limit stake amount");
gmi.safeTransferFrom(_msgSender(), address(this), _amount);
userInfo[_projectId][_msgSender()].stakedAmount += _amount;
userInfo[_projectId][_msgSender()].allocatedPortion += _amount;
stakeInfo.stakedTotalAmount += _amount;
emit Stake(_msgSender(), _projectId, _amount);
}
| function stake(uint256 _projectId, uint256 _amount) external validProject(_projectId) {
StakeInfo storage stakeInfo = projects[_projectId].stakeInfo;
require(!isAlreadyStaked(_projectId, _msgSender()), "You already staking");
require(block.number >= stakeInfo.startBlockNumber, "Staking has not started yet");
require(block.number <= stakeInfo.endBlockNumber, "Staking has ended");
require(_amount >= stakeInfo.minStakeAmount, "Not enough stake amount");
require(_amount <= stakeInfo.maxStakeAmount, "Amount exceed limit stake amount");
gmi.safeTransferFrom(_msgSender(), address(this), _amount);
userInfo[_projectId][_msgSender()].stakedAmount += _amount;
userInfo[_projectId][_msgSender()].allocatedPortion += _amount;
stakeInfo.stakedTotalAmount += _amount;
emit Stake(_msgSender(), _projectId, _amount);
}
| 18,519 |
117 | // Multiplies two precise units, and then truncates by the full scale, rounding up the result x Left hand input to multiplication y Right hand input to multiplicationreturnResult after multiplying the two inputs and then dividing by the shared scale unit, rounded up to the closest base unit. / | function mulTruncateCeil(uint256 x, uint256 y)
internal
pure
returns (uint256)
| function mulTruncateCeil(uint256 x, uint256 y)
internal
pure
returns (uint256)
| 36,573 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.