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 algorithm has been extracted from the implementation of smart pool (https:github.com/smartpool) | library Keccak {
function keccakF(uint256[25] memory a) internal pure returns (uint256[25] memory) {
uint256[5] memory c;
uint256[5] memory d;
//uint D_0; uint D_1; uint D_2; uint D_3; uint D_4;
uint256[25] memory b;
uint256[24] memory rc = [
uint256(0x0000000000000001),
0x0000000000008082,
0x800000000000808A,
0x8000000080008000,
0x000000000000808B,
0x0000000080000001,
0x8000000080008081,
0x8000000000008009,
0x000000000000008A,
0x0000000000000088,
0x0000000080008009,
0x000000008000000A,
0x000000008000808B,
0x800000000000008B,
0x8000000000008089,
0x8000000000008003,
0x8000000000008002,
0x8000000000000080,
0x000000000000800A,
0x800000008000000A,
0x8000000080008081,
0x8000000000008080,
0x0000000080000001,
0x8000000080008008
];
for (uint256 i = 0; i < 24; i++) {
/*
for( x = 0 ; x < 5 ; x++ ) {
C[x] = A[5*x]^A[5*x+1]^A[5*x+2]^A[5*x+3]^A[5*x+4];
}*/
c[0] = a[0] ^ a[1] ^ a[2] ^ a[3] ^ a[4];
c[1] = a[5] ^ a[6] ^ a[7] ^ a[8] ^ a[9];
c[2] = a[10] ^ a[11] ^ a[12] ^ a[13] ^ a[14];
c[3] = a[15] ^ a[16] ^ a[17] ^ a[18] ^ a[19];
c[4] = a[20] ^ a[21] ^ a[22] ^ a[23] ^ a[24];
/*
for( x = 0 ; x < 5 ; x++ ) {
D[x] = C[(x+4)%5]^((C[(x+1)%5] * 2)&0xffffffffffffffff | (C[(x+1)%5]/(2**63)));
}*/
d[0] = c[4] ^ (((c[1] * 2) & 0xffffffffffffffff) | (c[1] / (2**63)));
d[1] = c[0] ^ (((c[2] * 2) & 0xffffffffffffffff) | (c[2] / (2**63)));
d[2] = c[1] ^ (((c[3] * 2) & 0xffffffffffffffff) | (c[3] / (2**63)));
d[3] = c[2] ^ (((c[4] * 2) & 0xffffffffffffffff) | (c[4] / (2**63)));
d[4] = c[3] ^ (((c[0] * 2) & 0xffffffffffffffff) | (c[0] / (2**63)));
/*
for( x = 0 ; x < 5 ; x++ ) {
for( y = 0 ; y < 5 ; y++ ) {
A[5*x+y] = A[5*x+y] ^ D[x];
}
}*/
a[0] = a[0] ^ d[0];
a[1] = a[1] ^ d[0];
a[2] = a[2] ^ d[0];
a[3] = a[3] ^ d[0];
a[4] = a[4] ^ d[0];
a[5] = a[5] ^ d[1];
a[6] = a[6] ^ d[1];
a[7] = a[7] ^ d[1];
a[8] = a[8] ^ d[1];
a[9] = a[9] ^ d[1];
a[10] = a[10] ^ d[2];
a[11] = a[11] ^ d[2];
a[12] = a[12] ^ d[2];
a[13] = a[13] ^ d[2];
a[14] = a[14] ^ d[2];
a[15] = a[15] ^ d[3];
a[16] = a[16] ^ d[3];
a[17] = a[17] ^ d[3];
a[18] = a[18] ^ d[3];
a[19] = a[19] ^ d[3];
a[20] = a[20] ^ d[4];
a[21] = a[21] ^ d[4];
a[22] = a[22] ^ d[4];
a[23] = a[23] ^ d[4];
a[24] = a[24] ^ d[4];
/*Rho and pi steps*/
b[0] = a[0];
b[8] = (((a[1] * (2**36)) & 0xffffffffffffffff) | (a[1] / (2**28)));
b[11] = (((a[2] * (2**3)) & 0xffffffffffffffff) | (a[2] / (2**61)));
b[19] = (((a[3] * (2**41)) & 0xffffffffffffffff) | (a[3] / (2**23)));
b[22] = (((a[4] * (2**18)) & 0xffffffffffffffff) | (a[4] / (2**46)));
b[2] = (((a[5] * (2**1)) & 0xffffffffffffffff) | (a[5] / (2**63)));
b[5] = (((a[6] * (2**44)) & 0xffffffffffffffff) | (a[6] / (2**20)));
b[13] = (((a[7] * (2**10)) & 0xffffffffffffffff) | (a[7] / (2**54)));
b[16] = (((a[8] * (2**45)) & 0xffffffffffffffff) | (a[8] / (2**19)));
b[24] = (((a[9] * (2**2)) & 0xffffffffffffffff) | (a[9] / (2**62)));
b[4] = (((a[10] * (2**62)) & 0xffffffffffffffff) | (a[10] / (2**2)));
b[7] = (((a[11] * (2**6)) & 0xffffffffffffffff) | (a[11] / (2**58)));
b[10] = (((a[12] * (2**43)) & 0xffffffffffffffff) | (a[12] / (2**21)));
b[18] = (((a[13] * (2**15)) & 0xffffffffffffffff) | (a[13] / (2**49)));
b[21] = (((a[14] * (2**61)) & 0xffffffffffffffff) | (a[14] / (2**3)));
b[1] = (((a[15] * (2**28)) & 0xffffffffffffffff) | (a[15] / (2**36)));
b[9] = (((a[16] * (2**55)) & 0xffffffffffffffff) | (a[16] / (2**9)));
b[12] = (((a[17] * (2**25)) & 0xffffffffffffffff) | (a[17] / (2**39)));
b[15] = (((a[18] * (2**21)) & 0xffffffffffffffff) | (a[18] / (2**43)));
b[23] = (((a[19] * (2**56)) & 0xffffffffffffffff) | (a[19] / (2**8)));
b[3] = (((a[20] * (2**27)) & 0xffffffffffffffff) | (a[20] / (2**37)));
b[6] = (((a[21] * (2**20)) & 0xffffffffffffffff) | (a[21] / (2**44)));
b[14] = (((a[22] * (2**39)) & 0xffffffffffffffff) | (a[22] / (2**25)));
b[17] = (((a[23] * (2**8)) & 0xffffffffffffffff) | (a[23] / (2**56)));
b[20] = (((a[24] * (2**14)) & 0xffffffffffffffff) | (a[24] / (2**50)));
/*Xi state*/
/*
for( x = 0 ; x < 5 ; x++ ) {
for( y = 0 ; y < 5 ; y++ ) {
A[5*x+y] = B[5*x+y]^((~B[5*((x+1)%5)+y]) & B[5*((x+2)%5)+y]);
}
}*/
a[0] = b[0] ^ ((~b[5]) & b[10]);
a[1] = b[1] ^ ((~b[6]) & b[11]);
a[2] = b[2] ^ ((~b[7]) & b[12]);
a[3] = b[3] ^ ((~b[8]) & b[13]);
a[4] = b[4] ^ ((~b[9]) & b[14]);
a[5] = b[5] ^ ((~b[10]) & b[15]);
a[6] = b[6] ^ ((~b[11]) & b[16]);
a[7] = b[7] ^ ((~b[12]) & b[17]);
a[8] = b[8] ^ ((~b[13]) & b[18]);
a[9] = b[9] ^ ((~b[14]) & b[19]);
a[10] = b[10] ^ ((~b[15]) & b[20]);
a[11] = b[11] ^ ((~b[16]) & b[21]);
a[12] = b[12] ^ ((~b[17]) & b[22]);
a[13] = b[13] ^ ((~b[18]) & b[23]);
a[14] = b[14] ^ ((~b[19]) & b[24]);
a[15] = b[15] ^ ((~b[20]) & b[0]);
a[16] = b[16] ^ ((~b[21]) & b[1]);
a[17] = b[17] ^ ((~b[22]) & b[2]);
a[18] = b[18] ^ ((~b[23]) & b[3]);
a[19] = b[19] ^ ((~b[24]) & b[4]);
a[20] = b[20] ^ ((~b[0]) & b[5]);
a[21] = b[21] ^ ((~b[1]) & b[6]);
a[22] = b[22] ^ ((~b[2]) & b[7]);
a[23] = b[23] ^ ((~b[3]) & b[8]);
a[24] = b[24] ^ ((~b[4]) & b[9]);
/*Last step*/
a[0] = a[0] ^ rc[i];
}
return a;
}
}
| library Keccak {
function keccakF(uint256[25] memory a) internal pure returns (uint256[25] memory) {
uint256[5] memory c;
uint256[5] memory d;
//uint D_0; uint D_1; uint D_2; uint D_3; uint D_4;
uint256[25] memory b;
uint256[24] memory rc = [
uint256(0x0000000000000001),
0x0000000000008082,
0x800000000000808A,
0x8000000080008000,
0x000000000000808B,
0x0000000080000001,
0x8000000080008081,
0x8000000000008009,
0x000000000000008A,
0x0000000000000088,
0x0000000080008009,
0x000000008000000A,
0x000000008000808B,
0x800000000000008B,
0x8000000000008089,
0x8000000000008003,
0x8000000000008002,
0x8000000000000080,
0x000000000000800A,
0x800000008000000A,
0x8000000080008081,
0x8000000000008080,
0x0000000080000001,
0x8000000080008008
];
for (uint256 i = 0; i < 24; i++) {
/*
for( x = 0 ; x < 5 ; x++ ) {
C[x] = A[5*x]^A[5*x+1]^A[5*x+2]^A[5*x+3]^A[5*x+4];
}*/
c[0] = a[0] ^ a[1] ^ a[2] ^ a[3] ^ a[4];
c[1] = a[5] ^ a[6] ^ a[7] ^ a[8] ^ a[9];
c[2] = a[10] ^ a[11] ^ a[12] ^ a[13] ^ a[14];
c[3] = a[15] ^ a[16] ^ a[17] ^ a[18] ^ a[19];
c[4] = a[20] ^ a[21] ^ a[22] ^ a[23] ^ a[24];
/*
for( x = 0 ; x < 5 ; x++ ) {
D[x] = C[(x+4)%5]^((C[(x+1)%5] * 2)&0xffffffffffffffff | (C[(x+1)%5]/(2**63)));
}*/
d[0] = c[4] ^ (((c[1] * 2) & 0xffffffffffffffff) | (c[1] / (2**63)));
d[1] = c[0] ^ (((c[2] * 2) & 0xffffffffffffffff) | (c[2] / (2**63)));
d[2] = c[1] ^ (((c[3] * 2) & 0xffffffffffffffff) | (c[3] / (2**63)));
d[3] = c[2] ^ (((c[4] * 2) & 0xffffffffffffffff) | (c[4] / (2**63)));
d[4] = c[3] ^ (((c[0] * 2) & 0xffffffffffffffff) | (c[0] / (2**63)));
/*
for( x = 0 ; x < 5 ; x++ ) {
for( y = 0 ; y < 5 ; y++ ) {
A[5*x+y] = A[5*x+y] ^ D[x];
}
}*/
a[0] = a[0] ^ d[0];
a[1] = a[1] ^ d[0];
a[2] = a[2] ^ d[0];
a[3] = a[3] ^ d[0];
a[4] = a[4] ^ d[0];
a[5] = a[5] ^ d[1];
a[6] = a[6] ^ d[1];
a[7] = a[7] ^ d[1];
a[8] = a[8] ^ d[1];
a[9] = a[9] ^ d[1];
a[10] = a[10] ^ d[2];
a[11] = a[11] ^ d[2];
a[12] = a[12] ^ d[2];
a[13] = a[13] ^ d[2];
a[14] = a[14] ^ d[2];
a[15] = a[15] ^ d[3];
a[16] = a[16] ^ d[3];
a[17] = a[17] ^ d[3];
a[18] = a[18] ^ d[3];
a[19] = a[19] ^ d[3];
a[20] = a[20] ^ d[4];
a[21] = a[21] ^ d[4];
a[22] = a[22] ^ d[4];
a[23] = a[23] ^ d[4];
a[24] = a[24] ^ d[4];
/*Rho and pi steps*/
b[0] = a[0];
b[8] = (((a[1] * (2**36)) & 0xffffffffffffffff) | (a[1] / (2**28)));
b[11] = (((a[2] * (2**3)) & 0xffffffffffffffff) | (a[2] / (2**61)));
b[19] = (((a[3] * (2**41)) & 0xffffffffffffffff) | (a[3] / (2**23)));
b[22] = (((a[4] * (2**18)) & 0xffffffffffffffff) | (a[4] / (2**46)));
b[2] = (((a[5] * (2**1)) & 0xffffffffffffffff) | (a[5] / (2**63)));
b[5] = (((a[6] * (2**44)) & 0xffffffffffffffff) | (a[6] / (2**20)));
b[13] = (((a[7] * (2**10)) & 0xffffffffffffffff) | (a[7] / (2**54)));
b[16] = (((a[8] * (2**45)) & 0xffffffffffffffff) | (a[8] / (2**19)));
b[24] = (((a[9] * (2**2)) & 0xffffffffffffffff) | (a[9] / (2**62)));
b[4] = (((a[10] * (2**62)) & 0xffffffffffffffff) | (a[10] / (2**2)));
b[7] = (((a[11] * (2**6)) & 0xffffffffffffffff) | (a[11] / (2**58)));
b[10] = (((a[12] * (2**43)) & 0xffffffffffffffff) | (a[12] / (2**21)));
b[18] = (((a[13] * (2**15)) & 0xffffffffffffffff) | (a[13] / (2**49)));
b[21] = (((a[14] * (2**61)) & 0xffffffffffffffff) | (a[14] / (2**3)));
b[1] = (((a[15] * (2**28)) & 0xffffffffffffffff) | (a[15] / (2**36)));
b[9] = (((a[16] * (2**55)) & 0xffffffffffffffff) | (a[16] / (2**9)));
b[12] = (((a[17] * (2**25)) & 0xffffffffffffffff) | (a[17] / (2**39)));
b[15] = (((a[18] * (2**21)) & 0xffffffffffffffff) | (a[18] / (2**43)));
b[23] = (((a[19] * (2**56)) & 0xffffffffffffffff) | (a[19] / (2**8)));
b[3] = (((a[20] * (2**27)) & 0xffffffffffffffff) | (a[20] / (2**37)));
b[6] = (((a[21] * (2**20)) & 0xffffffffffffffff) | (a[21] / (2**44)));
b[14] = (((a[22] * (2**39)) & 0xffffffffffffffff) | (a[22] / (2**25)));
b[17] = (((a[23] * (2**8)) & 0xffffffffffffffff) | (a[23] / (2**56)));
b[20] = (((a[24] * (2**14)) & 0xffffffffffffffff) | (a[24] / (2**50)));
/*Xi state*/
/*
for( x = 0 ; x < 5 ; x++ ) {
for( y = 0 ; y < 5 ; y++ ) {
A[5*x+y] = B[5*x+y]^((~B[5*((x+1)%5)+y]) & B[5*((x+2)%5)+y]);
}
}*/
a[0] = b[0] ^ ((~b[5]) & b[10]);
a[1] = b[1] ^ ((~b[6]) & b[11]);
a[2] = b[2] ^ ((~b[7]) & b[12]);
a[3] = b[3] ^ ((~b[8]) & b[13]);
a[4] = b[4] ^ ((~b[9]) & b[14]);
a[5] = b[5] ^ ((~b[10]) & b[15]);
a[6] = b[6] ^ ((~b[11]) & b[16]);
a[7] = b[7] ^ ((~b[12]) & b[17]);
a[8] = b[8] ^ ((~b[13]) & b[18]);
a[9] = b[9] ^ ((~b[14]) & b[19]);
a[10] = b[10] ^ ((~b[15]) & b[20]);
a[11] = b[11] ^ ((~b[16]) & b[21]);
a[12] = b[12] ^ ((~b[17]) & b[22]);
a[13] = b[13] ^ ((~b[18]) & b[23]);
a[14] = b[14] ^ ((~b[19]) & b[24]);
a[15] = b[15] ^ ((~b[20]) & b[0]);
a[16] = b[16] ^ ((~b[21]) & b[1]);
a[17] = b[17] ^ ((~b[22]) & b[2]);
a[18] = b[18] ^ ((~b[23]) & b[3]);
a[19] = b[19] ^ ((~b[24]) & b[4]);
a[20] = b[20] ^ ((~b[0]) & b[5]);
a[21] = b[21] ^ ((~b[1]) & b[6]);
a[22] = b[22] ^ ((~b[2]) & b[7]);
a[23] = b[23] ^ ((~b[3]) & b[8]);
a[24] = b[24] ^ ((~b[4]) & b[9]);
/*Last step*/
a[0] = a[0] ^ rc[i];
}
return a;
}
}
| 41,875 |
81 | // Return the entitied LP token balance for the given shares./share The number of shares to be converted to LP balance. | function shareToBalance(uint256 share) public view returns (uint256) {
if (totalShare == 0) return share; // When there's no share, 1 share = 1 balance.
(uint256 totalBalance, ) = masterChef.userInfo(pid, address(this));
return share.mul(totalBalance).div(totalShare);
}
| function shareToBalance(uint256 share) public view returns (uint256) {
if (totalShare == 0) return share; // When there's no share, 1 share = 1 balance.
(uint256 totalBalance, ) = masterChef.userInfo(pid, address(this));
return share.mul(totalBalance).div(totalShare);
}
| 31,884 |
7 | // initialization address / | function initialize() initializer public {
__Pausable_init();
__AccessControl_init();
__ReentrancyGuard_init();
// init default values
managerFeeShare = 200; // 20%
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_grantRole(CONTROLLER_ROLE, msg.sender);
_grantRole(PAUSER_ROLE, msg.sender);
_grantRole(MANAGER_ROLE, msg.sender);
}
| function initialize() initializer public {
__Pausable_init();
__AccessControl_init();
__ReentrancyGuard_init();
// init default values
managerFeeShare = 200; // 20%
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_grantRole(CONTROLLER_ROLE, msg.sender);
_grantRole(PAUSER_ROLE, msg.sender);
_grantRole(MANAGER_ROLE, msg.sender);
}
| 32,202 |
43 | // deposits The underlying asset into the reserve. _pool the address of the pool _amount the amount to be deposited / | {
(address _token0, address _token1) = getPoolTokens(_pool);
require(_token0 != address(0), "UnilendV2: POOL NOT FOUND");
uint _nftID = IUnilendV2Position(positionsAddress).getNftId(
_pool,
msg.sender
);
if (_nftID == 0) {
_nftID = IUnilendV2Position(positionsAddress).newPosition(
_pool,
msg.sender
);
}
address _reserve = _amount < 0 ? _token0 : _token1;
mintedTokens = iLend(_pool, _reserve, _amount, _nftID);
}
| {
(address _token0, address _token1) = getPoolTokens(_pool);
require(_token0 != address(0), "UnilendV2: POOL NOT FOUND");
uint _nftID = IUnilendV2Position(positionsAddress).getNftId(
_pool,
msg.sender
);
if (_nftID == 0) {
_nftID = IUnilendV2Position(positionsAddress).newPosition(
_pool,
msg.sender
);
}
address _reserve = _amount < 0 ? _token0 : _token1;
mintedTokens = iLend(_pool, _reserve, _amount, _nftID);
}
| 22,370 |
1 | // address public constant devAddress = 0xbF535Abb8E3b277B250d4f9e444E81355A1E68ae; |
uint256 public reservedClaimed;
uint256 public numNFTsMinted;
string public baseTokenURI;
bool public publicSaleStarted;
bool public presaleStarted;
|
uint256 public reservedClaimed;
uint256 public numNFTsMinted;
string public baseTokenURI;
bool public publicSaleStarted;
bool public presaleStarted;
| 19,392 |
23 | // Image | metadata = string(
abi.encodePacked(
metadata,
' "image": "',
string(
abi.encodePacked(
"data:image/svg+xml;base64,",
Base64.encode(bytes(image))
)
),
| metadata = string(
abi.encodePacked(
metadata,
' "image": "',
string(
abi.encodePacked(
"data:image/svg+xml;base64,",
Base64.encode(bytes(image))
)
),
| 56,538 |
34 | // 40 is the final reward era, almost all tokens mintedonce the final era is reached, more tokens will not be given out because the assert function | if( tokensMinted.add(getMiningReward()) > maxSupplyForEra && rewardEra < 39)
{
rewardEra = rewardEra + 1;
}
| if( tokensMinted.add(getMiningReward()) > maxSupplyForEra && rewardEra < 39)
{
rewardEra = rewardEra + 1;
}
| 11,094 |
33 | // Validates that a given wallet has reached a given nonce Used as an optional transaction on a Sequence batch, to define transaction execution order_wallet Sequence wallet _nonceRequired nonce / | function requireMinNonce(address _wallet, uint256 _nonce) external view {
(uint256 space, uint256 nonce) = _decodeNonce(_nonce);
uint256 currentNonce = IModuleCalls(_wallet).readNonce(space);
require(currentNonce >= nonce, "RequireUtils#requireMinNonce: NONCE_BELOW_REQUIRED");
}
| function requireMinNonce(address _wallet, uint256 _nonce) external view {
(uint256 space, uint256 nonce) = _decodeNonce(_nonce);
uint256 currentNonce = IModuleCalls(_wallet).readNonce(space);
require(currentNonce >= nonce, "RequireUtils#requireMinNonce: NONCE_BELOW_REQUIRED");
}
| 10,532 |
22 | // Calculate trade to sell eggs | function calculateEggSell(uint256 eggs) public view returns(uint256){
return calculateTrade(eggs,marketEggs, tokenContract.myTokens());
}
| function calculateEggSell(uint256 eggs) public view returns(uint256){
return calculateTrade(eggs,marketEggs, tokenContract.myTokens());
}
| 18,096 |
17 | // The function can be called only by crowdsale agent. / | modifier onlyCrowdsaleAgent() {
assert(msg.sender == crowdsaleAgent);
_;
}
| modifier onlyCrowdsaleAgent() {
assert(msg.sender == crowdsaleAgent);
_;
}
| 18,855 |
273 | // our current supply rate.we only calculate once because it is expensive | uint256 currentSR = currentSupplyRate();
| uint256 currentSR = currentSupplyRate();
| 5,889 |
392 | // Unwind liquidity from a protocol (i.e exit a farm) Implementation should unstake LP tokens and remove liquidity If there is only one token to unwind, `index` should be 0 amount Amount of liquidity to unwind index Which token should be unwound / | function unwindLiquidity(uint256 amount, uint8 index) external;
| function unwindLiquidity(uint256 amount, uint8 index) external;
| 12,857 |
270 | // Nov 17 20:00 UTC (1 hour later) | uint32 publicSaleLaunchTime = nHolderSaleLaunchTime + 3600;
DerivativeParameters params = DerivativeParameters(false, false, 0, 383, 4);
mapping(uint256 => bool) public override nUsed;
INOwnerResolver public immutable nOwnerResolver;
IKarmaScore public immutable karmaScoreResolver;
constructor(
address _n,
| uint32 publicSaleLaunchTime = nHolderSaleLaunchTime + 3600;
DerivativeParameters params = DerivativeParameters(false, false, 0, 383, 4);
mapping(uint256 => bool) public override nUsed;
INOwnerResolver public immutable nOwnerResolver;
IKarmaScore public immutable karmaScoreResolver;
constructor(
address _n,
| 17,141 |
91 | // Global Debt Ceiling [wad] | uint256 public override globalDebtCeiling;
| uint256 public override globalDebtCeiling;
| 69,607 |
113 | // Triggers stopped state Only possible when contract not paused. / | function pause() external onlyAdmin whenNotPaused {
_pause();
emit Pause();
}
| function pause() external onlyAdmin whenNotPaused {
_pause();
emit Pause();
}
| 82,072 |
72 | // supplyDelta = totalSupply(price - targetPrice) / targetPrice | int256 pricex1T = price.mul(1000000000000).toInt256Safe();
int256 targetPricex1T = mcap.toInt256Safe();
return BASE.totalSupply().toInt256Safe()
.mul(pricex1T.sub(targetPricex1T))
.div(targetPricex1T);
| int256 pricex1T = price.mul(1000000000000).toInt256Safe();
int256 targetPricex1T = mcap.toInt256Safe();
return BASE.totalSupply().toInt256Safe()
.mul(pricex1T.sub(targetPricex1T))
.div(targetPricex1T);
| 37,350 |
20 | // Returns the attribute's value (from 0 to 15) of an attestationsCollection collectionId Collection Id of the targeted attestationsCollection index Index of the attribute. Can go from 0 to 63. / | function getAttributeValueForAttestationsCollection(
uint256 collectionId,
uint8 index
| function getAttributeValueForAttestationsCollection(
uint256 collectionId,
uint8 index
| 25,483 |
190 | // A mapping from NFT ID to the bidding unit. / | mapping(uint256 => uint256) internal unit;
| mapping(uint256 => uint256) internal unit;
| 3,828 |
55 | // CG: Update previous vote | bytes32 previousDelegateLastProposal = lastVotedOn[previousDelegate];
bytes32 newDelegateLastProposal = lastVotedOn[stakerStake.delegate];
updateVoteIfNeeded(previousDelegateLastProposal, previousDelegate, previousStake, newDelegateLastProposal, stakerStake.delegate, stakerStake.amount);
| bytes32 previousDelegateLastProposal = lastVotedOn[previousDelegate];
bytes32 newDelegateLastProposal = lastVotedOn[stakerStake.delegate];
updateVoteIfNeeded(previousDelegateLastProposal, previousDelegate, previousStake, newDelegateLastProposal, stakerStake.delegate, stakerStake.amount);
| 43,505 |
10 | // Returns the question/// return the answer | function getQuestion() external view override returns(string memory) {
/* solhint-disable not-rely-on-time */
if (block.timestamp >= GENERATE_QUESTION_TIME) {
/* solhint-disable not-rely-on-time */
return question;
} else {
return "please wait for the supercomputer comes up with a question";
}
}
| function getQuestion() external view override returns(string memory) {
/* solhint-disable not-rely-on-time */
if (block.timestamp >= GENERATE_QUESTION_TIME) {
/* solhint-disable not-rely-on-time */
return question;
} else {
return "please wait for the supercomputer comes up with a question";
}
}
| 27,605 |
5 | // sendFees(); | uint fnftId = getRevest().mintAddressLock(address(this), '', recipients, quantities, fnftConfig);
uint interestRate = getInterestRate(monthsMaturity);
uint allocPoint = amount * interestRate;
StakingData memory cfg = StakingData(monthsMaturity, block.timestamp);
stakingConfigs[fnftId] = cfg;
IRewardsHandler(rewardsHandlerAddress).updateShares(fnftId, allocPoint);
| uint fnftId = getRevest().mintAddressLock(address(this), '', recipients, quantities, fnftConfig);
uint interestRate = getInterestRate(monthsMaturity);
uint allocPoint = amount * interestRate;
StakingData memory cfg = StakingData(monthsMaturity, block.timestamp);
stakingConfigs[fnftId] = cfg;
IRewardsHandler(rewardsHandlerAddress).updateShares(fnftId, allocPoint);
| 30,236 |
150 | // 变更可升级 | upgrade = true;
upgradeContractAddress = upgradeContract;
| upgrade = true;
upgradeContractAddress = upgradeContract;
| 37,165 |
43 | // Receivable Fallback | event Received(address from, uint amount);
| event Received(address from, uint amount);
| 10,391 |
262 | // AFI Distribution Admin // Set the amount of AFI distributed per block afiRate_ The amount of AFI wei per block to distribute / | function _setAFIRate(uint256 afiRate_) public {
require(adminOrInitializing(), "only admin can change afi rate");
uint256 oldRate = afiRate;
afiRate = afiRate_;
emit NewAFIRate(oldRate, afiRate_);
refreshAFISpeedsInternal();
}
| function _setAFIRate(uint256 afiRate_) public {
require(adminOrInitializing(), "only admin can change afi rate");
uint256 oldRate = afiRate;
afiRate = afiRate_;
emit NewAFIRate(oldRate, afiRate_);
refreshAFISpeedsInternal();
}
| 11,114 |
51 | // Returns the current rental balance.return The current rental balance. / | function getRentalBalance() public view returns (uint256) {
return _currentRentalId;
}
| function getRentalBalance() public view returns (uint256) {
return _currentRentalId;
}
| 27,387 |
45 | // initial state, when not set | return underlyingBalanceInVault();
| return underlyingBalanceInVault();
| 9,676 |
1 | // Burns a specific amount of the sender's tokens _value The amount of tokens to be burned / | function burn(uint256 _amount) public {
// Must not burn more than the sender owns
require(_amount <= balances[msg.sender]);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_amount);
totalSupply = totalSupply.sub(_amount);
Burn(burner, _amount);
}
| function burn(uint256 _amount) public {
// Must not burn more than the sender owns
require(_amount <= balances[msg.sender]);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_amount);
totalSupply = totalSupply.sub(_amount);
Burn(burner, _amount);
}
| 21,898 |
101 | // end liquidity lock mechanism. carry on now... |
if (_isExcluded[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && _isExcluded[recipient]) {
|
if (_isExcluded[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && _isExcluded[recipient]) {
| 2,986 |
80 | // The minimum amount of output tokens that must be received for the transaction not to revert. 0 = accept any amount (slippage is inevitable) | 0,
path,
address(this),
block.timestamp
);
| 0,
path,
address(this),
block.timestamp
);
| 23,709 |
55 | // Gets delta debt generated (Total Safe debt minus available safeHandler COIN balance)/safeEngine address/taxCollector address/safeHandler address/collateralType bytes32/ return deltaDebt | function _getGeneratedDeltaDebt(
address safeEngine,
address taxCollector,
address safeHandler,
bytes32 collateralType,
uint wad
| function _getGeneratedDeltaDebt(
address safeEngine,
address taxCollector,
address safeHandler,
bytes32 collateralType,
uint wad
| 13,036 |
23 | // BENEFICIARY METHODS | /* modifier restrict({
require(msg.sender == reciever);
_;
}) */
| /* modifier restrict({
require(msg.sender == reciever);
_;
}) */
| 6,525 |
141 | // Get more tokens we need | IUpgradableExchange(twoKeyUpgradableExchange).getMore2KeyTokensForRebalancingV1(tokensToTakeFromExchange);
| IUpgradableExchange(twoKeyUpgradableExchange).getMore2KeyTokensForRebalancingV1(tokensToTakeFromExchange);
| 35,467 |
13 | // minimum supply for cutoff | uint32 cutoffSupply;
| uint32 cutoffSupply;
| 25,786 |
95 | // Calculate the auctioneer&39;s cut, so this subtraction can&39;t go negative | uint256 auctioneerCut = _computeCut(price);
sellerProceeds = price - auctioneerCut;
| uint256 auctioneerCut = _computeCut(price);
sellerProceeds = price - auctioneerCut;
| 36,494 |
19 | // Change parcel's receivedTimestamp/parcelId the id of the parcel to set/newTimestamp the new timestamp | function setParcelReceivedTimestamp(bytes32 parcelId, uint newTimestamp) public onlyOwner returns (bool) {
if(newTimestamp == 0){
newTimestamp == now;
}
parcels[parcelId].receivedTimeStamp = newTimestamp;
emit SetParcelReceivedTimestamp(msg.sender, parcelId, parcels[parcelId].id, newTimestamp);
}
| function setParcelReceivedTimestamp(bytes32 parcelId, uint newTimestamp) public onlyOwner returns (bool) {
if(newTimestamp == 0){
newTimestamp == now;
}
parcels[parcelId].receivedTimeStamp = newTimestamp;
emit SetParcelReceivedTimestamp(msg.sender, parcelId, parcels[parcelId].id, newTimestamp);
}
| 4,562 |
19 | // range: [0, 2112 - 1] resolution: 1 / 2112 | struct uq112x112 {
uint224 _x;
}
| struct uq112x112 {
uint224 _x;
}
| 3,030 |
99 | // update val and suit counts, and if it&39;s a flush | _val = _card % 13;
_valCounts[_val]++;
_suitCounts[_card/13]++;
if (_suitCounts[_card/13] == 5) _hasFlush = true;
| _val = _card % 13;
_valCounts[_val]++;
_suitCounts[_card/13]++;
if (_suitCounts[_card/13] == 5) _hasFlush = true;
| 57,058 |
172 | // See `_checkContractStorageLoad` for more information. | if (gasleft() < MIN_GAS_FOR_INVALID_STATE_ACCESS) {
_revertWithFlag(RevertFlag.OUT_OF_GAS);
}
| if (gasleft() < MIN_GAS_FOR_INVALID_STATE_ACCESS) {
_revertWithFlag(RevertFlag.OUT_OF_GAS);
}
| 79,396 |
14 | // End rewards emission earlier | function updatePeriodFinish(uint timestamp) external onlyOwner updateReward(address(0)) {
periodFinish = timestamp;
}
| function updatePeriodFinish(uint timestamp) external onlyOwner updateReward(address(0)) {
periodFinish = timestamp;
}
| 3,014 |
7 | // add event | RequestPosted(owner, requestClientIndex, _requestName, _requestDescriptionAddr, _testCodeAddr, _reward, _threshold, _requestPostTime, false);
| RequestPosted(owner, requestClientIndex, _requestName, _requestDescriptionAddr, _testCodeAddr, _reward, _threshold, _requestPostTime, false);
| 12,859 |
60 | // BitGuildCrowdsaleCapped crowdsale with a stard/end date / | contract BitGuildCrowdsale {
using SafeMath for uint256;
// Token being sold
BitGuildToken public token;
// Whitelist being used
BitGuildWhitelist public whitelist;
// start and end timestamps where investments are allowed (both inclusive)
uint256 public startTime;
uint256 public endTime;
// Crowdsale cap (how much can be raised total)
uint256 public cap = 14062.5 ether;
// Address where funds are collected
address public wallet;
// Predefined rate of PLAT to Ethereum (1/rate = crowdsale price)
uint256 public rate = 80000;
// Min/max purchase
uint256 public minContribution = 0.5 ether;
uint256 public maxContribution = 1500 ether;
// amount of raised money in wei
uint256 public weiRaised;
mapping (address => uint256) public contributions;
// Finalization flag for when we want to withdraw the remaining tokens after the end
bool public crowdsaleFinalized = false;
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
function BitGuildCrowdsale(uint256 _startTime, uint256 _endTime, address _token, address _wallet, address _whitelist) public {
require(_startTime >= now);
require(_endTime >= _startTime);
require(_token != address(0));
require(_wallet != address(0));
require(_whitelist != address(0));
startTime = _startTime;
endTime = _endTime;
token = BitGuildToken(_token);
wallet = _wallet;
whitelist = BitGuildWhitelist(_whitelist);
}
// fallback function can be used to buy tokens
function () external payable {
buyTokens(msg.sender);
}
// low level token purchase function
function buyTokens(address beneficiary) public payable {
require(beneficiary != address(0));
require(whitelist.whitelist(beneficiary));
require(validPurchase());
uint256 weiAmount = msg.value;
// calculate token amount to be created
uint256 tokens = getTokenAmount(weiAmount);
// update total and individual contributions
weiRaised = weiRaised.add(weiAmount);
contributions[beneficiary] = contributions[beneficiary].add(weiAmount);
// Send tokens
token.transfer(beneficiary, tokens);
TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
// Send funds
wallet.transfer(msg.value);
}
// Returns true if crowdsale event has ended
function hasEnded() public view returns (bool) {
bool capReached = weiRaised >= cap;
bool endTimeReached = now > endTime;
return capReached || endTimeReached || crowdsaleFinalized;
}
// Bonuses for larger purchases (in hundredths of percent)
function bonusPercentForWeiAmount(uint256 weiAmount) public pure returns(uint256) {
if (weiAmount >= 500 ether) return 1000; // 10%
if (weiAmount >= 250 ether) return 750; // 7.5%
if (weiAmount >= 100 ether) return 500; // 5%
if (weiAmount >= 50 ether) return 375; // 3.75%
if (weiAmount >= 15 ether) return 250; // 2.5%
if (weiAmount >= 5 ether) return 125; // 1.25%
return 0; // 0% bonus if lower than 5 eth
}
// Returns you how much tokens do you get for the wei passed
function getTokenAmount(uint256 weiAmount) internal view returns(uint256) {
uint256 tokens = weiAmount.mul(rate);
uint256 bonus = bonusPercentForWeiAmount(weiAmount);
tokens = tokens.mul(10000 + bonus).div(10000);
return tokens;
}
// Returns true if the transaction can buy tokens
function validPurchase() internal view returns (bool) {
bool withinPeriod = now >= startTime && now <= endTime;
bool moreThanMinPurchase = msg.value >= minContribution;
bool lessThanMaxPurchase = contributions[msg.sender] + msg.value <= maxContribution;
bool withinCap = weiRaised.add(msg.value) <= cap;
return withinPeriod && moreThanMinPurchase && lessThanMaxPurchase && withinCap && !crowdsaleFinalized;
}
// Escape hatch in case the sale needs to be urgently stopped
function finalizeCrowdsale() public {
require(msg.sender == wallet);
crowdsaleFinalized = true;
// send remaining tokens back to the admin
uint256 tokensLeft = token.balanceOf(this);
token.transfer(wallet, tokensLeft);
}
} | contract BitGuildCrowdsale {
using SafeMath for uint256;
// Token being sold
BitGuildToken public token;
// Whitelist being used
BitGuildWhitelist public whitelist;
// start and end timestamps where investments are allowed (both inclusive)
uint256 public startTime;
uint256 public endTime;
// Crowdsale cap (how much can be raised total)
uint256 public cap = 14062.5 ether;
// Address where funds are collected
address public wallet;
// Predefined rate of PLAT to Ethereum (1/rate = crowdsale price)
uint256 public rate = 80000;
// Min/max purchase
uint256 public minContribution = 0.5 ether;
uint256 public maxContribution = 1500 ether;
// amount of raised money in wei
uint256 public weiRaised;
mapping (address => uint256) public contributions;
// Finalization flag for when we want to withdraw the remaining tokens after the end
bool public crowdsaleFinalized = false;
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
function BitGuildCrowdsale(uint256 _startTime, uint256 _endTime, address _token, address _wallet, address _whitelist) public {
require(_startTime >= now);
require(_endTime >= _startTime);
require(_token != address(0));
require(_wallet != address(0));
require(_whitelist != address(0));
startTime = _startTime;
endTime = _endTime;
token = BitGuildToken(_token);
wallet = _wallet;
whitelist = BitGuildWhitelist(_whitelist);
}
// fallback function can be used to buy tokens
function () external payable {
buyTokens(msg.sender);
}
// low level token purchase function
function buyTokens(address beneficiary) public payable {
require(beneficiary != address(0));
require(whitelist.whitelist(beneficiary));
require(validPurchase());
uint256 weiAmount = msg.value;
// calculate token amount to be created
uint256 tokens = getTokenAmount(weiAmount);
// update total and individual contributions
weiRaised = weiRaised.add(weiAmount);
contributions[beneficiary] = contributions[beneficiary].add(weiAmount);
// Send tokens
token.transfer(beneficiary, tokens);
TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
// Send funds
wallet.transfer(msg.value);
}
// Returns true if crowdsale event has ended
function hasEnded() public view returns (bool) {
bool capReached = weiRaised >= cap;
bool endTimeReached = now > endTime;
return capReached || endTimeReached || crowdsaleFinalized;
}
// Bonuses for larger purchases (in hundredths of percent)
function bonusPercentForWeiAmount(uint256 weiAmount) public pure returns(uint256) {
if (weiAmount >= 500 ether) return 1000; // 10%
if (weiAmount >= 250 ether) return 750; // 7.5%
if (weiAmount >= 100 ether) return 500; // 5%
if (weiAmount >= 50 ether) return 375; // 3.75%
if (weiAmount >= 15 ether) return 250; // 2.5%
if (weiAmount >= 5 ether) return 125; // 1.25%
return 0; // 0% bonus if lower than 5 eth
}
// Returns you how much tokens do you get for the wei passed
function getTokenAmount(uint256 weiAmount) internal view returns(uint256) {
uint256 tokens = weiAmount.mul(rate);
uint256 bonus = bonusPercentForWeiAmount(weiAmount);
tokens = tokens.mul(10000 + bonus).div(10000);
return tokens;
}
// Returns true if the transaction can buy tokens
function validPurchase() internal view returns (bool) {
bool withinPeriod = now >= startTime && now <= endTime;
bool moreThanMinPurchase = msg.value >= minContribution;
bool lessThanMaxPurchase = contributions[msg.sender] + msg.value <= maxContribution;
bool withinCap = weiRaised.add(msg.value) <= cap;
return withinPeriod && moreThanMinPurchase && lessThanMaxPurchase && withinCap && !crowdsaleFinalized;
}
// Escape hatch in case the sale needs to be urgently stopped
function finalizeCrowdsale() public {
require(msg.sender == wallet);
crowdsaleFinalized = true;
// send remaining tokens back to the admin
uint256 tokensLeft = token.balanceOf(this);
token.transfer(wallet, tokensLeft);
}
} | 20,420 |
2 | // Sets the image URL for a specific token. tokenId The ID of the token. imageUrl The new image URL to be set for the specified token.Requirements:- The token with the given tokenId must exist.- Only addresses with the admin role can call this function. / | function setImageUrl(
uint256 tokenId,
string memory imageUrl
| function setImageUrl(
uint256 tokenId,
string memory imageUrl
| 22,947 |
20 | // 放弃所有权 仅所有者可访问 | function renounceOwnership() public onlyOwner {
// 触发转移所有权事件(访问者,合约用户列表第一个人)
emit OwnershipTransferred(_owner, address(0));
// 临时修改当前实例的用户对象为新的继承者 以保证当前合约继续执行
_owner = address(0);
}
| function renounceOwnership() public onlyOwner {
// 触发转移所有权事件(访问者,合约用户列表第一个人)
emit OwnershipTransferred(_owner, address(0));
// 临时修改当前实例的用户对象为新的继承者 以保证当前合约继续执行
_owner = address(0);
}
| 29,697 |
3 | // pluck function - pluck a random item from the array | function pluck(uint256 _tokenId, string memory _keyPrefix, string[] memory _sourceArray) internal pure returns(string memory) {
uint256 randomNumber = random(string(abi.encodePacked(_keyPrefix, Strings.toString(_tokenId))));
string memory output = _sourceArray[randomNumber % _sourceArray.length];
return output;
}
| function pluck(uint256 _tokenId, string memory _keyPrefix, string[] memory _sourceArray) internal pure returns(string memory) {
uint256 randomNumber = random(string(abi.encodePacked(_keyPrefix, Strings.toString(_tokenId))));
string memory output = _sourceArray[randomNumber % _sourceArray.length];
return output;
}
| 10,270 |
39 | // 移除黑名单 | function setPersonalStop(address _who) public onlyOwner returns (bool) {
personalStopped[_who] = true;
return true;
}
| function setPersonalStop(address _who) public onlyOwner returns (bool) {
personalStopped[_who] = true;
return true;
}
| 26,200 |
13 | // Returns if the account has the payment token price setter role or/ is the manager/account Account address/ return If the account has the payment token price setter or is the/ manager | function hasPaymentTokenPriceSetterRoleOrIsManager(address account)
internal
view
returns (bool)
| function hasPaymentTokenPriceSetterRoleOrIsManager(address account)
internal
view
returns (bool)
| 34,494 |
104 | // https:etherscan.io/address/0x76884cAFeCf1f7d4146DA6C4053B18B76bf6ED14 | address internal constant CRV_INTEREST_RATE_STRATEGY = 0x76884cAFeCf1f7d4146DA6C4053B18B76bf6ED14;
| address internal constant CRV_INTEREST_RATE_STRATEGY = 0x76884cAFeCf1f7d4146DA6C4053B18B76bf6ED14;
| 15,798 |
113 | // See {IERC721-transferFrom}. / | function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
| function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
| 205 |
3 | // Staking options === | function setMinimumStakeTime(uint256 minTime) public onlyOwner {
minStakeTime = minTime;
}
| function setMinimumStakeTime(uint256 minTime) public onlyOwner {
minStakeTime = minTime;
}
| 17,789 |
7 | // check cap | checkCap(amount);
| checkCap(amount);
| 43,733 |
11 | // See {ITrustedIssuersRegistry-getTrustedIssuerClaimTopics}. / | function getTrustedIssuerClaimTopics(IClaimIssuer _trustedIssuer) external view override returns (uint256[] memory) {
require(trustedIssuerClaimTopics[address(_trustedIssuer)].length != 0, 'trusted Issuer doesn\'t exist');
return trustedIssuerClaimTopics[address(_trustedIssuer)];
}
| function getTrustedIssuerClaimTopics(IClaimIssuer _trustedIssuer) external view override returns (uint256[] memory) {
require(trustedIssuerClaimTopics[address(_trustedIssuer)].length != 0, 'trusted Issuer doesn\'t exist');
return trustedIssuerClaimTopics[address(_trustedIssuer)];
}
| 36,241 |
5 | // Function allows Dapp Creator call to get price / | function getPrice(
| function getPrice(
| 35,254 |
192 | // We invoke doTransferOut for the borrower and the borrowAmount. Note: The aToken must handle variations between ERC-20 and ETH underlying. On success, the aToken borrowAmount less of cash. doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred. / | doTransferOut(borrower, borrowAmount);
| doTransferOut(borrower, borrowAmount);
| 21,469 |
97 | // Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. / | function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = alphabet[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
| function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = alphabet[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
| 927 |
38 | // Whether or not the proxy should upgrade./ return If the proxy can be upgraded and the new implementation address. | function shouldUpgrade() external view override returns (bool, address) {
return (
nextImplementationTimestamp() != 0
&& block.timestamp > nextImplementationTimestamp()
&& nextImplementation() != address(0),
nextImplementation()
);
}
| function shouldUpgrade() external view override returns (bool, address) {
return (
nextImplementationTimestamp() != 0
&& block.timestamp > nextImplementationTimestamp()
&& nextImplementation() != address(0),
nextImplementation()
);
}
| 71,669 |
0 | // Deploy a Pool./ Make sure that the fyToken follows ERC20 standards with regards to name, symbol and decimals | constructor(IERC20 base_, IFYToken fyToken_, int128 ts_, int128 g1_, int128 g2_)
ERC20Permit(
string(abi.encodePacked(IERC20Metadata(address(fyToken_)).name(), " LP")),
string(abi.encodePacked(IERC20Metadata(address(fyToken_)).symbol(), "LP")),
IERC20Metadata(address(fyToken_)).decimals()
)
| constructor(IERC20 base_, IFYToken fyToken_, int128 ts_, int128 g1_, int128 g2_)
ERC20Permit(
string(abi.encodePacked(IERC20Metadata(address(fyToken_)).name(), " LP")),
string(abi.encodePacked(IERC20Metadata(address(fyToken_)).symbol(), "LP")),
IERC20Metadata(address(fyToken_)).decimals()
)
| 67,981 |
10 | // if sell | if(pair[to] && sellTax > 0) {
amount -= SellFees;
super._transfer(from, address(this), SellFees);
super._transfer(from, to, amount);
}
| if(pair[to] && sellTax > 0) {
amount -= SellFees;
super._transfer(from, address(this), SellFees);
super._transfer(from, to, amount);
}
| 21,676 |
8 | // An ETH backed implementation of the IWasabiErrors. / | contract ETHWasabiPool is AbstractWasabiPool {
receive() external payable override {
emit ETHReceived(msg.value);
}
/**
* @dev Initializes this pool with the given parameters.
*/
function initialize(
IWasabiPoolFactory _factory,
IERC721 _nft,
address _optionNFT,
address _owner,
address _admin
) external payable {
baseInitialize(_factory, _nft, _optionNFT, _owner, _admin);
}
/// @inheritdoc AbstractWasabiPool
function validateAndWithdrawPayment(uint256 _premium, string memory _message) internal override {
IWasabiFeeManager feeManager = IWasabiFeeManager(factory.getFeeManager());
(address feeReceiver, uint256 feeAmount) = feeManager.getFeeData(address(this), _premium);
if (feeAmount > 0) {
uint256 maxFee = _maxFee(_premium);
if (feeAmount > maxFee) {
feeAmount = maxFee;
}
(bool _sent, ) = payable(feeReceiver).call{value: feeAmount}("");
if (!_sent) {
revert IWasabiErrors.FailedToSend();
}
}
require(msg.value >= (_premium + feeAmount) && _premium > 0, _message);
}
/// @inheritdoc AbstractWasabiPool
function payAddress(address _seller, uint256 _amount) internal override {
IWasabiFeeManager feeManager = IWasabiFeeManager(factory.getFeeManager());
(address feeReceiver, uint256 feeAmount) = feeManager.getFeeData(address(this), _amount);
if (feeAmount > 0) {
uint256 maxFee = _maxFee(_amount);
if (feeAmount > maxFee) {
feeAmount = maxFee;
}
(bool _sent, ) = payable(feeReceiver).call{value: feeAmount}("");
if (!_sent) {
revert IWasabiErrors.FailedToSend();
}
}
(bool sent, ) = payable(_seller).call{value: _amount - feeAmount}("");
if (!sent) {
revert IWasabiErrors.FailedToSend();
}
}
/// @inheritdoc IWasabiPool
function withdrawETH(uint256 _amount) external payable onlyOwner {
if (availableBalance() < _amount) {
revert IWasabiErrors.InsufficientAvailableLiquidity();
}
address payable to = payable(_msgSender());
(bool sent, ) = to.call{value: _amount}("");
if (!sent) {
revert IWasabiErrors.FailedToSend();
}
emit ETHWithdrawn(_amount);
}
/// @inheritdoc IWasabiPool
function withdrawERC20(IERC20 _token, uint256 _amount) external onlyOwner {
if (!_token.transfer(msg.sender, _amount)) {
revert IWasabiErrors.FailedToSend();
}
}
/// @inheritdoc IWasabiPool
function availableBalance() view public override returns(uint256) {
uint256 balance = address(this).balance;
uint256[] memory optionIds = getOptionIds();
for (uint256 i = 0; i < optionIds.length; i++) {
WasabiStructs.OptionData memory optionData = getOptionData(optionIds[i]);
if (optionData.optionType == WasabiStructs.OptionType.PUT && isValid(optionIds[i])) {
balance -= optionData.strikePrice;
}
}
return balance;
}
} | contract ETHWasabiPool is AbstractWasabiPool {
receive() external payable override {
emit ETHReceived(msg.value);
}
/**
* @dev Initializes this pool with the given parameters.
*/
function initialize(
IWasabiPoolFactory _factory,
IERC721 _nft,
address _optionNFT,
address _owner,
address _admin
) external payable {
baseInitialize(_factory, _nft, _optionNFT, _owner, _admin);
}
/// @inheritdoc AbstractWasabiPool
function validateAndWithdrawPayment(uint256 _premium, string memory _message) internal override {
IWasabiFeeManager feeManager = IWasabiFeeManager(factory.getFeeManager());
(address feeReceiver, uint256 feeAmount) = feeManager.getFeeData(address(this), _premium);
if (feeAmount > 0) {
uint256 maxFee = _maxFee(_premium);
if (feeAmount > maxFee) {
feeAmount = maxFee;
}
(bool _sent, ) = payable(feeReceiver).call{value: feeAmount}("");
if (!_sent) {
revert IWasabiErrors.FailedToSend();
}
}
require(msg.value >= (_premium + feeAmount) && _premium > 0, _message);
}
/// @inheritdoc AbstractWasabiPool
function payAddress(address _seller, uint256 _amount) internal override {
IWasabiFeeManager feeManager = IWasabiFeeManager(factory.getFeeManager());
(address feeReceiver, uint256 feeAmount) = feeManager.getFeeData(address(this), _amount);
if (feeAmount > 0) {
uint256 maxFee = _maxFee(_amount);
if (feeAmount > maxFee) {
feeAmount = maxFee;
}
(bool _sent, ) = payable(feeReceiver).call{value: feeAmount}("");
if (!_sent) {
revert IWasabiErrors.FailedToSend();
}
}
(bool sent, ) = payable(_seller).call{value: _amount - feeAmount}("");
if (!sent) {
revert IWasabiErrors.FailedToSend();
}
}
/// @inheritdoc IWasabiPool
function withdrawETH(uint256 _amount) external payable onlyOwner {
if (availableBalance() < _amount) {
revert IWasabiErrors.InsufficientAvailableLiquidity();
}
address payable to = payable(_msgSender());
(bool sent, ) = to.call{value: _amount}("");
if (!sent) {
revert IWasabiErrors.FailedToSend();
}
emit ETHWithdrawn(_amount);
}
/// @inheritdoc IWasabiPool
function withdrawERC20(IERC20 _token, uint256 _amount) external onlyOwner {
if (!_token.transfer(msg.sender, _amount)) {
revert IWasabiErrors.FailedToSend();
}
}
/// @inheritdoc IWasabiPool
function availableBalance() view public override returns(uint256) {
uint256 balance = address(this).balance;
uint256[] memory optionIds = getOptionIds();
for (uint256 i = 0; i < optionIds.length; i++) {
WasabiStructs.OptionData memory optionData = getOptionData(optionIds[i]);
if (optionData.optionType == WasabiStructs.OptionType.PUT && isValid(optionIds[i])) {
balance -= optionData.strikePrice;
}
}
return balance;
}
} | 26,139 |
1,446 | // Constraining the range of funding rates limits the PfC for any dishonest proposer and enhances the perpetual's security. For example, let's examine the case where the max and min funding rates are equivalent to +/- 500%/year. This 1000% funding rate range allows a 8.6% profit from corruption for a proposer who can deter honest proposers for 74 hours: 1000%/year / 360 days / 24 hours74 hours max attack time = ~ 8.6%. How would attack work? Imagine that the market is very volatile currently and that the "true" funding rate for the next 74 hours is -500%, but a dishonest | function _validateFundingRate(FixedPoint.Signed memory rate) internal {
require(
rate.isLessThanOrEqual(_getConfig().maxFundingRate) &&
rate.isGreaterThanOrEqual(_getConfig().minFundingRate)
);
}
| function _validateFundingRate(FixedPoint.Signed memory rate) internal {
require(
rate.isLessThanOrEqual(_getConfig().maxFundingRate) &&
rate.isGreaterThanOrEqual(_getConfig().minFundingRate)
);
}
| 10,487 |
41 | // Increase the dispute count by 1 | uint256 disputeId = self.uintVars[keccak256("disputeCount")] + 1;
self.uintVars[keccak256("disputeCount")] = disputeId;
| uint256 disputeId = self.uintVars[keccak256("disputeCount")] + 1;
self.uintVars[keccak256("disputeCount")] = disputeId;
| 25,968 |
137 | // update reward vairables for a pool | function updatePoolDividend(uint256 _pid) public virtual {
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastDividendHeight) {
return;
}
if (pool.tokenAmount == 0) {
pool.lastDividendHeight = block.number;
return;
}
uint256 availableDividend = totalAvailableDividend;
uint256 multiplier = getMultiplier(pool.lastDividendHeight, block.number);
uint256 producedToken = multiplier.mul(SHDPerBlock);
producedToken = availableDividend > producedToken? producedToken: availableDividend;
if(totalAllocPoint > 0){
uint256 poolDevidend = producedToken.mul(pool.allocPoint).div(totalAllocPoint);
if(poolDevidend > 0){
totalAvailableDividend = totalAvailableDividend.sub(poolDevidend);
pool.accumulativeDividend = pool.accumulativeDividend.add(poolDevidend);
pool.accShardPerWeight = pool.accShardPerWeight.add(poolDevidend.mul(1e12).div(pool.totalWeight));
}
}
pool.lastDividendHeight = block.number;
}
| function updatePoolDividend(uint256 _pid) public virtual {
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastDividendHeight) {
return;
}
if (pool.tokenAmount == 0) {
pool.lastDividendHeight = block.number;
return;
}
uint256 availableDividend = totalAvailableDividend;
uint256 multiplier = getMultiplier(pool.lastDividendHeight, block.number);
uint256 producedToken = multiplier.mul(SHDPerBlock);
producedToken = availableDividend > producedToken? producedToken: availableDividend;
if(totalAllocPoint > 0){
uint256 poolDevidend = producedToken.mul(pool.allocPoint).div(totalAllocPoint);
if(poolDevidend > 0){
totalAvailableDividend = totalAvailableDividend.sub(poolDevidend);
pool.accumulativeDividend = pool.accumulativeDividend.add(poolDevidend);
pool.accShardPerWeight = pool.accShardPerWeight.add(poolDevidend.mul(1e12).div(pool.totalWeight));
}
}
pool.lastDividendHeight = block.number;
}
| 17,956 |
99 | // Modifier with the conditions to be able to withdrawbased on exerciseType. / | modifier withdrawWindow() {
require(_isWithdrawWindow(), "PodOption: option has not expired yet");
_;
}
| modifier withdrawWindow() {
require(_isWithdrawWindow(), "PodOption: option has not expired yet");
_;
}
| 62,034 |
32 | // create a modifier that checks if the challenge winners is not set | modifier challengeWinnersIsNotSet {
require(isWinnersSet == false, "Challenge winners is set.");
_;
}
| modifier challengeWinnersIsNotSet {
require(isWinnersSet == false, "Challenge winners is set.");
_;
}
| 24,402 |
24 | // Storing info on the chain | function uploadBabiesImage(bytes calldata s) external onlyOwnerOrManager {}
| function uploadBabiesImage(bytes calldata s) external onlyOwnerOrManager {}
| 11,993 |
38 | // cancel user delegation/makes user his own delegate | function undelegate() public {
return _delegateTo(msg.sender, msg.sender);
}
| function undelegate() public {
return _delegateTo(msg.sender, msg.sender);
}
| 39,598 |
14 | // Logs the market into the registery. _vault: Address of the vault. _creator: Creator of the market. return uint256: Returns the index of market for looking up./ | function registerMarket(
address _marketAddress,
address _vault,
address _creator)
external
isRegisteredDeployer()
returns(uint256)
| function registerMarket(
address _marketAddress,
address _vault,
address _creator)
external
isRegisteredDeployer()
returns(uint256)
| 44,591 |
29 | // Decrease approval | function decreaseApproval (address _spender, uint _subtractedValue) public
| function decreaseApproval (address _spender, uint _subtractedValue) public
| 54,886 |
19 | // The initial COMP index for a market | uint224 public constant compInitialIndex = 1e36;
| uint224 public constant compInitialIndex = 1e36;
| 16,343 |
35 | // Insert node `_new` beside existing node `_node` in direction `_direction`./self stored linked list from contract/_node existing node/_newnew node to insert/_direction direction to insert node in | function insert(LinkedList storage self, uint256 _node, uint256 _new, bool _direction) internal returns (bool) {
if(!nodeExists(self,_new) && nodeExists(self,_node)) {
uint256 c = self.list[_node][_direction];
createLink(self, _node, _new, _direction);
createLink(self, _new, c, _direction);
return true;
} else {
return false;
}
}
| function insert(LinkedList storage self, uint256 _node, uint256 _new, bool _direction) internal returns (bool) {
if(!nodeExists(self,_new) && nodeExists(self,_node)) {
uint256 c = self.list[_node][_direction];
createLink(self, _node, _new, _direction);
createLink(self, _new, c, _direction);
return true;
} else {
return false;
}
}
| 25,500 |
6 | // Returns the resolver for the given market. The default is the contract owner_market Market contract address / | function getMarketResolver(address _market) public view returns (address) {
if (marketsToResolvers[_market] != NULL_ADDRESS) {
return marketsToResolvers[_market];
}
return owner();
}
| function getMarketResolver(address _market) public view returns (address) {
if (marketsToResolvers[_market] != NULL_ADDRESS) {
return marketsToResolvers[_market];
}
return owner();
}
| 38,248 |
77 | // be specified by overriding the virtual {_implementation} function.Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to adifferent contract through the {_delegate} function./ Delegates the current call to `implementation`. This function does not return to its internall call site, it will return directly to the external caller. / | function _delegate(address implementation) internal virtual {
| function _delegate(address implementation) internal virtual {
| 23,915 |
23 | // 初始化合约,并且把初始的所有的令牌都给这合约的创建者 initialSupply 所有币的总数 tokenName 代币名称 tokenSymbol 代币符号 / | function MyAdvancedToken(
uint256 initialSupply,
string tokenName,
string tokenSymbol
| function MyAdvancedToken(
uint256 initialSupply,
string tokenName,
string tokenSymbol
| 24,936 |
29 | // Set Props for the NFT of the champion | tokenId = currentId;
tokens[currentId].champion = champion;
tokens[currentId].price = price;
tokens[currentId].maxSupply = maxSupply;
tokens[currentId].sponsor = msg.sender;
tokens[currentId].apy = apy;
tokens[currentId].interestProportion = interestProportion;
tokens[currentId].daysToFirstPayment = daysToFirstPayment;
tokens[currentId].paymentFreqInDays = paymentFreqInDays;
tokens[currentId].numberOfPayments = numberOfPayments;
| tokenId = currentId;
tokens[currentId].champion = champion;
tokens[currentId].price = price;
tokens[currentId].maxSupply = maxSupply;
tokens[currentId].sponsor = msg.sender;
tokens[currentId].apy = apy;
tokens[currentId].interestProportion = interestProportion;
tokens[currentId].daysToFirstPayment = daysToFirstPayment;
tokens[currentId].paymentFreqInDays = paymentFreqInDays;
tokens[currentId].numberOfPayments = numberOfPayments;
| 26,353 |
0 | // 内部函数_msgSender,获取函数调用者地址 / | function _msgSender() internal view returns (address payable) {
return msg.sender;
}
| function _msgSender() internal view returns (address payable) {
return msg.sender;
}
| 14,951 |
4 | // Decrease the buy tax from 99% to normal rate within 3 minutes.Returns buy tax percentage / | function getDynamicBuyTax() public view returns (uint256) {
uint256 endingTime = launchTime + 3 minutes;
if (endingTime > block.timestamp) {
uint256 remainingTime = endingTime - block.timestamp;
return buyTax + 9100 * remainingTime / 3 minutes;
} else {
return buyTax;
}
}
| function getDynamicBuyTax() public view returns (uint256) {
uint256 endingTime = launchTime + 3 minutes;
if (endingTime > block.timestamp) {
uint256 remainingTime = endingTime - block.timestamp;
return buyTax + 9100 * remainingTime / 3 minutes;
} else {
return buyTax;
}
}
| 40,864 |
206 | // address of the aToken representing the asset//address of the interest rate strategy contract/ borrowingEnabled = true means users can borrow from this reserve | bool borrowingEnabled;
| bool borrowingEnabled;
| 24,258 |
37 | // allows Tellor to read data from the addressVars mapping _data is the keccak256("variable_name") of the variable that is being accessed.These are examples of how the variables are saved within other functions:addressVars[keccak256("_owner")]addressVars[keccak256("tellorContract")]return address / | function getAddressVars(bytes32 _data) external view returns (address);
| function getAddressVars(bytes32 _data) external view returns (address);
| 30,892 |
131 | // Max mints per transaction | uint256 private _maxTxMint;
| uint256 private _maxTxMint;
| 66,321 |
5 | // The fee to be charged for a given loan. token The loan currency. amount The amount of tokens lent.return The amount of `token` to be charged for the loan, on top of the returned principal. / | function flashFee(address token, uint256 amount) external view returns (uint256);
| function flashFee(address token, uint256 amount) external view returns (uint256);
| 16,205 |
282 | // Tracking affiliate sponsors | mapping(address => address) public sponsors; // 1 sponsor can have many affiliates, but only 1 sponsor, returns sponsor
| mapping(address => address) public sponsors; // 1 sponsor can have many affiliates, but only 1 sponsor, returns sponsor
| 1,784 |
122 | // Constructs the contract, approves each token inside of baseSwap to be used by baseSwap (needed for addLiquidity()) / | constructor(ISwap _baseSwap, ISynapseBridge _synapseBridge) public {
baseSwap = _baseSwap;
synapseBridge = _synapseBridge;
{
uint8 i;
for (; i < 32; i++) {
try _baseSwap.getToken(i) returns (IERC20 token) {
baseTokens.push(token);
token.safeApprove(address(_baseSwap), MAX_UINT256);
} catch {
break;
}
}
require(i > 1, 'baseSwap must have at least 2 tokens');
}
}
| constructor(ISwap _baseSwap, ISynapseBridge _synapseBridge) public {
baseSwap = _baseSwap;
synapseBridge = _synapseBridge;
{
uint8 i;
for (; i < 32; i++) {
try _baseSwap.getToken(i) returns (IERC20 token) {
baseTokens.push(token);
token.safeApprove(address(_baseSwap), MAX_UINT256);
} catch {
break;
}
}
require(i > 1, 'baseSwap must have at least 2 tokens');
}
}
| 71,903 |
64 | // Transfers funds from caller to offer maker, and from market to caller. | function buy(uint id, uint amount)
public
can_buy(id)
returns (bool)
| function buy(uint id, uint amount)
public
can_buy(id)
returns (bool)
| 5,110 |
109 | // can later be changed with {transferOwnership}./ Returns the current owner. / | function _getOwner() internal view returns (address) {
return StorageSlot.getAddressSlot(_OWNER_SLOT).value;
}
| function _getOwner() internal view returns (address) {
return StorageSlot.getAddressSlot(_OWNER_SLOT).value;
}
| 47,505 |
6 | // Multiplies two numbers, throws on overflow./ | function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
require(c / a == b);
return c;
}
| function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
require(c / a == b);
return c;
}
| 8,831 |
45 | // SBTC Token | i = 2;
| i = 2;
| 79,901 |
82 | // Internal function to batch mint amounts of tokens with the given IDs to The address that will own the minted token ids IDs of the tokens to be minted values Amounts of the tokens to be minted data Data forwarded to `onERC1155Received` if `to` is a contract receiver / | function _batchMint(
address to,
uint256[] memory ids,
uint256[] memory values,
bytes memory data
| function _batchMint(
address to,
uint256[] memory ids,
uint256[] memory values,
bytes memory data
| 79,723 |
66 | // Sets the finalization block number delta in the contract. | /// See also {finalizationBlockNumberDelta}.
/// @param finalizationBlockNumberDelta_ The new finalization block number delta.
function setFinalizationBlockNumberDelta(uint256 finalizationBlockNumberDelta_)
external
onlyRole(ORACLE_MANAGER_ROLE)
{
if (
finalizationBlockNumberDelta_ == 0
|| finalizationBlockNumberDelta_ > _FINALIZATION_BLOCK_NUMBER_DELTA_UPPER_BOUND
) {
revert InvalidConfiguration();
}
finalizationBlockNumberDelta = finalizationBlockNumberDelta_;
emit ProtocolConfigChanged(
this.setFinalizationBlockNumberDelta.selector,
"setFinalizationBlockNumberDelta(uint256)",
abi.encode(finalizationBlockNumberDelta_)
);
}
| /// See also {finalizationBlockNumberDelta}.
/// @param finalizationBlockNumberDelta_ The new finalization block number delta.
function setFinalizationBlockNumberDelta(uint256 finalizationBlockNumberDelta_)
external
onlyRole(ORACLE_MANAGER_ROLE)
{
if (
finalizationBlockNumberDelta_ == 0
|| finalizationBlockNumberDelta_ > _FINALIZATION_BLOCK_NUMBER_DELTA_UPPER_BOUND
) {
revert InvalidConfiguration();
}
finalizationBlockNumberDelta = finalizationBlockNumberDelta_;
emit ProtocolConfigChanged(
this.setFinalizationBlockNumberDelta.selector,
"setFinalizationBlockNumberDelta(uint256)",
abi.encode(finalizationBlockNumberDelta_)
);
}
| 35,595 |
76 | // Presale constants | uint256 public constant PRESALE_DURATION = 14 days; // pressale duration
uint256 public constant PRESALE_MIN_CONTRIBUTION = 200 ether; // pressale min contribution
| uint256 public constant PRESALE_DURATION = 14 days; // pressale duration
uint256 public constant PRESALE_MIN_CONTRIBUTION = 200 ether; // pressale min contribution
| 40,635 |
56 | // 1531699200 - July, 16, 2018 00:00:00 && 1532563199 - July, 25, 2018 23:59:59 | if( 1531699200 <= _currentDate && _currentDate <= 1532563199){
return 2;
}
| if( 1531699200 <= _currentDate && _currentDate <= 1532563199){
return 2;
}
| 40,985 |
22 | // Transfers StableToken from one address to another on behalf of a user. from The address to transfer StableToken from. to The address to transfer StableToken to. value The amount of StableToken to transfer.return True if the transaction succeeds. / | function transferFrom(address from, address to, uint256 value)
external
updateInflationFactor
onlyWhenNotFrozen
returns (bool)
| function transferFrom(address from, address to, uint256 value)
external
updateInflationFactor
onlyWhenNotFrozen
returns (bool)
| 8,711 |
8 | // We don't use abi.decode for this because of the large amount of zero-padding bytes the circuit would also have to hash. |
deposit.depositType = data.toUint8Unsafe(_offset);
_offset += 1;
deposit.to = data.toAddressUnsafe(_offset);
_offset += 20;
deposit.toAccountID = data.toUint32Unsafe(_offset);
_offset += 4;
deposit.tokenID = data.toUint32Unsafe(_offset);
_offset += 4;
deposit.amount = data.toUint248Unsafe(_offset);
|
deposit.depositType = data.toUint8Unsafe(_offset);
_offset += 1;
deposit.to = data.toAddressUnsafe(_offset);
_offset += 20;
deposit.toAccountID = data.toUint32Unsafe(_offset);
_offset += 4;
deposit.tokenID = data.toUint32Unsafe(_offset);
_offset += 4;
deposit.amount = data.toUint248Unsafe(_offset);
| 27,568 |
26 | // Returns an address stored in an arbitrary storage slot./ These storage slots decouple the storage layout from/ solc's automation./_slot The storage slot to retrieve the address from. | function _getAddress(bytes32 _slot) internal view returns (address addr_) {
assembly {
addr_ := sload(_slot)
}
}
| function _getAddress(bytes32 _slot) internal view returns (address addr_) {
assembly {
addr_ := sload(_slot)
}
}
| 41,088 |
14 | // voto no período de tempo aceitável | require(!participations[_id_poll].participants[msg.sender]);// usuário não votou/apostou
VoteStorage storage vote_storage = votes[_id_poll];
uint idx = vote_storage.n_votes;
| require(!participations[_id_poll].participants[msg.sender]);// usuário não votou/apostou
VoteStorage storage vote_storage = votes[_id_poll];
uint idx = vote_storage.n_votes;
| 30,918 |
2 | // The expected owner of adopted animal is this contract | address expectedAnimalAdopter = address(this);
| address expectedAnimalAdopter = address(this);
| 17,831 |
85 | // Add amount to a kitties donation limit | kitties[_kittyId].donationAmount = SafeMath.add(kitties[_kittyId].donationAmount, totalAmount);
emit NewDonation(
id,
_kittyId,
_trustAmount,
_fosterAmount,
totalAmount
);
| kitties[_kittyId].donationAmount = SafeMath.add(kitties[_kittyId].donationAmount, totalAmount);
emit NewDonation(
id,
_kittyId,
_trustAmount,
_fosterAmount,
totalAmount
);
| 51,124 |
24 | // Based on the solidity docs for common patterns: https:solidity.readthedocs.io/en/v0.5.0/common-patterns.html?highlight=seller | contract Owned {
/**
* Constructor
* Sets the message sender as the seller
*/
constructor() public { seller = msg.sender; }
bool public contractRetracted = false;
uint public creationTime = now;
address payable public seller;
address payable public buyer;
address public intermediator;
bool public contractIsClosed = false;
/**
* Disown
* Disown current seller
* Prerequisite: Seller and contractRetracted == false
*/
function disown()
public
onlyBy(seller)
contractIsRetracted(false)
{
delete seller;
}
/**
* Change Seller
* Prerequisite: Seller and contractRetracted == false
*/
function changeSeller(address payable _newSeller)
public
onlyBy(seller)
contractIsRetracted(false)
{
seller = _newSeller;
}
/**
* Getter
* returns { boolean } if contract is retracted
*/
function getContractRetracted()
public
view
returns (bool)
{
return contractRetracted;
}
/**
* Getter
* returns { boolean } if contract is closed
*/
function getIsContractClosed()
public
view
returns (bool)
{
return contractIsClosed;
}
/**
* Getter
* returns { address } of seller
*/
function getSeller()
public
view
returns (address)
{
return seller;
}
/**
* Getter
* returns { address } of buyer
*/
function getBuyer()
public
view
returns (address)
{
return buyer;
}
/**
* Getter
* returns { address } of intermediator
*/
function getIntermediator()
public
view
returns (address)
{
return intermediator;
}
/**
* Getter
* returns { uint } creationTime
*/
function getCreationTime()
public
view
returns (uint)
{
return creationTime;
}
/**
* Modifier
* Only _account is qualified to access function
*/
modifier onlyBy(address _account)
{
require(
msg.sender == _account,
"Sender is not the allowed to perform this action."
);
_;
}
/**
* Modifier
* Only _account is qualified to access function
*/
modifier onlyBySellerOrBuyer()
{
require(
(msg.sender == seller) || (msg.sender == buyer),
"Sender must be seller or buyer of the contract"
);
_;
}
/**
* Modifier
* Only after _time can the function be executed
*/
modifier onlyAfter(uint _time) {
require(
now >= _time,
"The function is called too early."
);
_;
}
/**
* Modifier
* Check if contract is intact
*/
modifier contractIntact() {
require(
contractIsClosed == false,
"The contract is closed."
);
_;
}
/**
* Modifier
* Check if msg.sender is member of the contract
*/
modifier onlyMemberOfContract() {
require(
msg.sender == seller ||
msg.sender == buyer ||
msg.sender == intermediator,
"Only members of contract can call this function"
);
_;
}
/**
* Modifier
* Check if contract is retracted
*/
modifier contractIsRetracted(bool retracted) {
require(
contractRetracted == retracted,
"Contract does not satisfy the retraction precondition"
);
_;
}
}
| contract Owned {
/**
* Constructor
* Sets the message sender as the seller
*/
constructor() public { seller = msg.sender; }
bool public contractRetracted = false;
uint public creationTime = now;
address payable public seller;
address payable public buyer;
address public intermediator;
bool public contractIsClosed = false;
/**
* Disown
* Disown current seller
* Prerequisite: Seller and contractRetracted == false
*/
function disown()
public
onlyBy(seller)
contractIsRetracted(false)
{
delete seller;
}
/**
* Change Seller
* Prerequisite: Seller and contractRetracted == false
*/
function changeSeller(address payable _newSeller)
public
onlyBy(seller)
contractIsRetracted(false)
{
seller = _newSeller;
}
/**
* Getter
* returns { boolean } if contract is retracted
*/
function getContractRetracted()
public
view
returns (bool)
{
return contractRetracted;
}
/**
* Getter
* returns { boolean } if contract is closed
*/
function getIsContractClosed()
public
view
returns (bool)
{
return contractIsClosed;
}
/**
* Getter
* returns { address } of seller
*/
function getSeller()
public
view
returns (address)
{
return seller;
}
/**
* Getter
* returns { address } of buyer
*/
function getBuyer()
public
view
returns (address)
{
return buyer;
}
/**
* Getter
* returns { address } of intermediator
*/
function getIntermediator()
public
view
returns (address)
{
return intermediator;
}
/**
* Getter
* returns { uint } creationTime
*/
function getCreationTime()
public
view
returns (uint)
{
return creationTime;
}
/**
* Modifier
* Only _account is qualified to access function
*/
modifier onlyBy(address _account)
{
require(
msg.sender == _account,
"Sender is not the allowed to perform this action."
);
_;
}
/**
* Modifier
* Only _account is qualified to access function
*/
modifier onlyBySellerOrBuyer()
{
require(
(msg.sender == seller) || (msg.sender == buyer),
"Sender must be seller or buyer of the contract"
);
_;
}
/**
* Modifier
* Only after _time can the function be executed
*/
modifier onlyAfter(uint _time) {
require(
now >= _time,
"The function is called too early."
);
_;
}
/**
* Modifier
* Check if contract is intact
*/
modifier contractIntact() {
require(
contractIsClosed == false,
"The contract is closed."
);
_;
}
/**
* Modifier
* Check if msg.sender is member of the contract
*/
modifier onlyMemberOfContract() {
require(
msg.sender == seller ||
msg.sender == buyer ||
msg.sender == intermediator,
"Only members of contract can call this function"
);
_;
}
/**
* Modifier
* Check if contract is retracted
*/
modifier contractIsRetracted(bool retracted) {
require(
contractRetracted == retracted,
"Contract does not satisfy the retraction precondition"
);
_;
}
}
| 41,279 |
86 | // We emit ModifiedHoldings later |
_minterest(investor);
|
_minterest(investor);
| 7,529 |
11 | // calculate price based on affiliate usage and mint discounts | function computePrice(
uint256 price,
Discount storage discounts,
uint256 numTokens,
bool affiliateUsed
| function computePrice(
uint256 price,
Discount storage discounts,
uint256 numTokens,
bool affiliateUsed
| 19,796 |
199 | // adding seperate function setupContractId since initialize is already called with old implementation | function setupContractId()
external
only(DEFAULT_ADMIN_ROLE)
| function setupContractId()
external
only(DEFAULT_ADMIN_ROLE)
| 42,184 |
6 | // Sets a new series of stages, overwriting any existing stages and cancelling any stages after the last new stage.registrant the address of the registrant the schedule is managed by scheduleId the id of the schedule to update the stages for firstStageIndex the index from which to update stages stages array of new stages to add to / overwrite existing stages minPhaseLimit the minimum phaseLimit for the new stages e.g. current supply of the token the schedule is for maxPhaseLimit the maximum phaseLimit for the new stages e.g. maximum supply of the token the schedule is for / | function setStages(
| function setStages(
| 28,495 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.