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
|
|---|---|---|---|---|
36
|
// The value is stored at length-1, but we add 1 to all indexes and use 0 as a sentinel value
|
set._indexes[value] = set._values.length;
return true;
|
set._indexes[value] = set._values.length;
return true;
| 2,656
|
146
|
// 获取账户信息
|
function getAccountState(address account)
external
view
returns (
uint256,
uint256,
uint256
)
|
function getAccountState(address account)
external
view
returns (
uint256,
uint256,
uint256
)
| 40,119
|
16
|
// Событие старта игры Хомяков
|
event StartHamsterGame();
|
event StartHamsterGame();
| 79,316
|
34
|
// Year
|
timestamp += (year - ORIGIN_YEAR) * 1 years;
timestamp += (leapYearsBefore(year) - leapYearsBefore(ORIGIN_YEAR)) * 1 days;
|
timestamp += (year - ORIGIN_YEAR) * 1 years;
timestamp += (leapYearsBefore(year) - leapYearsBefore(ORIGIN_YEAR)) * 1 days;
| 39,114
|
88
|
// 比率轉換-白金幣換白金
|
function convert2Platinum(uint256 _amount) constant returns (uint256) {
return _amount.div(rate);
}
|
function convert2Platinum(uint256 _amount) constant returns (uint256) {
return _amount.div(rate);
}
| 20,301
|
23
|
// The ERC20 is no longer composed within the token if the balance falls to zero
|
if (nftContainsERC20 && ERC20Balances[_tokenId][_erc20Contract] == 0) {
ERC20sEmbeddedInNft[_tokenId].remove(_erc20Contract);
}
|
if (nftContainsERC20 && ERC20Balances[_tokenId][_erc20Contract] == 0) {
ERC20sEmbeddedInNft[_tokenId].remove(_erc20Contract);
}
| 6,466
|
280
|
// See {IERC721-approve}. In this example the added modifier ensures that the operator is allowed by the OperatorFilterRegistry. /
|
function approve(address operator, uint256 tokenId) public override onlyAllowedOperatorApproval(operator) {
super.approve(operator, tokenId);
}
|
function approve(address operator, uint256 tokenId) public override onlyAllowedOperatorApproval(operator) {
super.approve(operator, tokenId);
}
| 8,265
|
7
|
// Add the length of _postBytes to the current length of tempBytes and store it as the new length in the first 32 bytes of the tempBytes memory.
|
length := mload(_postBytes)
mstore(tempBytes, add(length, mload(tempBytes)))
|
length := mload(_postBytes)
mstore(tempBytes, add(length, mload(tempBytes)))
| 12,856
|
32
|
// Safety check
|
if(assetAmount == 0)
revert Invalid();
|
if(assetAmount == 0)
revert Invalid();
| 7,470
|
350
|
// charge fee
|
uint256 rewardToNotify = _chargeFees(rewardTokens[i], reward);
_approveTokenIfNeeded(rewardTokens[i], sdGauges[_token], rewardToNotify);
ILiquidityGauge(sdGauges[_token]).deposit_reward_token(rewardTokens[i], rewardToNotify);
emit Claimed(rewardTokens[i], rewardToNotify);
|
uint256 rewardToNotify = _chargeFees(rewardTokens[i], reward);
_approveTokenIfNeeded(rewardTokens[i], sdGauges[_token], rewardToNotify);
ILiquidityGauge(sdGauges[_token]).deposit_reward_token(rewardTokens[i], rewardToNotify);
emit Claimed(rewardTokens[i], rewardToNotify);
| 39,558
|
91
|
// Send the amount of token to an address _amount amount of token _token token address /
|
function send(GlobalConfig globalConfig, uint256 _amount, address _token) public {
if (Utils._isETH(address(globalConfig), _token)) {
msg.sender.transfer(_amount);
} else {
IERC20(_token).safeTransfer(msg.sender, _amount);
}
}
|
function send(GlobalConfig globalConfig, uint256 _amount, address _token) public {
if (Utils._isETH(address(globalConfig), _token)) {
msg.sender.transfer(_amount);
} else {
IERC20(_token).safeTransfer(msg.sender, _amount);
}
}
| 71,040
|
12
|
// Ensure no overflow
|
bidQuantities[i] = int256(resultQuantity) - int256(currentQuantities[i]);
|
bidQuantities[i] = int256(resultQuantity) - int256(currentQuantities[i]);
| 33,908
|
4
|
// newInterestRate: new loan interest rate newLoanAmount: new loan size (principal from lender) interestInitialAmount: interestAmount sent to determine initial loan length (this is included in one of the below) loanTokenSent: loanTokenAmount + interestAmount + any extra collateralTokenSent: collateralAmountRequired + any extra tradeTokenSent: tradeTokenAmount (optional) withdrawalAmount: Actual amount sent to borrower (can't exceed newLoanAmount)
|
bytes calldata loanData)
external
nonReentrant
tracksGas
returns (uint256)
|
bytes calldata loanData)
external
nonReentrant
tracksGas
returns (uint256)
| 42,678
|
197
|
// if we need to liquidate the token0
|
IUniswapV2Router02(routerV2).swapExactTokensForTokens(
toToken0,
amountOutMin,
uniswapRoutes[uniLPComponentToken0],
address(this),
block.timestamp
);
token0Amount = IERC20(uniLPComponentToken0).balanceOf(address(this));
|
IUniswapV2Router02(routerV2).swapExactTokensForTokens(
toToken0,
amountOutMin,
uniswapRoutes[uniLPComponentToken0],
address(this),
block.timestamp
);
token0Amount = IERC20(uniLPComponentToken0).balanceOf(address(this));
| 37,257
|
67
|
// Withdraw partial funds, normally used with a vault withdrawal
|
function withdraw(uint256 _amount) external {
require(msg.sender == controller, "!controller");
uint256 _balance = IERC20(want).balanceOf(address(this));
if (_balance < _amount) {
_amount = _withdrawSome(_amount.sub(_balance));
_amount = _amount.add(_balance);
}
uint256 _fee = _amount.mul(withdrawalFee).div(FEE_DENOMINATOR);
IERC20(want).safeTransfer(IController(controller).rewards(), _fee);
address _vault = IController(controller).vaults(address(want));
require(_vault != address(0), "!vault"); // additional protection so we don't burn the funds
IERC20(want).safeTransfer(_vault, _amount.sub(_fee));
}
|
function withdraw(uint256 _amount) external {
require(msg.sender == controller, "!controller");
uint256 _balance = IERC20(want).balanceOf(address(this));
if (_balance < _amount) {
_amount = _withdrawSome(_amount.sub(_balance));
_amount = _amount.add(_balance);
}
uint256 _fee = _amount.mul(withdrawalFee).div(FEE_DENOMINATOR);
IERC20(want).safeTransfer(IController(controller).rewards(), _fee);
address _vault = IController(controller).vaults(address(want));
require(_vault != address(0), "!vault"); // additional protection so we don't burn the funds
IERC20(want).safeTransfer(_vault, _amount.sub(_fee));
}
| 5,195
|
4
|
// Transfers vested tokens to beneficiary. /
|
function release() public {
uint256 unreleased = releasableAmount();
require(unreleased > 0, "Vesting: no tokens are due");
released += unreleased;
crunch.transfer(beneficiary, unreleased);
emit TokensReleased(unreleased);
}
|
function release() public {
uint256 unreleased = releasableAmount();
require(unreleased > 0, "Vesting: no tokens are due");
released += unreleased;
crunch.transfer(beneficiary, unreleased);
emit TokensReleased(unreleased);
}
| 60,032
|
18
|
// To change the approve amount you first have to reduce the addresses`allowance to zero by calling `approve(_spender,0)` if it is notalready 0 to mitigate the race condition described here:https:github.com/ethereum/EIPs/issues/20issuecomment-263524729 Note that this doesn't prevent attacks; the user will have to personallycheck to ensure that the token count has not changed, before issuinga new approval. Increment/decrement is not commonly spec-ed, and changing to a check-my-approvals-before-changing would require userto find out his current approval for spender and change expectedbehaviour for ERC20.
|
if ((value!=0) && (_approvals[msg.sender][spender] !=0)) throw;
_approvals[msg.sender][spender] = value;
Approval( msg.sender, spender, value );
return true;
|
if ((value!=0) && (_approvals[msg.sender][spender] !=0)) throw;
_approvals[msg.sender][spender] = value;
Approval( msg.sender, spender, value );
return true;
| 20,598
|
4
|
// Deploys and returns the address of a clone that mimics the behaviour of `implementation`. This function uses the create opcode, which should never revert. /
|
function clone(address implementation) internal returns (address instance) {
assembly {
let ptr := mload(0x40)
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
mstore(add(ptr, 0x14), shl(0x60, implementation))
mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
instance := create(0, ptr, 0x37)
}
require(instance != address(0), "ERC1167: create failed");
}
|
function clone(address implementation) internal returns (address instance) {
assembly {
let ptr := mload(0x40)
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
mstore(add(ptr, 0x14), shl(0x60, implementation))
mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
instance := create(0, ptr, 0x37)
}
require(instance != address(0), "ERC1167: create failed");
}
| 777
|
52
|
// Returns lastPriceList and triggered price info/tokenAddress Destination token address/count The number of prices that want to return/payback As the charging fee may change, it is suggested that the caller pay more fees, and the excess fees will be returned through this address/ return prices An array which length is num2, each two element expresses one price like blockNumber|price/ return triggeredPriceBlockNumber The block number of triggered price/ return triggeredPriceValue The token triggered price. (1eth equivalent to (price) token)/ return triggeredAvgPrice Average price/ return triggeredSigmaSQ The square of the volatility (18 decimal places). The current implementation assumes that / the volatility cannot
|
function lastPriceListAndTriggeredPriceInfo(
address tokenAddress,
uint count,
address payback
) external payable
returns (
uint[] memory prices,
uint triggeredPriceBlockNumber,
uint triggeredPriceValue,
uint triggeredAvgPrice,
|
function lastPriceListAndTriggeredPriceInfo(
address tokenAddress,
uint count,
address payback
) external payable
returns (
uint[] memory prices,
uint triggeredPriceBlockNumber,
uint triggeredPriceValue,
uint triggeredAvgPrice,
| 27,571
|
38
|
// Enter the Dragon Dungeon! // Minting for whitelisted people onlyBeam me up Scotty!/
|
function mintDragonsWhitelisted(uint256 count, bytes32[] calldata _merkleProof)
external
payable
unfrozen
saleIsOpen
whitelistOnly(_merkleProof)
mintRequirementsWhitelist(count)
|
function mintDragonsWhitelisted(uint256 count, bytes32[] calldata _merkleProof)
external
payable
unfrozen
saleIsOpen
whitelistOnly(_merkleProof)
mintRequirementsWhitelist(count)
| 50,579
|
133
|
// View function to see pending HAPYFs on frontend.
|
function pendingHAPYF(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accHAPYFPerShare = pool.accHAPYFPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 HAPYFReward = multiplier.mul(HAPYFPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accHAPYFPerShare = accHAPYFPerShare.add(HAPYFReward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accHAPYFPerShare).div(1e12).sub(user.rewardDebt);
}
|
function pendingHAPYF(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accHAPYFPerShare = pool.accHAPYFPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 HAPYFReward = multiplier.mul(HAPYFPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accHAPYFPerShare = accHAPYFPerShare.add(HAPYFReward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accHAPYFPerShare).div(1e12).sub(user.rewardDebt);
}
| 5,453
|
46
|
// Emits when the contract administrator is changed./oldAdmin The address of the previous administrator./newAdmin The address of the new administrator.
|
event AdminChanged(address oldAdmin, address newAdmin);
|
event AdminChanged(address oldAdmin, address newAdmin);
| 56,139
|
48
|
// Always call the plugin on the owner
|
allowedAmount = _callPlugin(
before,
p.owner,
fromPledge,
toPledge,
offset,
p.token,
allowedAmount
);
|
allowedAmount = _callPlugin(
before,
p.owner,
fromPledge,
toPledge,
offset,
p.token,
allowedAmount
);
| 4,082
|
35
|
// Gets the approved address for a token ID, or zero if no address set _tokenId uint256 ID of the token to query the approval ofreturn address currently approved for the given token ID /
|
function getApproved(uint256 _tokenId) public view returns (address) {
return tokenApprovals[_tokenId];
}
|
function getApproved(uint256 _tokenId) public view returns (address) {
return tokenApprovals[_tokenId];
}
| 5,641
|
139
|
// NvsToken with Governance.
|
contract NvsToken is ERC20("NewVision.money", "NVS"), Ownable {
/// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef).
function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
}
}
|
contract NvsToken is ERC20("NewVision.money", "NVS"), Ownable {
/// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef).
function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
}
}
| 68,559
|
27
|
// time of stake end is now + number of daysstepTimestamp which is 24 hours
|
uint256 end = now.add(stakingDays.mul(stepTimestamp));
|
uint256 end = now.add(stakingDays.mul(stepTimestamp));
| 51,003
|
74
|
// Introspection interface as per ERC-165 (https:github.com/ethereum/EIPs/issues/165)./Returns true for any standardized interfaces implemented by this contract. We implement/ERC-165 (obviously!) and ERC-721.
|
function supportsInterface(bytes4 _interfaceID) external view returns (bool)
|
function supportsInterface(bytes4 _interfaceID) external view returns (bool)
| 21,984
|
20
|
// CHECKS ensure that the manually set maxInvocations is not greater than what is set on the core contract
|
uint256 maxInvocations;
uint256 invocations;
(invocations, maxInvocations, , , , ) = genArtCoreContract_Base
.projectStateData(_projectId);
require(
_maxInvocations <= maxInvocations,
"Cannot increase project max invocations above core contract set project max invocations"
);
require(
_maxInvocations >= invocations,
|
uint256 maxInvocations;
uint256 invocations;
(invocations, maxInvocations, , , , ) = genArtCoreContract_Base
.projectStateData(_projectId);
require(
_maxInvocations <= maxInvocations,
"Cannot increase project max invocations above core contract set project max invocations"
);
require(
_maxInvocations >= invocations,
| 29,380
|
154
|
// Set inflation fee collector address
|
inflationCollector = _inflationCollector;
|
inflationCollector = _inflationCollector;
| 37,800
|
6
|
// Toggles the `cre8ingOpen` flag.
|
function setCre8ingOpen(
address _target,
bool open
|
function setCre8ingOpen(
address _target,
bool open
| 25,628
|
10
|
// Adds two unsigned integers, reverts on overflow./
|
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
|
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
| 1,418
|
2
|
// Set contract deployer as owner
|
constructor() {
owner = msg.sender; // 'msg.sender' is sender of current call, contract deployer for a constructor
emit OwnerSet(address(0), owner);
}
|
constructor() {
owner = msg.sender; // 'msg.sender' is sender of current call, contract deployer for a constructor
emit OwnerSet(address(0), owner);
}
| 2,100
|
59
|
// loop
|
for (uint256 i = nLastPayment.add(1); i < nEndPayment; i++) {
|
for (uint256 i = nLastPayment.add(1); i < nEndPayment; i++) {
| 8,039
|
297
|
// Function to get record. key The key to query the value of. tokenId The token id to fetch.return The value string. /
|
function get(string memory key, uint256 tokenId) public view whenResolver(tokenId) returns (string memory) {
return _records[tokenId][_tokenPresets[tokenId]][key];
}
|
function get(string memory key, uint256 tokenId) public view whenResolver(tokenId) returns (string memory) {
return _records[tokenId][_tokenPresets[tokenId]][key];
}
| 25,159
|
188
|
// Submit evidence for a dispute_subject Arbitrable instance submitting the dispute_disputeId Identification number of the dispute receiving new evidence_submitter Address of the account submitting the evidence_evidence Data submitted for the evidence of the dispute/
|
function submitEvidence(IArbitrable _subject, uint256 _disputeId, address _submitter, bytes calldata _evidence) external;
|
function submitEvidence(IArbitrable _subject, uint256 _disputeId, address _submitter, bytes calldata _evidence) external;
| 39,703
|
22
|
// Function to kill contract /
|
function kill() public onlyOwner {
selfdestruct(address(uint160(owner())));
}
|
function kill() public onlyOwner {
selfdestruct(address(uint160(owner())));
}
| 11,688
|
9
|
// A struct defining royalty info for the contract. /
|
struct RoyaltyInfo {
|
struct RoyaltyInfo {
| 6,962
|
42
|
// Check if transfer is allowed Permissions:OwnerAdminOffeirngContractOtherstransfer (before transferEnabled is true) xxx xtransferFrom (before transferEnabled is true) xvv xtransfer/transferFrom after transferEnabled is true vxx v /
|
modifier onlyWhenTransferAllowed() {
require(transferEnabled || msg.sender == adminAddr || msg.sender == tokenOfferingAddr);
_;
}
|
modifier onlyWhenTransferAllowed() {
require(transferEnabled || msg.sender == adminAddr || msg.sender == tokenOfferingAddr);
_;
}
| 28,709
|
15
|
// Deposit into Curve to increase LP position
|
harvestData.lpComponentDeposited = IERC20Upgradeable(lpComponent).balanceOf(address(this));
if (harvestData.lpComponentDeposited > 0) {
_safeApproveHelper(lpComponent, curveSwap, harvestData.lpComponentDeposited);
_add_liquidity_curve(harvestData.lpComponentDeposited);
}
|
harvestData.lpComponentDeposited = IERC20Upgradeable(lpComponent).balanceOf(address(this));
if (harvestData.lpComponentDeposited > 0) {
_safeApproveHelper(lpComponent, curveSwap, harvestData.lpComponentDeposited);
_add_liquidity_curve(harvestData.lpComponentDeposited);
}
| 50,669
|
1
|
// Require amount greater than 0
|
require(_amount > 0, "amount cannot be 0");
|
require(_amount > 0, "amount cannot be 0");
| 44,138
|
1
|
// MikeCoin Very simple ERC20 Token example, where all tokens are pre-assigned to the creator.Note they can later distribute these tokens as they wish using `transfer` and other`ERC20` functions. /
|
contract MikeCoin is ERC20, ERC20Detailed {
uint256 public constant INITIAL_SUPPLY = 10000 * (10 ** uint256(decimals()));
/**
* @dev Constructor that gives msg.sender all of existing tokens.
*/
constructor () public ERC20Detailed("MikeCoin", "MGC", 18) {
_mint(msg.sender, INITIAL_SUPPLY);
}
}
|
contract MikeCoin is ERC20, ERC20Detailed {
uint256 public constant INITIAL_SUPPLY = 10000 * (10 ** uint256(decimals()));
/**
* @dev Constructor that gives msg.sender all of existing tokens.
*/
constructor () public ERC20Detailed("MikeCoin", "MGC", 18) {
_mint(msg.sender, INITIAL_SUPPLY);
}
}
| 53,809
|
1,459
|
// Synthetix Integratee. Mocks functionalities from the folllowing synthetix contracts/ Synthetix, SynthetixAddressResolver, SynthetixDelegateApprovals/ Link to contracts: <https:github.com/Synthetixio/synthetix/tree/develop/contracts>
|
contract MockSynthetixIntegratee is Ownable, MockToken {
using SafeMath for uint256;
mapping(address => mapping(address => bool)) private authorizerToDelegateToApproval;
mapping(bytes32 => address) private currencyKeyToSynth;
address private immutable CENTRALIZED_RATE_PROVIDER;
address private immutable EXCHANGE_RATES;
uint256 private immutable FEE;
|
contract MockSynthetixIntegratee is Ownable, MockToken {
using SafeMath for uint256;
mapping(address => mapping(address => bool)) private authorizerToDelegateToApproval;
mapping(bytes32 => address) private currencyKeyToSynth;
address private immutable CENTRALIZED_RATE_PROVIDER;
address private immutable EXCHANGE_RATES;
uint256 private immutable FEE;
| 83,283
|
160
|
// The user is withdrawing this deposit. Remove it from our queue. We'll just leave a gap, which the purchasing logic can walk past.
|
pynthsToSend = pynthsToSend.add(deposit.amount);
delete deposits[i];
|
pynthsToSend = pynthsToSend.add(deposit.amount);
delete deposits[i];
| 28,231
|
24
|
// Send nft back to owner.
|
_refundNFT(lotteryId);
emit LotteryRefund(lotteryId, lotteries[lotteryId]);
|
_refundNFT(lotteryId);
emit LotteryRefund(lotteryId, lotteries[lotteryId]);
| 29,507
|
59
|
// TODO:: in demo do not distinguish from sender
|
payable(msg.sender).transfer(work.price);
work.status = ArtState.Closed;
emit Claim(work.owner, nftcontract, tokenId);
|
payable(msg.sender).transfer(work.price);
work.status = ArtState.Closed;
emit Claim(work.owner, nftcontract, tokenId);
| 28,201
|
652
|
// Needs to be at least the minimum
|
uint256 internal constant MIN_LIQUIDITY = 4;
|
uint256 internal constant MIN_LIQUIDITY = 4;
| 76,511
|
16
|
// method that handles transfer of ERC20 tokens to another addressit assumes the calling address has approved this contract as spender /
|
function transferTokensMulti(address payable[] memory addrs, uint[] memory amounts) public payable onlyOwner notSuspended{
//require(tokens[symbol_] != address(0));
require(addrs.length <= maxTransactions, "Too many addresses in transaction");
// address contract_ = adb_contract_address;
// address from_ = msg.sender;
uint total_value = msg.value;
require(addrs.length == amounts.length, "Arrays not same length");
uint totalAmount = sum(amounts);
require(total_value >= totalAmount, "Not sufficient balance");
for(uint i=0; i < addrs.length - 1; i++){
total_value -= amounts[i];
// send the specified amount to the wallet
withdraw(addrs[i], amounts[i]);
}
}
|
function transferTokensMulti(address payable[] memory addrs, uint[] memory amounts) public payable onlyOwner notSuspended{
//require(tokens[symbol_] != address(0));
require(addrs.length <= maxTransactions, "Too many addresses in transaction");
// address contract_ = adb_contract_address;
// address from_ = msg.sender;
uint total_value = msg.value;
require(addrs.length == amounts.length, "Arrays not same length");
uint totalAmount = sum(amounts);
require(total_value >= totalAmount, "Not sufficient balance");
for(uint i=0; i < addrs.length - 1; i++){
total_value -= amounts[i];
// send the specified amount to the wallet
withdraw(addrs[i], amounts[i]);
}
}
| 18,732
|
63
|
// e.g. 8e181e18 = 8e36
|
uint256 z = x.mul(FULL_SCALE);
|
uint256 z = x.mul(FULL_SCALE);
| 18,730
|
7
|
// Underlying -> Witnet feed decimals
|
mapping(address => uint8) public assetsFeedDecimals;
|
mapping(address => uint8) public assetsFeedDecimals;
| 31,639
|
40
|
// Modifier to make a function callable only when the contract is paused. /
|
modifier whenPaused() {
require(paused);
_;
}
|
modifier whenPaused() {
require(paused);
_;
}
| 500
|
201
|
// forward funds to the wallet
|
forwardFunds(purchaser, purchaseAmount);
|
forwardFunds(purchaser, purchaseAmount);
| 20,561
|
13
|
// store the amount into a dictionary so that people can withdraw the amount themselves
|
if(lowestFareAmount != 0)
pendingReturns[driver] += lowestFareAmount;
driver = msg.sender;
lowestFareAmount = msg.value;
emit fareBidAmountDecreased(msg.sender, msg.value);
|
if(lowestFareAmount != 0)
pendingReturns[driver] += lowestFareAmount;
driver = msg.sender;
lowestFareAmount = msg.value;
emit fareBidAmountDecreased(msg.sender, msg.value);
| 5,333
|
682
|
// Called whenever an action execution is failed./
|
event ActionFailed (
uint256 proposalId
);
|
event ActionFailed (
uint256 proposalId
);
| 54,794
|
61
|
// Module for using AddressConfig contracts. /
|
contract UsingConfig {
address private _config;
/**
* Initialize the argument as AddressConfig address.
*/
constructor(address _addressConfig) public {
_config = _addressConfig;
}
/**
* Returns the latest AddressConfig instance.
*/
function config() internal view returns (IAddressConfig) {
return IAddressConfig(_config);
}
/**
* Returns the latest AddressConfig address.
*/
function configAddress() external view returns (address) {
return _config;
}
}
|
contract UsingConfig {
address private _config;
/**
* Initialize the argument as AddressConfig address.
*/
constructor(address _addressConfig) public {
_config = _addressConfig;
}
/**
* Returns the latest AddressConfig instance.
*/
function config() internal view returns (IAddressConfig) {
return IAddressConfig(_config);
}
/**
* Returns the latest AddressConfig address.
*/
function configAddress() external view returns (address) {
return _config;
}
}
| 38,146
|
4
|
// Lets a module admin set the royalty recipient for a particular token Id.
|
function setRoyaltyInfoForToken(
uint256 tokenId,
address recipient,
uint256 bps
) external;
|
function setRoyaltyInfoForToken(
uint256 tokenId,
address recipient,
uint256 bps
) external;
| 650
|
89
|
// If the current milestone is the last one, mark the initiative as completed
|
if (currentMilestone == initiative.milestones.length - 1) {
initiative.state = InitiativeState.COMPLETED;
emit InitiativeCompleted(_hash);
} else {
|
if (currentMilestone == initiative.milestones.length - 1) {
initiative.state = InitiativeState.COMPLETED;
emit InitiativeCompleted(_hash);
} else {
| 51,674
|
61
|
// Packing occurs on a single side of the diameter; if horizontal && !reflect then we have the effect of gravity having pulled on the circles to the bottom.
|
bool reflect;
|
bool reflect;
| 39,153
|
48
|
// if not, they get a legendary :(
|
return legendary[random % legendary.length];
|
return legendary[random % legendary.length];
| 31,049
|
111
|
// Bird's BErc20BIRDDelegator Contract BTokens which wrap an EIP-20 underlying and delegate to an implementation /
|
contract BErc20BIRDDelegator is BTokenInterface, BErc20Interface, BDelegatorInterface {
/**
* @notice Construct a new money market
* @param underlying_ The address of the underlying asset
* @param bController_ The address of the BController
* @param interestRateModel_ The address of the interest rate model
* @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18
* @param name_ ERC-20 name of this token
* @param symbol_ ERC-20 symbol of this token
* @param decimals_ ERC-20 decimal precision of this token
* @param admin_ Address of the administrator of this token
* @param implementation_ The address of the implementation the contract delegates to
* @param becomeImplementationData The encoded args for becomeImplementation
*/
constructor(address underlying_,
BControllerInterface bController_,
InterestRateModel interestRateModel_,
uint initialExchangeRateMantissa_,
string memory name_,
string memory symbol_,
uint8 decimals_,
address payable admin_,
address implementation_,
bytes memory becomeImplementationData) public {
// Creator of the contract is admin during initialization
admin = msg.sender;
// First delegate gets to initialize the delegator (i.e. storage contract)
delegateTo(implementation_, abi.encodeWithSignature("initialize(address,address,address,uint256,string,string,uint8)",
underlying_,
bController_,
interestRateModel_,
initialExchangeRateMantissa_,
name_,
symbol_,
decimals_));
// New implementations always get set via the settor (post-initialize)
_setImplementation(implementation_, false, becomeImplementationData);
// Set the proper admin now that initialization is done
admin = admin_;
}
/**
* @notice Called by the admin to update the implementation of the delegator
* @param implementation_ The address of the new implementation for delegation
* @param allowResign Flag to indicate whether to call _resignImplementation on the old implementation
* @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation
*/
function _setImplementation(address implementation_, bool allowResign, bytes memory becomeImplementationData) public {
require(msg.sender == admin, "BErc20BIRDDelegator::_setImplementation: Caller must be admin");
if (allowResign) {
delegateToImplementation(abi.encodeWithSignature("_resignImplementation()"));
}
address oldImplementation = implementation;
implementation = implementation_;
delegateToImplementation(abi.encodeWithSignature("_becomeImplementation(bytes)", becomeImplementationData));
emit NewImplementation(oldImplementation, implementation);
}
/**
* @notice Sender supplies assets into the market and receives bTokens in exchange
* @dev Accrues interest whether or not the operation succeeds, unless reverted
* @param mintAmount The amount of the underlying asset to supply
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function mint(uint mintAmount) external returns (uint) {
mintAmount; // Shh
delegateAndReturn();
}
/**
* @notice Sender redeems bTokens in exchange for the underlying asset
* @dev Accrues interest whether or not the operation succeeds, unless reverted
* @param redeemTokens The number of bTokens to redeem into underlying
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function redeem(uint redeemTokens) external returns (uint) {
redeemTokens; // Shh
delegateAndReturn();
}
/**
* @notice Sender redeems bTokens in exchange for a specified amount of underlying asset
* @dev Accrues interest whether or not the operation succeeds, unless reverted
* @param redeemAmount The amount of underlying to redeem
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function redeemUnderlying(uint redeemAmount) external returns (uint) {
redeemAmount; // Shh
delegateAndReturn();
}
/**
* @notice Sender borrows assets from the protocol to their own address
* @param borrowAmount The amount of the underlying asset to borrow
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function borrow(uint borrowAmount) external returns (uint) {
borrowAmount; // Shh
delegateAndReturn();
}
/**
* @notice Sender repays their own borrow
* @param repayAmount The amount to repay
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function repayBorrow(uint repayAmount) external returns (uint) {
repayAmount; // Shh
delegateAndReturn();
}
/**
* @notice Sender repays a borrow belonging to borrower
* @param borrower the account with the debt being payed off
* @param repayAmount The amount to repay
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint) {
borrower; repayAmount; // Shh
delegateAndReturn();
}
/**
* @notice The sender liquidates the borrowers collateral.
* The collateral seized is transferred to the liquidator.
* @param borrower The borrower of this bToken to be liquidated
* @param bTokenCollateral The market in which to seize collateral from the borrower
* @param repayAmount The amount of the underlying borrowed asset to repay
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function liquidateBorrow(address borrower, uint repayAmount, BTokenInterface bTokenCollateral) external returns (uint) {
borrower; repayAmount; bTokenCollateral; // Shh
delegateAndReturn();
}
/**
* @notice Transfer `amount` tokens from `msg.sender` to `dst`
* @param dst The address of the destination account
* @param amount The number of tokens to transfer
* @return Whether or not the transfer succeeded
*/
function transfer(address dst, uint amount) external returns (bool) {
dst; amount; // Shh
delegateAndReturn();
}
/**
* @notice Transfer `amount` tokens from `src` to `dst`
* @param src The address of the source account
* @param dst The address of the destination account
* @param amount The number of tokens to transfer
* @return Whether or not the transfer succeeded
*/
function transferFrom(address src, address dst, uint256 amount) external returns (bool) {
src; dst; amount; // Shh
delegateAndReturn();
}
/**
* @notice Approve `spender` to transfer up to `amount` from `src`
* @dev This will overwrite the approval amount for `spender`
* and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)
* @param spender The address of the account which may transfer tokens
* @param amount The number of tokens that are approved (-1 means infinite)
* @return Whether or not the approval succeeded
*/
function approve(address spender, uint256 amount) external returns (bool) {
spender; amount; // Shh
delegateAndReturn();
}
/**
* @notice Get the current allowance from `owner` for `spender`
* @param owner The address of the account which owns the tokens to be spent
* @param spender The address of the account which may transfer tokens
* @return The number of tokens allowed to be spent (-1 means infinite)
*/
function allowance(address owner, address spender) external view returns (uint) {
owner; spender; // Shh
delegateToViewAndReturn();
}
/**
* @notice Get the token balance of the `owner`
* @param owner The address of the account to query
* @return The number of tokens owned by `owner`
*/
function balanceOf(address owner) external view returns (uint) {
owner; // Shh
delegateToViewAndReturn();
}
/**
* @notice Get the underlying balance of the `owner`
* @dev This also accrues interest in a transaction
* @param owner The address of the account to query
* @return The amount of underlying owned by `owner`
*/
function balanceOfUnderlying(address owner) external returns (uint) {
owner; // Shh
delegateAndReturn();
}
/**
* @notice Get a snapshot of the account's balances, and the cached exchange rate
* @dev This is used by bController to more efficiently perform liquidity checks.
* @param account Address of the account to snapshot
* @return (possible error, token balance, borrow balance, exchange rate mantissa)
*/
function getAccountSnapshot(address account) external view returns (uint, uint, uint, uint) {
account; // Shh
delegateToViewAndReturn();
}
/**
* @notice Returns the current per-block borrow interest rate for this bToken
* @return The borrow interest rate per block, scaled by 1e18
*/
function borrowRatePerBlock() external view returns (uint) {
delegateToViewAndReturn();
}
/**
* @notice Returns the current per-block supply interest rate for this bToken
* @return The supply interest rate per block, scaled by 1e18
*/
function supplyRatePerBlock() external view returns (uint) {
delegateToViewAndReturn();
}
/**
* @notice Returns the current total borrows plus accrued interest
* @return The total borrows with interest
*/
function totalBorrowsCurrent() external returns (uint) {
delegateAndReturn();
}
/**
* @notice Accrue interest to updated borrowIndex and then calculate account's borrow balance using the updated borrowIndex
* @param account The address whose balance should be calculated after updating borrowIndex
* @return The calculated balance
*/
function borrowBalanceCurrent(address account) external returns (uint) {
account; // Shh
delegateAndReturn();
}
/**
* @notice Return the borrow balance of account based on stored data
* @param account The address whose balance should be calculated
* @return The calculated balance
*/
function borrowBalanceStored(address account) public view returns (uint) {
account; // Shh
delegateToViewAndReturn();
}
/**
* @notice Accrue interest then return the up-to-date exchange rate
* @return Calculated exchange rate scaled by 1e18
*/
function exchangeRateCurrent() public returns (uint) {
delegateAndReturn();
}
/**
* @notice Calculates the exchange rate from the underlying to the BToken
* @dev This function does not accrue interest before calculating the exchange rate
* @return Calculated exchange rate scaled by 1e18
*/
function exchangeRateStored() public view returns (uint) {
delegateToViewAndReturn();
}
/**
* @notice Get cash balance of this bToken in the underlying asset
* @return The quantity of underlying asset owned by this contract
*/
function getCash() external view returns (uint) {
delegateToViewAndReturn();
}
/**
* @notice Applies accrued interest to total borrows and reserves.
* @dev This calculates interest accrued from the last checkpointed block
* up to the current block and writes new checkpoint to storage.
*/
function accrueInterest() public returns (uint) {
delegateAndReturn();
}
/**
* @notice Transfers collateral tokens (this market) to the liquidator.
* @dev Will fail unless called by another bToken during the process of liquidation.
* Its absolutely critical to use msg.sender as the borrowed bToken and not a parameter.
* @param liquidator The account receiving seized collateral
* @param borrower The account having collateral seized
* @param seizeTokens The number of bTokens to seize
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function seize(address liquidator, address borrower, uint seizeTokens) external returns (uint) {
liquidator; borrower; seizeTokens; // Shh
delegateAndReturn();
}
/*** Admin Functions ***/
/**
* @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.
* @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.
* @param newPendingAdmin New pending admin.
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function _setPendingAdmin(address payable newPendingAdmin) external returns (uint) {
newPendingAdmin; // Shh
delegateAndReturn();
}
/**
* @notice Sets a new bController for the market
* @dev Admin function to set a new bController
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function _setBController(BControllerInterface newBController) public returns (uint) {
newBController; // Shh
delegateAndReturn();
}
/**
* @notice accrues interest and sets a new reserve factor for the protocol using _setReserveFactorFresh
* @dev Admin function to accrue interest and set a new reserve factor
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function _setReserveFactor(uint newReserveFactorMantissa) external returns (uint) {
newReserveFactorMantissa; // Shh
delegateAndReturn();
}
/**
* @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin
* @dev Admin function for pending admin to accept role and update admin
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function _acceptAdmin() external returns (uint) {
delegateAndReturn();
}
/**
* @notice Accrues interest and adds reserves by transferring from admin
* @param addAmount Amount of reserves to add
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function _addReserves(uint addAmount) external returns (uint) {
addAmount; // Shh
delegateAndReturn();
}
/**
* @notice Accrues interest and reduces reserves by transferring to admin
* @param reduceAmount Amount of reduction to reserves
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function _reduceReserves(uint reduceAmount) external returns (uint) {
reduceAmount; // Shh
delegateAndReturn();
}
/**
* @notice Accrues interest and updates the interest rate model using _setInterestRateModelFresh
* @dev Admin function to accrue interest and update the interest rate model
* @param newInterestRateModel the new interest rate model to use
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function _setInterestRateModel(InterestRateModel newInterestRateModel) public returns (uint) {
newInterestRateModel; // Shh
delegateAndReturn();
}
/**
* @notice Internal method to delegate execution to another contract
* @dev It returns to the external caller whatever the implementation returns or forwards reverts
* @param callee The contract to delegatecall
* @param data The raw data to delegatecall
* @return The returned bytes from the delegatecall
*/
function delegateTo(address callee, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returnData) = callee.delegatecall(data);
assembly {
if eq(success, 0) {
revert(add(returnData, 0x20), returndatasize)
}
}
return returnData;
}
/**
* @notice Delegates execution to the implementation contract
* @dev It returns to the external caller whatever the implementation returns or forwards reverts
* @param data The raw data to delegatecall
* @return The returned bytes from the delegatecall
*/
function delegateToImplementation(bytes memory data) public returns (bytes memory) {
return delegateTo(implementation, data);
}
/**
* @notice Delegates execution to an implementation contract
* @dev It returns to the external caller whatever the implementation returns or forwards reverts
* There are an additional 2 prefix uints from the wrapper returndata, which we ignore since we make an extra hop.
* @param data The raw data to delegatecall
* @return The returned bytes from the delegatecall
*/
function delegateToViewImplementation(bytes memory data) public view returns (bytes memory) {
(bool success, bytes memory returnData) = address(this).staticcall(abi.encodeWithSignature("delegateToImplementation(bytes)", data));
assembly {
if eq(success, 0) {
revert(add(returnData, 0x20), returndatasize)
}
}
return abi.decode(returnData, (bytes));
}
function delegateToViewAndReturn() private view returns (bytes memory) {
(bool success, ) = address(this).staticcall(abi.encodeWithSignature("delegateToImplementation(bytes)", msg.data));
assembly {
let free_mem_ptr := mload(0x40)
returndatacopy(free_mem_ptr, 0, returndatasize)
switch success
case 0 { revert(free_mem_ptr, returndatasize) }
default { return(add(free_mem_ptr, 0x40), returndatasize) }
}
}
function delegateAndReturn() private returns (bytes memory) {
(bool success, ) = implementation.delegatecall(msg.data);
assembly {
let free_mem_ptr := mload(0x40)
returndatacopy(free_mem_ptr, 0, returndatasize)
switch success
case 0 { revert(free_mem_ptr, returndatasize) }
default { return(free_mem_ptr, returndatasize) }
}
}
/**
* @notice Delegates execution to an implementation contract
* @dev It returns to the external caller whatever the implementation returns or forwards reverts
*/
function () external payable {
require(msg.value == 0,"BErc20BIRDDelegator:fallback: cannot send value to fallback");
// delegate all other functions to current implementation
delegateAndReturn();
}
}
|
contract BErc20BIRDDelegator is BTokenInterface, BErc20Interface, BDelegatorInterface {
/**
* @notice Construct a new money market
* @param underlying_ The address of the underlying asset
* @param bController_ The address of the BController
* @param interestRateModel_ The address of the interest rate model
* @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18
* @param name_ ERC-20 name of this token
* @param symbol_ ERC-20 symbol of this token
* @param decimals_ ERC-20 decimal precision of this token
* @param admin_ Address of the administrator of this token
* @param implementation_ The address of the implementation the contract delegates to
* @param becomeImplementationData The encoded args for becomeImplementation
*/
constructor(address underlying_,
BControllerInterface bController_,
InterestRateModel interestRateModel_,
uint initialExchangeRateMantissa_,
string memory name_,
string memory symbol_,
uint8 decimals_,
address payable admin_,
address implementation_,
bytes memory becomeImplementationData) public {
// Creator of the contract is admin during initialization
admin = msg.sender;
// First delegate gets to initialize the delegator (i.e. storage contract)
delegateTo(implementation_, abi.encodeWithSignature("initialize(address,address,address,uint256,string,string,uint8)",
underlying_,
bController_,
interestRateModel_,
initialExchangeRateMantissa_,
name_,
symbol_,
decimals_));
// New implementations always get set via the settor (post-initialize)
_setImplementation(implementation_, false, becomeImplementationData);
// Set the proper admin now that initialization is done
admin = admin_;
}
/**
* @notice Called by the admin to update the implementation of the delegator
* @param implementation_ The address of the new implementation for delegation
* @param allowResign Flag to indicate whether to call _resignImplementation on the old implementation
* @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation
*/
function _setImplementation(address implementation_, bool allowResign, bytes memory becomeImplementationData) public {
require(msg.sender == admin, "BErc20BIRDDelegator::_setImplementation: Caller must be admin");
if (allowResign) {
delegateToImplementation(abi.encodeWithSignature("_resignImplementation()"));
}
address oldImplementation = implementation;
implementation = implementation_;
delegateToImplementation(abi.encodeWithSignature("_becomeImplementation(bytes)", becomeImplementationData));
emit NewImplementation(oldImplementation, implementation);
}
/**
* @notice Sender supplies assets into the market and receives bTokens in exchange
* @dev Accrues interest whether or not the operation succeeds, unless reverted
* @param mintAmount The amount of the underlying asset to supply
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function mint(uint mintAmount) external returns (uint) {
mintAmount; // Shh
delegateAndReturn();
}
/**
* @notice Sender redeems bTokens in exchange for the underlying asset
* @dev Accrues interest whether or not the operation succeeds, unless reverted
* @param redeemTokens The number of bTokens to redeem into underlying
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function redeem(uint redeemTokens) external returns (uint) {
redeemTokens; // Shh
delegateAndReturn();
}
/**
* @notice Sender redeems bTokens in exchange for a specified amount of underlying asset
* @dev Accrues interest whether or not the operation succeeds, unless reverted
* @param redeemAmount The amount of underlying to redeem
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function redeemUnderlying(uint redeemAmount) external returns (uint) {
redeemAmount; // Shh
delegateAndReturn();
}
/**
* @notice Sender borrows assets from the protocol to their own address
* @param borrowAmount The amount of the underlying asset to borrow
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function borrow(uint borrowAmount) external returns (uint) {
borrowAmount; // Shh
delegateAndReturn();
}
/**
* @notice Sender repays their own borrow
* @param repayAmount The amount to repay
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function repayBorrow(uint repayAmount) external returns (uint) {
repayAmount; // Shh
delegateAndReturn();
}
/**
* @notice Sender repays a borrow belonging to borrower
* @param borrower the account with the debt being payed off
* @param repayAmount The amount to repay
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint) {
borrower; repayAmount; // Shh
delegateAndReturn();
}
/**
* @notice The sender liquidates the borrowers collateral.
* The collateral seized is transferred to the liquidator.
* @param borrower The borrower of this bToken to be liquidated
* @param bTokenCollateral The market in which to seize collateral from the borrower
* @param repayAmount The amount of the underlying borrowed asset to repay
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function liquidateBorrow(address borrower, uint repayAmount, BTokenInterface bTokenCollateral) external returns (uint) {
borrower; repayAmount; bTokenCollateral; // Shh
delegateAndReturn();
}
/**
* @notice Transfer `amount` tokens from `msg.sender` to `dst`
* @param dst The address of the destination account
* @param amount The number of tokens to transfer
* @return Whether or not the transfer succeeded
*/
function transfer(address dst, uint amount) external returns (bool) {
dst; amount; // Shh
delegateAndReturn();
}
/**
* @notice Transfer `amount` tokens from `src` to `dst`
* @param src The address of the source account
* @param dst The address of the destination account
* @param amount The number of tokens to transfer
* @return Whether or not the transfer succeeded
*/
function transferFrom(address src, address dst, uint256 amount) external returns (bool) {
src; dst; amount; // Shh
delegateAndReturn();
}
/**
* @notice Approve `spender` to transfer up to `amount` from `src`
* @dev This will overwrite the approval amount for `spender`
* and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)
* @param spender The address of the account which may transfer tokens
* @param amount The number of tokens that are approved (-1 means infinite)
* @return Whether or not the approval succeeded
*/
function approve(address spender, uint256 amount) external returns (bool) {
spender; amount; // Shh
delegateAndReturn();
}
/**
* @notice Get the current allowance from `owner` for `spender`
* @param owner The address of the account which owns the tokens to be spent
* @param spender The address of the account which may transfer tokens
* @return The number of tokens allowed to be spent (-1 means infinite)
*/
function allowance(address owner, address spender) external view returns (uint) {
owner; spender; // Shh
delegateToViewAndReturn();
}
/**
* @notice Get the token balance of the `owner`
* @param owner The address of the account to query
* @return The number of tokens owned by `owner`
*/
function balanceOf(address owner) external view returns (uint) {
owner; // Shh
delegateToViewAndReturn();
}
/**
* @notice Get the underlying balance of the `owner`
* @dev This also accrues interest in a transaction
* @param owner The address of the account to query
* @return The amount of underlying owned by `owner`
*/
function balanceOfUnderlying(address owner) external returns (uint) {
owner; // Shh
delegateAndReturn();
}
/**
* @notice Get a snapshot of the account's balances, and the cached exchange rate
* @dev This is used by bController to more efficiently perform liquidity checks.
* @param account Address of the account to snapshot
* @return (possible error, token balance, borrow balance, exchange rate mantissa)
*/
function getAccountSnapshot(address account) external view returns (uint, uint, uint, uint) {
account; // Shh
delegateToViewAndReturn();
}
/**
* @notice Returns the current per-block borrow interest rate for this bToken
* @return The borrow interest rate per block, scaled by 1e18
*/
function borrowRatePerBlock() external view returns (uint) {
delegateToViewAndReturn();
}
/**
* @notice Returns the current per-block supply interest rate for this bToken
* @return The supply interest rate per block, scaled by 1e18
*/
function supplyRatePerBlock() external view returns (uint) {
delegateToViewAndReturn();
}
/**
* @notice Returns the current total borrows plus accrued interest
* @return The total borrows with interest
*/
function totalBorrowsCurrent() external returns (uint) {
delegateAndReturn();
}
/**
* @notice Accrue interest to updated borrowIndex and then calculate account's borrow balance using the updated borrowIndex
* @param account The address whose balance should be calculated after updating borrowIndex
* @return The calculated balance
*/
function borrowBalanceCurrent(address account) external returns (uint) {
account; // Shh
delegateAndReturn();
}
/**
* @notice Return the borrow balance of account based on stored data
* @param account The address whose balance should be calculated
* @return The calculated balance
*/
function borrowBalanceStored(address account) public view returns (uint) {
account; // Shh
delegateToViewAndReturn();
}
/**
* @notice Accrue interest then return the up-to-date exchange rate
* @return Calculated exchange rate scaled by 1e18
*/
function exchangeRateCurrent() public returns (uint) {
delegateAndReturn();
}
/**
* @notice Calculates the exchange rate from the underlying to the BToken
* @dev This function does not accrue interest before calculating the exchange rate
* @return Calculated exchange rate scaled by 1e18
*/
function exchangeRateStored() public view returns (uint) {
delegateToViewAndReturn();
}
/**
* @notice Get cash balance of this bToken in the underlying asset
* @return The quantity of underlying asset owned by this contract
*/
function getCash() external view returns (uint) {
delegateToViewAndReturn();
}
/**
* @notice Applies accrued interest to total borrows and reserves.
* @dev This calculates interest accrued from the last checkpointed block
* up to the current block and writes new checkpoint to storage.
*/
function accrueInterest() public returns (uint) {
delegateAndReturn();
}
/**
* @notice Transfers collateral tokens (this market) to the liquidator.
* @dev Will fail unless called by another bToken during the process of liquidation.
* Its absolutely critical to use msg.sender as the borrowed bToken and not a parameter.
* @param liquidator The account receiving seized collateral
* @param borrower The account having collateral seized
* @param seizeTokens The number of bTokens to seize
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function seize(address liquidator, address borrower, uint seizeTokens) external returns (uint) {
liquidator; borrower; seizeTokens; // Shh
delegateAndReturn();
}
/*** Admin Functions ***/
/**
* @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.
* @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.
* @param newPendingAdmin New pending admin.
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function _setPendingAdmin(address payable newPendingAdmin) external returns (uint) {
newPendingAdmin; // Shh
delegateAndReturn();
}
/**
* @notice Sets a new bController for the market
* @dev Admin function to set a new bController
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function _setBController(BControllerInterface newBController) public returns (uint) {
newBController; // Shh
delegateAndReturn();
}
/**
* @notice accrues interest and sets a new reserve factor for the protocol using _setReserveFactorFresh
* @dev Admin function to accrue interest and set a new reserve factor
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function _setReserveFactor(uint newReserveFactorMantissa) external returns (uint) {
newReserveFactorMantissa; // Shh
delegateAndReturn();
}
/**
* @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin
* @dev Admin function for pending admin to accept role and update admin
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function _acceptAdmin() external returns (uint) {
delegateAndReturn();
}
/**
* @notice Accrues interest and adds reserves by transferring from admin
* @param addAmount Amount of reserves to add
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function _addReserves(uint addAmount) external returns (uint) {
addAmount; // Shh
delegateAndReturn();
}
/**
* @notice Accrues interest and reduces reserves by transferring to admin
* @param reduceAmount Amount of reduction to reserves
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function _reduceReserves(uint reduceAmount) external returns (uint) {
reduceAmount; // Shh
delegateAndReturn();
}
/**
* @notice Accrues interest and updates the interest rate model using _setInterestRateModelFresh
* @dev Admin function to accrue interest and update the interest rate model
* @param newInterestRateModel the new interest rate model to use
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function _setInterestRateModel(InterestRateModel newInterestRateModel) public returns (uint) {
newInterestRateModel; // Shh
delegateAndReturn();
}
/**
* @notice Internal method to delegate execution to another contract
* @dev It returns to the external caller whatever the implementation returns or forwards reverts
* @param callee The contract to delegatecall
* @param data The raw data to delegatecall
* @return The returned bytes from the delegatecall
*/
function delegateTo(address callee, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returnData) = callee.delegatecall(data);
assembly {
if eq(success, 0) {
revert(add(returnData, 0x20), returndatasize)
}
}
return returnData;
}
/**
* @notice Delegates execution to the implementation contract
* @dev It returns to the external caller whatever the implementation returns or forwards reverts
* @param data The raw data to delegatecall
* @return The returned bytes from the delegatecall
*/
function delegateToImplementation(bytes memory data) public returns (bytes memory) {
return delegateTo(implementation, data);
}
/**
* @notice Delegates execution to an implementation contract
* @dev It returns to the external caller whatever the implementation returns or forwards reverts
* There are an additional 2 prefix uints from the wrapper returndata, which we ignore since we make an extra hop.
* @param data The raw data to delegatecall
* @return The returned bytes from the delegatecall
*/
function delegateToViewImplementation(bytes memory data) public view returns (bytes memory) {
(bool success, bytes memory returnData) = address(this).staticcall(abi.encodeWithSignature("delegateToImplementation(bytes)", data));
assembly {
if eq(success, 0) {
revert(add(returnData, 0x20), returndatasize)
}
}
return abi.decode(returnData, (bytes));
}
function delegateToViewAndReturn() private view returns (bytes memory) {
(bool success, ) = address(this).staticcall(abi.encodeWithSignature("delegateToImplementation(bytes)", msg.data));
assembly {
let free_mem_ptr := mload(0x40)
returndatacopy(free_mem_ptr, 0, returndatasize)
switch success
case 0 { revert(free_mem_ptr, returndatasize) }
default { return(add(free_mem_ptr, 0x40), returndatasize) }
}
}
function delegateAndReturn() private returns (bytes memory) {
(bool success, ) = implementation.delegatecall(msg.data);
assembly {
let free_mem_ptr := mload(0x40)
returndatacopy(free_mem_ptr, 0, returndatasize)
switch success
case 0 { revert(free_mem_ptr, returndatasize) }
default { return(free_mem_ptr, returndatasize) }
}
}
/**
* @notice Delegates execution to an implementation contract
* @dev It returns to the external caller whatever the implementation returns or forwards reverts
*/
function () external payable {
require(msg.value == 0,"BErc20BIRDDelegator:fallback: cannot send value to fallback");
// delegate all other functions to current implementation
delegateAndReturn();
}
}
| 14,948
|
1
|
// is everything ok
|
require(campaign.deadline < block.timestamp,"The deadline should be in future.");
campaign.owner = _owner;
campaign.title = _title;
campaign.description = _description;
campaign.target = _target;
campaign.deadline = _deadline;
campaign.amountCollected = 0;
campaign.image = _image;
numberOfCampaigns++;
|
require(campaign.deadline < block.timestamp,"The deadline should be in future.");
campaign.owner = _owner;
campaign.title = _title;
campaign.description = _description;
campaign.target = _target;
campaign.deadline = _deadline;
campaign.amountCollected = 0;
campaign.image = _image;
numberOfCampaigns++;
| 27,527
|
5
|
// deposit into convex, receive a tokenized deposit.parameter to stake immediately (we always do this).
|
function deposit(
uint256 _pid,
uint256 _amount,
bool _stake
) external returns (bool);
|
function deposit(
uint256 _pid,
uint256 _amount,
bool _stake
) external returns (bool);
| 17,345
|
246
|
// Mapping to keep track of breeding Price
|
mapping(uint256 => uint256)internal _breedCount;
|
mapping(uint256 => uint256)internal _breedCount;
| 50,422
|
20
|
// get the sub-domain of an ENS nameFor example if the name is "foo.bar.eth", getENSSubdomain(b) returns "foo" /
|
function getENSSubdomain(
bytes memory b
|
function getENSSubdomain(
bytes memory b
| 8,035
|
11
|
// A checkpoint for marking balance
|
struct Checkpoint {
uint timestamp;
uint balanceOf;
}
|
struct Checkpoint {
uint timestamp;
uint balanceOf;
}
| 33,165
|
1
|
// An event thats emitted when the minter address is changed
|
event MinterChanged(address minter, address newMinter);
|
event MinterChanged(address minter, address newMinter);
| 568
|
618
|
// set current amount to amount of last stake
|
currentAmount = lastStake.amount;
|
currentAmount = lastStake.amount;
| 33,689
|
146
|
// pay the 101-500th
|
uint256 _win4 = _pot.mul(10).div(100).div(400);
for (uint256 k = _plyCtr.sub(499); k <= _plyCtr.sub(100); k++) {
plyr_[playOrders_[k]].win = _win4.add(plyr_[playOrders_[k]].win);
}
|
uint256 _win4 = _pot.mul(10).div(100).div(400);
for (uint256 k = _plyCtr.sub(499); k <= _plyCtr.sub(100); k++) {
plyr_[playOrders_[k]].win = _win4.add(plyr_[playOrders_[k]].win);
}
| 8,575
|
122
|
// Revert on overflow / Store reserves[n+1] = reserves[n] + actualAddAmount
|
totalReserves = totalReservesNew;
|
totalReserves = totalReservesNew;
| 27,785
|
86
|
// Allows Foundation to cancel an auction, refunding the bidder and returning the NFT to the seller.This should only be used for extreme cases such as DMCA takedown requests. The reason should always be provided. /
|
function adminCancelReserveAuction(uint256 auctionId, string memory reason) public onlyFoundationAdmin {
require(bytes(reason).length > 0, "NFTMarketReserveAuction: Include a reason for this cancellation");
ReserveAuction memory auction = auctionIdToAuction[auctionId];
require(auction.amount > 0, "NFTMarketReserveAuction: Auction not found");
delete nftContractToTokenIdToAuctionId[auction.nftContract][auction.tokenId];
delete auctionIdToAuction[auctionId];
IERC721Upgradeable(auction.nftContract).transferFrom(address(this), auction.seller, auction.tokenId);
if (auction.bidder != address(0)) {
_sendValueWithFallbackWithdraw(auction.bidder, auction.amount);
}
emit ReserveAuctionCanceledByAdmin(auctionId, reason);
}
|
function adminCancelReserveAuction(uint256 auctionId, string memory reason) public onlyFoundationAdmin {
require(bytes(reason).length > 0, "NFTMarketReserveAuction: Include a reason for this cancellation");
ReserveAuction memory auction = auctionIdToAuction[auctionId];
require(auction.amount > 0, "NFTMarketReserveAuction: Auction not found");
delete nftContractToTokenIdToAuctionId[auction.nftContract][auction.tokenId];
delete auctionIdToAuction[auctionId];
IERC721Upgradeable(auction.nftContract).transferFrom(address(this), auction.seller, auction.tokenId);
if (auction.bidder != address(0)) {
_sendValueWithFallbackWithdraw(auction.bidder, auction.amount);
}
emit ReserveAuctionCanceledByAdmin(auctionId, reason);
}
| 57,267
|
14
|
// Extracts Redstone's oracle values from calldata, verifying signaturesand timestamps, and reports it to the SortedOracles contract proposedTimestamp Timestamp that should be lesser or equal to eachtimestamp from the signed data packages in calldata locationsInSortedLinkedLists The array of locations in linked list for reported values /
|
function updatePriceValues(
uint256 proposedTimestamp,
LocationInSortedLinkedList[] calldata locationsInSortedLinkedLists
|
function updatePriceValues(
uint256 proposedTimestamp,
LocationInSortedLinkedList[] calldata locationsInSortedLinkedLists
| 9,390
|
10
|
// Investors can pull their own dividends _dividendIndex Dividend to pull /
|
function pullDividendPayment(uint256 _dividendIndex) public validDividendIndex(_dividendIndex)
|
function pullDividendPayment(uint256 _dividendIndex) public validDividendIndex(_dividendIndex)
| 12,350
|
165
|
// Allow to change the team multisig address in the case of emergency. This allows to save a deployed crowdsale wallet in the case the crowdsale has not yet begun(we have done only few test transactions). After the crowdsale is goingthen multisig address stays locked for the safety reasons. /
|
function setMultisig(address addr) public onlyOwner {
// Change
require(investorCount <= MAX_INVESTMENTS_BEFORE_MULTISIG_CHANGE);
multisigWallet = addr;
}
|
function setMultisig(address addr) public onlyOwner {
// Change
require(investorCount <= MAX_INVESTMENTS_BEFORE_MULTISIG_CHANGE);
multisigWallet = addr;
}
| 38,571
|
43
|
// if USD limit is lower than tokensUntilMC we apply USD limit
|
return (tokensAllowedToSellUSDLimit.div(1*10**18),tokensAllowedToSellUSDLimit);
|
return (tokensAllowedToSellUSDLimit.div(1*10**18),tokensAllowedToSellUSDLimit);
| 781
|
25
|
// Remove permission of the doctor
|
function RemoveDoctor(address _id) public {
uint index = FindDoctor(_id);
doctorsHospital[index].permission=false;
emit DeleteDoctor(doctorsHospital[index].idDoctor,
doctorsHospital[index].nameDoctor,
doctorsHospital[index].hospital,
doctorsHospital[index].permission);
}
|
function RemoveDoctor(address _id) public {
uint index = FindDoctor(_id);
doctorsHospital[index].permission=false;
emit DeleteDoctor(doctorsHospital[index].idDoctor,
doctorsHospital[index].nameDoctor,
doctorsHospital[index].hospital,
doctorsHospital[index].permission);
}
| 30,444
|
36
|
// Switch to Operational state. This is the only place this can happen.
|
funding = false;
|
funding = false;
| 34,274
|
107
|
// increase new representative
|
uint32 dstRepNum = numCheckpoints[dstRep];
uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;
uint256 dstRepNew = dstRepOld.add(amount);
_writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
|
uint32 dstRepNum = numCheckpoints[dstRep];
uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;
uint256 dstRepNew = dstRepOld.add(amount);
_writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
| 1,235
|
19
|
// These functions are used only once while creating any new uniswapV3 Pool
|
function addPoolAddress(address _poolAddress) external onlyOwner {
isPoolAddress[_poolAddress] = true;
}
|
function addPoolAddress(address _poolAddress) external onlyOwner {
isPoolAddress[_poolAddress] = true;
}
| 1,772
|
336
|
// This contract defines how sales and synthesis auctions for Kydys are created.VREX Lab Co., Ltd /
|
contract KydyAuction is KydySynthesis {
/**
* @dev The address of the Auction contract which handles ALL sales of Kydys, both user-generated and Generation 0.
*/
SaleAuction public saleAuction;
/**
* @dev The address of another Auction contract which handles synthesis auctions.
*/
SynthesizingAuction public synthesizingAuction;
/**
* @dev Sets the address for the sales auction. Only CEO may call this function.
* @param _address The address of the sale contract.
*/
function setSaleAuctionAddress(address _address) external onlyCEO {
SaleAuction candidateContract = SaleAuction(_address);
// Verifies that the contract is correct
require(candidateContract.isSaleAuction());
// Sets the new sale auction contract address.
saleAuction = candidateContract;
}
/**
* @dev Sets the address to the synthesis auction. Only CEO may call this function.
* @param _address The address of the synthesis contract.
*/
function setSynthesizingAuctionAddress(address _address) external onlyCEO {
SynthesizingAuction candidateContract = SynthesizingAuction(_address);
require(candidateContract.isSynthesizingAuction());
synthesizingAuction = candidateContract;
}
/**
* @dev Creates a Kydy sale.
*/
function createSaleAuction(
uint256 _kydyId,
uint256 _price
)
external
whenNotPaused
{
require(_owns(msg.sender, _kydyId));
require(!isCreating(_kydyId));
_approve(_kydyId, saleAuction);
saleAuction.createAuction(
_kydyId,
_price,
msg.sender
);
}
/**
* @dev Creates a synthesis auction.
*/
function createSynthesizingAuction(
uint256 _kydyId,
uint256 _price
)
external
whenNotPaused
{
require(_owns(msg.sender, _kydyId));
require(isReadyToSynthesize(_kydyId));
_approve(_kydyId, synthesizingAuction);
synthesizingAuction.createAuction(
_kydyId,
_price,
msg.sender
);
}
/**
* @dev After bidding for a synthesis auction is accepted, this starts the actual synthesis process.
* @param _yangId ID of the yang Kydy on the synthesis auction.
* @param _yinId ID of the yin Kydy owned by the bidder.
*/
function bidOnSynthesizingAuction(
uint256 _yangId,
uint256 _yinId
)
external
payable
whenNotPaused
{
require(_owns(msg.sender, _yinId));
require(isReadyToSynthesize(_yinId));
require(_canSynthesizeWithViaAuction(_yinId, _yangId));
uint256 currentPrice = synthesizingAuction.getCurrentPrice(_yangId);
require (msg.value >= currentPrice + autoCreationFee);
synthesizingAuction.bid.value(msg.value - autoCreationFee)(_yangId);
_synthesizeWith(uint32(_yinId), uint32(_yangId));
}
/**
* @dev Cancels a sale and returns the Kydy back to the owner.
* @param _kydyId ID of the Kydy on sale that the owner wishes to cancel.
*/
function cancelSaleAuction(
uint256 _kydyId
)
external
whenNotPaused
{
// Checks if the Kydy is in auction.
require(_owns(saleAuction, _kydyId));
// Gets the seller of the Kydy.
(address seller,,) = saleAuction.getAuction(_kydyId);
// Checks that the caller is the real seller.
require(msg.sender == seller);
// Cancels the sale auction of this kydy by it's seller's request.
saleAuction.cancelAuction(_kydyId, msg.sender);
}
/**
* @dev Cancels an synthesis auction.
* @param _kydyId ID of the Kydy on the synthesis auction.
*/
function cancelSynthesizingAuction(
uint256 _kydyId
)
external
whenNotPaused
{
require(_owns(synthesizingAuction, _kydyId));
(address seller,,) = synthesizingAuction.getAuction(_kydyId);
require(msg.sender == seller);
synthesizingAuction.cancelAuction(_kydyId, msg.sender);
}
/**
* @dev Transfers the balance.
*/
function withdrawAuctionBalances() external onlyCLevel {
saleAuction.withdrawBalance();
synthesizingAuction.withdrawBalance();
}
}
|
contract KydyAuction is KydySynthesis {
/**
* @dev The address of the Auction contract which handles ALL sales of Kydys, both user-generated and Generation 0.
*/
SaleAuction public saleAuction;
/**
* @dev The address of another Auction contract which handles synthesis auctions.
*/
SynthesizingAuction public synthesizingAuction;
/**
* @dev Sets the address for the sales auction. Only CEO may call this function.
* @param _address The address of the sale contract.
*/
function setSaleAuctionAddress(address _address) external onlyCEO {
SaleAuction candidateContract = SaleAuction(_address);
// Verifies that the contract is correct
require(candidateContract.isSaleAuction());
// Sets the new sale auction contract address.
saleAuction = candidateContract;
}
/**
* @dev Sets the address to the synthesis auction. Only CEO may call this function.
* @param _address The address of the synthesis contract.
*/
function setSynthesizingAuctionAddress(address _address) external onlyCEO {
SynthesizingAuction candidateContract = SynthesizingAuction(_address);
require(candidateContract.isSynthesizingAuction());
synthesizingAuction = candidateContract;
}
/**
* @dev Creates a Kydy sale.
*/
function createSaleAuction(
uint256 _kydyId,
uint256 _price
)
external
whenNotPaused
{
require(_owns(msg.sender, _kydyId));
require(!isCreating(_kydyId));
_approve(_kydyId, saleAuction);
saleAuction.createAuction(
_kydyId,
_price,
msg.sender
);
}
/**
* @dev Creates a synthesis auction.
*/
function createSynthesizingAuction(
uint256 _kydyId,
uint256 _price
)
external
whenNotPaused
{
require(_owns(msg.sender, _kydyId));
require(isReadyToSynthesize(_kydyId));
_approve(_kydyId, synthesizingAuction);
synthesizingAuction.createAuction(
_kydyId,
_price,
msg.sender
);
}
/**
* @dev After bidding for a synthesis auction is accepted, this starts the actual synthesis process.
* @param _yangId ID of the yang Kydy on the synthesis auction.
* @param _yinId ID of the yin Kydy owned by the bidder.
*/
function bidOnSynthesizingAuction(
uint256 _yangId,
uint256 _yinId
)
external
payable
whenNotPaused
{
require(_owns(msg.sender, _yinId));
require(isReadyToSynthesize(_yinId));
require(_canSynthesizeWithViaAuction(_yinId, _yangId));
uint256 currentPrice = synthesizingAuction.getCurrentPrice(_yangId);
require (msg.value >= currentPrice + autoCreationFee);
synthesizingAuction.bid.value(msg.value - autoCreationFee)(_yangId);
_synthesizeWith(uint32(_yinId), uint32(_yangId));
}
/**
* @dev Cancels a sale and returns the Kydy back to the owner.
* @param _kydyId ID of the Kydy on sale that the owner wishes to cancel.
*/
function cancelSaleAuction(
uint256 _kydyId
)
external
whenNotPaused
{
// Checks if the Kydy is in auction.
require(_owns(saleAuction, _kydyId));
// Gets the seller of the Kydy.
(address seller,,) = saleAuction.getAuction(_kydyId);
// Checks that the caller is the real seller.
require(msg.sender == seller);
// Cancels the sale auction of this kydy by it's seller's request.
saleAuction.cancelAuction(_kydyId, msg.sender);
}
/**
* @dev Cancels an synthesis auction.
* @param _kydyId ID of the Kydy on the synthesis auction.
*/
function cancelSynthesizingAuction(
uint256 _kydyId
)
external
whenNotPaused
{
require(_owns(synthesizingAuction, _kydyId));
(address seller,,) = synthesizingAuction.getAuction(_kydyId);
require(msg.sender == seller);
synthesizingAuction.cancelAuction(_kydyId, msg.sender);
}
/**
* @dev Transfers the balance.
*/
function withdrawAuctionBalances() external onlyCLevel {
saleAuction.withdrawBalance();
synthesizingAuction.withdrawBalance();
}
}
| 71,396
|
3
|
// {qRTok} The min value of total supply to use for redemption throttling The redemption capacity is always at least maxRedemptionChargeredemptionVirtualSupply
|
uint256 public redemptionVirtualSupply;
|
uint256 public redemptionVirtualSupply;
| 31,501
|
6
|
// xvalue -> yvaule -> address
|
mapping(uint256 => mapping(uint256 => address)) remintStateMap;
|
mapping(uint256 => mapping(uint256 => address)) remintStateMap;
| 10,084
|
102
|
// return 0 if exp(x) is tiny, using MIN_POWER = int(mp.floor(mp.log(mpf(1) / ONE)ONE))
|
if (x <= -818323753292969962227)
return 0;
|
if (x <= -818323753292969962227)
return 0;
| 20,459
|
120
|
// Number of assets acquired by the FrAactionHub
|
uint256 public numberOfAssets;
|
uint256 public numberOfAssets;
| 9,599
|
0
|
// Index tokens from 1
|
_tokenIdCounter.increment();
|
_tokenIdCounter.increment();
| 43,406
|
7
|
// sets nominal value of newly issued shares in euro, used to withdraw share capital to Nominee
|
uint256 public SHARE_NOMINAL_VALUE_EUR_ULPS;
|
uint256 public SHARE_NOMINAL_VALUE_EUR_ULPS;
| 19,892
|
37
|
// Calculate rent
|
uint256 rentalCostPerBlock = _getRentalPricePerBlock(_tokenId);
uint256 rentalCost = _numberOfBlocks * rentalCostPerBlock;
require(msg.value == rentalCost, "Frame: Incorrect payment");
|
uint256 rentalCostPerBlock = _getRentalPricePerBlock(_tokenId);
uint256 rentalCost = _numberOfBlocks * rentalCostPerBlock;
require(msg.value == rentalCost, "Frame: Incorrect payment");
| 39,976
|
20
|
// ================================ amount of shares for each address (scaled number)
|
mapping(address => uint256) internal tokenBalanceLedger_ ;
mapping(address => uint256) internal mintingDepositsOf_;
mapping(address => uint256) internal amountCirculated_;
mapping(address => uint256) internal taxesFeeTotalWithdrawn_;
mapping(address => uint256) internal taxesPreviousWithdrawn_;
|
mapping(address => uint256) internal tokenBalanceLedger_ ;
mapping(address => uint256) internal mintingDepositsOf_;
mapping(address => uint256) internal amountCirculated_;
mapping(address => uint256) internal taxesFeeTotalWithdrawn_;
mapping(address => uint256) internal taxesPreviousWithdrawn_;
| 16,534
|
70
|
// If no KCory exists, mint it 1:1 to the amount put in
|
if (totalShares == 0 || totalCory == 0) {
_mint(msg.sender, _amount);
}
|
if (totalShares == 0 || totalCory == 0) {
_mint(msg.sender, _amount);
}
| 36,584
|
23
|
// returns crowdsale min funding in Eth, low res
|
function fundingMinInEth() constant returns (uint256 fundingMinimumInEth) {
fundingMinimumInEth = safeDiv(fundingMinInWei,1 ether);
}
|
function fundingMinInEth() constant returns (uint256 fundingMinimumInEth) {
fundingMinimumInEth = safeDiv(fundingMinInWei,1 ether);
}
| 11,998
|
13
|
// Use to get the Permission flag related the `this` contract return Array of permission flags/
|
function getPermissions() public view returns(bytes32[]) {
bytes32[] memory allPermissions = new bytes32[](1);
allPermissions[0] = CHANGE_PERMISSION;
return allPermissions;
}
|
function getPermissions() public view returns(bytes32[]) {
bytes32[] memory allPermissions = new bytes32[](1);
allPermissions[0] = CHANGE_PERMISSION;
return allPermissions;
}
| 30,125
|
45
|
// SafeMath Math operations with safety checks that throw on error SafeMath adapted for uint96 /
|
library SafeMathUint96 {
function mul(uint96 a, uint96 b) internal pure returns (uint96) {
uint96 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint96 a, uint96 b) internal pure returns (uint96) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint96 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint96 a, uint96 b) internal pure returns (uint96) {
assert(b <= a);
return a - b;
}
function add(uint96 a, uint96 b) internal pure returns (uint96) {
uint96 c = a + b;
assert(c >= a);
return c;
}
}
|
library SafeMathUint96 {
function mul(uint96 a, uint96 b) internal pure returns (uint96) {
uint96 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint96 a, uint96 b) internal pure returns (uint96) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint96 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint96 a, uint96 b) internal pure returns (uint96) {
assert(b <= a);
return a - b;
}
function add(uint96 a, uint96 b) internal pure returns (uint96) {
uint96 c = a + b;
assert(c >= a);
return c;
}
}
| 47,174
|
174
|
// the base uri for the token
|
string public baseURI;
mapping(address => bool) private _whitelisted;
mapping(address => bool) private _minted;
|
string public baseURI;
mapping(address => bool) private _whitelisted;
mapping(address => bool) private _minted;
| 18,782
|
69
|
// sets the contract address of the X Droids contract, /
|
function setXDroidsContract(address xDroidsAddressParam) external onlyOwner {
if (xDroidsAddressParam == address(0)) {
revert NullAddressParameter();
}
if (xDroidsContractAddress != address(0)) {
revert XDroidAddressChange();
}
xDroidsContractAddress = xDroidsAddressParam;
emit XDroidContractSet(xDroidsAddressParam);
}
|
function setXDroidsContract(address xDroidsAddressParam) external onlyOwner {
if (xDroidsAddressParam == address(0)) {
revert NullAddressParameter();
}
if (xDroidsContractAddress != address(0)) {
revert XDroidAddressChange();
}
xDroidsContractAddress = xDroidsAddressParam;
emit XDroidContractSet(xDroidsAddressParam);
}
| 17,513
|
147
|
// Tells the address of the owner return the address of the owner/
|
function proxyOwner() public view returns (address owner) {
bytes32 position = proxyOwnerPosition;
assembly {
owner := sload(position)
}
}
|
function proxyOwner() public view returns (address owner) {
bytes32 position = proxyOwnerPosition;
assembly {
owner := sload(position)
}
}
| 9,215
|
17
|
// Calculate the available TWAP interval.
|
uint256 availableTwapInterval = block.timestamp - oldestAvailableAge;
|
uint256 availableTwapInterval = block.timestamp - oldestAvailableAge;
| 41,138
|
138
|
// /
|
uint pricePerShare = CURVE_POOL.get_virtual_price();
uint shares = bal.mul(MUL).mul(1e18).div(pricePerShare);
uint min = shares.mul(SLIP_MAX - slip) / SLIP_MAX;
ZAP.add_liquidity(amounts, min);
|
uint pricePerShare = CURVE_POOL.get_virtual_price();
uint shares = bal.mul(MUL).mul(1e18).div(pricePerShare);
uint min = shares.mul(SLIP_MAX - slip) / SLIP_MAX;
ZAP.add_liquidity(amounts, min);
| 4,758
|
100
|
// If there were less eth blocks passed in time than expected
|
if (ethBlocksSinceLastDifficultyPeriod < targetEthBlocksPerDiffPeriod) {
|
if (ethBlocksSinceLastDifficultyPeriod < targetEthBlocksPerDiffPeriod) {
| 36,550
|
523
|
// increase the total borrows by the compounded interest
|
reserve.increaseTotalBorrowsStableAndUpdateAverageRate(
_balanceIncrease,
user.stableBorrowRate
);
|
reserve.increaseTotalBorrowsStableAndUpdateAverageRate(
_balanceIncrease,
user.stableBorrowRate
);
| 16,395
|
17
|
// for RES in range(NUM_RESOURCES)
|
counts[$$(RES)] = _blockStats[$$(RES)].count;
scores[$$(RES)] = _blockStats[$$(RES)].score;
productions[$$(RES)] = _blockStats[$$(RES)].production;
|
counts[$$(RES)] = _blockStats[$$(RES)].count;
scores[$$(RES)] = _blockStats[$$(RES)].score;
productions[$$(RES)] = _blockStats[$$(RES)].production;
| 15,424
|
52
|
// Checks if left Exp <= right Exp. /
|
function lessThanOrEqualExp(Exp memory left, Exp memory right) pure internal returns (bool) {
return left.mantissa <= right.mantissa;
}
|
function lessThanOrEqualExp(Exp memory left, Exp memory right) pure internal returns (bool) {
return left.mantissa <= right.mantissa;
}
| 871
|
152
|
// Behavior has changed to match OpenZeppelin's `ERC20Burnable.burn(uint256 amount)`/Destoys `amount` tokens from `msg.sender`, reducing the total supply.// Emits a `Transfer` event with `to` set to the zero address./ Requirements:/ - `account` must have at least `amount` tokens.
|
function mint(uint256 _value) external returns (bool ok);
|
function mint(uint256 _value) external returns (bool ok);
| 32,890
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.