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 |
|---|---|---|---|---|
16 | // uint256[] memory _chestIds; | _chestIds = new uint256[](1);
_chestIds[0] = _chestId;
| _chestIds = new uint256[](1);
_chestIds[0] = _chestId;
| 23,085 |
47 | // Official record of token balances for each account | mapping(address => uint) internal balances;
mapping(address => LockedBalance) public locked;
DexAggregatorInterface public dexAgg;
IERC20 public oleToken;
| mapping(address => uint) internal balances;
mapping(address => LockedBalance) public locked;
DexAggregatorInterface public dexAgg;
IERC20 public oleToken;
| 31,558 |
68 | // Collected ETH is transferred to multisigs. Unsold tokens transferred to GoldmintUnsold contract. | ICOFinished,
| ICOFinished,
| 39,812 |
8 | // 참여자 금액 되돌려주기/ | function withdraw() external {
require(state == AuctionState.COMPLETED);
require(stakeAmounts[msg.sender] > 0);
uint amount = stakeAmounts[msg.sender];
stakeAmounts[msg.sender] = 0;
msg.sender.transfer(amount);
}
| function withdraw() external {
require(state == AuctionState.COMPLETED);
require(stakeAmounts[msg.sender] > 0);
uint amount = stakeAmounts[msg.sender];
stakeAmounts[msg.sender] = 0;
msg.sender.transfer(amount);
}
| 42,592 |
25 | // get all depositers and their claimed amount | function getDepositors()
public
view
returns (address[] memory, uint256[] memory)
| function getDepositors()
public
view
returns (address[] memory, uint256[] memory)
| 36,774 |
23 | // Запрос на выплату от пользователя, используется в случае, если клиент делает withdraw / | function _withdraw(address toAddress, uint weiAmount) private {
// Делаем перевод получателю
toAddress.transfer(weiAmount);
Withdraw(toAddress, weiAmount);
}
| function _withdraw(address toAddress, uint weiAmount) private {
// Делаем перевод получателю
toAddress.transfer(weiAmount);
Withdraw(toAddress, weiAmount);
}
| 21,873 |
16 | // Buys a position in a reality market./For a given starting token index n, n = Invalid, n+1 = No, n+2 = Yes./index Market index to buy the position in./outcome Token index of the outcome to buy into./amount Amount of Vision to stake on the outcome./Invariant - User may not purchase positions once the market has been finalized./Invariant - Market outcome may not be | function buyPosition(uint index, uint outcome, uint amount) public nonReentrant isInitialized {
require(!realityMarketRegistry[index].finalized, "Market already finalized.");
require(amount > 0, "Amount to mint should be greater than 0.");
uint invalid = realityMarketRegistry[index].tokenIndex;
uint no = realityMarketRegistry[index].tokenIndex.add(1);
uint yes = realityMarketRegistry[index].tokenIndex.add(2);
require(
(outcome == no || outcome == yes || outcome == invalid),
"Market outcome selection does not match market index outcomes."
);
uint foresightAmount = getPurchaseReturn(index, outcome, amount);
require(foresightAmount > 0, "Returned foresight should be greater than 0.");
realityMarketRegistry[index].totalStaked[outcome] = realityMarketRegistry[index].totalStaked[outcome].add(amount);
realityMarketRegistry[index].totalStakedByAddress[outcome][msg.sender] = realityMarketRegistry[index].totalStakedByAddress[outcome][msg.sender].add(amount);
realityMarketRegistry[index].totalMinted[outcome] = realityMarketRegistry[index].totalMinted[outcome].add(foresightAmount);
uint winningOutcome = realityMarketRegistry[index].winningOutcome;
if (realityMarketRegistry[index].totalStaked[outcome] > realityMarketRegistry[index].totalStaked[winningOutcome]) {
realityMarketRegistry[index].winningOutcome = outcome;
realityMarketRegistry[index].leadTime = block.timestamp;
}
foresightTokens.mint(msg.sender, outcome, foresightAmount);
vision.transferFrom(msg.sender, address(this), amount);
emit ForesightMinted(index, outcome, foresightAmount, amount, msg.sender);
}
| function buyPosition(uint index, uint outcome, uint amount) public nonReentrant isInitialized {
require(!realityMarketRegistry[index].finalized, "Market already finalized.");
require(amount > 0, "Amount to mint should be greater than 0.");
uint invalid = realityMarketRegistry[index].tokenIndex;
uint no = realityMarketRegistry[index].tokenIndex.add(1);
uint yes = realityMarketRegistry[index].tokenIndex.add(2);
require(
(outcome == no || outcome == yes || outcome == invalid),
"Market outcome selection does not match market index outcomes."
);
uint foresightAmount = getPurchaseReturn(index, outcome, amount);
require(foresightAmount > 0, "Returned foresight should be greater than 0.");
realityMarketRegistry[index].totalStaked[outcome] = realityMarketRegistry[index].totalStaked[outcome].add(amount);
realityMarketRegistry[index].totalStakedByAddress[outcome][msg.sender] = realityMarketRegistry[index].totalStakedByAddress[outcome][msg.sender].add(amount);
realityMarketRegistry[index].totalMinted[outcome] = realityMarketRegistry[index].totalMinted[outcome].add(foresightAmount);
uint winningOutcome = realityMarketRegistry[index].winningOutcome;
if (realityMarketRegistry[index].totalStaked[outcome] > realityMarketRegistry[index].totalStaked[winningOutcome]) {
realityMarketRegistry[index].winningOutcome = outcome;
realityMarketRegistry[index].leadTime = block.timestamp;
}
foresightTokens.mint(msg.sender, outcome, foresightAmount);
vision.transferFrom(msg.sender, address(this), amount);
emit ForesightMinted(index, outcome, foresightAmount, amount, msg.sender);
}
| 40,241 |
12 | // tokens should be held until vote is not one of the states below. | IAaveGovernanceV2.ProposalState state = aaveGovernanceV2
.getProposalState(runningProposals[i]);
if (
state == IAaveGovernanceV2.ProposalState.Pending ||
state == IAaveGovernanceV2.ProposalState.Active ||
state == IAaveGovernanceV2.ProposalState.Succeeded ||
state == IAaveGovernanceV2.ProposalState.Queued
) {
newRunningProposals[i] = runningProposals[i];
}
| IAaveGovernanceV2.ProposalState state = aaveGovernanceV2
.getProposalState(runningProposals[i]);
if (
state == IAaveGovernanceV2.ProposalState.Pending ||
state == IAaveGovernanceV2.ProposalState.Active ||
state == IAaveGovernanceV2.ProposalState.Succeeded ||
state == IAaveGovernanceV2.ProposalState.Queued
) {
newRunningProposals[i] = runningProposals[i];
}
| 6,719 |
7 | // The payment terms. paymentCycleAmount The amount to be paid every cycle. monthlyCycleInterest The interest to be paid every cycle. paymentCycle The duration of a payment cycle. APR The interest rate involved in bps. installments The total installments for the loan repayment. installmentsPaid The installments paid. / | struct Terms {
uint256 paymentCycleAmount;
uint256 monthlyCycleInterest;
uint32 paymentCycle;
uint16 APR;
uint32 installments;
uint32 installmentsPaid;
}
| struct Terms {
uint256 paymentCycleAmount;
uint256 monthlyCycleInterest;
uint32 paymentCycle;
uint16 APR;
uint32 installments;
uint32 installmentsPaid;
}
| 11,295 |
37 | // A generic interface for a contract which properly accepts ERC721 tokens./Solmate (https:github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC721.sol) | interface ERC721TokenReceiver {
function onERC721Received(
address operator,
address from,
uint256 id,
bytes calldata data
) external returns (bytes4);
}
| interface ERC721TokenReceiver {
function onERC721Received(
address operator,
address from,
uint256 id,
bytes calldata data
) external returns (bytes4);
}
| 23,394 |
359 | // start block of release to VAI Vault | uint256 public releaseStartBlock;
| uint256 public releaseStartBlock;
| 14,678 |
9 | // Set each state variable manually | function setTokenAddress(address _newToken) external onlyOwner{
REMI_INTERFACE = IERC20(_newToken);
}
| function setTokenAddress(address _newToken) external onlyOwner{
REMI_INTERFACE = IERC20(_newToken);
}
| 24,551 |
88 | // Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.And also called before burning one token. startTokenId - the first token id to be transferredquantity - the amount to be transferred Calling conditions: - When `from` and `to` are both non-zero, `from`'s `tokenId` will betransferred to `to`.- When `from` is zero, `tokenId` will be minted for `to`.- When `to` is zero, `tokenId` will be burned by `from`.- `from` and `to` are never both zero. / | function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
| function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
| 11,231 |
209 | // ========== SETTERS ========== / | ) public view returns (uint amountAfterSettlement) {
amountAfterSettlement = amount;
// balance of a pynth will show an amount after settlement
uint balanceOfSourceAfterSettlement = IERC20(address(issuer().pynths(currencyKey))).balanceOf(from);
// when there isn't enough supply (either due to reclamation settlement or because the number is too high)
if (amountAfterSettlement > balanceOfSourceAfterSettlement) {
// then the amount to exchange is reduced to their remaining supply
amountAfterSettlement = balanceOfSourceAfterSettlement;
}
if (refunded > 0) {
amountAfterSettlement = amountAfterSettlement.add(refunded);
}
}
| ) public view returns (uint amountAfterSettlement) {
amountAfterSettlement = amount;
// balance of a pynth will show an amount after settlement
uint balanceOfSourceAfterSettlement = IERC20(address(issuer().pynths(currencyKey))).balanceOf(from);
// when there isn't enough supply (either due to reclamation settlement or because the number is too high)
if (amountAfterSettlement > balanceOfSourceAfterSettlement) {
// then the amount to exchange is reduced to their remaining supply
amountAfterSettlement = balanceOfSourceAfterSettlement;
}
if (refunded > 0) {
amountAfterSettlement = amountAfterSettlement.add(refunded);
}
}
| 57,514 |
30 | // Add the application | applications[jobId][msg.sender] = Application(
msg.sender,
jobs[jobId].employerAddress,
jobId,
false,
false
);
| applications[jobId][msg.sender] = Application(
msg.sender,
jobs[jobId].employerAddress,
jobId,
false,
false
);
| 2,240 |
249 | // Constructor _securityToken Address of the security token / | constructor (address _securityToken, address _polyAddress) public
ModuleStorage(_securityToken, _polyAddress)
| constructor (address _securityToken, address _polyAddress) public
ModuleStorage(_securityToken, _polyAddress)
| 33,371 |
132 | // 크라우드 세일이 진행 중인지 여부를 반환한다.return isOpened true: 진행 중 false : 진행 중이 아님(참여 불가) / | function isOpened() public view returns (bool isOpend) {
if(now < startTime) return false;
if(now >= endTime) return false;
if(closed == true) return false;
return true;
}
| function isOpened() public view returns (bool isOpend) {
if(now < startTime) return false;
if(now >= endTime) return false;
if(closed == true) return false;
return true;
}
| 49,901 |
204 | // Toggles minting state. / | function toggleMintEnabled() public onlyOwner {
mintEnabled = !mintEnabled;
}
| function toggleMintEnabled() public onlyOwner {
mintEnabled = !mintEnabled;
}
| 38,491 |
64 | // Tax and MarketingPool fees will start at 0 so we don't have a big impact when deploying to Uniswap MarketingPool wallet address is null but the method to set the address is exposed | uint256 private _taxFee = 8;
uint256 private _MarketingPoolFee = 8;
uint256 private _previousTaxFee = _taxFee;
uint256 private _previousMarketingPoolFee = _MarketingPoolFee;
address payable public _MarketingPoolWalletAddress;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
| uint256 private _taxFee = 8;
uint256 private _MarketingPoolFee = 8;
uint256 private _previousTaxFee = _taxFee;
uint256 private _previousMarketingPoolFee = _MarketingPoolFee;
address payable public _MarketingPoolWalletAddress;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
| 24,428 |
29 | // A fulfillment is applied to a group of orders. It decrements a series of offer and consideration items, then generates a single execution element. A given fulfillment can be applied to as many offer and consideration items as desired, but must contain at least one offer and at least one consideration that match. The fulfillment must also remain consistent on all key parameters across all offer items (same offerer, token, type, tokenId, and conduit preference) as well as across all consideration items (token, type, tokenId, and recipient). / | struct Fulfillment {
FulfillmentComponent[] offerComponents;
FulfillmentComponent[] considerationComponents;
}
| struct Fulfillment {
FulfillmentComponent[] offerComponents;
FulfillmentComponent[] considerationComponents;
}
| 32,753 |
25 | // If the observation fails validation, do not update anything | if (!validateObservation(data, price)) return false;
ObservationLibrary.PriceObservation storage observation = observations[token];
AccumulationLibrary.PriceAccumulator storage accumulation = accumulations[token];
if (observation.timestamp == 0) {
| if (!validateObservation(data, price)) return false;
ObservationLibrary.PriceObservation storage observation = observations[token];
AccumulationLibrary.PriceAccumulator storage accumulation = accumulations[token];
if (observation.timestamp == 0) {
| 23,872 |
1 | // cliff period in seconds | uint256 cliff;
| uint256 cliff;
| 6,598 |
132 | // send some amount of arbitrary ERC20 Tokens_externalToken the address of the Token Contract_to address of the beneficiary_value the amount of ether (in Wei) to send_avatar address return bool which represents a success/ | function externalTokenTransfer(IERC20 _externalToken, address _to, uint256 _value, Avatar _avatar)
| function externalTokenTransfer(IERC20 _externalToken, address _to, uint256 _value, Avatar _avatar)
| 21,558 |
11 | // step => address => 可提取token | mapping(uint256 => mapping(address => uint256)) private tokenBalance;
mapping(uint256 => mapping(address => uint256)) FissionBalance;
mapping(uint256 => mapping(address => uint256)) FOMOBalance;
mapping(uint256 => mapping(address => uint256)) LuckyBalance;
| mapping(uint256 => mapping(address => uint256)) private tokenBalance;
mapping(uint256 => mapping(address => uint256)) FissionBalance;
mapping(uint256 => mapping(address => uint256)) FOMOBalance;
mapping(uint256 => mapping(address => uint256)) LuckyBalance;
| 11,084 |
37 | // A special address that is authorized to call `emergencyRecovery()`. That function/resets ALL authorization for this wallet, and must therefore be treated with utmost security./Reasonable choices for recoveryAddress include:/ - the address of a private key in cold storage/ - a physically secured hardware wallet/ - a multisig smart contract, possibly with a time-delayed challenge period/ - the zero address, if you like performing without a safety net ;-) | address public recoveryAddress;
| address public recoveryAddress;
| 7,278 |
212 | // Set the lastRewardBlock as the startBlock | lastRewardBlock = _startBlock;
| lastRewardBlock = _startBlock;
| 52,855 |
34 | // Pausable Base contract which allows children to implement an emergency stop mechanism. / | contract Pausable is Ownable {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
Unpause();
}
}
| contract Pausable is Ownable {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
Unpause();
}
}
| 2,595 |
132 | // Query if a contract implements an interfaceInterface identification is specified in ERC-165. This function uses less than 30,000 gas.interfaceID The interface identifier, as specified in ERC-165return `true` if the contract implements `interfaceID` and `interfaceID` is not 0xffffffff, `false` otherwise / | function supportsInterface(bytes4 interfaceID) external view returns (bool);
| function supportsInterface(bytes4 interfaceID) external view returns (bool);
| 6,035 |
126 | // Returns the underlying token address of the given cToken | function getUnderlyingAddr(address _cTokenAddr) internal returns (address tokenAddr) {
// cEth has no .underlying() method
if (_cTokenAddr == C_ETH_ADDR) return TokenUtils.WETH_ADDR;
tokenAddr = ICToken(_cTokenAddr).underlying();
}
| function getUnderlyingAddr(address _cTokenAddr) internal returns (address tokenAddr) {
// cEth has no .underlying() method
if (_cTokenAddr == C_ETH_ADDR) return TokenUtils.WETH_ADDR;
tokenAddr = ICToken(_cTokenAddr).underlying();
}
| 25,227 |
91 | // The oracle will have given you an ID for the VRF keypair they have committed to (let's call it keyHash), and have told you the minimum LINK price for VRF service. Make sure your contract has sufficient LINK, and call requestRandomness(keyHash, fee, seed), where seed is the input you want to generate randomness from.Once the VRFCoordinator has received and validated the oracle's response to your request, it will call your contract's fulfillRandomness method.The randomness argument to fulfillRandomness is the actual random value generated from your seed.The requestId argument is generated from the keyHash and the seed by makeRequestId(keyHash, seed). If | abstract contract VRFConsumerBase is VRFRequestIDBase {
using SafeMath for uint256;
/**
* @notice fulfillRandomness handles the VRF response. Your contract must
* @notice implement it.
*
* @dev The VRFCoordinator expects a calling contract to have a method with
* @dev this signature, and will trigger it once it has verified the proof
* @dev associated with the randomness (It is triggered via a call to
* @dev rawFulfillRandomness, below.)
*
* @param requestId The Id initially returned by requestRandomness
* @param randomness the VRF output
*/
function fulfillRandomness(bytes32 requestId, uint256 randomness)
internal virtual;
/**
* @notice requestRandomness initiates a request for VRF output given _seed
*
* @dev See "SECURITY CONSIDERATIONS" above for more information on _seed.
*
* @dev The fulfillRandomness method receives the output, once it's provided
* @dev by the Oracle, and verified by the vrfCoordinator.
*
* @dev The _keyHash must already be registered with the VRFCoordinator, and
* @dev the _fee must exceed the fee specified during registration of the
* @dev _keyHash.
*
* @param _keyHash ID of public key against which randomness is generated
* @param _fee The amount of LINK to send with the request
* @param _seed seed mixed into the input of the VRF
*
* @return requestId unique ID for this request
*
* @dev The returned requestId can be used to distinguish responses to *
* @dev concurrent requests. It is passed as the first argument to
* @dev fulfillRandomness.
*/
function requestRandomness(bytes32 _keyHash, uint256 _fee, uint256 _seed)
public returns (bytes32 requestId)
{
LINK.transferAndCall(vrfCoordinator, _fee, abi.encode(_keyHash, _seed));
// This is the seed passed to VRFCoordinator. The oracle will mix this with
// the hash of the block containing this request to obtain the seed/input
// which is finally passed to the VRF cryptographic machinery.
uint256 vRFSeed = makeVRFInputSeed(_keyHash, _seed, address(this), nonces[_keyHash]);
// nonces[_keyHash] must stay in sync with
// VRFCoordinator.nonces[_keyHash][this], which was incremented by the above
// successful LINK.transferAndCall (in VRFCoordinator.randomnessRequest).
// This provides protection against the user repeating their input
// seed, which would result in a predictable/duplicate output.
nonces[_keyHash] = nonces[_keyHash].add(1);
return makeRequestId(_keyHash, vRFSeed);
}
LinkTokenInterface immutable internal LINK;
address immutable private vrfCoordinator;
// Nonces for each VRF key from which randomness has been requested.
//
// Must stay in sync with VRFCoordinator[_keyHash][this]
mapping(bytes32 /* keyHash */ => uint256 /* nonce */) public nonces;
constructor(address _vrfCoordinator, address _link) public {
vrfCoordinator = _vrfCoordinator;
LINK = LinkTokenInterface(_link);
}
// rawFulfillRandomness is called by VRFCoordinator when it receives a valid VRF
// proof. rawFulfillRandomness then calls fulfillRandomness, after validating
// the origin of the call
function rawFulfillRandomness(bytes32 requestId, uint256 randomness) external {
require(msg.sender == vrfCoordinator, "Only VRFCoordinator can fulfill");
fulfillRandomness(requestId, randomness);
}
}
| abstract contract VRFConsumerBase is VRFRequestIDBase {
using SafeMath for uint256;
/**
* @notice fulfillRandomness handles the VRF response. Your contract must
* @notice implement it.
*
* @dev The VRFCoordinator expects a calling contract to have a method with
* @dev this signature, and will trigger it once it has verified the proof
* @dev associated with the randomness (It is triggered via a call to
* @dev rawFulfillRandomness, below.)
*
* @param requestId The Id initially returned by requestRandomness
* @param randomness the VRF output
*/
function fulfillRandomness(bytes32 requestId, uint256 randomness)
internal virtual;
/**
* @notice requestRandomness initiates a request for VRF output given _seed
*
* @dev See "SECURITY CONSIDERATIONS" above for more information on _seed.
*
* @dev The fulfillRandomness method receives the output, once it's provided
* @dev by the Oracle, and verified by the vrfCoordinator.
*
* @dev The _keyHash must already be registered with the VRFCoordinator, and
* @dev the _fee must exceed the fee specified during registration of the
* @dev _keyHash.
*
* @param _keyHash ID of public key against which randomness is generated
* @param _fee The amount of LINK to send with the request
* @param _seed seed mixed into the input of the VRF
*
* @return requestId unique ID for this request
*
* @dev The returned requestId can be used to distinguish responses to *
* @dev concurrent requests. It is passed as the first argument to
* @dev fulfillRandomness.
*/
function requestRandomness(bytes32 _keyHash, uint256 _fee, uint256 _seed)
public returns (bytes32 requestId)
{
LINK.transferAndCall(vrfCoordinator, _fee, abi.encode(_keyHash, _seed));
// This is the seed passed to VRFCoordinator. The oracle will mix this with
// the hash of the block containing this request to obtain the seed/input
// which is finally passed to the VRF cryptographic machinery.
uint256 vRFSeed = makeVRFInputSeed(_keyHash, _seed, address(this), nonces[_keyHash]);
// nonces[_keyHash] must stay in sync with
// VRFCoordinator.nonces[_keyHash][this], which was incremented by the above
// successful LINK.transferAndCall (in VRFCoordinator.randomnessRequest).
// This provides protection against the user repeating their input
// seed, which would result in a predictable/duplicate output.
nonces[_keyHash] = nonces[_keyHash].add(1);
return makeRequestId(_keyHash, vRFSeed);
}
LinkTokenInterface immutable internal LINK;
address immutable private vrfCoordinator;
// Nonces for each VRF key from which randomness has been requested.
//
// Must stay in sync with VRFCoordinator[_keyHash][this]
mapping(bytes32 /* keyHash */ => uint256 /* nonce */) public nonces;
constructor(address _vrfCoordinator, address _link) public {
vrfCoordinator = _vrfCoordinator;
LINK = LinkTokenInterface(_link);
}
// rawFulfillRandomness is called by VRFCoordinator when it receives a valid VRF
// proof. rawFulfillRandomness then calls fulfillRandomness, after validating
// the origin of the call
function rawFulfillRandomness(bytes32 requestId, uint256 randomness) external {
require(msg.sender == vrfCoordinator, "Only VRFCoordinator can fulfill");
fulfillRandomness(requestId, randomness);
}
}
| 30,685 |
128 | // prepended message with the length of the signed hash in hexadecimal | bytes constant private PREPEND_HEX = "\x19Ethereum Signed Message:\n\x20";
| bytes constant private PREPEND_HEX = "\x19Ethereum Signed Message:\n\x20";
| 10,386 |
9 | // Settlement of unsettled trades of maker orders./account Account placing the related maker orders/epoch Epoch of the settled trades/amountM Amount of Token M added to the account's available balance/amountA Amount of Token A added to the account's available balance/amountB Amount of Token B added to the account's available balance/quoteAmount Amount of quote asset transfered to the account, rounding precision to 18/for quote assets with precision other than 18 decimal places | event MakerSettled(
address indexed account,
uint256 epoch,
uint256 amountM,
uint256 amountA,
uint256 amountB,
uint256 quoteAmount
);
| event MakerSettled(
address indexed account,
uint256 epoch,
uint256 amountM,
uint256 amountA,
uint256 amountB,
uint256 quoteAmount
);
| 14,726 |
7 | // @custom:legacy/Initiates a withdrawal from L2 to L1 to a target account on L1./ Note that if ETH is sent to a contract on L1 and the call fails, then that ETH will/ be locked in the L1StandardBridge. ETH may be recoverable if the call can be/ successfully replayed by increasing the amount of gas supplied to the call. If the/ call will fail for any amount of gas, then the ETH will be locked permanently./ This function only works with OptimismMintableERC20 tokens or ether. Use the/ `bridgeERC20To` function to bridge native L2 tokens to L1./_l2Token Address of the L2 token | function withdrawTo(
address _l2Token,
address _to,
uint256 _amount,
uint32 _minGasLimit,
bytes calldata _extraData
| function withdrawTo(
address _l2Token,
address _to,
uint256 _amount,
uint32 _minGasLimit,
bytes calldata _extraData
| 12,256 |
6 | // BuilderCrowdfunding contract / | contract BuilderCrowdfunding is Builder {
/**
* @dev Run script creation contract
* @return address new contract
*/
function create(
address _fund,
address _bounty,
string _reference,
uint256 _startBlock,
uint256 _stopBlock,
uint256 _minValue,
uint256 _maxValue,
uint256 _scale,
uint256 _startRatio,
uint256 _reductionStep,
uint256 _reductionValue,
address _client
) payable returns (address) {
if (buildingCostWei > 0 && beneficiary != 0) {
// Too low value
if (msg.value < buildingCostWei) throw;
// Beneficiary send
if (!beneficiary.send(buildingCostWei)) throw;
// Refund
if (msg.value > buildingCostWei) {
if (!msg.sender.send(msg.value - buildingCostWei)) throw;
}
} else {
// Refund all
if (msg.value > 0) {
if (!msg.sender.send(msg.value)) throw;
}
}
if (_client == 0)
_client = msg.sender;
var inst = CreatorCrowdfunding.create(_fund, _bounty, _reference, _startBlock,
_stopBlock, _minValue, _maxValue, _scale,
_startRatio, _reductionStep, _reductionValue);
inst.setOwner(_client);
inst.setHammer(_client);
getContractsOf[_client].push(inst);
Builded(_client, inst);
return inst;
}
}
| contract BuilderCrowdfunding is Builder {
/**
* @dev Run script creation contract
* @return address new contract
*/
function create(
address _fund,
address _bounty,
string _reference,
uint256 _startBlock,
uint256 _stopBlock,
uint256 _minValue,
uint256 _maxValue,
uint256 _scale,
uint256 _startRatio,
uint256 _reductionStep,
uint256 _reductionValue,
address _client
) payable returns (address) {
if (buildingCostWei > 0 && beneficiary != 0) {
// Too low value
if (msg.value < buildingCostWei) throw;
// Beneficiary send
if (!beneficiary.send(buildingCostWei)) throw;
// Refund
if (msg.value > buildingCostWei) {
if (!msg.sender.send(msg.value - buildingCostWei)) throw;
}
} else {
// Refund all
if (msg.value > 0) {
if (!msg.sender.send(msg.value)) throw;
}
}
if (_client == 0)
_client = msg.sender;
var inst = CreatorCrowdfunding.create(_fund, _bounty, _reference, _startBlock,
_stopBlock, _minValue, _maxValue, _scale,
_startRatio, _reductionStep, _reductionValue);
inst.setOwner(_client);
inst.setHammer(_client);
getContractsOf[_client].push(inst);
Builded(_client, inst);
return inst;
}
}
| 46,519 |
257 | // Convert ETH to WETH if needed |
if (gemJoin == wethJoin) {
invokeWallet(_wallet, address(wethToken), _collateralAmount, abi.encodeWithSignature("deposit()"));
}
|
if (gemJoin == wethJoin) {
invokeWallet(_wallet, address(wethToken), _collateralAmount, abi.encodeWithSignature("deposit()"));
}
| 2,452 |
7 | // Only deploy if a smart wallet doesn't already exist at expected address. | uint256 size;
| uint256 size;
| 6,670 |
135 | // event emitted when a token template is added | event TokenTemplateAdded(address newToken, uint256 templateId);
| event TokenTemplateAdded(address newToken, uint256 templateId);
| 22,579 |
0 | // forward registrar | mapping(address=>bytes32) registrar;
| mapping(address=>bytes32) registrar;
| 32,315 |
115 | // delegates one specific power to a delegatee delegatee the user which delegated power has changed delegationType the type of delegation (VOTING_POWER, PROPOSITION_POWER) / | function delegateByType(address delegatee, DelegationType delegationType) external override {
_delegateByType(msg.sender, delegatee, delegationType);
}
| function delegateByType(address delegatee, DelegationType delegationType) external override {
_delegateByType(msg.sender, delegatee, delegationType);
}
| 12,316 |
24 | // Events contract for logging trade activity on Rubicon Market/Provides the key event logs that are used in all core functionality of exchanging on the Rubicon Market | contract EventfulMarket {
event LogItemUpdate(uint256 id);
event LogTrade(
uint256 pay_amt,
address indexed pay_gem,
uint256 buy_amt,
address indexed buy_gem
);
event LogMake(
bytes32 indexed id,
bytes32 indexed pair,
address indexed maker,
ERC20 pay_gem,
ERC20 buy_gem,
uint128 pay_amt,
uint128 buy_amt,
uint64 timestamp
);
event LogBump(
bytes32 indexed id,
bytes32 indexed pair,
address indexed maker,
ERC20 pay_gem,
ERC20 buy_gem,
uint128 pay_amt,
uint128 buy_amt,
uint64 timestamp
);
event LogTake(
bytes32 id,
bytes32 indexed pair,
address indexed maker,
ERC20 pay_gem,
ERC20 buy_gem,
address indexed taker,
uint128 take_amt,
uint128 give_amt,
uint64 timestamp
);
event LogKill(
bytes32 indexed id,
bytes32 indexed pair,
address indexed maker,
ERC20 pay_gem,
ERC20 buy_gem,
uint128 pay_amt,
uint128 buy_amt,
uint64 timestamp
);
event LogInt(string lol, uint256 input);
event FeeTake(
bytes32 id,
bytes32 indexed pair,
address indexed maker,
ERC20 pay_gem,
ERC20 buy_gem,
address indexed taker,
uint128 take_amt,
uint128 give_amt,
uint256 feeAmt,
address feeTo,
uint64 timestamp
);
}
| contract EventfulMarket {
event LogItemUpdate(uint256 id);
event LogTrade(
uint256 pay_amt,
address indexed pay_gem,
uint256 buy_amt,
address indexed buy_gem
);
event LogMake(
bytes32 indexed id,
bytes32 indexed pair,
address indexed maker,
ERC20 pay_gem,
ERC20 buy_gem,
uint128 pay_amt,
uint128 buy_amt,
uint64 timestamp
);
event LogBump(
bytes32 indexed id,
bytes32 indexed pair,
address indexed maker,
ERC20 pay_gem,
ERC20 buy_gem,
uint128 pay_amt,
uint128 buy_amt,
uint64 timestamp
);
event LogTake(
bytes32 id,
bytes32 indexed pair,
address indexed maker,
ERC20 pay_gem,
ERC20 buy_gem,
address indexed taker,
uint128 take_amt,
uint128 give_amt,
uint64 timestamp
);
event LogKill(
bytes32 indexed id,
bytes32 indexed pair,
address indexed maker,
ERC20 pay_gem,
ERC20 buy_gem,
uint128 pay_amt,
uint128 buy_amt,
uint64 timestamp
);
event LogInt(string lol, uint256 input);
event FeeTake(
bytes32 id,
bytes32 indexed pair,
address indexed maker,
ERC20 pay_gem,
ERC20 buy_gem,
address indexed taker,
uint128 take_amt,
uint128 give_amt,
uint256 feeAmt,
address feeTo,
uint64 timestamp
);
}
| 14,238 |
62 | // Allows the governance to set the locker/Can be called only by the governance/_locker locker address | function setLocker(address _locker) external {
require(msg.sender == governance, "!gov");
require(_locker != address(0), "can't be zero address");
emit LockerSet(locker, _locker);
locker = _locker;
}
| function setLocker(address _locker) external {
require(msg.sender == governance, "!gov");
require(_locker != address(0), "can't be zero address");
emit LockerSet(locker, _locker);
locker = _locker;
}
| 70,729 |
115 | // Handle the approval of ERC1363 tokens Any ERC1363 smart contract calls this function on the recipientafter an `approve`. This function MAY throw to revert and reject theapproval. Return of other than the magic value MUST result in thetransaction being reverted.Note: the token contract address is always the message sender. sender address The address which called `approveAndCall` function amount uint256 The amount of tokens to be spent data bytes Additional data with no specified formatreturn `bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))` unless throwing / | function onApprovalReceived(address sender, uint256 amount, bytes calldata data) external returns (bytes4);
| function onApprovalReceived(address sender, uint256 amount, bytes calldata data) external returns (bytes4);
| 18,289 |
7 | // Provides tracking nonces for addresses. Nonces will only increment. / | abstract contract Nonces {
/**
* @dev The nonce used for an `account` is not the expected current nonce.
*/
error InvalidAccountNonce(address account, uint256 currentNonce);
mapping(address account => uint256) private _nonces;
/**
* @dev Returns the next unused nonce for an address.
*/
function nonces(address owner) public view virtual returns (uint256) {
return _nonces[owner];
}
/**
* @dev Consumes a nonce.
*
* Returns the current value and increments nonce.
*/
function _useNonce(address owner) internal virtual returns (uint256) {
// For each account, the nonce has an initial value of 0, can only be incremented by one, and cannot be
// decremented or reset. This guarantees that the nonce never overflows.
unchecked {
// It is important to do x++ and not ++x here.
return _nonces[owner]++;
}
}
/**
* @dev Same as {_useNonce} but checking that `nonce` is the next valid for `owner`.
*/
function _useCheckedNonce(address owner, uint256 nonce) internal virtual {
uint256 current = _useNonce(owner);
if (nonce != current) {
revert InvalidAccountNonce(owner, current);
}
}
}
| abstract contract Nonces {
/**
* @dev The nonce used for an `account` is not the expected current nonce.
*/
error InvalidAccountNonce(address account, uint256 currentNonce);
mapping(address account => uint256) private _nonces;
/**
* @dev Returns the next unused nonce for an address.
*/
function nonces(address owner) public view virtual returns (uint256) {
return _nonces[owner];
}
/**
* @dev Consumes a nonce.
*
* Returns the current value and increments nonce.
*/
function _useNonce(address owner) internal virtual returns (uint256) {
// For each account, the nonce has an initial value of 0, can only be incremented by one, and cannot be
// decremented or reset. This guarantees that the nonce never overflows.
unchecked {
// It is important to do x++ and not ++x here.
return _nonces[owner]++;
}
}
/**
* @dev Same as {_useNonce} but checking that `nonce` is the next valid for `owner`.
*/
function _useCheckedNonce(address owner, uint256 nonce) internal virtual {
uint256 current = _useNonce(owner);
if (nonce != current) {
revert InvalidAccountNonce(owner, current);
}
}
}
| 9,919 |
184 | // The Tangshuk TOKEN! | TangshukBar public tangshuk;
| TangshukBar public tangshuk;
| 8,291 |
19 | // Lifecycle | bool public suspended;
| bool public suspended;
| 43,639 |
235 | // Update the given pool's PEARL allocation point. Can only be called by the owner. | function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);
uint256 prevAllocPoint = poolInfo[_pid].allocPoint;
poolInfo[_pid].allocPoint = _allocPoint;
if (prevAllocPoint != _allocPoint) {
updateStakingPool();
}
}
| function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);
uint256 prevAllocPoint = poolInfo[_pid].allocPoint;
poolInfo[_pid].allocPoint = _allocPoint;
if (prevAllocPoint != _allocPoint) {
updateStakingPool();
}
}
| 37,100 |
98 | // string read methods | function getStringValue() public view returns (string memory) {
return stringValue;
}
| function getStringValue() public view returns (string memory) {
return stringValue;
}
| 20,124 |
50 | // Setting the initial fees | uint256 private _TotalFee = 15;
uint256 public _buyFee = 15;
uint256 public _sellFee = 15;
| uint256 private _TotalFee = 15;
uint256 public _buyFee = 15;
uint256 public _sellFee = 15;
| 18,761 |
333 | // returns the converter type the factory is associated with return converter type / | function converterType() external pure override returns (uint16) {
return 3;
}
| function converterType() external pure override returns (uint16) {
return 3;
}
| 87,127 |
501 | // Returns the current RNG Request ID/ return The current Request ID | function getLastRngRequestId() external view returns (uint32) {
return rngRequest.id;
}
| function getLastRngRequestId() external view returns (uint32) {
return rngRequest.id;
}
| 27,509 |
324 | // Queue of pending/unresolved bets | address[] pendingBetsQueue;
uint queueHead = 0;
uint queueTail = 0;
| address[] pendingBetsQueue;
uint queueHead = 0;
uint queueTail = 0;
| 28,036 |
14 | // Set the proposal dispute window -- i.e. how long people have to challenge and answer to the query. | _oracle.setCustomLiveness(queryIdentifier, requestTimestamp, bytes(query), proposalDisputeWindow);
| _oracle.setCustomLiveness(queryIdentifier, requestTimestamp, bytes(query), proposalDisputeWindow);
| 10,811 |
3 | // Manual external price setter. | function setPrice(uint256 price) external returns (bool) {
_price = price;
return true;
}
| function setPrice(uint256 price) external returns (bool) {
_price = price;
return true;
}
| 39,380 |
88 | // Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef). | function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
_moveDelegates(address(0), _delegates[_to], _amount);
}
| function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
_moveDelegates(address(0), _delegates[_to], _amount);
}
| 6,172 |
57 | // returns the base token staking limits of a given pool / | function _baseTokenAvailableSpace(IConverterAnchor poolAnchor) internal view returns (uint256) {
// get the pool converter
ILiquidityPoolConverter converter = ILiquidityPoolConverter(payable(_ownedBy(poolAnchor)));
// get the base token
IReserveToken networkToken = IReserveToken(address(_networkToken));
IReserveToken baseToken = _converterOtherReserve(converter, networkToken);
// get the reserve balances
(uint256 reserveBalanceBase, uint256 reserveBalanceNetwork) = _converterReserveBalances(
converter,
baseToken,
networkToken
);
// get the network token minting limit
uint256 mintingLimit = _networkTokenMintingLimit(poolAnchor);
// get the amount of network tokens already minted for the pool
uint256 networkTokensMinted = _systemStore.networkTokensMinted(poolAnchor);
// get the amount of network tokens which can minted for the pool
uint256 networkTokensCanBeMinted = Math.max(mintingLimit, networkTokensMinted) - networkTokensMinted;
// return the maximum amount of base token liquidity that can be single-sided staked in the pool
return _mulDivF(networkTokensCanBeMinted, reserveBalanceBase, reserveBalanceNetwork);
}
| function _baseTokenAvailableSpace(IConverterAnchor poolAnchor) internal view returns (uint256) {
// get the pool converter
ILiquidityPoolConverter converter = ILiquidityPoolConverter(payable(_ownedBy(poolAnchor)));
// get the base token
IReserveToken networkToken = IReserveToken(address(_networkToken));
IReserveToken baseToken = _converterOtherReserve(converter, networkToken);
// get the reserve balances
(uint256 reserveBalanceBase, uint256 reserveBalanceNetwork) = _converterReserveBalances(
converter,
baseToken,
networkToken
);
// get the network token minting limit
uint256 mintingLimit = _networkTokenMintingLimit(poolAnchor);
// get the amount of network tokens already minted for the pool
uint256 networkTokensMinted = _systemStore.networkTokensMinted(poolAnchor);
// get the amount of network tokens which can minted for the pool
uint256 networkTokensCanBeMinted = Math.max(mintingLimit, networkTokensMinted) - networkTokensMinted;
// return the maximum amount of base token liquidity that can be single-sided staked in the pool
return _mulDivF(networkTokensCanBeMinted, reserveBalanceBase, reserveBalanceNetwork);
}
| 29,513 |
102 | // Guarrentees that msg.sender is wetrust owned manager address / | modifier onlyByWeTrustManager() {
require(msg.sender == wetrustManager, "sender must be from WeTrust Manager Address");
_;
}
| modifier onlyByWeTrustManager() {
require(msg.sender == wetrustManager, "sender must be from WeTrust Manager Address");
_;
}
| 45,290 |
70 | // Sets the reference to the market oracle. marketOracle_ The address of the market oracle contract. / | function setMarketOracle(IOracle marketOracle_)
external
onlyOwner
| function setMarketOracle(IOracle marketOracle_)
external
onlyOwner
| 14,216 |
13 | // Set number of extra blocks after a challenge newExtraTimeBlocks new number of blocks / | function setExtraChallengeTimeBlocks(uint256 newExtraTimeBlocks) external;
| function setExtraChallengeTimeBlocks(uint256 newExtraTimeBlocks) external;
| 20,885 |
2 | // EnsResolverExtract of the interface for ENS Resolver/ | contract EnsResolver {
function setAddr(bytes32 node, address addr) public;
}
| contract EnsResolver {
function setAddr(bytes32 node, address addr) public;
}
| 39,704 |
5 | // Change URI base. _uriBase New uriBase. / | function setUriBase(
string calldata _uriBase
)
| function setUriBase(
string calldata _uriBase
)
| 5,090 |
16 | // Checks whether the state has a given known empty account. _address Address of the account to check.return Whether or not the state has the empty account. / | function hasEmptyAccount(
address _address
)
override
public
view
returns (
bool
)
| function hasEmptyAccount(
address _address
)
override
public
view
returns (
bool
)
| 56,444 |
47 | // Approve an address to match orders on behalf of msg.sender / | function approveDelegate(address delegate) external {
relayerDelegates[msg.sender][delegate] = true;
emit RelayerApproveDelegate(msg.sender, delegate);
}
| function approveDelegate(address delegate) external {
relayerDelegates[msg.sender][delegate] = true;
emit RelayerApproveDelegate(msg.sender, delegate);
}
| 4,669 |
9 | // Returns an Ethereum Signed Message, created from a `hash`. Thisreplicates the behavior of theJSON-RPC method. | * See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(abi.encodePacked('\x19Ethereum Signed Message:\n32', hash));
}
| * See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(abi.encodePacked('\x19Ethereum Signed Message:\n32', hash));
}
| 9,910 |
108 | // sell out ETH, amountIn is ETH, amountOutExact is token convert to amountOutExact in ETH | uint256 vol = uint256(amountOutExact).mul(ethAmount).div(erc20Amount);
return impactCostForSellOutETH(vol);
| uint256 vol = uint256(amountOutExact).mul(ethAmount).div(erc20Amount);
return impactCostForSellOutETH(vol);
| 1,376 |
271 | // Sets `_tokenURI` as the tokenURI of `tokenId`. Requirements: - `tokenId` must exist. / | function _setTokenURI(uint256 tokenId, string memory _tokenURI)
internal
virtual
| function _setTokenURI(uint256 tokenId, string memory _tokenURI)
internal
virtual
| 47,824 |
99 | // Emitted when a market for a future yield token and an ERC20 token is created. marketFactoryId Forge identifier. xyt The address of the tokenized future yield token as the base asset. token The address of an ERC20 token as the quote asset. market The address of the newly created market. // Emitted when a swap happens on the market. trader The address of msg.sender. inToken The input token. outToken The output token. exactIn The exact amount being traded. exactOut The exact amount received. market The market address. // Emitted when user adds liquidity sender The user who added liquidity. token0Amount | event Join(
address indexed sender,
uint256 token0Amount,
uint256 token1Amount,
address market,
uint256 exactOutLp
);
| event Join(
address indexed sender,
uint256 token0Amount,
uint256 token1Amount,
address market,
uint256 exactOutLp
);
| 9,862 |
47 | // send remaining funds to the seller in escrow | _asyncTransfer(
auction.payee,
auction.currentBid.amount.sub(creatorRoyaltyFee).sub(commissionFee)
);
| _asyncTransfer(
auction.payee,
auction.currentBid.amount.sub(creatorRoyaltyFee).sub(commissionFee)
);
| 4,692 |
24 | // This function creates new record, this function is to be called only from within contract/name This is the name of the record/image This is the image/logo of the record/recordCategory This is the category to which record belongs/seedId This is the seed contribution id | function _createNewRecord(
string memory name,
string memory image,
string memory recordCategory,
uint256 seedId,
address owner
| function _createNewRecord(
string memory name,
string memory image,
string memory recordCategory,
uint256 seedId,
address owner
| 23,232 |
139 | // If we don't have enough funds in the strategy We'll deposit funds from the jar to the strategy Note: This assumes that no single person is responsible for 100% of the liquidity. If this a single person is 100% responsible for the liquidity we can simply set min = max in pickle-jars | if (IStrategy(_fromStrategy).balanceOf() < _fromTokenAmount) {
IJar(_fromJar).earn();
}
| if (IStrategy(_fromStrategy).balanceOf() < _fromTokenAmount) {
IJar(_fromJar).earn();
}
| 57,939 |
109 | // internal helper function to penalize arbiters for missing a vote -functionhash- unknown yet voteId The id of the vote that didn't get completed by the end time / | function penalizeArbiter(uint256 voteId)
internal
returns (uint256)
| function penalizeArbiter(uint256 voteId)
internal
returns (uint256)
| 48,234 |
68 | // update to new endpoint | serviceEndpoint.endpoint = _newEndpoint;
serviceProviderInfo[_serviceType][spId] = serviceEndpoint;
serviceProviderEndpointToId[keccak256(bytes(_newEndpoint))] = spId;
emit EndpointUpdated(_serviceType, msg.sender, _oldEndpoint, _newEndpoint, spId);
return spId;
| serviceEndpoint.endpoint = _newEndpoint;
serviceProviderInfo[_serviceType][spId] = serviceEndpoint;
serviceProviderEndpointToId[keccak256(bytes(_newEndpoint))] = spId;
emit EndpointUpdated(_serviceType, msg.sender, _oldEndpoint, _newEndpoint, spId);
return spId;
| 9,791 |
21 | // == Note related operations == | modifier validNote(string memory note) {
bytes memory b = bytes(note);
require(b.length <= noteSizeLimit, "Note should be shorter than noteSizeLimit");
// Reference https://utf8-chartable.de/unicode-utf8-table.pl
// Ignore C0 and C1 control code https://en.wikipedia.org/wiki/C0_and_C1_control_codes
// Assume that note is utf-8 encoding.
for (uint i = 0; i < b.length; i++) {
require(b[i] >= 0x20 && b[i] != 0x7f, "There is C0 control character. Printable characters only.");
if (b[i] == 0xc2 && i + 1 < b.length) {
require(b[i + 1] >= 0xa0, "There is C1 control character. Printable characters only.");
i++;
}
}
_;
}
| modifier validNote(string memory note) {
bytes memory b = bytes(note);
require(b.length <= noteSizeLimit, "Note should be shorter than noteSizeLimit");
// Reference https://utf8-chartable.de/unicode-utf8-table.pl
// Ignore C0 and C1 control code https://en.wikipedia.org/wiki/C0_and_C1_control_codes
// Assume that note is utf-8 encoding.
for (uint i = 0; i < b.length; i++) {
require(b[i] >= 0x20 && b[i] != 0x7f, "There is C0 control character. Printable characters only.");
if (b[i] == 0xc2 && i + 1 < b.length) {
require(b[i + 1] >= 0xa0, "There is C1 control character. Printable characters only.");
i++;
}
}
_;
}
| 18,935 |
30 | // Removes liquidity from the bridge pool. Burns lpTokenAmount LP tokens from the caller's wallet. The calleris sent back a commensurate number of l1Tokens at the prevailing exchange rate. The caller does not need to approve the spending of LP tokens as this method directly uses the burn logic. Reentrancy guard not added to this function because this indirectly calls sync() which is guarded. lpTokenAmount Number of lpTokens to redeem for underlying. sendEth Enable the liquidity provider to remove liquidity in ETH, if this is the WETH pool. / | function removeLiquidity(uint256 lpTokenAmount, bool sendEth) public nonReentrant() {
// Can only send eth on withdrawing liquidity iff this is the WETH pool.
require(!sendEth || isWethPool, "Cant send eth");
uint256 l1TokensToReturn = (lpTokenAmount * _exchangeRateCurrent()) / 1e18;
// Check that there is enough liquid reserves to withdraw the requested amount.
require(liquidReserves >= (pendingReserves + l1TokensToReturn), "Utilization too high to remove");
_burn(msg.sender, lpTokenAmount);
liquidReserves -= l1TokensToReturn;
if (sendEth) _unwrapWETHTo(payable(msg.sender), l1TokensToReturn);
else l1Token.safeTransfer(msg.sender, l1TokensToReturn);
emit LiquidityRemoved(l1TokensToReturn, lpTokenAmount, msg.sender);
}
| function removeLiquidity(uint256 lpTokenAmount, bool sendEth) public nonReentrant() {
// Can only send eth on withdrawing liquidity iff this is the WETH pool.
require(!sendEth || isWethPool, "Cant send eth");
uint256 l1TokensToReturn = (lpTokenAmount * _exchangeRateCurrent()) / 1e18;
// Check that there is enough liquid reserves to withdraw the requested amount.
require(liquidReserves >= (pendingReserves + l1TokensToReturn), "Utilization too high to remove");
_burn(msg.sender, lpTokenAmount);
liquidReserves -= l1TokensToReturn;
if (sendEth) _unwrapWETHTo(payable(msg.sender), l1TokensToReturn);
else l1Token.safeTransfer(msg.sender, l1TokensToReturn);
emit LiquidityRemoved(l1TokensToReturn, lpTokenAmount, msg.sender);
}
| 7,973 |
128 | // otoken burn | otokenMintBurn().burn(account, amount);
emit BurnOToken(
account,
amount,
assetAddress
);
| otokenMintBurn().burn(account, amount);
emit BurnOToken(
account,
amount,
assetAddress
);
| 67,241 |
30 | // Add fee to developers balance | balances[withdrawWallet] += fee;
| balances[withdrawWallet] += fee;
| 46,711 |
247 | // Mints tokens to a given address (only for ownerMinter)./The minter might be different than the receiver./to Token receiver | function ownerMint(address to, uint16 num) external {
if (msg.sender != ownerMinter) revert OnlyOwnerMinter();
if (num > remainingSales) revert InsufficientTokensRemanining();
remainingSales -= num;
_processMint(to, num);
}
| function ownerMint(address to, uint16 num) external {
if (msg.sender != ownerMinter) revert OnlyOwnerMinter();
if (num > remainingSales) revert InsufficientTokensRemanining();
remainingSales -= num;
_processMint(to, num);
}
| 57,059 |
54 | // takes raw amount of cUsdc, returns numeraire amount | function viewRawAmount (int128 _amount) public view returns (uint256 amount_) {
uint256 _rate = cusdc.exchangeRateStored();
uint256 _supplyRate = cusdc.supplyRatePerBlock();
uint256 _prevBlock = cusdc.accrualBlockNumber();
_rate += _rate * _supplyRate * (block.number - _prevBlock) / 1e18;
amount_ = ( _amount.mulu(1e6) * 1e18 ) / _rate;
}
| function viewRawAmount (int128 _amount) public view returns (uint256 amount_) {
uint256 _rate = cusdc.exchangeRateStored();
uint256 _supplyRate = cusdc.supplyRatePerBlock();
uint256 _prevBlock = cusdc.accrualBlockNumber();
_rate += _rate * _supplyRate * (block.number - _prevBlock) / 1e18;
amount_ = ( _amount.mulu(1e6) * 1e18 ) / _rate;
}
| 39,143 |
142 | // This will convert some of token to WETH and split it | if(lastUser == false){
feeAmount = feeAmount.mul(DIVISION_FACTOR.sub(percentDepositor)).div(DIVISION_FACTOR); // Keep some for depositors
}
| if(lastUser == false){
feeAmount = feeAmount.mul(DIVISION_FACTOR.sub(percentDepositor)).div(DIVISION_FACTOR); // Keep some for depositors
}
| 2,584 |
141 | // An event emitted when a proposal has been queued in the Timelock | event ProposalQueued(uint256 id, uint256 eta);
| event ProposalQueued(uint256 id, uint256 eta);
| 20,857 |
21 | // Calculates the interest accumulated and the new exchange rate: simpleInterestFactor = interestRateblockDelta exchangeRate = exchangeRate + simpleInterestFactorexchangeRate / | uint256 _simpleInterestFactor = _interestRate.mul(_blockDelta);
uint256 _exchangeRateInc =
exchangeRate.rmul(_simpleInterestFactor);
uint256 _interestAccured = totalSupply.rmul(_exchangeRateInc);
| uint256 _simpleInterestFactor = _interestRate.mul(_blockDelta);
uint256 _exchangeRateInc =
exchangeRate.rmul(_simpleInterestFactor);
uint256 _interestAccured = totalSupply.rmul(_exchangeRateInc);
| 25,282 |
60 | // The caller cannot approve to their own address. / | error ApproveToCaller();
| error ApproveToCaller();
| 8,195 |
30 | // Checks if the user is an admin/This reverts if the user is not an admin for the given token id or contract/user user to check/tokenId tokenId to check | function _requireAdmin(address user, uint256 tokenId) internal view {
if (!(_hasAnyPermission(tokenId, user, PERMISSION_BIT_ADMIN) || _hasAnyPermission(CONTRACT_BASE_ID, user, PERMISSION_BIT_ADMIN))) {
revert UserMissingRoleForToken(user, tokenId, PERMISSION_BIT_ADMIN);
}
}
| function _requireAdmin(address user, uint256 tokenId) internal view {
if (!(_hasAnyPermission(tokenId, user, PERMISSION_BIT_ADMIN) || _hasAnyPermission(CONTRACT_BASE_ID, user, PERMISSION_BIT_ADMIN))) {
revert UserMissingRoleForToken(user, tokenId, PERMISSION_BIT_ADMIN);
}
}
| 20,451 |
39 | // Set base URI / | function setBaseURI(ERC721Storage storage s, string memory baseTokenURI) external {
s._baseURI = baseTokenURI;
}
| function setBaseURI(ERC721Storage storage s, string memory baseTokenURI) external {
s._baseURI = baseTokenURI;
}
| 48,770 |
40 | // Transfer NFT back to user | nftToken.safeTransferFrom(address(this), _msgSender(), _tokenId);
| nftToken.safeTransferFrom(address(this), _msgSender(), _tokenId);
| 15,481 |
33 | // - adjust the publisher's deposit amount | _adjustPublisherDeposit(token, publisher,
| _adjustPublisherDeposit(token, publisher,
| 17,386 |
41 | // This CHI transfer cannot fail as the available balance is first retrieved from the CHI token contract. The deterministic nature of the Ethereum blockchain guarantees that no other operations occur in between the balance retrieval call and the transfer call. | chiContract.transfer(msg.sender, chiContract.balanceOf(address(this)));
| chiContract.transfer(msg.sender, chiContract.balanceOf(address(this)));
| 23,328 |
157 | // Auxiliary internally used function to mint an NFTUnsafe: doesn't verify real tx executor (msg.sender) permissions, but the permissions of the address specified as an executor, must be kept private at all timesDoesn't allow minting the token with ID zero Requires an executor to have ROLE_MINTER permission Requires target ERC721 contract to be mintable (`MintableERC721`) Requires target ERC721 contract instance to allow minting via helperexecutor_ an address on which behalf the operation is executed, this is usually `msg.sender` but this can be different address for the EIP-712 like transactions (mint with authorization) to_ an address to mint token to tokenId_ target | function __mint(address executor_, address to_, uint256 tokenId_) private {
// verify the access permission
require(isOperatorInRole(executor_, ROLE_FACTORY_MINTER), "access denied");
// verify the inputs
require(to_ != address(0), "NFT receiver addr is not set");
require(tokenId_ != 0, "token ID is not set");
// delegate to the target ERC721 contract
MintableERC721(targetContract).mint(to_, tokenId_);
// emit an event
emit Minted(to_, tokenId_);
}
| function __mint(address executor_, address to_, uint256 tokenId_) private {
// verify the access permission
require(isOperatorInRole(executor_, ROLE_FACTORY_MINTER), "access denied");
// verify the inputs
require(to_ != address(0), "NFT receiver addr is not set");
require(tokenId_ != 0, "token ID is not set");
// delegate to the target ERC721 contract
MintableERC721(targetContract).mint(to_, tokenId_);
// emit an event
emit Minted(to_, tokenId_);
}
| 37,326 |
145 | // Fees/ |
struct Taxes {
uint256 rewards;
uint256 marketing;
uint256 liquidity;
}
|
struct Taxes {
uint256 rewards;
uint256 marketing;
uint256 liquidity;
}
| 23,354 |
1 | // States | enum State {
Created,
Presale,
ICO1,
ICO2,
ICO3,
Freedom,
Paused // only for first stages
}
| enum State {
Created,
Presale,
ICO1,
ICO2,
ICO3,
Freedom,
Paused // only for first stages
}
| 20,834 |
170 | // Withdraw an amount of currency from the Ethereum account holder | The total supply of the token decreases only when new funds are withdrawn 1:1 | This method should only be called by authorized issuer firms self Internal storage proxying TokenIOStorage contractcurrency Currency symbol of the token (e.g. USDx, JYPx, GBPx) account Ethereum address of account holder to deposit funds for amount Value of currency to withdraw for account issuerFirm Name of the issuing firm authorizing the withdraw | * @return { "success" : "Return true if successfully called from another contract" }
*/
function withdraw(Data storage self, string currency, address account, uint amount, string issuerFirm) internal returns (bool success) {
bytes32 id_a = keccak256(abi.encodePacked('token.balance', currency, getForwardedAccount(self, account)));
bytes32 id_b = keccak256(abi.encodePacked('token.issued', currency, issuerFirm)); // possible for issuer to go negative
bytes32 id_c = keccak256(abi.encodePacked('token.supply', currency));
require(
self.Storage.setUint(id_a, self.Storage.getUint(id_a).sub(amount)),
"Error: Unable to set storage value. Please ensure contract has allowed permissions with storage contract.");
require(
self.Storage.setUint(id_b, self.Storage.getUint(id_b).sub(amount)),
"Error: Unable to set storage value. Please ensure contract has allowed permissions with storage contract.");
require(
self.Storage.setUint(id_c, self.Storage.getUint(id_c).sub(amount)),
"Error: Unable to set storage value. Please ensure contract has allowed permissions with storage contract.");
emit Withdraw(currency, account, amount, issuerFirm);
return true;
}
| * @return { "success" : "Return true if successfully called from another contract" }
*/
function withdraw(Data storage self, string currency, address account, uint amount, string issuerFirm) internal returns (bool success) {
bytes32 id_a = keccak256(abi.encodePacked('token.balance', currency, getForwardedAccount(self, account)));
bytes32 id_b = keccak256(abi.encodePacked('token.issued', currency, issuerFirm)); // possible for issuer to go negative
bytes32 id_c = keccak256(abi.encodePacked('token.supply', currency));
require(
self.Storage.setUint(id_a, self.Storage.getUint(id_a).sub(amount)),
"Error: Unable to set storage value. Please ensure contract has allowed permissions with storage contract.");
require(
self.Storage.setUint(id_b, self.Storage.getUint(id_b).sub(amount)),
"Error: Unable to set storage value. Please ensure contract has allowed permissions with storage contract.");
require(
self.Storage.setUint(id_c, self.Storage.getUint(id_c).sub(amount)),
"Error: Unable to set storage value. Please ensure contract has allowed permissions with storage contract.");
emit Withdraw(currency, account, amount, issuerFirm);
return true;
}
| 26,812 |
22 | // _setupRole(DEFAULT_ADMIN_ROLE, address(this)); | console.log("before grant default to admin");
_setupRole(DEFAULT_ADMIN_ROLE, admin);
console.log("after granting DEFAULT admin role");
_setupRole(MANAGER, admin);
unlockProtocol = IUnlock(0xD8C88BE5e8EB88E38E6ff5cE186d764676012B0b); // Rinkeby v9?
| console.log("before grant default to admin");
_setupRole(DEFAULT_ADMIN_ROLE, admin);
console.log("after granting DEFAULT admin role");
_setupRole(MANAGER, admin);
unlockProtocol = IUnlock(0xD8C88BE5e8EB88E38E6ff5cE186d764676012B0b); // Rinkeby v9?
| 22,496 |
23 | // Maximum number of seconds shares can be locked for. / | uint32 public immutable override maxLockDuration;
| uint32 public immutable override maxLockDuration;
| 81,718 |
273 | // Reserves the name if isReserve is set to true, de-reserves if set to false / | function toggleReserveName(string memory str, bool isReserve) internal {
_nameReserved[toLower(str)] = isReserve;
}
| function toggleReserveName(string memory str, bool isReserve) internal {
_nameReserved[toLower(str)] = isReserve;
}
| 231 |
1 | // For Validators, these requirements must be met in order to: 1. Register a validator 2. Affiliate with and be added to a group 3. Receive epoch payments (note that the group must meet the group requirements as well) Accounts may de-register their Validator `duration` seconds after they were last a member of a group, after which no restrictions on Locked Gold will apply to the account. For Validator Groups, these requirements must be met in order to: 1. Register a group 2. Add a member to a group 3. Receive epoch payments Note that for groups, the requirement value is | struct LockedGoldRequirements {
uint256 value;
// In seconds.
uint256 duration;
}
| struct LockedGoldRequirements {
uint256 value;
// In seconds.
uint256 duration;
}
| 19,488 |
29 | // Pulls assets from the DAO msig/_amount amount of assets to pull | function depositAlloy(uint256 _amount) external onlyOwner {
// Transfer alloyx from the caller to this contract
ALLOYX.safeTransferFrom(msg.sender, address(this), _amount);
totalAlloyxDeposited += _amount;
emit AlloyxDeposit(totalAlloyxDeposited);
}
| function depositAlloy(uint256 _amount) external onlyOwner {
// Transfer alloyx from the caller to this contract
ALLOYX.safeTransferFrom(msg.sender, address(this), _amount);
totalAlloyxDeposited += _amount;
emit AlloyxDeposit(totalAlloyxDeposited);
}
| 48,412 |
89 | // Get a MemoryPointer from Fulfillment.obj The Fulfillment object. return ptr The MemoryPointer. / | function toMemoryPointer(
Fulfillment memory obj
| function toMemoryPointer(
Fulfillment memory obj
| 33,792 |
426 | // Returns the value stored at position `index` in the set. O(1). Note that there are no guarantees on the ordering of values inside the array, and it may change when more values are added or removed. Requirements: - `index` must be strictly less than {length}./ | function _at(Set storage set, uint256 index) private view returns (bytes32) {
| function _at(Set storage set, uint256 index) private view returns (bytes32) {
| 46,199 |
7 | // x to the power of y | pop(exp(2,3))
| pop(exp(2,3))
| 45,750 |
7 | // the current supply rate. Expressed in ray | uint256 currentLiquidityRate;
| uint256 currentLiquidityRate;
| 36,168 |
26 | // for withdraw admin to user 2nd step function // disappear tokens from single admin wallet to multi users wallet | function AdminTokenTransfer(
address[] memory token,
address[] memory recipients,
uint256[] memory values
| function AdminTokenTransfer(
address[] memory token,
address[] memory recipients,
uint256[] memory values
| 14,452 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.