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
68
// Internal function returning the ShouldRebalance enum used in shouldRebalance and shouldRebalanceWithBounds external getter functions return ShouldRebalance Enum detailing whether to rebalance, iterateRebalance, ripcord or no action /
function _shouldRebalance( uint256 _currentLeverageRatio, uint256 _minLeverageRatio, uint256 _maxLeverageRatio ) internal view returns(ShouldRebalance)
function _shouldRebalance( uint256 _currentLeverageRatio, uint256 _minLeverageRatio, uint256 _maxLeverageRatio ) internal view returns(ShouldRebalance)
14,765
147
// View function to see pending WAV3s on frontend.
function pendingWav3(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accWav3PerShare = pool.accWav3PerShare; uint256 lpSupply = pool.lpToken.balanceOf(address(this)); ...
function pendingWav3(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accWav3PerShare = pool.accWav3PerShare; uint256 lpSupply = pool.lpToken.balanceOf(address(this)); ...
18,322
281
// Allocate one word for the length, and `tokenIdsMaxLength` words for the data. `shl(5, x)` is equivalent to `mul(32, x)`.
mstore(0x40, add(tokenIds, shl(5, add(tokenIdsLength, 1))))
mstore(0x40, add(tokenIds, shl(5, add(tokenIdsLength, 1))))
34,717
70
// Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} isused, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. Calling conditions: - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to...
function _afterTokenTransfer(
function _afterTokenTransfer(
32,555
92
// tax fee
if(_taxFee != 0){ uint256 taxFee = amount.mul(_taxFee).div(10**(_feeDecimal + 2)); transferAmount = transferAmount.sub(taxFee); _reflectionTotal = _reflectionTotal.sub(taxFee.mul(rate)); _taxFeeTotal = _taxFeeTotal.add(taxFee); }
if(_taxFee != 0){ uint256 taxFee = amount.mul(_taxFee).div(10**(_feeDecimal + 2)); transferAmount = transferAmount.sub(taxFee); _reflectionTotal = _reflectionTotal.sub(taxFee.mul(rate)); _taxFeeTotal = _taxFeeTotal.add(taxFee); }
53,452
73
// Return target(numerator / denominator). /
function getPartial( uint256 target, uint256 numerator, uint256 denominator ) internal pure returns (uint256)
function getPartial( uint256 target, uint256 numerator, uint256 denominator ) internal pure returns (uint256)
6,829
568
// res += val(coefficients[246] + coefficients[247]adjustments[17]).
res := addmod(res, mulmod(val, add(/*coefficients[246]*/ mload(0x2300), mulmod(/*coefficients[247]*/ mload(0x2320),
res := addmod(res, mulmod(val, add(/*coefficients[246]*/ mload(0x2300), mulmod(/*coefficients[247]*/ mload(0x2320),
20,866
30
// Calculate the amount of ETH available for the contract owner/
function _getOwnerEth() internal view returns (uint256) { uint256 liquidityEthFee = _getLiquidityEth(); return ethRaised - liquidityEthFee; }
function _getOwnerEth() internal view returns (uint256) { uint256 liquidityEthFee = _getLiquidityEth(); return ethRaised - liquidityEthFee; }
36,622
62
// Make the atomic self-call - if redeemUnderlying fails on cUSDC, it will succeed but nothing will happen except firing an ExternalError event. If the second part of the self-call (USDC transfer) fails, it will revert and roll back the first part of the call, and we'll fire an ExternalError event after returning from ...
bytes memory returnData; (ok, returnData) = address(this).call(abi.encodeWithSelector( this._withdrawUSDCAtomic.selector, amount, recipient )); if (!ok) {
bytes memory returnData; (ok, returnData) = address(this).call(abi.encodeWithSelector( this._withdrawUSDCAtomic.selector, amount, recipient )); if (!ok) {
26,680
8
// Gets price change in absolute terms.
signedPriceDelta = priceData[i-1].sub(priceData[i]); signedPriceDelta = signedPriceDelta.mul(smallFactor); signedPriceDelta = signedPriceDelta.div(priceData[i-1]); pricedelta = uint256(signedPriceDelta);
signedPriceDelta = priceData[i-1].sub(priceData[i]); signedPriceDelta = signedPriceDelta.mul(smallFactor); signedPriceDelta = signedPriceDelta.div(priceData[i-1]); pricedelta = uint256(signedPriceDelta);
4,739
122
// Pick transfer
if(isContractTransfer || isLiquidityTransfer || isExcluded){ _feelessTransfer(sender, recipient, amount); }
if(isContractTransfer || isLiquidityTransfer || isExcluded){ _feelessTransfer(sender, recipient, amount); }
34,644
12
// When block number more than endReleaseBlock, all locked FORKs can be unlocked
else if (block.number >= endReleaseBlock) { return _locks[_account]; }
else if (block.number >= endReleaseBlock) { return _locks[_account]; }
51,053
95
// Helpers to get Percentages
uint256 sevenOnePct = type(uint16).max / 100 * 71; uint256 eightyPct = type(uint16).max / 100 * 80; uint256 nineFivePct = type(uint16).max / 100 * 95; uint256 nineNinePct = type(uint16).max / 100 * 99; id = uint16(oldSupply + minted++ + 1); ...
uint256 sevenOnePct = type(uint16).max / 100 * 71; uint256 eightyPct = type(uint16).max / 100 * 80; uint256 nineFivePct = type(uint16).max / 100 * 95; uint256 nineNinePct = type(uint16).max / 100 * 99; id = uint16(oldSupply + minted++ + 1); ...
38,257
1,154
// Returns all occupied resources on one node for an Schain. /
function getSchainsPartOfNode(bytes32 schainHash) external view returns (uint8) { return schains[schainHash].partOfNode; }
function getSchainsPartOfNode(bytes32 schainHash) external view returns (uint8) { return schains[schainHash].partOfNode; }
29,199
226
// The addresses of the accounts (or contracts) that can execute actions within each roles.
address public ceoAddress; address public cfoAddress; address public cooAddress;
address public ceoAddress; address public cfoAddress; address public cooAddress;
3,543
139
// TrueGBP This is the top-level ERC20 contract, but most of the interesting functionality isinherited - see the documentation on the corresponding contracts. /
contract TrueGBP is TrueCurrency { uint8 constant DECIMALS = 18; uint8 constant ROUNDING = 2; function decimals() public override pure returns (uint8) { return DECIMALS; } function rounding() public pure returns (uint8) { return ROUNDING; } function name() public override ...
contract TrueGBP is TrueCurrency { uint8 constant DECIMALS = 18; uint8 constant ROUNDING = 2; function decimals() public override pure returns (uint8) { return DECIMALS; } function rounding() public pure returns (uint8) { return ROUNDING; } function name() public override ...
13,775
6
// REWARD ETHER
require(msg.sender.call.value(rewardAmount).gas(36000)());
require(msg.sender.call.value(rewardAmount).gas(36000)());
21,693
16
// ========== RESTRICTED FUNCTIONS ========== /
// function setVenusBridge(address payable newBridge) public payable onlyOwner { // require(newBridge != address(0), "VenusVault: bridge must be non-zero address"); // if (_stakingToken.allowance(address(this), address(newBridge)) == 0) { // _stakingToken.safeApprove(address(...
// function setVenusBridge(address payable newBridge) public payable onlyOwner { // require(newBridge != address(0), "VenusVault: bridge must be non-zero address"); // if (_stakingToken.allowance(address(this), address(newBridge)) == 0) { // _stakingToken.safeApprove(address(...
6,466
165
// Pre-generated keys to save gaskeys are generated with:NORMAL_FOSSIL_RELIC_PERCENTAGE = bytes4(keccak256("normalFossilRelicPercentage"))= 0xcaf6fae2PIONEER_FOSSIL_RELIC_PERCENTAGE= bytes4(keccak256("pioneerFossilRelicPercentage")) = 0x04988c65LEGENDARY_FOSSIL_RELIC_PERCENTAGE= bytes4(keccak256("legendaryFossilRelicPe...
bytes4 internal constant NORMAL_FOSSIL_RELIC_PERCENTAGE = 0xcaf6fae2; bytes4 internal constant PIONEER_FOSSIL_RELIC_PERCENTAGE = 0x04988c65; bytes4 internal constant LEGENDARY_FOSSIL_RELIC_PERCENTAGE = 0x277e613a; bytes4 internal constant FOSSIL_ATTRIBUTE_COUNT = 0x06c475be; bytes4 internal constant LEGENDARY...
bytes4 internal constant NORMAL_FOSSIL_RELIC_PERCENTAGE = 0xcaf6fae2; bytes4 internal constant PIONEER_FOSSIL_RELIC_PERCENTAGE = 0x04988c65; bytes4 internal constant LEGENDARY_FOSSIL_RELIC_PERCENTAGE = 0x277e613a; bytes4 internal constant FOSSIL_ATTRIBUTE_COUNT = 0x06c475be; bytes4 internal constant LEGENDARY...
36,903
9
// no overflow issue. if observationIndex + 1 overflows, result is still zero.
uint8 firstObservationIndex = (observationIndex + 1) % granularity; firstObservation = yieldObservations[firstObservationIndex];
uint8 firstObservationIndex = (observationIndex + 1) % granularity; firstObservation = yieldObservations[firstObservationIndex];
24,157
70
// Returns the percent rate of the balance limit. /
function balanceLimitPercent() public view returns (uint8) { return _balanceLimitRate; }
function balanceLimitPercent() public view returns (uint8) { return _balanceLimitRate; }
18,209
14
// Revoke the blacklist agent role from an account
function revokeBlacklistAgentRole(address account) external onlyOwner { require(account != address(0), "Cannot revoke role from zero address"); blacklistAgents[account] = false; emit RoleRevoked(account, "BLACKLIST_AGENT_ROLE"); }
function revokeBlacklistAgentRole(address account) external onlyOwner { require(account != address(0), "Cannot revoke role from zero address"); blacklistAgents[account] = false; emit RoleRevoked(account, "BLACKLIST_AGENT_ROLE"); }
1,812
9
// Transaction Helpers //Confirms the transfer of `_quantityToInvest` currency to the contract.function _collectInvestment(uint _quantityToInvest,uint _msgValue,bool _refundRemainder) private
// { // if(address(currency) == address(0)) // { // // currency is ETH // if(_refundRemainder) // { // // Math: if _msgValue was not sufficient then revert // uint refund = _msgValue.sub(_quantityToInvest); // if(refund > 0) // { // Address.sendValue(msg.sender...
// { // if(address(currency) == address(0)) // { // // currency is ETH // if(_refundRemainder) // { // // Math: if _msgValue was not sufficient then revert // uint refund = _msgValue.sub(_quantityToInvest); // if(refund > 0) // { // Address.sendValue(msg.sender...
14,872
47
// Collection of functions related to the address type /
library Address { /** *@dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return fal...
library Address { /** *@dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return fal...
42,493
83
// Store seconds in a day (need it in variable to use SafeMath)
uint _secondsPerDay = 86400; uint _tokensToMint = 0; // store number of new tokens to be minted
uint _secondsPerDay = 86400; uint _tokensToMint = 0; // store number of new tokens to be minted
41,331
20
// Function Modifiers/
modifier antiReentrant() { require(unlocked == 1, 'ERROR: Anti-Reentrant'); unlocked = 0; _; unlocked = 1; }
modifier antiReentrant() { require(unlocked == 1, 'ERROR: Anti-Reentrant'); unlocked = 0; _; unlocked = 1; }
35,943
89
// approve token transfer to cover all possible scenarios
_approve(address(this), address(uniswapV2Router), tokenAmount);
_approve(address(this), address(uniswapV2Router), tokenAmount);
8,706
22
// Security and Privilege Control //Modifier for ensuring only the Admin wallet can call a function. /
modifier adminLevel { require(msg.sender == adminWallet); _; }
modifier adminLevel { require(msg.sender == adminWallet); _; }
21,545
25
// the private sale purchasers will claim their tokens using this function
uint256 releasePeriod = 1 days; uint256 releasePercentage = 166; //1.66% is released per day uint256 totalTime = block.timestamp.sub(unLockingDate); // this will give total time totalTime = totalTime.div(releasePeriod); uint256 totalPercentage; if(block.timesta...
uint256 releasePeriod = 1 days; uint256 releasePercentage = 166; //1.66% is released per day uint256 totalTime = block.timestamp.sub(unLockingDate); // this will give total time totalTime = totalTime.div(releasePeriod); uint256 totalPercentage; if(block.timesta...
1,995
87
// Get the message of the code form the trasnfer restriction contract /
function messageForTransferRestriction (uint8 code) external override view returns (string memory) { return restrictedTransfer.messageForTransferRestriction(code); }
function messageForTransferRestriction (uint8 code) external override view returns (string memory) { return restrictedTransfer.messageForTransferRestriction(code); }
80,477
1,133
// This method assumes that positions are mutually exclusive i.e. that the token represents a position in either PoolTokens or Fidu, but not both. /
function transferPosition(uint256 tokenId, address to) public nonReentrant { require(ownerOf(tokenId) == msg.sender, "Cannot transfer position of token you don't own"); FiduPosition storage fiduPosition = fiduPositions[tokenId]; if (fiduPosition.lockedUntil > 0) { require( block.timestamp >...
function transferPosition(uint256 tokenId, address to) public nonReentrant { require(ownerOf(tokenId) == msg.sender, "Cannot transfer position of token you don't own"); FiduPosition storage fiduPosition = fiduPositions[tokenId]; if (fiduPosition.lockedUntil > 0) { require( block.timestamp >...
73,032
1
// EVENTS
event logMintVmcGeneration0(uint256 _tokenId, int16 _x, int16 _y); event logSetVmcPosition(uint256 _tokenId, int16 _x, int16 _y); event logSetVmcNft(uint256 _tokenId, address _displayedNftContractAddress, uint256 _displayedNftTokenId); event logSetVmcUri(uint256 _tokenId, string _tokenUri); event l...
event logMintVmcGeneration0(uint256 _tokenId, int16 _x, int16 _y); event logSetVmcPosition(uint256 _tokenId, int16 _x, int16 _y); event logSetVmcNft(uint256 _tokenId, address _displayedNftContractAddress, uint256 _displayedNftTokenId); event logSetVmcUri(uint256 _tokenId, string _tokenUri); event l...
9,052
6
// Returns an address by idreturn The address /
function getAddress(bytes32 id) public view override returns (address) { return _addresses[id]; }
function getAddress(bytes32 id) public view override returns (address) { return _addresses[id]; }
33,321
14
// swap tokens if required
if (swapQuantity != 0) { pool.swap( address(this), swapQuantity > 0, swapQuantity > 0 ? swapQuantity : -swapQuantity, swapQuantity > 0 ? TickMath.MIN_SQRT_RATIO + 1 : TickMath.MAX_SQRT_RATIO - 1, abi.encode(address(this)...
if (swapQuantity != 0) { pool.swap( address(this), swapQuantity > 0, swapQuantity > 0 ? swapQuantity : -swapQuantity, swapQuantity > 0 ? TickMath.MIN_SQRT_RATIO + 1 : TickMath.MAX_SQRT_RATIO - 1, abi.encode(address(this)...
16,064
81
// Returns whether the strategy is compounding repaying or no yield
function yieldType() public view virtual override returns (YieldType);
function yieldType() public view virtual override returns (YieldType);
338
24
// ParaSwapEcosystemReserve Stores all the PSP kept for incentives, just giving approval to the differentsystems that will pull PSP funds for their specific use case Aave /
contract BicoProtocolEcosystemReserve is VersionedInitializable { event NewFundsAdmin(address indexed fundsAdmin); address internal _fundsAdmin; uint256 public constant REVISION = 1; function getRevision() internal pure override returns (uint256) { return REVISION; } function getFundsAdmin() externa...
contract BicoProtocolEcosystemReserve is VersionedInitializable { event NewFundsAdmin(address indexed fundsAdmin); address internal _fundsAdmin; uint256 public constant REVISION = 1; function getRevision() internal pure override returns (uint256) { return REVISION; } function getFundsAdmin() externa...
55,974
121
// Withdraw any unclaimed eth in the contract.Can only be called if there are no stakers. /
function withdrawUnclaimed() external onlyOwner { require(totalShares == 0, "Stakers"); // send any unclaimed eth to the owner if (address(this).balance > 0) { Address.sendValue(payable(msg.sender), address(this).balance); } }
function withdrawUnclaimed() external onlyOwner { require(totalShares == 0, "Stakers"); // send any unclaimed eth to the owner if (address(this).balance > 0) { Address.sendValue(payable(msg.sender), address(this).balance); } }
65,909
242
// Deposit to this strategy for rewards deadline Number of blocks until transaction expiresreturn Amount of fDAI /
function deposit(uint256 deadline) public payable nonReentrant returns (uint256)
function deposit(uint256 deadline) public payable nonReentrant returns (uint256)
14,485
24
// Internal view function to get the current cToken exchange rate andsupply rate per block. This function is meant to be overridden by thedToken that inherits this contract.return The current cToken exchange rate, or amount of underlying tokensthat are redeemable for each cToken, and the cToken supply rate per block(wi...
function _getCurrentCTokenRates() internal view returns ( uint256 exchangeRate, uint256 supplyRate );
function _getCurrentCTokenRates() internal view returns ( uint256 exchangeRate, uint256 supplyRate );
67,143
233
// Return EpochManager interface.return Epoch manager contract registered with Controller /
function epochManager() internal view returns (IEpochManager) { return IEpochManager(_resolveContract(keccak256("EpochManager"))); }
function epochManager() internal view returns (IEpochManager) { return IEpochManager(_resolveContract(keccak256("EpochManager"))); }
50,189
60
// Mapping for token URIs.
mapping(bytes32 => Doc) internal _documents;
mapping(bytes32 => Doc) internal _documents;
17,654
106
// See {IERC721-setApprovalForAll}. /
function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); }
function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); }
9,663
208
// update the amount of collateral to sell
bids[id].amountToSell = subtract(bids[id].amountToSell, boughtCollateral);
bids[id].amountToSell = subtract(bids[id].amountToSell, boughtCollateral);
19,484
1
// Events//Variables//Public Functions//Sends a cross domain message to the target messenger. _target Target contract address. _message Message to send to the target. _gasLimit Gas limit for the provided message. /
function sendMessage(address _target, bytes calldata _message, uint32 _gasLimit) external;
function sendMessage(address _target, bytes calldata _message, uint32 _gasLimit) external;
13,921
182
// emit an event that the claim was redeemed for ERC20
emit NFTGemERC20ClaimRedeemed( msg.sender, address(this), claimHash, tokenUsed, unlockPaid, unlockTokenPaid, feePortion );
emit NFTGemERC20ClaimRedeemed( msg.sender, address(this), claimHash, tokenUsed, unlockPaid, unlockTokenPaid, feePortion );
70,359
38
// Returns list of transaction IDs in defined range. fromIndex start position of transaction array.toIndex end position of transaction array.pending Include pending transactions.executedInclude executed transactions.return Array of transaction IDs. /
function getTransactionIds( uint256 from, uint256 to, bool pending, bool executed ) public view returns (uint256[] memory)
function getTransactionIds( uint256 from, uint256 to, bool pending, bool executed ) public view returns (uint256[] memory)
76,112
15
// Calculates the staker locked amountreturn Member credit limit /
function getLockedAmount( LockedInfo[] calldata vouchAmountList, address staker, uint256 amount, bool isIncrease ) external pure returns (uint256);
function getLockedAmount( LockedInfo[] calldata vouchAmountList, address staker, uint256 amount, bool isIncrease ) external pure returns (uint256);
17,245
116
// Baby Information _newURI Baby's Information /
function setURI(string memory _newURI) public onlyOwner { _setURI(_newURI); }
function setURI(string memory _newURI) public onlyOwner { _setURI(_newURI); }
38,527
84
// Emitted when the Allocators loss limit is violated. /
event LossLimitViolated(uint128 lastLoss, uint128 dloss, uint256 estimatedTotalAllocated);
event LossLimitViolated(uint128 lastLoss, uint128 dloss, uint256 estimatedTotalAllocated);
46,897
51
// /
bytes4 constant private INTERFACE_SIGNATURE_ERC1155 = 0xd9b67a26;
bytes4 constant private INTERFACE_SIGNATURE_ERC1155 = 0xd9b67a26;
731
70
// Update the allowed payers for this nft contract on SeaDrop.Only the owner can use this function.seaDropImpl The allowed SeaDrop contract. payer The payer to update. allowed Whether the payer is allowed. /
function updatePayer( address seaDropImpl, address payer, bool allowed
function updatePayer( address seaDropImpl, address payer, bool allowed
1,495
35
// Add a new LP to the farm allocPoint reward allocation lpToken ERC20 LP token /
function add(uint256 allocPoint, IERC20 lpToken, uint8 flag) external onlyOwner saveGas(flag) { address tokenAddress = address(lpToken); require(!poolMap[tokenAddress], "pool-already-exists"); require(_isERC20(tokenAddress), "lp-token-not-erc20"); massUpdatePools(); uint256 l...
function add(uint256 allocPoint, IERC20 lpToken, uint8 flag) external onlyOwner saveGas(flag) { address tokenAddress = address(lpToken); require(!poolMap[tokenAddress], "pool-already-exists"); require(_isERC20(tokenAddress), "lp-token-not-erc20"); massUpdatePools(); uint256 l...
15,561
18
// Destroy tokens Remove `_value` tokens from system irreversibly_value amount of money to burn /
function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if sender has enough balanceOf[msg.sender] -= _value; // Subtract from sender totalSupply -= _value; // Updates totalSupply emit Burn(msg...
function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if sender has enough balanceOf[msg.sender] -= _value; // Subtract from sender totalSupply -= _value; // Updates totalSupply emit Burn(msg...
54,994
0
// Hadcoded value of keccak256("hookedTokenManager.tokenManagerHook.tokenManager")
bytes32 private constant TOKEN_MANAGER_POSITION = 0x5c513b2347f66d33af9d68f4a0ed7fbb73ce364889b2af7f3ee5764440da6a8a;
bytes32 private constant TOKEN_MANAGER_POSITION = 0x5c513b2347f66d33af9d68f4a0ed7fbb73ce364889b2af7f3ee5764440da6a8a;
40,136
216
// get price from Oracle
uint256 collateralToEthPrice = getPrice(address(collateral)); uint256 strikeToEthPrice = getPrice(address(strike));
uint256 collateralToEthPrice = getPrice(address(collateral)); uint256 strikeToEthPrice = getPrice(address(strike));
43,485
79
// Helper method to invoke a wallet. _wallet The target wallet. _to The target address for the transaction. _value The value of the transaction. _data The data of the transaction. /
function invokeWallet(address _wallet, address _to, uint256 _value, bytes memory _data) internal returns (bytes memory _res)
function invokeWallet(address _wallet, address _to, uint256 _value, bytes memory _data) internal returns (bytes memory _res)
26,226
41
// allow all users to transfer tokens /
function activeTransfer() onlyOwner public { transferable = true; }
function activeTransfer() onlyOwner public { transferable = true; }
33,094
34
// Calculate amount of token repaid given exact amount of USD input
function calculateRepayExactIn(address token, uint inExact) public view returns (uint) { address[] memory _path = new address[](2); _path[0] = token; _path[1] = address(STABLE); return UNI.getAmountsOut(inExact, _path)[1]; }
function calculateRepayExactIn(address token, uint inExact) public view returns (uint) { address[] memory _path = new address[](2); _path[0] = token; _path[1] = address(STABLE); return UNI.getAmountsOut(inExact, _path)[1]; }
53,666
4
// maxExpArray[0] = 0x6bffffffffffffffffffffffffffffffff;maxExpArray[1] = 0x67ffffffffffffffffffffffffffffffff;maxExpArray[2] = 0x637fffffffffffffffffffffffffffffff;maxExpArray[3] = 0x5f6fffffffffffffffffffffffffffffff;maxExpArray[4] = 0x5b77ffffffffffffffffffffffffffffff;maxExpArray[5] = 0x57b3ffffffffffffffffffffffff...
maxExpArray[ 32] = 0x1c35fedd14ffffffffffffffffffffffff; maxExpArray[ 33] = 0x1b0ce43b323fffffffffffffffffffffff; maxExpArray[ 34] = 0x19f0028ec1ffffffffffffffffffffffff; maxExpArray[ 35] = 0x18ded91f0e7fffffffffffffffffffffff; maxExpArray[ 36] = 0x17d8ec7f0417fffffffffffffffffff...
maxExpArray[ 32] = 0x1c35fedd14ffffffffffffffffffffffff; maxExpArray[ 33] = 0x1b0ce43b323fffffffffffffffffffffff; maxExpArray[ 34] = 0x19f0028ec1ffffffffffffffffffffffff; maxExpArray[ 35] = 0x18ded91f0e7fffffffffffffffffffffff; maxExpArray[ 36] = 0x17d8ec7f0417fffffffffffffffffff...
43,580
366
// Return the number of tokens an address has minted account Address to return the number of tokens minted for /
function numberMinted(address account) external view returns (uint256) {
function numberMinted(address account) external view returns (uint256) {
27,453
19
// Check is not needed because sub(_allowance, _value) will already revert if this condition is not met
require(_value <= _allowance, "transfer more then allowed"); balances[_to] = balances[_to].add(_value); balances[_from] = balances[_from].sub(_value); allowed[_from][msg.sender] = _allowance.sub(_value); emit Transfer(_from, _to, _value); return true;
require(_value <= _allowance, "transfer more then allowed"); balances[_to] = balances[_to].add(_value); balances[_from] = balances[_from].sub(_value); allowed[_from][msg.sender] = _allowance.sub(_value); emit Transfer(_from, _to, _value); return true;
1,197
1
// setting deadline to avoid scenario where miners hang onto it and execute at a more profitable time
deadline = block.timestamp + 300; // 5 minutes
deadline = block.timestamp + 300; // 5 minutes
3,889
496
// Invests all the underlying into the pool that mints crops (CRV)/
function investAllUnderlying() public restricted { uint256 underlyingBalance = IERC20(underlying).balanceOf(address(this)); if (underlyingBalance > 0) { IERC20(underlying).safeApprove(pool, 0); IERC20(underlying).safeApprove(pool, underlyingBalance); Gauge(pool).deposit(underlyingBalance); ...
function investAllUnderlying() public restricted { uint256 underlyingBalance = IERC20(underlying).balanceOf(address(this)); if (underlyingBalance > 0) { IERC20(underlying).safeApprove(pool, 0); IERC20(underlying).safeApprove(pool, underlyingBalance); Gauge(pool).deposit(underlyingBalance); ...
9,717
90
// Mapping if bridge is Frozen
bool public isFrozen;
bool public isFrozen;
53,950
31
// unlock deposit
traderBalanceVault.unlockAsset( ITraderBalanceVault.UnlockAssetParams( _order.trader, _order.trader, _order.depositAsset, _order.depositAmount ) );
traderBalanceVault.unlockAsset( ITraderBalanceVault.UnlockAssetParams( _order.trader, _order.trader, _order.depositAsset, _order.depositAmount ) );
20,565
1
// ========== STATE VARIABLES ========== / Instances and addresses
IFrax public FRAX = IFrax(0x853d955aCEf822Db058eb8505911ED77F175b99e); IFxs public FXS = IFxs(0x3432B6A60D23Ca0dFCa7761B7ab56459D9C964D0); ERC20 public collateral_token; IFraxAMOMinter public amo_minter;
IFrax public FRAX = IFrax(0x853d955aCEf822Db058eb8505911ED77F175b99e); IFxs public FXS = IFxs(0x3432B6A60D23Ca0dFCa7761B7ab56459D9C964D0); ERC20 public collateral_token; IFraxAMOMinter public amo_minter;
36,593
108
// Sets the reference to the sale auction./_address - Address of sale contract.
function setSaleAuctionAddress(address _address) public onlyCEO { SaleClockAuctionInterface candidateContract = SaleClockAuctionInterface(_address); // NOTE: verify that a contract is what we expect - https://github.com/Lunyr/crowdsale-contracts/blob/cfadd15986c30521d8ba7d5b6f57b4fefcc7ac38/contrac...
function setSaleAuctionAddress(address _address) public onlyCEO { SaleClockAuctionInterface candidateContract = SaleClockAuctionInterface(_address); // NOTE: verify that a contract is what we expect - https://github.com/Lunyr/crowdsale-contracts/blob/cfadd15986c30521d8ba7d5b6f57b4fefcc7ac38/contrac...
64,993
3
// if transfer restrictions are applied, we guess that should also be the case for newly minted tokens if the admin disagrees, it is still possible to change the type of the null address
if (transferRestrictionsApplicable){ setTypeInternal(address(0x0), TYPE_POWERLISTED); } else {
if (transferRestrictionsApplicable){ setTypeInternal(address(0x0), TYPE_POWERLISTED); } else {
33,413
25
// 함수를 호출한 '나'의 토큰 잔고가 보내는 토큰의 개수보다 크거나 같을때 실행.
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[msg.sender] = balances[msg.sender].sub(_value);
16,920
4
// rented number of blocks, to count time
uint256 rentedBlocks;
uint256 rentedBlocks;
45,161
11
// Calculates the total quantity of NFTs in a given list of Cart structs. carts An array of Cart struct representing the tiers and quantities.return The total quantity of NFTs in the given list of carts. /
function calculateTotalQuantity(
function calculateTotalQuantity(
22,845
55
// remove a trusted currencyContract _oldTrustedContractAddress The address of the currencyContract /
function adminRemoveTrustedCurrencyContract(address _oldTrustedContractAddress) external onlyOwner
function adminRemoveTrustedCurrencyContract(address _oldTrustedContractAddress) external onlyOwner
41,681
13
// The timestamp when the `nextOption` can be used by the vault
uint256 public nextOptionReadyAt;
uint256 public nextOptionReadyAt;
9,767
69
// blacklist contract & burn addr from lottery
isBlacklistedFromLottery[address(this)] = true; isBlacklistedFromLottery[_burnAddress] = true; emit Transfer(address(0), address(this), _totalSupply);
isBlacklistedFromLottery[address(this)] = true; isBlacklistedFromLottery[_burnAddress] = true; emit Transfer(address(0), address(this), _totalSupply);
22,491
26
// get specific infos about a account which is defined in this contract
function getAccountInfo(uint256 index) public view returns( uint256 _tokenBalance, uint256 _tokenEntitled, uint256 _shares, uint256 _percentage,
function getAccountInfo(uint256 index) public view returns( uint256 _tokenBalance, uint256 _tokenEntitled, uint256 _shares, uint256 _percentage,
20,416
0
// Variables//Allows oracle provider to push the vlue for the corresponding _id_id is thestandardizedADO data type/value pair Id_value is the value/
function setValue(bytes32 _id, int256 _value) external{ valuesByID[_id][block.timestamp] = _value; timestampsByID[_id].push(block.timestamp); }
function setValue(bytes32 _id, int256 _value) external{ valuesByID[_id][block.timestamp] = _value; timestampsByID[_id].push(block.timestamp); }
914
507
// return The difference in tokens between the target investmentand the currently invested amount (i.e. the amount that can be invested) /
function maxInvestableBalance(bytes32 poolId) external view returns (int256);
function maxInvestableBalance(bytes32 poolId) external view returns (int256);
43,163
277
// USD Cent value of 1 ether
uint256 public ethusd; uint256 ethusdLast;
uint256 public ethusd; uint256 ethusdLast;
1,649
215
// 0% collateral-backed
function mint(uint256 shareAmount, uint256 minimumReceived) external notLocked nonReentrant { require(globalCollateralRatio == 0, "mint-not-allowed"); (uint256 mintAmount, uint256 mintFeeAmount) = calculateShareMintAmount(shareAmount); require(minimumReceived <= mintAmount, "slippage-limit-r...
function mint(uint256 shareAmount, uint256 minimumReceived) external notLocked nonReentrant { require(globalCollateralRatio == 0, "mint-not-allowed"); (uint256 mintAmount, uint256 mintFeeAmount) = calculateShareMintAmount(shareAmount); require(minimumReceived <= mintAmount, "slippage-limit-r...
23,262
113
// use to updateParamL. Must only be called by _updateDueInterestsParamL can be thought of as an always-increase incomeIndex for 1 LPTheoretically we have to updateParamL whenever the _updateDueInterests is called, since the external incomeIndexYet, if we do so, the amount of interests to be claimed maybe negligible wh...
function _updateParamL() internal { if (!checkNeedUpdateParamL()) return; // redeem the interest from XYT router.redeemDueInterests(forgeId, underlyingAsset, expiry, address(this)); uint256 currentNYield = underlyingYieldToken.balanceOf(address(this)); (uint256 firstTerm, ui...
function _updateParamL() internal { if (!checkNeedUpdateParamL()) return; // redeem the interest from XYT router.redeemDueInterests(forgeId, underlyingAsset, expiry, address(this)); uint256 currentNYield = underlyingYieldToken.balanceOf(address(this)); (uint256 firstTerm, ui...
39,701
0
// unlockTime => amount that will be unlocked at unlockTime
mapping(uint256 => uint256) public scheduledUnlock; mapping(uint256 => uint256) public scheduledWeightedUnlock;
mapping(uint256 => uint256) public scheduledUnlock; mapping(uint256 => uint256) public scheduledWeightedUnlock;
44,218
239
// ==========================================/ Purchase tokens with Ether. 1% for dividend card holders is taken off before anything else
if (regularPhase) { toDivCardHolders = _incomingEthereum.div(100); remainingEth = remainingEth.sub(toDivCardHolders); }
if (regularPhase) { toDivCardHolders = _incomingEthereum.div(100); remainingEth = remainingEth.sub(toDivCardHolders); }
76,583
162
// Checks if the `RelayHub` will accept a relayed operation.Multiple things must be true for this to happen: - all arguments must be signed for by the sender (`from`) - the sender's nonce must be the current one - the recipient must accept this transaction (via {acceptRelayedCall}) Returns a `PreconditionCheck` value (...
function canRelay( address relay, address from, address to, bytes calldata encodedFunction, uint256 transactionFee, uint256 gasPrice, uint256 gasLimit, uint256 nonce,
function canRelay( address relay, address from, address to, bytes calldata encodedFunction, uint256 transactionFee, uint256 gasPrice, uint256 gasLimit, uint256 nonce,
5,455
73
// we want less than what we can get, we ask for the exact amount now we can remove the liquidity
uint256[4] memory tokenAmounts = wrapCoinAmount(wantLimit); IERC20(swusd).safeApprove(curve, 0); IERC20(swusd).safeApprove(curve, swusdBalance); ISwerveFi(curve).remove_liquidity_imbalance(tokenAmounts, swusdBalance);
uint256[4] memory tokenAmounts = wrapCoinAmount(wantLimit); IERC20(swusd).safeApprove(curve, 0); IERC20(swusd).safeApprove(curve, swusdBalance); ISwerveFi(curve).remove_liquidity_imbalance(tokenAmounts, swusdBalance);
35,308
5
// CommonBEP20 Implementation of the CommonBEP20 /
contract CommonBEP20 is BEP20Capped, BEP20Mintable, BEP20Burnable, ServicePayer { constructor ( string memory name, string memory symbol, uint8 decimals, uint256 cap, uint256 initialBalance, address payable feeReceiver ) BEP20(name, symbol) BEP20C...
contract CommonBEP20 is BEP20Capped, BEP20Mintable, BEP20Burnable, ServicePayer { constructor ( string memory name, string memory symbol, uint8 decimals, uint256 cap, uint256 initialBalance, address payable feeReceiver ) BEP20(name, symbol) BEP20C...
15,719
0
// Store the master.
master = msg.sender; version = 5; motd = ""; credit = "to 63e190e32fcae9ffcca380cead85247495cc53ffa32669d2d298ff0b0dbce524 for creating the contract"; lock = false;
master = msg.sender; version = 5; motd = ""; credit = "to 63e190e32fcae9ffcca380cead85247495cc53ffa32669d2d298ff0b0dbce524 for creating the contract"; lock = false;
53,951
289
// Gets a price of the asset/_ilk Ilk of the CDP
function getPrice(bytes32 _ilk) public view returns (uint) { (, uint mat) = spotter.ilks(_ilk); (,,uint spot,,) = vat.ilks(_ilk); return rmul(rmul(spot, spotter.par()), mat); }
function getPrice(bytes32 _ilk) public view returns (uint) { (, uint mat) = spotter.ilks(_ilk); (,,uint spot,,) = vat.ilks(_ilk); return rmul(rmul(spot, spotter.par()), mat); }
14,073
199
// Send reward to Multisig
for(uint x = 0; x < length; x++){ _handleRewardTransfer(tokens[x], IERC20Upgradeable(tokens[x]).balanceOf(address(this)).sub(beforeBalance[x])); }
for(uint x = 0; x < length; x++){ _handleRewardTransfer(tokens[x], IERC20Upgradeable(tokens[x]).balanceOf(address(this)).sub(beforeBalance[x])); }
12,741
19
// send the token...
require(Erc20(token).transfer(o, a), 'transfer failed.'); emit Claim(i, o, a); return true;
require(Erc20(token).transfer(o, a), 'transfer failed.'); emit Claim(i, o, a); return true;
30,940
34
// make sure that the signer and signature are corespondent
if (_signer != _voucher.tokenOwner) revert SignatureInvalid();
if (_signer != _voucher.tokenOwner) revert SignatureInvalid();
44,609
56
// Internal method to respond to the addition of new asset / aTokens We need to approve the aToken and give it permission to spend the asset _asset Address of the asset to approve _aToken This aToken has the approval approval /
function _abstractSetPToken(address _asset, address _aToken) internal { address lendingPoolVault = _getLendingPoolCore(); IERC20(_asset).safeApprove(lendingPoolVault, 0); IERC20(_asset).safeApprove(lendingPoolVault, uint256(-1)); }
function _abstractSetPToken(address _asset, address _aToken) internal { address lendingPoolVault = _getLendingPoolCore(); IERC20(_asset).safeApprove(lendingPoolVault, 0); IERC20(_asset).safeApprove(lendingPoolVault, uint256(-1)); }
46,897
91
// Returns amount of audits completed at each level for `auditorAdderss_`/auditorAddress_Address of auditor/ return levelsCompleted_Array of levels of audits completed for `auditorAddress_`
function levelsCompleted(address auditorAddress_) external view returns (uint256[4] memory levelsCompleted_) { return (_levelsCompleted[auditorAddress_]); }
function levelsCompleted(address auditorAddress_) external view returns (uint256[4] memory levelsCompleted_) { return (_levelsCompleted[auditorAddress_]); }
35,648
26
// 喂价 /
function feed() public { pce = IFeeder(fer).get(); //抵押物价格(val): 1 USD //最小抵押率(ove): 150% //兑换比(exr): val/ove = 1/1.5, 表示1.5个抵押物才兑换1个Qian, 或者说1个抵押物大约能兑换 0.6666666666666666... 个 Qian //乘以PRE(10 ** 18)是防止0.6666...被抹成0 exr = (pce * PRE * PRE9) / ove; //[10^27] e...
function feed() public { pce = IFeeder(fer).get(); //抵押物价格(val): 1 USD //最小抵押率(ove): 150% //兑换比(exr): val/ove = 1/1.5, 表示1.5个抵押物才兑换1个Qian, 或者说1个抵押物大约能兑换 0.6666666666666666... 个 Qian //乘以PRE(10 ** 18)是防止0.6666...被抹成0 exr = (pce * PRE * PRE9) / ove; //[10^27] e...
30,121
25
// compute epoch id from block.timestamp and epochStart date
function _getEpochId() internal view returns (uint128 epochId) { if (block.timestamp < epochStart) { return 0; } epochId = uint128(block.timestamp.sub(epochStart).div(epochDuration).add(1)); }
function _getEpochId() internal view returns (uint128 epochId) { if (block.timestamp < epochStart) { return 0; } epochId = uint128(block.timestamp.sub(epochStart).div(epochDuration).add(1)); }
22,239
272
// This should actually take users address as parameter to check total LP tokens locked.return uint256 the Reward Multiplier for KittieFightToken, amplified 1000000 times to avoid float imprecisionreturn uint256 the Reward Multiplier for SuperDaoFightToken, amplified 1000000 times to avoid float imprecision /
function getRewardMultipliers(address _staker) external view returns (uint256, uint256) { uint256 totalLPs = getTotalLPsLocked(_staker); if (totalLPs == 0) { return (0, 0); } uint256 totalRewards = yieldFarming.totalRewardsKTY(); (uint256 rewardsKTY, uint256 rewar...
function getRewardMultipliers(address _staker) external view returns (uint256, uint256) { uint256 totalLPs = getTotalLPsLocked(_staker); if (totalLPs == 0) { return (0, 0); } uint256 totalRewards = yieldFarming.totalRewardsKTY(); (uint256 rewardsKTY, uint256 rewar...
44,226
8
// Defining function modifier 'onlySeller'
modifier onlySeller(uint256 orderId) { require( msg.sender == escrowOrders[orderId].seller || msg.sender == arbiter, "Only the seller or arbiter can call this function" ); _; }
modifier onlySeller(uint256 orderId) { require( msg.sender == escrowOrders[orderId].seller || msg.sender == arbiter, "Only the seller or arbiter can call this function" ); _; }
19,898
64
// Close and destroy the loan
_palLoan.closeLoan(_totalFees);
_palLoan.closeLoan(_totalFees);
21,325
11
// bonds mature with a cliff at a set timestampprior to the expiry timestamp, no payout tokens are accessible to the userafter the expiry timestamp, the entire payout can be redeemed there are two types of bonds: fixed-term and fixed-expiration fixed-term bonds mature in a set amount of time from depositi.e. term = 1 w...
expiry_ = term.fixedTerm ? term.vesting + currentTime : term.vesting;
expiry_ = term.fixedTerm ? term.vesting + currentTime : term.vesting;
54,947
12
// Hash an order, returning the canonical order hash, without the message prefix order Order to hashreturn hash Hash of order /
function hashOrder(Order memory order) internal pure returns (bytes32 hash)
function hashOrder(Order memory order) internal pure returns (bytes32 hash)
7,058
28
// CALLER
OpCodes[51].Ins = 0; OpCodes[51].Outs = 1; OpCodes[51].Gas = 2;
OpCodes[51].Ins = 0; OpCodes[51].Outs = 1; OpCodes[51].Gas = 2;
3,038