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 |
|---|---|---|---|---|
24 | // Calculates the amount of liquidity in the pair. For a SNWM pool, the liquidity in thepair is two times the amount of SNWM multiplied by the price of AVAX per SNWM. Onlyworks for SNWM pairs. Args:pair: SNWM pair to get liquidity inconversionFactor: the price of AVAX to SNWM Returns: the amount of liquidity in the pool in units of AVAX / | function getPngLiquidity(address pair, uint conversionFactor) public view returns (uint) {
(uint reserve0, uint reserve1, ) = IPangolinPair(pair).getReserves();
uint liquidity = 0;
// add the snwm straight up
if (IPangolinPair(pair).token0() == snwm) {
liquidity = liquidity.add(reserve0);
} else {
require(IPangolinPair(pair).token1() == snwm, 'LiquidityPoolManager::getPngLiquidity: One of the tokens in the pair must be SNWM');
liquidity = liquidity.add(reserve1);
}
uint oneToken = 1e18;
liquidity = liquidity.mul(conversionFactor).mul(2).div(oneToken);
return liquidity;
}
| function getPngLiquidity(address pair, uint conversionFactor) public view returns (uint) {
(uint reserve0, uint reserve1, ) = IPangolinPair(pair).getReserves();
uint liquidity = 0;
// add the snwm straight up
if (IPangolinPair(pair).token0() == snwm) {
liquidity = liquidity.add(reserve0);
} else {
require(IPangolinPair(pair).token1() == snwm, 'LiquidityPoolManager::getPngLiquidity: One of the tokens in the pair must be SNWM');
liquidity = liquidity.add(reserve1);
}
uint oneToken = 1e18;
liquidity = liquidity.mul(conversionFactor).mul(2).div(oneToken);
return liquidity;
}
| 6,417 |
14 | // Ensure the destination token is allowed to be transferred by Set TransferProxy | ERC20.ensureAllowance(
trade.destinationToken,
address(this),
setTransferProxy,
destinationTokenQuantity
);
return (
trade.destinationToken,
destinationTokenQuantity
| ERC20.ensureAllowance(
trade.destinationToken,
address(this),
setTransferProxy,
destinationTokenQuantity
);
return (
trade.destinationToken,
destinationTokenQuantity
| 9,616 |
57 | // function provide the current bonus rate | function getCurrentBonusRate() internal returns (uint8) {
if (getState() == State.Acquiantances) {
return 40;
}
if (getState() == State.PreSale) {
return 20;
}
if (getState() == State.CrowdFund) {
return 0;
} else {
return 0;
}
}
| function getCurrentBonusRate() internal returns (uint8) {
if (getState() == State.Acquiantances) {
return 40;
}
if (getState() == State.PreSale) {
return 20;
}
if (getState() == State.CrowdFund) {
return 0;
} else {
return 0;
}
}
| 1,171 |
162 | // clear all data associated with a motionID for hygiene purposes. / | function _closeMotion(uint motionID)
internal
| function _closeMotion(uint motionID)
internal
| 73,639 |
99 | // 1. Sanity check the input position, or add a new position of ID is 0. | if (id == 0) {
id = nextPositionID++;
positions[id].goblin = goblin;
positions[id].owner = msg.sender;
} else {
| if (id == 0) {
id = nextPositionID++;
positions[id].goblin = goblin;
positions[id].owner = msg.sender;
} else {
| 47,541 |
6 | // @desc provides the name of the token/ | function name() external view returns (string) {
return NAME;
}
| function name() external view returns (string) {
return NAME;
}
| 79,495 |
2 | // libraries / because they are saved in storage and storage will be cleaned up on proxy clones (right?) | {
clowderMain = ClowderMain(_clowderMain);
reservoirOracleAddress = _reservoirOracleAddress;
}
| {
clowderMain = ClowderMain(_clowderMain);
reservoirOracleAddress = _reservoirOracleAddress;
}
| 18,711 |
113 | // update rewardCycleBlock | nextAvailableClaimDate[msg.sender] =
block.timestamp +
getRewardCycleBlock();
emit ClaimEthSuccessfully(
msg.sender,
reward,
nextAvailableClaimDate[msg.sender]
);
| nextAvailableClaimDate[msg.sender] =
block.timestamp +
getRewardCycleBlock();
emit ClaimEthSuccessfully(
msg.sender,
reward,
nextAvailableClaimDate[msg.sender]
);
| 16,438 |
1 | // mapping(address => Land) public landsByAddress; | uint256 public landsCounter;
mapping(address => uint256) public CounterByAddress;
mapping (address => mapping (uint => Land)) public landsByAddress;
| uint256 public landsCounter;
mapping(address => uint256) public CounterByAddress;
mapping (address => mapping (uint => Land)) public landsByAddress;
| 48,450 |
18 | // Returns the rate of interest collected to be distributed to the protocol reserve. | function reserveRate() external view returns (uint);
| function reserveRate() external view returns (uint);
| 34,845 |
323 | // Resolves a price request that has expired or been disputed and a price is available from the DVM. This will revert if the unique request ID does not match the hashed request parameters. This also marks the request as settled, therefore this method can only be triggered once per eligible request. | function _settle(
address requester,
bytes32 identifier,
uint32 timestamp,
bytes memory ancillaryData,
Request memory request
| function _settle(
address requester,
bytes32 identifier,
uint32 timestamp,
bytes memory ancillaryData,
Request memory request
| 15,159 |
7 | // If the verifier already verified this hash, throw. | if(hashes[_thehash].verifications[msg.sender] == true) {
Error('msg sender already verified this.');
return 'msg sender already verified this.';
}
| if(hashes[_thehash].verifications[msg.sender] == true) {
Error('msg sender already verified this.');
return 'msg sender already verified this.';
}
| 26,923 |
61 | // ERC165 interface ID of ERC721Metadata | bytes4 internal constant ERC721_METADATA_INTERFACE_ID = 0x5b5e139f;
bool internal _unlocked;
| bytes4 internal constant ERC721_METADATA_INTERFACE_ID = 0x5b5e139f;
bool internal _unlocked;
| 30,886 |
37 | // timeout capped at TIMEOUT1 | if (timeout > TIMEOUT1) timeout = TIMEOUT1;
_slideEndTime = (block.timestamp).add(timeout);
| if (timeout > TIMEOUT1) timeout = TIMEOUT1;
_slideEndTime = (block.timestamp).add(timeout);
| 45,055 |
14 | // Retract an item's latest revision. Revision 0 cannot be retracted. itemId itemId of the item. / | function retractLatestRevision(bytes32 itemId) external;
| function retractLatestRevision(bytes32 itemId) external;
| 13,226 |
257 | // See {ERC20-transferFrom} from The address to transfer tokens from to The address to transfer tokens to value The amount of tokens to transferreturn success A boolean indicating whether the operation was successful / | function transferFrom(address from, address to, uint256 value)
override public
notRestrictedTransferFrom(msg.sender, from, to, value)
returns (bool success)
{
success = ERC20.transferFrom(from, to, value);
}
| function transferFrom(address from, address to, uint256 value)
override public
notRestrictedTransferFrom(msg.sender, from, to, value)
returns (bool success)
{
success = ERC20.transferFrom(from, to, value);
}
| 29,847 |
2 | // Simple hash signatures checker. _hash Signed hash.return Verification status. / | function isSigned(bytes32 _hash) public view returns (bool)
| function isSigned(bytes32 _hash) public view returns (bool)
| 30,937 |
20 | // External Supporter struct to allow tracking reserved amounts by supporter/ | struct ExternalSupporter {
uint256 reservedAmount;
}
| struct ExternalSupporter {
uint256 reservedAmount;
}
| 36,311 |
15 | // Mock of the vault (from yearn.finance) to test deposit/withdraw/yield harvest locally, NOTE: this vault mock keeps 15% in reserve (otherwise 0.5% fee is applied) | contract InvestmentVaultYUSDCv2Mock is ERC20("yUSDCMOCK", "yUSDC"), IYearnVaultUSDCv2 {
using SafeMath for uint256;
using SafeERC20 for IERC20;
address private constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD;
address public override token;
address public tokenStash;
uint256 public totalShares;
mapping(address => uint256) shares;
uint256 public balance;
// tokenStash should hold token amount and have allowance so vault mock get them as yield when needed
constructor(address _token) public {
token = _token;
totalShares = 1e6;
balance = 1e6;
_setupDecimals(6);
}
// returns price of 1 lpToken (share) in amount of base asset (USDC)
function pricePerShare() external override view returns (uint256) {
//return IERC20(token).balanceOf(address(this)).mul(1e6).div(totalShares);
return balance.mul(1e6).div(totalShares);
}
// deposit USDC and receive lpTokens (shares)
function deposit(uint _amount, address _recipient) external override returns (uint256) {
IERC20(token).safeTransferFrom(msg.sender, tokenStash, _amount);
uint256 sharesToAdd = _amount.mul(1e6).div(this.pricePerShare());
totalShares = totalShares.add(sharesToAdd);
shares[_recipient] = shares[_recipient].add(sharesToAdd);
_mint(_recipient, sharesToAdd);
balance = balance.add(_amount);
rebalance();
return sharesToAdd;
}
// withdraw amount of shares and return USDC
function withdraw(uint _shares, address _recipient, uint _maxloss) external override returns (uint256) {
IERC20(this).safeTransferFrom(msg.sender, BURN_ADDRESS, _shares);
uint256 amount = this.pricePerShare().mul(_shares).div(1e6);
if (amount <= IERC20(token).balanceOf(address(this))) {
// no fee applied
IERC20(token).safeTransferFrom(tokenStash, _recipient, amount);
totalShares = totalShares.sub(_shares);
shares[msg.sender] = shares[msg.sender].sub(_shares);
balance = balance.sub(amount);
} else {
// 0.5% fee applied to portion exceeding safe amount
uint256 amountWithoutFee = IERC20(token).balanceOf(address(this));
uint256 amountWithFee = amount.sub(amountWithoutFee);
// transfer from stash amount with fee deducted
IERC20(token).safeTransferFrom(tokenStash, _recipient, amountWithoutFee.add(amountWithFee.mul(995).div(1000)));
totalShares = totalShares.sub(_shares);
shares[msg.sender] = shares[msg.sender].sub(_shares);
balance = balance.sub(amount);
amount = amountWithoutFee.add(amountWithFee.mul(995).div(1000));
}
rebalance();
return amount;
}
function availableDepositLimit() external override view returns(uint) {
return 1000000000000000000;
}
function totalAssets() external override view returns(uint) {
return balance;
}
function earnProfit(uint _amount) public {
balance = balance.add(_amount);
IERC20(token).safeTransferFrom(tokenStash, address(this), _amount);
}
// leave 15% of balance of token on this contract, place other to stash
function rebalance() internal {
// transfer all tokens to stash address
if (IERC20(token).balanceOf(address(this)) > 0) {
IERC20(token).transfer(tokenStash, IERC20(token).balanceOf(address(this)));
}
// get 15% of expected balance from stash address
if (IERC20(token).balanceOf(tokenStash) >= balance) {
IERC20(token).safeTransferFrom(tokenStash, address(this), balance.mul(15).div(100));
} else {
revert("not enough tokens in stash");
}
}
function setStash(address _stash) public {
tokenStash = _stash;
rebalance();
}
} | contract InvestmentVaultYUSDCv2Mock is ERC20("yUSDCMOCK", "yUSDC"), IYearnVaultUSDCv2 {
using SafeMath for uint256;
using SafeERC20 for IERC20;
address private constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD;
address public override token;
address public tokenStash;
uint256 public totalShares;
mapping(address => uint256) shares;
uint256 public balance;
// tokenStash should hold token amount and have allowance so vault mock get them as yield when needed
constructor(address _token) public {
token = _token;
totalShares = 1e6;
balance = 1e6;
_setupDecimals(6);
}
// returns price of 1 lpToken (share) in amount of base asset (USDC)
function pricePerShare() external override view returns (uint256) {
//return IERC20(token).balanceOf(address(this)).mul(1e6).div(totalShares);
return balance.mul(1e6).div(totalShares);
}
// deposit USDC and receive lpTokens (shares)
function deposit(uint _amount, address _recipient) external override returns (uint256) {
IERC20(token).safeTransferFrom(msg.sender, tokenStash, _amount);
uint256 sharesToAdd = _amount.mul(1e6).div(this.pricePerShare());
totalShares = totalShares.add(sharesToAdd);
shares[_recipient] = shares[_recipient].add(sharesToAdd);
_mint(_recipient, sharesToAdd);
balance = balance.add(_amount);
rebalance();
return sharesToAdd;
}
// withdraw amount of shares and return USDC
function withdraw(uint _shares, address _recipient, uint _maxloss) external override returns (uint256) {
IERC20(this).safeTransferFrom(msg.sender, BURN_ADDRESS, _shares);
uint256 amount = this.pricePerShare().mul(_shares).div(1e6);
if (amount <= IERC20(token).balanceOf(address(this))) {
// no fee applied
IERC20(token).safeTransferFrom(tokenStash, _recipient, amount);
totalShares = totalShares.sub(_shares);
shares[msg.sender] = shares[msg.sender].sub(_shares);
balance = balance.sub(amount);
} else {
// 0.5% fee applied to portion exceeding safe amount
uint256 amountWithoutFee = IERC20(token).balanceOf(address(this));
uint256 amountWithFee = amount.sub(amountWithoutFee);
// transfer from stash amount with fee deducted
IERC20(token).safeTransferFrom(tokenStash, _recipient, amountWithoutFee.add(amountWithFee.mul(995).div(1000)));
totalShares = totalShares.sub(_shares);
shares[msg.sender] = shares[msg.sender].sub(_shares);
balance = balance.sub(amount);
amount = amountWithoutFee.add(amountWithFee.mul(995).div(1000));
}
rebalance();
return amount;
}
function availableDepositLimit() external override view returns(uint) {
return 1000000000000000000;
}
function totalAssets() external override view returns(uint) {
return balance;
}
function earnProfit(uint _amount) public {
balance = balance.add(_amount);
IERC20(token).safeTransferFrom(tokenStash, address(this), _amount);
}
// leave 15% of balance of token on this contract, place other to stash
function rebalance() internal {
// transfer all tokens to stash address
if (IERC20(token).balanceOf(address(this)) > 0) {
IERC20(token).transfer(tokenStash, IERC20(token).balanceOf(address(this)));
}
// get 15% of expected balance from stash address
if (IERC20(token).balanceOf(tokenStash) >= balance) {
IERC20(token).safeTransferFrom(tokenStash, address(this), balance.mul(15).div(100));
} else {
revert("not enough tokens in stash");
}
}
function setStash(address _stash) public {
tokenStash = _stash;
rebalance();
}
} | 13,659 |
0 | // Construct a new money market underlying_ The address of the underlying asset comptroller_ The address of the Comptroller interestRateModel_ The address of the interest rate model initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18 name_ ERC-20 name of this token symbol_ ERC-20 symbol of this token decimals_ ERC-20 decimal precision of this token admin_ Address of the administrator of this token / | constructor(address underlying_,
ComptrollerInterface comptroller_,
InterestRateModel interestRateModel_,
uint initialExchangeRateMantissa_,
string memory name_,
string memory symbol_,
uint8 decimals_,
address payable admin_
| constructor(address underlying_,
ComptrollerInterface comptroller_,
InterestRateModel interestRateModel_,
uint initialExchangeRateMantissa_,
string memory name_,
string memory symbol_,
uint8 decimals_,
address payable admin_
| 4,246 |
24 | // for withdraw admin to user1st step function// function for approval of multi token to send from admin wallet to all user wallet | function multiApprovalbyAdmin(
address[] memory tokenContracts,
uint256 _values
| function multiApprovalbyAdmin(
address[] memory tokenContracts,
uint256 _values
| 14,451 |
12 | // Transfer in offer asset - erc20 to this contract | ERC20(erc20Address).safeTransferFrom(address(msg.sender), address(this), erc20Amount);
_abonus.switchToEthForNTokenOffer.value(ethMining)(nTokenAddress);
| ERC20(erc20Address).safeTransferFrom(address(msg.sender), address(this), erc20Amount);
_abonus.switchToEthForNTokenOffer.value(ethMining)(nTokenAddress);
| 53,350 |
186 | // Address of the contract responsible for post rebase syncs with AMMs | address private _deprecated_rebaseHooksAddr = address(0);
| address private _deprecated_rebaseHooksAddr = address(0);
| 67,808 |
8 | // Create additional privacy (only for receiver hashed transfers) | uint256 private privacyFund;
| uint256 private privacyFund;
| 50,799 |
67 | // _mints The set of {to: address, amount: uint256} pairs / | function batchMint(MintArgs[] calldata _mints) external {
require(msg.sender == minter);
for (uint256 i = 0; i < _mints.length; i++) {
_mint(_mints[i].to, _mints[i].amount);
}
| function batchMint(MintArgs[] calldata _mints) external {
require(msg.sender == minter);
for (uint256 i = 0; i < _mints.length; i++) {
_mint(_mints[i].to, _mints[i].amount);
}
| 59,216 |
7 | // Sets the base URI for the token's metadata./baseURI The new base URI. | function setURI(string memory baseURI) external onlyOwner {
_setURI(baseURI);
}
| function setURI(string memory baseURI) external onlyOwner {
_setURI(baseURI);
}
| 24,513 |
236 | // withdraw unlock lp | function withdrawUnlock(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(pool.lockedSeconds > 0 , "invalid pool");
updatePool(_pid);
uint256 unlockAmount = 0;
uint256 checkTime = block.timestamp;
uint256 index = 0;
if( user.lockAmount > 0 && pool.lockedSeconds > 0){
WithdrawOrder[] memory orders = userWithdrawInfo[_pid][msg.sender];
uint256 len = orders.length;
if( len > 0 ){
index = len ;
for (uint256 i = 0; i < len; i++) {
if( orders[i].orderTime.add(pool.lockedSeconds) <= checkTime ){
unlockAmount = unlockAmount.add( orders[i].amount);
}
else{
index = i;
break;
}
}
//pop some orders
for (uint256 i = 0; i < len - index; i++) {
userWithdrawInfo[_pid][msg.sender][i] = userWithdrawInfo[_pid][msg.sender][i + index];
}
for (uint256 j = len -index; j < len ; j++) {
userWithdrawInfo[_pid][msg.sender].pop();
}
}
}
uint256 pendingAmount = user.amount.mul(pool.accBonusPerShare).div(1e12).sub(user.rewardDebt);
if (pendingAmount > 0) {
TransferHelper.safeTransfer( address(pool.rewardToken), msg.sender , pendingAmount );
}
if (unlockAmount > 0 ) {
user.amount = user.amount.sub(unlockAmount);
user.lockAmount = user.lockAmount.sub(unlockAmount);
user.releaseAmount = user.releaseAmount.add( unlockAmount );
pool.lpAmount = pool.lpAmount.sub(unlockAmount);
pool.lpToken.safeTransfer(address(msg.sender), unlockAmount);
}
user.rewardDebt = user.amount.mul(pool.accBonusPerShare).div(1e12);
emit WithdrawUnlock(msg.sender, _pid, address(pool.lpToken), unlockAmount);
}
| function withdrawUnlock(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(pool.lockedSeconds > 0 , "invalid pool");
updatePool(_pid);
uint256 unlockAmount = 0;
uint256 checkTime = block.timestamp;
uint256 index = 0;
if( user.lockAmount > 0 && pool.lockedSeconds > 0){
WithdrawOrder[] memory orders = userWithdrawInfo[_pid][msg.sender];
uint256 len = orders.length;
if( len > 0 ){
index = len ;
for (uint256 i = 0; i < len; i++) {
if( orders[i].orderTime.add(pool.lockedSeconds) <= checkTime ){
unlockAmount = unlockAmount.add( orders[i].amount);
}
else{
index = i;
break;
}
}
//pop some orders
for (uint256 i = 0; i < len - index; i++) {
userWithdrawInfo[_pid][msg.sender][i] = userWithdrawInfo[_pid][msg.sender][i + index];
}
for (uint256 j = len -index; j < len ; j++) {
userWithdrawInfo[_pid][msg.sender].pop();
}
}
}
uint256 pendingAmount = user.amount.mul(pool.accBonusPerShare).div(1e12).sub(user.rewardDebt);
if (pendingAmount > 0) {
TransferHelper.safeTransfer( address(pool.rewardToken), msg.sender , pendingAmount );
}
if (unlockAmount > 0 ) {
user.amount = user.amount.sub(unlockAmount);
user.lockAmount = user.lockAmount.sub(unlockAmount);
user.releaseAmount = user.releaseAmount.add( unlockAmount );
pool.lpAmount = pool.lpAmount.sub(unlockAmount);
pool.lpToken.safeTransfer(address(msg.sender), unlockAmount);
}
user.rewardDebt = user.amount.mul(pool.accBonusPerShare).div(1e12);
emit WithdrawUnlock(msg.sender, _pid, address(pool.lpToken), unlockAmount);
}
| 35,302 |
28 | // The updated body of smart contract.%6 fund will be transferred to ParcelX advisors automatically./ | contract RoutineGPX is MultiOwnable, Pausable {
using SafeMath for uint256;
function RoutineGPX(address[] _multiOwners, uint _multiRequires)
MultiOwnable(_multiOwners, _multiRequires) public {
}
event Deposit(address indexed who, uint256 value);
event Withdraw(address indexed who, uint256 value, address indexed lastApprover, string extra);
function getTime() public view returns (uint256) {
return now;
}
function getBalance() public view returns (uint256) {
return this.balance;
}
/**
* FEATURE : Buyable
* minimum of 0.001 ether for purchase in the public, pre-ico, and private sale
* Code caculates the endtime via python:
* d1 = datetime.datetime.strptime("2018-10-31 23:59:59", '%Y-%m-%d %H:%M:%S')
* t = time.mktime(d1.timetuple())
* d2 = datetime.datetime.fromtimestamp(t)
* assert (d1 == d2) # print d2.strftime('%Y-%m-%d %H:%M:%S')
* print t # = 1541001599
*/
function buy() payable whenNotPaused public returns (bool) {
Deposit(msg.sender, msg.value);
require(msg.value >= 0.001 ether);
return true;
}
// gets called when no other function matches
function () payable public {
if (msg.value > 0) {
buy();
}
}
function execute(address _to, uint256 _value, string _extra) mostOwner(keccak256(msg.data)) external returns (bool){
require(_to != address(0));
_to.transfer(_value); // Prevent using call() or send()
Withdraw(_to, _value, msg.sender, _extra);
return true;
}
} | contract RoutineGPX is MultiOwnable, Pausable {
using SafeMath for uint256;
function RoutineGPX(address[] _multiOwners, uint _multiRequires)
MultiOwnable(_multiOwners, _multiRequires) public {
}
event Deposit(address indexed who, uint256 value);
event Withdraw(address indexed who, uint256 value, address indexed lastApprover, string extra);
function getTime() public view returns (uint256) {
return now;
}
function getBalance() public view returns (uint256) {
return this.balance;
}
/**
* FEATURE : Buyable
* minimum of 0.001 ether for purchase in the public, pre-ico, and private sale
* Code caculates the endtime via python:
* d1 = datetime.datetime.strptime("2018-10-31 23:59:59", '%Y-%m-%d %H:%M:%S')
* t = time.mktime(d1.timetuple())
* d2 = datetime.datetime.fromtimestamp(t)
* assert (d1 == d2) # print d2.strftime('%Y-%m-%d %H:%M:%S')
* print t # = 1541001599
*/
function buy() payable whenNotPaused public returns (bool) {
Deposit(msg.sender, msg.value);
require(msg.value >= 0.001 ether);
return true;
}
// gets called when no other function matches
function () payable public {
if (msg.value > 0) {
buy();
}
}
function execute(address _to, uint256 _value, string _extra) mostOwner(keccak256(msg.data)) external returns (bool){
require(_to != address(0));
_to.transfer(_value); // Prevent using call() or send()
Withdraw(_to, _value, msg.sender, _extra);
return true;
}
} | 32,103 |
14 | // withdraw directly to curve LP token, this is what we primarily use | function withdrawAndUnwrap(uint256 _amount, bool _claim)
external
returns (bool);
| function withdrawAndUnwrap(uint256 _amount, bool _claim)
external
returns (bool);
| 18,817 |
11 | // Multiply the price by the decimal adjuster to get the normalized result. | return uint256(_price) * feedDecimalAdjuster[_currency];
| return uint256(_price) * feedDecimalAdjuster[_currency];
| 13,839 |
14 | // string memory _quantity | {
| {
| 32,101 |
83 | // internal helper function to calculate fee per token multiplier used inswap fee calculations swapFee swap fee for the tokens / | function _feePerToken(uint256 swapFee) internal pure returns (uint256) {
return swapFee / NUM_TOKENS;
}
| function _feePerToken(uint256 swapFee) internal pure returns (uint256) {
return swapFee / NUM_TOKENS;
}
| 12,717 |
93 | // @inheritdoc IReserve | function getToken() external view override returns (IERC20) {
return token;
}
| function getToken() external view override returns (IERC20) {
return token;
}
| 32,702 |
51 | // Hook that is called after any transfer of tokens. This includesminting and burning. Calling conditions: - when `from` and `to` are both non-zero, `amount` of ``from``'s tokenshas been transferred to `to`.- when `from` is zero, `amount` tokens have been minted for `to`.- when `to` is zero, `amount` of ``from``'s tokens have been burned.- `from` and `to` are never both zero. To learn more about hooks, head to xref:ROOT:extending-contracts.adocusing-hooks[Using Hooks]. / | function _afterTokenTransfer(
address from,
address to,
uint256 amount
| function _afterTokenTransfer(
address from,
address to,
uint256 amount
| 27,031 |
11 | // Admin errors/Royalty percentage too high | error Setup_RoyaltyPercentageTooHigh(uint16 maxRoyaltyBPS);
| error Setup_RoyaltyPercentageTooHigh(uint16 maxRoyaltyBPS);
| 17,332 |
32 | // The `to` address cannot be the null address. | if (to == address(0)) {
return (false, bytes1(hex"57")); // invalid receiver
}
| if (to == address(0)) {
return (false, bytes1(hex"57")); // invalid receiver
}
| 23,387 |
3 | // this swap function is used to trade from one token to anotherthe inputs are self explainatorytoken in = the token address you want to trade out oftoken out = the token address you want as the output of this tradeamount in = the amount of tokens you are sending inamount out Min = the minimum amount of tokens you want out of the tradeto = the address you want the tokens to be sent to |
function swap(
address _tokenIn,
address _tokenOut,
uint256 _amountIn,
uint256 _amountOutMin,
address _to
|
function swap(
address _tokenIn,
address _tokenOut,
uint256 _amountIn,
uint256 _amountOutMin,
address _to
| 17,907 |
0 | // Constants related to the betting rules. | uint256 constant BET_AMT = 0.2 ether;
uint8 constant NUM_BETS = 3;
| uint256 constant BET_AMT = 0.2 ether;
uint8 constant NUM_BETS = 3;
| 15,390 |
96 | // return {uint256} totalToken / | function getTotalToken() public view returns (uint256) {
return _token.balanceOf(getContractAddress());
}
| function getTotalToken() public view returns (uint256) {
return _token.balanceOf(getContractAddress());
}
| 36,101 |
19 | // If there are SHER rewards still available (we didn't surpass zeroRewardsStartTVL)... | if (slopeRewardsAvailable != 0) {
| if (slopeRewardsAvailable != 0) {
| 62,262 |
33 | // check sum | require(0 != sum);
| require(0 != sum);
| 34,058 |
5 | // closingPrice The price the oracle recorded after the elapse runTime of the bet/ betID The ID of the bet to settle | function settleBet(uint256 betID, uint256 closingPrice) external override onlyOracle {
BetDetails memory closeBetDetails = betDetails[betID];
require(closeBetDetails.endTime <= block.timestamp, "PepeBet: UnelapsedBet");
require(closeBetDetails.active, "PepeBet: InactiveBet");
require(liquidityPool != address(0), "PepeBet: LiquidityPoolNotSet");
betDetails[betID].active = false;
betDetails[betID].closingPrice = closingPrice;
if (closeBetDetails.isLong) {
if (closingPrice >= closeBetDetails.openingPrice) {
payoutWinnings(closeBetDetails.initiator, closeBetDetails.wagerAmount, closeBetDetails.betId);
return;
}
emit SettledBet(closeBetDetails.initiator, betID, false, 0);
} else {
if (closeBetDetails.openingPrice >= closingPrice) {
payoutWinnings(closeBetDetails.initiator, closeBetDetails.wagerAmount, closeBetDetails.betId);
return;
}
emit SettledBet(closeBetDetails.initiator, betID, false, 0);
}
}
| function settleBet(uint256 betID, uint256 closingPrice) external override onlyOracle {
BetDetails memory closeBetDetails = betDetails[betID];
require(closeBetDetails.endTime <= block.timestamp, "PepeBet: UnelapsedBet");
require(closeBetDetails.active, "PepeBet: InactiveBet");
require(liquidityPool != address(0), "PepeBet: LiquidityPoolNotSet");
betDetails[betID].active = false;
betDetails[betID].closingPrice = closingPrice;
if (closeBetDetails.isLong) {
if (closingPrice >= closeBetDetails.openingPrice) {
payoutWinnings(closeBetDetails.initiator, closeBetDetails.wagerAmount, closeBetDetails.betId);
return;
}
emit SettledBet(closeBetDetails.initiator, betID, false, 0);
} else {
if (closeBetDetails.openingPrice >= closingPrice) {
payoutWinnings(closeBetDetails.initiator, closeBetDetails.wagerAmount, closeBetDetails.betId);
return;
}
emit SettledBet(closeBetDetails.initiator, betID, false, 0);
}
}
| 17,744 |
18 | // Only owner (EVTMaster Contract) | function mint(address _to, uint256 amount) public onlyOwner returns (bool) {
require(totalSupply.add(amount, 'EVT::mint: mint amount overflows') <= maxSupply, 'EVT::mint: max supply exceeded');
_mint(_to, amount);
return true;
}
| function mint(address _to, uint256 amount) public onlyOwner returns (bool) {
require(totalSupply.add(amount, 'EVT::mint: mint amount overflows') <= maxSupply, 'EVT::mint: max supply exceeded');
_mint(_to, amount);
return true;
}
| 37,939 |
5 | // comptroller_ The address of the comptroller, which will be consulted for market listing status v1PriceOracle_ The address of the v1 price oracle, which will continue to operate and hold prices for collateral assets / | constructor(address comptroller_,
address v1PriceOracle_
| constructor(address comptroller_,
address v1PriceOracle_
| 48,740 |
326 | // Function to initialize the contract stakingAddress must be initialized separately after Staking contract is deployed delegateManagerAddress must be initialized separately after DelegateManager contract is deployed serviceTypeManagerAddress must be initialized separately after ServiceTypeManager contract is deployed claimsManagerAddress must be initialized separately after ClaimsManager contract is deployed _governanceAddress - Governance proxy address / | function initialize (
| function initialize (
| 41,272 |
544 | // A bitmap currency can only ever hold debt in this currency | require(localCurrencyId == accountContext.bitmapCurrencyId);
| require(localCurrencyId == accountContext.bitmapCurrencyId);
| 63,198 |
15 | // Accrue token to the market by updating the borrow index To avoid revert: no over/underflow token The token whose borrow index to update mToken The market whose borrow index to update marketBorrowIndex The market borrow index / | function updateTokenBorrowIndexInternal(address token, address mToken, uint marketBorrowIndex) internal {
// Non-token market's speed will always be 0, 0 speed token market will also update nothing
if (isLendingPool == true && farmStates[token].speeds[mToken] > 0 && marketBorrowIndex > 0) {
(uint224 _index, uint32 _block) = newTokenBorrowIndexInternal(token, mToken, marketBorrowIndex);
MarketState storage borrowState = farmStates[token].borrowState[mToken];
borrowState.index = _index;
borrowState.block = _block;
}
}
| function updateTokenBorrowIndexInternal(address token, address mToken, uint marketBorrowIndex) internal {
// Non-token market's speed will always be 0, 0 speed token market will also update nothing
if (isLendingPool == true && farmStates[token].speeds[mToken] > 0 && marketBorrowIndex > 0) {
(uint224 _index, uint32 _block) = newTokenBorrowIndexInternal(token, mToken, marketBorrowIndex);
MarketState storage borrowState = farmStates[token].borrowState[mToken];
borrowState.index = _index;
borrowState.block = _block;
}
}
| 25,330 |
10 | // Withdraws funds from this contract, debiting the user's wallet. / | function withdraw(
bytes32[] walletIDs,
address[] recipients,
uint256[] values,
uint64[] nonces,
uint8[] v,
bytes32[] r,
bytes32[] s
| function withdraw(
bytes32[] walletIDs,
address[] recipients,
uint256[] values,
uint64[] nonces,
uint8[] v,
bytes32[] r,
bytes32[] s
| 20,879 |
35 | // Farm distributes the ERC20 rewards based on staked LP to each user. | contract Farm {
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.
uint256 lastClaimTime;
uint256 withdrawTime;
// We do some fancy math here. Basically, any point in time, the amount of ERC20s
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accERC20PerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
// 1. The pool's `accERC20PerShare` (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 stakingToken; // Address of staking token contract.
uint256 allocPoint; // How many allocation points assigned to this pool. ERC20s to distribute per block.
uint256 lastRewardBlock; // Last block number that ERC20s distribution occurs.
uint256 accERC20PerShare; // Accumulated ERC20s per share, times 1e36.
uint256 supply; // changes with unstakes.
bool isLP; // if the staking token is an LP token.
bool isBurnable; // if the staking token is burnable
}
// Address of the ERC20 Token contract.
IERC20 public erc20;
// The total amount of ERC20 that's paid out as reward.
uint256 public paidOut;
// ERC20 tokens rewarded per block.
uint256 public rewardPerBlock;
// Manager interface to get globals for all farms.
IFarmManager public manager;
// Info of each pool.
PoolInfo[] public poolInfo;
// Info of each user that stakes LP tokens.
mapping (uint256 => mapping (address => UserInfo)) public userInfo;
// Total allocation points. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint;
// The block number when farming starts.
uint256 public startBlock;
// Seconds per epoch (1 day)
uint256 public constant SECS_EPOCH = 86400;
// events
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid);
event Claim(address indexed user, uint256 indexed pid);
event Unstake(address indexed user, uint256 indexed pid);
event Initialize(IERC20 erc20, uint256 rewardPerBlock, uint256 startBlock, address manager);
constructor(IERC20 _erc20, uint256 _rewardPerBlock, uint256 _startBlock, address _manager) public {
erc20 = _erc20;
rewardPerBlock = _rewardPerBlock;
startBlock = _startBlock;
manager = IFarmManager(_manager);
emit Initialize(_erc20, _rewardPerBlock, _startBlock, _manager);
}
// Fund the farm, increase the end block.
function fund(address _funder, uint256 _amount) external {
require(msg.sender == address(manager), "fund: sender is not manager");
erc20.safeTransferFrom(_funder, address(this), _amount);
}
// Update the given pool's ERC20 allocation point. Can only be called by the manager.
function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) external {
require(msg.sender == address(manager), "set: sender is not manager");
if (_withUpdate) {
massUpdatePools();
}
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);
poolInfo[_pid].allocPoint = _allocPoint;
}
// Add a new staking token to the pool. Can only be called by the manager.
function add(uint256 _allocPoint, IERC20 _stakingToken, bool _isLP, bool _isBurnable, bool _withUpdate) external {
require(msg.sender == address(manager), "fund: sender is not manager");
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(PoolInfo({
stakingToken: _stakingToken,
supply: 0,
allocPoint: _allocPoint,
lastRewardBlock: lastRewardBlock,
accERC20PerShare: 0,
isLP: _isLP,
isBurnable: _isBurnable
}));
}
// 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);
}
}
// Update reward variables of the given pool to be up-to-date.
function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
uint256 lastBlock = block.number;
if (lastBlock <= pool.lastRewardBlock) {
return;
}
if (pool.supply == 0) {
pool.lastRewardBlock = lastBlock;
return;
}
uint256 nrOfBlocks = lastBlock.sub(pool.lastRewardBlock);
uint256 erc20Reward = nrOfBlocks.mul(rewardPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
pool.accERC20PerShare = pool.accERC20PerShare.add(erc20Reward.mul(1e36).div(pool.supply));
pool.lastRewardBlock = block.number;
}
// move LP tokens from one farm to another. only callable by Manager.
function move(uint256 _pid, address _mover) external {
require(msg.sender == address(manager), "move: sender is not manager");
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_mover];
updatePool(_pid);
uint256 pendingAmount = user.amount.mul(pool.accERC20PerShare).div(1e36).sub(user.rewardDebt);
erc20Transfer(_mover, pendingAmount);
pool.supply = pool.supply.sub(user.amount);
pool.stakingToken.safeTransfer(address(manager), user.amount);
user.amount = 0;
user.rewardDebt = user.amount.mul(pool.accERC20PerShare).div(1e36);
emit Withdraw(msg.sender, _pid);
}
// Deposit LP tokens to Farm for ERC20 allocation.
// can come from manager or user address directly.
// In the case the call is coming from the manager, msg.sender is the manager.
function deposit(uint256 _pid, address _depositor, uint256 _amount) external {
require(manager.getPaused()==false, "deposit: farm paused");
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_depositor];
require(user.withdrawTime == 0, "deposit: user is unstaking");
// If we're not called by the farm manager, then we must ensure that the caller is the depositor.
// This way we avoid the case where someone else commits the deposit, after the depositor
// granted allowance to the farm.
if(msg.sender != address(manager)) {
require(msg.sender == _depositor, "deposit: the caller must be the depositor");
}
updatePool(_pid);
if (user.amount > 0) {
uint256 pendingAmount = user.amount.mul(pool.accERC20PerShare).div(1e36).sub(user.rewardDebt);
erc20Transfer(_depositor, pendingAmount);
}
// We tranfer from the msg.sender, because in the case when we're called by the farm manager (change pool scenario)
// it's the FM who owns the tokens, not the depositor (who in this case is the user who changes pools).
pool.stakingToken.safeTransferFrom(msg.sender, address(this), _amount);
pool.supply = pool.supply.add(_amount);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accERC20PerShare).div(1e36);
emit Deposit(_depositor, _pid, _amount);
}
// Distribute rewards and start unstake period.
function withdraw(uint256 _pid) external {
require(manager.getPaused()==false, "withdraw: farm paused");
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount > 0, "withdraw: amount must be greater than 0");
require(user.withdrawTime == 0, "withdraw: user is unstaking");
updatePool(_pid);
// transfer any rewards due
uint256 pendingAmount = user.amount.mul(pool.accERC20PerShare).div(1e36).sub(user.rewardDebt);
erc20Transfer(msg.sender, pendingAmount);
pool.supply = pool.supply.sub(user.amount);
user.rewardDebt = 0;
user.withdrawTime = block.timestamp;
emit Withdraw(msg.sender, _pid);
}
// unstake LP tokens from Farm. if done within "unstakeEpochs" days, apply burn.
function unstake(uint256 _pid) external {
require(manager.getPaused()==false, "unstake: farm paused");
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.withdrawTime > 0, "unstake: user is not unstaking");
updatePool(_pid);
//apply burn fee if unstaking before unstake epochs.
uint256 unstakeEpochs = manager.getUnstakeEpochs();
uint256 burnRate = manager.getBurnRate();
address redistributor = manager.getRedistributor();
if((user.withdrawTime.add(SECS_EPOCH.mul(unstakeEpochs)) > block.timestamp) && burnRate > 0){
uint penalty = user.amount.mul(burnRate).div(1000);
user.amount = user.amount.sub(penalty);
// if the staking address is an LP, send 50% of penalty to redistributor, and 50% to lp lock address.
if(pool.isLP){
uint256 redistributorPenalty = penalty.div(2);
pool.stakingToken.safeTransfer(redistributor, redistributorPenalty);
pool.stakingToken.safeTransfer(manager.getLpLock(), penalty.sub(redistributorPenalty));
}else {
// for normal ERC20 tokens, a portion (50% by default) of the penalty is sent to the redistributor address
uint256 burnRatio = manager.getBurnRatio();
uint256 burnAmount = penalty.mul(burnRatio).div(1000);
pool.stakingToken.safeTransfer(redistributor, penalty.sub(burnAmount));
if(pool.isBurnable){
//if the staking token is burnable, the second portion (50% by default) is burned
IBurnable(address(pool.stakingToken)).burn(burnAmount);
}else{
//if the staking token is not burnable, the second portion (50% by default) is sent to burn valley
pool.stakingToken.safeTransfer(manager.getBurnValley(), burnAmount);
}
}
}
uint userAmount = user.amount;
// allows user to stake again.
user.withdrawTime = 0;
user.amount = 0;
pool.stakingToken.safeTransfer(address(msg.sender), userAmount);
emit Unstake(msg.sender, _pid);
}
// claim LP tokens from Farm.
function claim(uint256 _pid) external {
require(manager.getPaused() == false, "claim: farm paused");
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount > 0, "claim: amount is equal to 0");
require(user.withdrawTime == 0, "claim: user is unstaking");
updatePool(_pid);
uint256 pendingAmount = user.amount.mul(pool.accERC20PerShare).div(1e36).sub(user.rewardDebt);
erc20Transfer(msg.sender, pendingAmount);
user.rewardDebt = user.amount.mul(pool.accERC20PerShare).div(1e36);
user.lastClaimTime = block.timestamp;
emit Claim(msg.sender, _pid);
}
// Transfer ERC20 and update the required ERC20 to payout all rewards
function erc20Transfer(address _to, uint256 _amount) internal {
erc20.transfer(_to, _amount);
paidOut += _amount;
}
// emergency withdraw rewards. only owner. EMERGENCY ONLY.
function emergencyWithdrawRewards(address _receiver) external {
require(msg.sender == address(manager), "emergencyWithdrawRewards: sender is not manager");
uint balance = erc20.balanceOf(address(this));
erc20.safeTransfer(_receiver, balance);
}
}
| contract Farm {
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.
uint256 lastClaimTime;
uint256 withdrawTime;
// We do some fancy math here. Basically, any point in time, the amount of ERC20s
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accERC20PerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
// 1. The pool's `accERC20PerShare` (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 stakingToken; // Address of staking token contract.
uint256 allocPoint; // How many allocation points assigned to this pool. ERC20s to distribute per block.
uint256 lastRewardBlock; // Last block number that ERC20s distribution occurs.
uint256 accERC20PerShare; // Accumulated ERC20s per share, times 1e36.
uint256 supply; // changes with unstakes.
bool isLP; // if the staking token is an LP token.
bool isBurnable; // if the staking token is burnable
}
// Address of the ERC20 Token contract.
IERC20 public erc20;
// The total amount of ERC20 that's paid out as reward.
uint256 public paidOut;
// ERC20 tokens rewarded per block.
uint256 public rewardPerBlock;
// Manager interface to get globals for all farms.
IFarmManager public manager;
// Info of each pool.
PoolInfo[] public poolInfo;
// Info of each user that stakes LP tokens.
mapping (uint256 => mapping (address => UserInfo)) public userInfo;
// Total allocation points. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint;
// The block number when farming starts.
uint256 public startBlock;
// Seconds per epoch (1 day)
uint256 public constant SECS_EPOCH = 86400;
// events
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid);
event Claim(address indexed user, uint256 indexed pid);
event Unstake(address indexed user, uint256 indexed pid);
event Initialize(IERC20 erc20, uint256 rewardPerBlock, uint256 startBlock, address manager);
constructor(IERC20 _erc20, uint256 _rewardPerBlock, uint256 _startBlock, address _manager) public {
erc20 = _erc20;
rewardPerBlock = _rewardPerBlock;
startBlock = _startBlock;
manager = IFarmManager(_manager);
emit Initialize(_erc20, _rewardPerBlock, _startBlock, _manager);
}
// Fund the farm, increase the end block.
function fund(address _funder, uint256 _amount) external {
require(msg.sender == address(manager), "fund: sender is not manager");
erc20.safeTransferFrom(_funder, address(this), _amount);
}
// Update the given pool's ERC20 allocation point. Can only be called by the manager.
function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) external {
require(msg.sender == address(manager), "set: sender is not manager");
if (_withUpdate) {
massUpdatePools();
}
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);
poolInfo[_pid].allocPoint = _allocPoint;
}
// Add a new staking token to the pool. Can only be called by the manager.
function add(uint256 _allocPoint, IERC20 _stakingToken, bool _isLP, bool _isBurnable, bool _withUpdate) external {
require(msg.sender == address(manager), "fund: sender is not manager");
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(PoolInfo({
stakingToken: _stakingToken,
supply: 0,
allocPoint: _allocPoint,
lastRewardBlock: lastRewardBlock,
accERC20PerShare: 0,
isLP: _isLP,
isBurnable: _isBurnable
}));
}
// 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);
}
}
// Update reward variables of the given pool to be up-to-date.
function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
uint256 lastBlock = block.number;
if (lastBlock <= pool.lastRewardBlock) {
return;
}
if (pool.supply == 0) {
pool.lastRewardBlock = lastBlock;
return;
}
uint256 nrOfBlocks = lastBlock.sub(pool.lastRewardBlock);
uint256 erc20Reward = nrOfBlocks.mul(rewardPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
pool.accERC20PerShare = pool.accERC20PerShare.add(erc20Reward.mul(1e36).div(pool.supply));
pool.lastRewardBlock = block.number;
}
// move LP tokens from one farm to another. only callable by Manager.
function move(uint256 _pid, address _mover) external {
require(msg.sender == address(manager), "move: sender is not manager");
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_mover];
updatePool(_pid);
uint256 pendingAmount = user.amount.mul(pool.accERC20PerShare).div(1e36).sub(user.rewardDebt);
erc20Transfer(_mover, pendingAmount);
pool.supply = pool.supply.sub(user.amount);
pool.stakingToken.safeTransfer(address(manager), user.amount);
user.amount = 0;
user.rewardDebt = user.amount.mul(pool.accERC20PerShare).div(1e36);
emit Withdraw(msg.sender, _pid);
}
// Deposit LP tokens to Farm for ERC20 allocation.
// can come from manager or user address directly.
// In the case the call is coming from the manager, msg.sender is the manager.
function deposit(uint256 _pid, address _depositor, uint256 _amount) external {
require(manager.getPaused()==false, "deposit: farm paused");
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_depositor];
require(user.withdrawTime == 0, "deposit: user is unstaking");
// If we're not called by the farm manager, then we must ensure that the caller is the depositor.
// This way we avoid the case where someone else commits the deposit, after the depositor
// granted allowance to the farm.
if(msg.sender != address(manager)) {
require(msg.sender == _depositor, "deposit: the caller must be the depositor");
}
updatePool(_pid);
if (user.amount > 0) {
uint256 pendingAmount = user.amount.mul(pool.accERC20PerShare).div(1e36).sub(user.rewardDebt);
erc20Transfer(_depositor, pendingAmount);
}
// We tranfer from the msg.sender, because in the case when we're called by the farm manager (change pool scenario)
// it's the FM who owns the tokens, not the depositor (who in this case is the user who changes pools).
pool.stakingToken.safeTransferFrom(msg.sender, address(this), _amount);
pool.supply = pool.supply.add(_amount);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accERC20PerShare).div(1e36);
emit Deposit(_depositor, _pid, _amount);
}
// Distribute rewards and start unstake period.
function withdraw(uint256 _pid) external {
require(manager.getPaused()==false, "withdraw: farm paused");
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount > 0, "withdraw: amount must be greater than 0");
require(user.withdrawTime == 0, "withdraw: user is unstaking");
updatePool(_pid);
// transfer any rewards due
uint256 pendingAmount = user.amount.mul(pool.accERC20PerShare).div(1e36).sub(user.rewardDebt);
erc20Transfer(msg.sender, pendingAmount);
pool.supply = pool.supply.sub(user.amount);
user.rewardDebt = 0;
user.withdrawTime = block.timestamp;
emit Withdraw(msg.sender, _pid);
}
// unstake LP tokens from Farm. if done within "unstakeEpochs" days, apply burn.
function unstake(uint256 _pid) external {
require(manager.getPaused()==false, "unstake: farm paused");
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.withdrawTime > 0, "unstake: user is not unstaking");
updatePool(_pid);
//apply burn fee if unstaking before unstake epochs.
uint256 unstakeEpochs = manager.getUnstakeEpochs();
uint256 burnRate = manager.getBurnRate();
address redistributor = manager.getRedistributor();
if((user.withdrawTime.add(SECS_EPOCH.mul(unstakeEpochs)) > block.timestamp) && burnRate > 0){
uint penalty = user.amount.mul(burnRate).div(1000);
user.amount = user.amount.sub(penalty);
// if the staking address is an LP, send 50% of penalty to redistributor, and 50% to lp lock address.
if(pool.isLP){
uint256 redistributorPenalty = penalty.div(2);
pool.stakingToken.safeTransfer(redistributor, redistributorPenalty);
pool.stakingToken.safeTransfer(manager.getLpLock(), penalty.sub(redistributorPenalty));
}else {
// for normal ERC20 tokens, a portion (50% by default) of the penalty is sent to the redistributor address
uint256 burnRatio = manager.getBurnRatio();
uint256 burnAmount = penalty.mul(burnRatio).div(1000);
pool.stakingToken.safeTransfer(redistributor, penalty.sub(burnAmount));
if(pool.isBurnable){
//if the staking token is burnable, the second portion (50% by default) is burned
IBurnable(address(pool.stakingToken)).burn(burnAmount);
}else{
//if the staking token is not burnable, the second portion (50% by default) is sent to burn valley
pool.stakingToken.safeTransfer(manager.getBurnValley(), burnAmount);
}
}
}
uint userAmount = user.amount;
// allows user to stake again.
user.withdrawTime = 0;
user.amount = 0;
pool.stakingToken.safeTransfer(address(msg.sender), userAmount);
emit Unstake(msg.sender, _pid);
}
// claim LP tokens from Farm.
function claim(uint256 _pid) external {
require(manager.getPaused() == false, "claim: farm paused");
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount > 0, "claim: amount is equal to 0");
require(user.withdrawTime == 0, "claim: user is unstaking");
updatePool(_pid);
uint256 pendingAmount = user.amount.mul(pool.accERC20PerShare).div(1e36).sub(user.rewardDebt);
erc20Transfer(msg.sender, pendingAmount);
user.rewardDebt = user.amount.mul(pool.accERC20PerShare).div(1e36);
user.lastClaimTime = block.timestamp;
emit Claim(msg.sender, _pid);
}
// Transfer ERC20 and update the required ERC20 to payout all rewards
function erc20Transfer(address _to, uint256 _amount) internal {
erc20.transfer(_to, _amount);
paidOut += _amount;
}
// emergency withdraw rewards. only owner. EMERGENCY ONLY.
function emergencyWithdrawRewards(address _receiver) external {
require(msg.sender == address(manager), "emergencyWithdrawRewards: sender is not manager");
uint balance = erc20.balanceOf(address(this));
erc20.safeTransfer(_receiver, balance);
}
}
| 61,763 |
1,003 | // Freezes a reserve. A frozen reserve doesn't allow any new deposit, borrow or rate swap but allows repayments, liquidations, rate rebalances and withdrawals asset The address of the underlying asset of the reserve / | function freezeReserve(address asset) external onlyPoolAdmin {
DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
currentConfig.setFrozen(true);
pool.setConfiguration(asset, currentConfig.data);
emit ReserveFrozen(asset);
}
| function freezeReserve(address asset) external onlyPoolAdmin {
DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
currentConfig.setFrozen(true);
pool.setConfiguration(asset, currentConfig.data);
emit ReserveFrozen(asset);
}
| 39,515 |
9 | // The hash of the name parameter for the EIP712 domain. NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costsare a concern. / | function _EIP712NameHash() internal virtual view returns (bytes32) {
return _HASHED_NAME;
}
| function _EIP712NameHash() internal virtual view returns (bytes32) {
return _HASHED_NAME;
}
| 8,280 |
503 | // Sets {decimals} to a value other than the default one of 18. WARNING: This function should only be called from the constructor. Mostapplications that interact with token contracts will not expect{decimals} to ever change, and may work incorrectly if it does. / | function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
| function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
| 8,793 |
112 | // Get the rounds an account has unclaimed rewards | function getRewards(address accountAddress)
public
view
returns(uint256[] memory)
| function getRewards(address accountAddress)
public
view
returns(uint256[] memory)
| 67,646 |
51 | // Then unpause will sync all pairs | tokenUniswapPairCORE = coreGlobals.COREWETHUniPair();
_editNoFeeList(coreGlobals.COREVaultAddress(), true); // corevault proxy needs to have no sender fee
_addPairToTrack(coreGlobals.COREWETHUniPair());
| tokenUniswapPairCORE = coreGlobals.COREWETHUniPair();
_editNoFeeList(coreGlobals.COREVaultAddress(), true); // corevault proxy needs to have no sender fee
_addPairToTrack(coreGlobals.COREWETHUniPair());
| 40,329 |
9 | // loop through players to see who selected winning team | for(uint256 i = 0; i < winners.length; i++){
playerAddress = winners[i];
| for(uint256 i = 0; i < winners.length; i++){
playerAddress = winners[i];
| 42,815 |
6 | // Team allocation vested over {VESTING_DURATION} years | uint256 internal constant _TEAM_ALLOCATION = 250_000_000 * 1 ether;
| uint256 internal constant _TEAM_ALLOCATION = 250_000_000 * 1 ether;
| 13,815 |
13 | // call the initializer, passing any remaining amount and get initial state (S_0) | bytes32 initial_state = logic_contract.initialize_state{ value: remainder }(user);
| bytes32 initial_state = logic_contract.initialize_state{ value: remainder }(user);
| 45,547 |
80 | // Set caller as contract owner / | function initialize() public initializer {
_setInitialOwner(msg.sender);
}
| function initialize() public initializer {
_setInitialOwner(msg.sender);
}
| 41,104 |
44 | // Function to accept stamping of an item by the intended recipient self is the mappings of completed stamping associated with the recipient user _stampingOrderMapping is the mapping of the completed stamping order using SortOrder Struct (IceSort Library) of the recipient _stampingCountMapping is the mapping of completed stamping count _stampingsReq is the mappings of stamping requests associated with the recipient user _stampingReqOrderMapping is the mapping of the stamping request order using SortOrder Struct (IceSort Library) of the recipient _stampingReqCountMapping is the mapping of all stamping requests count _globalItem is the Association Struct (IceGlobal Library) of the item in question _recipientEIN is | function acceptStamping(
mapping (uint => IceGlobal.GlobalRecord) storage self,
mapping (uint => IceSort.SortOrder) storage _stampingOrderMapping,
mapping (uint => uint) storage _stampingCountMapping,
mapping (uint => IceGlobal.GlobalRecord) storage _stampingsReq,
mapping (uint => IceSort.SortOrder) storage _stampingReqOrderMapping,
mapping (uint => uint) storage _stampingReqCountMapping,
IceGlobal.Association storage _globalItem,
| function acceptStamping(
mapping (uint => IceGlobal.GlobalRecord) storage self,
mapping (uint => IceSort.SortOrder) storage _stampingOrderMapping,
mapping (uint => uint) storage _stampingCountMapping,
mapping (uint => IceGlobal.GlobalRecord) storage _stampingsReq,
mapping (uint => IceSort.SortOrder) storage _stampingReqOrderMapping,
mapping (uint => uint) storage _stampingReqCountMapping,
IceGlobal.Association storage _globalItem,
| 34,372 |
7 | // A contract that can be stopped/restarted by its owner. / | contract Stoppable is Ownable {
bool public isActive = true;
event IsActiveChanged(bool _isActive);
modifier onlyActive() {
require(isActive, "contract is stopped");
_;
}
function setIsActive(bool _isActive) external onlyOwner {
if (_isActive == isActive) return;
isActive = _isActive;
emit IsActiveChanged(_isActive);
}
}
| contract Stoppable is Ownable {
bool public isActive = true;
event IsActiveChanged(bool _isActive);
modifier onlyActive() {
require(isActive, "contract is stopped");
_;
}
function setIsActive(bool _isActive) external onlyOwner {
if (_isActive == isActive) return;
isActive = _isActive;
emit IsActiveChanged(_isActive);
}
}
| 31,857 |
17 | // `pendingOwner` can claim `owner` account. | function claimOwner() external {
require(msg.sender == pendingOwner, "NOT_PENDING_OWNER");
emit TransferOwner(owner, msg.sender);
owner = msg.sender;
pendingOwner = address(0);
}
| function claimOwner() external {
require(msg.sender == pendingOwner, "NOT_PENDING_OWNER");
emit TransferOwner(owner, msg.sender);
owner = msg.sender;
pendingOwner = address(0);
}
| 19,719 |
25 | // Assert that main UTXO for passed wallet exists in storage. | bytes32 mainUtxoHash = self
.registeredWallets[walletPubKeyHash]
.mainUtxoHash;
require(mainUtxoHash != bytes32(0), "No main UTXO for given wallet");
| bytes32 mainUtxoHash = self
.registeredWallets[walletPubKeyHash]
.mainUtxoHash;
require(mainUtxoHash != bytes32(0), "No main UTXO for given wallet");
| 10,781 |
81 | // Gets the amount of Crane locked in the contract | uint256 totalCrane = crane.balanceOf(address(this));
| uint256 totalCrane = crane.balanceOf(address(this));
| 26,321 |
20 | // check if any of the winnerPicks is this contributor's bin | for (uint8 j = 0; j < numberOfPicks; j++) {
if (acc > winnerPicks[j] && winnerPicks[j] >= prevLimit) {
winnerIdxs.push(contributorIdx);
}
| for (uint8 j = 0; j < numberOfPicks; j++) {
if (acc > winnerPicks[j] && winnerPicks[j] >= prevLimit) {
winnerIdxs.push(contributorIdx);
}
| 8,906 |
49 | // 總共有空令牌或沒有銷售代幣 | if (tokens == 0 || total_supply == 0) {
return 0;
}
| if (tokens == 0 || total_supply == 0) {
return 0;
}
| 12,579 |
72 | // uint delta = LiquidityGauge(reward_contract).claimable_tokens(address(this));Error: Mutable call in static context | uint delta = LiquidityGauge(reward_contract).integrate_fraction(address(this)).sub(Minter(LiquidityGauge(reward_contract).minter()).minted(address(this), reward_contract));
return _claimable_tokens(addr, delta, reward_integral_[rewarded_token], reward_integral_for_[addr][rewarded_token]);
| uint delta = LiquidityGauge(reward_contract).integrate_fraction(address(this)).sub(Minter(LiquidityGauge(reward_contract).minter()).minted(address(this), reward_contract));
return _claimable_tokens(addr, delta, reward_integral_[rewarded_token], reward_integral_for_[addr][rewarded_token]);
| 28,540 |
9 | // Emitted if Relay Server is inactive for an `abandonmentDelay` and contract owner initiates its removal. | event RelayServerAbandoned(
address indexed relayManager,
uint256 abandonedTime
);
| event RelayServerAbandoned(
address indexed relayManager,
uint256 abandonedTime
);
| 11,145 |
34 | // Multisignature wallet factory | contract MultiSigWalletCreator is Ownable() {
// wallets
mapping(address => bool) public isMultiSigWallet;
mapping(address => address[]) public wallets;
mapping(address => uint) public numberOfWallets;
// information about system
string public currentSystemInfo;
event walletCreated(address indexed _creator, address indexed _wallet);
function createMultiSigWallet(
address[] _signers,
uint _requiredConfirmations,
string _name
)
public
returns (address wallet)
{
wallet = new MultiSigWallet(_signers, _requiredConfirmations, _name);
isMultiSigWallet[wallet] = true;
for (uint i = 0; i < _signers.length; i++) {
wallets[_signers[i]].push(wallet);
numberOfWallets[_signers[i]]++;
}
emit walletCreated(msg.sender, wallet);
}
function setCurrentSystemInfo(string _info) public onlyOwner {
currentSystemInfo = _info;
}
} | contract MultiSigWalletCreator is Ownable() {
// wallets
mapping(address => bool) public isMultiSigWallet;
mapping(address => address[]) public wallets;
mapping(address => uint) public numberOfWallets;
// information about system
string public currentSystemInfo;
event walletCreated(address indexed _creator, address indexed _wallet);
function createMultiSigWallet(
address[] _signers,
uint _requiredConfirmations,
string _name
)
public
returns (address wallet)
{
wallet = new MultiSigWallet(_signers, _requiredConfirmations, _name);
isMultiSigWallet[wallet] = true;
for (uint i = 0; i < _signers.length; i++) {
wallets[_signers[i]].push(wallet);
numberOfWallets[_signers[i]]++;
}
emit walletCreated(msg.sender, wallet);
}
function setCurrentSystemInfo(string _info) public onlyOwner {
currentSystemInfo = _info;
}
} | 33,275 |
186 | // check if the sender is an authorized operator _sender msg.sender _accountOwner owner of a vault / | function _isAuthorized(address _sender, address _accountOwner) internal view {
require(
(_sender == _accountOwner) || (operators[_accountOwner][_sender]),
"Controller: msg.sender is not authorized to run action"
);
}
| function _isAuthorized(address _sender, address _accountOwner) internal view {
require(
(_sender == _accountOwner) || (operators[_accountOwner][_sender]),
"Controller: msg.sender is not authorized to run action"
);
}
| 9,490 |
0 | // 定义工厂合约接口 | contract FactoryInterface {
// uniswap中现有的代币地址数组
address[] public tokenList;
// 设置a代币地址和a代币流动性池子地址的映射
mapping(address => address) tokenToExchange;
// 设置a代币流动性池子地址和a代币地址的映射
mapping(address => address) exchangeToToken;
// 启动一个新的流动性池子(new一个新的子合约)
function launchExchange(address _token) public returns (address exchange);
// 返回当前可用的流动性池子数量
function getExchangeCount() public view returns (uint256 exchangeCount);
// 使用代币地址找出其对应的代币交易对地址
function tokenToExchangeLookup(address _token) public view returns (address exchange);
// 使用代币交易对地址找出其对应的代币地址
function exchangeToTokenLookup(address _exchange) public view returns (address token);
// 新的交易对合约生成事件
event ExchangeLaunch(address indexed exchange, address indexed token);
}
| contract FactoryInterface {
// uniswap中现有的代币地址数组
address[] public tokenList;
// 设置a代币地址和a代币流动性池子地址的映射
mapping(address => address) tokenToExchange;
// 设置a代币流动性池子地址和a代币地址的映射
mapping(address => address) exchangeToToken;
// 启动一个新的流动性池子(new一个新的子合约)
function launchExchange(address _token) public returns (address exchange);
// 返回当前可用的流动性池子数量
function getExchangeCount() public view returns (uint256 exchangeCount);
// 使用代币地址找出其对应的代币交易对地址
function tokenToExchangeLookup(address _token) public view returns (address exchange);
// 使用代币交易对地址找出其对应的代币地址
function exchangeToTokenLookup(address _exchange) public view returns (address token);
// 新的交易对合约生成事件
event ExchangeLaunch(address indexed exchange, address indexed token);
}
| 34,219 |
101 | // for dev fee send to the dev address |
sendEthToDevAddress(devEthBalance);
emit SwapAndLiquify(contractTokenBalance, liquidityEthBalance, devEthBalance);
|
sendEthToDevAddress(devEthBalance);
emit SwapAndLiquify(contractTokenBalance, liquidityEthBalance, devEthBalance);
| 29,032 |
106 | // generates a base64 encoded metadata response without referencing off-chain content tokenId the ID of the token to generate the metadata forreturn a base64 encoded JSON dictionary of the token's metadata and SVG / | function tokenURI(uint256 tokenId) public view override returns (string memory) {
IKONGS.KaijuKong memory s = kongs.getTokenTraits(tokenId);
string memory metadata = string(abi.encodePacked(
'{"name": "',
s.isKaiju ? 'Kaiju #' : 'Kong #',
tokenId.toString(),
'", "description": "Thousands of Kaiju and Wolves compete on Kong Island. A tempting prize of $FOOD awaits, with deadly high stakes. All the metadata and images are generated and stored 100% on-chain. No IPFS. NO API. Just the Ethereum blockchain.", "image": "data:image/svg+xml;base64,',
base64(bytes(drawSVG(tokenId))),
'", "attributes":',
compileAttributes(tokenId),
"}"
));
return string(abi.encodePacked(
"data:application/json;base64,",
base64(bytes(metadata))
));
}
| function tokenURI(uint256 tokenId) public view override returns (string memory) {
IKONGS.KaijuKong memory s = kongs.getTokenTraits(tokenId);
string memory metadata = string(abi.encodePacked(
'{"name": "',
s.isKaiju ? 'Kaiju #' : 'Kong #',
tokenId.toString(),
'", "description": "Thousands of Kaiju and Wolves compete on Kong Island. A tempting prize of $FOOD awaits, with deadly high stakes. All the metadata and images are generated and stored 100% on-chain. No IPFS. NO API. Just the Ethereum blockchain.", "image": "data:image/svg+xml;base64,',
base64(bytes(drawSVG(tokenId))),
'", "attributes":',
compileAttributes(tokenId),
"}"
));
return string(abi.encodePacked(
"data:application/json;base64,",
base64(bytes(metadata))
));
}
| 21,962 |
119 | // sets the referenced backup oracle/newBackupOracle the new backup oracle to reference | function setBackupOracle(address newBackupOracle) external override onlyGovernorOrAdmin {
_setBackupOracle(newBackupOracle);
}
| function setBackupOracle(address newBackupOracle) external override onlyGovernorOrAdmin {
_setBackupOracle(newBackupOracle);
}
| 31,851 |
2 | // Remove a trusted claim topic (For example: KYC=1, AML=2) claimTopicclaim topic identification / | function removeClaimTopic(
uint256 claimTopic
| function removeClaimTopic(
uint256 claimTopic
| 19,414 |
4 | // Returns whether the interface is supported.interfaceId The interface id to check against. / | function supportsInterface(
bytes4 interfaceId
)
public
view
virtual
override(ERC1155Receiver, ONFT1155Core)
returns (bool)
| function supportsInterface(
bytes4 interfaceId
)
public
view
virtual
override(ERC1155Receiver, ONFT1155Core)
returns (bool)
| 11,661 |
117 | // check LP balance | uint256 _lpBalance = IERC20(uniswapV2Pair).balanceOf(address(this));
if (_lpBalance != 0) {
| uint256 _lpBalance = IERC20(uniswapV2Pair).balanceOf(address(this));
if (_lpBalance != 0) {
| 30,139 |
2 | // Total Claimable GTX which is the Amount of GTX sold during presale | uint256 public totalClaimableGTX;
| uint256 public totalClaimableGTX;
| 47,668 |
99 | // a checkpoint of the valid balance of a user for an epoch | struct Checkpoint {
uint128 epochId;
uint128 multiplier;
uint256 startBalance;
uint256 newDeposits;
}
| struct Checkpoint {
uint128 epochId;
uint128 multiplier;
uint256 startBalance;
uint256 newDeposits;
}
| 42,361 |
20 | // Token Buy/ | function buyTokensWithEth() external payable {
require (msg.value > 0, "You need to send some Ether");
require (msg.value <= maxAmountinEth, "Cannot buy more than max limit");
uint256 amount = msg.value * exchangeRateInEth;
require(token.balanceOf(address(this)) >= amount, "Not enough tokens left for sale");
token.transfer(msg.sender, amount);
payable(owner()).transfer(msg.value);
emit TokensPurchasedWithETH(msg.sender, msg.value, amount);
}
| function buyTokensWithEth() external payable {
require (msg.value > 0, "You need to send some Ether");
require (msg.value <= maxAmountinEth, "Cannot buy more than max limit");
uint256 amount = msg.value * exchangeRateInEth;
require(token.balanceOf(address(this)) >= amount, "Not enough tokens left for sale");
token.transfer(msg.sender, amount);
payable(owner()).transfer(msg.value);
emit TokensPurchasedWithETH(msg.sender, msg.value, amount);
}
| 32,848 |
285 | // part two | bpool.swapExactAmountIn(
weth,wethB,address(want), 0,uint256(-1));
| bpool.swapExactAmountIn(
weth,wethB,address(want), 0,uint256(-1));
| 9,885 |
0 | // Withdrawal addresses | address public constant ADD = 0xa64b407D4363E203F682f7D95eB13241B039E580;
bool public preSale;
bool public publicSale;
bool public revealed;
uint256 public reservedMintedAmount;
mapping(address => bool) public presalerList;
mapping(address => uint256) public presalerListPurchases;
| address public constant ADD = 0xa64b407D4363E203F682f7D95eB13241B039E580;
bool public preSale;
bool public publicSale;
bool public revealed;
uint256 public reservedMintedAmount;
mapping(address => bool) public presalerList;
mapping(address => uint256) public presalerListPurchases;
| 2,285 |
28 | // Fetch bet parameters into local variables (to save gas). | Game storage game = games[commit];
uint bet1Amount = game.bet1Amount;
uint bet2Amount = game.bet2Amount;
uint bet3Amount = game.bet3Amount;
uint bet4Amount = game.bet4Amount;
uint bet5Amount = game.bet5Amount;
uint placeBlockNumber = game.placeBlockNumber;
address gambler = game.gambler;
uint24 betMask = game.mask;
| Game storage game = games[commit];
uint bet1Amount = game.bet1Amount;
uint bet2Amount = game.bet2Amount;
uint bet3Amount = game.bet3Amount;
uint bet4Amount = game.bet4Amount;
uint bet5Amount = game.bet5Amount;
uint placeBlockNumber = game.placeBlockNumber;
address gambler = game.gambler;
uint24 betMask = game.mask;
| 47,553 |
65 | // IMMUTABLES & CONSTANTS / Fees are 6-decimal places. For example: 20106 = 20% | uint256 internal constant FEE_MULTIPLIER = 10**6;
| uint256 internal constant FEE_MULTIPLIER = 10**6;
| 64,908 |
15 | // accessible only by owner, prevents further loans to be created after being called/called by bot when sudden price drop is detected on OpenSea API of listed collections/resumes the contract to normal operations when called again/supplies, repays, sells & withdraws stay unaffected | function stopOrRestartBorrows() public {
require(msg.sender == owner);
stopBorrows = !stopBorrows;
}
| function stopOrRestartBorrows() public {
require(msg.sender == owner);
stopBorrows = !stopBorrows;
}
| 29,984 |
80 | // copy candidates to confirms | copyCandidatesToConfirms(candidates);
| copyCandidatesToConfirms(candidates);
| 9,092 |
60 | // It is expected that this value is sometimes NULL. | address prev = self.list[target].previous;
self.list[newNode].next = target;
self.list[newNode].previous = prev;
self.list[target].previous = newNode;
self.list[prev].next = newNode;
self.list[newNode].inList = true;
| address prev = self.list[target].previous;
self.list[newNode].next = target;
self.list[newNode].previous = prev;
self.list[target].previous = newNode;
self.list[prev].next = newNode;
self.list[newNode].inList = true;
| 12,341 |
11 | // returns the resistant balance and FEI in the deposit | function resistantBalanceAndFei() public view override returns (uint256, uint256) {
uint256 resistantBalance = balance();
uint256 reistantFei = isProtocolFeiDeposit ? resistantBalance : 0;
return (resistantBalance, reistantFei);
}
| function resistantBalanceAndFei() public view override returns (uint256, uint256) {
uint256 resistantBalance = balance();
uint256 reistantFei = isProtocolFeiDeposit ? resistantBalance : 0;
return (resistantBalance, reistantFei);
}
| 51,890 |
543 | // Existing Voting contract needs to be informed of the address of the new Voting contract. | Voting public existingVoting;
| Voting public existingVoting;
| 21,441 |
67 | // 150 000 tokens soft cap | uint public constant ICO_TOKEN_SOFT_CAP = 150000 * (1 ether / 1 wei);
| uint public constant ICO_TOKEN_SOFT_CAP = 150000 * (1 ether / 1 wei);
| 46,279 |
6 | // totalShares are not 0, so we can uncheck | unchecked { result /= totalShares; }
| unchecked { result /= totalShares; }
| 8,585 |
179 | // Return the borrow balance of account based on stored data account The address whose balance should be calculatedreturn The calculated balance / | function borrowBalanceStored(address account) public view returns (uint) {
(MathError err, uint result) = borrowBalanceStoredInternal(account);
require(err == MathError.NO_ERROR, "borrowBalanceStored: borrowBalanceStoredInternal failed");
return result;
}
| function borrowBalanceStored(address account) public view returns (uint) {
(MathError err, uint result) = borrowBalanceStoredInternal(account);
require(err == MathError.NO_ERROR, "borrowBalanceStored: borrowBalanceStoredInternal failed");
return result;
}
| 1,502 |
3 | // The token being loaned. | address loanToken;
| address loanToken;
| 9,212 |
18 | // 销毁收藏品/碎片 | Burn,
| Burn,
| 44,794 |
19 | // Mint a ParagonsDAO Player ID NFT for PDT (Public). nameOn-chain username for the minter. / | function publicMint(bytes32 name) external nonReentrant {
_handleMint(msg.sender, name, false);
}
| function publicMint(bytes32 name) external nonReentrant {
_handleMint(msg.sender, name, false);
}
| 19,439 |
23 | // How much of the generated interest is donated, meaning no GD is expected in compensation, 1 in mil precision. 100% for phase0 POC | uint32 public avgInterestDonatedRatio = 1e6;
| uint32 public avgInterestDonatedRatio = 1e6;
| 51,389 |
21 | // Setea el CUIT de la SAS/proyecto / | function setCuit(uint cuit) onlyowner public {
m_cuit = cuit;
emit cuitSet(m_cuit);
}
| function setCuit(uint cuit) onlyowner public {
m_cuit = cuit;
emit cuitSet(m_cuit);
}
| 27,386 |
6 | // @custom:security-contact john@newellserv.com | contract GoldCoin is ERC20, ERC20Burnable, AccessControl, ERC20Permit, ERC20Votes {
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
constructor() ERC20("Gold Coin", "gCOIN") ERC20Permit("Gold Coin") {
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_grantRole(MINTER_ROLE, msg.sender);
}
function mint(address to, uint256 amount) public onlyRole(MINTER_ROLE) {
_mint(to, amount);
}
// The following functions are overrides required by Solidity.
function _afterTokenTransfer(address from, address to, uint256 amount)
internal
override(ERC20, ERC20Votes)
{
super._afterTokenTransfer(from, to, amount);
}
function _mint(address to, uint256 amount)
internal
override(ERC20, ERC20Votes)
{
super._mint(to, amount);
}
function _burn(address account, uint256 amount)
internal
override(ERC20, ERC20Votes)
{
super._burn(account, amount);
}
}
| contract GoldCoin is ERC20, ERC20Burnable, AccessControl, ERC20Permit, ERC20Votes {
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
constructor() ERC20("Gold Coin", "gCOIN") ERC20Permit("Gold Coin") {
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_grantRole(MINTER_ROLE, msg.sender);
}
function mint(address to, uint256 amount) public onlyRole(MINTER_ROLE) {
_mint(to, amount);
}
// The following functions are overrides required by Solidity.
function _afterTokenTransfer(address from, address to, uint256 amount)
internal
override(ERC20, ERC20Votes)
{
super._afterTokenTransfer(from, to, amount);
}
function _mint(address to, uint256 amount)
internal
override(ERC20, ERC20Votes)
{
super._mint(to, amount);
}
function _burn(address account, uint256 amount)
internal
override(ERC20, ERC20Votes)
{
super._burn(account, amount);
}
}
| 43,022 |
121 | // Constructs the Bomb ERC-20 contract. / | constructor() ERC20("Bomb", "bomb") {
// Mints 5000 Bomb to contract creator for initial pool setup
_mint(msg.sender, 5000 ether);
}
| constructor() ERC20("Bomb", "bomb") {
// Mints 5000 Bomb to contract creator for initial pool setup
_mint(msg.sender, 5000 ether);
}
| 13,386 |
173 | // Configured contract implementing token rule(s).If set, transfer will consult this contract should transferbe allowed after successful authorization signature check.And call doTransfer() in order for rules to decide where fundshould end up. / | ITransferRules public _rules;
event RulesUpdated(address rules);
| ITransferRules public _rules;
event RulesUpdated(address rules);
| 29,776 |
10 | // Asset for which we create a covered call for | address public asset;
| address public asset;
| 9,764 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.