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 |
|---|---|---|---|---|
2 | // This creates an array with all balances | mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
| mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
| 12,422 |
65 | // sin compras desde referidos se agrega bono de referencia nuevamente al reparto global de dividendos. | _dividends = SafeMath.add(_dividends, _referralBonus);
_fee = _dividends * magnitude;
| _dividends = SafeMath.add(_dividends, _referralBonus);
_fee = _dividends * magnitude;
| 9,733 |
318 | // Initializes a new Comptroller V2/_asset The asset to disburse to users/_measure The token to use to measure a users portion/_dripRatePerSecond The amount of the asset to drip each second | function initialize (
IERC20Upgradeable _asset,
IERC20Upgradeable _measure,
uint256 _dripRatePerSecond
| function initialize (
IERC20Upgradeable _asset,
IERC20Upgradeable _measure,
uint256 _dripRatePerSecond
| 36,055 |
85 | // Encodes message for transferring ERC20 with token info. Returns encoded message. / | function encodeTransferErc20AndTokenInfoMessage(
address token,
address receiver,
uint256 amount,
uint256 totalSupply,
Erc20TokenInfo memory tokenInfo
| function encodeTransferErc20AndTokenInfoMessage(
address token,
address receiver,
uint256 amount,
uint256 totalSupply,
Erc20TokenInfo memory tokenInfo
| 13,754 |
72 | // Delegates the current call to the address returned by `_implementation()`.This function does not return to its internall call site, it will return directly to the external caller. / | function _fallback() internal {
_beforeFallback();
_delegate(_implementation());
}
| function _fallback() internal {
_beforeFallback();
_delegate(_implementation());
}
| 4,683 |
58 | // Return the current price for tiles | function tilePrice() view public returns(uint256) {
return (BYZANTINE_TILE_STARTING_PRICE + byzantineTileSalesCount.add(1).mul(INCREASE_RATE));
}
| function tilePrice() view public returns(uint256) {
return (BYZANTINE_TILE_STARTING_PRICE + byzantineTileSalesCount.add(1).mul(INCREASE_RATE));
}
| 17,608 |
131 | // ... //Get the adjusted liquidation spread for some market pair. This is equal to the globalliquidation spread multiplied by (1 + spreadPremium) for each of the two markets. heldMarketIdThe market for which the account has collateralowedMarketIdThe market for which the account has borrowed tokensreturn The adjusted liquidation spread / | function getLiquidationSpreadForPair(
| function getLiquidationSpreadForPair(
| 59,128 |
54 | // Creator can extend the lock time of the secret,as long as the previous lock time is in the future data the system's data struct instance identifier the identifier of the secret lockTime new lock time for the relockedsecret handlingFee new handling fee for the relocked secret reward new reward for the relocked secret lifeToken the LIFE token used for payment handlingreturn bool indicating that the relock was successful / | function relockSecret(
Datas.Data storage data,
bytes32 identifier,
uint256 lockTime,
uint256 handlingFee,
uint256 reward,
IERC20 lifeToken
| function relockSecret(
Datas.Data storage data,
bytes32 identifier,
uint256 lockTime,
uint256 handlingFee,
uint256 reward,
IERC20 lifeToken
| 18,873 |
60 | // Safety measure - this should never trigger | require(
totalDrawn[_beneficiary] <= vestedAmount[_beneficiary],
"VestingContract::_drawDown: Safety Mechanism - Drawn exceeded Amount Vested"
);
| require(
totalDrawn[_beneficiary] <= vestedAmount[_beneficiary],
"VestingContract::_drawDown: Safety Mechanism - Drawn exceeded Amount Vested"
);
| 67,534 |
59 | // {IERC165} interfaces can also be queried via the registry./ Sets `newManager` as the manager for `account`. A manager of anaccount is able to set interface implementers for it. By default, each account is its own manager. Passing a value of `0x0` in`newManager` will reset the manager to this initial state. Emits a {ManagerChanged} event. Requirements: - the caller must be the current manager for `account`. / | function setManager(address account, address newManager) external;
| function setManager(address account, address newManager) external;
| 13,216 |
308 | // get chope value | (,uint chop,) = manager.end().cat().ilks(collateralType);
uint biteIlk = mul(chop, daiDebt) / currentPriceFeedValue;
| (,uint chop,) = manager.end().cat().ilks(collateralType);
uint biteIlk = mul(chop, daiDebt) / currentPriceFeedValue;
| 81,416 |
58 | // Calculate liquidity and equivalent token amounts of limit order. / | function getLimitPosition()
public
view
returns (
uint128 liquidity,
uint256 amount0,
uint256 amount1
)
| function getLimitPosition()
public
view
returns (
uint128 liquidity,
uint256 amount0,
uint256 amount1
)
| 45,027 |
69 | // Since _startingMultiplier and _endingMultiplier are in 6 decimalsNeed to divide multiplier by _MULTIPLIER_DIVISOR / | return multiplier.div(_MULTIPLIER_DIVISOR);
| return multiplier.div(_MULTIPLIER_DIVISOR);
| 16,485 |
27 | // Creates {amount} tokens and assigns them to {account}, increasing the total supply. | function _minted(address account, uint256 amount) internal virtual returns (bool)
{
if ((account == address(0)) || (amount == uint256(0)))
return false;
mTotalSupply += amount;
mDataBalance[account] += amount;
emit Minted(account, amount);
return true;
}
| function _minted(address account, uint256 amount) internal virtual returns (bool)
{
if ((account == address(0)) || (amount == uint256(0)))
return false;
mTotalSupply += amount;
mDataBalance[account] += amount;
emit Minted(account, amount);
return true;
}
| 17,081 |
13 | // The DMEX Fee Contract | contract DMEX_Fee_Contract {
address DMEX_CONTRACT = address(0x2101e480e22C953b37b9D0FE6551C1354Fe705E6);
address DMEX_TOKEN = address(0x6263e260fF6597180c9538c69aF8284EDeaCEC80);
address TOKEN_ETH = address(0x0000000000000000000000000000000000000000);
address TOKEN_DAI = address(0x6B175474E89094C44Da98b954EedeAC495271d0F);
address TOKEN_BTC = address(0x5228a22e72ccC52d415EcFd199F99D0665E7733b);
address uniswapRouter = address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
address payable FEE_ACCOUNT;
address owner;
uint256 fee_account_share = 618e15;
uint256 uniswap_share = 382e15;
function extractFees() public {
uint256 fee_share;
uint256 us_share;
// extract eth
uint256 eth_balance = DMEX(DMEX_CONTRACT).availableBalanceOf(TOKEN_ETH, address(this));
DMEX(DMEX_CONTRACT).withdraw(TOKEN_ETH, eth_balance);
fee_share = eth_balance * fee_account_share / 1e18;
us_share = eth_balance - fee_share;
require(FEE_ACCOUNT.send(fee_share), "Error: eth send failed");
// swap eth for DMEX Token
address[] memory path = new address[](2);
path[0] = UniswapV2ExchangeInterface(uniswapRouter).WETH();
path[1] = DMEX_TOKEN;
uint[] memory amounts = UniswapV2ExchangeInterface(uniswapRouter).swapExactETHForTokens.value(us_share)(1, path, address(this), 2**256 - 1);
uint token_bought = amounts[1];
DMEXTokenInterface(DMEX_TOKEN).burn(token_bought);
}
constructor(
address payable initialFeeAccount
) public {
owner = msg.sender;
FEE_ACCOUNT = initialFeeAccount;
}
/** Safe Math **/
// Safe Multiply Function - prevents integer overflow
function safeMul(uint a, uint b) internal pure returns (uint) {
uint c = a * b;
assert(a == 0 || c / a == b);
return c;
}
// Safe Subtraction Function - prevents integer overflow
function safeSub(uint a, uint b) internal pure returns (uint) {
assert(b <= a);
return a - b;
}
// Safe Addition Function - prevents integer overflow
function safeAdd(uint a, uint b) internal pure returns (uint) {
uint c = a + b;
assert(c>=a && c>=b);
return c;
}
} | contract DMEX_Fee_Contract {
address DMEX_CONTRACT = address(0x2101e480e22C953b37b9D0FE6551C1354Fe705E6);
address DMEX_TOKEN = address(0x6263e260fF6597180c9538c69aF8284EDeaCEC80);
address TOKEN_ETH = address(0x0000000000000000000000000000000000000000);
address TOKEN_DAI = address(0x6B175474E89094C44Da98b954EedeAC495271d0F);
address TOKEN_BTC = address(0x5228a22e72ccC52d415EcFd199F99D0665E7733b);
address uniswapRouter = address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
address payable FEE_ACCOUNT;
address owner;
uint256 fee_account_share = 618e15;
uint256 uniswap_share = 382e15;
function extractFees() public {
uint256 fee_share;
uint256 us_share;
// extract eth
uint256 eth_balance = DMEX(DMEX_CONTRACT).availableBalanceOf(TOKEN_ETH, address(this));
DMEX(DMEX_CONTRACT).withdraw(TOKEN_ETH, eth_balance);
fee_share = eth_balance * fee_account_share / 1e18;
us_share = eth_balance - fee_share;
require(FEE_ACCOUNT.send(fee_share), "Error: eth send failed");
// swap eth for DMEX Token
address[] memory path = new address[](2);
path[0] = UniswapV2ExchangeInterface(uniswapRouter).WETH();
path[1] = DMEX_TOKEN;
uint[] memory amounts = UniswapV2ExchangeInterface(uniswapRouter).swapExactETHForTokens.value(us_share)(1, path, address(this), 2**256 - 1);
uint token_bought = amounts[1];
DMEXTokenInterface(DMEX_TOKEN).burn(token_bought);
}
constructor(
address payable initialFeeAccount
) public {
owner = msg.sender;
FEE_ACCOUNT = initialFeeAccount;
}
/** Safe Math **/
// Safe Multiply Function - prevents integer overflow
function safeMul(uint a, uint b) internal pure returns (uint) {
uint c = a * b;
assert(a == 0 || c / a == b);
return c;
}
// Safe Subtraction Function - prevents integer overflow
function safeSub(uint a, uint b) internal pure returns (uint) {
assert(b <= a);
return a - b;
}
// Safe Addition Function - prevents integer overflow
function safeAdd(uint a, uint b) internal pure returns (uint) {
uint c = a + b;
assert(c>=a && c>=b);
return c;
}
} | 77,587 |
13 | // Allows to get the address for a new proxy contact created via `createProxyWithNonce`/This method is only meant for address calculation purpose when you use an initializer that would revert,/therefore the response is returned with a revert. When calling this method set `from` to the address of the proxy factory./_singleton Address of singleton contract./initializer Payload for message call sent to new proxy contract./saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract. | function calculateCreateProxyWithNonceAddress(
address _singleton,
bytes calldata initializer,
uint256 saltNonce
| function calculateCreateProxyWithNonceAddress(
address _singleton,
bytes calldata initializer,
uint256 saltNonce
| 7,721 |
3,150 | // 1577 | entry "extorsively" : ENG_ADVERB
| entry "extorsively" : ENG_ADVERB
| 22,413 |
5 | // Mainnet address of the KyberNetworkProxy contract. | IKyberNetworkProxy private immutable KYBER_NETWORK_PROXY;
constructor(AdapterAddresses memory addresses)
public
| IKyberNetworkProxy private immutable KYBER_NETWORK_PROXY;
constructor(AdapterAddresses memory addresses)
public
| 36,958 |
55 | // This contract now has the funds requested. | uint256 amountFL = amounts[0];
uint256 amountFLWithFees = amounts[0] + premiums[0];
address tokenFL = assets[0];
if (operation == 0) {
longOperation(amountFL, amountFLWithFees, params);
} else if (operation == 1) {
| uint256 amountFL = amounts[0];
uint256 amountFLWithFees = amounts[0] + premiums[0];
address tokenFL = assets[0];
if (operation == 0) {
longOperation(amountFL, amountFLWithFees, params);
} else if (operation == 1) {
| 8,830 |
81 | // WETH must be converted to Eth for Uniswap trade (Uniswap allows ERC20:ERC20 but most liquidity is on ETH:ERC20 markets) | _withdrawEther(amount);
require(address(this).balance >= amount, "buying from uniswap takes real Ether");
| _withdrawEther(amount);
require(address(this).balance >= amount, "buying from uniswap takes real Ether");
| 1,986 |
106 | // Claim Crowns for all tokens owned by the sender/This function will run out of gas if you have too much Based Stats! If/ this is a concern, you should use claimRangeForOwner and claim Crowns in batches. | function claimAllForOwner() external {
uint256 tokenBalanceOwner = basedContract.balanceOf(_msgSender());
// Checks
require(tokenBalanceOwner > 0, "NO_TOKENS_OWNED");
// i < tokenBalanceOwner because tokenBalanceOwner is 1-indexed
for (uint256 i = 0; i < tokenBalanceOwner; i++) {
// Further Checks, Effects, and Interactions are contained within
// the _claim() function
_claim(
basedContract.tokenOfOwnerByIndex(_msgSender(), i),
_msgSender()
);
}
}
| function claimAllForOwner() external {
uint256 tokenBalanceOwner = basedContract.balanceOf(_msgSender());
// Checks
require(tokenBalanceOwner > 0, "NO_TOKENS_OWNED");
// i < tokenBalanceOwner because tokenBalanceOwner is 1-indexed
for (uint256 i = 0; i < tokenBalanceOwner; i++) {
// Further Checks, Effects, and Interactions are contained within
// the _claim() function
_claim(
basedContract.tokenOfOwnerByIndex(_msgSender(), i),
_msgSender()
);
}
}
| 32,001 |
0 | // Mapping from token ID to seal status (0 ~ 1) | mapping(uint256 => bool) public isTokenUnsealed;
| mapping(uint256 => bool) public isTokenUnsealed;
| 19,788 |
25 | // An event indicating that a proposal has been accepted for votingcontractAddress The address of the PolicyVotes contract instance. / | event VoteStart(PolicyVotes indexed contractAddress);
| event VoteStart(PolicyVotes indexed contractAddress);
| 9,964 |
45 | // toEthSignedMessageHash prefix a bytes32 value with "\x19Ethereum Signed Message:"and hash the result / | function toEthSignedMessageHash(bytes32 hash)
internal
pure
returns (bytes32)
| function toEthSignedMessageHash(bytes32 hash)
internal
pure
returns (bytes32)
| 41,252 |
38 | // Standard ERC20 tokenImplementation of the basic standard token. This implementation emits additional Approval events, allowing applications to reconstruct the allowance status forall accounts just by listening to said events. Note that this isn't required by the specification, and othercompliant implementations may not do it. / | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
uint256 private _totalSupply;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
/**
* @dev Gets the balance of the specified address.
* @param owner The address to query the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address owner) public view returns (uint256) {
return _balances[owner];
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param owner address The address which owns the funds.
* @param spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address owner, address spender) public view returns (uint256) {
return _allowed[owner][spender];
}
/**
* @dev Transfer token for a specified address
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function transfer(address to, uint256 value) public returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
*/
function approve(address spender, uint256 value) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
/**
* @dev Transfer tokens from one address to another.
* Note that while this function emits an Approval event, this is not required as per the specification,
* and other compliant implementations may not emit the event.
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 the amount of tokens to be transferred
*/
function transferFrom(address from, address to, uint256 value) public returns (bool) {
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
_transfer(from, to, value);
emit Approval(from, msg.sender, _allowed[from][msg.sender]);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* Emits an Approval event.
* @param spender The address which will spend the funds.
* @param addedValue The amount of tokens to increase the allowance by.
*/
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = _allowed[msg.sender][spender].add(addedValue);
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* Emits an Approval event.
* @param spender The address which will spend the funds.
* @param subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = _allowed[msg.sender][spender].sub(subtractedValue);
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
/**
* @dev Transfer token for a specified addresses
* @param from The address to transfer from.
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function _transfer(address from, address to, uint256 value) internal {
require(to != address(0));
_balances[from] = _balances[from].sub(value);
_balances[to] = _balances[to].add(value);
emit Transfer(from, to, value);
}
/**
* @dev Internal function that mints an amount of the token and assigns it to
* an account. This encapsulates the modification of balances such that the
* proper events are emitted.
* @param account The account that will receive the created tokens.
* @param value The amount that will be created.
*/
function _mint(address account, uint256 value) internal {
require(account != address(0));
_totalSupply = _totalSupply.add(value);
_balances[account] = _balances[account].add(value);
emit Transfer(address(0), account, value);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account.
* @param account The account whose tokens will be burnt.
* @param value The amount that will be burnt.
*/
function _burn(address account, uint256 value) internal {
require(account != address(0));
_totalSupply = _totalSupply.sub(value);
_balances[account] = _balances[account].sub(value);
emit Transfer(account, address(0), value);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account, deducting from the sender's allowance for said account. Uses the
* internal burn function.
* Emits an Approval event (reflecting the reduced allowance).
* @param account The account whose tokens will be burnt.
* @param value The amount that will be burnt.
*/
function _burnFrom(address account, uint256 value) internal {
_allowed[account][msg.sender] = _allowed[account][msg.sender].sub(value);
_burn(account, value);
emit Approval(account, msg.sender, _allowed[account][msg.sender]);
}
}
| contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
uint256 private _totalSupply;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
/**
* @dev Gets the balance of the specified address.
* @param owner The address to query the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address owner) public view returns (uint256) {
return _balances[owner];
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param owner address The address which owns the funds.
* @param spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address owner, address spender) public view returns (uint256) {
return _allowed[owner][spender];
}
/**
* @dev Transfer token for a specified address
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function transfer(address to, uint256 value) public returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
*/
function approve(address spender, uint256 value) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
/**
* @dev Transfer tokens from one address to another.
* Note that while this function emits an Approval event, this is not required as per the specification,
* and other compliant implementations may not emit the event.
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 the amount of tokens to be transferred
*/
function transferFrom(address from, address to, uint256 value) public returns (bool) {
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
_transfer(from, to, value);
emit Approval(from, msg.sender, _allowed[from][msg.sender]);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* Emits an Approval event.
* @param spender The address which will spend the funds.
* @param addedValue The amount of tokens to increase the allowance by.
*/
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = _allowed[msg.sender][spender].add(addedValue);
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* Emits an Approval event.
* @param spender The address which will spend the funds.
* @param subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = _allowed[msg.sender][spender].sub(subtractedValue);
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
/**
* @dev Transfer token for a specified addresses
* @param from The address to transfer from.
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function _transfer(address from, address to, uint256 value) internal {
require(to != address(0));
_balances[from] = _balances[from].sub(value);
_balances[to] = _balances[to].add(value);
emit Transfer(from, to, value);
}
/**
* @dev Internal function that mints an amount of the token and assigns it to
* an account. This encapsulates the modification of balances such that the
* proper events are emitted.
* @param account The account that will receive the created tokens.
* @param value The amount that will be created.
*/
function _mint(address account, uint256 value) internal {
require(account != address(0));
_totalSupply = _totalSupply.add(value);
_balances[account] = _balances[account].add(value);
emit Transfer(address(0), account, value);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account.
* @param account The account whose tokens will be burnt.
* @param value The amount that will be burnt.
*/
function _burn(address account, uint256 value) internal {
require(account != address(0));
_totalSupply = _totalSupply.sub(value);
_balances[account] = _balances[account].sub(value);
emit Transfer(account, address(0), value);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account, deducting from the sender's allowance for said account. Uses the
* internal burn function.
* Emits an Approval event (reflecting the reduced allowance).
* @param account The account whose tokens will be burnt.
* @param value The amount that will be burnt.
*/
function _burnFrom(address account, uint256 value) internal {
_allowed[account][msg.sender] = _allowed[account][msg.sender].sub(value);
_burn(account, value);
emit Approval(account, msg.sender, _allowed[account][msg.sender]);
}
}
| 8,174 |
1 | // State Variables // Constructor / | {}
}
| {}
}
| 13,911 |
48 | // Event for token purchase loggingpurchaser who paid for the tokensbeneficiary who got the tokensvalue weis paid for purchaseamount amount of tokens purchased/ | event TokenPurchase(
address indexed purchaser,
address indexed beneficiary,
uint256 value,
uint256 amount,
uint256 burned
);
| event TokenPurchase(
address indexed purchaser,
address indexed beneficiary,
uint256 value,
uint256 amount,
uint256 burned
);
| 40,860 |
12 | // Allow player to attack boss. | if (bigBoss.hp < player.attackDamage) {
bigBoss.hp = 0;
} else {
| if (bigBoss.hp < player.attackDamage) {
bigBoss.hp = 0;
} else {
| 18,213 |
11 | // Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:spender The address which will spend the funds.value The amount of tokens to be spent./ | function approve(address spender, uint256 value) public returns (bool) {
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
| function approve(address spender, uint256 value) public returns (bool) {
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
| 27,047 |
26 | // Returns product associated with given productId | function getProductType(string memory productId)
public
view
returns (Product memory)
| function getProductType(string memory productId)
public
view
returns (Product memory)
| 36,027 |
30 | // deduct hub/user wei/tokens from total channel balances | channel.weiBalances[2] = channel.weiBalances[2].sub(channel.weiBalances[0]).sub(channel.weiBalances[1]);
channel.tokenBalances[2] = channel.tokenBalances[2].sub(channel.tokenBalances[0]).sub(channel.tokenBalances[1]);
| channel.weiBalances[2] = channel.weiBalances[2].sub(channel.weiBalances[0]).sub(channel.weiBalances[1]);
channel.tokenBalances[2] = channel.tokenBalances[2].sub(channel.tokenBalances[0]).sub(channel.tokenBalances[1]);
| 1,904 |
5 | // Grab tokens and send to caller If the _amount[i] is 0, then transfer all the tokens _tokens List of tokens _amounts Amount of each token to send / | function _rescueTokens(address[] calldata _tokens, uint256[] memory _amounts)
internal
virtual
| function _rescueTokens(address[] calldata _tokens, uint256[] memory _amounts)
internal
virtual
| 23,281 |
152 | // update balance of verifier | totalDepositedToSCAmount[token] = totalDepositedToSCAmount[token].safeSub(amount);
withdrawRequests[verifier][token] = withdrawRequests[verifier][token].safeSub(amount);
| totalDepositedToSCAmount[token] = totalDepositedToSCAmount[token].safeSub(amount);
withdrawRequests[verifier][token] = withdrawRequests[verifier][token].safeSub(amount);
| 34,682 |
50 | // Sweep the old balance, if any | address[] memory users = new address[](1);
users[0] = user;
_sweepTimelockBalances(users);
timelockTotalSupply = timelockTotalSupply.add(amount);
_timelockBalances[user] = _timelockBalances[user].add(amount);
_unlockTimestamps[user] = timestamp;
| address[] memory users = new address[](1);
users[0] = user;
_sweepTimelockBalances(users);
timelockTotalSupply = timelockTotalSupply.add(amount);
_timelockBalances[user] = _timelockBalances[user].add(amount);
_unlockTimestamps[user] = timestamp;
| 14,357 |
146 | // This stops an attack vector where a user stakes a lot of money then drops the debt requirement by staking less before the deadline to reduce the amount of debt they need to lock in |
require(
debtRequirement >= staker.debtSnapshot,
"Your new debt requiremen cannot be lower than last time"
);
staker.positionId = positionId;
staker.debtSnapshot = debtRequirement;
staker.balance = staker.balance.add(amount);
|
require(
debtRequirement >= staker.debtSnapshot,
"Your new debt requiremen cannot be lower than last time"
);
staker.positionId = positionId;
staker.debtSnapshot = debtRequirement;
staker.balance = staker.balance.add(amount);
| 46,699 |
16 | // get the erc-20 balance of this owner | uint256 balance = token.balanceOf(owner);
| uint256 balance = token.balanceOf(owner);
| 25,217 |
242 | // Resolve governance address from Vault contract, used to make assertionson protected functions in the Strategy. / | function governance() internal view returns (address) {
return IVault(vault).governance();
}
| function governance() internal view returns (address) {
return IVault(vault).governance();
}
| 70,547 |
33 | // Assigns a new address to act as the Banker. | function setBanker(address _newBK) external onlyManager {
require(_newBK != address(0));
bankManager = _newBK;
}
| function setBanker(address _newBK) external onlyManager {
require(_newBK != address(0));
bankManager = _newBK;
}
| 26,327 |
132 | // transfer token | pool.safeTransferFrom(provider, address(this), amount);
| pool.safeTransferFrom(provider, address(this), amount);
| 46,683 |
262 | // calculate spread fee by input quoteAssetAmount _quoteAssetAmount quoteAssetAmountreturn total tx fee / | function calcFee(Decimal.decimal calldata _quoteAssetAmount)
external
view
override
returns (Decimal.decimal memory)
| function calcFee(Decimal.decimal calldata _quoteAssetAmount)
external
view
override
returns (Decimal.decimal memory)
| 2,520 |
2 | // store candidatesFetch candidate | mapping(uint=>Condidate)public candidates;
uint256 public candidatesCount;
address owner;
| mapping(uint=>Condidate)public candidates;
uint256 public candidatesCount;
address owner;
| 10,789 |
277 | // set after end time has been changed once, prevents further changes to end timestamp | bool public genesisEndTimestampLocked;
| bool public genesisEndTimestampLocked;
| 10,682 |
10 | // The `ph` variable represents an instance of the IPriceHandler interface.This contract is used to handle the pricing logic of the tokens. / | IPriceHandler private ph;
| IPriceHandler private ph;
| 358 |
1 | // this function call should be free; check gas | return 'hello there amigo';
| return 'hello there amigo';
| 25,450 |
10 | // SENDS PERMISSION TO ALLOW OR NOT TO DISALLOW | function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external override {
require(deadline >= block.timestamp, 'UniswapV2: EXPIRED');
bytes32 digest = keccak256(
abi.encodePacked(
'\x19\x01',
DOMAIN_SEPARATOR,
keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline))
)
);
address recoveredAddress = ecrecover(digest, v, r, s);
require(recoveredAddress != address(0) && recoveredAddress == owner, 'UniswapV2: INVALID_SIGNATURE');
_approve(owner, spender, value);
}
| function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external override {
require(deadline >= block.timestamp, 'UniswapV2: EXPIRED');
bytes32 digest = keccak256(
abi.encodePacked(
'\x19\x01',
DOMAIN_SEPARATOR,
keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline))
)
);
address recoveredAddress = ecrecover(digest, v, r, s);
require(recoveredAddress != address(0) && recoveredAddress == owner, 'UniswapV2: INVALID_SIGNATURE');
_approve(owner, spender, value);
}
| 36,409 |
0 | // uint256 private price = 10000000000000000;0.01 Ether | uint256 private price = 90000000000000000; // 0.09 ETHER
| uint256 private price = 90000000000000000; // 0.09 ETHER
| 77,161 |
78 | // Allows the current owner to set the pendingOwner address./newOwner The address to transfer ownership to. | function transferOwnership(
address newOwner
)
public
override
onlyOwner
| function transferOwnership(
address newOwner
)
public
override
onlyOwner
| 15,997 |
94 | // Token Info | string private constant _name = 'MetaVault';
string private constant _symbol = '$MVT';
uint8 private constant _decimals = 9;
uint256 public constant InitialSupply= 1000000000000 * 10**_decimals;//equals 1 000 000 000 000 tokens
| string private constant _name = 'MetaVault';
string private constant _symbol = '$MVT';
uint8 private constant _decimals = 9;
uint256 public constant InitialSupply= 1000000000000 * 10**_decimals;//equals 1 000 000 000 000 tokens
| 16,483 |
11 | // Overriding the _transfer function to implement tax logic | function _transfer(address sender, address recipient, uint256 amount) internal virtual override {
require(amount > 0, "Amount must be greater than 0");
uint256 taxAmount = 0;
if (recipient == address(this)) {
// The transfer is a buy transaction (transfer to the contract address)
taxAmount = amount.mul(BUY_TAX_RATE).div(100); // Calculate the buy tax amount
super._transfer(sender, _devWallet, taxAmount); // Send the buy tax to the dev wallet
emit Buy(sender, amount, taxAmount, amount.sub(taxAmount)); // Emit the buy event with net amount
} else if (sender != owner() && recipient != owner() && sender != _devWallet) {
// The transfer is a sell transaction (transfer from any wallet other than the contract owner and dev wallet)
taxAmount = amount.mul(SELL_TAX_RATE).div(100); // Calculate the sell tax amount
super._transfer(sender, _burnWallet, taxAmount); // Send the sell tax to the burn wallet (not burned from total supply)
emit Sell(sender, amount, taxAmount, amount.sub(taxAmount)); // Emit the sell event with net amount
emit BurnTax(sender, taxAmount, amount.sub(taxAmount)); // Emit the burn tax event with net amount
}
super._transfer(sender, recipient, amount.sub(taxAmount)); // Transfer the remaining amount
}
| function _transfer(address sender, address recipient, uint256 amount) internal virtual override {
require(amount > 0, "Amount must be greater than 0");
uint256 taxAmount = 0;
if (recipient == address(this)) {
// The transfer is a buy transaction (transfer to the contract address)
taxAmount = amount.mul(BUY_TAX_RATE).div(100); // Calculate the buy tax amount
super._transfer(sender, _devWallet, taxAmount); // Send the buy tax to the dev wallet
emit Buy(sender, amount, taxAmount, amount.sub(taxAmount)); // Emit the buy event with net amount
} else if (sender != owner() && recipient != owner() && sender != _devWallet) {
// The transfer is a sell transaction (transfer from any wallet other than the contract owner and dev wallet)
taxAmount = amount.mul(SELL_TAX_RATE).div(100); // Calculate the sell tax amount
super._transfer(sender, _burnWallet, taxAmount); // Send the sell tax to the burn wallet (not burned from total supply)
emit Sell(sender, amount, taxAmount, amount.sub(taxAmount)); // Emit the sell event with net amount
emit BurnTax(sender, taxAmount, amount.sub(taxAmount)); // Emit the burn tax event with net amount
}
super._transfer(sender, recipient, amount.sub(taxAmount)); // Transfer the remaining amount
}
| 7,313 |
441 | // Is the registered ENS node identifying the licence contract. | bytes32 private _licenceNode;
| bytes32 private _licenceNode;
| 42,790 |
15 | // increment license count | NFTCount++;
emit ContractCreated(newNFT);
| NFTCount++;
emit ContractCreated(newNFT);
| 30,188 |
204 | // MasterChef is the master of Fruit. He can make Fruit and he is a fair guy. Note that it's ownable and the owner wields tremendous power. The ownership will be transferred to a governance smart contract once FRUIT is sufficiently distributed and the community can show to govern itself. Have fun reading it. Hopefully it's bug-free. God bless. | contract MasterChef is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do some fancy math here. Basically, any point in time, the amount of FRUITs
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accFruitPerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
// 1. The pool's `accFruitPerShare` (and `lastRewardBlock`) gets updated.
// 2. User receives the pending reward sent to his/her address.
// 3. User's `amount` gets updated.
// 4. User's `rewardDebt` gets updated.
}
// Info of each pool.
struct PoolInfo {
IERC20 lpToken; // Address of LP token contract.
uint256 allocPoint; // How many allocation points assigned to this pool. FRUITs to distribute per block.
uint256 lastRewardBlock; // Last block number that FRUITs distribution occurs.
uint256 accFruitPerShare; // Accumulated FRUITs per share, times 1e12. See below.
}
// The FRUIT TOKEN!
FruitToken public fruit;
// Dev address.
address public devaddr;
// FRUIT tokens created per block.
uint256 public fruitPerBlock = 100 ether;
// The migrator contract. It has a lot of power. Can only be set through governance (owner).
IMigratorChef public migrator;
// Info of each pool.
PoolInfo[] public poolInfo;
// Info of each user that stakes LP tokens.
mapping (uint256 => mapping (address => UserInfo)) public userInfo;
// Total allocation poitns. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint = 0;
// The block number when FRUIT mining starts.
uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
FruitToken _fruit,
uint256 _startBlock
) public {
fruit = _fruit;
devaddr = msg.sender;
startBlock = _startBlock;
}
function poolLength() external view returns (uint256) {
return poolInfo.length;
}
// Add a new lp to the pool. Can only be called by the owner.
// XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do.
function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(PoolInfo({
lpToken: _lpToken,
allocPoint: _allocPoint,
lastRewardBlock: lastRewardBlock,
accFruitPerShare: 0
}));
}
// Update the given pool's FRUIT allocation point. Can only be called by the owner.
function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);
poolInfo[_pid].allocPoint = _allocPoint;
}
// Set the migrator contract. Can only be called by the owner.
function setMigrator(IMigratorChef _migrator) public onlyOwner {
migrator = _migrator;
}
// Migrate lp token to another lp contract. Can be called by anyone. We trust that migrator contract is good.
function migrate(uint256 _pid) public {
require(address(migrator) != address(0), "migrate: no migrator");
PoolInfo storage pool = poolInfo[_pid];
IERC20 lpToken = pool.lpToken;
uint256 bal = lpToken.balanceOf(address(this));
lpToken.safeApprove(address(migrator), bal);
IERC20 newLpToken = migrator.migrate(lpToken);
require(bal == newLpToken.balanceOf(address(this)), "migrate: bad");
pool.lpToken = newLpToken;
}
// View function to see pending FRUITs on frontend.
function pendingFruit(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accFruitPerShare = pool.accFruitPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 fruitReward = multiplier.mul(fruitPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accFruitPerShare = accFruitPerShare.add(fruitReward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accFruitPerShare).div(1e12).sub(user.rewardDebt);
}
// Update reward variables for all pools. Be careful of gas spending!
function massUpdatePools() public {
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
}
function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) {
return _to.sub(_from);
}
// Update reward variables of the given pool to be up-to-date.
function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (lpSupply == 0) {
pool.lastRewardBlock = block.number;
return;
}
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 fruitReward = multiplier.mul(fruitPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
fruit.mint(devaddr, fruitReward.div(10));
fruit.mint(address(this), fruitReward);
pool.accFruitPerShare = pool.accFruitPerShare.add(fruitReward.mul(1e12).div(lpSupply));
pool.lastRewardBlock = block.number;
}
// Deposit LP tokens to MasterChef for FRUIT allocation.
function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accFruitPerShare).div(1e12).sub(user.rewardDebt);
if(pending > 0) {
safeFruitTransfer(msg.sender, pending);
}
}
if(_amount > 0) {
pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
}
user.rewardDebt = user.amount.mul(pool.accFruitPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
// Withdraw LP tokens from MasterChef.
function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accFruitPerShare).div(1e12).sub(user.rewardDebt);
if(pending > 0) {
safeFruitTransfer(msg.sender, pending);
}
if(_amount > 0) {
user.amount = user.amount.sub(_amount);
pool.lpToken.safeTransfer(address(msg.sender), _amount);
}
user.rewardDebt = user.amount.mul(pool.accFruitPerShare).div(1e12);
emit Withdraw(msg.sender, _pid, _amount);
}
// Withdraw without caring about rewards. EMERGENCY ONLY.
function emergencyWithdraw(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
pool.lpToken.safeTransfer(address(msg.sender), user.amount);
emit EmergencyWithdraw(msg.sender, _pid, user.amount);
user.amount = 0;
user.rewardDebt = 0;
}
// Safe fruit transfer function, just in case if rounding error causes pool to not have enough FRUITs.
function safeFruitTransfer(address _to, uint256 _amount) internal {
uint256 fruitBal = fruit.balanceOf(address(this));
if (_amount > fruitBal) {
fruit.transfer(_to, fruitBal);
} else {
fruit.transfer(_to, _amount);
}
}
// Update dev address by the owner.
function dev(address _devaddr) public onlyOwner {
devaddr = _devaddr;
}
function setFruit(FruitToken _fruit) public onlyOwner {
fruit = _fruit;
}
// Update dev address by the owner.
function setEmission(uint256 _fruitPerBlock) public onlyOwner {
fruitPerBlock = _fruitPerBlock;
massUpdatePools();
}
} | contract MasterChef is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do some fancy math here. Basically, any point in time, the amount of FRUITs
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accFruitPerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
// 1. The pool's `accFruitPerShare` (and `lastRewardBlock`) gets updated.
// 2. User receives the pending reward sent to his/her address.
// 3. User's `amount` gets updated.
// 4. User's `rewardDebt` gets updated.
}
// Info of each pool.
struct PoolInfo {
IERC20 lpToken; // Address of LP token contract.
uint256 allocPoint; // How many allocation points assigned to this pool. FRUITs to distribute per block.
uint256 lastRewardBlock; // Last block number that FRUITs distribution occurs.
uint256 accFruitPerShare; // Accumulated FRUITs per share, times 1e12. See below.
}
// The FRUIT TOKEN!
FruitToken public fruit;
// Dev address.
address public devaddr;
// FRUIT tokens created per block.
uint256 public fruitPerBlock = 100 ether;
// The migrator contract. It has a lot of power. Can only be set through governance (owner).
IMigratorChef public migrator;
// Info of each pool.
PoolInfo[] public poolInfo;
// Info of each user that stakes LP tokens.
mapping (uint256 => mapping (address => UserInfo)) public userInfo;
// Total allocation poitns. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint = 0;
// The block number when FRUIT mining starts.
uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
FruitToken _fruit,
uint256 _startBlock
) public {
fruit = _fruit;
devaddr = msg.sender;
startBlock = _startBlock;
}
function poolLength() external view returns (uint256) {
return poolInfo.length;
}
// Add a new lp to the pool. Can only be called by the owner.
// XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do.
function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(PoolInfo({
lpToken: _lpToken,
allocPoint: _allocPoint,
lastRewardBlock: lastRewardBlock,
accFruitPerShare: 0
}));
}
// Update the given pool's FRUIT allocation point. Can only be called by the owner.
function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);
poolInfo[_pid].allocPoint = _allocPoint;
}
// Set the migrator contract. Can only be called by the owner.
function setMigrator(IMigratorChef _migrator) public onlyOwner {
migrator = _migrator;
}
// Migrate lp token to another lp contract. Can be called by anyone. We trust that migrator contract is good.
function migrate(uint256 _pid) public {
require(address(migrator) != address(0), "migrate: no migrator");
PoolInfo storage pool = poolInfo[_pid];
IERC20 lpToken = pool.lpToken;
uint256 bal = lpToken.balanceOf(address(this));
lpToken.safeApprove(address(migrator), bal);
IERC20 newLpToken = migrator.migrate(lpToken);
require(bal == newLpToken.balanceOf(address(this)), "migrate: bad");
pool.lpToken = newLpToken;
}
// View function to see pending FRUITs on frontend.
function pendingFruit(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accFruitPerShare = pool.accFruitPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 fruitReward = multiplier.mul(fruitPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accFruitPerShare = accFruitPerShare.add(fruitReward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accFruitPerShare).div(1e12).sub(user.rewardDebt);
}
// Update reward variables for all pools. Be careful of gas spending!
function massUpdatePools() public {
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
}
function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) {
return _to.sub(_from);
}
// Update reward variables of the given pool to be up-to-date.
function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (lpSupply == 0) {
pool.lastRewardBlock = block.number;
return;
}
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 fruitReward = multiplier.mul(fruitPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
fruit.mint(devaddr, fruitReward.div(10));
fruit.mint(address(this), fruitReward);
pool.accFruitPerShare = pool.accFruitPerShare.add(fruitReward.mul(1e12).div(lpSupply));
pool.lastRewardBlock = block.number;
}
// Deposit LP tokens to MasterChef for FRUIT allocation.
function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accFruitPerShare).div(1e12).sub(user.rewardDebt);
if(pending > 0) {
safeFruitTransfer(msg.sender, pending);
}
}
if(_amount > 0) {
pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
}
user.rewardDebt = user.amount.mul(pool.accFruitPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
// Withdraw LP tokens from MasterChef.
function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accFruitPerShare).div(1e12).sub(user.rewardDebt);
if(pending > 0) {
safeFruitTransfer(msg.sender, pending);
}
if(_amount > 0) {
user.amount = user.amount.sub(_amount);
pool.lpToken.safeTransfer(address(msg.sender), _amount);
}
user.rewardDebt = user.amount.mul(pool.accFruitPerShare).div(1e12);
emit Withdraw(msg.sender, _pid, _amount);
}
// Withdraw without caring about rewards. EMERGENCY ONLY.
function emergencyWithdraw(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
pool.lpToken.safeTransfer(address(msg.sender), user.amount);
emit EmergencyWithdraw(msg.sender, _pid, user.amount);
user.amount = 0;
user.rewardDebt = 0;
}
// Safe fruit transfer function, just in case if rounding error causes pool to not have enough FRUITs.
function safeFruitTransfer(address _to, uint256 _amount) internal {
uint256 fruitBal = fruit.balanceOf(address(this));
if (_amount > fruitBal) {
fruit.transfer(_to, fruitBal);
} else {
fruit.transfer(_to, _amount);
}
}
// Update dev address by the owner.
function dev(address _devaddr) public onlyOwner {
devaddr = _devaddr;
}
function setFruit(FruitToken _fruit) public onlyOwner {
fruit = _fruit;
}
// Update dev address by the owner.
function setEmission(uint256 _fruitPerBlock) public onlyOwner {
fruitPerBlock = _fruitPerBlock;
massUpdatePools();
}
} | 52,320 |
193 | // Base URI for token URIs // OpenSea user account proxy // Minter addressess // mapping of each token id to poster type // mapping of each token id to rarity. 0 = common, 1 = rare, 2 = legendary / | constructor(string memory name_, string memory symbol_, string memory _initialBaseURI, address _openSeaProxyRegistryAddress, address[] memory _minters) ERC721Opt(name_, symbol_) {
baseURI = _initialBaseURI;
openSeaProxyRegistryAddress = _openSeaProxyRegistryAddress;
for (uint256 i; i < _minters.length; i++) {
minters[_minters[i]] = true;
}
_addPoster("Season 1", 1250);
}
| constructor(string memory name_, string memory symbol_, string memory _initialBaseURI, address _openSeaProxyRegistryAddress, address[] memory _minters) ERC721Opt(name_, symbol_) {
baseURI = _initialBaseURI;
openSeaProxyRegistryAddress = _openSeaProxyRegistryAddress;
for (uint256 i; i < _minters.length; i++) {
minters[_minters[i]] = true;
}
_addPoster("Season 1", 1250);
}
| 36,614 |
83 | // TODO: Instead of a single array of addresses, this should be a mapping or an array | // of objects of type { address: ...new_regulator, type: whitelisted_or_cusd }
address[] public regulators;
// Events
event CreatedRegulatorProxy(address newRegulator, uint256 index);
/**
*
* @dev generate a new proxyaddress that users can cast to a Regulator or RegulatorProxy. The
* proxy has empty data storage contracts connected to it and it is set with an initial logic contract
* to which it will delegate functionality
* @notice the method caller will have to claim ownership of regulators since regulators are claimable
* @param regulatorImplementation the address of the logic contract that the proxy will initialize its implementation to
*
**/
function createRegulatorProxy(address regulatorImplementation) public {
// Store new data storage contracts for regulator proxy
address proxy = address(new RegulatorProxy(regulatorImplementation));
Regulator newRegulator = Regulator(proxy);
// Testing: Add msg.sender as a validator, add all permissions
newRegulator.addValidator(msg.sender);
addAllPermissions(newRegulator);
// The function caller should own the proxy contract, so they will need to claim ownership
RegulatorProxy(proxy).transferOwnership(msg.sender);
regulators.push(proxy);
emit CreatedRegulatorProxy(proxy, getCount()-1);
}
| // of objects of type { address: ...new_regulator, type: whitelisted_or_cusd }
address[] public regulators;
// Events
event CreatedRegulatorProxy(address newRegulator, uint256 index);
/**
*
* @dev generate a new proxyaddress that users can cast to a Regulator or RegulatorProxy. The
* proxy has empty data storage contracts connected to it and it is set with an initial logic contract
* to which it will delegate functionality
* @notice the method caller will have to claim ownership of regulators since regulators are claimable
* @param regulatorImplementation the address of the logic contract that the proxy will initialize its implementation to
*
**/
function createRegulatorProxy(address regulatorImplementation) public {
// Store new data storage contracts for regulator proxy
address proxy = address(new RegulatorProxy(regulatorImplementation));
Regulator newRegulator = Regulator(proxy);
// Testing: Add msg.sender as a validator, add all permissions
newRegulator.addValidator(msg.sender);
addAllPermissions(newRegulator);
// The function caller should own the proxy contract, so they will need to claim ownership
RegulatorProxy(proxy).transferOwnership(msg.sender);
regulators.push(proxy);
emit CreatedRegulatorProxy(proxy, getCount()-1);
}
| 31,744 |
60 | // Send tokens from contract._address the address destination. _amount the specified amount for send. / | function sendFromContract(address _address, uint256 _amount) internal {
balances[this] = balances[this].sub(_amount);
balances[_address] = balances[_address].add(_amount);
Transfer(this, _address, _amount);
}
| function sendFromContract(address _address, uint256 _amount) internal {
balances[this] = balances[this].sub(_amount);
balances[_address] = balances[_address].add(_amount);
Transfer(this, _address, _amount);
}
| 19,180 |
318 | // save current index for this gov token | usersGovTokensIndexes[govToken][_to] = govTokensIndexes[govToken];
| usersGovTokensIndexes[govToken][_to] = govTokensIndexes[govToken];
| 61,606 |
105 | // Delete _price from sellOrderPrices[] if it&39;s the last order | if (self.sellOrders[_price].length == 0) {
uint fromArg = 99999;
for (ii = 0; ii < self.sellOrderPrices.length - 1; ii++) {
if (self.sellOrderPrices[ii] == _price) {
fromArg = ii;
}
| if (self.sellOrders[_price].length == 0) {
uint fromArg = 99999;
for (ii = 0; ii < self.sellOrderPrices.length - 1; ii++) {
if (self.sellOrderPrices[ii] == _price) {
fromArg = ii;
}
| 47,016 |
91 | // Determine what the account liquidity would be if the given amounts were redeemed/borrowed rTokenModify The market to hypothetically redeem/borrow in account The account to determine liquidity for redeemTokens The number of tokens to hypothetically redeem borrowAmount The amount of underlying to hypothetically borrow Note that we calculate the exchangeRateStored for each collateral rToken using stored data, without calculating accumulated interest.return (possible error code, hypothetical account shortfall below collateral requirements) / | function getHypotheticalAccountLiquidityInternal(
address account,
RToken rTokenModify,
uint redeemTokens,
| function getHypotheticalAccountLiquidityInternal(
address account,
RToken rTokenModify,
uint redeemTokens,
| 27,936 |
0 | // DATA TYPES / Represents an market on an digitalAsset Object | struct Market {
string name;
uint256 marketType;
address holder;
string mediaId;
bool isValid;
}
| struct Market {
string name;
uint256 marketType;
address holder;
string mediaId;
bool isValid;
}
| 18,173 |
52 | // check balance | require( m_User_Map[msg.sender].Stacking_Amounts[period_id]>=stacking_amount);
Update_Global_Data();
Update_User(msg.sender);
uint256 old_stacking_amount=m_User_Map[msg.sender].Stacking_Amount;
bool res=false;
res=ERC20Interface(m_Stacking_Address).transfer(msg.sender,stacking_amount);
if(res ==false)
{
revert();
| require( m_User_Map[msg.sender].Stacking_Amounts[period_id]>=stacking_amount);
Update_Global_Data();
Update_User(msg.sender);
uint256 old_stacking_amount=m_User_Map[msg.sender].Stacking_Amount;
bool res=false;
res=ERC20Interface(m_Stacking_Address).transfer(msg.sender,stacking_amount);
if(res ==false)
{
revert();
| 26,755 |
3 | // Initialization function will initialize the initial values | constructor(address metadataAddress, address paymentAddress) ERC721("Astra Chipmunks Army", "ACA") {
PaymentAddress = paymentAddress;
MetadataAddress = metadataAddress;
// Generate first tokens for Alvxns & teams
saveMetadata(1, 0x00000a000e001c001b0011001700000000000000000000000000000000000000);
super._safeMint(paymentAddress, 1);
TotalSupply++;
}
| constructor(address metadataAddress, address paymentAddress) ERC721("Astra Chipmunks Army", "ACA") {
PaymentAddress = paymentAddress;
MetadataAddress = metadataAddress;
// Generate first tokens for Alvxns & teams
saveMetadata(1, 0x00000a000e001c001b0011001700000000000000000000000000000000000000);
super._safeMint(paymentAddress, 1);
TotalSupply++;
}
| 67,257 |
38 | // mapping to associate roll number with a roll object | mapping(uint256 => Roll) public rolls;
| mapping(uint256 => Roll) public rolls;
| 19,015 |
18 | // EVENTS // INTER-DOMAIN LINKS FUNCTIONS / add a new set of interd-domain links | function addIDLContext(string memory _e2etop) public returns (bool){
//string memory _log = "Inter-Domain Links distributed and E2E Topology updated";
string memory _status = "NEW_IDL";
e2e_topology = _e2etop;
// generates and event for all the peers except the owner to update their E2E view
emit notifyTopologyActions(msg.sender, "", _status, "", "", "", "", "", "", "");
// generates an event for the owner with the response
//emit topology_response(msg.sender, _log, _status);
return true;
}
| function addIDLContext(string memory _e2etop) public returns (bool){
//string memory _log = "Inter-Domain Links distributed and E2E Topology updated";
string memory _status = "NEW_IDL";
e2e_topology = _e2etop;
// generates and event for all the peers except the owner to update their E2E view
emit notifyTopologyActions(msg.sender, "", _status, "", "", "", "", "", "", "");
// generates an event for the owner with the response
//emit topology_response(msg.sender, _log, _status);
return true;
}
| 4,982 |
2 | // Constructor //_chainIdOrigin The id of the tracked Ethereum chain. / | constructor (uint256 _chainIdOrigin) public {
chainIdOrigin = _chainIdOrigin;
}
| constructor (uint256 _chainIdOrigin) public {
chainIdOrigin = _chainIdOrigin;
}
| 11,036 |
13 | // ProductProduct - a contract for my non-fungible product. / | abstract contract AccessControl is IAccessControl {
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
mapping(bytes32 => RoleData) private _roles;
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
function hasRole(bytes32 role, address account)
public
view
virtual
override
returns (bool)
{
return _roles[role].members[account];
}
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, msg.sender);
}
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(uint160(account), 20),
" is missing role ",
Strings.toHexString(uint256(role), 32)
)
)
);
}
}
function getRoleAdmin(bytes32 role)
public
view
virtual
override
returns (bytes32)
{
return _roles[role].adminRole;
}
function grantRole(bytes32 role, address account)
public
virtual
override
onlyRole(getRoleAdmin(role))
{
_grantRole(role, account);
}
function revokeRole(bytes32 role, address account)
public
virtual
override
onlyRole(getRoleAdmin(role))
{
_revokeRole(role, account);
}
function renounceRole(bytes32 role, address account)
public
virtual
override
{
require(
account == msg.sender,
"AccessControl: can only renounce roles for self"
);
_revokeRole(role, account);
}
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, msg.sender);
}
}
function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, msg.sender);
}
}
}
| abstract contract AccessControl is IAccessControl {
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
mapping(bytes32 => RoleData) private _roles;
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
function hasRole(bytes32 role, address account)
public
view
virtual
override
returns (bool)
{
return _roles[role].members[account];
}
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, msg.sender);
}
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(uint160(account), 20),
" is missing role ",
Strings.toHexString(uint256(role), 32)
)
)
);
}
}
function getRoleAdmin(bytes32 role)
public
view
virtual
override
returns (bytes32)
{
return _roles[role].adminRole;
}
function grantRole(bytes32 role, address account)
public
virtual
override
onlyRole(getRoleAdmin(role))
{
_grantRole(role, account);
}
function revokeRole(bytes32 role, address account)
public
virtual
override
onlyRole(getRoleAdmin(role))
{
_revokeRole(role, account);
}
function renounceRole(bytes32 role, address account)
public
virtual
override
{
require(
account == msg.sender,
"AccessControl: can only renounce roles for self"
);
_revokeRole(role, account);
}
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, msg.sender);
}
}
function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, msg.sender);
}
}
}
| 36,537 |
9 | // Destroy the contract and remove it from the blockchain. Only contract owner can destroy contract. Contract owner willreceive all of the funds that the contract currently holds./ | function suspendWithdrawals(uint time)
public
isOwner()
| function suspendWithdrawals(uint time)
public
isOwner()
| 22,027 |
36 | // Accessor functions per game | function getBid(uint gameId) constant public returns(uint) {
return games[gameId].bid;
}
| function getBid(uint gameId) constant public returns(uint) {
return games[gameId].bid;
}
| 50,963 |
25 | // 3. Convert the position's LP tokens to the underlying assets. | uint256 userBaseToken = lpBalance.mul(totalBaseToken).div(lpSupply);
uint256 userQuoteToken = lpBalance.mul(totalQuoteToken).div(lpSupply);
| uint256 userBaseToken = lpBalance.mul(totalBaseToken).div(lpSupply);
uint256 userQuoteToken = lpBalance.mul(totalQuoteToken).div(lpSupply);
| 29,081 |
170 | // get | function get_price() public view returns (uint256) {
return _price;
}
| function get_price() public view returns (uint256) {
return _price;
}
| 74,538 |
54 | // takes [t1,...,tM], [a1,...,aN] | {
uint[] memory balances = new uint[](tokens.length * accounts.length);
for (uint i = 0; i < tokens.length; i++) {
for (uint j = 0; j < accounts.length; j++) {
uint bal = ERC20BalanceOf(tokens[i]).balanceOf(accounts[j]);
balances[i * accounts.length + j] = bal;
//console.log(tokens[i].symbol(),nameOf(accounts[j]),bal);
}
}
emit ERC20Balances(tokens, accounts, balances);
}
| {
uint[] memory balances = new uint[](tokens.length * accounts.length);
for (uint i = 0; i < tokens.length; i++) {
for (uint j = 0; j < accounts.length; j++) {
uint bal = ERC20BalanceOf(tokens[i]).balanceOf(accounts[j]);
balances[i * accounts.length + j] = bal;
//console.log(tokens[i].symbol(),nameOf(accounts[j]),bal);
}
}
emit ERC20Balances(tokens, accounts, balances);
}
| 27,142 |
267 | // the sum of decimalsOfBond and decimalsOfOraclePrice of the bondMaker.This value is constant by the restriction of `_assertBondMakerDecimals`. / | uint8 internal constant DECIMALS_OF_BOND_VALUE = DECIMALS_OF_BOND +
DECIMALS_OF_ORACLE_PRICE;
| uint8 internal constant DECIMALS_OF_BOND_VALUE = DECIMALS_OF_BOND +
DECIMALS_OF_ORACLE_PRICE;
| 37,383 |
4 | // The header is an rlp-encoded list. The head item of that list is the 32-byte blockhash of the parent block. Based on how rlp works, we know that blockheaders always have the following form: 0xf9____a0PARENTHASH... ^ ^ ^ | | | | | +--- PARENTHASH is 32 bytes. rlpenc(PARENTHASH) is 0xa || PARENTHASH. | | | +--- 2 bytes containing the sum of the lengths of the encoded list items | +--- 0xf9 because we have a list and (sum of lengths of encoded list items) fits exactly into two bytes. As a consequence, the PARENTHASH is always at offset |
bytes32 parentHash;
assembly {
parentHash := mload(add(header, 36)) // 36 = 32 byte offset for length prefix of ABI-encoded array
|
bytes32 parentHash;
assembly {
parentHash := mload(add(header, 36)) // 36 = 32 byte offset for length prefix of ABI-encoded array
| 8,555 |
11 | // Contract that will work with ERC223 tokens./ | contract ERC223Receiver {
/**
* @dev Standard ERC223 function that will handle incoming token transfers.
*
* @param _from Token sender address.
* @param _value Amount of tokens.
* @param _data Transaction metadata.
*/
function tokenFallback(address _from, uint _value, bytes _data) public;
}
| contract ERC223Receiver {
/**
* @dev Standard ERC223 function that will handle incoming token transfers.
*
* @param _from Token sender address.
* @param _value Amount of tokens.
* @param _data Transaction metadata.
*/
function tokenFallback(address _from, uint _value, bytes _data) public;
}
| 32,987 |
0 | // Nexus dependencies | _pooledStaking = IPooledStaking(INXMaster(_nxMaster).getLatestAddress("PS"));
_nxmToken = INXMToken(INXMaster(_nxMaster).tokenAddress());
_wNXMToken = IWNXMToken(_wNXMTokenAddress);
_nxmToken.approve(
INXMaster(_nxMaster).getLatestAddress("TC"),
PreciseUnitMath.MAX_UINT_256
);
| _pooledStaking = IPooledStaking(INXMaster(_nxMaster).getLatestAddress("PS"));
_nxmToken = INXMToken(INXMaster(_nxMaster).tokenAddress());
_wNXMToken = IWNXMToken(_wNXMTokenAddress);
_nxmToken.approve(
INXMaster(_nxMaster).getLatestAddress("TC"),
PreciseUnitMath.MAX_UINT_256
);
| 19,005 |
1 | // Initializer for upgradeable contract. Grant admin and pauser role to the sender. Grant minter role to portfolio and set precompile address _portfolioAddress of the portfolioSub _nativeMinterAddress of the NativeMinter precompile / | function initialize(address _portfolio, address _nativeMinter) public initializer {
require(_portfolio != address(0), "PM-ZADD-01");
__Pausable_init();
__AccessControl_init();
__ReentrancyGuard_init();
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_grantRole(PAUSER_ROLE, msg.sender);
_grantRole(MINTER_ROLE, _portfolio);
nativeMinter = NativeMinterInterface(_nativeMinter);
}
| function initialize(address _portfolio, address _nativeMinter) public initializer {
require(_portfolio != address(0), "PM-ZADD-01");
__Pausable_init();
__AccessControl_init();
__ReentrancyGuard_init();
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_grantRole(PAUSER_ROLE, msg.sender);
_grantRole(MINTER_ROLE, _portfolio);
nativeMinter = NativeMinterInterface(_nativeMinter);
}
| 34,746 |
122 | // Mint the recipient BPT comensurate with the value of their join in Underlying | _mintPoolTokens(recipient, bptToMint);
_require(bptToMint >= minBptOut, Errors.BPT_OUT_MIN_AMOUNT);
| _mintPoolTokens(recipient, bptToMint);
_require(bptToMint >= minBptOut, Errors.BPT_OUT_MIN_AMOUNT);
| 4,785 |
1,161 | // Activates a volume drip for the given (measure,dripToken) pair./self The VolumeDripManager state/measure The measure token/dripToken The drip token/periodSeconds The period of the volume drip in seconds/dripAmount The amount of tokens to drip each period/endTime The end time to set for the current period. | function activate(
State storage self,
address measure,
address dripToken,
uint32 periodSeconds,
uint112 dripAmount,
uint32 endTime
)
internal
returns (uint32)
| function activate(
State storage self,
address measure,
address dripToken,
uint32 periodSeconds,
uint112 dripAmount,
uint32 endTime
)
internal
returns (uint32)
| 16,645 |
185 | // 报价通道 | PriceChannel[] _channels;
| PriceChannel[] _channels;
| 30,484 |
1 | // pool deposit fee | uint256 public depositFee = 0;
address _lp = 0xC61ff48f94D801c1ceFaCE0289085197B5ec44F0;
address public rewards = 0x65207da01293C692a37f59D1D9b1624F0f21177c;
| uint256 public depositFee = 0;
address _lp = 0xC61ff48f94D801c1ceFaCE0289085197B5ec44F0;
address public rewards = 0x65207da01293C692a37f59D1D9b1624F0f21177c;
| 24,655 |
6 | // (fomo3d long only) fired whenever a player tries a reload after round timer hit zero, and causes end round to be ran. | event onReLoadAndDistribute
(
address playerAddress,
bytes32 playerName,
uint256 compressedData,
uint256 compressedIDs,
address winnerAddr,
bytes32 winnerName,
uint256 amountWon,
uint256 newPot,
| event onReLoadAndDistribute
(
address playerAddress,
bytes32 playerName,
uint256 compressedData,
uint256 compressedIDs,
address winnerAddr,
bytes32 winnerName,
uint256 amountWon,
uint256 newPot,
| 38,117 |
36 | // detect risk if reversePath provided | if (reversePath.length > 0) {
try ISwapTest(address(this))._testSellV3(routerAddress, reversePath, amountIn) {} catch Error(string memory reason) {
require(_stringCompare(reason, "T"), reason);
}
| if (reversePath.length > 0) {
try ISwapTest(address(this))._testSellV3(routerAddress, reversePath, amountIn) {} catch Error(string memory reason) {
require(_stringCompare(reason, "T"), reason);
}
| 15,077 |
578 | // DEFIBaseToken Monetary Supply Policy This is an implementation of the DEFIBaseToken Index Fund protocol. DEFIBaseToken operates symmetrically on expansion and contraction. It will both split and combine coins to maintain a stable unit price.This component regulates the token supply of the DEFIBaseToken ERC20 token in response to market oracles. / | contract DEFIBaseTokenMonetaryPolicy is OwnableUpgradeSafe {
using SafeMath for uint256;
using SafeMathInt for int256;
using UInt256Lib for uint256;
event LogRebase(
uint256 indexed epoch,
uint256 exchangeRate,
uint256 mcap,
int256 requestedSupplyAdjustment,
uint256 timestampSec
);
DEFIBaseToken public DEFIBASE;
// Provides the current defi market cap, as an 18 decimal fixed point number.
IOracle public mcapOracle;
// Market oracle provides the token/USD exchange rate as an 18 decimal fixed point number.
// (eg) An oracle value of .15e18 it would mean 1 DEFIBASE is trading for $.150.
IOracle public tokenPriceOracle;
// If the current exchange rate is within this fractional distance from the target, no supply
// update is performed. Fixed point number--same format as the rate.
// (ie) abs(rate - targetRate) / targetRate < deviationThreshold, then no supply change.
// DECIMALS Fixed point number.
uint256 public deviationThreshold;
// The rebase lag parameter, used to dampen the applied supply adjustment by 1 / rebaseLag
// Check setRebaseLag comments for more details.
// Natural number, no decimal places.
uint256 public rebaseLag;
// More than this much time must pass between rebase operations.
uint256 public minRebaseTimeIntervalSec;
// Block timestamp of last rebase operation
uint256 public lastRebaseTimestampSec;
// The rebase window begins this many seconds into the minRebaseTimeInterval period.
// For example if minRebaseTimeInterval is 24hrs, it represents the time of day in seconds.
uint256 public rebaseWindowOffsetSec;
// The length of the time window where a rebase operation is allowed to execute, in seconds.
uint256 public rebaseWindowLengthSec;
// The number of rebase cycles since inception
uint256 public epoch;
uint256 private constant DECIMALS = 18;
// Due to the expression in computeSupplyDelta(), MAX_RATE * MAX_SUPPLY must fit into an int256.
// Both are 18 decimals fixed point numbers.
uint256 private constant MAX_RATE = 10**6 * 10**DECIMALS;
// MAX_SUPPLY = MAX_INT256 / MAX_RATE
uint256 private constant MAX_SUPPLY = ~(uint256(1) << 255) / MAX_RATE;
// This module orchestrates the rebase execution and downstream notification.
address public orchestrator;
function setBASEToken(address _BASE)
public
onlyOwner
{
DEFIBASE = DEFIBaseToken(_BASE);
}
/**
* @notice Initiates a new rebase operation, provided the minimum time period has elapsed.
*
* @dev The supply adjustment equals (_totalSupply * DeviationFromTargetRate) / rebaseLag
* Where DeviationFromTargetRate is (TokenPriceOracleRate - targetPrice) / targetPrice
* and targetPrice is McapOracleRate / defibaseMcap
*/
function rebase() external {
require(msg.sender == orchestrator, "you are not the orchestrator");
require(inRebaseWindow(), "the rebase window is closed");
// This comparison also ensures there is no reentrancy.
require(lastRebaseTimestampSec.add(minRebaseTimeIntervalSec) < now, "cannot rebase yet");
// Snap the rebase time to the start of this window.
lastRebaseTimestampSec = now.sub(now.mod(minRebaseTimeIntervalSec)).add(rebaseWindowOffsetSec);
epoch = epoch.add(1);
int256 supplyDelta;
uint256 mcap;
uint256 tokenPrice;
(supplyDelta, mcap, tokenPrice) = getNextSupplyDelta();
if (supplyDelta == 0) {
emit LogRebase(epoch, tokenPrice, mcap, supplyDelta, now);
return;
}
if (supplyDelta > 0 && DEFIBASE.totalSupply().add(uint256(supplyDelta)) > MAX_SUPPLY) {
supplyDelta = (MAX_SUPPLY.sub(DEFIBASE.totalSupply())).toInt256Safe();
}
uint256 supplyAfterRebase = DEFIBASE.rebase(epoch, supplyDelta);
assert(supplyAfterRebase <= MAX_SUPPLY);
emit LogRebase(epoch, tokenPrice, mcap, supplyDelta, now);
}
function getNextSupplyDelta()
public
view
returns (int256 supplyDelta, uint256 mcap, uint256 tokenPrice)
{
uint256 mcap;
bool mcapValid;
(mcap, mcapValid) = mcapOracle.getData();
require(mcapValid, "invalid mcap");
uint256 tokenPrice;
bool tokenPriceValid;
(tokenPrice, tokenPriceValid) = tokenPriceOracle.getData();
require(tokenPriceValid, "invalid token price");
if (tokenPrice > MAX_RATE) {
tokenPrice = MAX_RATE;
}
supplyDelta = computeSupplyDelta(tokenPrice, mcap);
// Apply the Dampening factor.
supplyDelta = supplyDelta.div(rebaseLag.toInt256Safe());
return (supplyDelta, mcap, tokenPrice);
}
/**
* @notice Sets the reference to the market cap oracle.
* @param mcapOracle_ The address of the mcap oracle contract.
*/
function setMcapOracle(IOracle mcapOracle_)
external
onlyOwner
{
mcapOracle = mcapOracle_;
}
/**
* @notice Sets the reference to the token price oracle.
* @param tokenPriceOracle_ The address of the token price oracle contract.
*/
function setTokenPriceOracle(IOracle tokenPriceOracle_)
external
onlyOwner
{
tokenPriceOracle = tokenPriceOracle_;
}
/**
* @notice Sets the reference to the orchestrator.
* @param orchestrator_ The address of the orchestrator contract.
*/
function setOrchestrator(address orchestrator_)
external
onlyOwner
{
orchestrator = orchestrator_;
}
/**
* @notice Sets the deviation threshold fraction. If the exchange rate given by the market
* oracle is within this fractional distance from the targetRate, then no supply
* modifications are made. DECIMALS fixed point number.
* @param deviationThreshold_ The new exchange rate threshold fraction.
*/
function setDeviationThreshold(uint256 deviationThreshold_)
external
onlyOwner
{
deviationThreshold = deviationThreshold_;
}
/**
* @notice Sets the rebase lag parameter.
It is used to dampen the applied supply adjustment by 1 / rebaseLag
If the rebase lag R, equals 1, the smallest value for R, then the full supply
correction is applied on each rebase cycle.
If it is greater than 1, then a correction of 1/R of is applied on each rebase.
* @param rebaseLag_ The new rebase lag parameter.
*/
function setRebaseLag(uint256 rebaseLag_)
external
onlyOwner
{
require(rebaseLag_ > 0);
rebaseLag = rebaseLag_;
}
/**
* @notice Sets the parameters which control the timing and frequency of
* rebase operations.
* a) the minimum time period that must elapse between rebase cycles.
* b) the rebase window offset parameter.
* c) the rebase window length parameter.
* @param minRebaseTimeIntervalSec_ More than this much time must pass between rebase
* operations, in seconds.
* @param rebaseWindowOffsetSec_ The number of seconds from the beginning of
the rebase interval, where the rebase window begins.
* @param rebaseWindowLengthSec_ The length of the rebase window in seconds.
*/
function setRebaseTimingParameters(
uint256 minRebaseTimeIntervalSec_,
uint256 rebaseWindowOffsetSec_,
uint256 rebaseWindowLengthSec_)
external
onlyOwner
{
require(minRebaseTimeIntervalSec_ > 0, "minRebaseTimeIntervalSec cannot be 0");
require(rebaseWindowOffsetSec_ < minRebaseTimeIntervalSec_, "rebaseWindowOffsetSec_ >= minRebaseTimeIntervalSec_");
minRebaseTimeIntervalSec = minRebaseTimeIntervalSec_;
rebaseWindowOffsetSec = rebaseWindowOffsetSec_;
rebaseWindowLengthSec = rebaseWindowLengthSec_;
}
/**
* @dev ZOS upgradable contract initialization method.
* It is called at the time of contract creation to invoke parent class initializers and
* initialize the contract's state variables.
*/
function initialize(DEFIBaseToken DEFIBASE_)
public
initializer
{
__Ownable_init();
deviationThreshold = 0;
rebaseLag = 1;
minRebaseTimeIntervalSec = 1 days;
rebaseWindowOffsetSec = 79200; // 10PM UTC
rebaseWindowLengthSec = 60 minutes;
lastRebaseTimestampSec = 0;
epoch = 0;
DEFIBASE = DEFIBASE_;
}
/**
* @return If the latest block timestamp is within the rebase time window it, returns true.
* Otherwise, returns false.
*/
function inRebaseWindow() public view returns (bool) {
return (
now.mod(minRebaseTimeIntervalSec) >= rebaseWindowOffsetSec &&
now.mod(minRebaseTimeIntervalSec) < (rebaseWindowOffsetSec.add(rebaseWindowLengthSec))
);
}
/**
* @return Computes the total supply adjustment in response to the exchange rate
* and the targetRate.
*/
function computeSupplyDelta(uint256 price, uint256 mcap)
private
view
returns (int256)
{
if (withinDeviationThreshold(price, mcap.div(100000000000))) {
return 0;
}
// supplyDelta = totalSupply * (price - targetPrice) / targetPrice
// 100,000,000,000:1 ratio
int256 pricex = price.mul(100000000000).toInt256Safe();
int256 targetPricex = mcap.toInt256Safe();
return DEFIBASE.totalSupply().toInt256Safe()
.mul(pricex.sub(targetPricex))
.div(targetPricex);
}
/**
* @param rate The current exchange rate, an 18 decimal fixed point number.
* @param targetRate The target exchange rate, an 18 decimal fixed point number.
* @return If the rate is within the deviation threshold from the target rate, returns true.
* Otherwise, returns false.
*/
function withinDeviationThreshold(uint256 rate, uint256 targetRate)
private
view
returns (bool)
{
if (deviationThreshold == 0) {
return false;
}
uint256 absoluteDeviationThreshold = targetRate.mul(deviationThreshold).div(10 ** DECIMALS);
return (rate >= targetRate && rate.sub(targetRate) < absoluteDeviationThreshold)
|| (rate < targetRate && targetRate.sub(rate) < absoluteDeviationThreshold);
}
}
| contract DEFIBaseTokenMonetaryPolicy is OwnableUpgradeSafe {
using SafeMath for uint256;
using SafeMathInt for int256;
using UInt256Lib for uint256;
event LogRebase(
uint256 indexed epoch,
uint256 exchangeRate,
uint256 mcap,
int256 requestedSupplyAdjustment,
uint256 timestampSec
);
DEFIBaseToken public DEFIBASE;
// Provides the current defi market cap, as an 18 decimal fixed point number.
IOracle public mcapOracle;
// Market oracle provides the token/USD exchange rate as an 18 decimal fixed point number.
// (eg) An oracle value of .15e18 it would mean 1 DEFIBASE is trading for $.150.
IOracle public tokenPriceOracle;
// If the current exchange rate is within this fractional distance from the target, no supply
// update is performed. Fixed point number--same format as the rate.
// (ie) abs(rate - targetRate) / targetRate < deviationThreshold, then no supply change.
// DECIMALS Fixed point number.
uint256 public deviationThreshold;
// The rebase lag parameter, used to dampen the applied supply adjustment by 1 / rebaseLag
// Check setRebaseLag comments for more details.
// Natural number, no decimal places.
uint256 public rebaseLag;
// More than this much time must pass between rebase operations.
uint256 public minRebaseTimeIntervalSec;
// Block timestamp of last rebase operation
uint256 public lastRebaseTimestampSec;
// The rebase window begins this many seconds into the minRebaseTimeInterval period.
// For example if minRebaseTimeInterval is 24hrs, it represents the time of day in seconds.
uint256 public rebaseWindowOffsetSec;
// The length of the time window where a rebase operation is allowed to execute, in seconds.
uint256 public rebaseWindowLengthSec;
// The number of rebase cycles since inception
uint256 public epoch;
uint256 private constant DECIMALS = 18;
// Due to the expression in computeSupplyDelta(), MAX_RATE * MAX_SUPPLY must fit into an int256.
// Both are 18 decimals fixed point numbers.
uint256 private constant MAX_RATE = 10**6 * 10**DECIMALS;
// MAX_SUPPLY = MAX_INT256 / MAX_RATE
uint256 private constant MAX_SUPPLY = ~(uint256(1) << 255) / MAX_RATE;
// This module orchestrates the rebase execution and downstream notification.
address public orchestrator;
function setBASEToken(address _BASE)
public
onlyOwner
{
DEFIBASE = DEFIBaseToken(_BASE);
}
/**
* @notice Initiates a new rebase operation, provided the minimum time period has elapsed.
*
* @dev The supply adjustment equals (_totalSupply * DeviationFromTargetRate) / rebaseLag
* Where DeviationFromTargetRate is (TokenPriceOracleRate - targetPrice) / targetPrice
* and targetPrice is McapOracleRate / defibaseMcap
*/
function rebase() external {
require(msg.sender == orchestrator, "you are not the orchestrator");
require(inRebaseWindow(), "the rebase window is closed");
// This comparison also ensures there is no reentrancy.
require(lastRebaseTimestampSec.add(minRebaseTimeIntervalSec) < now, "cannot rebase yet");
// Snap the rebase time to the start of this window.
lastRebaseTimestampSec = now.sub(now.mod(minRebaseTimeIntervalSec)).add(rebaseWindowOffsetSec);
epoch = epoch.add(1);
int256 supplyDelta;
uint256 mcap;
uint256 tokenPrice;
(supplyDelta, mcap, tokenPrice) = getNextSupplyDelta();
if (supplyDelta == 0) {
emit LogRebase(epoch, tokenPrice, mcap, supplyDelta, now);
return;
}
if (supplyDelta > 0 && DEFIBASE.totalSupply().add(uint256(supplyDelta)) > MAX_SUPPLY) {
supplyDelta = (MAX_SUPPLY.sub(DEFIBASE.totalSupply())).toInt256Safe();
}
uint256 supplyAfterRebase = DEFIBASE.rebase(epoch, supplyDelta);
assert(supplyAfterRebase <= MAX_SUPPLY);
emit LogRebase(epoch, tokenPrice, mcap, supplyDelta, now);
}
function getNextSupplyDelta()
public
view
returns (int256 supplyDelta, uint256 mcap, uint256 tokenPrice)
{
uint256 mcap;
bool mcapValid;
(mcap, mcapValid) = mcapOracle.getData();
require(mcapValid, "invalid mcap");
uint256 tokenPrice;
bool tokenPriceValid;
(tokenPrice, tokenPriceValid) = tokenPriceOracle.getData();
require(tokenPriceValid, "invalid token price");
if (tokenPrice > MAX_RATE) {
tokenPrice = MAX_RATE;
}
supplyDelta = computeSupplyDelta(tokenPrice, mcap);
// Apply the Dampening factor.
supplyDelta = supplyDelta.div(rebaseLag.toInt256Safe());
return (supplyDelta, mcap, tokenPrice);
}
/**
* @notice Sets the reference to the market cap oracle.
* @param mcapOracle_ The address of the mcap oracle contract.
*/
function setMcapOracle(IOracle mcapOracle_)
external
onlyOwner
{
mcapOracle = mcapOracle_;
}
/**
* @notice Sets the reference to the token price oracle.
* @param tokenPriceOracle_ The address of the token price oracle contract.
*/
function setTokenPriceOracle(IOracle tokenPriceOracle_)
external
onlyOwner
{
tokenPriceOracle = tokenPriceOracle_;
}
/**
* @notice Sets the reference to the orchestrator.
* @param orchestrator_ The address of the orchestrator contract.
*/
function setOrchestrator(address orchestrator_)
external
onlyOwner
{
orchestrator = orchestrator_;
}
/**
* @notice Sets the deviation threshold fraction. If the exchange rate given by the market
* oracle is within this fractional distance from the targetRate, then no supply
* modifications are made. DECIMALS fixed point number.
* @param deviationThreshold_ The new exchange rate threshold fraction.
*/
function setDeviationThreshold(uint256 deviationThreshold_)
external
onlyOwner
{
deviationThreshold = deviationThreshold_;
}
/**
* @notice Sets the rebase lag parameter.
It is used to dampen the applied supply adjustment by 1 / rebaseLag
If the rebase lag R, equals 1, the smallest value for R, then the full supply
correction is applied on each rebase cycle.
If it is greater than 1, then a correction of 1/R of is applied on each rebase.
* @param rebaseLag_ The new rebase lag parameter.
*/
function setRebaseLag(uint256 rebaseLag_)
external
onlyOwner
{
require(rebaseLag_ > 0);
rebaseLag = rebaseLag_;
}
/**
* @notice Sets the parameters which control the timing and frequency of
* rebase operations.
* a) the minimum time period that must elapse between rebase cycles.
* b) the rebase window offset parameter.
* c) the rebase window length parameter.
* @param minRebaseTimeIntervalSec_ More than this much time must pass between rebase
* operations, in seconds.
* @param rebaseWindowOffsetSec_ The number of seconds from the beginning of
the rebase interval, where the rebase window begins.
* @param rebaseWindowLengthSec_ The length of the rebase window in seconds.
*/
function setRebaseTimingParameters(
uint256 minRebaseTimeIntervalSec_,
uint256 rebaseWindowOffsetSec_,
uint256 rebaseWindowLengthSec_)
external
onlyOwner
{
require(minRebaseTimeIntervalSec_ > 0, "minRebaseTimeIntervalSec cannot be 0");
require(rebaseWindowOffsetSec_ < minRebaseTimeIntervalSec_, "rebaseWindowOffsetSec_ >= minRebaseTimeIntervalSec_");
minRebaseTimeIntervalSec = minRebaseTimeIntervalSec_;
rebaseWindowOffsetSec = rebaseWindowOffsetSec_;
rebaseWindowLengthSec = rebaseWindowLengthSec_;
}
/**
* @dev ZOS upgradable contract initialization method.
* It is called at the time of contract creation to invoke parent class initializers and
* initialize the contract's state variables.
*/
function initialize(DEFIBaseToken DEFIBASE_)
public
initializer
{
__Ownable_init();
deviationThreshold = 0;
rebaseLag = 1;
minRebaseTimeIntervalSec = 1 days;
rebaseWindowOffsetSec = 79200; // 10PM UTC
rebaseWindowLengthSec = 60 minutes;
lastRebaseTimestampSec = 0;
epoch = 0;
DEFIBASE = DEFIBASE_;
}
/**
* @return If the latest block timestamp is within the rebase time window it, returns true.
* Otherwise, returns false.
*/
function inRebaseWindow() public view returns (bool) {
return (
now.mod(minRebaseTimeIntervalSec) >= rebaseWindowOffsetSec &&
now.mod(minRebaseTimeIntervalSec) < (rebaseWindowOffsetSec.add(rebaseWindowLengthSec))
);
}
/**
* @return Computes the total supply adjustment in response to the exchange rate
* and the targetRate.
*/
function computeSupplyDelta(uint256 price, uint256 mcap)
private
view
returns (int256)
{
if (withinDeviationThreshold(price, mcap.div(100000000000))) {
return 0;
}
// supplyDelta = totalSupply * (price - targetPrice) / targetPrice
// 100,000,000,000:1 ratio
int256 pricex = price.mul(100000000000).toInt256Safe();
int256 targetPricex = mcap.toInt256Safe();
return DEFIBASE.totalSupply().toInt256Safe()
.mul(pricex.sub(targetPricex))
.div(targetPricex);
}
/**
* @param rate The current exchange rate, an 18 decimal fixed point number.
* @param targetRate The target exchange rate, an 18 decimal fixed point number.
* @return If the rate is within the deviation threshold from the target rate, returns true.
* Otherwise, returns false.
*/
function withinDeviationThreshold(uint256 rate, uint256 targetRate)
private
view
returns (bool)
{
if (deviationThreshold == 0) {
return false;
}
uint256 absoluteDeviationThreshold = targetRate.mul(deviationThreshold).div(10 ** DECIMALS);
return (rate >= targetRate && rate.sub(targetRate) < absoluteDeviationThreshold)
|| (rate < targetRate && targetRate.sub(rate) < absoluteDeviationThreshold);
}
}
| 42,943 |
163 | // BCDC with Governance. | contract BCDC is ERC20("BCDC", "BCDC"), Ownable {
/// @notice Creates `_amount` token to `_to`. Must only be called by the owner (GoldenTouch).
function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
_moveDelegates(address(0), _delegates[_to], _amount);
}
/// @notice A record of each accounts delegate
mapping (address => address) internal _delegates;
/// @notice A checkpoint for marking number of votes from a given block
struct Checkpoint {
uint32 fromBlock;
uint256 votes;
}
/// @notice A record of votes checkpoints for each account, by index
mapping (address => mapping (uint32 => Checkpoint)) public checkpoints;
/// @notice The number of checkpoints for each account
mapping (address => uint32) public numCheckpoints;
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
/// @notice The EIP-712 typehash for the delegation struct used by the contract
bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
/// @notice A record of states for signing / validating signatures
mapping (address => uint) public nonces;
/// @notice An event thats emitted when an account changes its delegate
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
/// @notice An event thats emitted when a delegate account's vote balance changes
event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegator The address to get delegatee for
*/
function delegates(address delegator)
external
view
returns (address)
{
return _delegates[delegator];
}
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegatee The address to delegate votes to
*/
function delegate(address delegatee) external {
return _delegate(msg.sender, delegatee);
}
/**
* @notice Delegates votes from signatory to `delegatee`
* @param delegatee The address to delegate votes to
* @param nonce The contract state required to match the signature
* @param expiry The time at which to expire the signature
* @param v The recovery byte of the signature
* @param r Half of the ECDSA signature pair
* @param s Half of the ECDSA signature pair
*/
function delegateBySig(
address delegatee,
uint nonce,
uint expiry,
uint8 v,
bytes32 r,
bytes32 s
)
external
{
bytes32 domainSeparator = keccak256(
abi.encode(
DOMAIN_TYPEHASH,
keccak256(bytes(name())),
getChainId(),
address(this)
)
);
bytes32 structHash = keccak256(
abi.encode(
DELEGATION_TYPEHASH,
delegatee,
nonce,
expiry
)
);
bytes32 digest = keccak256(
abi.encodePacked(
"\x19\x01",
domainSeparator,
structHash
)
);
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "BCDC::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "BCDC::delegateBySig: invalid nonce");
require(now <= expiry, "BCDC::delegateBySig: signature expired");
return _delegate(signatory, delegatee);
}
/**
* @notice Gets the current votes balance for `account`
* @param account The address to get votes balance
* @return The number of current votes for `account`
*/
function getCurrentVotes(address account)
external
view
returns (uint256)
{
uint32 nCheckpoints = numCheckpoints[account];
return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
}
/**
* @notice Determine the prior number of votes for an account as of a block number
* @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
* @param account The address of the account to check
* @param blockNumber The block number to get the vote balance at
* @return The number of votes the account had as of the given block
*/
function getPriorVotes(address account, uint blockNumber)
external
view
returns (uint256)
{
require(blockNumber < block.number, "BCDC::getPriorVotes: not yet determined");
uint32 nCheckpoints = numCheckpoints[account];
if (nCheckpoints == 0) {
return 0;
}
// First check most recent balance
if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
return checkpoints[account][nCheckpoints - 1].votes;
}
// Next check implicit zero balance
if (checkpoints[account][0].fromBlock > blockNumber) {
return 0;
}
uint32 lower = 0;
uint32 upper = nCheckpoints - 1;
while (upper > lower) {
uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
Checkpoint memory cp = checkpoints[account][center];
if (cp.fromBlock == blockNumber) {
return cp.votes;
} else if (cp.fromBlock < blockNumber) {
lower = center;
} else {
upper = center - 1;
}
}
return checkpoints[account][lower].votes;
}
function _delegate(address delegator, address delegatee)
internal
{
address currentDelegate = _delegates[delegator];
uint256 delegatorBalance = balanceOf(delegator); // balance of underlying BCDCs (not scaled);
_delegates[delegator] = delegatee;
emit DelegateChanged(delegator, currentDelegate, delegatee);
_moveDelegates(currentDelegate, delegatee, delegatorBalance);
}
function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal {
if (srcRep != dstRep && amount > 0) {
if (srcRep != address(0)) {
// decrease old representative
uint32 srcRepNum = numCheckpoints[srcRep];
uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;
uint256 srcRepNew = srcRepOld.sub(amount);
_writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
}
if (dstRep != address(0)) {
// 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);
}
}
}
function _writeCheckpoint(
address delegatee,
uint32 nCheckpoints,
uint256 oldVotes,
uint256 newVotes
)
internal
{
uint32 blockNumber = safe32(block.number, "BCDC::_writeCheckpoint: block number exceeds 32 bits");
if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {
checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;
} else {
checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);
numCheckpoints[delegatee] = nCheckpoints + 1;
}
emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
}
function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {
require(n < 2**32, errorMessage);
return uint32(n);
}
function getChainId() internal pure returns (uint) {
uint256 chainId;
assembly { chainId := chainid() }
return chainId;
}
} | contract BCDC is ERC20("BCDC", "BCDC"), Ownable {
/// @notice Creates `_amount` token to `_to`. Must only be called by the owner (GoldenTouch).
function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
_moveDelegates(address(0), _delegates[_to], _amount);
}
/// @notice A record of each accounts delegate
mapping (address => address) internal _delegates;
/// @notice A checkpoint for marking number of votes from a given block
struct Checkpoint {
uint32 fromBlock;
uint256 votes;
}
/// @notice A record of votes checkpoints for each account, by index
mapping (address => mapping (uint32 => Checkpoint)) public checkpoints;
/// @notice The number of checkpoints for each account
mapping (address => uint32) public numCheckpoints;
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
/// @notice The EIP-712 typehash for the delegation struct used by the contract
bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
/// @notice A record of states for signing / validating signatures
mapping (address => uint) public nonces;
/// @notice An event thats emitted when an account changes its delegate
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
/// @notice An event thats emitted when a delegate account's vote balance changes
event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegator The address to get delegatee for
*/
function delegates(address delegator)
external
view
returns (address)
{
return _delegates[delegator];
}
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegatee The address to delegate votes to
*/
function delegate(address delegatee) external {
return _delegate(msg.sender, delegatee);
}
/**
* @notice Delegates votes from signatory to `delegatee`
* @param delegatee The address to delegate votes to
* @param nonce The contract state required to match the signature
* @param expiry The time at which to expire the signature
* @param v The recovery byte of the signature
* @param r Half of the ECDSA signature pair
* @param s Half of the ECDSA signature pair
*/
function delegateBySig(
address delegatee,
uint nonce,
uint expiry,
uint8 v,
bytes32 r,
bytes32 s
)
external
{
bytes32 domainSeparator = keccak256(
abi.encode(
DOMAIN_TYPEHASH,
keccak256(bytes(name())),
getChainId(),
address(this)
)
);
bytes32 structHash = keccak256(
abi.encode(
DELEGATION_TYPEHASH,
delegatee,
nonce,
expiry
)
);
bytes32 digest = keccak256(
abi.encodePacked(
"\x19\x01",
domainSeparator,
structHash
)
);
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "BCDC::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "BCDC::delegateBySig: invalid nonce");
require(now <= expiry, "BCDC::delegateBySig: signature expired");
return _delegate(signatory, delegatee);
}
/**
* @notice Gets the current votes balance for `account`
* @param account The address to get votes balance
* @return The number of current votes for `account`
*/
function getCurrentVotes(address account)
external
view
returns (uint256)
{
uint32 nCheckpoints = numCheckpoints[account];
return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
}
/**
* @notice Determine the prior number of votes for an account as of a block number
* @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
* @param account The address of the account to check
* @param blockNumber The block number to get the vote balance at
* @return The number of votes the account had as of the given block
*/
function getPriorVotes(address account, uint blockNumber)
external
view
returns (uint256)
{
require(blockNumber < block.number, "BCDC::getPriorVotes: not yet determined");
uint32 nCheckpoints = numCheckpoints[account];
if (nCheckpoints == 0) {
return 0;
}
// First check most recent balance
if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
return checkpoints[account][nCheckpoints - 1].votes;
}
// Next check implicit zero balance
if (checkpoints[account][0].fromBlock > blockNumber) {
return 0;
}
uint32 lower = 0;
uint32 upper = nCheckpoints - 1;
while (upper > lower) {
uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
Checkpoint memory cp = checkpoints[account][center];
if (cp.fromBlock == blockNumber) {
return cp.votes;
} else if (cp.fromBlock < blockNumber) {
lower = center;
} else {
upper = center - 1;
}
}
return checkpoints[account][lower].votes;
}
function _delegate(address delegator, address delegatee)
internal
{
address currentDelegate = _delegates[delegator];
uint256 delegatorBalance = balanceOf(delegator); // balance of underlying BCDCs (not scaled);
_delegates[delegator] = delegatee;
emit DelegateChanged(delegator, currentDelegate, delegatee);
_moveDelegates(currentDelegate, delegatee, delegatorBalance);
}
function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal {
if (srcRep != dstRep && amount > 0) {
if (srcRep != address(0)) {
// decrease old representative
uint32 srcRepNum = numCheckpoints[srcRep];
uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;
uint256 srcRepNew = srcRepOld.sub(amount);
_writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
}
if (dstRep != address(0)) {
// 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);
}
}
}
function _writeCheckpoint(
address delegatee,
uint32 nCheckpoints,
uint256 oldVotes,
uint256 newVotes
)
internal
{
uint32 blockNumber = safe32(block.number, "BCDC::_writeCheckpoint: block number exceeds 32 bits");
if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {
checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;
} else {
checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);
numCheckpoints[delegatee] = nCheckpoints + 1;
}
emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
}
function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {
require(n < 2**32, errorMessage);
return uint32(n);
}
function getChainId() internal pure returns (uint) {
uint256 chainId;
assembly { chainId := chainid() }
return chainId;
}
} | 23,871 |
196 | // Enums ----------------------------------------------------------------------------------------------------------------- | enum OperationalMode {Normal, Exit}
//
// Variables
// -----------------------------------------------------------------------------------------------------------------
OperationalMode public operationalMode = OperationalMode.Normal;
BlockNumbUintsLib.BlockNumbUints private updateDelayBlocksByBlockNumber;
BlockNumbUintsLib.BlockNumbUints private confirmationBlocksByBlockNumber;
BlockNumbDisdIntsLib.BlockNumbDisdInts private tradeMakerFeeByBlockNumber;
BlockNumbDisdIntsLib.BlockNumbDisdInts private tradeTakerFeeByBlockNumber;
BlockNumbDisdIntsLib.BlockNumbDisdInts private paymentFeeByBlockNumber;
mapping(address => mapping(uint256 => BlockNumbDisdIntsLib.BlockNumbDisdInts)) private currencyPaymentFeeByBlockNumber;
BlockNumbIntsLib.BlockNumbInts private tradeMakerMinimumFeeByBlockNumber;
BlockNumbIntsLib.BlockNumbInts private tradeTakerMinimumFeeByBlockNumber;
BlockNumbIntsLib.BlockNumbInts private paymentMinimumFeeByBlockNumber;
mapping(address => mapping(uint256 => BlockNumbIntsLib.BlockNumbInts)) private currencyPaymentMinimumFeeByBlockNumber;
BlockNumbReferenceCurrenciesLib.BlockNumbReferenceCurrencies private feeCurrencyByCurrencyBlockNumber;
BlockNumbUintsLib.BlockNumbUints private walletLockTimeoutByBlockNumber;
BlockNumbUintsLib.BlockNumbUints private cancelOrderChallengeTimeoutByBlockNumber;
BlockNumbUintsLib.BlockNumbUints private settlementChallengeTimeoutByBlockNumber;
BlockNumbUintsLib.BlockNumbUints private fraudStakeFractionByBlockNumber;
BlockNumbUintsLib.BlockNumbUints private walletSettlementStakeFractionByBlockNumber;
BlockNumbUintsLib.BlockNumbUints private operatorSettlementStakeFractionByBlockNumber;
BlockNumbFiguresLib.BlockNumbFigures private operatorSettlementStakeByBlockNumber;
uint256 public earliestSettlementBlockNumber;
bool public earliestSettlementBlockNumberUpdateDisabled;
//
// Events
// -----------------------------------------------------------------------------------------------------------------
event SetOperationalModeExitEvent();
event SetUpdateDelayBlocksEvent(uint256 fromBlockNumber, uint256 newBlocks);
event SetConfirmationBlocksEvent(uint256 fromBlockNumber, uint256 newBlocks);
event SetTradeMakerFeeEvent(uint256 fromBlockNumber, int256 nominal, int256[] discountTiers, int256[] discountValues);
event SetTradeTakerFeeEvent(uint256 fromBlockNumber, int256 nominal, int256[] discountTiers, int256[] discountValues);
event SetPaymentFeeEvent(uint256 fromBlockNumber, int256 nominal, int256[] discountTiers, int256[] discountValues);
event SetCurrencyPaymentFeeEvent(uint256 fromBlockNumber, address currencyCt, uint256 currencyId, int256 nominal,
int256[] discountTiers, int256[] discountValues);
event SetTradeMakerMinimumFeeEvent(uint256 fromBlockNumber, int256 nominal);
event SetTradeTakerMinimumFeeEvent(uint256 fromBlockNumber, int256 nominal);
event SetPaymentMinimumFeeEvent(uint256 fromBlockNumber, int256 nominal);
event SetCurrencyPaymentMinimumFeeEvent(uint256 fromBlockNumber, address currencyCt, uint256 currencyId, int256 nominal);
event SetFeeCurrencyEvent(uint256 fromBlockNumber, address referenceCurrencyCt, uint256 referenceCurrencyId,
address feeCurrencyCt, uint256 feeCurrencyId);
event SetWalletLockTimeoutEvent(uint256 fromBlockNumber, uint256 timeoutInSeconds);
event SetCancelOrderChallengeTimeoutEvent(uint256 fromBlockNumber, uint256 timeoutInSeconds);
event SetSettlementChallengeTimeoutEvent(uint256 fromBlockNumber, uint256 timeoutInSeconds);
event SetWalletSettlementStakeFractionEvent(uint256 fromBlockNumber, uint256 stakeFraction);
event SetOperatorSettlementStakeFractionEvent(uint256 fromBlockNumber, uint256 stakeFraction);
event SetOperatorSettlementStakeEvent(uint256 fromBlockNumber, int256 stakeAmount, address stakeCurrencyCt,
uint256 stakeCurrencyId);
event SetFraudStakeFractionEvent(uint256 fromBlockNumber, uint256 stakeFraction);
event SetEarliestSettlementBlockNumberEvent(uint256 earliestSettlementBlockNumber);
event DisableEarliestSettlementBlockNumberUpdateEvent();
//
// Constructor
// -----------------------------------------------------------------------------------------------------------------
constructor(address deployer) Ownable(deployer) public {
updateDelayBlocksByBlockNumber.addEntry(block.number, 0);
}
| enum OperationalMode {Normal, Exit}
//
// Variables
// -----------------------------------------------------------------------------------------------------------------
OperationalMode public operationalMode = OperationalMode.Normal;
BlockNumbUintsLib.BlockNumbUints private updateDelayBlocksByBlockNumber;
BlockNumbUintsLib.BlockNumbUints private confirmationBlocksByBlockNumber;
BlockNumbDisdIntsLib.BlockNumbDisdInts private tradeMakerFeeByBlockNumber;
BlockNumbDisdIntsLib.BlockNumbDisdInts private tradeTakerFeeByBlockNumber;
BlockNumbDisdIntsLib.BlockNumbDisdInts private paymentFeeByBlockNumber;
mapping(address => mapping(uint256 => BlockNumbDisdIntsLib.BlockNumbDisdInts)) private currencyPaymentFeeByBlockNumber;
BlockNumbIntsLib.BlockNumbInts private tradeMakerMinimumFeeByBlockNumber;
BlockNumbIntsLib.BlockNumbInts private tradeTakerMinimumFeeByBlockNumber;
BlockNumbIntsLib.BlockNumbInts private paymentMinimumFeeByBlockNumber;
mapping(address => mapping(uint256 => BlockNumbIntsLib.BlockNumbInts)) private currencyPaymentMinimumFeeByBlockNumber;
BlockNumbReferenceCurrenciesLib.BlockNumbReferenceCurrencies private feeCurrencyByCurrencyBlockNumber;
BlockNumbUintsLib.BlockNumbUints private walletLockTimeoutByBlockNumber;
BlockNumbUintsLib.BlockNumbUints private cancelOrderChallengeTimeoutByBlockNumber;
BlockNumbUintsLib.BlockNumbUints private settlementChallengeTimeoutByBlockNumber;
BlockNumbUintsLib.BlockNumbUints private fraudStakeFractionByBlockNumber;
BlockNumbUintsLib.BlockNumbUints private walletSettlementStakeFractionByBlockNumber;
BlockNumbUintsLib.BlockNumbUints private operatorSettlementStakeFractionByBlockNumber;
BlockNumbFiguresLib.BlockNumbFigures private operatorSettlementStakeByBlockNumber;
uint256 public earliestSettlementBlockNumber;
bool public earliestSettlementBlockNumberUpdateDisabled;
//
// Events
// -----------------------------------------------------------------------------------------------------------------
event SetOperationalModeExitEvent();
event SetUpdateDelayBlocksEvent(uint256 fromBlockNumber, uint256 newBlocks);
event SetConfirmationBlocksEvent(uint256 fromBlockNumber, uint256 newBlocks);
event SetTradeMakerFeeEvent(uint256 fromBlockNumber, int256 nominal, int256[] discountTiers, int256[] discountValues);
event SetTradeTakerFeeEvent(uint256 fromBlockNumber, int256 nominal, int256[] discountTiers, int256[] discountValues);
event SetPaymentFeeEvent(uint256 fromBlockNumber, int256 nominal, int256[] discountTiers, int256[] discountValues);
event SetCurrencyPaymentFeeEvent(uint256 fromBlockNumber, address currencyCt, uint256 currencyId, int256 nominal,
int256[] discountTiers, int256[] discountValues);
event SetTradeMakerMinimumFeeEvent(uint256 fromBlockNumber, int256 nominal);
event SetTradeTakerMinimumFeeEvent(uint256 fromBlockNumber, int256 nominal);
event SetPaymentMinimumFeeEvent(uint256 fromBlockNumber, int256 nominal);
event SetCurrencyPaymentMinimumFeeEvent(uint256 fromBlockNumber, address currencyCt, uint256 currencyId, int256 nominal);
event SetFeeCurrencyEvent(uint256 fromBlockNumber, address referenceCurrencyCt, uint256 referenceCurrencyId,
address feeCurrencyCt, uint256 feeCurrencyId);
event SetWalletLockTimeoutEvent(uint256 fromBlockNumber, uint256 timeoutInSeconds);
event SetCancelOrderChallengeTimeoutEvent(uint256 fromBlockNumber, uint256 timeoutInSeconds);
event SetSettlementChallengeTimeoutEvent(uint256 fromBlockNumber, uint256 timeoutInSeconds);
event SetWalletSettlementStakeFractionEvent(uint256 fromBlockNumber, uint256 stakeFraction);
event SetOperatorSettlementStakeFractionEvent(uint256 fromBlockNumber, uint256 stakeFraction);
event SetOperatorSettlementStakeEvent(uint256 fromBlockNumber, int256 stakeAmount, address stakeCurrencyCt,
uint256 stakeCurrencyId);
event SetFraudStakeFractionEvent(uint256 fromBlockNumber, uint256 stakeFraction);
event SetEarliestSettlementBlockNumberEvent(uint256 earliestSettlementBlockNumber);
event DisableEarliestSettlementBlockNumberUpdateEvent();
//
// Constructor
// -----------------------------------------------------------------------------------------------------------------
constructor(address deployer) Ownable(deployer) public {
updateDelayBlocksByBlockNumber.addEntry(block.number, 0);
}
| 24,831 |
2 | // It allows users to harvest from pool _pid: poolId / | function harvestPool(uint8 _pid) external;
| function harvestPool(uint8 _pid) external;
| 37,477 |
656 | // Set ETH amount | amountETH = amountETHRequired;
| amountETH = amountETHRequired;
| 45,060 |
18 | // contracts/interfaces/IFundingLockerFactory.sol/ pragma solidity 0.6.11; / | interface IFundingLockerFactory {
function owner(address) external view returns (address);
function isLocker(address) external view returns (bool);
function factoryType() external view returns (uint8);
function newLocker(address) external returns (address);
}
| interface IFundingLockerFactory {
function owner(address) external view returns (address);
function isLocker(address) external view returns (bool);
function factoryType() external view returns (uint8);
function newLocker(address) external returns (address);
}
| 1,533 |
107 | // Return the sell price of 1 individual token. / | function buyPrice()
public
view
returns(uint256)
| function buyPrice()
public
view
returns(uint256)
| 26,534 |
2 | // The project to which the redeemed tokens are associated. | uint256 projectId;
| uint256 projectId;
| 9,541 |
65 | // check if the milestone requires user to be whitelisted | if (whitelistedMilestones[milestoneIndex]) {
require(whitelist[_msgSender()], "The address must be whitelisted!");
}
| if (whitelistedMilestones[milestoneIndex]) {
require(whitelist[_msgSender()], "The address must be whitelisted!");
}
| 14,735 |
122 | // StakeStake asset-backed tokens / | function stake(uint256 value, address assetAdd)
public
whenNotPaused
returns(bool)
| function stake(uint256 value, address assetAdd)
public
whenNotPaused
returns(bool)
| 7,322 |
164 | // this will mean a service provider could start the program again with stakeServiceProviderBond() | isServiceProviderFullySetup = false;
| isServiceProviderFullySetup = false;
| 26,597 |
98 | // NOTE: Don't take performance fee in this scenario | } else {
| } else {
| 2,957 |
24 | // Update devAddr newValue address / | function updateDevAddr(address newValue) public onlyDev {
emit UpdateDevAddr(devAddr, newValue);
devAddr = newValue;
}
| function updateDevAddr(address newValue) public onlyDev {
emit UpdateDevAddr(devAddr, newValue);
devAddr = newValue;
}
| 2,401 |
79 | // CrowdSale reward | uint256 public constant CROWDSALE_TOKENS_NUMS = 67500000*TOKEN_UNIT;
| uint256 public constant CROWDSALE_TOKENS_NUMS = 67500000*TOKEN_UNIT;
| 75,964 |
14 | // loan period is in days so we convert to seconds, (606024 = 600) | uint256 loanPeriodSeconds = loanPeriod * 86400;
require(block.timestamp > (loanTime + loanPeriodSeconds), "Must have loaned banker for full loan time period");
uint256 rewardTime;
if (loanTime > 0) {
rewardTime = (loanTime - bankerIdToTimeStamp[bankerId]) + (block.timestamp - (loanTime + loanPeriodSeconds));
} else {
| uint256 loanPeriodSeconds = loanPeriod * 86400;
require(block.timestamp > (loanTime + loanPeriodSeconds), "Must have loaned banker for full loan time period");
uint256 rewardTime;
if (loanTime > 0) {
rewardTime = (loanTime - bankerIdToTimeStamp[bankerId]) + (block.timestamp - (loanTime + loanPeriodSeconds));
} else {
| 79,590 |
341 | // Selector of `log(bool,bool,address,uint256)`. | mstore(0x00, 0x4c123d57)
mstore(0x20, p0)
mstore(0x40, p1)
mstore(0x60, p2)
mstore(0x80, p3)
| mstore(0x00, 0x4c123d57)
mstore(0x20, p0)
mstore(0x40, p1)
mstore(0x60, p2)
mstore(0x80, p3)
| 30,603 |
188 | // Expiration time of the transaction | uint256 expiration;
| uint256 expiration;
| 2,005 |
38 | // staking not started | if (block.number < poolInfo.tokenAllocationStartBlock) {
return;
}
| if (block.number < poolInfo.tokenAllocationStartBlock) {
return;
}
| 72,216 |
276 | // fetches all the pools data/ return uint256 VUreinsurnacePool/ return uint256 LUreinsurnacePool/ return uint256 LUleveragePool/ return uint256 user leverage pool address | function getPoolsData()
external
view
returns (
uint256,
uint256,
uint256,
address
);
| function getPoolsData()
external
view
returns (
uint256,
uint256,
uint256,
address
);
| 50,650 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.