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
|
|---|---|---|---|---|
69
|
// External View functions // Return lock duration. /
|
function getLockDurations() external view returns (uint256[] memory) {
return _lockPeriod;
}
|
function getLockDurations() external view returns (uint256[] memory) {
return _lockPeriod;
}
| 28,906
|
32
|
// Public functions //Allows to change the number of required confirmations/approvals. Transaction has to be sent by the contract./_requiredApprovals Number of required approvals.
|
function changeRequirement(uint _requiredApprovals)
public
onlyContract
validRequirement(operators.length, _requiredApprovals)
|
function changeRequirement(uint _requiredApprovals)
public
onlyContract
validRequirement(operators.length, _requiredApprovals)
| 4,606
|
72
|
// Internal function to set allowance owner_Token owner's address spender Spender's address value Allowance amount /
|
function _approve(
address owner_,
address spender,
uint256 value
|
function _approve(
address owner_,
address spender,
uint256 value
| 54,984
|
136
|
// Initialize call makes token pausable & gives pauserRole to governance
|
ERC20Pausable.initialize(governance);
|
ERC20Pausable.initialize(governance);
| 66,891
|
22
|
// withdrawEth when minimum cap is reached
|
function withdrawEth() onlyOwner{
require(this.balance != 0);
require(ethRaised >= minCap);
multisigAddress.transfer(this.balance);
}
|
function withdrawEth() onlyOwner{
require(this.balance != 0);
require(ethRaised >= minCap);
multisigAddress.transfer(this.balance);
}
| 40,737
|
28
|
// Check if STC token are available to transfer
|
require(availableSTCTokens() > safeAdd(_tokens,_tokenBonus));
|
require(availableSTCTokens() > safeAdd(_tokens,_tokenBonus));
| 32,419
|
129
|
// Ultimate instantiation of a Nifty Gateway NFT collection./
|
constructor() ERC721() {
_creator = "Six N. Five";
_dateTimeContract = 0x740a637ADD6492e5FaA907AF0fe708770B737058; //Mainnet
|
constructor() ERC721() {
_creator = "Six N. Five";
_dateTimeContract = 0x740a637ADD6492e5FaA907AF0fe708770B737058; //Mainnet
| 2,913
|
62
|
// Anyone can create a DApp (i.e an arb piece of data this contract happens to care about). _id bytes32 unique identifier. _amount of tokens to stake on initial ranking. _metadata metadata hex string /
|
function createDApp(bytes32 _id, uint _amount, bytes32 _metadata) external {
_createDApp(
msg.sender,
_id,
_amount,
_metadata);
}
|
function createDApp(bytes32 _id, uint _amount, bytes32 _metadata) external {
_createDApp(
msg.sender,
_id,
_amount,
_metadata);
}
| 28,166
|
18
|
// Frozen balance portion, in percents
|
uint portionPercent;
|
uint portionPercent;
| 18,324
|
36
|
// number of contributors
|
uint256 len=contributors.length;
|
uint256 len=contributors.length;
| 51,890
|
7
|
// cash out the holders position
|
uint amountToTransfer=quantity[msg.sender]*virtualGoldPrice; //calculate the amount to transfer
total-=quantity[msg.sender]; //update total
quantity[msg.sender]=0; //reset quantity to zero as he/she is no longer a holder
msg.sender.transfer(amountToTransfer); //transfer ethereum to holders address
return true;
|
uint amountToTransfer=quantity[msg.sender]*virtualGoldPrice; //calculate the amount to transfer
total-=quantity[msg.sender]; //update total
quantity[msg.sender]=0; //reset quantity to zero as he/she is no longer a holder
msg.sender.transfer(amountToTransfer); //transfer ethereum to holders address
return true;
| 41,282
|
17
|
// CONSTRUCTOR
|
function DADetails (string _daId, uint _dateLodged, string _description, string _lga, uint _estimatedCost) public {
applicant = msg.sender;
daid = _daId;
dateLodged = _dateLodged;
description = _description;
lga = _lga;
estimatedCost = _estimatedCost;
changeState(ContractStates.DALodged);
}
|
function DADetails (string _daId, uint _dateLodged, string _description, string _lga, uint _estimatedCost) public {
applicant = msg.sender;
daid = _daId;
dateLodged = _dateLodged;
description = _description;
lga = _lga;
estimatedCost = _estimatedCost;
changeState(ContractStates.DALodged);
}
| 12,995
|
1
|
// the send() method which sends a bytes payload to a another chain
|
function send(uint16 _chainId, bytes calldata _destination, bytes calldata _payload, address payable refundAddress, address _zroPaymentAddress, bytes calldata txParameters ) external payable;
|
function send(uint16 _chainId, bytes calldata _destination, bytes calldata _payload, address payable refundAddress, address _zroPaymentAddress, bytes calldata txParameters ) external payable;
| 13,035
|
4
|
// Token name and symbol used in ERC721A constructor
|
string internal constant NAME = "The First Friend";
string internal constant SYMBOL = "FFF";
|
string internal constant NAME = "The First Friend";
string internal constant SYMBOL = "FFF";
| 42,403
|
18
|
// View the capital requirements needed to buy up until `_sherAmountWant`/Will adjust to remaining SHER if `_sherAmountWant` exceeds that/ return sherAmount Will adjust to remining SHER if `_sherAmountWant` exceeds that/ return stake How much USDC needs to be staked for `PERIOD` of time to buy `sherAmount` SHER/ return price How much USDC needs to be paid to buy `sherAmount` SHER
|
function viewCapitalRequirements(uint256 _sherAmountWant)
public
view
returns (
uint256 sherAmount,
uint256 stake,
uint256 price
)
|
function viewCapitalRequirements(uint256 _sherAmountWant)
public
view
returns (
uint256 sherAmount,
uint256 stake,
uint256 price
)
| 58,264
|
21
|
// tokens that don't have return data
|
if (returndata.length == 0) {
return true;
}
|
if (returndata.length == 0) {
return true;
}
| 54,460
|
188
|
// deposit eth and get weth
|
if (msg.sender == owner) {
TokenInterface(WETH_ADDRESS).deposit{value: (address(this).balance)}();
|
if (msg.sender == owner) {
TokenInterface(WETH_ADDRESS).deposit{value: (address(this).balance)}();
| 495
|
444
|
// Free up space once all collateral is withdrawn by removing the liquidation object from the array.
|
if (
liquidation.disputer == address(0) &&
liquidation.sponsor == address(0) &&
liquidation.liquidator == address(0)
) {
delete liquidations[sponsor][liquidationId];
}
|
if (
liquidation.disputer == address(0) &&
liquidation.sponsor == address(0) &&
liquidation.liquidator == address(0)
) {
delete liquidations[sponsor][liquidationId];
}
| 30,893
|
6
|
// https:docs.synthetix.io/contracts/source/interfaces/ibinaryoptionmarketmanager
|
interface IBinaryOptionMarketManager {
/* ========== VIEWS / VARIABLES ========== */
function fees()
external
view
returns (
uint poolFee,
uint creatorFee,
uint refundFee
);
function durations()
external
view
returns (
uint maxOraclePriceAge,
uint expiryDuration,
uint maxTimeToMaturity
);
function creatorLimits() external view returns (uint capitalRequirement, uint skewLimit);
function marketCreationEnabled() external view returns (bool);
function totalDeposited() external view returns (uint);
function numActiveMarkets() external view returns (uint);
function activeMarkets(uint index, uint pageSize) external view returns (address[] memory);
function numMaturedMarkets() external view returns (uint);
function maturedMarkets(uint index, uint pageSize) external view returns (address[] memory);
/* ========== MUTATIVE FUNCTIONS ========== */
function createMarket(
bytes32 oracleKey,
uint strikePrice,
bool refundsEnabled,
uint[2] calldata times, // [biddingEnd, maturity]
uint[2] calldata bids // [longBid, shortBid]
) external returns (IBinaryOptionMarket);
function resolveMarket(address market) external;
function cancelMarket(address market) external;
function expireMarkets(address[] calldata market) external;
}
|
interface IBinaryOptionMarketManager {
/* ========== VIEWS / VARIABLES ========== */
function fees()
external
view
returns (
uint poolFee,
uint creatorFee,
uint refundFee
);
function durations()
external
view
returns (
uint maxOraclePriceAge,
uint expiryDuration,
uint maxTimeToMaturity
);
function creatorLimits() external view returns (uint capitalRequirement, uint skewLimit);
function marketCreationEnabled() external view returns (bool);
function totalDeposited() external view returns (uint);
function numActiveMarkets() external view returns (uint);
function activeMarkets(uint index, uint pageSize) external view returns (address[] memory);
function numMaturedMarkets() external view returns (uint);
function maturedMarkets(uint index, uint pageSize) external view returns (address[] memory);
/* ========== MUTATIVE FUNCTIONS ========== */
function createMarket(
bytes32 oracleKey,
uint strikePrice,
bool refundsEnabled,
uint[2] calldata times, // [biddingEnd, maturity]
uint[2] calldata bids // [longBid, shortBid]
) external returns (IBinaryOptionMarket);
function resolveMarket(address market) external;
function cancelMarket(address market) external;
function expireMarkets(address[] calldata market) external;
}
| 30,079
|
5
|
// Public variables of the token // This creates an array with all balances // This generates a public event on the blockchain that will notify clients // Initializes contract with initial supply tokens to the creator of the contract /
|
) {
if(centralMinter != 0 ) owner = msg.sender;
balanceOf[msg.sender] = initialSupply; // Give the creator all initial tokens
totalSupply = initialSupply; // Update total supply
name = tokenName; // Set the name for display purposes
symbol = tokenSymbol; // Set the symbol for display purposes
decimals = decimalUnits; // Amount of decimals for display purposes
}
|
) {
if(centralMinter != 0 ) owner = msg.sender;
balanceOf[msg.sender] = initialSupply; // Give the creator all initial tokens
totalSupply = initialSupply; // Update total supply
name = tokenName; // Set the name for display purposes
symbol = tokenSymbol; // Set the symbol for display purposes
decimals = decimalUnits; // Amount of decimals for display purposes
}
| 71,784
|
112
|
// Query if a contract implements an interface _interfaceIDThe interface identifier, as specified in ERC-165return `true` if the contract implements `_interfaceID` and /
|
function supportsInterface(bytes4 _interfaceID)
external
view
returns (bool)
|
function supportsInterface(bytes4 _interfaceID)
external
view
returns (bool)
| 19,208
|
463
|
// What's the total value of the system excluding ETH backed synths in their requested currency?
|
(uint snxBackedAmount, , bool debtInfoStale) = allNetworksDebtInfo();
if (debtShareBalance == 0) {
return (0, snxBackedAmount, debtInfoStale);
}
|
(uint snxBackedAmount, , bool debtInfoStale) = allNetworksDebtInfo();
if (debtShareBalance == 0) {
return (0, snxBackedAmount, debtInfoStale);
}
| 24,683
|
136
|
// mint and distribute ALPA to callerNOTE: caller must be approved consumer /
|
function distribute(uint256 _since) external returns (uint256);
|
function distribute(uint256 _since) external returns (uint256);
| 23,997
|
259
|
// Set max pool share for a cube token. Expressed in basis points.A value of 0 means no limit. This protects users from buying cube tokenswith limited upside, as well as protecting the whole pool from thevolatility of a single asset. /
|
function setMaxPoolShare(CubeToken cubeToken, uint256 maxPoolShare) external onlyGovernance {
require(params[cubeToken].added, "Not added");
require(maxPoolShare < 1e4, "Max pool share should be < 100%");
params[cubeToken].maxPoolShare = maxPoolShare;
}
|
function setMaxPoolShare(CubeToken cubeToken, uint256 maxPoolShare) external onlyGovernance {
require(params[cubeToken].added, "Not added");
require(maxPoolShare < 1e4, "Max pool share should be < 100%");
params[cubeToken].maxPoolShare = maxPoolShare;
}
| 59,877
|
4
|
// reconcile payments
|
owner.transfer(costOfToken);
msg.sender.transfer(msg.value - costOfToken);
|
owner.transfer(costOfToken);
msg.sender.transfer(msg.value - costOfToken);
| 37,099
|
1
|
// Magic value of a smart contract that can receive NFT.Equal to: bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")). /
|
bytes4 internal constant MAGIC_ON_ERC721_RECEIVED = 0x150b7a02;
|
bytes4 internal constant MAGIC_ON_ERC721_RECEIVED = 0x150b7a02;
| 23,662
|
8
|
// Before migration hook. It will be called during migration Transfer Maker vault ownership to new strategy _newStrategy Address of new strategy. /
|
function _beforeMigration(address _newStrategy) internal virtual override {
require(MakerStrategy(_newStrategy).collateralType() == collateralType, "collateral-type-must-be-the-same");
cm.transferVaultOwnership(_newStrategy);
}
|
function _beforeMigration(address _newStrategy) internal virtual override {
require(MakerStrategy(_newStrategy).collateralType() == collateralType, "collateral-type-must-be-the-same");
cm.transferVaultOwnership(_newStrategy);
}
| 31,932
|
10
|
// The percent of each trade's implied yield to collect as LP fee
|
uint256 public immutable percentFee;
|
uint256 public immutable percentFee;
| 71,184
|
40
|
// Add presale liquidity to UniswapV2Pair
|
(, , uint256 liquidity) = IUniswapV2Router02(_UNISWAPV2ROUTER)
|
(, , uint256 liquidity) = IUniswapV2Router02(_UNISWAPV2ROUTER)
| 22,114
|
4
|
// Emitted when a collateral factor is changed by admin
|
event NewCollateralFactor(CToken cToken, uint oldCollateralFactorMantissa, uint newCollateralFactorMantissa);
|
event NewCollateralFactor(CToken cToken, uint oldCollateralFactorMantissa, uint newCollateralFactorMantissa);
| 12,328
|
123
|
// maxDayForMonthField returns the maximum valid day given the month field month the month fieldreturn the max day /
|
function maxDayForMonthField(Field memory month) private pure returns (uint8) {
// DEV: ranges are always safe because any two consecutive months will always
// contain a month with 31 days
if (month.fieldType == FieldType.WILD || month.fieldType == FieldType.RANGE) {
return 31;
} else if (month.fieldType == FieldType.EXACT) {
// DEV: assume leap year in order to get max value
return DateTime.getDaysInMonth(month.singleValue, 4);
} else if (month.fieldType == FieldType.INTERVAL) {
if (month.interval == 9 || month.interval == 11) {
return 30;
} else {
return 31;
}
} else if (month.fieldType == FieldType.LIST) {
uint8 result;
for (uint256 idx = 0; idx < month.listLength; idx++) {
// DEV: assume leap year in order to get max value
uint8 daysInMonth = DateTime.getDaysInMonth(month.list[idx], 4);
if (daysInMonth == 31) {
return daysInMonth;
}
if (daysInMonth > result) {
result = daysInMonth;
}
}
return result;
} else {
revert UnknownFieldType();
}
}
|
function maxDayForMonthField(Field memory month) private pure returns (uint8) {
// DEV: ranges are always safe because any two consecutive months will always
// contain a month with 31 days
if (month.fieldType == FieldType.WILD || month.fieldType == FieldType.RANGE) {
return 31;
} else if (month.fieldType == FieldType.EXACT) {
// DEV: assume leap year in order to get max value
return DateTime.getDaysInMonth(month.singleValue, 4);
} else if (month.fieldType == FieldType.INTERVAL) {
if (month.interval == 9 || month.interval == 11) {
return 30;
} else {
return 31;
}
} else if (month.fieldType == FieldType.LIST) {
uint8 result;
for (uint256 idx = 0; idx < month.listLength; idx++) {
// DEV: assume leap year in order to get max value
uint8 daysInMonth = DateTime.getDaysInMonth(month.list[idx], 4);
if (daysInMonth == 31) {
return daysInMonth;
}
if (daysInMonth > result) {
result = daysInMonth;
}
}
return result;
} else {
revert UnknownFieldType();
}
}
| 28,918
|
17
|
// given an output amount of an asset and pair reserves, returns a required input amount of the other asset
|
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {
require(amountOut > 0, 'PancakeLibrary: INSUFFICIENT_OUTPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'PancakeLibrary: INSUFFICIENT_LIQUIDITY');
uint numerator = reserveIn.mul(amountOut).mul(10000);
uint denominator = reserveOut.sub(amountOut).mul(9975);
amountIn = (numerator / denominator).add(1);
}
|
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {
require(amountOut > 0, 'PancakeLibrary: INSUFFICIENT_OUTPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'PancakeLibrary: INSUFFICIENT_LIQUIDITY');
uint numerator = reserveIn.mul(amountOut).mul(10000);
uint denominator = reserveOut.sub(amountOut).mul(9975);
amountIn = (numerator / denominator).add(1);
}
| 18,971
|
0
|
// ERC223InterfaceERC223 Contract Interface/
|
contract ERC20Interface {
function transfer(address _to, uint256 _value) public returns (bool);
function balanceOf(address who)public view returns (uint);
}
|
contract ERC20Interface {
function transfer(address _to, uint256 _value) public returns (bool);
function balanceOf(address who)public view returns (uint);
}
| 49,390
|
175
|
// minimum amount of funds to be raised in weis
|
uint256 public goal;
|
uint256 public goal;
| 3,361
|
2
|
// Mapping of makerAddress => senderAddress => lowest salt an order can have in order to be fillable/Orders with specified senderAddress and with a salt less than their epoch are considered cancelled/0 Address of the order's maker./1 Address of the order's sender./ return 0 Minimum valid order epoch.
|
mapping (address => mapping (address => uint256)) public orderEpoch;
|
mapping (address => mapping (address => uint256)) public orderEpoch;
| 41,018
|
8
|
// Initialize the number of votes for an accountaddr The address to initialize.balance The number of votes./
|
function initNbVotes(address addr, uint256 balance) internal {
Voter memory voter = votingObjects[votingObjects.length-1].voters[addr];
if(!voter.isNbVotesInitialized) {
Voter storage _voter = votingObjects[votingObjects.length-1].voters[addr];
_voter.isNbVotesInitialized = true;
_voter.nbVotes = balance;
}
}
|
function initNbVotes(address addr, uint256 balance) internal {
Voter memory voter = votingObjects[votingObjects.length-1].voters[addr];
if(!voter.isNbVotesInitialized) {
Voter storage _voter = votingObjects[votingObjects.length-1].voters[addr];
_voter.isNbVotesInitialized = true;
_voter.nbVotes = balance;
}
}
| 50,692
|
4
|
// ==================== Mutative Functions ==================== // Add an exchange provider to the list of providers. exchangeProvider The address of the exchange provider to add.return index The index of the newly added specified exchange provider. /
|
function addExchangeProvider(address exchangeProvider) public onlyOwner returns (uint256 index) {
require(!isExchangeProvider[exchangeProvider], "ExchangeProvider already exists in the list");
require(exchangeProvider != address(0), "ExchangeProvider address can't be 0");
exchangeProviders.push(exchangeProvider);
isExchangeProvider[exchangeProvider] = true;
emit ExchangeProviderAdded(exchangeProvider);
index = exchangeProviders.length - 1;
}
|
function addExchangeProvider(address exchangeProvider) public onlyOwner returns (uint256 index) {
require(!isExchangeProvider[exchangeProvider], "ExchangeProvider already exists in the list");
require(exchangeProvider != address(0), "ExchangeProvider address can't be 0");
exchangeProviders.push(exchangeProvider);
isExchangeProvider[exchangeProvider] = true;
emit ExchangeProviderAdded(exchangeProvider);
index = exchangeProviders.length - 1;
}
| 25,985
|
189
|
// govToken -> user_address -> user_index eg. usersGovTokensIndexes[govTokens[0]][msg.sender] = 1111123;
|
mapping (address => mapping (address => uint256)) public usersGovTokensIndexes;
|
mapping (address => mapping (address => uint256)) public usersGovTokensIndexes;
| 15,758
|
11
|
// Add a new compute option. unitCost The unit cost of the compute option. unitMinutes The expected number of minutes per compute unit.return index The added compute option id. Only callable by owner. /
|
function addComputeOption(uint256 unitCost, uint256 unitMinutes)
external
virtual
onlyOwner
returns (uint256 index)
|
function addComputeOption(uint256 unitCost, uint256 unitMinutes)
external
virtual
onlyOwner
returns (uint256 index)
| 16,367
|
26
|
// Transfer sync, updateColors, transfer sync back to sender
|
for (uint256 i = 0; i < tokenIds.length; i++) {
IERC721Enumerable(SYNCXCOLORS).transferFrom(
msg.sender,
address(this),
tokenIds[i]
);
ISYNC(SYNCXCOLORS).updateColors{value: 0.005 ether}(
|
for (uint256 i = 0; i < tokenIds.length; i++) {
IERC721Enumerable(SYNCXCOLORS).transferFrom(
msg.sender,
address(this),
tokenIds[i]
);
ISYNC(SYNCXCOLORS).updateColors{value: 0.005 ether}(
| 78,616
|
11
|
// Remove oneself from the voter role.
|
function renounceVoter() public virtual {
renounceMembership(VOTER_ROLE_ID);
}
|
function renounceVoter() public virtual {
renounceMembership(VOTER_ROLE_ID);
}
| 6,027
|
114
|
// Internal function to set the token URI for a given token. Reverts if the token ID does not exist.tokenId uint256 ID of the token to set its URIuri string URI to assign/
|
function _setTokenURI(uint256 tokenId, string memory uri) internal {
require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token");
_tokenURIs[tokenId] = uri;
}
|
function _setTokenURI(uint256 tokenId, string memory uri) internal {
require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token");
_tokenURIs[tokenId] = uri;
}
| 5,662
|
51
|
// Withdraws funds from contract
|
function withdraw() public onlyOwner {
uint256 balance = address(this).balance;
(bool success, ) = treasury.call{value: balance}("");
require(success, "Unable to withdraw ETH");
}
|
function withdraw() public onlyOwner {
uint256 balance = address(this).balance;
(bool success, ) = treasury.call{value: balance}("");
require(success, "Unable to withdraw ETH");
}
| 14,450
|
33
|
// NOTE: This is a modified version that allows only for a stream of up to 12 random numbers to save the PRNG initialization gas cost. Instead of generating and using the full feedback register with 607 numbers, we pre-generate and use two slices of 12 numbers that are read at first by the original implementation.
|
uint16 constant RNG_LEN = 607;
uint16 constant RNG_TAP = 273;
uint64 constant RNG_MASK = uint64(type(int64).max);
int32 constant int32max = type(int32).max;
uint8 constant RNG_COUNT = 12;
|
uint16 constant RNG_LEN = 607;
uint16 constant RNG_TAP = 273;
uint64 constant RNG_MASK = uint64(type(int64).max);
int32 constant int32max = type(int32).max;
uint8 constant RNG_COUNT = 12;
| 6,576
|
2
|
// Valuations Data.
|
struct Valuations {
string valuationsData;
}
|
struct Valuations {
string valuationsData;
}
| 6,039
|
1
|
// safe guards
|
require(!paused, "Campaign is not live"); // campaign is on-going
if (msg.sender != owner()) { //only request payment to non-whitelisted users
if(whitelisted[msg.sender] != true) {
require(msg.value >= cost, "You are not sending enough ETH");
}
|
require(!paused, "Campaign is not live"); // campaign is on-going
if (msg.sender != owner()) { //only request payment to non-whitelisted users
if(whitelisted[msg.sender] != true) {
require(msg.value >= cost, "You are not sending enough ETH");
}
| 66,693
|
18
|
// emits when token is transferred/erc1155
|
event TransferSingle(
address indexed _operator,
address indexed _from,
address indexed _to,
uint256 _id,
uint256 _value
);
|
event TransferSingle(
address indexed _operator,
address indexed _from,
address indexed _to,
uint256 _id,
uint256 _value
);
| 10,559
|
97
|
// for token to token dest address is network. and Ether / token already here...
|
if (dest == ETH_TOKEN_ADDRESS) {
destAddress.transfer(expectedDestAmount);
} else {
|
if (dest == ETH_TOKEN_ADDRESS) {
destAddress.transfer(expectedDestAmount);
} else {
| 24,013
|
249
|
// amount of wPowerPerp minted from the vault
|
uint128 shortAmount;
|
uint128 shortAmount;
| 3,862
|
281
|
// The token being staked in this pool
|
IERC20 public stakedToken;
|
IERC20 public stakedToken;
| 58,832
|
17
|
// Mint Ornaments to sender. /
|
function mint() external payable {
require(saleActive, "Sale not active.");
require(totalSupply() < maxTokens, "Maximum supply reached.");
require(msg.value >= price, "Not enough Ether sent.");
_mint(msg.sender, _currentId);
emit OrnamentCreated(_currentId++);
}
|
function mint() external payable {
require(saleActive, "Sale not active.");
require(totalSupply() < maxTokens, "Maximum supply reached.");
require(msg.value >= price, "Not enough Ether sent.");
_mint(msg.sender, _currentId);
emit OrnamentCreated(_currentId++);
}
| 21,807
|
8
|
// Archangel
|
function getFountain(address) external returns (address) {
return fountainAddress;
}
|
function getFountain(address) external returns (address) {
return fountainAddress;
}
| 19,341
|
39
|
// Next round
|
incentiveDistributionDate = now + incentiveDistributionInterval;
incentiveDistributionRound++;
|
incentiveDistributionDate = now + incentiveDistributionInterval;
incentiveDistributionRound++;
| 10,697
|
149
|
// Get the unifiedPoint of token's decimal (for fixed decimal number)return the unifiedPoint of token's decimal // default: UnifiedTokenDecimal Function /
|
{
return unifiedTokenDecimal;
}
|
{
return unifiedTokenDecimal;
}
| 20,682
|
32
|
// Adds cash, expects actual ERC20 underlyingToken got transferred in. Can only be called by Pool. amount amount to add /
|
function addCash(uint256 amount) external onlyPool {
_cash += amount;
emit CashAdded(this.cash() - amount, amount);
}
|
function addCash(uint256 amount) external onlyPool {
_cash += amount;
emit CashAdded(this.cash() - amount, amount);
}
| 36,266
|
10
|
// Compute a target basket range for trading -{BU}
|
BasketRange memory range = basketRange(ctx, reg);
|
BasketRange memory range = basketRange(ctx, reg);
| 40,217
|
20
|
// Allows another account to spend a given amount of tokens on behalf of the sender&39;s account. _spender The address of the spenders account. _amount The amount of tokens the spender is allowed to spend./
|
function approve(address _spender, uint256 _amount) public returns (bool) {
allowances[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
return true;
}
|
function approve(address _spender, uint256 _amount) public returns (bool) {
allowances[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
return true;
}
| 49,392
|
75
|
// singleToken -> minePool
|
mapping(address => address[]) public _SINGLE_REGISTRY_;
|
mapping(address => address[]) public _SINGLE_REGISTRY_;
| 42,416
|
39
|
// snapshot from reserve balance at epoch close
|
uint public epochReserve;
|
uint public epochReserve;
| 8,355
|
104
|
// require(bytes(_name).length > 0 && bytes(_symbol).length > 0);validate input
|
token = GACToken(tokenAddress);
tokensPerUSD = 10 * 10 ** 18;
valueToBeSent = token.valueToBeSent();
pricingstrategy = PricingStrategy(strategy);
|
token = GACToken(tokenAddress);
tokensPerUSD = 10 * 10 ** 18;
valueToBeSent = token.valueToBeSent();
pricingstrategy = PricingStrategy(strategy);
| 26,268
|
45
|
// UI helper fx - Returns signers from offset as [signer id (index in allSigners), address as uint, isActive 0 or 1]
|
function getAllSigners(uint offset) external view returns(uint[3][CHUNK_SIZE] signersResult) {
for (uint8 i = 0; i < CHUNK_SIZE && i + offset < allSigners.length; i++) {
address signerAddress = allSigners[i + offset];
signersResult[i] = [ i + offset, uint(signerAddress), isSigner[signerAddress] ? 1 : 0 ];
}
}
|
function getAllSigners(uint offset) external view returns(uint[3][CHUNK_SIZE] signersResult) {
for (uint8 i = 0; i < CHUNK_SIZE && i + offset < allSigners.length; i++) {
address signerAddress = allSigners[i + offset];
signersResult[i] = [ i + offset, uint(signerAddress), isSigner[signerAddress] ? 1 : 0 ];
}
}
| 14,491
|
87
|
// request from hot wallet
|
if (isHotWallet(_userAddress)) {
addGoldTransaction(_userId, int(tokens));
}
|
if (isHotWallet(_userAddress)) {
addGoldTransaction(_userId, int(tokens));
}
| 22,587
|
16
|
// cap so uint doesnt overflow in split calculations. can sweep by "attaching" a push payment spigot with same token
|
if (claimed > MAX_REVENUE) claimed = MAX_REVENUE;
return claimed;
|
if (claimed > MAX_REVENUE) claimed = MAX_REVENUE;
return claimed;
| 15,679
|
63
|
// Removes a value from a set. O(1). Returns true if the key was removed from the map, that is if it was present. /
|
function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) {
return _remove(map._inner, bytes32(key));
}
|
function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) {
return _remove(map._inner, bytes32(key));
}
| 30,432
|
0
|
// Diamond Loupe Functions/ These functions are expected to be called frequently by tools.
|
// struct Facet {
// address facetAddress;
// bytes4[] functionSelectors;
// }
|
// struct Facet {
// address facetAddress;
// bytes4[] functionSelectors;
// }
| 5,829
|
1
|
// Sctruct which describes registry metainformation with balance state and status/Registry name stringRegistry contract addressRegistry creator addressRegistry version stringRegistry ABI link stringRegistry creation timestamp uintRegistry admin address /
|
struct RegistryMeta {
/* string name;
string symbol; */
address contractAddress;
address creator;
string version;
string linkABI;
uint registrationTimestamp;
/* address admin; */
uint256 currentRegistryBalanceETH;
uint256 accumulatedRegistryETH;
}
|
struct RegistryMeta {
/* string name;
string symbol; */
address contractAddress;
address creator;
string version;
string linkABI;
uint registrationTimestamp;
/* address admin; */
uint256 currentRegistryBalanceETH;
uint256 accumulatedRegistryETH;
}
| 54,221
|
11
|
// tell treasury to update its balance for this policy
|
_getTreasury().incPolicyBalance(netPremium);
|
_getTreasury().incPolicyBalance(netPremium);
| 9,812
|
161
|
// Update deamortized balance
|
deamortizedTokenABalance = deamortizedTokenABalance.sub(
originalBalanceAToReduce.mul(10**FIMP_DECIMALS).div(userFImp)
);
deamortizedTokenBBalance = deamortizedTokenBBalance.sub(
originalBalanceBToReduce.mul(10**FIMP_DECIMALS).div(userFImp)
);
|
deamortizedTokenABalance = deamortizedTokenABalance.sub(
originalBalanceAToReduce.mul(10**FIMP_DECIMALS).div(userFImp)
);
deamortizedTokenBBalance = deamortizedTokenBBalance.sub(
originalBalanceBToReduce.mul(10**FIMP_DECIMALS).div(userFImp)
);
| 64,128
|
42
|
// Transfers the ownership of an NFT from one address to another address This works identically to the other function with an extra data parameter, except this function just sets data to "" _from The current owner of the NFT _to The new owner _tokenId The NFT to transfer/
|
function safeTransferFrom(
address _from,
address _to,
uint256 _tokenId
)
external
whenNotPaused
|
function safeTransferFrom(
address _from,
address _to,
uint256 _tokenId
)
external
whenNotPaused
| 35,208
|
74
|
// If no other charity wallet will be set, the initial one is excluded from fees
|
_isCharity[_CharityWallet] = true;
|
_isCharity[_CharityWallet] = true;
| 55,942
|
611
|
// Resets the internal counter to newIndex
|
function resetCounter(uint256 newIndex) external onlyRole(OPERATOR_ROLE) {
_passCounter.reset();
for (uint256 i = 0; i < newIndex; i++) {
_passCounter.increment();
}
}
|
function resetCounter(uint256 newIndex) external onlyRole(OPERATOR_ROLE) {
_passCounter.reset();
for (uint256 i = 0; i < newIndex; i++) {
_passCounter.increment();
}
}
| 45,826
|
340
|
// Utility library of inline functions on addresses This contract is copied here and renamed from the original to avoid clashes in the compiled artifactswhen the user imports a zos-lib contract (that transitively causes this contract to be compiled and added to thebuild/artifacts folder) as well as the vanilla Address implementation from an openzeppelin version. /
|
library OpenZeppelinUpgradesAddress {
/**
* Returns whether the target address is a contract
* @dev This function will return false if invoked during the constructor of a contract,
* as the code is not actually created until after the constructor finishes.
* @param account address of the account to check
* @return whether the target address is a contract
*/
function isContract(address account) internal view returns (bool) {
uint256 size;
// XXX Currently there is no better way to check if there is a contract in an address
// than to check the size of the code at that address.
// See https://ethereum.stackexchange.com/a/14016/36603
// for more details about how this works.
// TODO Check this again before the Serenity release, because all addresses will be
// contracts then.
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
}
|
library OpenZeppelinUpgradesAddress {
/**
* Returns whether the target address is a contract
* @dev This function will return false if invoked during the constructor of a contract,
* as the code is not actually created until after the constructor finishes.
* @param account address of the account to check
* @return whether the target address is a contract
*/
function isContract(address account) internal view returns (bool) {
uint256 size;
// XXX Currently there is no better way to check if there is a contract in an address
// than to check the size of the code at that address.
// See https://ethereum.stackexchange.com/a/14016/36603
// for more details about how this works.
// TODO Check this again before the Serenity release, because all addresses will be
// contracts then.
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
}
| 8,034
|
8
|
// In this level we convert data into bytesand do bitwise operations /
|
contract Test_Bits_Bytes_3 is Koans {
function test_integers_convert_to_bytes() public {
int integer = 123456789;
Assert.equal(bytes32(integer), bytes32(0x75BCD15), "should convert integer to bytes32");
}
// You can declare bytes of sizes: bytes1, bytes2, bytes32 (but NOT bytes)
function test_shrinking_and_converting_bytes_corrupts_data() public {
bytes32 a = bytes32(MAX_UINT);
bytes3 b = bytes3(MAX_UINT);
Assert.isBelow(uint(b), uint(a), "should not be equal after resizing");
}
// You can do bitwise operations
function test_bitwise_operator_AND() public {
bytes2 data = 0xffff;
bytes2 mask = 0xf0f0;
bytes2 and_masked = data & mask;
bytes2 or_masked = data | mask;
Assert.equal(and_masked, bytes2(0xf0f0), "should equal the bitwise of (integer AND mask)");
Assert.equal(or_masked, bytes2(0xffff), "should equal the bitwise of (integer OR mask)");
}
// Likewise, you can do bitwise operations on ints
function test_bitwise_operator_XOR() public {
uint integer = 42; // or 101010 bitwise
uint actual = integer ^ 56;
Assert.equal(actual, uint(18), "should equal the bitwise of (integer XOR mask)");
}
// You can shift bits with bytes variables
function test_left_shift_operand() public {
bytes4 a = 0xffffffff;
bytes4 actual = a << 2;
Assert.equal(actual, bytes4(0x3FFFFFFFC), "should equal 0xffffffff shifted left by 2 bits");
}
// Likewise, you can shift bits with integers
function test_right_shift_operand() public {
uint a = 555555;
uint actual = a >> 5;
Assert.equal(actual, uint(17361), "should correctly shift a right by 5 bits");
}
// "bytes" is a special variable type.
// "bytes" is an array of single bytes, similar to "string" and "byte[]"
// bytes hello_world = "hello world";
bytes hello_world = "hello world";
function test_bytes_are_like_strings() public {
uint string_length = hello_world.length;
bytes1 first_byte = hello_world[0];
bytes1 last_byte = hello_world[string_length-1];
Assert.equal(string_length, uint(11), "should be the byte length of the hello world string");
Assert.equal(first_byte, 'h', "should be the UTF-8 of the first byte");
Assert.equal(last_byte, 'd', "should be the UTF-8 of the last byte");
}
}
|
contract Test_Bits_Bytes_3 is Koans {
function test_integers_convert_to_bytes() public {
int integer = 123456789;
Assert.equal(bytes32(integer), bytes32(0x75BCD15), "should convert integer to bytes32");
}
// You can declare bytes of sizes: bytes1, bytes2, bytes32 (but NOT bytes)
function test_shrinking_and_converting_bytes_corrupts_data() public {
bytes32 a = bytes32(MAX_UINT);
bytes3 b = bytes3(MAX_UINT);
Assert.isBelow(uint(b), uint(a), "should not be equal after resizing");
}
// You can do bitwise operations
function test_bitwise_operator_AND() public {
bytes2 data = 0xffff;
bytes2 mask = 0xf0f0;
bytes2 and_masked = data & mask;
bytes2 or_masked = data | mask;
Assert.equal(and_masked, bytes2(0xf0f0), "should equal the bitwise of (integer AND mask)");
Assert.equal(or_masked, bytes2(0xffff), "should equal the bitwise of (integer OR mask)");
}
// Likewise, you can do bitwise operations on ints
function test_bitwise_operator_XOR() public {
uint integer = 42; // or 101010 bitwise
uint actual = integer ^ 56;
Assert.equal(actual, uint(18), "should equal the bitwise of (integer XOR mask)");
}
// You can shift bits with bytes variables
function test_left_shift_operand() public {
bytes4 a = 0xffffffff;
bytes4 actual = a << 2;
Assert.equal(actual, bytes4(0x3FFFFFFFC), "should equal 0xffffffff shifted left by 2 bits");
}
// Likewise, you can shift bits with integers
function test_right_shift_operand() public {
uint a = 555555;
uint actual = a >> 5;
Assert.equal(actual, uint(17361), "should correctly shift a right by 5 bits");
}
// "bytes" is a special variable type.
// "bytes" is an array of single bytes, similar to "string" and "byte[]"
// bytes hello_world = "hello world";
bytes hello_world = "hello world";
function test_bytes_are_like_strings() public {
uint string_length = hello_world.length;
bytes1 first_byte = hello_world[0];
bytes1 last_byte = hello_world[string_length-1];
Assert.equal(string_length, uint(11), "should be the byte length of the hello world string");
Assert.equal(first_byte, 'h', "should be the UTF-8 of the first byte");
Assert.equal(last_byte, 'd', "should be the UTF-8 of the last byte");
}
}
| 19,657
|
87
|
// Adjustment polynomial for constraints 'ecdsa/signature0/exponentiate_generator/booleanity_test', 'ecdsa/signature0/exponentiate_generator/add_points/slope', 'ecdsa/signature0/exponentiate_generator/add_points/x', 'ecdsa/signature0/exponentiate_generator/add_points/y', 'ecdsa/signature0/exponentiate_generator/add_points/x_diff_inv', 'ecdsa/signature0/exponentiate_generator/copy_point/x', 'ecdsa/signature0/exponentiate_generator/copy_point/y'. adjustments[17] = point^degreeAdjustment(composition_degree_bound, 2(trace_length - 1), trace_length / 8192, trace_length / 32).
|
mstore(0x5a20,
expmod(point, degreeAdjustment(/*composition_degree_bound*/ mload(0x4980), mul(2, sub(/*trace_length*/ mload(0x80), 1)), div(/*trace_length*/ mload(0x80), 8192), div(/*trace_length*/ mload(0x80), 32)), PRIME))
|
mstore(0x5a20,
expmod(point, degreeAdjustment(/*composition_degree_bound*/ mload(0x4980), mul(2, sub(/*trace_length*/ mload(0x80), 1)), div(/*trace_length*/ mload(0x80), 8192), div(/*trace_length*/ mload(0x80), 32)), PRIME))
| 17,446
|
43
|
// Emits a {Transfer} event with `from` set to the zero address. Requirements: - `account` cannot be the zero address.- the caller must have minter role. /
|
function mint(address account, uint256 amountIn) public onlyRole(MINTER_ROLE) {
|
function mint(address account, uint256 amountIn) public onlyRole(MINTER_ROLE) {
| 30,809
|
186
|
// NFT params
|
string public baseURI;
string public defaultURI;
string public mycontractURI;
bool public finalizeBaseUri = false;
|
string public baseURI;
string public defaultURI;
string public mycontractURI;
bool public finalizeBaseUri = false;
| 15,474
|
184
|
// Provide an accurate estimate for the total amount of assets (principle + return) that this Strategy is currently managing, denominated in terms of `want` tokens.This total should be "realizable" e.g. the total value that could actually be obtained from this Strategy if it were to divest its entire position based on current on-chain conditions. Care must be taken in using this function, since it relies on external systems, which could be manipulated by the attacker to give an inflated (or reduced) value produced by this function, based on current on-chain conditions (e.g. this function is possible to influence through flashloan
|
function estimatedTotalAssets() public view virtual returns (uint256);
|
function estimatedTotalAssets() public view virtual returns (uint256);
| 53,212
|
44
|
// 15 IN DATA / SET DATA / GET DATA / STRING / PUBLIC / ONLY OWNER / CONSTANT
|
string inLLV_edit_15 = " une première phrase " ;
|
string inLLV_edit_15 = " une première phrase " ;
| 4,831
|
4
|
// Dev address.
|
address public devAddress;
|
address public devAddress;
| 6,499
|
4
|
// : create a monsterModifies: allMonster arraycan not create monster when game is paused /
|
function create_monster() public override {
// uint seed = random.get_random(monster_maximum_attack);
uint256 attack = get_random(monster_maximum_attack);
uint256 monster_health = get_random(monster_maximum_health);
allMonsters.push(
Monster(
attack,
monster_health,
string(
abi.encodePacked(
"monster",
Strings.toString(monsterCounter)
)
)
)
);
monsterCounter++;
}
|
function create_monster() public override {
// uint seed = random.get_random(monster_maximum_attack);
uint256 attack = get_random(monster_maximum_attack);
uint256 monster_health = get_random(monster_maximum_health);
allMonsters.push(
Monster(
attack,
monster_health,
string(
abi.encodePacked(
"monster",
Strings.toString(monsterCounter)
)
)
)
);
monsterCounter++;
}
| 3,005
|
24
|
// Returns the installment amount to be paid at the called timestamp. Return type is of uint256. _loanId The Id of the loan.return uint256 of the installment amount to be paid. /
|
function viewInstallmentAmount(
uint256 _loanId
|
function viewInstallmentAmount(
uint256 _loanId
| 23,122
|
15
|
// Handout excess assets above what is needed, including any newly minted RToken
|
RevenueTotals memory totals = main.distributor().totals();
for (uint256 i = 0; i < erc20s.length; i++) {
IAsset asset = main.assetRegistry().toAsset(erc20s[i]);
uint192 bal = asset.bal(address(this)); // {tok}
|
RevenueTotals memory totals = main.distributor().totals();
for (uint256 i = 0; i < erc20s.length; i++) {
IAsset asset = main.assetRegistry().toAsset(erc20s[i]);
uint192 bal = asset.bal(address(this)); // {tok}
| 42,959
|
51
|
// input of strings to write / string memory proof,
|
) external {
// check for user to be goal initiator
require(
goalIdToGoal[_goalId].info.user == msg.sender,
"not goal creator"
);
// update proof
goalIdToGoal[_goalId].proof = proof;
}
|
) external {
// check for user to be goal initiator
require(
goalIdToGoal[_goalId].info.user == msg.sender,
"not goal creator"
);
// update proof
goalIdToGoal[_goalId].proof = proof;
}
| 26,464
|
7
|
// FRAX
|
address private constant frax_address = 0x853d955aCEf822Db058eb8505911ED77F175b99e;
|
address private constant frax_address = 0x853d955aCEf822Db058eb8505911ED77F175b99e;
| 51,986
|
16
|
// For querying totalSupply of token.
|
function totalSupply() public view returns (uint256 _totalSupply);
|
function totalSupply() public view returns (uint256 _totalSupply);
| 25,339
|
337
|
// Add distributed coll and debt rewards-per-unit-staked to the running totals. Division uses a "feedback" error correction, to keep the cumulative error low in the running totals L_ETH and L_RUBCDebt: 1) Form numerators which compensate for the floor division errors that occurred the last time this function was called. 2) Calculate "per-unit-staked" ratios. 3) Multiply each ratio back by its denominator, to reveal the current floor division error. 4) Store these errors for use in the next correction when this function is called. 5) Note: static analysis tools complain about this "division before multiplication", however, it is intended./
|
uint ETHNumerator = _coll.mul(DECIMAL_PRECISION).add(lastETHError_Redistribution);
uint RUBCDebtNumerator = _debt.mul(DECIMAL_PRECISION).add(lastRUBCDebtError_Redistribution);
|
uint ETHNumerator = _coll.mul(DECIMAL_PRECISION).add(lastETHError_Redistribution);
uint RUBCDebtNumerator = _debt.mul(DECIMAL_PRECISION).add(lastRUBCDebtError_Redistribution);
| 28,129
|
22
|
// set a new sequencer inbox contract _sequencerInbox new address of sequencer inbox /
|
function setSequencerInbox(address _sequencerInbox) external;
|
function setSequencerInbox(address _sequencerInbox) external;
| 33,785
|
186
|
// Check whether the parameters of a sale are valid saleKind Kind of sale expirationTime Order expiration timereturn Whether the parameters were valid /
|
function validateParameters(SaleKind saleKind, uint expirationTime)
|
function validateParameters(SaleKind saleKind, uint expirationTime)
| 41,978
|
47
|
// send the change back if any
|
uint256 change = (msg.value - mintPrice);
if (change > 0) {
(bool changeSent, ) = _msgSender().call{value: change}("");
|
uint256 change = (msg.value - mintPrice);
if (change > 0) {
(bool changeSent, ) = _msgSender().call{value: change}("");
| 2,915
|
50
|
// If someone sends ETH to the contract address, assume that they are trying to buy tokens.
|
function () payable external
|
function () payable external
| 30,418
|
139
|
// set Withdrawed to zero
|
Withdrawed[sender] = 0;
|
Withdrawed[sender] = 0;
| 5,887
|
2
|
// @inheritdoc IPeripheryPayments
|
function unwrapWETH9(uint256 amountMinimum, address recipient) public payable virtual override {
uint256 balanceWETH9 = IWETH9(WETH9).balanceOf(address(this));
// IWETH -> Insufficient WETH9
require(balanceWETH9 >= amountMinimum, 'IWETH');
if (balanceWETH9 > 0) {
IWETH9(WETH9).withdraw(balanceWETH9);
TransferHelper.safeTransferETH(recipient, balanceWETH9);
}
}
|
function unwrapWETH9(uint256 amountMinimum, address recipient) public payable virtual override {
uint256 balanceWETH9 = IWETH9(WETH9).balanceOf(address(this));
// IWETH -> Insufficient WETH9
require(balanceWETH9 >= amountMinimum, 'IWETH');
if (balanceWETH9 > 0) {
IWETH9(WETH9).withdraw(balanceWETH9);
TransferHelper.safeTransferETH(recipient, balanceWETH9);
}
}
| 31,430
|
50
|
// First 10 mil. have bonus
|
if (phase.soldTokens < 10000000000000000000000000) {
return amount.mul(40).div(100);
}
|
if (phase.soldTokens < 10000000000000000000000000) {
return amount.mul(40).div(100);
}
| 12,855
|
31
|
// Deposit tokens adding them to contract balance. /
|
function deposit(uint256 amount) external {
require(amount > 0, 'Vault: deposit amount must be greater than 0');
address sender = msg.sender;
uint256 mintAmount;
uint256 inputTokenDecimals = tokenInfo[address(inputToken)].tokenDecimals;
uint256 scaledAmount = amount * 10**(18 - inputTokenDecimals);
uint256 totalSupply = totalSupply();
uint256 vaultTotalValue_ = vaultTotalScaledValue();
if (_maxCapDeposit > 0) {
require(
vaultTotalValue_ + scaledAmount <=
_maxCapDeposit * 10**(18 - inputTokenDecimals),
'Vault: deposit exceed vault maximum capacity'
);
}
if (totalSupply == 0) {
mintAmount = scaledAmount;
} else {
mintAmount = calculateMintAmount(
scaledAmount,
totalSupply,
vaultTotalValue_
);
}
inputToken.safeTransferFrom(sender, address(this), amount);
_mint(sender, mintAmount);
emit Deposited(sender, amount);
}
|
function deposit(uint256 amount) external {
require(amount > 0, 'Vault: deposit amount must be greater than 0');
address sender = msg.sender;
uint256 mintAmount;
uint256 inputTokenDecimals = tokenInfo[address(inputToken)].tokenDecimals;
uint256 scaledAmount = amount * 10**(18 - inputTokenDecimals);
uint256 totalSupply = totalSupply();
uint256 vaultTotalValue_ = vaultTotalScaledValue();
if (_maxCapDeposit > 0) {
require(
vaultTotalValue_ + scaledAmount <=
_maxCapDeposit * 10**(18 - inputTokenDecimals),
'Vault: deposit exceed vault maximum capacity'
);
}
if (totalSupply == 0) {
mintAmount = scaledAmount;
} else {
mintAmount = calculateMintAmount(
scaledAmount,
totalSupply,
vaultTotalValue_
);
}
inputToken.safeTransferFrom(sender, address(this), amount);
_mint(sender, mintAmount);
emit Deposited(sender, amount);
}
| 31,346
|
61
|
// Address of roller
|
address roller;
|
address roller;
| 9,169
|
305
|
// sorry limited to 32 characters
|
require (_length <= 32 && _length > 0, "string must be between 1 and 32 characters");
|
require (_length <= 32 && _length > 0, "string must be between 1 and 32 characters");
| 7,896
|
14
|
// Set inital contract values
|
owner = msg.sender;
storageFactory = _storageFactory;
|
owner = msg.sender;
storageFactory = _storageFactory;
| 16,789
|
27
|
// withdraw everything from the strategy to accurately check the share value
|
if (numberOfShares == totalSupply) {
IStrategy(strategy()).withdrawAllToVault();
} else {
|
if (numberOfShares == totalSupply) {
IStrategy(strategy()).withdrawAllToVault();
} else {
| 67,174
|
5
|
// Transfers ownership of a _node to a new address. May only be called by the current _owner of the _node. _node The _node to transfer ownership of. _owner The address of the new _owner. /
|
function setOwner(bytes32 _node, address _owner) public override authorised(_node) {
_setOwner(_node, _owner);
emit Transfer(_node, _owner);
}
|
function setOwner(bytes32 _node, address _owner) public override authorised(_node) {
_setOwner(_node, _owner);
emit Transfer(_node, _owner);
}
| 10,407
|
136
|
// amount of tokens 1 TRU is worth
|
function truToToken(uint256 truAmount) external view returns (uint256);
|
function truToToken(uint256 truAmount) external view returns (uint256);
| 7,437
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.