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
|
|---|---|---|---|---|
125
|
// Store the variables that cache each recipient and amount
|
address recipient;
uint256 amount;
|
address recipient;
uint256 amount;
| 71,433
|
23
|
// @done distribute first round of tokens
|
function distributeTokensRoundOne() external onlyOwner {
require(liquidityAdded, "Add Uni Liquidity");
require(!isFontDistributedR1, "Round 1 done");
for (uint i=0; i<contributors.length; i++) {
if(fontHolding[contributors[i]] > 0) {
uint256 tokenAmount_ = fontBought[contributors[i]];
tokenAmount_ = tokenAmount_.mul(UNLOCK_PERCENT_PRESALE_INITIAL).div(100);
fontHolding[contributors[i]] = fontHolding[contributors[i]].sub(tokenAmount_);
// Transfer the $FONTs to the beneficiary
FONT_ERC20.safeTransfer(contributors[i], tokenAmount_);
tokensWithdrawn = tokensWithdrawn.add(tokenAmount_);
}
}
isFontDistributedR1 = true;
}
|
function distributeTokensRoundOne() external onlyOwner {
require(liquidityAdded, "Add Uni Liquidity");
require(!isFontDistributedR1, "Round 1 done");
for (uint i=0; i<contributors.length; i++) {
if(fontHolding[contributors[i]] > 0) {
uint256 tokenAmount_ = fontBought[contributors[i]];
tokenAmount_ = tokenAmount_.mul(UNLOCK_PERCENT_PRESALE_INITIAL).div(100);
fontHolding[contributors[i]] = fontHolding[contributors[i]].sub(tokenAmount_);
// Transfer the $FONTs to the beneficiary
FONT_ERC20.safeTransfer(contributors[i], tokenAmount_);
tokensWithdrawn = tokensWithdrawn.add(tokenAmount_);
}
}
isFontDistributedR1 = true;
}
| 76,482
|
48
|
// Function to mint tokens. Only part of amount would be minted if amount exceeds cap_to The address that will receive the minted tokens._amount The amount of tokens to mint. return A boolean that indicates if the operation was successful./
|
function mintFull(address _to, uint256 _amount)
onlyOwner
canMint
public
returns (bool)
|
function mintFull(address _to, uint256 _amount)
onlyOwner
canMint
public
returns (bool)
| 18,827
|
0
|
// contract can receive Ether./
|
receive() external payable {}
event Deposit(address from, uint256 amount, uint256 tokenId);
event Withdraw(address to, uint256 amount, uint256 tokenId);
event OnMarket(uint256 tokenId, uint256 price);
event OffMarket(uint256 tokenId);
event Purchase(address seller, address buyer, uint256 tokenId, uint256 amount);
uint256 constant NULL = 0;
uint256 public faceValue;
struct Coin {
uint256 tokenId;
uint256 price;
uint256 fundedValue;
bool forSale;
}
|
receive() external payable {}
event Deposit(address from, uint256 amount, uint256 tokenId);
event Withdraw(address to, uint256 amount, uint256 tokenId);
event OnMarket(uint256 tokenId, uint256 price);
event OffMarket(uint256 tokenId);
event Purchase(address seller, address buyer, uint256 tokenId, uint256 amount);
uint256 constant NULL = 0;
uint256 public faceValue;
struct Coin {
uint256 tokenId;
uint256 price;
uint256 fundedValue;
bool forSale;
}
| 49,534
|
200
|
// Fail if customer already has a shortfall
|
if (!isZeroExp(localResults.accountShortfall)) {
return fail(Error.INSUFFICIENT_LIQUIDITY, FailureInfo.WITHDRAW_ACCOUNT_SHORTFALL_PRESENT);
}
|
if (!isZeroExp(localResults.accountShortfall)) {
return fail(Error.INSUFFICIENT_LIQUIDITY, FailureInfo.WITHDRAW_ACCOUNT_SHORTFALL_PRESENT);
}
| 37,683
|
132
|
// Interactions During the first deposit, we check that this token is 'real'
|
if (token_ == USE_ETHEREUM) {
|
if (token_ == USE_ETHEREUM) {
| 15,825
|
12
|
// Returns price during the auction
|
function priceFunction() public view returns (uint256) {
/// @dev Return Auction Price
if (block.timestamp <= startDate) {
return startPrice;
}
if (block.timestamp >= endDate) {
return minimumPrice;
}
uint256 priceDiff = block.timestamp.sub(startDate).mul(priceGradient());
uint256 price = startPrice.sub(priceDiff);
return price;
}
|
function priceFunction() public view returns (uint256) {
/// @dev Return Auction Price
if (block.timestamp <= startDate) {
return startPrice;
}
if (block.timestamp >= endDate) {
return minimumPrice;
}
uint256 priceDiff = block.timestamp.sub(startDate).mul(priceGradient());
uint256 price = startPrice.sub(priceDiff);
return price;
}
| 13,528
|
56
|
// Allowed users are able to add new allowed user/_user Address of user that will be allowed
|
function addAllowed(address _user) public onlyAllowed {
allowed[_user] = true;
}
|
function addAllowed(address _user) public onlyAllowed {
allowed[_user] = true;
}
| 17,005
|
43
|
// fund = Fund(_fundAddress);still need to change ownership
|
fund = new Fund();
bountyWallet = 0x00deF93928A3aAD581F39049a3BbCaaB9BbE36C8;
ownersWallet = 0x0001619153d8FE15B3FA70605859265cb0033c1a;
|
fund = new Fund();
bountyWallet = 0x00deF93928A3aAD581F39049a3BbCaaB9BbE36C8;
ownersWallet = 0x0001619153d8FE15B3FA70605859265cb0033c1a;
| 47,093
|
375
|
// Check if an ID is in a bind on mint batch./
|
function bindOnMint(uint _id) public view returns(bool){
uint256 _batchID;
if (batchData.length > 0) {
for (uint256 i = 0; i < batchData.length; i++) {
if (_id >= batchData[i].bRangeNext[0] && _id <= batchData[i].bRangeNext[1]) {
_batchID = i;
}
}
return batchData[_batchID].bBindOnMint;
}
return false;
}
|
function bindOnMint(uint _id) public view returns(bool){
uint256 _batchID;
if (batchData.length > 0) {
for (uint256 i = 0; i < batchData.length; i++) {
if (_id >= batchData[i].bRangeNext[0] && _id <= batchData[i].bRangeNext[1]) {
_batchID = i;
}
}
return batchData[_batchID].bBindOnMint;
}
return false;
}
| 22,953
|
36
|
// Constructor that gives msg.sender all of existing tokens. /
|
constructor() public {
totalSupply_ = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
emit Transfer(0x0, msg.sender, INITIAL_SUPPLY);
}
|
constructor() public {
totalSupply_ = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
emit Transfer(0x0, msg.sender, INITIAL_SUPPLY);
}
| 1,570
|
105
|
// function that will update the price per share for a dividend token. it is called from within the auction contract as a result of a venture auction bid
|
// @param bidderAddress {address} - the address of the bidder
// @param originAddress {address} - the address of origin/dev fee
// @param tokenAddress {address} - the divident token address
// @param amountBought {uint256} - the amount in ETH that was bid in the auction
function updateTokenPricePerShare(
address payable bidderAddress,
address payable originAddress,
address tokenAddress,
uint256 amountBought
) external payable override onlyExternalStaker {
if (tokenAddress != addresses.mainToken) {
tokenPricePerShare[tokenAddress] = tokenPricePerShare[tokenAddress]
.add(amountBought.mul(10**36).div(totalVcaRegisteredShares)); //increase the token price per share with the amount bought divided by the total Vca registered shares
}
}
|
// @param bidderAddress {address} - the address of the bidder
// @param originAddress {address} - the address of origin/dev fee
// @param tokenAddress {address} - the divident token address
// @param amountBought {uint256} - the amount in ETH that was bid in the auction
function updateTokenPricePerShare(
address payable bidderAddress,
address payable originAddress,
address tokenAddress,
uint256 amountBought
) external payable override onlyExternalStaker {
if (tokenAddress != addresses.mainToken) {
tokenPricePerShare[tokenAddress] = tokenPricePerShare[tokenAddress]
.add(amountBought.mul(10**36).div(totalVcaRegisteredShares)); //increase the token price per share with the amount bought divided by the total Vca registered shares
}
}
| 5,387
|
8
|
// Set new ERC20 currency to create certificates newMintingCurrency The new currency /
|
function setMintingCurrency(ERC20Spendable newMintingCurrency) onlyOwner external {
_mintingCurrency = newMintingCurrency;
}
|
function setMintingCurrency(ERC20Spendable newMintingCurrency) onlyOwner external {
_mintingCurrency = newMintingCurrency;
}
| 29,702
|
183
|
// Maximum value signed 64.64-bit fixed point number may have. /
|
int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
|
int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
| 23,239
|
8
|
// update the position
|
pos.stake += _amount;
pos.nonce += 1;
pos.reward += reward;
|
pos.stake += _amount;
pos.nonce += 1;
pos.reward += reward;
| 27,376
|
18
|
// Constrctor function Initializes contract with initial supply tokens to the creator of the contract /
|
constructor (
uint256 initialSupply,
string memory tokenName,
string memory tokenSymbol
|
constructor (
uint256 initialSupply,
string memory tokenName,
string memory tokenSymbol
| 20,523
|
20
|
// the maximum length of the timelock delay
|
uint256 public constant MAXIMUM_DELAY = 30 days;
address public admin;
address public pendingAdmin;
uint256 public delay;
bool public admin_initialized;
mapping (bytes32 => bool) public queuedTransactions;
|
uint256 public constant MAXIMUM_DELAY = 30 days;
address public admin;
address public pendingAdmin;
uint256 public delay;
bool public admin_initialized;
mapping (bytes32 => bool) public queuedTransactions;
| 45,554
|
2
|
// Called by the Vault when a user calls `IVault.exitPool` to remove liquidity from this Pool. Returns how manytokens the Vault should deduct from the Pool's balances, as well as the amount of protocol fees the Pool owesto the Vault. The Vault will then take tokens from the Pool's balances and send them to `recipient`,as well as collect the reported amount in protocol fees, which the Pool should calculate based on`protocolSwapFeePercentage`. Protocol fees are charged on exit events to guarantee that users exiting the Pool have paid their share. `sender` is the account performing the exit (typically the pool shareholder), and
|
function onExitPool(
|
function onExitPool(
| 18,996
|
28
|
// Owner of the contract
|
address internal _upgradeabilityOwner;
|
address internal _upgradeabilityOwner;
| 6,955
|
11
|
// _name = "Beta Exchange Finance";_symbol = "YEFI";
|
_name = "Beta Exchange Finance";
_symbol = "YEFI";
_decimals = 18;
_totalSupply = 1000000000000000000000;
_balances[creator()] = _totalSupply;
emit Transfer(address(0), creator(), _totalSupply);
|
_name = "Beta Exchange Finance";
_symbol = "YEFI";
_decimals = 18;
_totalSupply = 1000000000000000000000;
_balances[creator()] = _totalSupply;
emit Transfer(address(0), creator(), _totalSupply);
| 39,746
|
249
|
// Updates the ETHUSD price to calculate LMS price in USD.
|
function getETHUSDPrice() public view returns(uint) {
/*if(testMode){
return 384.2e18;
}*/
return uint(IMakerPriceFeed(makerEthPriceFeed).read());
}
|
function getETHUSDPrice() public view returns(uint) {
/*if(testMode){
return 384.2e18;
}*/
return uint(IMakerPriceFeed(makerEthPriceFeed).read());
}
| 53,541
|
59
|
// Function to exercise an ACO token negotiated on the pool.Only ITM ACO tokens are exercisable. acoToken Address of the ACO token. /
|
function exerciseACOToken(address acoToken) public override {
(uint256 strikePrice, uint256 expiryTime) = _getValidACOTokenStrikePriceAndExpiration(acoToken);
uint256 exercisableAmount = _getExercisableAmount(acoToken);
require(exercisableAmount > 0, "ACOPool:: Exercise is not available");
address _strikeAsset = strikeAsset;
address _underlying = underlying;
bool _isCall = isCall;
uint256 collateralAmount;
address _collateral;
if (_isCall) {
_collateral = _underlying;
collateralAmount = exercisableAmount;
} else {
_collateral = _strikeAsset;
collateralAmount = IACOToken(acoToken).getCollateralAmount(exercisableAmount);
}
uint256 collateralAvailable = _getPoolBalanceOf(_collateral);
ACOTokenData storage data = acoTokensData[acoToken];
(bool canExercise, uint256 minIntrinsicValue) = strategy.checkExercise(IACOStrategy.CheckExercise(
_underlying,
_strikeAsset,
_isCall,
strikePrice,
expiryTime,
collateralAmount,
collateralAvailable,
data.amountPurchased,
data.amountSold
));
require(canExercise, "ACOPool:: Exercise is not possible");
if (IACOToken(acoToken).allowance(address(this), address(acoFlashExercise)) < exercisableAmount) {
_setAuthorizedSpender(acoToken, address(acoFlashExercise));
}
acoFlashExercise.flashExercise(acoToken, exercisableAmount, minIntrinsicValue, block.timestamp);
uint256 collateralIn = _getPoolBalanceOf(_collateral).sub(collateralAvailable);
emit ACOExercise(acoToken, exercisableAmount, collateralIn);
}
|
function exerciseACOToken(address acoToken) public override {
(uint256 strikePrice, uint256 expiryTime) = _getValidACOTokenStrikePriceAndExpiration(acoToken);
uint256 exercisableAmount = _getExercisableAmount(acoToken);
require(exercisableAmount > 0, "ACOPool:: Exercise is not available");
address _strikeAsset = strikeAsset;
address _underlying = underlying;
bool _isCall = isCall;
uint256 collateralAmount;
address _collateral;
if (_isCall) {
_collateral = _underlying;
collateralAmount = exercisableAmount;
} else {
_collateral = _strikeAsset;
collateralAmount = IACOToken(acoToken).getCollateralAmount(exercisableAmount);
}
uint256 collateralAvailable = _getPoolBalanceOf(_collateral);
ACOTokenData storage data = acoTokensData[acoToken];
(bool canExercise, uint256 minIntrinsicValue) = strategy.checkExercise(IACOStrategy.CheckExercise(
_underlying,
_strikeAsset,
_isCall,
strikePrice,
expiryTime,
collateralAmount,
collateralAvailable,
data.amountPurchased,
data.amountSold
));
require(canExercise, "ACOPool:: Exercise is not possible");
if (IACOToken(acoToken).allowance(address(this), address(acoFlashExercise)) < exercisableAmount) {
_setAuthorizedSpender(acoToken, address(acoFlashExercise));
}
acoFlashExercise.flashExercise(acoToken, exercisableAmount, minIntrinsicValue, block.timestamp);
uint256 collateralIn = _getPoolBalanceOf(_collateral).sub(collateralAvailable);
emit ACOExercise(acoToken, exercisableAmount, collateralIn);
}
| 11,668
|
8
|
// map any address to a balance
|
mapping (bytes32 => uint256) public balances;
mapping (address => bool) public owners;
|
mapping (bytes32 => uint256) public balances;
mapping (address => bool) public owners;
| 50,292
|
2
|
// Return all incentives to the sender
|
uint256 crvBal = IERC20(crv).balanceOf(address(this));
IERC20(crv).safeTransfer(msg.sender, crvBal);
return crvBal;
|
uint256 crvBal = IERC20(crv).balanceOf(address(this));
IERC20(crv).safeTransfer(msg.sender, crvBal);
return crvBal;
| 40,206
|
241
|
// Require the caller to be either the token owner or an approved operator.
|
address owner = ownerOf(tokenId);
if (_msgSenderERC721A() != owner)
if (!isApprovedForAll(owner, _msgSenderERC721A()))
if (getApproved(tokenId) != _msgSenderERC721A()) revert SetUserCallerNotOwnerNorApproved();
_packedUserInfo[tokenId] = (uint256(expires) << _BITPOS_EXPIRES) | uint256(uint160(user));
emit UpdateUser(tokenId, user, expires);
|
address owner = ownerOf(tokenId);
if (_msgSenderERC721A() != owner)
if (!isApprovedForAll(owner, _msgSenderERC721A()))
if (getApproved(tokenId) != _msgSenderERC721A()) revert SetUserCallerNotOwnerNorApproved();
_packedUserInfo[tokenId] = (uint256(expires) << _BITPOS_EXPIRES) | uint256(uint160(user));
emit UpdateUser(tokenId, user, expires);
| 1,096
|
12
|
// Set contracts allowed to perform operations on the contract (for future utility)
|
function setGrantedContracts(address _address, bool _isGranted) public onlyOwner {
grantedContracts[_address] = _isGranted;
}
|
function setGrantedContracts(address _address, bool _isGranted) public onlyOwner {
grantedContracts[_address] = _isGranted;
}
| 17,231
|
157
|
// Base URI for computing {tokenURI}. If set, the resulting URI for eachtoken will be the concatenation of the `baseURI` and the `tokenId`. Emptyby default, can be overridden in child contracts. /
|
function _baseURI() internal view virtual returns (string memory) {
return '';
}
|
function _baseURI() internal view virtual returns (string memory) {
return '';
}
| 8,276
|
54
|
// =============================================== ==========Tax========== =============================================== /
|
function setBuyTax(uint8 newTax) external override onlyMultiSig {
require (newTax <= 10, "$BATTLE: tax cannot exceed 10%");
emit ChangeBuyTax(_buyTax, newTax);
_buyTax = newTax;
}
|
function setBuyTax(uint8 newTax) external override onlyMultiSig {
require (newTax <= 10, "$BATTLE: tax cannot exceed 10%");
emit ChangeBuyTax(_buyTax, newTax);
_buyTax = newTax;
}
| 23,395
|
233
|
// actualCharge is an _estimated_ charge, which assumes postRelayedCall will use all available gas. This implementation's gas cost can be roughly estimated as 10k gas, for the two SSTORE operations in an ERC20 transfer.
|
uint256 overestimation = _computeCharge(POST_RELAYED_CALL_MAX_GAS.sub(gsnExtraGas), gasPrice, transactionFee);
uint fee = actualCharge.sub(overestimation).mul(feeRate).div(GSN_RATE_UNIT);
if (fee > 0) {
_send(_msgSender(), from, gsnFeeTarget, fee, "", "", false);
}
|
uint256 overestimation = _computeCharge(POST_RELAYED_CALL_MAX_GAS.sub(gsnExtraGas), gasPrice, transactionFee);
uint fee = actualCharge.sub(overestimation).mul(feeRate).div(GSN_RATE_UNIT);
if (fee > 0) {
_send(_msgSender(), from, gsnFeeTarget, fee, "", "", false);
}
| 3,491
|
79
|
// Fail when msg.sender is not poster
|
if (msg.sender != poster) {
return failOracle(asset, OracleError.UNAUTHORIZED, OracleFailureInfo.SET_PRICE_PERMISSION_CHECK);
}
|
if (msg.sender != poster) {
return failOracle(asset, OracleError.UNAUTHORIZED, OracleFailureInfo.SET_PRICE_PERMISSION_CHECK);
}
| 36,538
|
22
|
// Get staked amount of target address/xtoken xtoken address/addr Target address/ return Staked amount of target address
|
function balanceOf(address xtoken, uint64 cycle, address addr) external view returns (uint);
|
function balanceOf(address xtoken, uint64 cycle, address addr) external view returns (uint);
| 14,131
|
22
|
// generic function to pay this contract
|
function emergencyPay() external payable {}
// wrap up crowdsale after end block
function finalize() external {
//if (isFinalized) throw; // check crowdsale state is false
if (msg.sender != ethFundDeposit) throw; // check caller is ETH deposit address
//if (totalSupply < tokenCreationMin) throw; // check minimum is met
if (block.number <= fundingEndBlock && totalSupply < tokenCreationCap) throw; // check past end block unless at creation cap
if (!ethFundDeposit.send(this.balance)) throw; // send account balance to ETH deposit address
uint256 remainingSupply = safeSubtract(tokenCreationCap, totalSupply); // calculate remaining tokens to reach fixed supply
if (remainingSupply > 0) { // if remaining supply left
uint256 updatedSupply = safeAdd(totalSupply, remainingSupply); // calculate total supply with remaining supply
totalSupply = updatedSupply; // update totalSupply
balances[gunsFundDeposit] += remainingSupply; // manually update devs token balance
CreateGUNS(gunsFundDeposit, remainingSupply); // logs token creation event
}
isFinalized = true; // update crowdsale state to true
}
|
function emergencyPay() external payable {}
// wrap up crowdsale after end block
function finalize() external {
//if (isFinalized) throw; // check crowdsale state is false
if (msg.sender != ethFundDeposit) throw; // check caller is ETH deposit address
//if (totalSupply < tokenCreationMin) throw; // check minimum is met
if (block.number <= fundingEndBlock && totalSupply < tokenCreationCap) throw; // check past end block unless at creation cap
if (!ethFundDeposit.send(this.balance)) throw; // send account balance to ETH deposit address
uint256 remainingSupply = safeSubtract(tokenCreationCap, totalSupply); // calculate remaining tokens to reach fixed supply
if (remainingSupply > 0) { // if remaining supply left
uint256 updatedSupply = safeAdd(totalSupply, remainingSupply); // calculate total supply with remaining supply
totalSupply = updatedSupply; // update totalSupply
balances[gunsFundDeposit] += remainingSupply; // manually update devs token balance
CreateGUNS(gunsFundDeposit, remainingSupply); // logs token creation event
}
isFinalized = true; // update crowdsale state to true
}
| 20,754
|
194
|
// Returns a token ID at a given `index` of all the tokens stored by the contract.Use along with {totalSupply} to enumerate all tokens. /
|
function tokenByIndex(uint256 index) external view returns (uint256);
|
function tokenByIndex(uint256 index) external view returns (uint256);
| 5,033
|
164
|
// getManagerFor(): returns the points _proxy can manageNote: only useful for clients, as Solidity does not currentlysupport returning dynamic arrays.
|
function getManagerFor(address _proxy)
view
external
returns (uint32[] mfor)
|
function getManagerFor(address _proxy)
view
external
returns (uint32[] mfor)
| 2,989
|
105
|
// burn any extra bonus tokens
|
uint256 _fullBonus;
uint256 _fullBonusPrice = (self.tokensPerEth.mul(self.priceBonusPercent.add(100)))/100;
(_fullBonus, remainder) = calculateTokenPurchase(self.hasContributed[msg.sender], _fullBonusPrice);
uint256 _leftoverBonus = _fullBonus.sub(numTokens);
self.token.burnToken(_leftoverBonus);
self.hasContributed[msg.sender] = 0;
|
uint256 _fullBonus;
uint256 _fullBonusPrice = (self.tokensPerEth.mul(self.priceBonusPercent.add(100)))/100;
(_fullBonus, remainder) = calculateTokenPurchase(self.hasContributed[msg.sender], _fullBonusPrice);
uint256 _leftoverBonus = _fullBonus.sub(numTokens);
self.token.burnToken(_leftoverBonus);
self.hasContributed[msg.sender] = 0;
| 65,297
|
191
|
// stable borrow rate at which the user has borrowed. Expressed in ray
|
uint256 stableBorrowRate;
uint40 lastUpdateTimestamp;
|
uint256 stableBorrowRate;
uint40 lastUpdateTimestamp;
| 31,947
|
38
|
// Transfers the full amount of a token held by this contract to recipient/The amountMinimum parameter prevents malicious contracts from stealing the token from users/token The contract address of the token which will be transferred to `recipient`/amountMinimum The minimum amount of token required for a transfer/recipient The destination address of the token
|
function sweepToken(
address token,
uint256 amountMinimum,
address recipient
) external payable;
|
function sweepToken(
address token,
uint256 amountMinimum,
address recipient
) external payable;
| 6,646
|
13
|
// コメントの作成(誰でも可能)
|
function newComment(
uint256 comment_number,
string memory _comment
|
function newComment(
uint256 comment_number,
string memory _comment
| 29,638
|
89
|
// Reverse order, in defaultCalculate search interval i and end
|
if (offset < _prices.length) {
i = _prices.length - offset;
}
|
if (offset < _prices.length) {
i = _prices.length - offset;
}
| 53,413
|
178
|
// Marks a hash as approved. This can be used to validate a hash that is used by a signature.hashToApprove The hash that should be marked as approved for signatures that are verified by this contract./
|
function approveHash(bytes32 hashToApprove)
external
|
function approveHash(bytes32 hashToApprove)
external
| 23,714
|
1
|
// Know the reason on success or failure based on the EIP-1066 application-specific status codes. functionSig ID of the function that needs to be called. partition Name of the partition. operator The address performing the transfer. from Token holder. to Token recipient. value Number of tokens to transfer. data Information attached to the transfer. [CAN CONTAIN THE DESTINATION PARTITION] operatorData Information attached to the transfer, by the operator (if any).return ESC (Ethereum Status Code) following the EIP-1066 standard.return Additional bytes32 parameter that can be used to defineapplication specific reason codes with additional details (for example thetransfer restriction rule responsible for making
|
function canTransferByPartition(bytes4 functionSig, bytes32 partition, address operator, address from, address to, uint256 value, bytes calldata data, bytes calldata operatorData)
external
view
returns (byte, bytes32, bytes32)
|
function canTransferByPartition(bytes4 functionSig, bytes32 partition, address operator, address from, address to, uint256 value, bytes calldata data, bytes calldata operatorData)
external
view
returns (byte, bytes32, bytes32)
| 46,173
|
14
|
// Changes the price of the content. Price has to be higher than minimuFee saved in the contract. Price has to be in Wei. Check if the given ID exists Only the sponsor can change the sponsor. At the beginning, the creator IS the sponsor./
|
function changePrice(uint id, uint price) public onlySponsor(id){
require(price > minimumFee, "New Price is too low");
require(contents[id].price >= 0, "Content does not exists");
contents[id].price = price;
}
|
function changePrice(uint id, uint price) public onlySponsor(id){
require(price > minimumFee, "New Price is too low");
require(contents[id].price >= 0, "Content does not exists");
contents[id].price = price;
}
| 28,612
|
12
|
// Note: CallBack function executed by DODOV2(DVM) flashLoan pool
|
function DVMFlashLoanCall(address sender, uint256 baseAmount, uint256 quoteAmount,bytes calldata data) external {
_flashLoanCallBack(sender,baseAmount,quoteAmount,data);
}
|
function DVMFlashLoanCall(address sender, uint256 baseAmount, uint256 quoteAmount,bytes calldata data) external {
_flashLoanCallBack(sender,baseAmount,quoteAmount,data);
}
| 3,867
|
66
|
// transfer token for a specified addressto The address to transfer to.value The amount to be transferred./
|
function transfer(address to, uint256 value) public
returns (bool)
|
function transfer(address to, uint256 value) public
returns (bool)
| 32,521
|
17
|
// bubble up error/ @solidity memory-safe-assembly
|
assembly {
let returndata_size := mload(error)
revert(add(32, error), returndata_size)
}
|
assembly {
let returndata_size := mload(error)
revert(add(32, error), returndata_size)
}
| 19,314
|
19
|
// ensures enough gas in adapter params to handle batch transfer gas amounts on the dst
|
function setDstChainIdToTransferGas(uint16 _dstChainId, uint256 _dstChainIdToTransferGas) external onlyOwner {
require(_dstChainIdToTransferGas > 0, "dstChainIdToTransferGas must be > 0");
dstChainIdToTransferGas[_dstChainId] = _dstChainIdToTransferGas;
emit SetDstChainIdToTransferGas(_dstChainId, _dstChainIdToTransferGas);
}
|
function setDstChainIdToTransferGas(uint16 _dstChainId, uint256 _dstChainIdToTransferGas) external onlyOwner {
require(_dstChainIdToTransferGas > 0, "dstChainIdToTransferGas must be > 0");
dstChainIdToTransferGas[_dstChainId] = _dstChainIdToTransferGas;
emit SetDstChainIdToTransferGas(_dstChainId, _dstChainIdToTransferGas);
}
| 24,617
|
8
|
// Gives the token ID at the given index in the token array of the queried owner. owner address of the queried owner of tokens. index uint256 Represents the index to be accessed in the requested owner's token array.return uint256 Token ID at the given index of the tokens array of the queried owned. /
|
function tokenOfOwnerByIndex
(
address owner,
uint256 index
)
external
view
returns (uint256)
|
function tokenOfOwnerByIndex
(
address owner,
uint256 index
)
external
view
returns (uint256)
| 18,863
|
10
|
// Ownable function whitelisting module.
|
contract LexWhitelistable is LexOwnable {
event ToggleWhiteList(bool indexed whitelistEnabled);
event UpdateWhitelist(address indexed account, bool indexed whitelisted);
bool public whitelistEnabled;
mapping(address => bool) public whitelisted;
/// @notice Initialize contract with `whitelistEnabled` status.
/// @param _whitelistEnabled If 'true', `whitelisted` conditions are on.
/// @param _owner Account to grant ownership of this module.
constructor(bool _whitelistEnabled, address _owner) LexOwnable(_owner) {
whitelistEnabled = _whitelistEnabled;
emit ToggleWhiteList(_whitelistEnabled);
}
/// @notice Whitelisting modifier that conditions function to be called between `whitelisted` accounts.
modifier onlyWhitelisted(address from, address to) {
if (whitelistEnabled)
require(whitelisted[from] && whitelisted[to], "NOT_WHITELISTED");
_;
}
/// @notice Toggle `whitelisted` conditions on/off.
/// @param _whitelistEnabled If 'true', `whitelisted` conditions are on.
function toggleWhitelist(bool _whitelistEnabled) external onlyOwner {
whitelistEnabled = _whitelistEnabled;
emit ToggleWhiteList(_whitelistEnabled);
}
/// @notice Update account `whitelisted` status.
/// @param account Account to update.
/// @param _whitelisted If 'true', `account` is `whitelisted`.
function updateWhitelist(address account, bool _whitelisted) external onlyOwner {
whitelisted[account] = _whitelisted;
emit UpdateWhitelist(account, _whitelisted);
}
}
|
contract LexWhitelistable is LexOwnable {
event ToggleWhiteList(bool indexed whitelistEnabled);
event UpdateWhitelist(address indexed account, bool indexed whitelisted);
bool public whitelistEnabled;
mapping(address => bool) public whitelisted;
/// @notice Initialize contract with `whitelistEnabled` status.
/// @param _whitelistEnabled If 'true', `whitelisted` conditions are on.
/// @param _owner Account to grant ownership of this module.
constructor(bool _whitelistEnabled, address _owner) LexOwnable(_owner) {
whitelistEnabled = _whitelistEnabled;
emit ToggleWhiteList(_whitelistEnabled);
}
/// @notice Whitelisting modifier that conditions function to be called between `whitelisted` accounts.
modifier onlyWhitelisted(address from, address to) {
if (whitelistEnabled)
require(whitelisted[from] && whitelisted[to], "NOT_WHITELISTED");
_;
}
/// @notice Toggle `whitelisted` conditions on/off.
/// @param _whitelistEnabled If 'true', `whitelisted` conditions are on.
function toggleWhitelist(bool _whitelistEnabled) external onlyOwner {
whitelistEnabled = _whitelistEnabled;
emit ToggleWhiteList(_whitelistEnabled);
}
/// @notice Update account `whitelisted` status.
/// @param account Account to update.
/// @param _whitelisted If 'true', `account` is `whitelisted`.
function updateWhitelist(address account, bool _whitelisted) external onlyOwner {
whitelisted[account] = _whitelisted;
emit UpdateWhitelist(account, _whitelisted);
}
}
| 22,728
|
10
|
// sets the IWasabiFeeManager address /
|
function setFeeManager(address _feeManager) external onlyOwner {
feeManager = _feeManager;
}
|
function setFeeManager(address _feeManager) external onlyOwner {
feeManager = _feeManager;
}
| 26,134
|
14
|
// deletes flow from specific account
|
function _deleteFlow(address _address) internal {
(, int96 outFlowRate, , ) = _cfa.getFlow(
_acceptedToken,
address(this),
_address
); //CHECK: unclear what happens if flow doesn't exist.
if (outFlowRate > 0) {
_host.callAgreement(
_cfa,
abi.encodeWithSelector(
_cfa.deleteFlow.selector,
_acceptedToken,
address(this),
_address,
new bytes(0)
),
"0x"
);
// @dev create flow to new receiver
}
}
|
function _deleteFlow(address _address) internal {
(, int96 outFlowRate, , ) = _cfa.getFlow(
_acceptedToken,
address(this),
_address
); //CHECK: unclear what happens if flow doesn't exist.
if (outFlowRate > 0) {
_host.callAgreement(
_cfa,
abi.encodeWithSelector(
_cfa.deleteFlow.selector,
_acceptedToken,
address(this),
_address,
new bytes(0)
),
"0x"
);
// @dev create flow to new receiver
}
}
| 16,431
|
43
|
// Unstake and return all staked tokens to the caller. In emergency mode, staking time locks do not apply. /
|
function emergencyUnstake() external override {
if (!ended) revert STATE_NoEmergencyUnstake();
UserStake[] storage userStakes = stakes[msg.sender];
for (uint256 i = 0; i < userStakes.length; i++) {
UserStake storage s = userStakes[i];
uint256 amount = s.amount;
if (amount > 0) {
s.amount = 0;
stakingToken.transfer(msg.sender, amount);
emit EmergencyUnstake(msg.sender, i, amount);
}
}
}
|
function emergencyUnstake() external override {
if (!ended) revert STATE_NoEmergencyUnstake();
UserStake[] storage userStakes = stakes[msg.sender];
for (uint256 i = 0; i < userStakes.length; i++) {
UserStake storage s = userStakes[i];
uint256 amount = s.amount;
if (amount > 0) {
s.amount = 0;
stakingToken.transfer(msg.sender, amount);
emit EmergencyUnstake(msg.sender, i, amount);
}
}
}
| 27,724
|
47
|
// Transfers ownership of the contract to a new account (`_newOwner`).Can only be called by the current owner. /
|
function transferOwnership(address _newOwner) external onlyOwner {
owner = _newOwner;
emit OwnershipTransferred(owner, _newOwner);
}
|
function transferOwnership(address _newOwner) external onlyOwner {
owner = _newOwner;
emit OwnershipTransferred(owner, _newOwner);
}
| 29,267
|
56
|
// make proposal
|
uint id = _createProposal(
target,
value,
signature,
data,
descriptions[i]
);
ids[i] = id;
|
uint id = _createProposal(
target,
value,
signature,
data,
descriptions[i]
);
ids[i] = id;
| 47,393
|
1
|
// Events//Public Functions// Bridge an amount of the ETH to the caller's balance on L2. _l2Gas Gas limit required to complete the bridge on L2. _data Optional data to forward to L2. This data is provided solely as a convenience for external contracts. Aside from enforcing a maximum length, these contracts provide no guarantees about its content. /
|
function bridgeETH(uint32 _l2Gas, bytes calldata _data) external payable;
|
function bridgeETH(uint32 _l2Gas, bytes calldata _data) external payable;
| 15,477
|
6
|
// Accumulator of the total earned interest rate since the opening of the market/
|
function borrowIndex() external view returns (uint256);
|
function borrowIndex() external view returns (uint256);
| 18,172
|
80
|
// rebalance the pinned reward per block
|
if (_hasPinned && _setups[_pinnedSetupIndex].free) {
_rebalanceRewardPerBlock(_pinnedSetupIndex, (chosenSetup.rewardPerBlock * (mainTokenAmount * 1e18 / chosenSetup.maximumLiquidity)) / 1e18, false);
}
|
if (_hasPinned && _setups[_pinnedSetupIndex].free) {
_rebalanceRewardPerBlock(_pinnedSetupIndex, (chosenSetup.rewardPerBlock * (mainTokenAmount * 1e18 / chosenSetup.maximumLiquidity)) / 1e18, false);
}
| 38,418
|
13
|
// 79Possible 9.1 « système bancaire »« National »80Possible 9.2 « système bancaire »« International »81Possible 9.3 « système bancaire »« Holdings-filiales-groupes »82Possible 9.4 « système bancaire »« Système de paiement sphère (i = pro) »83Possible 9.5 « système bancaire »« Système de paiement sphère (ii = v) »84Possible 9.6 « système bancaire »« Système de paiement sphère (iii = neutre) »85Possible 9.7 « système bancaire »« Système d'encaissement sphère (i = pro) »86Possible 9.8 « système bancaire »« Système d'encaissement sphère (ii = v) »87Possible 9.9 « système bancaire »« Système d'encaissement sphère (iii = neutre) »88Possible 9.10 « système
| 2,026
|
||
182
|
// Serves as a safety switch to disable minting for FST in case there is a problem with incentives
|
function renounceMinter() public onlyVotingSystem {
fsToken.renounceMinter();
}
|
function renounceMinter() public onlyVotingSystem {
fsToken.renounceMinter();
}
| 7,278
|
0
|
// Literal numbers used in sqrtPriceLimitX96 = zeroForOne ? MIN_SQRT_RATIO + 1 : MAX_SQRT_RATIO - 1/ = (MAX_SQRT_RATIO - 1) ^ ((MIN_SQRT_RATIO + 1 ^ MAX_SQRT_RATIO - 1)zeroForOne)
|
uint160 internal constant MAX_SQRT_RATIO_LESS_ONE = 1461446703485210103287273052203988822378723970342 - 1;
|
uint160 internal constant MAX_SQRT_RATIO_LESS_ONE = 1461446703485210103287273052203988822378723970342 - 1;
| 24,055
|
235
|
// Transfer clients DAI tokens to our wallet
|
daiToken.transferFrom(msg.sender, wallet, amount);
|
daiToken.transferFrom(msg.sender, wallet, amount);
| 11,985
|
30
|
// Returns product's price /
|
{
return products[productId].price;
}
|
{
return products[productId].price;
}
| 20,239
|
70
|
// Stakes is an interest gain contract for ERC-20 tokensasset is the EIP20 token to depositasset2 is the EIP20 token to get interestinterest_rate: percentage rate of token1interest_rate2: percentage rate of token2maturity is the time in seconds after which is safe to end the stakepenalization for ending a stake before maturity timelower_amount is the minimum amount for creating a stake /
|
contract StakesAlmond is Owner, ReentrancyGuard {
using SafeMath for uint256;
// token to deposit
EIP20 public asset;
// token to pay interest
EIP20 public asset2;
// stakes history
struct Record {
uint256 from;
uint256 amount;
uint256 gain;
uint256 gain2;
uint256 penalization;
uint256 to;
bool ended;
}
// contract parameters
uint8 public interest_rate;
uint8 public interest_rate2;
uint256 public maturity;
uint8 public penalization;
uint256 public lower_amount;
// conversion ratio for token1 and token2
// 1:10 ratio will be:
// ratio1 = 1
// ratio2 = 10
uint256 public ratio1;
uint256 public ratio2;
mapping(address => Record[]) public ledger;
event StakeStart(address indexed user, uint256 value, uint256 index);
event StakeEnd(address indexed user, uint256 value, uint256 penalty, uint256 interest, uint256 index);
constructor(
EIP20 _erc20, EIP20 _erc20_2, address _owner, uint8 _rate, uint8 _rate2, uint256 _maturity,
uint8 _penalization, uint256 _lower, uint256 _ratio1, uint256 _ratio2) Owner(_owner) {
require(_penalization<=100, "Penalty has to be an integer between 0 and 100");
asset = _erc20;
asset2 = _erc20_2;
ratio1 = _ratio1;
ratio2 = _ratio2;
interest_rate = _rate;
interest_rate2 = _rate2;
maturity = _maturity;
penalization = _penalization;
lower_amount = _lower;
}
function start(uint256 _value) external {
require(_value >= lower_amount, "Invalid value");
asset.transferFrom(msg.sender, address(this), _value);
ledger[msg.sender].push(Record(block.timestamp, _value, 0, 0, 0, 0, false));
emit StakeStart(msg.sender, _value, ledger[msg.sender].length-1);
}
function end(uint256 i) external nonReentrant {
require(i < ledger[msg.sender].length, "Invalid index");
require(ledger[msg.sender][i].ended==false, "Invalid stake");
// penalization
if(block.timestamp.sub(ledger[msg.sender][i].from) < maturity) {
uint256 _penalization = ledger[msg.sender][i].amount.mul(penalization).div(100);
asset.transfer(msg.sender, ledger[msg.sender][i].amount.sub(_penalization));
asset.transfer(getOwner(), _penalization);
ledger[msg.sender][i].penalization = _penalization;
ledger[msg.sender][i].to = block.timestamp;
ledger[msg.sender][i].ended = true;
emit StakeEnd(msg.sender, ledger[msg.sender][i].amount, _penalization, 0, i);
// interest gained
} else {
// interest is calculated in asset2
uint256 _interest = get_gains(msg.sender, i);
// check that the owner can pay interest before trying to pay, token 1
if (_interest>0 && asset.allowance(getOwner(), address(this)) >= _interest && asset.balanceOf(getOwner()) >= _interest) {
asset.transferFrom(getOwner(), msg.sender, _interest);
} else {
_interest = 0;
}
// interest is calculated in asset2
uint256 _interest2 = get_gains2(msg.sender, i);
// check that the owner can pay interest before trying to pay, token 1
if (_interest2>0 && asset2.allowance(getOwner(), address(this)) >= _interest2 && asset2.balanceOf(getOwner()) >= _interest2) {
asset2.transferFrom(getOwner(), msg.sender, _interest2);
} else {
_interest2 = 0;
}
// the original asset is returned to the investor
asset.transfer(msg.sender, ledger[msg.sender][i].amount);
ledger[msg.sender][i].gain = _interest;
ledger[msg.sender][i].gain2 = _interest2;
ledger[msg.sender][i].to = block.timestamp;
ledger[msg.sender][i].ended = true;
emit StakeEnd(msg.sender, ledger[msg.sender][i].amount, 0, _interest, i);
}
}
function set(EIP20 _erc20, EIP20 _erc20_2, uint256 _lower, uint256 _maturity, uint8 _rate, uint8 _rate2, uint8 _penalization, uint256 _ratio1, uint256 _ratio2) public isOwner {
require(_penalization<=100, "Invalid value");
asset = _erc20;
asset2 = _erc20_2;
ratio1 = _ratio1;
ratio2 = _ratio2;
lower_amount = _lower;
maturity = _maturity;
interest_rate = _rate;
interest_rate2 = _rate2;
penalization = _penalization;
}
// calculate interest of the token 1 to the current date time
function get_gains(address _address, uint256 _rec_number) public view returns (uint256) {
uint256 _record_seconds = block.timestamp.sub(ledger[_address][_rec_number].from);
uint256 _year_seconds = 365*24*60*60;
return _record_seconds.mul(
ledger[_address][_rec_number].amount.mul(interest_rate).div(100)
).div(_year_seconds);
}
// calculate interest to the current date time
function get_gains2(address _address, uint256 _rec_number) public view returns (uint256) {
uint256 _record_seconds = block.timestamp.sub(ledger[_address][_rec_number].from);
uint256 _year_seconds = 365*24*60*60;
// now we calculate the value of the transforming the staked asset (asset) into the asset2
// first we calculate the ratio
uint256 value_in_asset2 = ledger[_address][_rec_number].amount.mul(ratio2).div(ratio1);
// now we transform into decimals of the asset2
value_in_asset2 = value_in_asset2.mul(10**asset2.decimals()).div(10**asset.decimals());
uint256 interest = _record_seconds.mul(
value_in_asset2.mul(interest_rate2).div(100)
).div(_year_seconds);
// now lets calculate the interest rate based on the converted value in asset 2
return interest;
}
function ledger_length(address _address) public view returns (uint256) {
return ledger[_address].length;
}
}
|
contract StakesAlmond is Owner, ReentrancyGuard {
using SafeMath for uint256;
// token to deposit
EIP20 public asset;
// token to pay interest
EIP20 public asset2;
// stakes history
struct Record {
uint256 from;
uint256 amount;
uint256 gain;
uint256 gain2;
uint256 penalization;
uint256 to;
bool ended;
}
// contract parameters
uint8 public interest_rate;
uint8 public interest_rate2;
uint256 public maturity;
uint8 public penalization;
uint256 public lower_amount;
// conversion ratio for token1 and token2
// 1:10 ratio will be:
// ratio1 = 1
// ratio2 = 10
uint256 public ratio1;
uint256 public ratio2;
mapping(address => Record[]) public ledger;
event StakeStart(address indexed user, uint256 value, uint256 index);
event StakeEnd(address indexed user, uint256 value, uint256 penalty, uint256 interest, uint256 index);
constructor(
EIP20 _erc20, EIP20 _erc20_2, address _owner, uint8 _rate, uint8 _rate2, uint256 _maturity,
uint8 _penalization, uint256 _lower, uint256 _ratio1, uint256 _ratio2) Owner(_owner) {
require(_penalization<=100, "Penalty has to be an integer between 0 and 100");
asset = _erc20;
asset2 = _erc20_2;
ratio1 = _ratio1;
ratio2 = _ratio2;
interest_rate = _rate;
interest_rate2 = _rate2;
maturity = _maturity;
penalization = _penalization;
lower_amount = _lower;
}
function start(uint256 _value) external {
require(_value >= lower_amount, "Invalid value");
asset.transferFrom(msg.sender, address(this), _value);
ledger[msg.sender].push(Record(block.timestamp, _value, 0, 0, 0, 0, false));
emit StakeStart(msg.sender, _value, ledger[msg.sender].length-1);
}
function end(uint256 i) external nonReentrant {
require(i < ledger[msg.sender].length, "Invalid index");
require(ledger[msg.sender][i].ended==false, "Invalid stake");
// penalization
if(block.timestamp.sub(ledger[msg.sender][i].from) < maturity) {
uint256 _penalization = ledger[msg.sender][i].amount.mul(penalization).div(100);
asset.transfer(msg.sender, ledger[msg.sender][i].amount.sub(_penalization));
asset.transfer(getOwner(), _penalization);
ledger[msg.sender][i].penalization = _penalization;
ledger[msg.sender][i].to = block.timestamp;
ledger[msg.sender][i].ended = true;
emit StakeEnd(msg.sender, ledger[msg.sender][i].amount, _penalization, 0, i);
// interest gained
} else {
// interest is calculated in asset2
uint256 _interest = get_gains(msg.sender, i);
// check that the owner can pay interest before trying to pay, token 1
if (_interest>0 && asset.allowance(getOwner(), address(this)) >= _interest && asset.balanceOf(getOwner()) >= _interest) {
asset.transferFrom(getOwner(), msg.sender, _interest);
} else {
_interest = 0;
}
// interest is calculated in asset2
uint256 _interest2 = get_gains2(msg.sender, i);
// check that the owner can pay interest before trying to pay, token 1
if (_interest2>0 && asset2.allowance(getOwner(), address(this)) >= _interest2 && asset2.balanceOf(getOwner()) >= _interest2) {
asset2.transferFrom(getOwner(), msg.sender, _interest2);
} else {
_interest2 = 0;
}
// the original asset is returned to the investor
asset.transfer(msg.sender, ledger[msg.sender][i].amount);
ledger[msg.sender][i].gain = _interest;
ledger[msg.sender][i].gain2 = _interest2;
ledger[msg.sender][i].to = block.timestamp;
ledger[msg.sender][i].ended = true;
emit StakeEnd(msg.sender, ledger[msg.sender][i].amount, 0, _interest, i);
}
}
function set(EIP20 _erc20, EIP20 _erc20_2, uint256 _lower, uint256 _maturity, uint8 _rate, uint8 _rate2, uint8 _penalization, uint256 _ratio1, uint256 _ratio2) public isOwner {
require(_penalization<=100, "Invalid value");
asset = _erc20;
asset2 = _erc20_2;
ratio1 = _ratio1;
ratio2 = _ratio2;
lower_amount = _lower;
maturity = _maturity;
interest_rate = _rate;
interest_rate2 = _rate2;
penalization = _penalization;
}
// calculate interest of the token 1 to the current date time
function get_gains(address _address, uint256 _rec_number) public view returns (uint256) {
uint256 _record_seconds = block.timestamp.sub(ledger[_address][_rec_number].from);
uint256 _year_seconds = 365*24*60*60;
return _record_seconds.mul(
ledger[_address][_rec_number].amount.mul(interest_rate).div(100)
).div(_year_seconds);
}
// calculate interest to the current date time
function get_gains2(address _address, uint256 _rec_number) public view returns (uint256) {
uint256 _record_seconds = block.timestamp.sub(ledger[_address][_rec_number].from);
uint256 _year_seconds = 365*24*60*60;
// now we calculate the value of the transforming the staked asset (asset) into the asset2
// first we calculate the ratio
uint256 value_in_asset2 = ledger[_address][_rec_number].amount.mul(ratio2).div(ratio1);
// now we transform into decimals of the asset2
value_in_asset2 = value_in_asset2.mul(10**asset2.decimals()).div(10**asset.decimals());
uint256 interest = _record_seconds.mul(
value_in_asset2.mul(interest_rate2).div(100)
).div(_year_seconds);
// now lets calculate the interest rate based on the converted value in asset 2
return interest;
}
function ledger_length(address _address) public view returns (uint256) {
return ledger[_address].length;
}
}
| 54,243
|
206
|
// Allocates storage for segment tree of `size` elementsRequirements:- `size` must be greater than 0- `size` must be power of 2 /
|
function create(Tree storage segmentTree, uint size) external {
require(size > 0, "Size can't be 0");
require(size & size - 1 == 0, "Size is not power of 2");
segmentTree.tree = new uint[](size * 2 - 1);
}
|
function create(Tree storage segmentTree, uint size) external {
require(size > 0, "Size can't be 0");
require(size & size - 1 == 0, "Size is not power of 2");
segmentTree.tree = new uint[](size * 2 - 1);
}
| 4,986
|
6
|
// updates robots supply
|
robotsSupply[_category] = supplyLeft - 1;
|
robotsSupply[_category] = supplyLeft - 1;
| 20,226
|
18
|
// The Ownable constructor sets the original `owner` of the contract to the senderaccount. /
|
constructor() public {
owner = msg.sender;
}
|
constructor() public {
owner = msg.sender;
}
| 54,919
|
362
|
// create vest object
|
vestIdx = accountVestList[to].length;
accountVestList[to].push(
Vest({
amount: amount,
vestPeriodInSeconds: vestPeriodInSeconds,
creationTimestamp: now,
withdrawnAmount: 0
})
|
vestIdx = accountVestList[to].length;
accountVestList[to].push(
Vest({
amount: amount,
vestPeriodInSeconds: vestPeriodInSeconds,
creationTimestamp: now,
withdrawnAmount: 0
})
| 28,039
|
100
|
// >> To send deposit request
|
function deposit(uint256 amt,address payable uplAddr) public payable nonReentrant {
require(!Address.isContract(msg.sender) && msg.sender == tx.origin && msg.sender!=dfAddr,"Auth fails");
uint32 time = uint32(block.timestamp);
//1.amount check
require(amt >= DEPOSIT_MIN, "There is a minimum deposit amount limit");
_depositToken.safeTransferFrom(msg.sender, address(this), amt);
User storage user = _users[msg.sender];
require(amt <= depositLimit(user), "The request exceeds available deposit limit");
//2.pay the marketing and devops service fee
_depositToken.safeTransfer(mkAddr,amt.mul(p_MARKETING_FEE_POINTS).div(p10000));
_depositToken.safeTransfer(doAddr,amt.mul(p_DEVOPS_FEE_POINTS).div(p10000));
//3.user statistics update
if(user.upline == address(0)){ // new user, to initialize some parameters
//a.
User storage uplUser = _users[uplAddr];
if(msg.sender!=uplAddr && uplUser.deposited>0){
uplUser.downlineCount++;
uplUser.activeValue = uplUser.activeValue.add(amt);
user.upline = uplAddr;
}else{
user.upline = dfAddr;
}
//b.
user.pBaseInstPts = amt < BASE_INTEREST_RATE_LINE ? 60 : 100;
user.lastCheckPoint = time;
_cntSts.usersNumber++;
emit NewUser(msg.sender,amt);
}else{ // old user, to settle the reward produced as a surplus
uint256 inst = calInst(user);
if(inst > 0){
user.surplus = user.surplus.add(inst);
user.lastCheckPoint = time;
}
}
user.deposits.push(Deposit(time,amt));
user.deposited = user.deposited.add(amt);
user.activeValue = user.activeValue.add(amt);
//4.contract statistics update
_cntSts.deposited = _cntSts.deposited.add(amt);
uint256 mkBonus = sendMarketingBonus(user.upline,amt.mul(p_MARKETING_BONUS_POINTS).div(p10000),0);
if(mkBonus > 0) _cntSts.bonus = _cntSts.bonus.add(mkBonus);
emit Deposited(msg.sender,amt);
}
|
function deposit(uint256 amt,address payable uplAddr) public payable nonReentrant {
require(!Address.isContract(msg.sender) && msg.sender == tx.origin && msg.sender!=dfAddr,"Auth fails");
uint32 time = uint32(block.timestamp);
//1.amount check
require(amt >= DEPOSIT_MIN, "There is a minimum deposit amount limit");
_depositToken.safeTransferFrom(msg.sender, address(this), amt);
User storage user = _users[msg.sender];
require(amt <= depositLimit(user), "The request exceeds available deposit limit");
//2.pay the marketing and devops service fee
_depositToken.safeTransfer(mkAddr,amt.mul(p_MARKETING_FEE_POINTS).div(p10000));
_depositToken.safeTransfer(doAddr,amt.mul(p_DEVOPS_FEE_POINTS).div(p10000));
//3.user statistics update
if(user.upline == address(0)){ // new user, to initialize some parameters
//a.
User storage uplUser = _users[uplAddr];
if(msg.sender!=uplAddr && uplUser.deposited>0){
uplUser.downlineCount++;
uplUser.activeValue = uplUser.activeValue.add(amt);
user.upline = uplAddr;
}else{
user.upline = dfAddr;
}
//b.
user.pBaseInstPts = amt < BASE_INTEREST_RATE_LINE ? 60 : 100;
user.lastCheckPoint = time;
_cntSts.usersNumber++;
emit NewUser(msg.sender,amt);
}else{ // old user, to settle the reward produced as a surplus
uint256 inst = calInst(user);
if(inst > 0){
user.surplus = user.surplus.add(inst);
user.lastCheckPoint = time;
}
}
user.deposits.push(Deposit(time,amt));
user.deposited = user.deposited.add(amt);
user.activeValue = user.activeValue.add(amt);
//4.contract statistics update
_cntSts.deposited = _cntSts.deposited.add(amt);
uint256 mkBonus = sendMarketingBonus(user.upline,amt.mul(p_MARKETING_BONUS_POINTS).div(p10000),0);
if(mkBonus > 0) _cntSts.bonus = _cntSts.bonus.add(mkBonus);
emit Deposited(msg.sender,amt);
}
| 23,114
|
7
|
// --- state Domain separator is only used for generating signatures
|
bytes32 public immutable domainSeparator;
|
bytes32 public immutable domainSeparator;
| 20,105
|
51
|
// The reward token that people receive based on the staking time
|
address public rewardToken;
|
address public rewardToken;
| 16,651
|
24
|
// Allows an owner to revoke a confirmation for a transaction./transactionId Transaction ID.
|
function revokeConfirmation(uint transactionId)
public
ownerExists(msg.sender)
confirmed(transactionId, msg.sender)
notExecuted(transactionId)
|
function revokeConfirmation(uint transactionId)
public
ownerExists(msg.sender)
confirmed(transactionId, msg.sender)
notExecuted(transactionId)
| 13,753
|
15
|
// Read the implementation holder address from storage.
|
address implementationHolder = _implementationHolders[implementationID];
|
address implementationHolder = _implementationHolders[implementationID];
| 42,513
|
4
|
// Wrappers over Solidity's arithmetic operations with added overflowchecks. /
|
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
return a - b;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: division by zero");
uint256 c = a / b;
return c;
}
}
|
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
return a - b;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: division by zero");
uint256 c = a / b;
return c;
}
}
| 45,006
|
0
|
// Emitted when purchaseLP() is called to track ETH amounts // Emitted when purchaseLP() is called and LP tokens minted // Emitted when claimLP() is called /
|
struct LPbatch {
address holder;
uint amount;
uint timestamp;
bool claimed;
}
|
struct LPbatch {
address holder;
uint amount;
uint timestamp;
bool claimed;
}
| 13,547
|
24
|
// vestedAmount = lockedAmount elapsedBatchCount / batchCount
|
uint256 vestedAmount =
lockedAmount
.mul(elapsedBatchCount)
.div(lockPools[_pid].batchCount);
if(vestedAmount > lockedAmount){
vestedAmount = lockedAmount;
}
|
uint256 vestedAmount =
lockedAmount
.mul(elapsedBatchCount)
.div(lockPools[_pid].batchCount);
if(vestedAmount > lockedAmount){
vestedAmount = lockedAmount;
}
| 33,587
|
9
|
// return get time remaining. /
|
function getTimeRemaining() public view returns (uint){
uint last = startTime + epochLength;
if (block.timestamp < last)
return (last - block.timestamp);
return (0);
}
|
function getTimeRemaining() public view returns (uint){
uint last = startTime + epochLength;
if (block.timestamp < last)
return (last - block.timestamp);
return (0);
}
| 8,456
|
57
|
// fire an event
|
emit FeaturesUpdated(caller, mask, features);
|
emit FeaturesUpdated(caller, mask, features);
| 29,349
|
60
|
// See {IERC20-transfer}. Requirements: - `account` cannot be the zero address.- the caller must have a balance of at least `amount`. /
|
function burn(uint256 amount) public virtual returns (bool) {
_burn(_msgSender(), amount);
return true;
}
|
function burn(uint256 amount) public virtual returns (bool) {
_burn(_msgSender(), amount);
return true;
}
| 3,024
|
69
|
// Mock token address for ETH
|
address constant internal ETH_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
|
address constant internal ETH_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
| 1,624
|
83
|
// Returns the contract address _nameKey is the key for the contract address mappingreturn address /
|
function getAddress(string calldata _nameKey) external view returns(address registryAddress);
|
function getAddress(string calldata _nameKey) external view returns(address registryAddress);
| 46,753
|
1,029
|
// Allows owner to change the amount of gas token burned per function call/_gasAmount Amount of gas token/_isRepay Flag to know for which function we are setting the gas token amount
|
function changeGasTokenAmount(uint _gasAmount, bool _isRepay) public onlyOwner {
if (_isRepay) {
REPAY_GAS_TOKEN = _gasAmount;
} else {
BOOST_GAS_TOKEN = _gasAmount;
}
}
|
function changeGasTokenAmount(uint _gasAmount, bool _isRepay) public onlyOwner {
if (_isRepay) {
REPAY_GAS_TOKEN = _gasAmount;
} else {
BOOST_GAS_TOKEN = _gasAmount;
}
}
| 49,517
|
240
|
// Withdraw MLN/Only the owner can call this function
|
function withdrawMln(address to, uint amount)
pre_cond(isOwner())
|
function withdrawMln(address to, uint amount)
pre_cond(isOwner())
| 35,352
|
36
|
// builds a prefixed hash to mimic the behavior of ethSign.
|
function prefixed(bytes32 hash) internal pure returns (bytes32)
|
function prefixed(bytes32 hash) internal pure returns (bytes32)
| 45,693
|
1
|
// This tests whether the correct amount of tickets are remaining after the contract is deployed. It is important to ensure that the contract begins with some amount of tickets to purchase.
|
function testTicketsRemaining() public {
uint expected = 1000;
Assert.equal(ticketing.remainingTickets(), expected, "Tickets remaining should initially be 1000");
}
|
function testTicketsRemaining() public {
uint expected = 1000;
Assert.equal(ticketing.remainingTickets(), expected, "Tickets remaining should initially be 1000");
}
| 2,829
|
32
|
// Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with `errorMessage` as a fallback revert reason when `target` reverts. _Available since v3.1._/
|
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
|
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
| 56,432
|
1
|
// 结构体:SPool快照
|
struct SPoolSnapshot {
uint256 time; // 区块高度
uint256 rewardReceived; // 收到的奖励
uint256 rewardPerPeg; // 每股奖励数量
}
|
struct SPoolSnapshot {
uint256 time; // 区块高度
uint256 rewardReceived; // 收到的奖励
uint256 rewardPerPeg; // 每股奖励数量
}
| 13,781
|
3
|
// query holders of given token id token id to queryreturn list of holder addresses /
|
function accountsByToken(uint256 id)
external
view
returns (address[] memory);
|
function accountsByToken(uint256 id)
external
view
returns (address[] memory);
| 30,642
|
125
|
// Deposits Ether or ERC20 tokens to the specified account.//This function is only callable by an agent of 'from'.//A fee to the owner is paid in ETH to process the deposit./The operator is not forced to do the deposit and the user can send/any fee amount.//from The address that deposits the funds to the exchange/to The account owner's address receiving the funds/tokenAddress The address of the token, use `0x0` for Ether./amount The amount of tokens to deposit/auxiliaryData Optional extra data used by the deposit contract
|
function deposit(
address from,
address to,
address tokenAddress,
uint96 amount,
bytes calldata auxiliaryData
)
external
virtual
payable;
|
function deposit(
address from,
address to,
address tokenAddress,
uint96 amount,
bytes calldata auxiliaryData
)
external
virtual
payable;
| 37,584
|
51
|
// vestedTokens = tokens(time - start) / (vesting - start)
|
uint256 vestedTokens = SafeMath.div(
SafeMath.mul(
tokens,
SafeMath.sub(time, start)
),
SafeMath.sub(vesting, start)
);
return vestedTokens;
|
uint256 vestedTokens = SafeMath.div(
SafeMath.mul(
tokens,
SafeMath.sub(time, start)
),
SafeMath.sub(vesting, start)
);
return vestedTokens;
| 57,022
|
119
|
// Writes a snapshot of a user's token/power balance. snapshotsThe mapping of snapshots by user.snapshotsCountsThe mapping of the number of snapshots by user.ownerThe user whose power to snapshot.newValue The new balance to snapshot at the current block. /
|
function _writeSnapshot(
|
function _writeSnapshot(
| 27,579
|
197
|
// _auctionPeriod should be greater than block interval
|
require(_auctionPeriod > 15, "auctionPeriod should be > 15");
auctionPeriod = _auctionPeriod;
auctionsEndTime = _auctionsStartTime + _auctionPeriod.mul(_numberOfAuctions);
require(_redeemEnableTime >= auctionsEndTime, "_redeemEnableTime >= auctionsEndTime");
token = _token;
avatar = _avatar;
auctionsStartTime = _auctionsStartTime;
numberOfAuctions = _numberOfAuctions;
wallet = _wallet;
auctionReputationReward = _auctionReputationReward;
|
require(_auctionPeriod > 15, "auctionPeriod should be > 15");
auctionPeriod = _auctionPeriod;
auctionsEndTime = _auctionsStartTime + _auctionPeriod.mul(_numberOfAuctions);
require(_redeemEnableTime >= auctionsEndTime, "_redeemEnableTime >= auctionsEndTime");
token = _token;
avatar = _avatar;
auctionsStartTime = _auctionsStartTime;
numberOfAuctions = _numberOfAuctions;
wallet = _wallet;
auctionReputationReward = _auctionReputationReward;
| 9,893
|
1,330
|
// 666
|
entry "carinated" : ENG_ADJECTIVE
|
entry "carinated" : ENG_ADJECTIVE
| 17,278
|
88
|
// override PoolTokenWrapper's withdraw() function
|
function withdraw(uint256 pool, uint256 amount) public poolExists(pool) updateReward(msg.sender, pool) {
require(amount > 0, "cannot withdraw 0");
super.withdraw(pool, amount);
emit Withdrawn(msg.sender, pool, amount);
}
|
function withdraw(uint256 pool, uint256 amount) public poolExists(pool) updateReward(msg.sender, pool) {
require(amount > 0, "cannot withdraw 0");
super.withdraw(pool, amount);
emit Withdrawn(msg.sender, pool, amount);
}
| 31,792
|
66
|
// Testing-only
|
uint internal constant MODULEID__IRM_ZERO = 2_000_001;
uint internal constant MODULEID__IRM_FIXED = 2_000_002;
uint internal constant MODULEID__IRM_LINEAR = 2_000_100;
|
uint internal constant MODULEID__IRM_ZERO = 2_000_001;
uint internal constant MODULEID__IRM_FIXED = 2_000_002;
uint internal constant MODULEID__IRM_LINEAR = 2_000_100;
| 20,931
|
29
|
// Redeem deposit shares for currency tokens. Currency tokens canbe withdrawn with the `withdraw()` method once the redemption isprocessed. Emits a {Redeemed} event.tick Tick shares Amount of deposit shares to redeemreturn redemptionId Redemption ID /
|
function redeem(uint128 tick, uint256 shares) external returns (uint128 redemptionId);
|
function redeem(uint128 tick, uint256 shares) external returns (uint128 redemptionId);
| 13,600
|
10
|
// Allocations : allocationID => Allocation
|
mapping(address => IStakingData.Allocation) public allocations;
|
mapping(address => IStakingData.Allocation) public allocations;
| 12,220
|
1
|
// The base amount of percentage function
|
uint256 public constant PERCENTAGE_BASE = 1 ether;
|
uint256 public constant PERCENTAGE_BASE = 1 ether;
| 8,096
|
50
|
// Tells whether the msg.sender is approved for the given token ID or notThis function is not private so it can be extended in further implementations like the operatable ERC721 _owner address of the owner to query the approval of _tokenId uint256 ID of the token to query the approval ofreturn bool whether the msg.sender is approved for the given token ID or not /
|
function isApprovedFor(address _owner, uint256 _tokenId) internal view returns (bool) {
return approvedFor(_tokenId) == _owner;
}
|
function isApprovedFor(address _owner, uint256 _tokenId) internal view returns (bool) {
return approvedFor(_tokenId) == _owner;
}
| 2,144
|
105
|
// update withdraw address
|
function updateAccountant(address _newAddress) external onlyOwner
|
function updateAccountant(address _newAddress) external onlyOwner
| 17,387
|
119
|
// As opposed to {transferFrom}, this imposes no restrictions on msg.sender. Requirements: - `to` cannot be the zero address.- `tokenId` token must be owned by `from`. Emits a {Transfer} event. /
|
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(
ERC721.ownerOf(tokenId) == from,
"ERC721: transfer of token that is not own"
);
require(to != address(0), "ERC721: transfer to the zero address");
|
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(
ERC721.ownerOf(tokenId) == from,
"ERC721: transfer of token that is not own"
);
require(to != address(0), "ERC721: transfer to the zero address");
| 17,685
|
60
|
// TransfersController contract functions
|
function transfersEnabled() public view returns (bool);
|
function transfersEnabled() public view returns (bool);
| 8,899
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.