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 |
|---|---|---|---|---|
22 | // Internal conversion function (from assets to shares) with support for rounding direction. Will revert if assets > 0, totalSupply > 0 and totalAssets = 0. That corresponds to a case where any assetwould represent an infinite amount of shares. / | function _convertToShares(uint256 assets, MathUpgradeable.Rounding rounding) internal view virtual returns (uint256 shares) {
uint256 supply = totalSupply();
return
(assets == 0 || supply == 0)
? _initialConvertToShares(assets, rounding)
: assets.mulDiv(supply, totalAssets(), rounding);
}
| function _convertToShares(uint256 assets, MathUpgradeable.Rounding rounding) internal view virtual returns (uint256 shares) {
uint256 supply = totalSupply();
return
(assets == 0 || supply == 0)
? _initialConvertToShares(assets, rounding)
: assets.mulDiv(supply, totalAssets(), rounding);
}
| 22,741 |
45 | // Call to one of the template addresses as factory owner _templateAddress Address of the template _data Data of the call / | function transact(address _templateAddress, bytes memory _data)
external
onlyFactoryOwner
returns (bool success, bytes memory result)
| function transact(address _templateAddress, bytes memory _data)
external
onlyFactoryOwner
returns (bool success, bytes memory result)
| 50,259 |
12 | // Save this for an assertion in the future | uint previousBalances = balanceOf[_from] + balanceOf[_to];
| uint previousBalances = balanceOf[_from] + balanceOf[_to];
| 667 |
5 | // Trades must be executed within time window | modifier onTime(uint256 minTimestamp, uint256 maxTimestamp) {
require(maxTimestamp >= block.timestamp, "trade too late");
require(minTimestamp <= block.timestamp, "trade too early");
_;
}
| modifier onTime(uint256 minTimestamp, uint256 maxTimestamp) {
require(maxTimestamp >= block.timestamp, "trade too late");
require(minTimestamp <= block.timestamp, "trade too early");
_;
}
| 31,217 |
14 | // Add extra owner. / | function addOwner(address owner) onlyOwner public {
require(owner != address(0));
require(!isOwner[owner]);
ownerHistory.push(owner);
isOwner[owner] = true;
emit OwnerAddedEvent(owner);
}
| function addOwner(address owner) onlyOwner public {
require(owner != address(0));
require(!isOwner[owner]);
ownerHistory.push(owner);
isOwner[owner] = true;
emit OwnerAddedEvent(owner);
}
| 49,373 |
11 | // add event details to event array mapped to the current msg.sender | eventToOrganizerMapping[msg.sender].push(details);
| eventToOrganizerMapping[msg.sender].push(details);
| 2,716 |
26 | // Changes the owner of the contract | function setOwner(address newOwner) public onlyOwner {
emit SetOwner(owner, newOwner);
owner = newOwner;
}
| function setOwner(address newOwner) public onlyOwner {
emit SetOwner(owner, newOwner);
owner = newOwner;
}
| 14,251 |
44 | // check the address is admin of kyc contract | mapping (address => bool) public admin;
event Registered(address indexed _addr);
event Unregistered(address indexed _addr);
event NewAdmin(address indexed _addr);
| mapping (address => bool) public admin;
event Registered(address indexed _addr);
event Unregistered(address indexed _addr);
event NewAdmin(address indexed _addr);
| 7,108 |
10 | // By specifiying the type of the flowers, quantity of them, owner and managers can complete a request (only owner or managers can access this function). | function submitRequestArrayExtra(uint requestID, uint[] calldata extra) external returns (uint8 status, uint reqID) {
if (extra.length < minimumNumberOfRequestExtraElements || extra.length > maximumNumberOfRequestExtraElements) {
emit FunctionStatus(InvalidInput);
return (InvalidInput, 0);
}
if(!(msg.sender == owner() || isManager(msg.sender))) {
emit FunctionStatus(AccessDenied);
return (AccessDenied, 0);
}
if(!requests[requestID].isDefined) {
emit FunctionStatus(UndefinedID);
return (UndefinedID, 0);
}
if(requests[requestID].reqStage != Stage.Pending) {
emit FunctionStatus(NotPending);
return (NotPending, 0);
}
require(msg.sender == owner() || isManager(msg.sender));
require(requests[requestID].isDefined && requests[requestID].reqStage == Stage.Pending);
RequestExtra memory requestExtra;
requestExtra.quantity = extra[0];
requestExtra.flowerType = FlowerType(extra[1]);
requestsExtra[requestID] = requestExtra;
return finishSubmitRequestExtra(requestID);
}
| function submitRequestArrayExtra(uint requestID, uint[] calldata extra) external returns (uint8 status, uint reqID) {
if (extra.length < minimumNumberOfRequestExtraElements || extra.length > maximumNumberOfRequestExtraElements) {
emit FunctionStatus(InvalidInput);
return (InvalidInput, 0);
}
if(!(msg.sender == owner() || isManager(msg.sender))) {
emit FunctionStatus(AccessDenied);
return (AccessDenied, 0);
}
if(!requests[requestID].isDefined) {
emit FunctionStatus(UndefinedID);
return (UndefinedID, 0);
}
if(requests[requestID].reqStage != Stage.Pending) {
emit FunctionStatus(NotPending);
return (NotPending, 0);
}
require(msg.sender == owner() || isManager(msg.sender));
require(requests[requestID].isDefined && requests[requestID].reqStage == Stage.Pending);
RequestExtra memory requestExtra;
requestExtra.quantity = extra[0];
requestExtra.flowerType = FlowerType(extra[1]);
requestsExtra[requestID] = requestExtra;
return finishSubmitRequestExtra(requestID);
}
| 39,541 |
160 | // stop pool 0 for emergency | safeVbswapMint(_account, _pending);
| safeVbswapMint(_account, _pending);
| 20,899 |
21 | // Returns whether the specified token exists by checking to see if it has a creator _id uint256 ID of the token to query the existence ofreturn bool whether the token exists / | function _exists(uint256 _id) internal view returns (bool) {
return creators[_id] != address(0);
}
| function _exists(uint256 _id) internal view returns (bool) {
return creators[_id] != address(0);
}
| 15,054 |
209 | // finalize the auction | delete auctions[tokenId];
| delete auctions[tokenId];
| 34,677 |
21 | // Lets do a final maxSupply check here | require(totalSupply() <= m.maxSupply, "ERC20: Max supply reached");
emit Transfer(address(0), to, amount);
| require(totalSupply() <= m.maxSupply, "ERC20: Max supply reached");
emit Transfer(address(0), to, amount);
| 48,570 |
365 | // Pulls LP tokens, burns them, removes liquidity, pull option token, burns then, pushes all underlying tokens. Uses permit to pull LP tokens. optionAddress The address of the option that will be closed from burned UNI-V2 liquidity shares. liquidity The quantity of liquidity tokens to pull from _msgSender() and burn. amountAMin The minimum quantity of shortOptionTokens to receive from removing liquidity. amountBMin The minimum quantity of underlyingTokens to receive from removing liquidity. deadline The timestamp to expire a pending transaction and `permit` call.returnReturns the sum of the removed underlying tokens. / | function removeShortLiquidityThenCloseOptionsWithPermit(
address optionAddress,
uint256 liquidity,
uint256 amountAMin,
uint256 amountBMin,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
| function removeShortLiquidityThenCloseOptionsWithPermit(
address optionAddress,
uint256 liquidity,
uint256 amountAMin,
uint256 amountBMin,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
| 64,497 |
26 | // Get the name of the Asset type | function getTypeName (uint32 _type) public returns(string);
function RequestDetachment(
uint256 _tokenId
)
public;
function AttachAsset(
uint256 _tokenId
)
public;
function BatchAttachAssets(uint256[10] _ids) public;
| function getTypeName (uint32 _type) public returns(string);
function RequestDetachment(
uint256 _tokenId
)
public;
function AttachAsset(
uint256 _tokenId
)
public;
function BatchAttachAssets(uint256[10] _ids) public;
| 63,742 |
95 | // src/LandItemBar.sol/ pragma solidity ^0.6.7; // import "zeppelin-solidity/proxy/Initializable.sol"; // import "./ItemBar.sol"; / | contract LandItemBar is Initializable, ItemBar(address(0),0) {
event ForceUnequip(
uint256 indexed tokenId,
uint256 index,
address staker,
address token,
uint256 id
);
mapping(address => bool) public allowList;
mapping(uint256 => bool) public land2IsPrivate;
function initialize(address _registry, uint256 _maxAmount)
public
initializer
{
owner = msg.sender;
emit LogSetOwner(msg.sender);
registry = ISettingsRegistry(_registry);
maxAmount = _maxAmount;
}
modifier onlyLander(uint256 _landTokenId) {
address ownership = registry.addressOf(CONTRACT_OBJECT_OWNERSHIP);
require(
IERC721(ownership).ownerOf(_landTokenId) == msg.sender,
"Forbidden."
);
_;
}
modifier onlyAuth(uint256 _landTokenId, uint256 _index) override {
address ownership = registry.addressOf(CONTRACT_OBJECT_OWNERSHIP);
require(
land2IsPrivate[_landTokenId] == false ||
IERC721(ownership).ownerOf(_landTokenId) == msg.sender,
"Forbidden."
);
_;
}
modifier updateMinerStrength(uint256 _landTokenId) override {
address landResource = registry.addressOf(CONTRACT_LAND_RESOURCE);
ILandResource(landResource).updateAllMinerStrengthWhenStop(
_landTokenId
);
_;
ILandResource(landResource).updateAllMinerStrengthWhenStart(
_landTokenId
);
}
function forceUneqiup(uint256 _landTokenId, uint256 _index)
internal
updateMinerStrength(_landTokenId)
{
require(_index < maxAmount, "Index Forbidden.");
Bar storage bar = token2Bars[_landTokenId][_index];
if (bar.token == address(0)) return;
IERC721(bar.token).transferFrom(address(this), bar.staker, bar.id);
emit ForceUnequip(_landTokenId, _index, bar.staker, bar.token, bar.id);
delete token2Bars[_landTokenId][_index];
}
function setPrivate(uint256 _landTokenId)
external
onlyLander(_landTokenId)
{
require(land2IsPrivate[_landTokenId] == false, "Already is private.");
land2IsPrivate[_landTokenId] = true;
for (uint256 i = 0; i < maxAmount; i++) {
Bar storage bar = token2Bars[_landTokenId][i];
if (bar.staker != msg.sender) {
forceUneqiup(_landTokenId, i);
}
}
}
function setPublic(uint256 _landTokenId) external onlyLander(_landTokenId) {
require(land2IsPrivate[_landTokenId] == true, "Already is public.");
land2IsPrivate[_landTokenId] = false;
}
function isAllowed(address _token, uint256 _id)
public
view
override
returns (bool)
{
address ownership = registry.addressOf(CONTRACT_OBJECT_OWNERSHIP);
if (_token == ownership) {
address interstellarEncoder =
registry.addressOf(CONTRACT_INTERSTELLAR_ENCODER);
uint8 objectClass =
IInterstellarEncoder(interstellarEncoder).getObjectClass(_id);
if (
//TODO:: internal token
objectClass == ITEM_OBJECT_CLASS ||
objectClass == DRILL_OBJECT_CLASS ||
objectClass == DARWINIA_OBJECT_CLASS
) {
return true;
} else {
return false;
}
} else {
return allowList[_token];
}
}
function addSupportedToken(address _token) public auth {
allowList[_token] = true;
}
function removeSupportedToken(address _token) public auth {
allowList[_token] = false;
}
}
| contract LandItemBar is Initializable, ItemBar(address(0),0) {
event ForceUnequip(
uint256 indexed tokenId,
uint256 index,
address staker,
address token,
uint256 id
);
mapping(address => bool) public allowList;
mapping(uint256 => bool) public land2IsPrivate;
function initialize(address _registry, uint256 _maxAmount)
public
initializer
{
owner = msg.sender;
emit LogSetOwner(msg.sender);
registry = ISettingsRegistry(_registry);
maxAmount = _maxAmount;
}
modifier onlyLander(uint256 _landTokenId) {
address ownership = registry.addressOf(CONTRACT_OBJECT_OWNERSHIP);
require(
IERC721(ownership).ownerOf(_landTokenId) == msg.sender,
"Forbidden."
);
_;
}
modifier onlyAuth(uint256 _landTokenId, uint256 _index) override {
address ownership = registry.addressOf(CONTRACT_OBJECT_OWNERSHIP);
require(
land2IsPrivate[_landTokenId] == false ||
IERC721(ownership).ownerOf(_landTokenId) == msg.sender,
"Forbidden."
);
_;
}
modifier updateMinerStrength(uint256 _landTokenId) override {
address landResource = registry.addressOf(CONTRACT_LAND_RESOURCE);
ILandResource(landResource).updateAllMinerStrengthWhenStop(
_landTokenId
);
_;
ILandResource(landResource).updateAllMinerStrengthWhenStart(
_landTokenId
);
}
function forceUneqiup(uint256 _landTokenId, uint256 _index)
internal
updateMinerStrength(_landTokenId)
{
require(_index < maxAmount, "Index Forbidden.");
Bar storage bar = token2Bars[_landTokenId][_index];
if (bar.token == address(0)) return;
IERC721(bar.token).transferFrom(address(this), bar.staker, bar.id);
emit ForceUnequip(_landTokenId, _index, bar.staker, bar.token, bar.id);
delete token2Bars[_landTokenId][_index];
}
function setPrivate(uint256 _landTokenId)
external
onlyLander(_landTokenId)
{
require(land2IsPrivate[_landTokenId] == false, "Already is private.");
land2IsPrivate[_landTokenId] = true;
for (uint256 i = 0; i < maxAmount; i++) {
Bar storage bar = token2Bars[_landTokenId][i];
if (bar.staker != msg.sender) {
forceUneqiup(_landTokenId, i);
}
}
}
function setPublic(uint256 _landTokenId) external onlyLander(_landTokenId) {
require(land2IsPrivate[_landTokenId] == true, "Already is public.");
land2IsPrivate[_landTokenId] = false;
}
function isAllowed(address _token, uint256 _id)
public
view
override
returns (bool)
{
address ownership = registry.addressOf(CONTRACT_OBJECT_OWNERSHIP);
if (_token == ownership) {
address interstellarEncoder =
registry.addressOf(CONTRACT_INTERSTELLAR_ENCODER);
uint8 objectClass =
IInterstellarEncoder(interstellarEncoder).getObjectClass(_id);
if (
//TODO:: internal token
objectClass == ITEM_OBJECT_CLASS ||
objectClass == DRILL_OBJECT_CLASS ||
objectClass == DARWINIA_OBJECT_CLASS
) {
return true;
} else {
return false;
}
} else {
return allowList[_token];
}
}
function addSupportedToken(address _token) public auth {
allowList[_token] = true;
}
function removeSupportedToken(address _token) public auth {
allowList[_token] = false;
}
}
| 5,440 |
372 | // Validate the parameters for the docs / | function validateParams(uint8 shapes, uint8 hatching, uint16[3] memory color, uint8[4] memory size, uint8[2] memory position, bool exclusive) public pure {
require(shapes > 0 && shapes < 31, "invalid shape count");
require(hatching <= shapes, "invalid hatching");
require(color[2] <= 360, "invalid color");
require(color[1] <= 100, "invalid saturation");
if (!exclusive) require(color[1] >= 20, "invalid saturation");
require(color[2] <= 100, "invalid lightness");
require(size[0] <= size[1], "invalid width range");
require(size[2] <= size[3], "invalid height range");
require(position[0] <= 100, "invalid spread");
}
| function validateParams(uint8 shapes, uint8 hatching, uint16[3] memory color, uint8[4] memory size, uint8[2] memory position, bool exclusive) public pure {
require(shapes > 0 && shapes < 31, "invalid shape count");
require(hatching <= shapes, "invalid hatching");
require(color[2] <= 360, "invalid color");
require(color[1] <= 100, "invalid saturation");
if (!exclusive) require(color[1] >= 20, "invalid saturation");
require(color[2] <= 100, "invalid lightness");
require(size[0] <= size[1], "invalid width range");
require(size[2] <= size[3], "invalid height range");
require(position[0] <= 100, "invalid spread");
}
| 9,670 |
43 | // This library supports basic math operations with overflow/underflow protection. / | library SafeMath {
/**
* @dev returns the sum of _x and _y, reverts if the calculation overflows
*
* @param _x value 1
* @param _y value 2
*
* @return sum
*/
function add(uint256 _x, uint256 _y) internal pure returns (uint256) {
uint256 z = _x + _y;
require(z >= _x, "ERR_OVERFLOW");
return z;
}
/**
* @dev returns the difference of _x minus _y, reverts if the calculation underflows
*
* @param _x minuend
* @param _y subtrahend
*
* @return difference
*/
function sub(uint256 _x, uint256 _y) internal pure returns (uint256) {
require(_x >= _y, "ERR_UNDERFLOW");
return _x - _y;
}
/**
* @dev returns the product of multiplying _x by _y, reverts if the calculation overflows
*
* @param _x factor 1
* @param _y factor 2
*
* @return product
*/
function mul(uint256 _x, uint256 _y) internal pure returns (uint256) {
// gas optimization
if (_x == 0) return 0;
uint256 z = _x * _y;
require(z / _x == _y, "ERR_OVERFLOW");
return z;
}
/**
* @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
*
* @param _x dividend
* @param _y divisor
*
* @return quotient
*/
function div(uint256 _x, uint256 _y) internal pure returns (uint256) {
require(_y > 0, "ERR_DIVIDE_BY_ZERO");
uint256 c = _x / _y;
return c;
}
}
| library SafeMath {
/**
* @dev returns the sum of _x and _y, reverts if the calculation overflows
*
* @param _x value 1
* @param _y value 2
*
* @return sum
*/
function add(uint256 _x, uint256 _y) internal pure returns (uint256) {
uint256 z = _x + _y;
require(z >= _x, "ERR_OVERFLOW");
return z;
}
/**
* @dev returns the difference of _x minus _y, reverts if the calculation underflows
*
* @param _x minuend
* @param _y subtrahend
*
* @return difference
*/
function sub(uint256 _x, uint256 _y) internal pure returns (uint256) {
require(_x >= _y, "ERR_UNDERFLOW");
return _x - _y;
}
/**
* @dev returns the product of multiplying _x by _y, reverts if the calculation overflows
*
* @param _x factor 1
* @param _y factor 2
*
* @return product
*/
function mul(uint256 _x, uint256 _y) internal pure returns (uint256) {
// gas optimization
if (_x == 0) return 0;
uint256 z = _x * _y;
require(z / _x == _y, "ERR_OVERFLOW");
return z;
}
/**
* @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
*
* @param _x dividend
* @param _y divisor
*
* @return quotient
*/
function div(uint256 _x, uint256 _y) internal pure returns (uint256) {
require(_y > 0, "ERR_DIVIDE_BY_ZERO");
uint256 c = _x / _y;
return c;
}
}
| 14,000 |
36 | // Mapping from token ID to owner | mapping (uint256 => address) private _tokenOwner;
| mapping (uint256 => address) private _tokenOwner;
| 1,043 |
121 | // User withdraws tokens from the Aave protocol/_market address provider for specific market/_tokenAddr The address of the token to be withdrawn/_amount Amount of tokens to be withdrawn -> send -1 for whole amount | function withdraw(address _market, address _tokenAddr, uint256 _amount) public burnGas(8) {
address lendingPool = ILendingPoolAddressesProviderV2(_market).getLendingPool();
_tokenAddr = changeToWeth(_tokenAddr);
if (_tokenAddr == WETH_ADDRESS) {
// if weth, pull to proxy and return ETH to user
ILendingPoolV2(lendingPool).withdraw(_tokenAddr, _amount, address(this));
// needs to use balance of in case that amount is -1 for whole debt
TokenInterface(WETH_ADDRESS).withdraw(TokenInterface(WETH_ADDRESS).balanceOf(address(this)));
msg.sender.transfer(address(this).balance);
} else {
// if not eth send directly to user
ILendingPoolV2(lendingPool).withdraw(_tokenAddr, _amount, msg.sender);
}
}
| function withdraw(address _market, address _tokenAddr, uint256 _amount) public burnGas(8) {
address lendingPool = ILendingPoolAddressesProviderV2(_market).getLendingPool();
_tokenAddr = changeToWeth(_tokenAddr);
if (_tokenAddr == WETH_ADDRESS) {
// if weth, pull to proxy and return ETH to user
ILendingPoolV2(lendingPool).withdraw(_tokenAddr, _amount, address(this));
// needs to use balance of in case that amount is -1 for whole debt
TokenInterface(WETH_ADDRESS).withdraw(TokenInterface(WETH_ADDRESS).balanceOf(address(this)));
msg.sender.transfer(address(this).balance);
} else {
// if not eth send directly to user
ILendingPoolV2(lendingPool).withdraw(_tokenAddr, _amount, msg.sender);
}
}
| 18,921 |
38 | // --------Unstake zin Token | function unStakeZin(uint256 _amount)
public
| function unStakeZin(uint256 _amount)
public
| 34,833 |
61 | // Set the address's white list ID | addressWhitelists[addressToAdd] = whitelist;
| addressWhitelists[addressToAdd] = whitelist;
| 10,858 |
403 | // check owner is caller | require(ownerOf(id) == msg.sender, "NOPE");
| require(ownerOf(id) == msg.sender, "NOPE");
| 12,956 |
147 | // Choco tokens created per block. | uint256 public chocoPerBlock;
| uint256 public chocoPerBlock;
| 18,818 |
13 | // Return required number of votes vs total number of votes of all owners/ return requiredVote Required number of votes to execute request/ return totalVote Total number of votes of all owners | function voteRequirement() external view override returns (uint16 requiredVote, uint16 totalVote) {
VoteRequirement memory requirement = _voteRequirement;
return (requirement.requiredVote, requirement.totalVote);
}
| function voteRequirement() external view override returns (uint16 requiredVote, uint16 totalVote) {
VoteRequirement memory requirement = _voteRequirement;
return (requirement.requiredVote, requirement.totalVote);
}
| 22,222 |
13 | // returns array of lottery payouts / | function payoutList() public view returns (Payouts[] memory) {
return _payouts;
}
| function payoutList() public view returns (Payouts[] memory) {
return _payouts;
}
| 10,674 |
112 | // See {_transfer} and {ERC20Interface - transfer} | function transfer(address _to, uint256 _amount) public virtual override returns (bool success) {
| function transfer(address _to, uint256 _amount) public virtual override returns (bool success) {
| 39,757 |
87 | // Change the maximum cap of the presale. New value shall be greater than previous one. _maxCap The maximum cap of the presale, expressed in wei / | function setMaxCap(uint256 _maxCap) external onlyOwner {
require(_maxCap > maxCap, "_maxCap is not greater than current maxCap");
require(!hasEnded(), "presale has ended");
maxCap = _maxCap;
emit LogMaxCapChanged(msg.sender, _maxCap);
}
| function setMaxCap(uint256 _maxCap) external onlyOwner {
require(_maxCap > maxCap, "_maxCap is not greater than current maxCap");
require(!hasEnded(), "presale has ended");
maxCap = _maxCap;
emit LogMaxCapChanged(msg.sender, _maxCap);
}
| 43,246 |
199 | // Initiates the cancelling of the Auction. updates state variables in this AuctionCalling conditions: - Only the owner of the smart contract i.e Unicus platform can end an Auction. - Only if this Auction was not already canceled or finished owner_ owner of the Auction return success after updating the state variables | * Emits a {AuctionCanceled} event.
*/
function cancelAuction(address owner_) public
onlyNotCanceled
onlyNotFinished
returns (bool )
{
require(owner_ == _owner, "Only Auction owner can perform this operation");
_canceled = true;
_startTime = 0;
return true;
}
| * Emits a {AuctionCanceled} event.
*/
function cancelAuction(address owner_) public
onlyNotCanceled
onlyNotFinished
returns (bool )
{
require(owner_ == _owner, "Only Auction owner can perform this operation");
_canceled = true;
_startTime = 0;
return true;
}
| 77,841 |
4 | // Deploys a new gauge for a Balancer pool. As anyone can register arbitrary Balancer pools with the Vault,it's impossible to prove onchain that `pool` is a "valid" deployment. Care must be taken to ensure that gauges deployed from this factory aresuitable before they are added to the GaugeController. This factory disallows deploying multiple gauges for a single pool. pool The address of the pool for which to deploy a gaugereturn The address of the deployed gauge / | function create(address pool) external returns (address) {
require(_poolGauge[pool] == address(0), "Gauge already exists");
address gauge = Clones.clone(address(_gaugeImplementation));
IStakingLiquidityGauge(gauge).initialize(pool);
_isGaugeFromFactory[gauge] = true;
_poolGauge[pool] = gauge;
emit GaugeCreated(gauge, pool);
return gauge;
}
| function create(address pool) external returns (address) {
require(_poolGauge[pool] == address(0), "Gauge already exists");
address gauge = Clones.clone(address(_gaugeImplementation));
IStakingLiquidityGauge(gauge).initialize(pool);
_isGaugeFromFactory[gauge] = true;
_poolGauge[pool] = gauge;
emit GaugeCreated(gauge, pool);
return gauge;
}
| 22,526 |
14 | // ERROR |
error CannotUseCurrentAddress(address current);
error CannotUseCurrentValue(uint256 current);
error CannotUseCurrentState(bool current);
error InvalidAddress(address invalid);
error InvalidValue(uint256 invalid);
|
error CannotUseCurrentAddress(address current);
error CannotUseCurrentValue(uint256 current);
error CannotUseCurrentState(bool current);
error InvalidAddress(address invalid);
error InvalidValue(uint256 invalid);
| 5,868 |
13 | // Get last Provenance Hash for the batch / | function getLastProvenance() public view returns (string memory) {
return _provenanceHashes[_nextProvenanceHashIndex - 1];
}
| function getLastProvenance() public view returns (string memory) {
return _provenanceHashes[_nextProvenanceHashIndex - 1];
}
| 17,895 |
57 | // to withdarw ETH from contract | function withdrawETH(uint256 _amount) external onlyOwner {
require(address(this).balance >= _amount, "Invalid Amount");
payable(msg.sender).transfer(_amount);
}
| function withdrawETH(uint256 _amount) external onlyOwner {
require(address(this).balance >= _amount, "Invalid Amount");
payable(msg.sender).transfer(_amount);
}
| 2,423 |
3 | // Registration method for new insured contracts/_transactionAddress address of the transaction/_insurer address of proposed insurer | function registerInsurer(address payable _transactionAddress, address payable _insurer) public {
Transaction trxnInsurer = Transaction(_transactionAddress);
require(address(trxnInsurer.insurer) == _insurer, "Transaction is not insured by proposed registry insurer");
contractsInsuredBy[_transactionAddress].push(_insurer);
}
| function registerInsurer(address payable _transactionAddress, address payable _insurer) public {
Transaction trxnInsurer = Transaction(_transactionAddress);
require(address(trxnInsurer.insurer) == _insurer, "Transaction is not insured by proposed registry insurer");
contractsInsuredBy[_transactionAddress].push(_insurer);
}
| 15,464 |
22 | // Check owned and not phraseChecks the owner of the provided [tokenId] is the sender account If the provided word is a phrase / a burned token it will also revert | * @param tokenId - { The tokenId being dismantled }
* @dev Strictly a helper function
*/
function checkOwnedAndNotPhrase(uint256 tokenId) private {
require(ownerOf(tokenId) == msg.sender, "!OWNER");
require(tokenToWords[tokenId].length == 1, "LEXICON:CannotAssemblePhrases");
}
| * @param tokenId - { The tokenId being dismantled }
* @dev Strictly a helper function
*/
function checkOwnedAndNotPhrase(uint256 tokenId) private {
require(ownerOf(tokenId) == msg.sender, "!OWNER");
require(tokenToWords[tokenId].length == 1, "LEXICON:CannotAssemblePhrases");
}
| 43,361 |
5 | // Lock the Token in the contract | IERC20(Token).transferFrom(msg.sender, address(this), _amount);
if (totalShares == 0 || totalTokenLocked == 0) { // If no camToken exists, mint it 1:1 to the amount put in
if(depositFeeBP > 0){
| IERC20(Token).transferFrom(msg.sender, address(this), _amount);
if (totalShares == 0 || totalTokenLocked == 0) { // If no camToken exists, mint it 1:1 to the amount put in
if(depositFeeBP > 0){
| 42,195 |
35 | // Returns the amount of tokens received in redeeming CurveBTC+. _amount Amount of CurveBTC+ to redeem. / | function getRedeemAmount(uint256 _amount) public view returns (address[] memory, uint256[] memory, uint256) {
(address[] memory _singles, uint256[] memory _amounts,,) = ICompositePlus(CURVE_BTC_PLUS).getRedeemAmount(_amount);
address[] memory _lps = new address[](_singles.length);
uint256[] memory _lpAmounts = new uint256[](_singles.length);
for (uint256 i = 0; i < _singles.length; i++) {
_lps[i] = ISinglePlus(_singles[i]).token();
(_lpAmounts[i],) = ISinglePlus(_singles[i]).getRedeemAmount(_amounts[i]);
}
// Compute the amount of CurveBTC+ that could be mited with the returned LPs.
// The difference can be seen as fees.
uint256 _mintAmount = getMintAmount(_singles, _lpAmounts);
return (_lps, _lpAmounts, _amount.sub(_mintAmount));
}
| function getRedeemAmount(uint256 _amount) public view returns (address[] memory, uint256[] memory, uint256) {
(address[] memory _singles, uint256[] memory _amounts,,) = ICompositePlus(CURVE_BTC_PLUS).getRedeemAmount(_amount);
address[] memory _lps = new address[](_singles.length);
uint256[] memory _lpAmounts = new uint256[](_singles.length);
for (uint256 i = 0; i < _singles.length; i++) {
_lps[i] = ISinglePlus(_singles[i]).token();
(_lpAmounts[i],) = ISinglePlus(_singles[i]).getRedeemAmount(_amounts[i]);
}
// Compute the amount of CurveBTC+ that could be mited with the returned LPs.
// The difference can be seen as fees.
uint256 _mintAmount = getMintAmount(_singles, _lpAmounts);
return (_lps, _lpAmounts, _amount.sub(_mintAmount));
}
| 53,969 |
95 | // round 25 | ark(i, q, 11178069035565459212220861899558526502477231302924961773582350246646450941231);
sbox_partial(i, q);
mix(i, q);
| ark(i, q, 11178069035565459212220861899558526502477231302924961773582350246646450941231);
sbox_partial(i, q);
mix(i, q);
| 27,709 |
65 | // The contributers can check the actual price in wei before selling | function checkActualPrice() returns (uint256 _sellPrice)
| function checkActualPrice() returns (uint256 _sellPrice)
| 32,616 |
14 | // Place Limit | uint256 optionOneLimit = 0;
uint256 optionTwoLimit = 0;
uint256 optionThreeLimit = 0;
uint256 optionFourLimit = 0;
uint256 optionFiveLimit = 0;
uint256 optionSixLimit = 0;
| uint256 optionOneLimit = 0;
uint256 optionTwoLimit = 0;
uint256 optionThreeLimit = 0;
uint256 optionFourLimit = 0;
uint256 optionFiveLimit = 0;
uint256 optionSixLimit = 0;
| 28,162 |
46 | // Return a list of asset created by _creator _creator address representing the creator / owner of the assets./ | function getAssetsByCreator(address _creator) external view returns (uint256[] memory) {
require(_creator != address(0), "There is no asset associated with the zero address");
return assetListByCreator[_creator];
}
| function getAssetsByCreator(address _creator) external view returns (uint256[] memory) {
require(_creator != address(0), "There is no asset associated with the zero address");
return assetListByCreator[_creator];
}
| 40,322 |
26 | // Only a participant can call updateTransfer (293 for third parties) | caller_index = index_or_throw(self, msg.sender);
| caller_index = index_or_throw(self, msg.sender);
| 25,686 |
91 | // Make sure the result is less than 2256. Also prevents denominator == 0 | require(denominator > prod1);
| require(denominator > prod1);
| 38,637 |
7 | // Deposits tokens into the vault.//_amount the amount of tokens to deposit into the vault. | function deposit(uint256 _amount) external override {
vault.deposit(_amount);
}
| function deposit(uint256 _amount) external override {
vault.deposit(_amount);
}
| 5,657 |
42 | // Returns name of the NFT at index. / | function tokenNameByIndex(uint256 index) public view returns (string memory) {
return _tokenName[index];
}
| function tokenNameByIndex(uint256 index) public view returns (string memory) {
return _tokenName[index];
}
| 6,933 |
148 | // The total number of burned FAIR tokens, excluding tokens burned from a `Sell` action in the DAT. | uint public burnedSupply;
| uint public burnedSupply;
| 46,463 |
18 | // Check that the amount matches the amount provided | require(msg.value == _amount, "Incorrect amount provided");
| require(msg.value == _amount, "Incorrect amount provided");
| 9,238 |
452 | // Ensures that the storage state will not be overwritten | asset.storageState == AssetStorageState.NoChange,
"PT: invalid liquidity token"
);
| asset.storageState == AssetStorageState.NoChange,
"PT: invalid liquidity token"
);
| 88,522 |
58 | // Replaces an owner / | function changeOwner(address _to) onlyOwner() {
balances[_to] = balances[owner];
balances[owner] = 0;
owner = _to;
}
| function changeOwner(address _to) onlyOwner() {
balances[_to] = balances[owner];
balances[owner] = 0;
owner = _to;
}
| 9,980 |
30 | // No time delay revoke minter emergency function | function revokeMinter(address _auth) external onlyVault {
isMinter[_auth] = false;
}
| function revokeMinter(address _auth) external onlyVault {
isMinter[_auth] = false;
}
| 5,736 |
18 | // timestamp when token 5M BIDS is enabled | uint256 private _releaseTime;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
| uint256 private _releaseTime;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
| 32,797 |
27 | // - For the challenger to start a query | function queryBlockHeader(bytes32 superblockHash, bytes32 sessionId, bytes32 blockHash)
| function queryBlockHeader(bytes32 superblockHash, bytes32 sessionId, bytes32 blockHash)
| 15,119 |
5 | // SecuredTokenTransfer - Secure token transfer | contract SecuredTokenTransfer {
/// @dev Transfers a token and returns if it was a success
/// @param token Token that should be transferred
/// @param receiver Receiver to whom the token should be transferred
/// @param amount The amount of tokens that should be transferred
function transferToken(
address token,
address receiver,
uint256 amount
) internal returns (bool transferred) {
// 0xa9059cbb - keccack("transfer(address,uint256)")
bytes memory data = abi.encodeWithSelector(0xa9059cbb, receiver, amount);
// solhint-disable-next-line no-inline-assembly
assembly {
// We write the return value to scratch space.
// See https://docs.soliditylang.org/en/v0.7.6/internals/layout_in_memory.html#layout-in-memory
let success := call(sub(gas(), 10000), token, 0, add(data, 0x20), mload(data), 0, 0x20)
switch returndatasize()
case 0 {
transferred := success
}
case 0x20 {
transferred := iszero(or(iszero(success), iszero(mload(0))))
}
default {
transferred := 0
}
}
}
}
| contract SecuredTokenTransfer {
/// @dev Transfers a token and returns if it was a success
/// @param token Token that should be transferred
/// @param receiver Receiver to whom the token should be transferred
/// @param amount The amount of tokens that should be transferred
function transferToken(
address token,
address receiver,
uint256 amount
) internal returns (bool transferred) {
// 0xa9059cbb - keccack("transfer(address,uint256)")
bytes memory data = abi.encodeWithSelector(0xa9059cbb, receiver, amount);
// solhint-disable-next-line no-inline-assembly
assembly {
// We write the return value to scratch space.
// See https://docs.soliditylang.org/en/v0.7.6/internals/layout_in_memory.html#layout-in-memory
let success := call(sub(gas(), 10000), token, 0, add(data, 0x20), mload(data), 0, 0x20)
switch returndatasize()
case 0 {
transferred := success
}
case 0x20 {
transferred := iszero(or(iszero(success), iszero(mload(0))))
}
default {
transferred := 0
}
}
}
}
| 33,481 |
169 | // Aeternalism smart contract/Le Brian/This contract is used for trading, token sale event and future DAO | contract Polkadex is ERC20, IERC20Mintable, AccessControl {
using SafeMath for uint256;
uint256 private _cap = 10**24;
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
constructor()
ERC20("Polkadex", "PDEX")
{
/// deployer will be the default admin
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
/// grant MINTER role to deployer & issuance contract to mint token to investors
grantRole(MINTER_ROLE, msg.sender);
grantRole(MINTER_ROLE, 0x169F95FcD7D19deEE33F9c473dC83e651D28e41C);
}
/// @notice Hook before token transfer
/// @param from Address transfer token - Address(0) means minting
/// @param to Address to receive token
/// @param amount Amount to transfer (decimals 18)
function _beforeTokenTransfer(address from, address to, uint256 amount)
internal
virtual
override
{
super._beforeTokenTransfer(from, to, amount);
/// check minting doesn't exceed _cap
if (from == address(0)) {
require(totalSupply().add(amount) <= _cap, "Max cap reached");
}
}
/// @notice Mint token to specific address
/// @dev Requires sender has MINTER role
/// @param to address to receive token
/// @param amount amount to mint (decimals 18)
function mint(address to, uint256 amount)
external
override
returns(bool)
{
require(hasRole(MINTER_ROLE, msg.sender), "Not a minter");
super._mint(to, amount);
}
} | contract Polkadex is ERC20, IERC20Mintable, AccessControl {
using SafeMath for uint256;
uint256 private _cap = 10**24;
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
constructor()
ERC20("Polkadex", "PDEX")
{
/// deployer will be the default admin
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
/// grant MINTER role to deployer & issuance contract to mint token to investors
grantRole(MINTER_ROLE, msg.sender);
grantRole(MINTER_ROLE, 0x169F95FcD7D19deEE33F9c473dC83e651D28e41C);
}
/// @notice Hook before token transfer
/// @param from Address transfer token - Address(0) means minting
/// @param to Address to receive token
/// @param amount Amount to transfer (decimals 18)
function _beforeTokenTransfer(address from, address to, uint256 amount)
internal
virtual
override
{
super._beforeTokenTransfer(from, to, amount);
/// check minting doesn't exceed _cap
if (from == address(0)) {
require(totalSupply().add(amount) <= _cap, "Max cap reached");
}
}
/// @notice Mint token to specific address
/// @dev Requires sender has MINTER role
/// @param to address to receive token
/// @param amount amount to mint (decimals 18)
function mint(address to, uint256 amount)
external
override
returns(bool)
{
require(hasRole(MINTER_ROLE, msg.sender), "Not a minter");
super._mint(to, amount);
}
} | 76,928 |
31 | // Get one user's withdrawal requests./ | function getUserWithdrawals(address user) external view returns(PendingUsersWithdrawal[] memory){
return pendingUsersWithdrawal[user];
}
| function getUserWithdrawals(address user) external view returns(PendingUsersWithdrawal[] memory){
return pendingUsersWithdrawal[user];
}
| 9,557 |
149 | // Update the record per amount withdrawn, with no applicable fees. A common mistake would be update the metric below with fees included. DONT DO THAT. | _records[currentPeriod].totalDeposited -= withdrawalAmount;
| _records[currentPeriod].totalDeposited -= withdrawalAmount;
| 26,094 |
59 | // approve the LendingPool contract allowance to pull the owed amount | IERC20(DAI).safeApprove(aave, amountOwing);
| IERC20(DAI).safeApprove(aave, amountOwing);
| 5,060 |
18 | // StringStorage | function getStringValue(bytes32 record) external view returns (string memory) {
return StringStorage[record];
}
| function getStringValue(bytes32 record) external view returns (string memory) {
return StringStorage[record];
}
| 19,126 |
4 | // Tightly pack and store only non-zero overwritten terms (LifecycleTerms) All non zero values of the overwrittenTerms object are stored.It does not check if overwrittenAttributesMap actually marks attribute as overwritten. / | function encodeAndSetPAMTerms(Asset storage asset, PAMTerms memory terms) external {
storeInPackedTerms(
asset,
"enums",
bytes32(uint256(uint8(terms.contractType))) << 248 |
bytes32(uint256(uint8(terms.calendar))) << 240 |
bytes32(uint256(uint8(terms.contractRole))) << 232 |
bytes32(uint256(uint8(terms.dayCountConvention))) << 224 |
bytes32(uint256(uint8(terms.businessDayConvention))) << 216 |
bytes32(uint256(uint8(terms.endOfMonthConvention))) << 208 |
bytes32(uint256(uint8(terms.scalingEffect))) << 200 |
bytes32(uint256(uint8(terms.feeBasis))) << 192
);
storeInPackedTerms(asset, "currency", bytes32(uint256(terms.currency) << 96));
storeInPackedTerms(asset, "settlementCurrency", bytes32(uint256(terms.settlementCurrency) << 96));
storeInPackedTerms(asset, "marketObjectCodeRateReset", bytes32(terms.marketObjectCodeRateReset));
storeInPackedTerms(asset, "statusDate", bytes32(terms.statusDate));
storeInPackedTerms(asset, "initialExchangeDate", bytes32(terms.initialExchangeDate));
storeInPackedTerms(asset, "maturityDate", bytes32(terms.maturityDate));
storeInPackedTerms(asset, "issueDate", bytes32(terms.issueDate));
storeInPackedTerms(asset, "purchaseDate", bytes32(terms.purchaseDate));
storeInPackedTerms(asset, "capitalizationEndDate", bytes32(terms.capitalizationEndDate));
storeInPackedTerms(asset, "cycleAnchorDateOfInterestPayment", bytes32(terms.cycleAnchorDateOfInterestPayment));
storeInPackedTerms(asset, "cycleAnchorDateOfRateReset", bytes32(terms.cycleAnchorDateOfRateReset));
storeInPackedTerms(asset, "cycleAnchorDateOfScalingIndex", bytes32(terms.cycleAnchorDateOfScalingIndex));
storeInPackedTerms(asset, "cycleAnchorDateOfFee", bytes32(terms.cycleAnchorDateOfFee));
storeInPackedTerms(asset, "notionalPrincipal", bytes32(terms.notionalPrincipal));
storeInPackedTerms(asset, "nominalInterestRate", bytes32(terms.nominalInterestRate));
storeInPackedTerms(asset, "accruedInterest", bytes32(terms.accruedInterest));
storeInPackedTerms(asset, "rateMultiplier", bytes32(terms.rateMultiplier));
storeInPackedTerms(asset, "rateSpread", bytes32(terms.rateSpread));
storeInPackedTerms(asset, "nextResetRate", bytes32(terms.nextResetRate));
storeInPackedTerms(asset, "feeRate", bytes32(terms.feeRate));
storeInPackedTerms(asset, "feeAccrued", bytes32(terms.feeAccrued));
storeInPackedTerms(asset, "premiumDiscountAtIED", bytes32(terms.premiumDiscountAtIED));
storeInPackedTerms(asset, "priceAtPurchaseDate", bytes32(terms.priceAtPurchaseDate));
storeInPackedTerms(asset, "priceAtTerminationDate", bytes32(terms.priceAtTerminationDate));
storeInPackedTerms(asset, "lifeCap", bytes32(terms.lifeCap));
storeInPackedTerms(asset, "lifeFloor", bytes32(terms.lifeFloor));
storeInPackedTerms(asset, "periodCap", bytes32(terms.periodCap));
storeInPackedTerms(asset, "periodFloor", bytes32(terms.periodFloor));
storeInPackedTerms(
asset,
"gracePeriod",
bytes32(uint256(terms.gracePeriod.i)) << 24 |
bytes32(uint256(terms.gracePeriod.p)) << 16 |
bytes32(uint256((terms.gracePeriod.isSet) ? 1 : 0)) << 8
);
storeInPackedTerms(
asset,
"delinquencyPeriod",
bytes32(uint256(terms.delinquencyPeriod.i)) << 24 |
bytes32(uint256(terms.delinquencyPeriod.p)) << 16 |
bytes32(uint256((terms.delinquencyPeriod.isSet) ? 1 : 0)) << 8
);
storeInPackedTerms(
asset,
"cycleOfInterestPayment",
bytes32(uint256(terms.cycleOfInterestPayment.i)) << 24 |
bytes32(uint256(terms.cycleOfInterestPayment.p)) << 16 |
bytes32(uint256(terms.cycleOfInterestPayment.s)) << 8 |
bytes32(uint256((terms.cycleOfInterestPayment.isSet) ? 1 : 0))
);
storeInPackedTerms(
asset,
"cycleOfRateReset",
bytes32(uint256(terms.cycleOfRateReset.i)) << 24 |
bytes32(uint256(terms.cycleOfRateReset.p)) << 16 |
bytes32(uint256(terms.cycleOfRateReset.s)) << 8 |
bytes32(uint256((terms.cycleOfRateReset.isSet) ? 1 : 0))
);
storeInPackedTerms(
asset,
"cycleOfScalingIndex",
bytes32(uint256(terms.cycleOfScalingIndex.i)) << 24 |
bytes32(uint256(terms.cycleOfScalingIndex.p)) << 16 |
bytes32(uint256(terms.cycleOfScalingIndex.s)) << 8 |
bytes32(uint256((terms.cycleOfScalingIndex.isSet) ? 1 : 0))
);
storeInPackedTerms(
asset,
"cycleOfFee",
bytes32(uint256(terms.cycleOfFee.i)) << 24 |
bytes32(uint256(terms.cycleOfFee.p)) << 16 |
bytes32(uint256(terms.cycleOfFee.s)) << 8 |
bytes32(uint256((terms.cycleOfFee.isSet) ? 1 : 0))
);
}
| function encodeAndSetPAMTerms(Asset storage asset, PAMTerms memory terms) external {
storeInPackedTerms(
asset,
"enums",
bytes32(uint256(uint8(terms.contractType))) << 248 |
bytes32(uint256(uint8(terms.calendar))) << 240 |
bytes32(uint256(uint8(terms.contractRole))) << 232 |
bytes32(uint256(uint8(terms.dayCountConvention))) << 224 |
bytes32(uint256(uint8(terms.businessDayConvention))) << 216 |
bytes32(uint256(uint8(terms.endOfMonthConvention))) << 208 |
bytes32(uint256(uint8(terms.scalingEffect))) << 200 |
bytes32(uint256(uint8(terms.feeBasis))) << 192
);
storeInPackedTerms(asset, "currency", bytes32(uint256(terms.currency) << 96));
storeInPackedTerms(asset, "settlementCurrency", bytes32(uint256(terms.settlementCurrency) << 96));
storeInPackedTerms(asset, "marketObjectCodeRateReset", bytes32(terms.marketObjectCodeRateReset));
storeInPackedTerms(asset, "statusDate", bytes32(terms.statusDate));
storeInPackedTerms(asset, "initialExchangeDate", bytes32(terms.initialExchangeDate));
storeInPackedTerms(asset, "maturityDate", bytes32(terms.maturityDate));
storeInPackedTerms(asset, "issueDate", bytes32(terms.issueDate));
storeInPackedTerms(asset, "purchaseDate", bytes32(terms.purchaseDate));
storeInPackedTerms(asset, "capitalizationEndDate", bytes32(terms.capitalizationEndDate));
storeInPackedTerms(asset, "cycleAnchorDateOfInterestPayment", bytes32(terms.cycleAnchorDateOfInterestPayment));
storeInPackedTerms(asset, "cycleAnchorDateOfRateReset", bytes32(terms.cycleAnchorDateOfRateReset));
storeInPackedTerms(asset, "cycleAnchorDateOfScalingIndex", bytes32(terms.cycleAnchorDateOfScalingIndex));
storeInPackedTerms(asset, "cycleAnchorDateOfFee", bytes32(terms.cycleAnchorDateOfFee));
storeInPackedTerms(asset, "notionalPrincipal", bytes32(terms.notionalPrincipal));
storeInPackedTerms(asset, "nominalInterestRate", bytes32(terms.nominalInterestRate));
storeInPackedTerms(asset, "accruedInterest", bytes32(terms.accruedInterest));
storeInPackedTerms(asset, "rateMultiplier", bytes32(terms.rateMultiplier));
storeInPackedTerms(asset, "rateSpread", bytes32(terms.rateSpread));
storeInPackedTerms(asset, "nextResetRate", bytes32(terms.nextResetRate));
storeInPackedTerms(asset, "feeRate", bytes32(terms.feeRate));
storeInPackedTerms(asset, "feeAccrued", bytes32(terms.feeAccrued));
storeInPackedTerms(asset, "premiumDiscountAtIED", bytes32(terms.premiumDiscountAtIED));
storeInPackedTerms(asset, "priceAtPurchaseDate", bytes32(terms.priceAtPurchaseDate));
storeInPackedTerms(asset, "priceAtTerminationDate", bytes32(terms.priceAtTerminationDate));
storeInPackedTerms(asset, "lifeCap", bytes32(terms.lifeCap));
storeInPackedTerms(asset, "lifeFloor", bytes32(terms.lifeFloor));
storeInPackedTerms(asset, "periodCap", bytes32(terms.periodCap));
storeInPackedTerms(asset, "periodFloor", bytes32(terms.periodFloor));
storeInPackedTerms(
asset,
"gracePeriod",
bytes32(uint256(terms.gracePeriod.i)) << 24 |
bytes32(uint256(terms.gracePeriod.p)) << 16 |
bytes32(uint256((terms.gracePeriod.isSet) ? 1 : 0)) << 8
);
storeInPackedTerms(
asset,
"delinquencyPeriod",
bytes32(uint256(terms.delinquencyPeriod.i)) << 24 |
bytes32(uint256(terms.delinquencyPeriod.p)) << 16 |
bytes32(uint256((terms.delinquencyPeriod.isSet) ? 1 : 0)) << 8
);
storeInPackedTerms(
asset,
"cycleOfInterestPayment",
bytes32(uint256(terms.cycleOfInterestPayment.i)) << 24 |
bytes32(uint256(terms.cycleOfInterestPayment.p)) << 16 |
bytes32(uint256(terms.cycleOfInterestPayment.s)) << 8 |
bytes32(uint256((terms.cycleOfInterestPayment.isSet) ? 1 : 0))
);
storeInPackedTerms(
asset,
"cycleOfRateReset",
bytes32(uint256(terms.cycleOfRateReset.i)) << 24 |
bytes32(uint256(terms.cycleOfRateReset.p)) << 16 |
bytes32(uint256(terms.cycleOfRateReset.s)) << 8 |
bytes32(uint256((terms.cycleOfRateReset.isSet) ? 1 : 0))
);
storeInPackedTerms(
asset,
"cycleOfScalingIndex",
bytes32(uint256(terms.cycleOfScalingIndex.i)) << 24 |
bytes32(uint256(terms.cycleOfScalingIndex.p)) << 16 |
bytes32(uint256(terms.cycleOfScalingIndex.s)) << 8 |
bytes32(uint256((terms.cycleOfScalingIndex.isSet) ? 1 : 0))
);
storeInPackedTerms(
asset,
"cycleOfFee",
bytes32(uint256(terms.cycleOfFee.i)) << 24 |
bytes32(uint256(terms.cycleOfFee.p)) << 16 |
bytes32(uint256(terms.cycleOfFee.s)) << 8 |
bytes32(uint256((terms.cycleOfFee.isSet) ? 1 : 0))
);
}
| 3,809 |
6 | // Add new deputy owner. Only Owner can call this function New Deputy should not be zero address New Deputy should not be be already exisitng emit DeputyOwnerUdpatd event_newDO Address of new deputy owner / | function addDeputyOwner(address _newDO)
public
onlyOwner
| function addDeputyOwner(address _newDO)
public
onlyOwner
| 5,091 |
26 | // debt accrued is the sum of the current debt minus the sum of the debt at the last update | vars.totalDebtAccrued =
vars.currTotalVariableDebt +
reserveCache.currTotalStableDebt -
vars.prevTotalVariableDebt -
vars.prevTotalStableDebt;
vars.amountToMint = vars.totalDebtAccrued.percentMul(reserveCache.reserveFactor);
if (vars.amountToMint != 0) {
reserve.accruedToTreasury += vars
| vars.totalDebtAccrued =
vars.currTotalVariableDebt +
reserveCache.currTotalStableDebt -
vars.prevTotalVariableDebt -
vars.prevTotalStableDebt;
vars.amountToMint = vars.totalDebtAccrued.percentMul(reserveCache.reserveFactor);
if (vars.amountToMint != 0) {
reserve.accruedToTreasury += vars
| 33,834 |
17 | // Event emitted when liquidity is redeemed from the Pool | event Redeemed(
address indexed redeemer,
uint256 currencyAmount,
uint256 tokens
);
| event Redeemed(
address indexed redeemer,
uint256 currencyAmount,
uint256 tokens
);
| 8,324 |
328 | // Throws if the sender is not the proxy admin. / | function _checkProxyAdmin() internal view virtual {
require(_getAdmin() == _msgSender(), "FabricaUUPSUpgradeable: caller is not the proxy admin");
}
| function _checkProxyAdmin() internal view virtual {
require(_getAdmin() == _msgSender(), "FabricaUUPSUpgradeable: caller is not the proxy admin");
}
| 18,481 |
52 | // Required interface of an ERC1155 compliant contract, as defined in the _Available since v3.1._ / | interface IERC1155 is IERC165 {
/**
* @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
*/
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
/**
* @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
* transfers.
*/
event TransferBatch(
address indexed operator,
address indexed from,
address indexed to,
uint256[] ids,
uint256[] values
);
/**
* @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
* `approved`.
*/
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
/**
* @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
*
* If an {URI} event was emitted for `id`, the standard
* https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
* returned by {IERC1155MetadataURI-uri}.
*/
event URI(string value, uint256 indexed id);
/**
* @dev Returns the amount of tokens of token type `id` owned by `account`.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) external view returns (uint256);
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
external
view
returns (uint256[] memory);
/**
* @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
*
* Emits an {ApprovalForAll} event.
*
* Requirements:
*
* - `operator` cannot be the caller.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address account, address operator) external view returns (bool);
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes calldata data
) external;
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata amounts,
bytes calldata data
) external;
}
| interface IERC1155 is IERC165 {
/**
* @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
*/
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
/**
* @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
* transfers.
*/
event TransferBatch(
address indexed operator,
address indexed from,
address indexed to,
uint256[] ids,
uint256[] values
);
/**
* @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
* `approved`.
*/
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
/**
* @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
*
* If an {URI} event was emitted for `id`, the standard
* https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
* returned by {IERC1155MetadataURI-uri}.
*/
event URI(string value, uint256 indexed id);
/**
* @dev Returns the amount of tokens of token type `id` owned by `account`.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) external view returns (uint256);
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
external
view
returns (uint256[] memory);
/**
* @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
*
* Emits an {ApprovalForAll} event.
*
* Requirements:
*
* - `operator` cannot be the caller.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address account, address operator) external view returns (bool);
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes calldata data
) external;
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata amounts,
bytes calldata data
) external;
}
| 3,304 |
0 | // Implementation of the {IERC20} interface.that a supply mechanism has to be added in a derived contract using {_mint}.The default value of {decimals} is 18. To change this, you should overrideAdditionally, an {Approval} event is emitted on calls to {transferFrom}.Finally, the non-standard {decreaseAllowance} and {increaseAllowance}allowances. See {IERC20-approve}./ Indicates a failed `decreaseAllowance` request. / | error ERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
| error ERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
| 2,040 |
50 | // Returns the maximum amount able to be transferred per transaction. / | function getBuySellLimit() public view virtual returns (uint256) {
return _buySellLimit;
}
| function getBuySellLimit() public view virtual returns (uint256) {
return _buySellLimit;
}
| 3,050 |
44 | // bytes3 + bytes1 => uid | function getUid(bytes3 key2, bytes1 min) public pure returns(bytes4) {
bytes4 key2Bytes = bytes4(key2);
bytes4 minBytes = bytes4(min) >> 24;
return key2Bytes | minBytes;
}
| function getUid(bytes3 key2, bytes1 min) public pure returns(bytes4) {
bytes4 key2Bytes = bytes4(key2);
bytes4 minBytes = bytes4(min) >> 24;
return key2Bytes | minBytes;
}
| 45,198 |
80 | // Since nobody has won, then we reimburse both parties equally. If item.sumDeposit is odd, 1 wei will remain in the contract balance. | uint256 halfSumDeposit = sumDeposit / 2;
request.requester.send(halfSumDeposit);
request.challenger.send(halfSumDeposit);
| uint256 halfSumDeposit = sumDeposit / 2;
request.requester.send(halfSumDeposit);
request.challenger.send(halfSumDeposit);
| 28,730 |
26 | // Finalized Pre crowdsele. | finalized = true;
uint256 tokensAmount = token.balanceOf(address(this));
token.transferFrom(address(this),beneficiary, tokensAmount);
| finalized = true;
uint256 tokensAmount = token.balanceOf(address(this));
token.transferFrom(address(this),beneficiary, tokensAmount);
| 6,880 |
77 | // Check whether skin is already on sale | require(isOnSale[skinId] == false);
require(price > 0);
| require(isOnSale[skinId] == false);
require(price > 0);
| 7,651 |
434 | // Join the SAI wad amount to the `vat`: | saiJoin.join(address(this), wad);
| saiJoin.join(address(this), wad);
| 41,537 |
487 | // The multiplication in the next line is necessary because when slicing multiples of 32 bytes (lengthmod == 0) the following copy loop was copying the origin's length and then ending prematurely not copying everything it should. | let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod)))
let end := add(mc, _length)
for {
| let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod)))
let end := add(mc, _length)
for {
| 4,225 |
14 | // Owner of account approves the transfer of amount to another account | mapping(address => mapping (address => uint256)) internal allowed;
| mapping(address => mapping (address => uint256)) internal allowed;
| 25,703 |
132 | // Because the base is larger than one (and the power rounds up), the power should always be larger than one, so the following subtraction should never revert. | uint256 ratio = power.sub(FixedPoint.ONE);
return balanceIn.mulUp(ratio);
| uint256 ratio = power.sub(FixedPoint.ONE);
return balanceIn.mulUp(ratio);
| 13,357 |
7 | // The address of manager (the account or contracts) that can execute action within the role. | address public managerAddress;
| address public managerAddress;
| 23,228 |
50 | // Withdraws ether previously funded for ether-less signing (using fundDocumentSigning) from paymaster (relay hub).This is usually called after document is certified to get unspent amount back to submitter,but it is not a requirement. Only allowed when EthNOSPaymaster is set (etherless signing is supported).Only allowed to be called by document submitter.documentHash Keccak256 hash of the document (computed off-chain). Only previously submitted documents are allowed. / | function withdrawDocumentSigningBalance(
bytes32 documentHash)
external
isEthNOSPaymasterSet
documentValid(documentHash)
| function withdrawDocumentSigningBalance(
bytes32 documentHash)
external
isEthNOSPaymasterSet
documentValid(documentHash)
| 12,913 |
13 | // round to make sure that we pass the target price | return
zeroForOne
? getNextSqrtPriceFromAmount1RoundingDown(
sqrtPX96,
liquidity,
amountOut,
false
)
: getNextSqrtPriceFromAmount0RoundingUp(
sqrtPX96,
| return
zeroForOne
? getNextSqrtPriceFromAmount1RoundingDown(
sqrtPX96,
liquidity,
amountOut,
false
)
: getNextSqrtPriceFromAmount0RoundingUp(
sqrtPX96,
| 3,630 |
173 | // add the escrow amount to escrowedAccountBalance // Delete the vesting entry being migrated // update account total escrow balances for migration transfer the escrowed SNX being migrated to the L2 deposit contract / | if (escrowedAccountBalance > 0) {
_reduceAccountEscrowBalances(account, escrowedAccountBalance);
IERC20(address(synthetix())).transfer(synthetixBridgeToOptimism(), escrowedAccountBalance);
}
| if (escrowedAccountBalance > 0) {
_reduceAccountEscrowBalances(account, escrowedAccountBalance);
IERC20(address(synthetix())).transfer(synthetixBridgeToOptimism(), escrowedAccountBalance);
}
| 8,320 |
30 | // Allows token holders to vote _disputeId is the dispute id _supportsDispute is the vote (true=the dispute has basis false = vote against dispute)/ | function vote(uint256 _disputeId, bool _supportsDispute) external {
require(_disputeId <= uints[_DISPUTE_COUNT], "dispute does not exist");
Dispute storage disp = disputesById[_disputeId];
require(!disp.executed, "the dispute has already been executed");
//Get the voteWeight or the balance of the user at the time/blockNumber the dispute began
uint256 voteWeight = balanceOfAt(msg.sender, disp.disputeUintVars[_BLOCK_NUMBER]);
//Require that the msg.sender has not voted
require(disp.voted[msg.sender] != true, "Sender has already voted");
//Require that the user had a balance >0 at time/blockNumber the dispute began
require(voteWeight != 0, "User balance is 0");
//ensures miners that are under dispute cannot vote
require(
stakerDetails[msg.sender].currentStatus != 3,
"Miner is under dispute"
);
//Update user voting status to true
disp.voted[msg.sender] = true;
//Update the number of votes for the dispute
disp.disputeUintVars[_NUM_OF_VOTES] += 1;
//If the user supports the dispute increase the tally for the dispute by the voteWeight
//otherwise decrease it
if (_supportsDispute) {
disp.tally = disp.tally.add(int256(voteWeight));
} else {
disp.tally = disp.tally.sub(int256(voteWeight));
}
//Let the network kblock.timestamp the user has voted on the dispute and their casted vote
emit Voted(_disputeId, _supportsDispute, msg.sender, voteWeight);
}
| function vote(uint256 _disputeId, bool _supportsDispute) external {
require(_disputeId <= uints[_DISPUTE_COUNT], "dispute does not exist");
Dispute storage disp = disputesById[_disputeId];
require(!disp.executed, "the dispute has already been executed");
//Get the voteWeight or the balance of the user at the time/blockNumber the dispute began
uint256 voteWeight = balanceOfAt(msg.sender, disp.disputeUintVars[_BLOCK_NUMBER]);
//Require that the msg.sender has not voted
require(disp.voted[msg.sender] != true, "Sender has already voted");
//Require that the user had a balance >0 at time/blockNumber the dispute began
require(voteWeight != 0, "User balance is 0");
//ensures miners that are under dispute cannot vote
require(
stakerDetails[msg.sender].currentStatus != 3,
"Miner is under dispute"
);
//Update user voting status to true
disp.voted[msg.sender] = true;
//Update the number of votes for the dispute
disp.disputeUintVars[_NUM_OF_VOTES] += 1;
//If the user supports the dispute increase the tally for the dispute by the voteWeight
//otherwise decrease it
if (_supportsDispute) {
disp.tally = disp.tally.add(int256(voteWeight));
} else {
disp.tally = disp.tally.sub(int256(voteWeight));
}
//Let the network kblock.timestamp the user has voted on the dispute and their casted vote
emit Voted(_disputeId, _supportsDispute, msg.sender, voteWeight);
}
| 6,909 |
38 | // //Let owner withdraw Link owned by the contract / | function withdrawLink() public onlyOwner{
LinkTokenInterface link = LinkTokenInterface(chainlinkTokenAddress());
require(link.transfer(owner(), link.balanceOf(address(this))), "Unable to transfer");
}
| function withdrawLink() public onlyOwner{
LinkTokenInterface link = LinkTokenInterface(chainlinkTokenAddress());
require(link.transfer(owner(), link.balanceOf(address(this))), "Unable to transfer");
}
| 34,073 |
7 | // public function | function addAnchor(string memory anchorID, bytes32 controlString,
string memory newHashLinkSSI, string memory ZKPValue, string memory lastHashLinkSSI,
| function addAnchor(string memory anchorID, bytes32 controlString,
string memory newHashLinkSSI, string memory ZKPValue, string memory lastHashLinkSSI,
| 14,862 |
101 | // release non-invoice tokens | function releaseTokens(address _token) external nonReentrant {
if (_token == token) {
release();
} else {
require(_msgSender() == client, "!client");
uint256 balance = IERC20(_token).balanceOf(address(this));
IERC20(_token).safeTransfer(provider, balance);
}
}
| function releaseTokens(address _token) external nonReentrant {
if (_token == token) {
release();
} else {
require(_msgSender() == client, "!client");
uint256 balance = IERC20(_token).balanceOf(address(this));
IERC20(_token).safeTransfer(provider, balance);
}
}
| 9,300 |
34 | // Calculates the PoW difficulty target from compressed nBits representation,nBits Compressed PoW target representation return PoW difficulty target computed from nBits/ | function nBitsToTarget(uint256 nBits) private pure returns (uint256){
uint256 exp = uint256(nBits) >> 24;
uint256 c = uint256(nBits) & 0xffffff;
uint256 target = uint256((c * 2**(8*(exp - 3))));
return target;
}
| function nBitsToTarget(uint256 nBits) private pure returns (uint256){
uint256 exp = uint256(nBits) >> 24;
uint256 c = uint256(nBits) & 0xffffff;
uint256 target = uint256((c * 2**(8*(exp - 3))));
return target;
}
| 8,175 |
67 | // Transfer tokens from the caller toPayee's address value Transfer amountreturn True if successful / | function transfer(address to, uint256 value)
external
override
whenNotPaused
notBlacklisted(msg.sender)
notBlacklisted(to)
returns (bool)
| function transfer(address to, uint256 value)
external
override
whenNotPaused
notBlacklisted(msg.sender)
notBlacklisted(to)
returns (bool)
| 1,854 |
431 | // Savings Manager | function savingsContracts(address) external view returns (address);
| function savingsContracts(address) external view returns (address);
| 49,324 |
296 | // Return any remaining ether after the buy | uint256 remaining = msg.value.sub(price);
if (remaining > 0) {
(bool success, ) = msg.sender.call{value: remaining}("");
| uint256 remaining = msg.value.sub(price);
if (remaining > 0) {
(bool success, ) = msg.sender.call{value: remaining}("");
| 35,757 |
3 | // Leaves the contract without admin, so it will not be possible to call`onlyAdmin` functions anymore. Requirements: - The caller must be the administrator. WARNING: Doing this will leave the contract without an admin,thereby removing any functionality that is only available to the admin. / | function _renounceAdmin() external virtual override onlyAdmin {
emit TransferAdmin(admin, address(0x00));
admin = address(0x00);
}
| function _renounceAdmin() external virtual override onlyAdmin {
emit TransferAdmin(admin, address(0x00));
admin = address(0x00);
}
| 53,364 |
10 | // returns current balance of contract | function getBalance() external view returns(uint){
return address(this).balance;
}
| function getBalance() external view returns(uint){
return address(this).balance;
}
| 34,722 |
14 | // set withdrawable period in unixtimestamp length (1 day = 86400) _address address to set the parameter _target parameter / | function setWithdrawable(address _address, uint256 _target)
external
override
onlyOwner
| function setWithdrawable(address _address, uint256 _target)
external
override
onlyOwner
| 14,927 |
4 | // Mapping to keep track of tokens by address | mapping (address => uint256[]) private ownedTokens;
uint256 solutionId;
| mapping (address => uint256[]) private ownedTokens;
uint256 solutionId;
| 13,041 |
7 | // view the name of the contract |
function setTaxFeePercent(uint256 taxFee) external;
function setLiquidityFeePercent(uint256 liquidityFee) external;
function setNumTokensSellToAddToLiquidity(uint256 amount) external;
|
function setTaxFeePercent(uint256 taxFee) external;
function setLiquidityFeePercent(uint256 liquidityFee) external;
function setNumTokensSellToAddToLiquidity(uint256 amount) external;
| 19,985 |
165 | // new_AA_amount is roughly 10x new_A_amount | uint256 new_AA_amount = eternal_unutilized_balances.S - new_A_amount;
| uint256 new_AA_amount = eternal_unutilized_balances.S - new_A_amount;
| 83,402 |
54 | // Allows the node operator to withdraw earned LINK to a given address The owner of the contract can be another wallet and does not have to be a Chainlink node _recipient The address to send the LINK token to _amount The amount to send (specified in wei) / | function withdraw(address _recipient, uint256 _amount)
external
override(OracleInterface, WithdrawalInterface)
onlyOwner
hasAvailableFunds(_amount)
| function withdraw(address _recipient, uint256 _amount)
external
override(OracleInterface, WithdrawalInterface)
onlyOwner
hasAvailableFunds(_amount)
| 21,078 |
20 | // Privileged function which allows the Realty owner to change the availability of the listing The RealtyState is automatically toggled to available or not available depending on previous state registryId The id of the Realty to change / | function changeAvailability(uint registryId) public whenNotPaused() onlyRealtyOwner(registryId) {
RealtyState currentState = idToRealty[registryId].state;
if (currentState == RealtyState.Available) {
idToRealty[registryId].state = RealtyState.NotAvailable;
} else {
idToRealty[registryId].state = RealtyState.Available;
}
RealtyState newState = idToRealty[registryId].state;
emit RealtyStateChanged(registryId, newState);
}
| function changeAvailability(uint registryId) public whenNotPaused() onlyRealtyOwner(registryId) {
RealtyState currentState = idToRealty[registryId].state;
if (currentState == RealtyState.Available) {
idToRealty[registryId].state = RealtyState.NotAvailable;
} else {
idToRealty[registryId].state = RealtyState.Available;
}
RealtyState newState = idToRealty[registryId].state;
emit RealtyStateChanged(registryId, newState);
}
| 18,685 |
12 | // Get the balance of an erc20 token in a boxboxId id of the box tokenAddress erc20 token address return balance / | function erc20BalanceOf(uint256 boxId, address tokenAddress)
public
view
override
returns (uint256 balance)
| function erc20BalanceOf(uint256 boxId, address tokenAddress)
public
view
override
returns (uint256 balance)
| 46,556 |
215 | // get ETH in core ERC20 | if (_token == ETH_TOKEN_ADDRESS){
return exchangePortal.getValue(
address(_token),
coreFundAsset,
address(this).balance);
}
| if (_token == ETH_TOKEN_ADDRESS){
return exchangePortal.getValue(
address(_token),
coreFundAsset,
address(this).balance);
}
| 57,898 |
179 | // Start with some random bytes | bytes32 setCrabyDNA = randBytes32(tokenId);
| bytes32 setCrabyDNA = randBytes32(tokenId);
| 3,161 |
43 | // check token balance of current account, swap to eth, send it to this wallet | swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHToFee(address(this).balance); // send this adrs eth to marketing wallet
}
| swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHToFee(address(this).balance); // send this adrs eth to marketing wallet
}
| 21,454 |
304 | // 基金本币全部兑换成t0 | if (params.amount > 0){
if(params.token0 == params.token){
amount0Max = amount0Max.add(params.amount);
} else{
| if (params.amount > 0){
if(params.token0 == params.token){
amount0Max = amount0Max.add(params.amount);
} else{
| 66,067 |
47 | // This function calculates the balance of a given token (tokenIndex) given all the other balances and the invariant | function _getTokenBalanceGivenInvariantAndAllOtherBalances(
uint256 amplificationParameter,
uint256[] memory balances,
uint256 invariant,
uint256 tokenIndex
| function _getTokenBalanceGivenInvariantAndAllOtherBalances(
uint256 amplificationParameter,
uint256[] memory balances,
uint256 invariant,
uint256 tokenIndex
| 21,673 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.