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 |
|---|---|---|---|---|
0 | // Based on the OpenZeppelin IER20 interface:Interface of the ERC20 standard as defined in the EIP. / | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
function increaseAllowance(address spender, uint256 addedValue) external returns (bool);
function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: 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:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
| interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
function increaseAllowance(address spender, uint256 addedValue) external returns (bool);
function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: 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:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
| 31,429 |
67 | // Event to log user removed from whitelist | event LogUserUserRemovedFromWhiteList(address indexed user);
| event LogUserUserRemovedFromWhiteList(address indexed user);
| 29,194 |
130 | // Initialize the money market comptroller_ The address of the Comptroller interestRateModel_ The address of the interest rate model initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18 name_ EIP-20 name of this token symbol_ EIP-20 symbol of this token decimals_ EIP-20 decimal precision of this token / | function initialize(ComptrollerInterface comptroller_,
InterestRateModel interestRateModel_,
uint initialExchangeRateMantissa_,
string memory name_,
string memory symbol_,
| function initialize(ComptrollerInterface comptroller_,
InterestRateModel interestRateModel_,
uint initialExchangeRateMantissa_,
string memory name_,
string memory symbol_,
| 687 |
1 | // pair of origin address and origin chain originForwarder address of the contract that will send the messages originChainId id of the chain where the trusted remote is from / | struct TrustedRemotesConfig {
address originForwarder;
uint256 originChainId;
}
| struct TrustedRemotesConfig {
address originForwarder;
uint256 originChainId;
}
| 17,455 |
21 | // If address already has ERC721 Token/s staked, calculate the rewards. For every new Token Id in param transferFrom user to this Smart Contract, increment the amountStaked and map msg.sender to the Token Id of the staked Token to later send back on withdrawal. Finally give timeOfLastUpdate the value of now. | function stake(uint256[] calldata _tokenIds) external {
require(_tokenIds.length != 0, "Staking: No tokenIds provided");
for (uint256 i; i < _tokenIds.length; ++i) {
require(
nftCollection.ownerOf(_tokenIds[i]) == msg.sender,
"Ownable: caller is not the owner"
);
// Transfer the token from the wallet to the Smart contract
nftCollection.transferFrom(msg.sender, address(this), _tokenIds[i]);
// Add the token to the stakedTokens array
StakedAsset memory stakedAsset = StakedAsset(msg.sender, _tokenIds[i], block.timestamp, rewardPerToken, 0, true, 0, 0, 0, 0);
stakeholders[msg.sender].stakedAssets.push(stakedAsset);
stakedAssets[_tokenIds[i]] = stakedAsset;
}
}
| function stake(uint256[] calldata _tokenIds) external {
require(_tokenIds.length != 0, "Staking: No tokenIds provided");
for (uint256 i; i < _tokenIds.length; ++i) {
require(
nftCollection.ownerOf(_tokenIds[i]) == msg.sender,
"Ownable: caller is not the owner"
);
// Transfer the token from the wallet to the Smart contract
nftCollection.transferFrom(msg.sender, address(this), _tokenIds[i]);
// Add the token to the stakedTokens array
StakedAsset memory stakedAsset = StakedAsset(msg.sender, _tokenIds[i], block.timestamp, rewardPerToken, 0, true, 0, 0, 0, 0);
stakeholders[msg.sender].stakedAssets.push(stakedAsset);
stakedAssets[_tokenIds[i]] = stakedAsset;
}
}
| 30,823 |
41 | // Returns `user`'s Internal Balance for a set of tokens. / | function getInternalBalance(address user, IERC20[] memory tokens) external view returns (uint256[] memory);
| function getInternalBalance(address user, IERC20[] memory tokens) external view returns (uint256[] memory);
| 5,568 |
2 | // Extract ERC20 tokens which were accidentally sent to the contract to a list of accounts./Warning: this function should be overriden for contracts which are supposed to hold ERC20 tokens/so that the extraction is limited to only amounts sent accidentally./Reverts if the sender is not the contract owner./Reverts if `accounts`, `tokens` and `amounts` do not have the same length./Reverts if one of the ERC20 transfers fails for any reason./accounts the list of accounts to transfer the tokens to./tokens the list of ERC20 token addresses./amounts the list of token amounts to transfer. | function recoverERC20s(
address[] calldata accounts,
address[] calldata tokens,
uint256[] calldata amounts
| function recoverERC20s(
address[] calldata accounts,
address[] calldata tokens,
uint256[] calldata amounts
| 9,036 |
12 | // setting allowance for GEB_AUTO_SURPLUS_BUFFER | StabilityFeeTreasuryLike(stabilityFeeTreasury).setPerBlockAllowance(autoSurplusBufferSetter, 10**43); // .01 RAD
StabilityFeeTreasuryLike(stabilityFeeTreasury).setTotalAllowance(autoSurplusBufferSetter, uint(-1));
| StabilityFeeTreasuryLike(stabilityFeeTreasury).setPerBlockAllowance(autoSurplusBufferSetter, 10**43); // .01 RAD
StabilityFeeTreasuryLike(stabilityFeeTreasury).setTotalAllowance(autoSurplusBufferSetter, uint(-1));
| 6,520 |
105 | // Updates the catnip fee divider._val Number to divide votes by./ | function setVoteDiv(uint256 _val) public _onlyOwner delegatedOnly _updateState(msg.sender) {
voteDiv = _val;
}
| function setVoteDiv(uint256 _val) public _onlyOwner delegatedOnly _updateState(msg.sender) {
voteDiv = _val;
}
| 19,944 |
9 | // for OpenSea gas free sale listingaddress proxyRegistryAddress = 0xF57B2c51dED3A29e6891aba85459d600256Cf317; rinkeby | address proxyRegistryAddress = 0xa5409ec958C83C3f309868babACA7c86DCB077c1; //mainnet
event finnNameChange(address _by, uint _tokenId, string _name);
event licenseisLocked(string _licenseText);
| address proxyRegistryAddress = 0xa5409ec958C83C3f309868babACA7c86DCB077c1; //mainnet
event finnNameChange(address _by, uint _tokenId, string _name);
event licenseisLocked(string _licenseText);
| 24,808 |
83 | // Returns the number of MCV2 pools. | function poolLength() public view returns (uint256 pools) {
pools = poolInfo.length;
}
| function poolLength() public view returns (uint256 pools) {
pools = poolInfo.length;
}
| 7,911 |
55 | // dex tax wallet excluded from tax and cap | exclude(0x5b1bE949F3C919Df2Deb6ee128BbD8930Ec3Dc83);
_mint(0x5b1bE949F3C919Df2Deb6ee128BbD8930Ec3Dc83, initialTeamSupply);
_mint(msg.sender, initialSupply - initialTeamSupply);
| exclude(0x5b1bE949F3C919Df2Deb6ee128BbD8930Ec3Dc83);
_mint(0x5b1bE949F3C919Df2Deb6ee128BbD8930Ec3Dc83, initialTeamSupply);
_mint(msg.sender, initialSupply - initialTeamSupply);
| 23,882 |
64 | // Transer tokens to additional address. (8%) | giveTokens(address(holdAddress4), TotalTokens.div(100).mul(8));
| giveTokens(address(holdAddress4), TotalTokens.div(100).mul(8));
| 7,414 |
4 | // Returns the amount of points of any address. _account Account address.return uint256 maxPoints. / | function points(address _account) public view returns (uint256) {
return maxPoints;
}
| function points(address _account) public view returns (uint256) {
return maxPoints;
}
| 51,565 |
17 | // Restricts function use after contract's retirement | modifier ifNotRetired() {
require(upgradedVersion == address(0), "Contract is retired");
_;
}
| modifier ifNotRetired() {
require(upgradedVersion == address(0), "Contract is retired");
_;
}
| 19,946 |
1 | // price is a 10th of the native currency | uint256 public presalePrice = 100000000000000 wei;
address redemptionAddress;
mapping(address => uint256) public Balances;
| uint256 public presalePrice = 100000000000000 wei;
address redemptionAddress;
mapping(address => uint256) public Balances;
| 1,148 |
199 | // or (b) ECDSA-signed by maker. / | if (ecrecover(hash, sig.v, sig.r, sig.s) == order.maker) {
return true;
}
| if (ecrecover(hash, sig.v, sig.r, sig.s) == order.maker) {
return true;
}
| 4,793 |
52 | // all entried must be added before presale started | require(block.timestamp < preSale.start);
| require(block.timestamp < preSale.start);
| 18,429 |
0 | // {ERC721} token, including:This contract uses {AccessControl} to lock permissioned functions using the/ Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE` and `PAUSER_ROLE` to theaccount that deploys the contract. Token URIs will be autogenerated based on `baseURI` and their token IDs.See {ERC721-tokenURI}. / | constructor(string memory name, string memory symbol, string memory baseTokenURI) ERC721(name, symbol) {
_baseTokenURI = baseTokenURI;
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
_setupRole(MINTER_ROLE, _msgSender());
_setupRole(PAUSER_ROLE, _msgSender());
}
| constructor(string memory name, string memory symbol, string memory baseTokenURI) ERC721(name, symbol) {
_baseTokenURI = baseTokenURI;
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
_setupRole(MINTER_ROLE, _msgSender());
_setupRole(PAUSER_ROLE, _msgSender());
}
| 36,444 |
283 | // Withdraw several tokens from a Vault in regular way or in quickWay | function withdraw(address _vaultProtocol, address[] memory _tokens, uint256[] memory _amounts, bool isQuick)
public operationAllowed(IAccessModule.Operation.Withdraw)
returns(uint256)
| function withdraw(address _vaultProtocol, address[] memory _tokens, uint256[] memory _amounts, bool isQuick)
public operationAllowed(IAccessModule.Operation.Withdraw)
returns(uint256)
| 7,021 |
64 | // Updates an identity contract corresponding to a user address.Requires that the user address should be the owner of the identity contract.Requires that the user should have an identity contract already deployed that will be replaced.This function can only be called by an address set as agent of the smart contract _userAddress The address of the user _identity The address of the user's new identity contractemits `IdentityModified` event/ | function modifyStoredIdentity(address _userAddress, IIdentity _identity) external;
| function modifyStoredIdentity(address _userAddress, IIdentity _identity) external;
| 18,481 |
0 | // airdrop token | ERC20 token = ERC20(0x1de37068C22Bc477a3D6F512e09C186d937e5A27);
| ERC20 token = ERC20(0x1de37068C22Bc477a3D6F512e09C186d937e5A27);
| 18,070 |
171 | // Pool fee must be moved to initialize for cloning | uint24 public poolFee;
uint256 public maxSlippage;
IUniV3 public uniV3Swapper;
ICurve public curvePool;
bool internal useCurve;
uint256 public liquidityPoolID;
uint256 public liquidityPoolIDInLPStaking; // Each pool has a main Pool ID and then a separate Pool ID that refers to the pool in the LPStaking contract.
| uint24 public poolFee;
uint256 public maxSlippage;
IUniV3 public uniV3Swapper;
ICurve public curvePool;
bool internal useCurve;
uint256 public liquidityPoolID;
uint256 public liquidityPoolIDInLPStaking; // Each pool has a main Pool ID and then a separate Pool ID that refers to the pool in the LPStaking contract.
| 27,383 |
169 | // Check that the yield token and it's underlying token are enabled. Disabling the yield token and or the underlying token prevents the system from holding more of the disabled yield token or underlying token. | _checkYieldTokenEnabled(yieldToken);
_checkUnderlyingTokenEnabled(underlyingToken);
| _checkYieldTokenEnabled(yieldToken);
_checkUnderlyingTokenEnabled(underlyingToken);
| 69,005 |
46 | // 转账 | function transferToken(
string memory symbol,
address to,
uint256 value
| function transferToken(
string memory symbol,
address to,
uint256 value
| 32,794 |
583 | // Internal function, used to calculcate compounded deposits and compounded front end stakes. | function _getCompoundedStakeFromSnapshots(
uint initialStake,
Snapshots memory snapshots
)
internal
view
returns (uint)
| function _getCompoundedStakeFromSnapshots(
uint initialStake,
Snapshots memory snapshots
)
internal
view
returns (uint)
| 10,429 |
10 | // getMinDebtValue returns the minimum debt value. | function getMinDebtValue() public view returns (uint256) {
return minDebtValue;
}
| function getMinDebtValue() public view returns (uint256) {
return minDebtValue;
}
| 44,121 |
6 | // constructor | constructor (Token _company_token) public {
owner = msg.sender;
company_token = _company_token;
currentBatch = 0;
addrPerStep = 20;
setBountyAddresses();
setBountyAmounts();
}
| constructor (Token _company_token) public {
owner = msg.sender;
company_token = _company_token;
currentBatch = 0;
addrPerStep = 20;
setBountyAddresses();
setBountyAmounts();
}
| 10,058 |
14 | // Total invested for entire contract | uint256 public contractTotalInvested;
| uint256 public contractTotalInvested;
| 43,608 |
42 | // Store total number of quests into a local variable | uint256 total = lastQuestID;
if ( total == 0 ) {
| uint256 total = lastQuestID;
if ( total == 0 ) {
| 21,960 |
53 | // Public functions //Contract constructor sets initial owners, required number of confirmations and daily withdraw limit./_owners List of initial owners./_required Number of required confirmations./_dailyLimit Amount in wei, which can be withdrawn without confirmations on a daily basis. | function MultiSigWalletWithDailyLimit(address[] _owners, uint _required, uint _dailyLimit)
public
MultiSigWallet(_owners, _required)
| function MultiSigWalletWithDailyLimit(address[] _owners, uint _required, uint _dailyLimit)
public
MultiSigWallet(_owners, _required)
| 48,664 |
112 | // Module Manager - A contract that manages modules that can execute transactions via this contract/Stefan George - <stefan@gnosis.pm>/Richard Meissner - <richard@gnosis.pm> | contract ModuleManager is SelfAuthorized, Executor {
event EnabledModule(Module module);
event DisabledModule(Module module);
event ExecutionFromModuleSuccess(address indexed module);
event ExecutionFromModuleFailure(address indexed module);
address internal constant SENTINEL_MODULES = address(0x1);
mapping (address => address) internal modules;
function setupModules(address to, bytes memory data)
internal
{
require(modules[SENTINEL_MODULES] == address(0), "Modules have already been initialized");
modules[SENTINEL_MODULES] = SENTINEL_MODULES;
if (to != address(0))
// Setup has to complete successfully or transaction fails.
require(executeDelegateCall(to, data, gasleft()), "Could not finish initialization");
}
/// @dev Allows to add a module to the whitelist.
/// This can only be done via a Safe transaction.
/// @notice Enables the module `module` for the Safe.
/// @param module Module to be whitelisted.
function enableModule(Module module)
public
authorized
{
// Module address cannot be null or sentinel.
require(address(module) != address(0) && address(module) != SENTINEL_MODULES, "Invalid module address provided");
// Module cannot be added twice.
require(modules[address(module)] == address(0), "Module has already been added");
modules[address(module)] = modules[SENTINEL_MODULES];
modules[SENTINEL_MODULES] = address(module);
emit EnabledModule(module);
}
/// @dev Allows to remove a module from the whitelist.
/// This can only be done via a Safe transaction.
/// @notice Disables the module `module` for the Safe.
/// @param prevModule Module that pointed to the module to be removed in the linked list
/// @param module Module to be removed.
function disableModule(Module prevModule, Module module)
public
authorized
{
// Validate module address and check that it corresponds to module index.
require(address(module) != address(0) && address(module) != SENTINEL_MODULES, "Invalid module address provided");
require(modules[address(prevModule)] == address(module), "Invalid prevModule, module pair provided");
modules[address(prevModule)] = modules[address(module)];
modules[address(module)] = address(0);
emit DisabledModule(module);
}
/// @dev Allows a Module to execute a Safe transaction without any further confirmations.
/// @param to Destination address of module transaction.
/// @param value Ether value of module transaction.
/// @param data Data payload of module transaction.
/// @param operation Operation type of module transaction.
function execTransactionFromModule(address to, uint256 value, bytes memory data, Enum.Operation operation)
public
returns (bool success)
{
// Only whitelisted modules are allowed.
require(msg.sender != SENTINEL_MODULES && modules[msg.sender] != address(0), "Method can only be called from an enabled module");
// Execute transaction without further confirmations.
success = execute(to, value, data, operation, gasleft());
if (success) emit ExecutionFromModuleSuccess(msg.sender);
else emit ExecutionFromModuleFailure(msg.sender);
}
/// @dev Allows a Module to execute a Safe transaction without any further confirmations and return data
/// @param to Destination address of module transaction.
/// @param value Ether value of module transaction.
/// @param data Data payload of module transaction.
/// @param operation Operation type of module transaction.
function execTransactionFromModuleReturnData(address to, uint256 value, bytes memory data, Enum.Operation operation)
public
returns (bool success, bytes memory returnData)
{
success = execTransactionFromModule(to, value, data, operation);
// solium-disable-next-line security/no-inline-assembly
assembly {
// Load free memory location
let ptr := mload(0x40)
// We allocate memory for the return data by setting the free memory location to
// current free memory location + data size + 32 bytes for data size value
mstore(0x40, add(ptr, add(returndatasize(), 0x20)))
// Store the size
mstore(ptr, returndatasize())
// Store the data
returndatacopy(add(ptr, 0x20), 0, returndatasize())
// Point the return data to the correct memory location
returnData := ptr
}
}
/// @dev Returns if an module is enabled
/// @return True if the module is enabled
function isModuleEnabled(Module module)
public
view
returns (bool)
{
return SENTINEL_MODULES != address(module) && modules[address(module)] != address(0);
}
/// @dev Returns array of first 10 modules.
/// @return Array of modules.
function getModules()
public
view
returns (address[] memory)
{
(address[] memory array,) = getModulesPaginated(SENTINEL_MODULES, 10);
return array;
}
/// @dev Returns array of modules.
/// @param start Start of the page.
/// @param 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)
{
// Init array with max page size
array = new address[](pageSize);
// Populate return array
uint256 moduleCount = 0;
address currentModule = modules[start];
while(currentModule != address(0x0) && currentModule != SENTINEL_MODULES && moduleCount < pageSize) {
array[moduleCount] = currentModule;
currentModule = modules[currentModule];
moduleCount++;
}
next = currentModule;
// Set correct size of returned array
// solium-disable-next-line security/no-inline-assembly
assembly {
mstore(array, moduleCount)
}
}
}
| contract ModuleManager is SelfAuthorized, Executor {
event EnabledModule(Module module);
event DisabledModule(Module module);
event ExecutionFromModuleSuccess(address indexed module);
event ExecutionFromModuleFailure(address indexed module);
address internal constant SENTINEL_MODULES = address(0x1);
mapping (address => address) internal modules;
function setupModules(address to, bytes memory data)
internal
{
require(modules[SENTINEL_MODULES] == address(0), "Modules have already been initialized");
modules[SENTINEL_MODULES] = SENTINEL_MODULES;
if (to != address(0))
// Setup has to complete successfully or transaction fails.
require(executeDelegateCall(to, data, gasleft()), "Could not finish initialization");
}
/// @dev Allows to add a module to the whitelist.
/// This can only be done via a Safe transaction.
/// @notice Enables the module `module` for the Safe.
/// @param module Module to be whitelisted.
function enableModule(Module module)
public
authorized
{
// Module address cannot be null or sentinel.
require(address(module) != address(0) && address(module) != SENTINEL_MODULES, "Invalid module address provided");
// Module cannot be added twice.
require(modules[address(module)] == address(0), "Module has already been added");
modules[address(module)] = modules[SENTINEL_MODULES];
modules[SENTINEL_MODULES] = address(module);
emit EnabledModule(module);
}
/// @dev Allows to remove a module from the whitelist.
/// This can only be done via a Safe transaction.
/// @notice Disables the module `module` for the Safe.
/// @param prevModule Module that pointed to the module to be removed in the linked list
/// @param module Module to be removed.
function disableModule(Module prevModule, Module module)
public
authorized
{
// Validate module address and check that it corresponds to module index.
require(address(module) != address(0) && address(module) != SENTINEL_MODULES, "Invalid module address provided");
require(modules[address(prevModule)] == address(module), "Invalid prevModule, module pair provided");
modules[address(prevModule)] = modules[address(module)];
modules[address(module)] = address(0);
emit DisabledModule(module);
}
/// @dev Allows a Module to execute a Safe transaction without any further confirmations.
/// @param to Destination address of module transaction.
/// @param value Ether value of module transaction.
/// @param data Data payload of module transaction.
/// @param operation Operation type of module transaction.
function execTransactionFromModule(address to, uint256 value, bytes memory data, Enum.Operation operation)
public
returns (bool success)
{
// Only whitelisted modules are allowed.
require(msg.sender != SENTINEL_MODULES && modules[msg.sender] != address(0), "Method can only be called from an enabled module");
// Execute transaction without further confirmations.
success = execute(to, value, data, operation, gasleft());
if (success) emit ExecutionFromModuleSuccess(msg.sender);
else emit ExecutionFromModuleFailure(msg.sender);
}
/// @dev Allows a Module to execute a Safe transaction without any further confirmations and return data
/// @param to Destination address of module transaction.
/// @param value Ether value of module transaction.
/// @param data Data payload of module transaction.
/// @param operation Operation type of module transaction.
function execTransactionFromModuleReturnData(address to, uint256 value, bytes memory data, Enum.Operation operation)
public
returns (bool success, bytes memory returnData)
{
success = execTransactionFromModule(to, value, data, operation);
// solium-disable-next-line security/no-inline-assembly
assembly {
// Load free memory location
let ptr := mload(0x40)
// We allocate memory for the return data by setting the free memory location to
// current free memory location + data size + 32 bytes for data size value
mstore(0x40, add(ptr, add(returndatasize(), 0x20)))
// Store the size
mstore(ptr, returndatasize())
// Store the data
returndatacopy(add(ptr, 0x20), 0, returndatasize())
// Point the return data to the correct memory location
returnData := ptr
}
}
/// @dev Returns if an module is enabled
/// @return True if the module is enabled
function isModuleEnabled(Module module)
public
view
returns (bool)
{
return SENTINEL_MODULES != address(module) && modules[address(module)] != address(0);
}
/// @dev Returns array of first 10 modules.
/// @return Array of modules.
function getModules()
public
view
returns (address[] memory)
{
(address[] memory array,) = getModulesPaginated(SENTINEL_MODULES, 10);
return array;
}
/// @dev Returns array of modules.
/// @param start Start of the page.
/// @param 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)
{
// Init array with max page size
array = new address[](pageSize);
// Populate return array
uint256 moduleCount = 0;
address currentModule = modules[start];
while(currentModule != address(0x0) && currentModule != SENTINEL_MODULES && moduleCount < pageSize) {
array[moduleCount] = currentModule;
currentModule = modules[currentModule];
moduleCount++;
}
next = currentModule;
// Set correct size of returned array
// solium-disable-next-line security/no-inline-assembly
assembly {
mstore(array, moduleCount)
}
}
}
| 82,690 |
55 | // phase-1 | startTimes[1] = 1525172460; //MAY 01, 2018 11:01 AM GMT
endTimes[1] = 1526382000; //MAY 15, 2018 11:00 AM GMT
hardCaps[1] = 20000 ether;
bonusPercentages[1][0] = 25;// above 100 ether
bonusPercentages[1][1] = 20;// 10<=x<=100
bonusPercentages[1][2] = 15;// less than 10 ether
| startTimes[1] = 1525172460; //MAY 01, 2018 11:01 AM GMT
endTimes[1] = 1526382000; //MAY 15, 2018 11:00 AM GMT
hardCaps[1] = 20000 ether;
bonusPercentages[1][0] = 25;// above 100 ether
bonusPercentages[1][1] = 20;// 10<=x<=100
bonusPercentages[1][2] = 15;// less than 10 ether
| 32,527 |
730 | // Aave lending pool interface Documentation: https:docs.aave.com/developers/the-core-protocol/lendingpool/ilendingpool refer to the whitepaper, section 1.1 basic concepts for a formal description of these properties. | interface ILendingPool {
/**
* @dev Deposits an `amount` of underlying asset into the reserve, receiving in return overlying aTokens.
* - E.g. User deposits 100 USDC and gets in return 100 aUSDC
* @param asset The address of the underlying asset to deposit
* @param amount The amount to be deposited
* @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user
* wants to receive them on his own wallet, or a different address if the beneficiary of aTokens
* is a different wallet
* @param referralCode Code used to register the integrator originating the operation, for potential rewards.
* 0 if the action is executed directly by the user, without any middle-man
**/
function deposit(
address asset,
uint256 amount,
address onBehalfOf,
uint16 referralCode
) external;
/**
* @dev Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned
* E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC
* @param asset The address of the underlying asset to withdraw
* @param amount The underlying amount to be withdrawn
* - Send the value type(uint256).max in order to withdraw the whole aToken balance
* @param to Address that will receive the underlying, same as msg.sender if the user
* wants to receive it on his own wallet, or a different address if the beneficiary is a
* different wallet
* @return The final amount withdrawn
**/
function withdraw(
address asset,
uint256 amount,
address to
) external returns (uint256);
/**
* @dev Returns the normalized income normalized income of the reserve
* @param asset The address of the underlying asset of the reserve
* @return The reserve's normalized income
*/
function getReserveNormalizedIncome(address asset)
external
view
returns (uint256);
}
| interface ILendingPool {
/**
* @dev Deposits an `amount` of underlying asset into the reserve, receiving in return overlying aTokens.
* - E.g. User deposits 100 USDC and gets in return 100 aUSDC
* @param asset The address of the underlying asset to deposit
* @param amount The amount to be deposited
* @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user
* wants to receive them on his own wallet, or a different address if the beneficiary of aTokens
* is a different wallet
* @param referralCode Code used to register the integrator originating the operation, for potential rewards.
* 0 if the action is executed directly by the user, without any middle-man
**/
function deposit(
address asset,
uint256 amount,
address onBehalfOf,
uint16 referralCode
) external;
/**
* @dev Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned
* E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC
* @param asset The address of the underlying asset to withdraw
* @param amount The underlying amount to be withdrawn
* - Send the value type(uint256).max in order to withdraw the whole aToken balance
* @param to Address that will receive the underlying, same as msg.sender if the user
* wants to receive it on his own wallet, or a different address if the beneficiary is a
* different wallet
* @return The final amount withdrawn
**/
function withdraw(
address asset,
uint256 amount,
address to
) external returns (uint256);
/**
* @dev Returns the normalized income normalized income of the reserve
* @param asset The address of the underlying asset of the reserve
* @return The reserve's normalized income
*/
function getReserveNormalizedIncome(address asset)
external
view
returns (uint256);
}
| 59,600 |
433 | // Withdraw asset/Only vault contract can withdraw asset/to Withdraw address/amount Withdraw amount/scale Withdraw percentage | function withdraw(address to, uint256 amount, uint256 scale) external onlyVault {
uint256 surplusAmount = ioToken.balanceOf(address(this));
if (surplusAmount < amount) {
_decreaseLiquidityByScale(scale);
for (uint256 i = 0; i < underlyings.length(); i++) {
address token = underlyings.at(i);
uint256 balance = IERC20(token).balanceOf(address(this));
if (token != address(ioToken) && balance > 0) {
exactInput(token, address(ioToken), balance, 0);
}
}
}
surplusAmount = ioToken.balanceOf(address(this));
if (surplusAmount < amount) {
amount = surplusAmount;
}
ioToken.safeTransfer(to, amount);
}
| function withdraw(address to, uint256 amount, uint256 scale) external onlyVault {
uint256 surplusAmount = ioToken.balanceOf(address(this));
if (surplusAmount < amount) {
_decreaseLiquidityByScale(scale);
for (uint256 i = 0; i < underlyings.length(); i++) {
address token = underlyings.at(i);
uint256 balance = IERC20(token).balanceOf(address(this));
if (token != address(ioToken) && balance > 0) {
exactInput(token, address(ioToken), balance, 0);
}
}
}
surplusAmount = ioToken.balanceOf(address(this));
if (surplusAmount < amount) {
amount = surplusAmount;
}
ioToken.safeTransfer(to, amount);
}
| 10,702 |
57 | // set by the engine during minting, immutable | MINT_DATA,
| MINT_DATA,
| 43,511 |
45 | // 255.255.255.255/32 | (ipv4address != 0xFFFFFFFF),
"Wrong IP");
| (ipv4address != 0xFFFFFFFF),
"Wrong IP");
| 50,236 |
16 | // All spaces Ids from facility by Id | function getSpaceIdsByFacilityId(bytes32 _lodgingFacilityId) public view override returns (bytes32[] memory) {
return _spaceIdsByFacilityId[_lodgingFacilityId];
}
| function getSpaceIdsByFacilityId(bytes32 _lodgingFacilityId) public view override returns (bytes32[] memory) {
return _spaceIdsByFacilityId[_lodgingFacilityId];
}
| 8,874 |
489 | // Reverts if the sender is not the oracle of the request.Emits ChainlinkFulfilled event. requestId The request ID for fulfillment / | modifier recordChainlinkFulfillment(bytes32 requestId) {
require(msg.sender == s_pendingRequests[requestId], "Source must be the oracle of the request");
delete s_pendingRequests[requestId];
emit ChainlinkFulfilled(requestId);
_;
}
| modifier recordChainlinkFulfillment(bytes32 requestId) {
require(msg.sender == s_pendingRequests[requestId], "Source must be the oracle of the request");
delete s_pendingRequests[requestId];
emit ChainlinkFulfilled(requestId);
_;
}
| 12,824 |
368 | // CONSTRUCTOR //USER METHODS //Retrieve the results of the last spin of a plyer, for web3 calls._playerAddress The address of the player/ | function getLastSpinOutput(address _playerAddress)
public view
returns (uint winAmount, uint lossAmount, uint jackpotAmount, uint jackpotWins, uint[] memory output)
{
| function getLastSpinOutput(address _playerAddress)
public view
returns (uint winAmount, uint lossAmount, uint jackpotAmount, uint jackpotWins, uint[] memory output)
{
| 18,926 |
11 | // _name = "MetaWoof";_symbol = "$WOOF"; | _name = "MetaWoof";
_symbol = "$WOOF";
_decimals = 18;
_totalSupply = 1000000000000000000000000000;
_balances[creator()] = _totalSupply;
emit Transfer(address(0), creator(), _totalSupply);
| _name = "MetaWoof";
_symbol = "$WOOF";
_decimals = 18;
_totalSupply = 1000000000000000000000000000;
_balances[creator()] = _totalSupply;
emit Transfer(address(0), creator(), _totalSupply);
| 29,253 |
81 | // Implements IETOCommitment |
function claim()
external
withStateTransition()
onlyStates(ETOState.Claim, ETOState.Payout)
|
function claim()
external
withStateTransition()
onlyStates(ETOState.Claim, ETOState.Payout)
| 33,936 |
3 | // Check whether the derived factory has been disabled. / | function isDisabled() public view returns (bool) {
return _disabled;
}
| function isDisabled() public view returns (bool) {
return _disabled;
}
| 4,412 |
5 | // the medium-term public signed public prekey associated with this contract | bytes32 public signedPreKey;
| bytes32 public signedPreKey;
| 23,473 |
582 | // Make sure tax isn't 100% | require(_amount > 0, "Amount 0 after tax");
if(pool.depositFeeBP > 0){
uint256 depositFee = _amount.mul(pool.depositFeeBP).div(10000);
pool.lpToken.safeTransfer(feeAddress, depositFee);
user.amount = user.amount.add(_amount).sub(depositFee);
}else{
| require(_amount > 0, "Amount 0 after tax");
if(pool.depositFeeBP > 0){
uint256 depositFee = _amount.mul(pool.depositFeeBP).div(10000);
pool.lpToken.safeTransfer(feeAddress, depositFee);
user.amount = user.amount.add(_amount).sub(depositFee);
}else{
| 28,472 |
14 | // Phase 2 Added to staking | users[msg.sender].stakingpayout = users[msg.sender]
.stakingpayout
.add(token_fee);
users[msg.sender].total_stakingpayout = users[msg.sender]
.total_stakingpayout
.add(token_fee);
total_staked = total_staked.add(token_fee);
current_staked = current_staked.add(token_fee);
| users[msg.sender].stakingpayout = users[msg.sender]
.stakingpayout
.add(token_fee);
users[msg.sender].total_stakingpayout = users[msg.sender]
.total_stakingpayout
.add(token_fee);
total_staked = total_staked.add(token_fee);
current_staked = current_staked.add(token_fee);
| 38,241 |
69 | // return the refund address for non-claimed tokens | function refundAddress() external view returns (address);
| function refundAddress() external view returns (address);
| 2,132 |
161 | // called during emergency exit. Rebalance after to halt pool | function liquidateAllPositions() internal override returns (uint _amountFreed) {
_amountFreed = _liquidateAllPositions();
_adjustPosition(type(uint).max);
}
| function liquidateAllPositions() internal override returns (uint _amountFreed) {
_amountFreed = _liquidateAllPositions();
_adjustPosition(type(uint).max);
}
| 18,636 |
18 | // Deserialize txBytes to txParams | ECCUtils.TxParams memory txParams = ECCUtils.deserializeTxParams(txBytes);
require(!eccd.checkIfFromChainTxExist(txParams.fromChainId, txParams.txHash), "the transaction has been executed!");
require(eccd.markFromChainTxExist(txParams.fromChainId, txParams.txHash), "Save crosschain tx exist failed!");
| ECCUtils.TxParams memory txParams = ECCUtils.deserializeTxParams(txBytes);
require(!eccd.checkIfFromChainTxExist(txParams.fromChainId, txParams.txHash), "the transaction has been executed!");
require(eccd.markFromChainTxExist(txParams.fromChainId, txParams.txHash), "Save crosschain tx exist failed!");
| 16,252 |
49 | // return info ---------------------------------------------------------- | function getOwner() public view returns(address){
return _owner;
}
| function getOwner() public view returns(address){
return _owner;
}
| 20,493 |
37 | // ========== PUBLIC FUNCTIONS ========== / | function mintFractionalFRAX(uint256 collateral_amount, uint256 fxs_amount, uint256 FRAX_out_min) public notMintPaused returns (uint256, uint256, uint256) {
uint256 global_collateral_ratio = FRAX.global_collateral_ratio();
// Do not need to equalize decimals between FXS and collateral, getAmountOut & reserves takes care of it
// Still need to adjust for FRAX (18 decimals) and collateral (not always 18 decimals)
uint256 total_frax_mint;
uint256 collat_needed;
uint256 fxs_needed;
if (global_collateral_ratio == 1e6) { // 1-to-1
total_frax_mint = collateral_amount.mul(10 ** missing_decimals);
collat_needed = collateral_amount;
fxs_needed = 0;
} else if (global_collateral_ratio == 0) { // Algorithmic
// Assumes 1 collat = 1 FRAX at all times
total_frax_mint = getAmountOut(fxs_amount, fxs_virtual_reserves, collat_virtual_reserves, minting_fee);
_update(fxs_virtual_reserves.add(fxs_amount), collat_virtual_reserves.sub(total_frax_mint), fxs_virtual_reserves, collat_virtual_reserves);
total_frax_mint = total_frax_mint.mul(10 ** missing_decimals);
collat_needed = 0;
fxs_needed = fxs_amount;
} else { // Fractional
// Assumes 1 collat = 1 FRAX at all times
uint256 frax_mint_from_fxs = getAmountOut(fxs_amount, fxs_virtual_reserves, collat_virtual_reserves, minting_fee);
_update(fxs_virtual_reserves.add(fxs_amount), collat_virtual_reserves.sub(frax_mint_from_fxs), fxs_virtual_reserves, collat_virtual_reserves);
collat_needed = frax_mint_from_fxs.mul(1e6).div(uint(1e6).sub(global_collateral_ratio)); // find collat needed at collateral ratio
require(collat_needed <= collateral_amount, "Not enough collateral inputted");
uint256 frax_mint_from_collat = collat_needed.mul(10 ** missing_decimals);
frax_mint_from_fxs = frax_mint_from_fxs.mul(10 ** missing_decimals);
total_frax_mint = frax_mint_from_fxs.add(frax_mint_from_collat);
fxs_needed = fxs_amount;
}
require(total_frax_mint >= FRAX_out_min, "Slippage limit reached");
require(collateral_token.balanceOf(address(this)).add(collateral_invested).sub(unclaimedPoolCollateral).add(collat_needed) <= pool_ceiling, "Pool ceiling reached, no more FRAX can be minted with this collateral");
FXS.pool_burn_from(msg.sender, fxs_needed);
collateral_token.transferFrom(msg.sender, address(this), collat_needed);
// Sanity check to make sure the FRAX mint amount is close to the expected amount from the collateral input
// Using collateral_needed here could cause problems if the reserves are off
// Useful in case of a sandwich attack or some other fault with the virtual reserves
// Assumes $1 collateral (USDC, USDT, DAI, etc)
require(total_frax_mint <= collateral_amount.mul(10 ** missing_decimals).mul(uint256(1e6).add(max_drift_band)).div(global_collateral_ratio), "[max_drift_band] Too much FRAX being minted");
FRAX.pool_mint(msg.sender, total_frax_mint);
return (total_frax_mint, collat_needed, fxs_needed);
}
| function mintFractionalFRAX(uint256 collateral_amount, uint256 fxs_amount, uint256 FRAX_out_min) public notMintPaused returns (uint256, uint256, uint256) {
uint256 global_collateral_ratio = FRAX.global_collateral_ratio();
// Do not need to equalize decimals between FXS and collateral, getAmountOut & reserves takes care of it
// Still need to adjust for FRAX (18 decimals) and collateral (not always 18 decimals)
uint256 total_frax_mint;
uint256 collat_needed;
uint256 fxs_needed;
if (global_collateral_ratio == 1e6) { // 1-to-1
total_frax_mint = collateral_amount.mul(10 ** missing_decimals);
collat_needed = collateral_amount;
fxs_needed = 0;
} else if (global_collateral_ratio == 0) { // Algorithmic
// Assumes 1 collat = 1 FRAX at all times
total_frax_mint = getAmountOut(fxs_amount, fxs_virtual_reserves, collat_virtual_reserves, minting_fee);
_update(fxs_virtual_reserves.add(fxs_amount), collat_virtual_reserves.sub(total_frax_mint), fxs_virtual_reserves, collat_virtual_reserves);
total_frax_mint = total_frax_mint.mul(10 ** missing_decimals);
collat_needed = 0;
fxs_needed = fxs_amount;
} else { // Fractional
// Assumes 1 collat = 1 FRAX at all times
uint256 frax_mint_from_fxs = getAmountOut(fxs_amount, fxs_virtual_reserves, collat_virtual_reserves, minting_fee);
_update(fxs_virtual_reserves.add(fxs_amount), collat_virtual_reserves.sub(frax_mint_from_fxs), fxs_virtual_reserves, collat_virtual_reserves);
collat_needed = frax_mint_from_fxs.mul(1e6).div(uint(1e6).sub(global_collateral_ratio)); // find collat needed at collateral ratio
require(collat_needed <= collateral_amount, "Not enough collateral inputted");
uint256 frax_mint_from_collat = collat_needed.mul(10 ** missing_decimals);
frax_mint_from_fxs = frax_mint_from_fxs.mul(10 ** missing_decimals);
total_frax_mint = frax_mint_from_fxs.add(frax_mint_from_collat);
fxs_needed = fxs_amount;
}
require(total_frax_mint >= FRAX_out_min, "Slippage limit reached");
require(collateral_token.balanceOf(address(this)).add(collateral_invested).sub(unclaimedPoolCollateral).add(collat_needed) <= pool_ceiling, "Pool ceiling reached, no more FRAX can be minted with this collateral");
FXS.pool_burn_from(msg.sender, fxs_needed);
collateral_token.transferFrom(msg.sender, address(this), collat_needed);
// Sanity check to make sure the FRAX mint amount is close to the expected amount from the collateral input
// Using collateral_needed here could cause problems if the reserves are off
// Useful in case of a sandwich attack or some other fault with the virtual reserves
// Assumes $1 collateral (USDC, USDT, DAI, etc)
require(total_frax_mint <= collateral_amount.mul(10 ** missing_decimals).mul(uint256(1e6).add(max_drift_band)).div(global_collateral_ratio), "[max_drift_band] Too much FRAX being minted");
FRAX.pool_mint(msg.sender, total_frax_mint);
return (total_frax_mint, collat_needed, fxs_needed);
}
| 51,644 |
0 | // / | interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval( address indexed owner, address indexed spender, uint256 value );
}
| interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval( address indexed owner, address indexed spender, uint256 value );
}
| 45,312 |
239 | // Assigns ownership of a specific warrior to an address. | function _transfer(address _from, address _to, uint256 _tokenId) internal {
// When creating new warriors _from is 0x0, but we can't account that address.
if (_from != address(0)) {
_clearApproval(_tokenId);
_removeTokenFrom(_from, _tokenId);
}
_addTokenTo(_to, _tokenId);
// Emit the transfer event.
Transfer(_from, _to, _tokenId);
}
| function _transfer(address _from, address _to, uint256 _tokenId) internal {
// When creating new warriors _from is 0x0, but we can't account that address.
if (_from != address(0)) {
_clearApproval(_tokenId);
_removeTokenFrom(_from, _tokenId);
}
_addTokenTo(_to, _tokenId);
// Emit the transfer event.
Transfer(_from, _to, _tokenId);
}
| 40,832 |
15 | // ========================== FEES | struct taxes {
uint buyFee;
uint sellFee;
uint transferFee;
}
| struct taxes {
uint buyFee;
uint sellFee;
uint transferFee;
}
| 64,565 |
44 | // Creates a new Avatar | function createAvatar(string _name, uint256 _rank) public onlyCLevel {
_createAvatar(_name, address(this), _rank);
}
| function createAvatar(string _name, uint256 _rank) public onlyCLevel {
_createAvatar(_name, address(this), _rank);
}
| 40,283 |
26 | // Implementation of the {IERC20} interface.that a supply mechanism has to be added in a derived contract using {_mint}.For a generic mechanism see {ERC20PresetMinterPauser}.Additionally, an {Approval} event is emitted on calls to {transferFrom}.Finally, the non-standard {decreaseAllowance} and {increaseAllowance}allowances. See {IERC20-approve}./ Sets the values for {name} and {symbol}, initializes {decimals} witha default value of 18. To select a different value for {decimals}, use {_setupDecimals}. All three of these values are immutable: they can only be set once duringconstruction. / | constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
_decimals = 18;
}
| constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
_decimals = 18;
}
| 564 |
14 | // Asserts are used to use static analysis to find bugs in your code. They should never fail | assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
| assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
| 8,587 |
243 | // NOTE: we use issuanceRatio because that is what will put us on 500% c-ratio (i.e. 20% debt ratio) | uint256 _targetDebt =
getIssuanceRatio().mul(wantToSUSD(_collateral())).div(1e18);
uint256 _balanceOfDebt = balanceOfDebt();
bool claim = true;
if (_balanceOfDebt > _targetDebt) {
uint256 _requiredPayment = _balanceOfDebt.sub(_targetDebt);
uint256 _maxCash =
balanceOfSusd().add(balanceOfSusdInVault()).mul(50).div(
100
| uint256 _targetDebt =
getIssuanceRatio().mul(wantToSUSD(_collateral())).div(1e18);
uint256 _balanceOfDebt = balanceOfDebt();
bool claim = true;
if (_balanceOfDebt > _targetDebt) {
uint256 _requiredPayment = _balanceOfDebt.sub(_targetDebt);
uint256 _maxCash =
balanceOfSusd().add(balanceOfSusdInVault()).mul(50).div(
100
| 21,052 |
51 | // For slash / | function misdemeanor(address validator)external onlySlash override{
uint256 validatorIndex = _misdemeanor(validator);
if (canEnterMaintenance(validatorIndex)) {
_enterMaintenance(validator, validatorIndex);
}
}
| function misdemeanor(address validator)external onlySlash override{
uint256 validatorIndex = _misdemeanor(validator);
if (canEnterMaintenance(validatorIndex)) {
_enterMaintenance(validator, validatorIndex);
}
}
| 16,742 |
471 | // delegates borrowing power to a user on the specific debt token delegatee the address receiving the delegated borrowing power amount the maximum amount being delegated. Delegation will stillrespect the liquidation constraints (even if delegated, a delegatee cannotforce a delegator HF to go below 1) / | function approveDelegation(address delegatee, uint256 amount) external override {
_borrowAllowances[_msgSender()][delegatee] = amount;
emit BorrowAllowanceDelegated(_msgSender(), delegatee, UNDERLYING_ASSET_ADDRESS, amount);
}
| function approveDelegation(address delegatee, uint256 amount) external override {
_borrowAllowances[_msgSender()][delegatee] = amount;
emit BorrowAllowanceDelegated(_msgSender(), delegatee, UNDERLYING_ASSET_ADDRESS, amount);
}
| 25,076 |
289 | // Accrued protocol fees in terms of token1 | uint256 public protocolFees1;
| uint256 public protocolFees1;
| 42,885 |
5 | // Next reward duration in blocks | uint256 public nextRewardDurationInBlocks;
| uint256 public nextRewardDurationInBlocks;
| 52,783 |
9 | // Bridges tokens via CBridge/_bridgeData the core information needed for bridging/_cBridgeData data specific to CBridge | function startBridgeTokensViaCBridge(
ILiFi.BridgeData memory _bridgeData,
CBridgeData calldata _cBridgeData
)
external
payable
nonReentrant
refundExcessNative(payable(msg.sender))
doesNotContainSourceSwaps(_bridgeData)
doesNotContainDestinationCalls(_bridgeData)
| function startBridgeTokensViaCBridge(
ILiFi.BridgeData memory _bridgeData,
CBridgeData calldata _cBridgeData
)
external
payable
nonReentrant
refundExcessNative(payable(msg.sender))
doesNotContainSourceSwaps(_bridgeData)
doesNotContainDestinationCalls(_bridgeData)
| 11,692 |
22 | // Sets `adminRole` as ``role``'s admin role. | * Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
| * Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
| 1,741 |
8 | // Metadata of vault, aka the id & the minter's address | VaultInfo public _vaultInfo;
VotingVaultController public _votingController;
IVaultController public _controller;
| VaultInfo public _vaultInfo;
VotingVaultController public _votingController;
IVaultController public _controller;
| 24,548 |
85 | // Map user address to referrer address. | mapping(address => address) public userReferrer;
| mapping(address => address) public userReferrer;
| 27,363 |
5 | // Register candidate to recieve votes Constraints: 1. Disallow duplicate proposals 2. Check if maxProposal cap hit / | function register(address addr) public isChairperson {
require(getProposalId(addr) == -1, "Duplicate proposal");
require(addr != chairperson, "Chairperson not allowed to stand");
proposals.push(Proposal(addr, 0));
assert(proposals.length <= numProposals); // To check whether cap limit hit
}
| function register(address addr) public isChairperson {
require(getProposalId(addr) == -1, "Duplicate proposal");
require(addr != chairperson, "Chairperson not allowed to stand");
proposals.push(Proposal(addr, 0));
assert(proposals.length <= numProposals); // To check whether cap limit hit
}
| 18,454 |
19 | // A helper variable to track match easily on the backend web server | uint matchNumber;
| uint matchNumber;
| 58,343 |
91 | // This method can be used by the controller to extract mistakenlysent tokens to this contract.dst The address that will be receiving the tokenswad The amount of tokens to transfer_token The address of the token contract that you want to recover | function transferTokens(address dst, uint wad, address _token) public onlyWithdrawer {
require( _token != address(key));
if (wad > 0) {
ERC20 token = ERC20(_token);
token.transfer(dst, wad);
}
}
| function transferTokens(address dst, uint wad, address _token) public onlyWithdrawer {
require( _token != address(key));
if (wad > 0) {
ERC20 token = ERC20(_token);
token.transfer(dst, wad);
}
}
| 50,302 |
101 | // write-off group: 4 - 100% write off | setWriteOff(4, WRITE_OFF_PHASE_E, ONE, 0);
| setWriteOff(4, WRITE_OFF_PHASE_E, ONE, 0);
| 37,259 |
16 | // set rock as not-for-sale | rocks.sellRock(id, type(uint256).max);
| rocks.sellRock(id, type(uint256).max);
| 22,306 |
69 | // MultiMint to allow multiple tokens to be minted at the same time. Price is .0777e per count/_count Total number of tokens to mint/ return _tokenIds An array of tokenids, 1 entry per token minted. | function multiMint(uint256 _count) public payable isMode(SalesState.Active) returns (uint256[] memory _tokenIds) {
uint256 price = sale.pricePerToken * _count;
require(msg.value >= price, "GG: Ether amount is under set price");
require(_count >= 1, "GG: Token count must be 1 or more");
require(totalSupply() < sale.maxPublicTokens, "GG: Max tokens reached");
return _mintToken(_msgSender(), _count, true);
}
| function multiMint(uint256 _count) public payable isMode(SalesState.Active) returns (uint256[] memory _tokenIds) {
uint256 price = sale.pricePerToken * _count;
require(msg.value >= price, "GG: Ether amount is under set price");
require(_count >= 1, "GG: Token count must be 1 or more");
require(totalSupply() < sale.maxPublicTokens, "GG: Max tokens reached");
return _mintToken(_msgSender(), _count, true);
}
| 29,075 |
201 | // verify that the protected liquidity is not removed on the same block in which it was added | require(liquidity.timestamp < time(), "ERR_TOO_EARLY");
if (_portion == PPM_RESOLUTION) {
| require(liquidity.timestamp < time(), "ERR_TOO_EARLY");
if (_portion == PPM_RESOLUTION) {
| 43,218 |
105 | // Iterate over each execution. | for (uint256 i = 0; i < totalExecutions; ) {
| for (uint256 i = 0; i < totalExecutions; ) {
| 14,587 |
7 | // Default Callback Handler - Handles supported tokens' callbacks, allowing Safes receiving these tokens. Richard Meissner - @rmeissner / | contract TokenCallbackHandler is ERC1155TokenReceiver, ERC777TokensRecipient, ERC721TokenReceiver, IERC165 {
string public constant NAME = "Default Callback Handler";
string public constant VERSION = "1.0.0";
/**
* @notice Handles ERC1155 Token callback.
* return Standardized onERC1155Received return value.
*/
function onERC1155Received(address, address, uint256, uint256, bytes calldata) external pure override returns (bytes4) {
return 0xf23a6e61;
}
/**
* @notice Handles ERC1155 Token batch callback.
* return Standardized onERC1155BatchReceived return value.
*/
function onERC1155BatchReceived(
address,
address,
uint256[] calldata,
uint256[] calldata,
bytes calldata
) external pure override returns (bytes4) {
return 0xbc197c81;
}
/**
* @notice Handles ERC721 Token callback.
* return Standardized onERC721Received return value.
*/
function onERC721Received(address, address, uint256, bytes calldata) external pure override returns (bytes4) {
return 0x150b7a02;
}
/**
* @notice Handles ERC777 Token callback.
* return nothing (not standardized)
*/
function tokensReceived(address, address, address, uint256, bytes calldata, bytes calldata) external pure override {
// We implement this for completeness, doesn't really have any value
}
/**
* @notice Implements ERC165 interface support for ERC1155TokenReceiver, ERC721TokenReceiver and IERC165.
* @param interfaceId Id of the interface.
* @return if the interface is supported.
*/
function supportsInterface(bytes4 interfaceId) external view virtual override returns (bool) {
return
interfaceId == type(ERC1155TokenReceiver).interfaceId ||
interfaceId == type(ERC721TokenReceiver).interfaceId ||
interfaceId == type(IERC165).interfaceId;
}
}
| contract TokenCallbackHandler is ERC1155TokenReceiver, ERC777TokensRecipient, ERC721TokenReceiver, IERC165 {
string public constant NAME = "Default Callback Handler";
string public constant VERSION = "1.0.0";
/**
* @notice Handles ERC1155 Token callback.
* return Standardized onERC1155Received return value.
*/
function onERC1155Received(address, address, uint256, uint256, bytes calldata) external pure override returns (bytes4) {
return 0xf23a6e61;
}
/**
* @notice Handles ERC1155 Token batch callback.
* return Standardized onERC1155BatchReceived return value.
*/
function onERC1155BatchReceived(
address,
address,
uint256[] calldata,
uint256[] calldata,
bytes calldata
) external pure override returns (bytes4) {
return 0xbc197c81;
}
/**
* @notice Handles ERC721 Token callback.
* return Standardized onERC721Received return value.
*/
function onERC721Received(address, address, uint256, bytes calldata) external pure override returns (bytes4) {
return 0x150b7a02;
}
/**
* @notice Handles ERC777 Token callback.
* return nothing (not standardized)
*/
function tokensReceived(address, address, address, uint256, bytes calldata, bytes calldata) external pure override {
// We implement this for completeness, doesn't really have any value
}
/**
* @notice Implements ERC165 interface support for ERC1155TokenReceiver, ERC721TokenReceiver and IERC165.
* @param interfaceId Id of the interface.
* @return if the interface is supported.
*/
function supportsInterface(bytes4 interfaceId) external view virtual override returns (bool) {
return
interfaceId == type(ERC1155TokenReceiver).interfaceId ||
interfaceId == type(ERC721TokenReceiver).interfaceId ||
interfaceId == type(IERC165).interfaceId;
}
}
| 30,611 |
34 | // Check the validity of an order (Make sure order make has sufficient balance + allowance for required tokens)/_order The order from which to check the validity/ return Whether the order is valid or not | function isOrderValid(Order memory _order) public view returns(bool) {
bytes32 hash = getOrderHash(_order);
uint256 amountLeft = amounts[hash];
if (amountLeft == 0) return false;
// Expired
if (_order.expirationTime == 0 || block.timestamp > _order.expirationTime) return false;
IERC20 token = IERC20(_order.paymentToken);
if (_order.side == SaleSide.Buy) {
uint8 decimals = _order.decimals;
uint256 basePrice = _order.pricePerUnit.mul(amountLeft).div(10**decimals);
uint256 makerFee = feeCalculator.getFee(_order.maker, false, IFeeCalculator.FeeType.Maker);
uint256 orderMakerFee = basePrice.mul(makerFee).div(_inverseBasisPoint);
uint256 totalPrice = basePrice.add(orderMakerFee);
uint256 userBalance = token.balanceOf(_order.maker);
uint256 allowance = token.allowance(_order.maker, address(this));
return userBalance >= totalPrice && allowance >= totalPrice;
} else if (_order.side == SaleSide.Sell) {
IPremiaOption premiaOption = IPremiaOption(_order.optionContract);
bool isApproved = premiaOption.isApprovedForAll(_order.maker, address(this));
if (_order.isDelayedWriting) {
IPremiaOption.OptionData memory data = premiaOption.optionData(_order.optionId);
IPremiaOption.OptionWriteArgs memory writeArgs = IPremiaOption.OptionWriteArgs({
token: data.token,
amount: amountLeft,
strikePrice: data.strikePrice,
expiration: data.expiration,
isCall: data.isCall
});
IPremiaOption.QuoteWrite memory quote = premiaOption.getWriteQuote(_order.maker, writeArgs, address(0), _order.decimals);
uint256 userBalance = IERC20(quote.collateralToken).balanceOf(_order.maker);
uint256 allowance = IERC20(quote.collateralToken).allowance(_order.maker, _order.optionContract);
uint256 totalPrice = quote.collateral.add(quote.fee).add(quote.feeReferrer);
return isApproved && userBalance >= totalPrice && allowance >= totalPrice;
} else {
uint256 optionBalance = premiaOption.balanceOf(_order.maker, _order.optionId);
return isApproved && optionBalance >= amountLeft;
}
}
return false;
}
| function isOrderValid(Order memory _order) public view returns(bool) {
bytes32 hash = getOrderHash(_order);
uint256 amountLeft = amounts[hash];
if (amountLeft == 0) return false;
// Expired
if (_order.expirationTime == 0 || block.timestamp > _order.expirationTime) return false;
IERC20 token = IERC20(_order.paymentToken);
if (_order.side == SaleSide.Buy) {
uint8 decimals = _order.decimals;
uint256 basePrice = _order.pricePerUnit.mul(amountLeft).div(10**decimals);
uint256 makerFee = feeCalculator.getFee(_order.maker, false, IFeeCalculator.FeeType.Maker);
uint256 orderMakerFee = basePrice.mul(makerFee).div(_inverseBasisPoint);
uint256 totalPrice = basePrice.add(orderMakerFee);
uint256 userBalance = token.balanceOf(_order.maker);
uint256 allowance = token.allowance(_order.maker, address(this));
return userBalance >= totalPrice && allowance >= totalPrice;
} else if (_order.side == SaleSide.Sell) {
IPremiaOption premiaOption = IPremiaOption(_order.optionContract);
bool isApproved = premiaOption.isApprovedForAll(_order.maker, address(this));
if (_order.isDelayedWriting) {
IPremiaOption.OptionData memory data = premiaOption.optionData(_order.optionId);
IPremiaOption.OptionWriteArgs memory writeArgs = IPremiaOption.OptionWriteArgs({
token: data.token,
amount: amountLeft,
strikePrice: data.strikePrice,
expiration: data.expiration,
isCall: data.isCall
});
IPremiaOption.QuoteWrite memory quote = premiaOption.getWriteQuote(_order.maker, writeArgs, address(0), _order.decimals);
uint256 userBalance = IERC20(quote.collateralToken).balanceOf(_order.maker);
uint256 allowance = IERC20(quote.collateralToken).allowance(_order.maker, _order.optionContract);
uint256 totalPrice = quote.collateral.add(quote.fee).add(quote.feeReferrer);
return isApproved && userBalance >= totalPrice && allowance >= totalPrice;
} else {
uint256 optionBalance = premiaOption.balanceOf(_order.maker, _order.optionId);
return isApproved && optionBalance >= amountLeft;
}
}
return false;
}
| 50,514 |
1 | // The Constructor assigns the message sender to be `owner` | constructor() public{
owner = msg.sender;
}
| constructor() public{
owner = msg.sender;
}
| 7,758 |
240 | // Only the actual admin operator can change the address / | function setAdminOperator(address adminOperator_) public {
require(msg.sender == adminOperator, "Only the actual admin operator can change the address");
emit AdminOperatorChange(adminOperator, adminOperator_);
adminOperator = adminOperator_;
}
| function setAdminOperator(address adminOperator_) public {
require(msg.sender == adminOperator, "Only the actual admin operator can change the address");
emit AdminOperatorChange(adminOperator, adminOperator_);
adminOperator = adminOperator_;
}
| 43,397 |
77 | // Sets the address of the ERC-20 token to be used as the fee. newToken The new address of the ERC-20 token to be used as the fee. / | function setErc20TokenAddress(address newToken) external onlyOwner {
require(newToken != address(0), "ACG: Invalid ERC-20 token address");
require(
newToken != erc20TokenFeeAddress,
"ACG: Token address is the same."
);
// Check if a WBNNB pair exists for the ERC20 token
address[] memory path = new address[](2);
path[0] = address(newToken);
path[1] = uniswapV2Router.WETH();
uint[] memory amounts = uniswapV2Router.getAmountsOut(1e18, path);
require(
amounts.length > 0 && amounts[amounts.length - 1] > 0,
"ACG: No WBNNB pair for ERC20 token"
);
erc20TokenFeeAddress = address(newToken);
emit SetNewErc20TokenAddress(newToken);
}
| function setErc20TokenAddress(address newToken) external onlyOwner {
require(newToken != address(0), "ACG: Invalid ERC-20 token address");
require(
newToken != erc20TokenFeeAddress,
"ACG: Token address is the same."
);
// Check if a WBNNB pair exists for the ERC20 token
address[] memory path = new address[](2);
path[0] = address(newToken);
path[1] = uniswapV2Router.WETH();
uint[] memory amounts = uniswapV2Router.getAmountsOut(1e18, path);
require(
amounts.length > 0 && amounts[amounts.length - 1] > 0,
"ACG: No WBNNB pair for ERC20 token"
);
erc20TokenFeeAddress = address(newToken);
emit SetNewErc20TokenAddress(newToken);
}
| 5,242 |
2 | // / | interface IFlashLoanReceiver {
function executeOperation(
address[] calldata assets,
uint256[] calldata amounts,
uint256[] calldata premiums,
address initiator,
bytes calldata params
) external returns (bool);
}
| interface IFlashLoanReceiver {
function executeOperation(
address[] calldata assets,
uint256[] calldata amounts,
uint256[] calldata premiums,
address initiator,
bytes calldata params
) external returns (bool);
}
| 9,027 |
400 | // ensure that we don't try to share too much | if(timePlusFee < timeRemaining) {
| if(timePlusFee < timeRemaining) {
| 32,377 |
8 | // console.log('file: LoveNotes.sol ~ line 110 ~ )purereturns ~ i2', i); | uint256 y = marginTop + ((fontSize * 6) / 5) * i;
| uint256 y = marginTop + ((fontSize * 6) / 5) * i;
| 8,034 |
50 | // Recalc issuing and burning prices/ | function recalcPrices() private {
issue_price = collateral() * fmk / _totalSupply;
burn_price = issue_price * burn_ratio / fmk;
issue_price = issue_price + issue_price * issue_increase_ratio / fmk;
}
| function recalcPrices() private {
issue_price = collateral() * fmk / _totalSupply;
burn_price = issue_price * burn_ratio / fmk;
issue_price = issue_price + issue_price * issue_increase_ratio / fmk;
}
| 41,671 |
197 | // compute unstake amount in shares | uint256 shares = totalStakingShares.mul(amount).div(totalStaked());
require(shares > 0, "Geyser: preview amount too small");
uint256 rawShareSeconds = 0;
uint256 timeBonusShareSeconds = 0;
| uint256 shares = totalStakingShares.mul(amount).div(totalStaked());
require(shares > 0, "Geyser: preview amount too small");
uint256 rawShareSeconds = 0;
uint256 timeBonusShareSeconds = 0;
| 2,940 |
32 | // is it new participant? | if (p.index == 0) {
p.index = ++ico.totalParticipants;
ico.participantsList[ico.totalParticipants] = msg.sender;
p.needReward = true;
p.needCalc = true;
}
| if (p.index == 0) {
p.index = ++ico.totalParticipants;
ico.participantsList[ico.totalParticipants] = msg.sender;
p.needReward = true;
p.needCalc = true;
}
| 54,092 |
23 | // ability for owner to suspend / resume the contract is necessary _suspended to suspend or resume the contract / | function suspend(bool _suspended) external onlyOwner {
suspended = _suspended;
}
| function suspend(bool _suspended) external onlyOwner {
suspended = _suspended;
}
| 35,470 |
14 | // Return address of the pooled token at given index. Reverts if tokenIndex is out of range. index the index of the tokenreturn address of the token at given index / | function getToken(uint8 index) public view returns (IERC20) {
require(index < swapStorage.pooledTokens.length, "Out of range");
return swapStorage.pooledTokens[index];
}
| function getToken(uint8 index) public view returns (IERC20) {
require(index < swapStorage.pooledTokens.length, "Out of range");
return swapStorage.pooledTokens[index];
}
| 9,978 |
54 | // ------------------------------------overridden methods------------------------------------// Overridder modifier to allow exceptions for pausing for a given addressThis modifier is added to all transfer methods by PausableToken and only allows if paused is set to false.With this override the function allows either if paused is set to false or msg.sender is allowedTransfers during the pause as well. / | modifier whenNotPaused() {
require(!paused || allowedTransfers[msg.sender]);
_;
}
| modifier whenNotPaused() {
require(!paused || allowedTransfers[msg.sender]);
_;
}
| 1,372 |
11 | // Internal function to stake given token ID tokenId token ID of the asset that is asked to be staked user user that wants to stake given token ID Logic of this function is simple. We set stake owner of given token ID as sender, and incrementnumber of staked tokens of that address. Total staked token counter is also incremented. | * The last but not least, we emit {Transfer} event to let outside world know that the given
* token ID is transferred to this contract.
*
* CONSTRAINTS:
* 1) Given token ID should not be staked beforehand
* 2) User should be the owner of the given token ID
*/
function _stake(uint256 tokenId, address user) internal virtual {
if (_tokenIdToStakeOwner[tokenId] != address(0))
revert TokenIsAlreadyStaked();
if (super.ownerOf(tokenId) != user)
revert OnlyOwnerCanStake();
_tokenIdToStakeOwner[tokenId] = user;
unchecked {
++_walletToStakedToken[user];
++_totalStakedTokens;
}
emit Transfer(user, address(this), tokenId);
}
| * The last but not least, we emit {Transfer} event to let outside world know that the given
* token ID is transferred to this contract.
*
* CONSTRAINTS:
* 1) Given token ID should not be staked beforehand
* 2) User should be the owner of the given token ID
*/
function _stake(uint256 tokenId, address user) internal virtual {
if (_tokenIdToStakeOwner[tokenId] != address(0))
revert TokenIsAlreadyStaked();
if (super.ownerOf(tokenId) != user)
revert OnlyOwnerCanStake();
_tokenIdToStakeOwner[tokenId] = user;
unchecked {
++_walletToStakedToken[user];
++_totalStakedTokens;
}
emit Transfer(user, address(this), tokenId);
}
| 35,579 |
10 | // Starts the contract. All functions but required to execute only inemergency continue the execution / | function start() onlyStopper public {
stopped = false;
}
| function start() onlyStopper public {
stopped = false;
}
| 52,114 |
6 | // Maps address to ability ids. / | mapping(address => uint256) public addressToAbility;
| mapping(address => uint256) public addressToAbility;
| 16,307 |
62 | // Update reward variables of the given pool./pid The index of the pool. See `poolInfo`./ return pool Returns the pool that was updated. | function updatePool(uint256 pid) public returns (PoolInfo memory pool) {
pool = poolInfo[pid];
if (block.timestamp > pool.lastRewardTime) {
uint256 lpSupply = IMasterChefV2(MASTERCHEF_V2).lpToken(pid).balanceOf(MASTERCHEF_V2);
if (lpSupply > 0) {
uint256 time = block.timestamp.sub(pool.lastRewardTime);
uint256 sushiReward = time.mul(rewardPerSecond);
pool.accSushiPerShare = pool.accSushiPerShare.add((sushiReward.mul(ACC_TOKEN_PRECISION) / lpSupply).to128());
}
pool.lastRewardTime = block.timestamp.to64();
poolInfo[pid] = pool;
emit LogUpdatePool(pid, pool.lastRewardTime, lpSupply, pool.accSushiPerShare);
}
}
| function updatePool(uint256 pid) public returns (PoolInfo memory pool) {
pool = poolInfo[pid];
if (block.timestamp > pool.lastRewardTime) {
uint256 lpSupply = IMasterChefV2(MASTERCHEF_V2).lpToken(pid).balanceOf(MASTERCHEF_V2);
if (lpSupply > 0) {
uint256 time = block.timestamp.sub(pool.lastRewardTime);
uint256 sushiReward = time.mul(rewardPerSecond);
pool.accSushiPerShare = pool.accSushiPerShare.add((sushiReward.mul(ACC_TOKEN_PRECISION) / lpSupply).to128());
}
pool.lastRewardTime = block.timestamp.to64();
poolInfo[pid] = pool;
emit LogUpdatePool(pid, pool.lastRewardTime, lpSupply, pool.accSushiPerShare);
}
}
| 8,167 |
135 | // Burns (destroys) the given amount of Bridge tokens on behalf of another account | * @dev see {ERC20-_burn} and {ERC20-allowance}
* @dev the caller must have allowance for ``accounts``'s tokens
* @param from the address that owns the tokens to be burned
* @param amount the amount of tokens to be burned
* @dev emits event Transfer
*/
function burnFrom(address from, uint256 amount) external virtual whenNotPaused {
// check if burn amount is within allowance
require(allowance(from, _msgSender()) >= amount, 'Bridge: burn amount exceeds allowance');
_approve(from, _msgSender(), allowance(from, _msgSender()) - amount);
// burn token
_burn(from, amount);
}
| * @dev see {ERC20-_burn} and {ERC20-allowance}
* @dev the caller must have allowance for ``accounts``'s tokens
* @param from the address that owns the tokens to be burned
* @param amount the amount of tokens to be burned
* @dev emits event Transfer
*/
function burnFrom(address from, uint256 amount) external virtual whenNotPaused {
// check if burn amount is within allowance
require(allowance(from, _msgSender()) >= amount, 'Bridge: burn amount exceeds allowance');
_approve(from, _msgSender(), allowance(from, _msgSender()) - amount);
// burn token
_burn(from, amount);
}
| 33,039 |
7 | // called when user wants to withdraw tokens back to root chain Should burn user's tokens. This transaction will be verified when exiting on root chain amount amount of tokens to withdraw / | function withdraw(uint256 amount) external virtual {
_burn(_msgSender(), amount);
}
| function withdraw(uint256 amount) external virtual {
_burn(_msgSender(), amount);
}
| 30,291 |
33 | // This function makes it easy to get the total number of reputation/ return The total number of reputation | function totalSupply() public view returns (uint256) {
return totalSupplyAt(block.number);
}
| function totalSupply() public view returns (uint256) {
return totalSupplyAt(block.number);
}
| 10,577 |
7 | // withdraw only as much as needed from the vault | uint _withdraw = _yCrv.sub(here).mul(1e18).div(controller.getPricePerFullShare(address(yCrv)));
controller.vaultWithdraw(yCrv, _withdraw);
_yCrv = yCrv.balanceOf(address(this));
| uint _withdraw = _yCrv.sub(here).mul(1e18).div(controller.getPricePerFullShare(address(yCrv)));
controller.vaultWithdraw(yCrv, _withdraw);
_yCrv = yCrv.balanceOf(address(this));
| 41,100 |
23 | // From https:github.com/Arachnid/solidity-stringutils/blob/b9a6f6615cf18a87a823cbc461ce9e140a61c305/src/strings.sol | function _memcpy(
uint256 dest,
uint256 src,
uint256 len
| function _memcpy(
uint256 dest,
uint256 src,
uint256 len
| 24,443 |
86 | // Creates `amount` tokens and assigns them to `msg.sender`, increasingthe total supply. Requirements - `msg.sender` must be the token owner / | function mint(uint256 amount) public onlyOwner returns (bool) {
_mint(_msgSender(), amount);
return true;
}
| function mint(uint256 amount) public onlyOwner returns (bool) {
_mint(_msgSender(), amount);
return true;
}
| 7,588 |
161 | // Emit event tracking current full price per share/Provides a pure on-chain way of approximating APY | function trackFullPricePerShare() external {
_onlyAuthorizedActors();
emit FullPricePerShareUpdated(getPricePerFullShare(), now, block.number);
}
| function trackFullPricePerShare() external {
_onlyAuthorizedActors();
emit FullPricePerShareUpdated(getPricePerFullShare(), now, block.number);
}
| 28,932 |
13 | // Transfer shares from a user account to another one./token The ERC-20 token to transfer./from which user to pull the tokens./to which user to push the tokens./share The amount of `token` in shares. | function transfer(
address token,
address from,
address to,
uint256 share
) external;
| function transfer(
address token,
address from,
address to,
uint256 share
) external;
| 3,962 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.