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 |
|---|---|---|---|---|
13 | // Transfer all tokens to company address | balances[companyAddress] = totalSupply;
emit Transfer(address(0), companyAddress, totalSupply);
| balances[companyAddress] = totalSupply;
emit Transfer(address(0), companyAddress, totalSupply);
| 43,913 |
2 | // the native address to deposit and withdraw from in the swap methods this address cannot be updated after it is set during constructor / | address payable public immutable wNative;
| address payable public immutable wNative;
| 5,206 |
120 | // validate that the appropriate offerAmount was deducted surplusAssetId == offerAssetId | if (_assetIds[2] == _assetIds[0]) {
| if (_assetIds[2] == _assetIds[0]) {
| 42,997 |
50 | // The last accrued index | uint public globalAccruedIndex;
| uint public globalAccruedIndex;
| 51,629 |
102 | // Get whitelist status of an address | function getWhiteList(address _address) public view returns(bool) {
return whiteList[_address];
}
| function getWhiteList(address _address) public view returns(bool) {
return whiteList[_address];
}
| 51,432 |
30 | // function that is called when transaction target is an address | function transferToAddress(address _to, uint256 _value, bytes _data) private returns (bool success) {
require(balanceOf(msg.sender) >= _value);
balances[msg.sender] = balanceOf(msg.sender).sub(_value);
balances[_to] = balanceOf(_to).add(_value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
| function transferToAddress(address _to, uint256 _value, bytes _data) private returns (bool success) {
require(balanceOf(msg.sender) >= _value);
balances[msg.sender] = balanceOf(msg.sender).sub(_value);
balances[_to] = balanceOf(_to).add(_value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
| 16,079 |
39 | // Standard EIP-20 token with an interface marker.Interface marker is used by crowdsale contracts to validate that addresses point a good token contract./ | contract StandardTokenExt is StandardToken {
/* Interface declaration */
function isToken() public constant returns (bool weAre) {
return true;
}
}
| contract StandardTokenExt is StandardToken {
/* Interface declaration */
function isToken() public constant returns (bool weAre) {
return true;
}
}
| 3,620 |
0 | // Wrapper function preparing balancer flashloan andloading data to pass into receiver. / | function _executeBalancerFlashLoan(
uint256 _nftId,
uint256 _amount,
uint256 _initialAmount,
uint256 _lendingShares,
uint256 _borrowShares,
uint256 _minAmountOut,
bool _ethBack
)
internal
| function _executeBalancerFlashLoan(
uint256 _nftId,
uint256 _amount,
uint256 _initialAmount,
uint256 _lendingShares,
uint256 _borrowShares,
uint256 _minAmountOut,
bool _ethBack
)
internal
| 31,102 |
30 | // Set success to whether the call reverted, if not we check it either returned exactly 1 (can't just be non-zero data), or had no return data. | or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
| or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
| 2,849 |
29 | // Returns votes given by specified userto the list of projects ever voted by that usergiver user's addressreturn projects array of project codes represented by bytes32 arrayreturn kudos array of votes given by user,index of vote corresponds to index of project from projects array / | function getKudosPerProject(address giver) constant returns (bytes32[] projects, uint[] kudos) {
UserIndex idx = usersIndex[giver];
projects = idx.projects;
kudos = idx.kudos;
}
| function getKudosPerProject(address giver) constant returns (bytes32[] projects, uint[] kudos) {
UserIndex idx = usersIndex[giver];
projects = idx.projects;
kudos = idx.kudos;
}
| 31,041 |
221 | // k:tokenId, v:token hash array | mapping(uint256 => string []) tokenLogsMap;
string [] logsArray;
| mapping(uint256 => string []) tokenLogsMap;
string [] logsArray;
| 26,522 |
13 | // make sure user has enough balance | require(_shares[account] >= shares, "insufficient balance");
| require(_shares[account] >= shares, "insufficient balance");
| 44,005 |
10 | // Settle long and/or short tokens in for collateral at a rate informed by the contract settlement. Uses financialProductLibrary to compute the redemption rate between long and short tokens. This contract must have the `Burner` role for the `longToken` and `shortToken` in order to call `burnFrom`. The caller does not need to approve this contract to transfer any amount of `tokensToRedeem` since longand short tokens are burned, rather than transferred, from the caller. longTokensToRedeem number of long tokens to settle. shortTokensToRedeem number of short tokens to settle.return collateralReturned total collateral returned in exchange for the pair of synthetics. / | function settle(uint256 longTokensToRedeem, uint256 shortTokensToRedeem)
public
postExpiration()
nonReentrant()
returns (uint256 collateralReturned)
| function settle(uint256 longTokensToRedeem, uint256 shortTokensToRedeem)
public
postExpiration()
nonReentrant()
returns (uint256 collateralReturned)
| 22,577 |
12 | // target token addresses | address[] to;
| address[] to;
| 45,614 |
1 | // actions that build up this strategy (vault) | address[] public actions;
| address[] public actions;
| 56,136 |
15 | // defer lock cost to another user | uint256 callIncentive = ((_amount * lockIncentive) / FEE_DENOMINATOR);
_amount = _amount - callIncentive;
| uint256 callIncentive = ((_amount * lockIncentive) / FEE_DENOMINATOR);
_amount = _amount - callIncentive;
| 11,557 |
272 | // Check if certain token id is exists. / | function exists(uint256 _tokenId) public view returns (bool) {
return _exists(_tokenId);
}
| function exists(uint256 _tokenId) public view returns (bool) {
return _exists(_tokenId);
}
| 37,360 |
3 | // OWNER FUNCTIONS | function setPaused(bool _state) external onlyOwner {
if (_state) {
_pause();
} else {
_unpause();
}
}
| function setPaused(bool _state) external onlyOwner {
if (_state) {
_pause();
} else {
_unpause();
}
}
| 76,227 |
3 | // Emitted when the tokens are swapped. _underlying name of the underlying asset. _strikeAsset name of the strike asset. _inputTokens amount of input tokens. _swappedTokens amount of swapped tokens. / | event Swapped(
| event Swapped(
| 44,528 |
145 | // 指定したアドレスをホワイトリストから削除 <Ownerのみ実行可能> | * @param addr {address} - 削除するアカウント
* @return {bool} 削除に成功したら true を返す
*/
function removeApprovedAddress(address addr) auth public returns (bool) {
sharedStorage.removeApprovedAddress(addr);
RemoveApprovedAddress(msg.sender, addr);
return true;
}
| * @param addr {address} - 削除するアカウント
* @return {bool} 削除に成功したら true を返す
*/
function removeApprovedAddress(address addr) auth public returns (bool) {
sharedStorage.removeApprovedAddress(addr);
RemoveApprovedAddress(msg.sender, addr);
return true;
}
| 4,672 |
192 | // Price and maximum number of Verbs | uint256 public price = 20000000000000000;
uint256 public mint_limit= 30;
| uint256 public price = 20000000000000000;
uint256 public mint_limit= 30;
| 45,156 |
60 | // read methods of int<bits>[size][size] | function getInt128FixedMatrixValue() public view returns (int128[3][2] memory) {
return int128FixedMatrixValue;
}
| function getInt128FixedMatrixValue() public view returns (int128[3][2] memory) {
return int128FixedMatrixValue;
}
| 5,532 |
6 | // 2. Check bank pause condition | require(!Pausable(betaBank).paused(), 'BetaBank/paused');
| require(!Pausable(betaBank).paused(), 'BetaBank/paused');
| 31,059 |
41 | // Transfer tokens from one address to another _from address The address which you want to send tokens from _to address The address which you want to transfer to _value uint256 the amout of tokens to be transfered / | function transferFrom(address _from, address _to, uint _value) whenNotPaused canTransfer returns (bool) {
require(_to != address(this) && _to != address(0));
return super.transferFrom(_from, _to, _value);
}
| function transferFrom(address _from, address _to, uint _value) whenNotPaused canTransfer returns (bool) {
require(_to != address(this) && _to != address(0));
return super.transferFrom(_from, _to, _value);
}
| 31,604 |
47 | // in percentage, 100% = 10000; 1% = 100; 0.1% = 10 | uint256 public taxTeamPercent = 400;
uint256 public taxTreasuryPercent = 100;
uint256 public taxLPPercent = 200;
uint256 public liquidityFee = 700; // Team + Treasury + LP
uint256 private _previousLiquidityFee = liquidityFee;
uint256 public maxTxAmount = 100 * 10**6 * 10**_decimals;
uint256 public minimumTokensBeforeSwap = 2 * 10**6 * 10**_decimals;
uint256 public holders = 0;
| uint256 public taxTeamPercent = 400;
uint256 public taxTreasuryPercent = 100;
uint256 public taxLPPercent = 200;
uint256 public liquidityFee = 700; // Team + Treasury + LP
uint256 private _previousLiquidityFee = liquidityFee;
uint256 public maxTxAmount = 100 * 10**6 * 10**_decimals;
uint256 public minimumTokensBeforeSwap = 2 * 10**6 * 10**_decimals;
uint256 public holders = 0;
| 28,749 |
162 | // PaymentSplitter This contract allows to split Ether payments among a group of accounts. The sender does not need to be awarethat the Ether will be split in this way, since it is handled transparently by the contract. The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning eachaccount to a number of shares. Of all the Ether that this contract receives, each account will then be able to claiman amount proportional to the percentage of total shares they were assigned. `PaymentSplitter` follows a _pull payment_ model. This means that | * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release}
* function.
*
* NOTE: This contract assumes that ERC20 tokens will behave similarly to native tokens (Ether). Rebasing tokens, and
* tokens that apply fees during transfers, are likely to not be supported as expected. If in doubt, we encourage you
* to run tests before sending real value to this contract.
*/
contract PaymentSplitter is Context {
event PayeeAdded(address account, uint256 shares);
event PaymentReleased(address to, uint256 amount);
event ERC20PaymentReleased(
IERC20 indexed token,
address to,
uint256 amount
);
event PaymentReceived(address from, uint256 amount);
uint256 private _totalShares;
uint256 private _totalReleased;
mapping(address => uint256) private _shares;
mapping(address => uint256) private _released;
address[] private _payees;
mapping(IERC20 => uint256) private _erc20TotalReleased;
mapping(IERC20 => mapping(address => uint256)) private _erc20Released;
/**
* @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at
* the matching position in the `shares` array.
*
* All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no
* duplicates in `payees`.
*/
constructor(address[] memory payees, uint256[] memory shares_) payable {
require(
payees.length == shares_.length,
"PaymentSplitter: payees and shares length mismatch"
);
require(payees.length > 0, "PaymentSplitter: no payees");
for (uint256 i = 0; i < payees.length; i++) {
_addPayee(payees[i], shares_[i]);
}
}
/**
* @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully
* reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the
* reliability of the events, and not the actual splitting of Ether.
*
* To learn more about this see the Solidity documentation for
* https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback
* functions].
*/
receive() external payable virtual {
emit PaymentReceived(_msgSender(), msg.value);
}
/**
* @dev Getter for the total shares held by payees.
*/
function totalShares() public view returns (uint256) {
return _totalShares;
}
/**
* @dev Getter for the total amount of Ether already released.
*/
function totalReleased() public view returns (uint256) {
return _totalReleased;
}
/**
* @dev Getter for the total amount of `token` already released. `token` should be the address of an IERC20
* contract.
*/
function totalReleased(IERC20 token) public view returns (uint256) {
return _erc20TotalReleased[token];
}
/**
* @dev Getter for the amount of shares held by an account.
*/
function shares(address account) public view returns (uint256) {
return _shares[account];
}
/**
* @dev Getter for the amount of Ether already released to a payee.
*/
function released(address account) public view returns (uint256) {
return _released[account];
}
/**
* @dev Getter for the amount of `token` tokens already released to a payee. `token` should be the address of an
* IERC20 contract.
*/
function released(IERC20 token, address account)
public
view
returns (uint256)
{
return _erc20Released[token][account];
}
/**
* @dev Getter for the address of the payee number `index`.
*/
function payee(uint256 index) public view returns (address) {
return _payees[index];
}
/**
* @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the
* total shares and their previous withdrawals.
*/
function release(address payable account) public virtual {
require(_shares[account] > 0, "PaymentSplitter: account has no shares");
uint256 totalReceived = address(this).balance + totalReleased();
uint256 payment = _pendingPayment(
account,
totalReceived,
released(account)
);
require(payment != 0, "PaymentSplitter: account is not due payment");
_released[account] += payment;
_totalReleased += payment;
Address.sendValue(account, payment);
emit PaymentReleased(account, payment);
}
/**
* @dev Triggers a transfer to `account` of the amount of `token` tokens they are owed, according to their
* percentage of the total shares and their previous withdrawals. `token` must be the address of an IERC20
* contract.
*/
function release(IERC20 token, address account) public virtual {
require(_shares[account] > 0, "PaymentSplitter: account has no shares");
uint256 totalReceived = token.balanceOf(address(this)) +
totalReleased(token);
uint256 payment = _pendingPayment(
account,
totalReceived,
released(token, account)
);
require(payment != 0, "PaymentSplitter: account is not due payment");
_erc20Released[token][account] += payment;
_erc20TotalReleased[token] += payment;
SafeERC20.safeTransfer(token, account, payment);
emit ERC20PaymentReleased(token, account, payment);
}
/**
* @dev internal logic for computing the pending payment of an `account` given the token historical balances and
* already released amounts.
*/
function _pendingPayment(
address account,
uint256 totalReceived,
uint256 alreadyReleased
) private view returns (uint256) {
return
(totalReceived * _shares[account]) / _totalShares - alreadyReleased;
}
/**
* @dev Add a new payee to the contract.
* @param account The address of the payee to add.
* @param shares_ The number of shares owned by the payee.
*/
function _addPayee(address account, uint256 shares_) private {
require(
account != address(0),
"PaymentSplitter: account is the zero address"
);
require(shares_ > 0, "PaymentSplitter: shares are 0");
require(
_shares[account] == 0,
"PaymentSplitter: account already has shares"
);
_payees.push(account);
_shares[account] = shares_;
_totalShares = _totalShares + shares_;
emit PayeeAdded(account, shares_);
}
}
| * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release}
* function.
*
* NOTE: This contract assumes that ERC20 tokens will behave similarly to native tokens (Ether). Rebasing tokens, and
* tokens that apply fees during transfers, are likely to not be supported as expected. If in doubt, we encourage you
* to run tests before sending real value to this contract.
*/
contract PaymentSplitter is Context {
event PayeeAdded(address account, uint256 shares);
event PaymentReleased(address to, uint256 amount);
event ERC20PaymentReleased(
IERC20 indexed token,
address to,
uint256 amount
);
event PaymentReceived(address from, uint256 amount);
uint256 private _totalShares;
uint256 private _totalReleased;
mapping(address => uint256) private _shares;
mapping(address => uint256) private _released;
address[] private _payees;
mapping(IERC20 => uint256) private _erc20TotalReleased;
mapping(IERC20 => mapping(address => uint256)) private _erc20Released;
/**
* @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at
* the matching position in the `shares` array.
*
* All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no
* duplicates in `payees`.
*/
constructor(address[] memory payees, uint256[] memory shares_) payable {
require(
payees.length == shares_.length,
"PaymentSplitter: payees and shares length mismatch"
);
require(payees.length > 0, "PaymentSplitter: no payees");
for (uint256 i = 0; i < payees.length; i++) {
_addPayee(payees[i], shares_[i]);
}
}
/**
* @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully
* reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the
* reliability of the events, and not the actual splitting of Ether.
*
* To learn more about this see the Solidity documentation for
* https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback
* functions].
*/
receive() external payable virtual {
emit PaymentReceived(_msgSender(), msg.value);
}
/**
* @dev Getter for the total shares held by payees.
*/
function totalShares() public view returns (uint256) {
return _totalShares;
}
/**
* @dev Getter for the total amount of Ether already released.
*/
function totalReleased() public view returns (uint256) {
return _totalReleased;
}
/**
* @dev Getter for the total amount of `token` already released. `token` should be the address of an IERC20
* contract.
*/
function totalReleased(IERC20 token) public view returns (uint256) {
return _erc20TotalReleased[token];
}
/**
* @dev Getter for the amount of shares held by an account.
*/
function shares(address account) public view returns (uint256) {
return _shares[account];
}
/**
* @dev Getter for the amount of Ether already released to a payee.
*/
function released(address account) public view returns (uint256) {
return _released[account];
}
/**
* @dev Getter for the amount of `token` tokens already released to a payee. `token` should be the address of an
* IERC20 contract.
*/
function released(IERC20 token, address account)
public
view
returns (uint256)
{
return _erc20Released[token][account];
}
/**
* @dev Getter for the address of the payee number `index`.
*/
function payee(uint256 index) public view returns (address) {
return _payees[index];
}
/**
* @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the
* total shares and their previous withdrawals.
*/
function release(address payable account) public virtual {
require(_shares[account] > 0, "PaymentSplitter: account has no shares");
uint256 totalReceived = address(this).balance + totalReleased();
uint256 payment = _pendingPayment(
account,
totalReceived,
released(account)
);
require(payment != 0, "PaymentSplitter: account is not due payment");
_released[account] += payment;
_totalReleased += payment;
Address.sendValue(account, payment);
emit PaymentReleased(account, payment);
}
/**
* @dev Triggers a transfer to `account` of the amount of `token` tokens they are owed, according to their
* percentage of the total shares and their previous withdrawals. `token` must be the address of an IERC20
* contract.
*/
function release(IERC20 token, address account) public virtual {
require(_shares[account] > 0, "PaymentSplitter: account has no shares");
uint256 totalReceived = token.balanceOf(address(this)) +
totalReleased(token);
uint256 payment = _pendingPayment(
account,
totalReceived,
released(token, account)
);
require(payment != 0, "PaymentSplitter: account is not due payment");
_erc20Released[token][account] += payment;
_erc20TotalReleased[token] += payment;
SafeERC20.safeTransfer(token, account, payment);
emit ERC20PaymentReleased(token, account, payment);
}
/**
* @dev internal logic for computing the pending payment of an `account` given the token historical balances and
* already released amounts.
*/
function _pendingPayment(
address account,
uint256 totalReceived,
uint256 alreadyReleased
) private view returns (uint256) {
return
(totalReceived * _shares[account]) / _totalShares - alreadyReleased;
}
/**
* @dev Add a new payee to the contract.
* @param account The address of the payee to add.
* @param shares_ The number of shares owned by the payee.
*/
function _addPayee(address account, uint256 shares_) private {
require(
account != address(0),
"PaymentSplitter: account is the zero address"
);
require(shares_ > 0, "PaymentSplitter: shares are 0");
require(
_shares[account] == 0,
"PaymentSplitter: account already has shares"
);
_payees.push(account);
_shares[account] = shares_;
_totalShares = _totalShares + shares_;
emit PayeeAdded(account, shares_);
}
}
| 34,888 |
13 | // New deals must request opposite position tokens | require(
_buyOrder.takerTokenId == longTokenId,
"MATCH:DERIVATIVE_NOT_MATCH"
);
| require(
_buyOrder.takerTokenId == longTokenId,
"MATCH:DERIVATIVE_NOT_MATCH"
);
| 21,151 |
114 | // These functions deal with verification of Merkle Trees proofs. The proofs can be generated using the JavaScript library Note: the hashing algorithm should be keccak256 and pair sorting should be enabled. WARNING: You should avoid using leaf values that are 64 bytes long prior to hashing, or use a hash function other than keccak256 for hashing leaves. This is because the concatenation of a sorted pair of internal nodes in the merkle tree could be reinterpreted as a leaf value./ | library MerkleProof {
/**
* @dev Returns true if a 'leaf' can be proved to be a part of a Merkle tree
* defined by 'root'. For this, a 'proof' must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*/
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from 'leaf' using 'proof'. A 'proof' is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leafs & pre-images are assumed to be sorted.
*
* _Available since v4.4._
*/
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
bytes32 proofElement = proof[i];
if (computedHash <= proofElement) {
// Hash(current computed hash + current element of the proof)
computedHash = _efficientHash(computedHash, proofElement);
} else {
// Hash(current element of the proof + current computed hash)
computedHash = _efficientHash(proofElement, computedHash);
}
}
return computedHash;
}
function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
assembly {
mstore(0x00, a)
mstore(0x20, b)
value := keccak256(0x00, 0x40)
}
}
}
| library MerkleProof {
/**
* @dev Returns true if a 'leaf' can be proved to be a part of a Merkle tree
* defined by 'root'. For this, a 'proof' must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*/
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from 'leaf' using 'proof'. A 'proof' is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leafs & pre-images are assumed to be sorted.
*
* _Available since v4.4._
*/
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
bytes32 proofElement = proof[i];
if (computedHash <= proofElement) {
// Hash(current computed hash + current element of the proof)
computedHash = _efficientHash(computedHash, proofElement);
} else {
// Hash(current element of the proof + current computed hash)
computedHash = _efficientHash(proofElement, computedHash);
}
}
return computedHash;
}
function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
assembly {
mstore(0x00, a)
mstore(0x20, b)
value := keccak256(0x00, 0x40)
}
}
}
| 17,554 |
4 | // Overflow if y == 0 Overflow if (xWAD + y / 2) > type(uint256).max <=> xWAD > type(uint256).max - y / 2 <=> x > (type(uint256).max - y / 2) / WAD | assembly {
z := div(y, 2)
if iszero(mul(y, iszero(gt(x, div(sub(MAX_UINT256, z), WAD))))) {
revert(0, 0)
}
| assembly {
z := div(y, 2)
if iszero(mul(y, iszero(gt(x, div(sub(MAX_UINT256, z), WAD))))) {
revert(0, 0)
}
| 28,612 |
49 | // Document Management | function getDocument(bytes32 name) external view returns (string memory, bytes32);
function setDocument(bytes32 name, string calldata uri, bytes32 documentHash) external;
| function getDocument(bytes32 name) external view returns (string memory, bytes32);
function setDocument(bytes32 name, string calldata uri, bytes32 documentHash) external;
| 40,976 |
4 | // Get Prices | function getEthToTokenInputPrice(uint256 eth_sold) external view returns (uint256 tokens_bought);
function getEthToTokenOutputPrice(uint256 tokens_bought) external view returns (uint256 eth_sold);
function getTokenToEthInputPrice(uint256 tokens_sold) external view returns (uint256 eth_bought);
function getTokenToEthOutputPrice(uint256 eth_bought) external view returns (uint256 tokens_sold);
| function getEthToTokenInputPrice(uint256 eth_sold) external view returns (uint256 tokens_bought);
function getEthToTokenOutputPrice(uint256 tokens_bought) external view returns (uint256 eth_sold);
function getTokenToEthInputPrice(uint256 tokens_sold) external view returns (uint256 eth_bought);
function getTokenToEthOutputPrice(uint256 eth_bought) external view returns (uint256 tokens_sold);
| 1,941 |
80 | // Get the way we will trade it | function getTradePath(address tokenaddress) internal view returns (address[] memory) {
address[] memory path = new address[](2);
path[0] = tokenaddress;
path[1] = WETH;
return path;
}
| function getTradePath(address tokenaddress) internal view returns (address[] memory) {
address[] memory path = new address[](2);
path[0] = tokenaddress;
path[1] = WETH;
return path;
}
| 39,479 |
10 | // no on-chain action on resolution, default bylaw with voting initative | None,
| None,
| 37,147 |
241 | // Retrieve the tax rate | if (_poolInformation[_pid].hasTax) {
uint256 taxOverflow =
_calculateTaxOverflow(
_poolInformation[_pid].totalAmountPool,
_poolInformation[_pid].raisingAmountPool
);
| if (_poolInformation[_pid].hasTax) {
uint256 taxOverflow =
_calculateTaxOverflow(
_poolInformation[_pid].totalAmountPool,
_poolInformation[_pid].raisingAmountPool
);
| 21,433 |
145 | // INestGovernance implementation contract address | address public _governance;
| address public _governance;
| 14,437 |
36 | // Update boneLocker address by the owner. | function boneLockerUpdate(address _boneLocker) public onlyOwner {
boneLocker = BoneLocker(_boneLocker);
}
| function boneLockerUpdate(address _boneLocker) public onlyOwner {
boneLocker = BoneLocker(_boneLocker);
}
| 70,340 |
7 | // Hash key fields of the sport event to get a unique id | bytes32 eventId = keccak256(abi.encodePacked(_name, _participantCount, _date));
| bytes32 eventId = keccak256(abi.encodePacked(_name, _participantCount, _date));
| 12,606 |
54 | // Returns the address is excluded from antiWhale or not./ | function isExcludedFromAntiWhale(address _account) public view returns (bool) {
return _excludedFromAntiWhale[_account];
}
| function isExcludedFromAntiWhale(address _account) public view returns (bool) {
return _excludedFromAntiWhale[_account];
}
| 35,226 |
8 | // 正常 | Normal,
| Normal,
| 10,543 |
113 | // sender transfers 99% of the BOOB | return super.transfer(recipient, amount.sub(ectoAmount));
| return super.transfer(recipient, amount.sub(ectoAmount));
| 8,199 |
156 | // BaseTransfer Module containing internal methods to execute or approve transfers Olivier VDB - <olivier@argent.xyz> / | contract BaseTransfer is BaseModule {
// Mock token address for ETH
address constant internal ETH_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
// *************** Events *************************** //
event Transfer(address indexed wallet, address indexed token, uint256 indexed amount, address to, bytes data);
event Approved(address indexed wallet, address indexed token, uint256 amount, address spender);
event CalledContract(address indexed wallet, address indexed to, uint256 amount, bytes data);
event ApprovedAndCalledContract(
address indexed wallet,
address indexed to,
address spender,
address indexed token,
uint256 amountApproved,
uint256 amountSpent,
bytes data
);
// *************** Internal Functions ********************* //
/**
* @dev Helper method to transfer ETH or ERC20 for a wallet.
* @param _wallet The target wallet.
* @param _token The ERC20 address.
* @param _to The recipient.
* @param _value The amount of ETH to transfer
* @param _data The data to *log* with the transfer.
*/
function doTransfer(BaseWallet _wallet, address _token, address _to, uint256 _value, bytes memory _data) internal {
if (_token == ETH_TOKEN) {
invokeWallet(address(_wallet), _to, _value, EMPTY_BYTES);
} else {
bytes memory methodData = abi.encodeWithSignature("transfer(address,uint256)", _to, _value);
invokeWallet(address(_wallet), _token, 0, methodData);
}
emit Transfer(address(_wallet), _token, _value, _to, _data);
}
/**
* @dev Helper method to approve spending the ERC20 of a wallet.
* @param _wallet The target wallet.
* @param _token The ERC20 address.
* @param _spender The spender address.
* @param _value The amount of token to transfer.
*/
function doApproveToken(BaseWallet _wallet, address _token, address _spender, uint256 _value) internal {
bytes memory methodData = abi.encodeWithSignature("approve(address,uint256)", _spender, _value);
invokeWallet(address(_wallet), _token, 0, methodData);
emit Approved(address(_wallet), _token, _value, _spender);
}
/**
* @dev Helper method to call an external contract.
* @param _wallet The target wallet.
* @param _contract The contract address.
* @param _value The ETH value to transfer.
* @param _data The method data.
*/
function doCallContract(BaseWallet _wallet, address _contract, uint256 _value, bytes memory _data) internal {
invokeWallet(address(_wallet), _contract, _value, _data);
emit CalledContract(address(_wallet), _contract, _value, _data);
}
/**
* @dev Helper method to approve a certain amount of token and call an external contract.
* The address that spends the _token and the address that is called with _data can be different.
* @param _wallet The target wallet.
* @param _token The ERC20 address.
* @param _spender The spender address.
* @param _amount The amount of tokens to transfer.
* @param _contract The contract address.
* @param _data The method data.
*/
function doApproveTokenAndCallContract(
BaseWallet _wallet,
address _token,
address _spender,
uint256 _amount,
address _contract,
bytes memory _data
)
internal
{
uint256 existingAllowance = ERC20(_token).allowance(address(_wallet), _spender);
uint256 totalAllowance = SafeMath.add(existingAllowance, _amount);
// Approve the desired amount plus existing amount. This logic allows for potential gas saving later
// when restoring the original approved amount, in cases where the _spender uses the exact approved _amount.
bytes memory methodData = abi.encodeWithSignature("approve(address,uint256)", _spender, totalAllowance);
invokeWallet(address(_wallet), _token, 0, methodData);
invokeWallet(address(_wallet), _contract, 0, _data);
// Calculate the approved amount that was spent after the call
uint256 unusedAllowance = ERC20(_token).allowance(address(_wallet), _spender);
uint256 usedAllowance = SafeMath.sub(totalAllowance, unusedAllowance);
// Ensure the amount spent does not exceed the amount approved for this call
require(usedAllowance <= _amount, "BT: insufficient amount for call");
if (unusedAllowance != existingAllowance) {
// Restore the original allowance amount if the amount spent was different (can be lower).
methodData = abi.encodeWithSignature("approve(address,uint256)", _spender, existingAllowance);
invokeWallet(address(_wallet), _token, 0, methodData);
}
emit ApprovedAndCalledContract(
address(_wallet),
_contract,
_spender,
_token,
_amount,
usedAllowance,
_data);
}
}
| contract BaseTransfer is BaseModule {
// Mock token address for ETH
address constant internal ETH_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
// *************** Events *************************** //
event Transfer(address indexed wallet, address indexed token, uint256 indexed amount, address to, bytes data);
event Approved(address indexed wallet, address indexed token, uint256 amount, address spender);
event CalledContract(address indexed wallet, address indexed to, uint256 amount, bytes data);
event ApprovedAndCalledContract(
address indexed wallet,
address indexed to,
address spender,
address indexed token,
uint256 amountApproved,
uint256 amountSpent,
bytes data
);
// *************** Internal Functions ********************* //
/**
* @dev Helper method to transfer ETH or ERC20 for a wallet.
* @param _wallet The target wallet.
* @param _token The ERC20 address.
* @param _to The recipient.
* @param _value The amount of ETH to transfer
* @param _data The data to *log* with the transfer.
*/
function doTransfer(BaseWallet _wallet, address _token, address _to, uint256 _value, bytes memory _data) internal {
if (_token == ETH_TOKEN) {
invokeWallet(address(_wallet), _to, _value, EMPTY_BYTES);
} else {
bytes memory methodData = abi.encodeWithSignature("transfer(address,uint256)", _to, _value);
invokeWallet(address(_wallet), _token, 0, methodData);
}
emit Transfer(address(_wallet), _token, _value, _to, _data);
}
/**
* @dev Helper method to approve spending the ERC20 of a wallet.
* @param _wallet The target wallet.
* @param _token The ERC20 address.
* @param _spender The spender address.
* @param _value The amount of token to transfer.
*/
function doApproveToken(BaseWallet _wallet, address _token, address _spender, uint256 _value) internal {
bytes memory methodData = abi.encodeWithSignature("approve(address,uint256)", _spender, _value);
invokeWallet(address(_wallet), _token, 0, methodData);
emit Approved(address(_wallet), _token, _value, _spender);
}
/**
* @dev Helper method to call an external contract.
* @param _wallet The target wallet.
* @param _contract The contract address.
* @param _value The ETH value to transfer.
* @param _data The method data.
*/
function doCallContract(BaseWallet _wallet, address _contract, uint256 _value, bytes memory _data) internal {
invokeWallet(address(_wallet), _contract, _value, _data);
emit CalledContract(address(_wallet), _contract, _value, _data);
}
/**
* @dev Helper method to approve a certain amount of token and call an external contract.
* The address that spends the _token and the address that is called with _data can be different.
* @param _wallet The target wallet.
* @param _token The ERC20 address.
* @param _spender The spender address.
* @param _amount The amount of tokens to transfer.
* @param _contract The contract address.
* @param _data The method data.
*/
function doApproveTokenAndCallContract(
BaseWallet _wallet,
address _token,
address _spender,
uint256 _amount,
address _contract,
bytes memory _data
)
internal
{
uint256 existingAllowance = ERC20(_token).allowance(address(_wallet), _spender);
uint256 totalAllowance = SafeMath.add(existingAllowance, _amount);
// Approve the desired amount plus existing amount. This logic allows for potential gas saving later
// when restoring the original approved amount, in cases where the _spender uses the exact approved _amount.
bytes memory methodData = abi.encodeWithSignature("approve(address,uint256)", _spender, totalAllowance);
invokeWallet(address(_wallet), _token, 0, methodData);
invokeWallet(address(_wallet), _contract, 0, _data);
// Calculate the approved amount that was spent after the call
uint256 unusedAllowance = ERC20(_token).allowance(address(_wallet), _spender);
uint256 usedAllowance = SafeMath.sub(totalAllowance, unusedAllowance);
// Ensure the amount spent does not exceed the amount approved for this call
require(usedAllowance <= _amount, "BT: insufficient amount for call");
if (unusedAllowance != existingAllowance) {
// Restore the original allowance amount if the amount spent was different (can be lower).
methodData = abi.encodeWithSignature("approve(address,uint256)", _spender, existingAllowance);
invokeWallet(address(_wallet), _token, 0, methodData);
}
emit ApprovedAndCalledContract(
address(_wallet),
_contract,
_spender,
_token,
_amount,
usedAllowance,
_data);
}
}
| 4,910 |
1 | // Constructor function to set the rewards token and the NFT collection addresses | constructor(IERC721 _nftCollection, IERC20 _rewardsToken) {
nftCollection = _nftCollection;
rewardsToken = _rewardsToken;
}
| constructor(IERC721 _nftCollection, IERC20 _rewardsToken) {
nftCollection = _nftCollection;
rewardsToken = _rewardsToken;
}
| 16,606 |
11 | // Voting token minimum balance to participate | uint public votingMinimum;
| uint public votingMinimum;
| 29,701 |
96 | // If swap is paused, only admins can mint. | require(!paused || admins[msg.sender], "paused");
require(_balances.length == _amounts.length, "invalid amounts");
uint256 A = getA();
uint256 oldD = totalSupply;
uint256 i = 0;
for (i = 0; i < _balances.length; i++) {
if (_amounts[i] == 0) {
| require(!paused || admins[msg.sender], "paused");
require(_balances.length == _amounts.length, "invalid amounts");
uint256 A = getA();
uint256 oldD = totalSupply;
uint256 i = 0;
for (i = 0; i < _balances.length; i++) {
if (_amounts[i] == 0) {
| 41,669 |
17 | // transplant matching |
function transplantmatch(address recipientad) public
|
function transplantmatch(address recipientad) public
| 45,441 |
206 | // price of Nac = ETH/NAC | uint public price = 1;
| uint public price = 1;
| 43,758 |
10 | // return The symbol of the token / | function symbol() external view returns (string) {
return _symbol;
}
| function symbol() external view returns (string) {
return _symbol;
}
| 56 |
84 | // Function to get Big Pay Percentage / | function getBigPayDayPercentage() public view returns(uint256){
return _bigPayDayPercentage;
}
| function getBigPayDayPercentage() public view returns(uint256){
return _bigPayDayPercentage;
}
| 12,842 |
76 | // Otherwise, assign the execution to the executions array. | executions[i - totalFilteredExecutions] = execution;
| executions[i - totalFilteredExecutions] = execution;
| 22,841 |
185 | // For gas savings, we query the existing balance of the input token exactly once, which is why this function needs to return both output AND input | function calculateSwapAmount(ERC20 inputToken, ERC20 outputToken, uint256 totalInputToken) public view returns(uint256 outputAmount, uint256 inputAmount) {
// balancesAndMultipliers checks for tradability
(uint256 x, uint256 y, uint256 M, uint256 N, uint256 weightX, uint256 weightY) = theExchange.balancesAndMultipliers(inputToken, outputToken);
inputAmount = totalInputToken-x;
uint256 b = invariantSwap(x, y, M, N, inputAmount, weightX, weightY);
// trader gets back b-swapFee*b/10000 (swapFee is in basis points)
outputAmount = b-((b*swapFee)/10000);
}
| function calculateSwapAmount(ERC20 inputToken, ERC20 outputToken, uint256 totalInputToken) public view returns(uint256 outputAmount, uint256 inputAmount) {
// balancesAndMultipliers checks for tradability
(uint256 x, uint256 y, uint256 M, uint256 N, uint256 weightX, uint256 weightY) = theExchange.balancesAndMultipliers(inputToken, outputToken);
inputAmount = totalInputToken-x;
uint256 b = invariantSwap(x, y, M, N, inputAmount, weightX, weightY);
// trader gets back b-swapFee*b/10000 (swapFee is in basis points)
outputAmount = b-((b*swapFee)/10000);
}
| 58,898 |
69 | // total principal amount only used to keep a track of the gross deposits. | uint256 public totalGamePrincipal;
| uint256 public totalGamePrincipal;
| 17,870 |
28 | // address of the wallet controlled by the platform that will receive the platform fee | address payable public destinationWallet =
payable(0xEda703919A528481F4F11423a728300dCaBF441F);
| address payable public destinationWallet =
payable(0xEda703919A528481F4F11423a728300dCaBF441F);
| 31,843 |
3 | // no one can stop minting | function finishMinting()
public
returns (bool)
| function finishMinting()
public
returns (bool)
| 38,947 |
57 | // validSignature modifier.signature bytes memory assignedQuantity uint256 / | modifier validSignature(bytes memory signature, uint256 assignedQuantity)
| modifier validSignature(bytes memory signature, uint256 assignedQuantity)
| 83,646 |
20 | // Split the total amount amongst all participants and convert to wei | uint individualAmount = (groupRequest.totalAmount * 1 ether) /
(groupRequest.participants.length + 1);
| uint individualAmount = (groupRequest.totalAmount * 1 ether) /
(groupRequest.participants.length + 1);
| 19,880 |
1 | // The recovered signer must have this role | bytes32 public constant SIGNER_ROLE = keccak256("SIGNER_ROLE");
| bytes32 public constant SIGNER_ROLE = keccak256("SIGNER_ROLE");
| 7,909 |
28 | // Notifies about the discrepancy between legacy KEEP active stake/ and the amount cached in T staking contract. Slashes the staking/ provider in case the amount cached is higher than the actual/ active stake amount in KEEP staking contract. Needs to update/ authorizations of all affected applications and execute an/ involuntary allocation decrease on all affected applications./ Can be called by anyone, notifier receives a reward. | function notifyKeepStakeDiscrepancy(address stakingProvider) external;
| function notifyKeepStakeDiscrepancy(address stakingProvider) external;
| 2,257 |
18 | // string public constant name = "ZUG"; string public constant symbol = "ZUG"; uint8public constant decimals = 18; |
/*///////////////////////////////////////////////////////////////
ERC20 STORAGE
|
/*///////////////////////////////////////////////////////////////
ERC20 STORAGE
| 66,641 |
256 | // Delegator called unbond | if (roundsManager().currentRound() >= del.withdrawRound) {
return DelegatorStatus.Unbonded;
} else {
| if (roundsManager().currentRound() >= del.withdrawRound) {
return DelegatorStatus.Unbonded;
} else {
| 24,744 |
14 | // Current step; / | uint8 public currentStep;
| uint8 public currentStep;
| 23,806 |
14 | // `setNetworkFeeRate`: Sets the `networkFeeRate` if lower than`maxNetworkFeeRate` `from`: Don't change the rate if the current rate is not whatthe caller is changing it `from` `to`: The new rate Requires `to` to be less than or equal to `maxNetworkFeeRate` Emits a `SetNetworkFeeRate` event / | function setNetworkFeeRate(uint16 from, uint16 to) external onlyOwner {
require(
networkFeeRate == from,
"SquadController: network fee compare failed"
);
require(
to <= maxNetworkFeeRate,
"SquadController: cannot set fee higer than max"
);
networkFeeRate = to;
emit SetNetworkFeeRate(from, to);
}
| function setNetworkFeeRate(uint16 from, uint16 to) external onlyOwner {
require(
networkFeeRate == from,
"SquadController: network fee compare failed"
);
require(
to <= maxNetworkFeeRate,
"SquadController: cannot set fee higer than max"
);
networkFeeRate = to;
emit SetNetworkFeeRate(from, to);
}
| 31,970 |
76 | // Only after burn is open can the deposit be claimed | require(
nftProps.status == YAGMIStatus.BURN_OPEN,
"Burn to withdraw not open"
);
uint256 depositAmount = (nftProps.price * nftProps.maxSupply) /
nftProps.ratio;
| require(
nftProps.status == YAGMIStatus.BURN_OPEN,
"Burn to withdraw not open"
);
uint256 depositAmount = (nftProps.price * nftProps.maxSupply) /
nftProps.ratio;
| 26,384 |
1 | // Mapping blacklisted Address | mapping(address => bool) private blacklisted;
| mapping(address => bool) private blacklisted;
| 15,721 |
115 | // The block number when KIMBAP mining ends. | uint256 public endBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
GamjaToken _kimbap,
address _devaddr,
uint256 _kimbapPerBlock,
| uint256 public endBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
GamjaToken _kimbap,
address _devaddr,
uint256 _kimbapPerBlock,
| 4,944 |
134 | // Assign this id to receiver address | lockedToken[_id].withdrawalAddress = _receiverAddress;
depositsByWithdrawalAddress[_receiverAddress].push(_id);
| lockedToken[_id].withdrawalAddress = _receiverAddress;
depositsByWithdrawalAddress[_receiverAddress].push(_id);
| 8,905 |
218 | // Only allows approved admins to call the specified function / | modifier adminRequired() {
require(owner() == msg.sender || _admins.contains(msg.sender), "AdminControl: Must be owner or admin");
_;
}
| modifier adminRequired() {
require(owner() == msg.sender || _admins.contains(msg.sender), "AdminControl: Must be owner or admin");
_;
}
| 23,681 |
38 | // a library for performing overflow-safe math, courtesy of DappHub (https:github.com/dapphub/ds-math) |
library SafeMath {
function add(uint x, uint y) internal pure returns (uint z) {
require((z = x + y) >= x, 'ds-math-add-overflow');
}
|
library SafeMath {
function add(uint x, uint y) internal pure returns (uint z) {
require((z = x + y) >= x, 'ds-math-add-overflow');
}
| 21,241 |
21 | // Long list. | uint256 lenOfListLen = prefix - 0xf7;
require(
_in.length > lenOfListLen,
"RLPReader: length of content must be > than length of list length (long list)"
);
bytes1 firstByteOfContent;
assembly {
firstByteOfContent := and(mload(add(ptr, 1)), shl(248, 0xff))
| uint256 lenOfListLen = prefix - 0xf7;
require(
_in.length > lenOfListLen,
"RLPReader: length of content must be > than length of list length (long list)"
);
bytes1 firstByteOfContent;
assembly {
firstByteOfContent := and(mload(add(ptr, 1)), shl(248, 0xff))
| 18,275 |
88 | // Set admin status. | function setAdminStatus(address _admin, bool _status) external onlyOwner {
isAdmin[_admin] = _status;
}
| function setAdminStatus(address _admin, bool _status) external onlyOwner {
isAdmin[_admin] = _status;
}
| 47,208 |
50 | // Allows anyone to transfer the H20 tokens once trading has started _to the recipient address of the tokens. _value number of tokens to be transfered. / | function transfer(address _to, uint _value) whenNotPaused returns (bool) {
bool result = super.transfer(_to, _value);
update(msg.sender,balances[msg.sender]);
update(_to,balances[_to]);
return result;
}
| function transfer(address _to, uint _value) whenNotPaused returns (bool) {
bool result = super.transfer(_to, _value);
update(msg.sender,balances[msg.sender]);
update(_to,balances[_to]);
return result;
}
| 7,925 |
135 | // Fills an order | function fillOrder(FillOrderArgs memory args) public override returns (uint256 amountOut) {
// solhint-disable-next-line avoid-tx-origin
require(msg.sender == tx.origin, "called-by-contract"); // voids flashloan attack vectors
// Hash of the order
bytes32 hash = args.order.hash();
// Check if the order is valid
if (!_validateArgs(args, hash)) {
return 0;
}
// Check if the order is canceled / already fully filled
if (!_validateStatus(args, hash)) {
return 0;
}
// Calculates fee deducted amountIn and amountOutMin
(uint256 amountIn, uint256 amountOutMin) = (
args.amountToFillIn,
args.order.amountOutMin.mul(args.amountToFillIn) / args.order.amountIn
);
uint256 _feeNumerator = feeNumerator;
uint256 fee = amountIn.mul(_feeNumerator) / 10000;
if (fee > 0) {
amountIn = amountIn.sub(fee);
amountOutMin = amountOutMin.sub(amountOutMin.mul(_feeNumerator) / 10000);
}
// Requires args.amountToFillIn to have already been approved to this
amountOut = _swapExactTokensForTokens(
args.order.maker,
amountIn,
amountOutMin,
args.path,
args.order.recipient
);
if (amountOut > 0) {
if (fee > 0) {
_transferFees(args.order.fromToken, args.order.maker, fee, hash);
}
// This line is free from reentrancy issues since UniswapV2Pair prevents from them
filledAmountInOfHash[hash] = filledAmountInOfHash[hash].add(args.amountToFillIn);
emit OrderFilled(hash, args.amountToFillIn, amountOut);
}
}
| function fillOrder(FillOrderArgs memory args) public override returns (uint256 amountOut) {
// solhint-disable-next-line avoid-tx-origin
require(msg.sender == tx.origin, "called-by-contract"); // voids flashloan attack vectors
// Hash of the order
bytes32 hash = args.order.hash();
// Check if the order is valid
if (!_validateArgs(args, hash)) {
return 0;
}
// Check if the order is canceled / already fully filled
if (!_validateStatus(args, hash)) {
return 0;
}
// Calculates fee deducted amountIn and amountOutMin
(uint256 amountIn, uint256 amountOutMin) = (
args.amountToFillIn,
args.order.amountOutMin.mul(args.amountToFillIn) / args.order.amountIn
);
uint256 _feeNumerator = feeNumerator;
uint256 fee = amountIn.mul(_feeNumerator) / 10000;
if (fee > 0) {
amountIn = amountIn.sub(fee);
amountOutMin = amountOutMin.sub(amountOutMin.mul(_feeNumerator) / 10000);
}
// Requires args.amountToFillIn to have already been approved to this
amountOut = _swapExactTokensForTokens(
args.order.maker,
amountIn,
amountOutMin,
args.path,
args.order.recipient
);
if (amountOut > 0) {
if (fee > 0) {
_transferFees(args.order.fromToken, args.order.maker, fee, hash);
}
// This line is free from reentrancy issues since UniswapV2Pair prevents from them
filledAmountInOfHash[hash] = filledAmountInOfHash[hash].add(args.amountToFillIn);
emit OrderFilled(hash, args.amountToFillIn, amountOut);
}
}
| 45,100 |
33 | // God can set a new auctions contract | function godSetOpenAuctionsContract(address _openAuctionsContract)
public
onlyGod
| function godSetOpenAuctionsContract(address _openAuctionsContract)
public
onlyGod
| 26,138 |
117 | // Borrower withdraws ETH from their balance. _amount The amount of ETH to withdraw./ | {
require(_amount > 0, "Must withdraw more than 0.");
Balance memory balance = balances[msg.sender];
// Since cost increases per second, it's difficult to estimate the correct amount. Withdraw it all in that case.
if (balance.lastBalance > _amount) {
balance.lastBalance = uint128( balance.lastBalance.sub(_amount) );
} else {
_amount = balance.lastBalance;
balance.lastBalance = 0;
}
balances[msg.sender] = balance;
msg.sender.transfer(_amount);
emit Withdraw(msg.sender, _amount);
}
| {
require(_amount > 0, "Must withdraw more than 0.");
Balance memory balance = balances[msg.sender];
// Since cost increases per second, it's difficult to estimate the correct amount. Withdraw it all in that case.
if (balance.lastBalance > _amount) {
balance.lastBalance = uint128( balance.lastBalance.sub(_amount) );
} else {
_amount = balance.lastBalance;
balance.lastBalance = 0;
}
balances[msg.sender] = balance;
msg.sender.transfer(_amount);
emit Withdraw(msg.sender, _amount);
}
| 29,208 |
0 | // fields to help the contract operate | uint256 private _totalSupply;
uint256 private allTimeMatchAmount;
uint8 private borkMatchRateShift; // percent of each transaction to be held by contract for eventual donation
mapping(address => uint256) private balances;
mapping(address => mapping(address => uint256)) private allowed;
| uint256 private _totalSupply;
uint256 private allTimeMatchAmount;
uint8 private borkMatchRateShift; // percent of each transaction to be held by contract for eventual donation
mapping(address => uint256) private balances;
mapping(address => mapping(address => uint256)) private allowed;
| 5,040 |
45 | // Checks msg.sender can transfer a token, by being owner, approved, or operator _tokenId uint256 ID of the token to validate / | modifier canTransfer(uint256 _tokenId) {
require(isApprovedOrOwner(msg.sender, _tokenId));
_;
}
| modifier canTransfer(uint256 _tokenId) {
require(isApprovedOrOwner(msg.sender, _tokenId));
_;
}
| 35,857 |
3 | // The unix timestamp of the block the listing was created on (in seconds). | uint64 createdAt;
| uint64 createdAt;
| 41,202 |
0 | // ============ External ============ //Get deposit calldata from SetToken Supplies an `_amountNotional` of underlying asset into the reserve, receiving in return overlying aTokens.- E.g. User supplies 100 USDC and gets in return 100 aUSDC _pool Address of the AaveV3 Pool contract _assetThe address of the underlying asset to deposit _amountNotional The amount to be supplied _onBehalfOf The address that will receive the aTokens, same as msg.sender if the user wants to receive them on his own wallet, or a different address if the beneficiary of aTokens is a different wallet _referralCode Code used to register the integrator originating the operation, for | function getSupplyCalldata(
IPool _pool,
address _asset,
uint256 _amountNotional,
address _onBehalfOf,
uint16 _referralCode
)
public
pure
returns (address, uint256, bytes memory)
| function getSupplyCalldata(
IPool _pool,
address _asset,
uint256 _amountNotional,
address _onBehalfOf,
uint16 _referralCode
)
public
pure
returns (address, uint256, bytes memory)
| 35,786 |
5 | // Reduce deposit 3 from 5 -> 4 | deposit.directDeposit(3, msg.sender, 4);
assertEq(deposit.totalDeposited(), 14);
| deposit.directDeposit(3, msg.sender, 4);
assertEq(deposit.totalDeposited(), 14);
| 30,853 |
53 | // transform desire amount to sell amount | uint160 sqrtPrice = LogPowMath.getSqrtPrice(addLimitOrderParam.pt);
if (addLimitOrderParam.sellXEarnY) {
uint256 l = MulDivMath.mulDivCeil(addLimitOrderParam.amount, TwoPower.pow96, sqrtPrice);
addLimitOrderParam.amount = Converter.toUint128(MulDivMath.mulDivCeil(l, TwoPower.pow96, sqrtPrice));
} else {
| uint160 sqrtPrice = LogPowMath.getSqrtPrice(addLimitOrderParam.pt);
if (addLimitOrderParam.sellXEarnY) {
uint256 l = MulDivMath.mulDivCeil(addLimitOrderParam.amount, TwoPower.pow96, sqrtPrice);
addLimitOrderParam.amount = Converter.toUint128(MulDivMath.mulDivCeil(l, TwoPower.pow96, sqrtPrice));
} else {
| 15,491 |
3 | // max expiry that BokkyPooBahsDateTimeLibrary can handle. (2345/12/31) | uint256 private constant MAX_EXPIRY = 11865398400;
constructor(address _addressBook) public {
addressBook = _addressBook;
}
| uint256 private constant MAX_EXPIRY = 11865398400;
constructor(address _addressBook) public {
addressBook = _addressBook;
}
| 30,623 |
11 | // Mutable parameters, can be changed by governance | AMMFeeConfig ammFeeConfig = AMMFeeConfig(1, 20, 10000, 50, 1000);
bool public depositFeeEnabled = true;
| AMMFeeConfig ammFeeConfig = AMMFeeConfig(1, 20, 10000, 50, 1000);
bool public depositFeeEnabled = true;
| 5,240 |
592 | // Reads the int32 at `mPtr` in memory. | function readInt32(MemoryPointer mPtr) internal pure returns (int32 value) {
assembly ("memory-safe") {
value := mload(mPtr)
}
}
| function readInt32(MemoryPointer mPtr) internal pure returns (int32 value) {
assembly ("memory-safe") {
value := mload(mPtr)
}
}
| 33,715 |
26 | // The lost coins and the collected tax are distributed to the voters who voted for the "truth" level as a reward. The PROPORTIONAL_REWARD_RATE of the reward is distributed to the voters in proportion to the coins they deposited. The rest of the reward is distributed to the voters evenly. | PROPORTIONAL_REWARD_RATE = 90; // 90%
| PROPORTIONAL_REWARD_RATE = 90; // 90%
| 13,786 |
89 | // sub depot from user | function subDepotEth(address _user, uint256 _amount) private returns (bool) {
if(depotEth[_user] < _amount){
return false;
}
depotEth[_user] = depotEth[_user].sub(_amount);
return true;
}
| function subDepotEth(address _user, uint256 _amount) private returns (bool) {
if(depotEth[_user] < _amount){
return false;
}
depotEth[_user] = depotEth[_user].sub(_amount);
return true;
}
| 44,122 |
463 | // Sets up royalty for secondary sales used by EIP2981 royaltyInfo method receiver_ - Receiving address for the royalty payment basisAmount_ - % commission with scale 1e4.1% = 100; 15% = 1500; 100% = 10000, / | function setRoyalty(address receiver_, uint256 basisAmount_) public only(DEFAULT_ADMIN_ROLE) {
_royaltyReceiver = receiver_;
_royaltyBasis = basisAmount_;
emit RoyaltyChanged(_royaltyReceiver, _royaltyBasis);
}
| function setRoyalty(address receiver_, uint256 basisAmount_) public only(DEFAULT_ADMIN_ROLE) {
_royaltyReceiver = receiver_;
_royaltyBasis = basisAmount_;
emit RoyaltyChanged(_royaltyReceiver, _royaltyBasis);
}
| 16,637 |
4 | // If not the last, replace the current volley with the last volley and pop the array | if (length != _index + 1) {
willCallVolleys[msg.sender][_index] = willCallVolleys[msg.sender][--length];
}
| if (length != _index + 1) {
willCallVolleys[msg.sender][_index] = willCallVolleys[msg.sender][--length];
}
| 76,972 |
10 | // packed uint: max of 95, max uint8 = 255 | uint8 secondaryMarketRoyaltyPercentage;
address payable additionalPayeeSecondarySales;
| uint8 secondaryMarketRoyaltyPercentage;
address payable additionalPayeeSecondarySales;
| 20,238 |
91 | // Check whether given token is reserved or not. Reserved tokens are not allowed to sweep. | function isReservedToken(address _token) public view virtual override returns (bool);
| function isReservedToken(address _token) public view virtual override returns (bool);
| 5,767 |
29 | // reset borrower's data | collateralEther[msg.sender] = 0;
isBorrowed[msg.sender] = false;
| collateralEther[msg.sender] = 0;
isBorrowed[msg.sender] = false;
| 22,921 |
97 | // Verify signer's signature. | function verifySignature(
address signer,
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
)
private
pure
| function verifySignature(
address signer,
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
)
private
pure
| 25,176 |
7 | // Locker to prevent reentry | modifier _lock_() {
require(!_mutex, "PerpetualPool: reentry");
_mutex = true;
_;
_mutex = false;
}
| modifier _lock_() {
require(!_mutex, "PerpetualPool: reentry");
_mutex = true;
_;
_mutex = false;
}
| 62,407 |
69 | // Sets a new controller / | function setController(address _controller)
external
onlyOwner
returns (uint256)
| function setController(address _controller)
external
onlyOwner
returns (uint256)
| 21,223 |
68 | // Call createAuction in auction contract | auction.createAuction(
tokenId,
_startingPrice,
_endingPrice,
_duration,
address(this)
);
releaseCreatedCount++;
| auction.createAuction(
tokenId,
_startingPrice,
_endingPrice,
_duration,
address(this)
);
releaseCreatedCount++;
| 46,983 |
19 | // track number of signatures | self.proposal_[_whatProposal].count += 1;
| self.proposal_[_whatProposal].count += 1;
| 31,554 |
55 | // transfer funds to hold in case of transfer failed | if (!rthAddress.send(rthAmnt)) {
_finished = false;
return false;
}
| if (!rthAddress.send(rthAmnt)) {
_finished = false;
return false;
}
| 270 |
26 | // Failed executing transaction | revert(string(abi.encodePacked("[#", toString(i) ,"]execution failed")));
| revert(string(abi.encodePacked("[#", toString(i) ,"]execution failed")));
| 25,148 |
5 | // initialize the campaign mapping | Campaign storage campaign = campaignList[campaignCount];
| Campaign storage campaign = campaignList[campaignCount];
| 8,078 |
191 | // check that i < the number of entries | valid := lt(
_i,
mload(add(_proofOutputsOrNotes, 0x20))
)
| valid := lt(
_i,
mload(add(_proofOutputsOrNotes, 0x20))
)
| 35,993 |
24 | // Check for minimum buy amount for the first 400 transactions | if (transactionsCount < 400) {
require(msg.sender == _owner || msg.value >= minimumBuyAmount, "Minimum buy amount not met");
}
| if (transactionsCount < 400) {
require(msg.sender == _owner || msg.value >= minimumBuyAmount, "Minimum buy amount not met");
}
| 31,206 |
1 | // Returns the fee tier for a given proxy contract address and proxy deployer address. | function getFeeTier(address deployer, address proxy)
external
view
returns (uint128 tierId, uint128 validUntilTimestamp);
| function getFeeTier(address deployer, address proxy)
external
view
returns (uint128 tierId, uint128 validUntilTimestamp);
| 36,431 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.