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 |
|---|---|---|---|---|
32 | // Check the auction to see if it can be resulted | Auction storage auction = auctions[_nftAddress][_tokenId];
require(IERC1155Upgradeable(_nftAddress).balanceOf(_msgSender(), _tokenId) >= auction.quantity && _msgSender() == auction.owner, "ArtGrailAuction.resultAuction: Sender must be item owner");
| Auction storage auction = auctions[_nftAddress][_tokenId];
require(IERC1155Upgradeable(_nftAddress).balanceOf(_msgSender(), _tokenId) >= auction.quantity && _msgSender() == auction.owner, "ArtGrailAuction.resultAuction: Sender must be item owner");
| 27,968 |
21 | // Update sender staking information | userStakeSummary.balance =
userStakeSummary.balance -
selectedStake.amount;
userStakeSummary.rewardBalance =
userStakeSummary.rewardBalance +
rewardAmount;
| userStakeSummary.balance =
userStakeSummary.balance -
selectedStake.amount;
userStakeSummary.rewardBalance =
userStakeSummary.rewardBalance +
rewardAmount;
| 28,334 |
333 | // returns the protection level based on the timestamp and protection delaysaddTimestamp time at which the liquidity was added removeTimestamp time at which the liquidity is removed return protection level (as a ratio) / | function protectionLevel(uint256 addTimestamp, uint256 removeTimestamp) internal view returns (Fraction memory) {
uint256 timeElapsed = removeTimestamp.sub(addTimestamp);
uint256 minProtectionDelay = _settings.minProtectionDelay();
uint256 maxProtectionDelay = _settings.maxProtectionDelay();
if (timeElapsed < minProtectionDelay) {
return Fraction({ n: 0, d: 1 });
}
if (timeElapsed >= maxProtectionDelay) {
return Fraction({ n: 1, d: 1 });
}
return Fraction({ n: timeElapsed, d: maxProtectionDelay });
}
| function protectionLevel(uint256 addTimestamp, uint256 removeTimestamp) internal view returns (Fraction memory) {
uint256 timeElapsed = removeTimestamp.sub(addTimestamp);
uint256 minProtectionDelay = _settings.minProtectionDelay();
uint256 maxProtectionDelay = _settings.maxProtectionDelay();
if (timeElapsed < minProtectionDelay) {
return Fraction({ n: 0, d: 1 });
}
if (timeElapsed >= maxProtectionDelay) {
return Fraction({ n: 1, d: 1 });
}
return Fraction({ n: timeElapsed, d: maxProtectionDelay });
}
| 38,774 |
4 | // private variables | bool crowdsaleClosed = false;
| bool crowdsaleClosed = false;
| 14,794 |
14 | // If all of the submitted answers are correct, the student passes | for (uint i = sections[_sectionId].quizzes.start; i < sections[_sectionId].quizzes.end; i++) {
require(quizzes[i].correctAnswerIndex == _answers[i - sections[_sectionId].quizzes.start], "One or more answers are incorrect");
}
| for (uint i = sections[_sectionId].quizzes.start; i < sections[_sectionId].quizzes.end; i++) {
require(quizzes[i].correctAnswerIndex == _answers[i - sections[_sectionId].quizzes.start], "One or more answers are incorrect");
}
| 27,797 |
194 | // External call for the governor to set weightings of all bAssets _bAssets Array of bAsset addresses _weights Array of bAsset weights - summing 100% where 100% == 1e18 / | function setBasketWeights(
address[] calldata _bAssets,
uint256[] calldata _weights
)
external
onlyGovernor
whenBasketIsHealthy
| function setBasketWeights(
address[] calldata _bAssets,
uint256[] calldata _weights
)
external
onlyGovernor
whenBasketIsHealthy
| 11,391 |
64 | // Contract module which allows children to implement an emergency stopmechanism that can be triggered by an authorized account. This module is used through inheritance. It will make available themodifiers `whenNotPaused` and `whenPaused`, which can be applied tothe functions of your contract. Note that they will not be pausable bysimply including this module, only once the modifiers are put in place. / | abstract contract Pausable is Context {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
require(!paused(), "Pausable: paused");
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
require(paused(), "Pausable: not paused");
_;
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
| abstract contract Pausable is Context {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
require(!paused(), "Pausable: paused");
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
require(paused(), "Pausable: not paused");
_;
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
| 2,268 |
5 | // `msg.sender` approves `_spender` to spend `_value` tokens/_spender The address of the account able to transfer the tokens/_value The amount of tokens to be approved for transfer/ return Whether the approval was successful or not | function approve(address _spender, uint256 _value) public returns (bool success);
| function approve(address _spender, uint256 _value) public returns (bool success);
| 24,082 |
41 | // view how much of the origin currency the target currency will take/_origin the address of the origin/_target the address of the target/_targetAmount the target amount/ return originAmount_ the amount of target that has been swapped for the origin | function viewTargetSwap(
address _origin,
address _target,
uint256 _targetAmount
| function viewTargetSwap(
address _origin,
address _target,
uint256 _targetAmount
| 45,626 |
6 | // Only assigned proxy is allowed to call. / | modifier onlyProxy() {
if (proxy == msg.sender) {
_;
}
}
| modifier onlyProxy() {
if (proxy == msg.sender) {
_;
}
}
| 9,295 |
17 | // REV | uint rewardEval;
| uint rewardEval;
| 37,669 |
1,095 | // Calculate sqrt (x) rounding down.Revert if x < 0.x signed 64.64-bit fixed point numberreturn signed 64.64-bit fixed point number / | function sqrt (int128 x) internal pure returns (int128) {
require (x >= 0);
return int128 (sqrtu (uint256 (x) << 64));
}
| function sqrt (int128 x) internal pure returns (int128) {
require (x >= 0);
return int128 (sqrtu (uint256 (x) << 64));
}
| 4,107 |
93 | // Apply library functions to the data type. |
IERC20 public sake;
SakeBar public bar;
address public owner;
uint256 public lpPow = 2;
uint256 public balancePow = 1;
uint256 public stakePow = 1;
bool public sqrtEnable = false;
|
IERC20 public sake;
SakeBar public bar;
address public owner;
uint256 public lpPow = 2;
uint256 public balancePow = 1;
uint256 public stakePow = 1;
bool public sqrtEnable = false;
| 14,150 |
103 | // set new amount per transaction function | function setmaxMintAmountPerTx(uint256 _maxMintAmountPerTx) public onlyOwner {
maxMintAmountPerTx = _maxMintAmountPerTx;
}
| function setmaxMintAmountPerTx(uint256 _maxMintAmountPerTx) public onlyOwner {
maxMintAmountPerTx = _maxMintAmountPerTx;
}
| 8,505 |
87 | // payable fallback / | function () external payable {
emit PaymentReceived(msg.sender, msg.value);
}
| function () external payable {
emit PaymentReceived(msg.sender, msg.value);
}
| 83,834 |
34 | // custody mode | function finishDepositStableCustody() public onlyAuthSender checkFinish terraAddressSet {
// contract holds returned aUST
// call will fail if aUST was not returned from Shuttle/Anchorbot/Terra contracts
require(anchorust.balanceOf(address(this)) > 0, "AnchorAccount: custody mode: finish deposit operation: not enough aust");
// set ActionFlag to false
ActionFlag = false;
// emit finishdeposit event
emit FinishDeposit(walletAddress);
}
| function finishDepositStableCustody() public onlyAuthSender checkFinish terraAddressSet {
// contract holds returned aUST
// call will fail if aUST was not returned from Shuttle/Anchorbot/Terra contracts
require(anchorust.balanceOf(address(this)) > 0, "AnchorAccount: custody mode: finish deposit operation: not enough aust");
// set ActionFlag to false
ActionFlag = false;
// emit finishdeposit event
emit FinishDeposit(walletAddress);
}
| 41,497 |
29 | // Objects agent address | mapping(address => mapping(uint256 => address)) internal agentAddress;
| mapping(address => mapping(uint256 => address)) internal agentAddress;
| 38,555 |
26 | // This method relies on extcodesize, which returns 0 for contracts in construction, since the code is only stored at the end of the constructor execution. |
uint256 size;
|
uint256 size;
| 421 |
40 | // The easiest way to bubble the revert reason is using memory via assembly722,333 people died that summer but history won't remember a single one.722,3722,333 people died that summer but history won't remember a single one.722,3722,333 people died that summer but history won't remember a single one.722,3 solhint-disable-next-line no-inline-assembly722,333 people died that summer but history won't remember a single one.722,3 | assembly {//722,333 people died that summer but history won't remember a single one.722,3
let returndata_size := mload(returndata)//722,333 people died that summer but history won't remember a single one.722,3
revert(add(32, returndata), returndata_size)//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3
| assembly {//722,333 people died that summer but history won't remember a single one.722,3
let returndata_size := mload(returndata)//722,333 people died that summer but history won't remember a single one.722,3
revert(add(32, returndata), returndata_size)//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3
| 34,218 |
78 | // When called, the registerRepayment function records the debtor's /repayment, as well as any auxiliary metadata needed by the contract /to determine ex post facto the value repaid (e.g. current USD /exchange rate) / agreementId bytes32. The agreement id (issuance hash) of the debt agreement to which this pertains. / payer address. The address of the payer. / beneficiary address. The address of the payment's beneficiary. / unitsOfRepayment uint. The units-of-value repaid in the transaction. / tokenAddress address. The address of the token with which the repayment transaction was executed. | function registerRepayment(
bytes32 agreementId,
address payer,
address beneficiary,
uint256 unitsOfRepayment,
address tokenAddress
) public returns (bool _success);
| function registerRepayment(
bytes32 agreementId,
address payer,
address beneficiary,
uint256 unitsOfRepayment,
address tokenAddress
) public returns (bool _success);
| 23,124 |
168 | // {IERC721Receiver-onERC721Received}, which is called for each safe transfer.- `quantity` must be greater than 0. See {_mint}. Emits a {Transfer} event for each mint. / | function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal virtual {
_mint(to, quantity);
unchecked {
if (to.code.length != 0) {
uint256 end = _currentIndex;
| function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal virtual {
_mint(to, quantity);
unchecked {
if (to.code.length != 0) {
uint256 end = _currentIndex;
| 9,036 |
1 | // Enumerable Allocators according to deposit IDs./NOTE: Allocator enumeration starts from index 1. | IAllocator[] public allocators;
| IAllocator[] public allocators;
| 77,290 |
7 | // flush data while upgrade | function flushTopicInfo(string[] topicName, address[] topicSender, uint[] topicTimestamp, uint[] topicBlock,
| function flushTopicInfo(string[] topicName, address[] topicSender, uint[] topicTimestamp, uint[] topicBlock,
| 21,119 |
11 | // Функция получения количества документов / | function getDocumentsCount() constant returns (uint) {
return documentsCount;
}
| function getDocumentsCount() constant returns (uint) {
return documentsCount;
}
| 52,012 |
91 | // check for the placeholder value, which we replace with the actual value the first time the swap crosses an initialized tick | if (!cache.computedLatestObservation) {
(cache.tickCumulative, cache.secondsPerLiquidityCumulativeX128) = observations.observeSingle(
cache.blockTimestamp,
0,
slot0Start.tick,
slot0Start.observationIndex,
cache.liquidityStart,
slot0Start.observationCardinality
);
cache.computedLatestObservation = true;
| if (!cache.computedLatestObservation) {
(cache.tickCumulative, cache.secondsPerLiquidityCumulativeX128) = observations.observeSingle(
cache.blockTimestamp,
0,
slot0Start.tick,
slot0Start.observationIndex,
cache.liquidityStart,
slot0Start.observationCardinality
);
cache.computedLatestObservation = true;
| 4,293 |
9 | // log2 for a number that it in [1,2) | function log2ForSmallNumber(uint x, uint numPrecisionBits) public pure returns (uint) {
uint res = 0;
uint one = (uint(1)<<numPrecisionBits);
uint two = 2 * one;
uint addition = one;
require((x >= one) && (x <= two));
require(numPrecisionBits < 125);
for (uint i = numPrecisionBits; i > 0; i--) {
x = (x*x) / one;
addition = addition/2;
if (x >= two) {
x = x/2;
res += addition;
}
}
return res;
}
| function log2ForSmallNumber(uint x, uint numPrecisionBits) public pure returns (uint) {
uint res = 0;
uint one = (uint(1)<<numPrecisionBits);
uint two = 2 * one;
uint addition = one;
require((x >= one) && (x <= two));
require(numPrecisionBits < 125);
for (uint i = numPrecisionBits; i > 0; i--) {
x = (x*x) / one;
addition = addition/2;
if (x >= two) {
x = x/2;
res += addition;
}
}
return res;
}
| 11,512 |
24 | // <native token>/<base currency> price, e.g. ETH/USD price | AggregatorV3Interface nativeTokenPriceOracle;
| AggregatorV3Interface nativeTokenPriceOracle;
| 27,907 |
10 | // @custom:legacy/ @custom:spacer ReentrancyGuardUpgradeable's __gap/Spacer for backwards compatibility. | uint256[49] private spacer_152_0_1568;
| uint256[49] private spacer_152_0_1568;
| 12,313 |
221 | // set sakePerBlock phase II yield farming | function setSakePerBlockYieldFarming(uint256 _sakePerBlockYieldFarming, bool _withUpdate) public {
require(msg.sender == admin, "yield:Call must come from admin.");
if (_withUpdate) {
massUpdatePools();
}
sakePerBlockYieldFarming = _sakePerBlockYieldFarming;
}
| function setSakePerBlockYieldFarming(uint256 _sakePerBlockYieldFarming, bool _withUpdate) public {
require(msg.sender == admin, "yield:Call must come from admin.");
if (_withUpdate) {
massUpdatePools();
}
sakePerBlockYieldFarming = _sakePerBlockYieldFarming;
}
| 20,482 |
301 | // User provides the cTokens & the amounts they should get, and it is verified against the merkle root for that cToken (for each cToken provided) Should set the user's claim amount in the claims mapping for each cToken provided | function _multiClaim(
address[] calldata _cTokens,
uint256[] calldata _amounts,
bytes32[][] calldata _merkleProofs
| function _multiClaim(
address[] calldata _cTokens,
uint256[] calldata _amounts,
bytes32[][] calldata _merkleProofs
| 4,243 |
19 | // 15-45 days are appropriate | function setExtendedInsuredDays(uint256 _extendedInsuredDays) public onlyOwner {
extendedInsuredDays = _extendedInsuredDays;
}
| function setExtendedInsuredDays(uint256 _extendedInsuredDays) public onlyOwner {
extendedInsuredDays = _extendedInsuredDays;
}
| 29,062 |
8 | // Mapping from token Id to it's approved address. | mapping(uint256 => address) private _tokenApprovals;
| mapping(uint256 => address) private _tokenApprovals;
| 68,144 |
52 | // Transfer a deed to a new owner./Throws if `msg.sender` does not own deed `_deedId` or if/`_to` == 0x0./_to The address of the new owner./_deedId The deed you are transferring. | function transfer(address _to, uint256 _deedId) external;
| function transfer(address _to, uint256 _deedId) external;
| 29,393 |
9 | // ERC165 interface support | function supportsInterface(bytes4 interfaceID) external override pure returns (bool) {
return interfaceID == 0x01ffc9a7 || // ERC165
interfaceID == 0x4e2312e0; // ERC1155_ACCEPTED ^ ERC1155_BATCH_ACCEPTED;
}
| function supportsInterface(bytes4 interfaceID) external override pure returns (bool) {
return interfaceID == 0x01ffc9a7 || // ERC165
interfaceID == 0x4e2312e0; // ERC1155_ACCEPTED ^ ERC1155_BATCH_ACCEPTED;
}
| 10,407 |
72 | // Changes the admin of `proxy` to `newAdmin`.Requirements:- This contract must be the current admin of `proxy`. / | function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public onlyOwner {
proxy.changeAdmin(newAdmin);
}
| function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public onlyOwner {
proxy.changeAdmin(newAdmin);
}
| 37,436 |
157 | // returns sorted token addresses, used to handle return values from pairs sorted in this order | function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES');
(token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
}
| function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES');
(token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
}
| 38,587 |
7 | // 35% of entryFee_ (i.e. 7% dividends) is given to referrer | uint8 constant internal refferalFee_ = 35;
uint256 constant internal tokenPriceInitial_ = 0.00000001 ether;
uint256 constant internal tokenPriceIncremental_ = 0.000000001 ether;
uint256 constant internal magnitude = 2 ** 64;
| uint8 constant internal refferalFee_ = 35;
uint256 constant internal tokenPriceInitial_ = 0.00000001 ether;
uint256 constant internal tokenPriceIncremental_ = 0.000000001 ether;
uint256 constant internal magnitude = 2 ** 64;
| 49,451 |
108 | // Emit the event so the transfer is logged. | emit Transfer(address(this), _msgSender(), tokensAmount);
| emit Transfer(address(this), _msgSender(), tokensAmount);
| 26,544 |
134 | // A low-level call is necessary, here, because we don't want the consuming contract to be able to revert this execution, and thus deny the oracle payment for a valid randomness response. This also necessitates the above check on the gasleft, as otherwise there would be no indication if the callback method ran out of gas. solhint-disable-next-line avoid-low-level-calls | (bool success,) = consumerContract.call(resp);
| (bool success,) = consumerContract.call(resp);
| 136 |
554 | // Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) bypresenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn'tneed to send a transaction, and thus is not required to hold Ether at all. _Available since v3.4._ / | abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {
using Counters for Counters.Counter;
mapping(address => Counters.Counter) private _nonces;
| abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {
using Counters for Counters.Counter;
mapping(address => Counters.Counter) private _nonces;
| 33,995 |
864 | // Co-owners of a platform. Has less access rights than a root contract owner | StorageInterface.AddressBoolMapping internal partownersStorage;
| StorageInterface.AddressBoolMapping internal partownersStorage;
| 36,344 |
129 | // Collateral amount for the position has been changed./position The address of the user that has opened the position./collateralToken The address of the collateral token being added to position./collateralAmount The amount of collateral added or removed./isCollateralIncrease Whether the collateral is added to the position or removed from it. | event CollateralChanged(
address indexed position, IERC20 indexed collateralToken, uint256 collateralAmount, bool isCollateralIncrease
);
| event CollateralChanged(
address indexed position, IERC20 indexed collateralToken, uint256 collateralAmount, bool isCollateralIncrease
);
| 35,810 |
77 | // Total amount of external contributions (BTC, LTC, USD, etc.) during this crowdsale. | uint256 public totalExternalSales = 0;
modifier canNotify() {
require(msg.sender == owner || msg.sender == notifier);
_;
}
| uint256 public totalExternalSales = 0;
modifier canNotify() {
require(msg.sender == owner || msg.sender == notifier);
_;
}
| 16,146 |
43 | // Modifiers Only checks if caller is a valid keeper, payment should be handled manually | modifier onlyKeeper() {
_isKeeper();
_;
}
| modifier onlyKeeper() {
_isKeeper();
_;
}
| 10,283 |
100 | // representing an app's life-cyclean app's life-cycle starts in the ON state, then it is either move to the final OFF state, or to the RETIRED state when it upgrades itself to its successor version./ | contract AppState {
enum State { OFF, ON, RETIRED }
| contract AppState {
enum State { OFF, ON, RETIRED }
| 25,506 |
126 | // Events for adding and removing various roles |
event MinterRoleGranted(
address indexed beneficiary,
address indexed caller
);
event MinterRoleRemoved(
address indexed beneficiary,
address indexed caller
);
|
event MinterRoleGranted(
address indexed beneficiary,
address indexed caller
);
event MinterRoleRemoved(
address indexed beneficiary,
address indexed caller
);
| 30,806 |
14 | // deployment variables for static supply sale | uint256 private initialTokenSupply;
uint256 private tokensRemaining;
| uint256 private initialTokenSupply;
uint256 private tokensRemaining;
| 24,465 |
24 | // subtraction overflow is desired | uint32 timeElapsed = blockTimestamp - blockTimestampLast;
| uint32 timeElapsed = blockTimestamp - blockTimestampLast;
| 1,211 |
5 | // Returns all normalized weights, in the same order as the Pool's tokens. / | function _getNormalizedWeights() internal view virtual returns (uint256[] memory);
| function _getNormalizedWeights() internal view virtual returns (uint256[] memory);
| 21,412 |
272 | // RETURNS COUNT OF LP POOLS | function poolLength() external view returns (uint256) {
return rewardPools.length;
}
| function poolLength() external view returns (uint256) {
return rewardPools.length;
}
| 48,889 |
248 | // register collateral for the borrower if the token is CollateralCap version. | CCollateralCapErc20Interface(address(cToken)).registerCollateral(borrower);
| CCollateralCapErc20Interface(address(cToken)).registerCollateral(borrower);
| 21,544 |
417 | // This is required to clear the suffix as we append below | bytes18 suffix = activeCurrencies & TURN_OFF_PORTFOLIO_FLAGS;
uint256 shifts;
| bytes18 suffix = activeCurrencies & TURN_OFF_PORTFOLIO_FLAGS;
uint256 shifts;
| 35,532 |
0 | // string medicineName; | string manufactureAddress;
uint dateOfManufacture;
uint ExpirationDate;
uint numberOfUnits;
uint pricePerUnit;
string description;
string chemicalSupplierName;
| string manufactureAddress;
uint dateOfManufacture;
uint ExpirationDate;
uint numberOfUnits;
uint pricePerUnit;
string description;
string chemicalSupplierName;
| 50,561 |
35 | // BookmakerXYZ free bet contract | contract XYZFreeBet is ERC721Upgradeable, OwnableUpgradeable {
struct Bet {
uint128 amount;
uint64 minOdds;
uint64 durationTime;
}
struct AzuroBet {
address owner;
uint256 freeBetId;
uint128 amount;
uint128 payout;
}
ILP public LP;
string public baseURI;
address public token;
uint256 public lockedReserve;
mapping(uint256 => Bet) public freeBets;
mapping(uint256 => AzuroBet) public azuroBets;
mapping(uint256 => uint64) public expirationTime;
uint256 public lastTokenId;
mapping(address => bool) public maintainers;
event LpChanged(address indexed newLp);
event FreeBetMinted(address indexed receiver, uint256 indexed id, Bet bet);
event FreeBetMintedBatch(address[] receivers, uint256[] ids, Bet[] bets);
event FreeBetRedeemed(
address indexed bettor,
uint256 indexed id,
uint256 indexed azuroBetId,
uint128 amount
);
event FreeBetReissued(
address indexed receiver,
uint256 indexed id,
Bet bet
);
event MaintainerUpdated(address maintainer, bool active);
event BettorWin(address bettor, uint256 azuroBetId, uint128 amount);
error OnlyBetOwner();
error InsufficientAmount();
error DifferentArraysLength();
error WrongToken();
error InsufficientContractBalance();
error NonTransferable();
error BetExpired();
error OddsTooSmall();
error ZeroAmount();
error ZeroDuration();
error OnlyMaintainer();
error AlreadyResolved();
/**
* @notice Only permits calls by Maintainers.
*/
modifier onlyMaintainer() {
_checkOnlyMaintainer();
_;
}
receive() external payable {
if (msg.sender != token) {
// add reserves
IWNative(token).deposit{value: msg.value}();
}
// else let withdraw reserves of token via withdrawReserveNative
}
function initialize(address token_) external initializer {
__ERC721_init("XYZFreeBet", "XFBET");
__Ownable_init();
if (token_ == address(0)) revert WrongToken();
token = token_;
}
/**
* @notice Owner: sets 'lp' as LP address
* @param lp LP address
*/
function setLp(address lp) external onlyOwner {
LP = ILP(lp);
emit LpChanged(lp);
}
/**
* @notice Owner: sets 'uri' as base NFT URI
* @param uri base URI string
*/
function setBaseURI(string calldata uri) external onlyOwner {
baseURI = uri;
}
/**
* @notice Owner: Set whether `maintainer` is active maintainer or not.
* @param maintainer address of a maintainer
* @param active true if maintainer is active
*/
function updateMaintainer(address maintainer, bool active)
external
onlyOwner
{
maintainers[maintainer] = active;
emit MaintainerUpdated(maintainer, active);
}
/**
* @notice Get all expired and not yet burned free bets IDs
* @param start Starting free bet ID to search from
* @param count Number of IDs to search through
* @return Array of found IDs and its size (remaining elements filled with 0)
*/
function getExpiredUnburned(uint256 start, uint256 count)
external
view
returns (uint256[] memory, uint256)
{
uint256[] memory ids = new uint256[](count);
uint256 index;
uint256 end = start + count;
Bet storage bet;
for (uint256 id = start; id < end; id++) {
bet = freeBets[id];
if (bet.amount > 0 && expirationTime[id] <= block.timestamp) {
ids[index++] = id;
}
}
return (ids, index);
}
/**
* @notice Burn expired free bets with given IDs
* @param ids Array of IDs to check expiration and burn
*/
function burnExpired(uint256[] calldata ids) external {
uint256 burnedAmount;
uint256 len = ids.length;
uint256 id;
Bet storage bet;
uint128 amount;
for (uint256 i = 0; i < len; i++) {
id = ids[i];
bet = freeBets[id];
amount = bet.amount;
if (amount > 0 && expirationTime[id] <= block.timestamp) {
burnedAmount += amount;
bet.amount = 0;
_burn(id);
}
}
lockedReserve -= burnedAmount;
}
/**
* @notice Maintainer: withdraw unlocked token reserves
* @param amount Amount to withdraw
*/
function withdrawReserve(uint128 amount) external onlyMaintainer {
_checkInsufficient(amount);
TransferHelper.safeTransfer(token, msg.sender, amount);
}
/**
* @notice Maintainer: withdraw unlocked token reserves in native currency
* @param amount Amount to withdraw
*/
function withdrawReserveNative(uint128 amount) external onlyMaintainer {
_checkInsufficient(amount);
IWNative(token).withdraw(amount);
TransferHelper.safeTransferETH(msg.sender, amount);
}
/**
* @notice Maintainer: mint free bets to users
* @dev Arrays must have the same length, receivers[i] is mapped with bets[i]
* @param receivers Addresses to mint free bets to
* @param bets Free bet params
*/
function mintBatch(address[] calldata receivers, Bet[] calldata bets)
external
onlyMaintainer
{
uint256 receiversLength = receivers.length;
if (receiversLength != bets.length) revert DifferentArraysLength();
uint256[] memory ids = new uint256[](receiversLength);
uint256 lastId = lastTokenId;
uint128 amountsSum;
for (uint256 i = 0; i < receiversLength; i++) {
ids[i] = ++lastId;
amountsSum += bets[i].amount;
_safeMint(receivers[i], lastId, bets[i]);
}
_checkInsufficient(amountsSum);
lastTokenId = lastId;
lockedReserve += amountsSum;
emit FreeBetMintedBatch(receivers, ids, bets);
}
/**
* @notice Maintainer: mint free bet to user
* @param to Address to mint free bet to
* @param bet Free bet params
*/
function mint(address to, Bet calldata bet) external onlyMaintainer {
_checkInsufficient(bet.amount);
lockedReserve += bet.amount;
uint256 newId = ++lastTokenId;
_safeMint(to, newId, bet);
emit FreeBetMinted(to, newId, bet);
}
/**
* @notice Redeem free bet and make real bet
* @param id ID of free bet
* @param conditionId The match or game ID
* @param amount Amount of free bet to redeem (can be partial)
* @param outcomeId ID of predicted outcome
* @param deadline The time before which the bet should be made
* @param minOdds Minimum allowed bet odds
* @return Minted Azuro bet ID
*/
function redeem(
uint256 id,
uint256 conditionId,
uint128 amount,
uint64 outcomeId,
uint64 deadline,
uint64 minOdds
) external returns (uint256) {
if (ownerOf(id) != msg.sender) revert OnlyBetOwner();
Bet storage bet = freeBets[id];
if (bet.amount < amount) revert InsufficientAmount();
if (expirationTime[id] <= block.timestamp) revert BetExpired();
if (bet.minOdds > minOdds) revert OddsTooSmall();
lockedReserve -= amount;
bet.amount -= amount;
TransferHelper.safeApprove(token, address(LP), amount);
uint256 azuroBetId = LP.bet(
conditionId,
amount,
outcomeId,
deadline,
minOdds
);
azuroBets[azuroBetId] = AzuroBet(msg.sender, id, amount, 0);
emit FreeBetRedeemed(msg.sender, id, azuroBetId, amount);
return azuroBetId;
}
/**
* @notice Resolve bet payout
* @param azuroBetId The ID of Azuro bet to resolve
*/
function resolvePayout(uint256 azuroBetId) external {
azuroBets[azuroBetId].payout = _resolvePayout(azuroBetId);
}
/**
* @notice Withdraw bet payout for bettor (reward or 0)
* @param azuroBetId The ID of Azuro bet to withdraw
*/
function withdrawPayout(uint256 azuroBetId) external {
uint128 payout = _withdrawPayout(azuroBetId);
if (payout > 0) {
TransferHelper.safeTransfer(token, msg.sender, payout);
}
}
/**
* @notice Withdraw bet payout for bettor (reward or 0) in native currency
* @param azuroBetId The ID of Azuro bet to withdraw
*/
function withdrawPayoutNative(uint256 azuroBetId) external {
uint128 payout = _withdrawPayout(azuroBetId);
if (payout > 0) {
IWNative(token).withdraw(payout);
TransferHelper.safeTransferETH(msg.sender, payout);
}
}
function _withdrawPayout(uint256 azuroBetId) internal returns (uint128) {
AzuroBet storage azuroBet = azuroBets[azuroBetId];
if (azuroBet.owner != msg.sender) revert OnlyBetOwner();
uint128 payout;
if (azuroBet.amount == 0) {
// was resolved
payout = azuroBet.payout;
if (payout > 0) azuroBet.payout = 0;
} else {
// was not resolved
payout = _resolvePayout(azuroBetId);
}
if (payout > 0) {
emit BettorWin(azuroBet.owner, azuroBetId, payout);
}
return payout;
}
function _resolvePayout(uint256 azuroBetId) internal returns (uint128) {
AzuroBet storage azuroBet = azuroBets[azuroBetId];
uint128 betAmount = azuroBet.amount;
if (betAmount == 0) revert AlreadyResolved();
(, uint128 fullPayout) = LP.viewPayout(azuroBetId);
if (fullPayout > 0) {
LP.withdrawPayout(azuroBetId);
}
uint256 freeBetId = azuroBet.freeBetId;
if (fullPayout != betAmount) {
// win or lose
if (freeBets[freeBetId].amount == 0) {
_burn(freeBetId);
}
} else {
// cancel
Bet storage bet = freeBets[freeBetId];
bet.amount += betAmount;
lockedReserve += betAmount;
expirationTime[freeBetId] =
uint64(block.timestamp) +
bet.durationTime;
emit FreeBetReissued(azuroBet.owner, freeBetId, bet);
}
azuroBet.amount = 0;
return (fullPayout > betAmount) ? (fullPayout - betAmount) : 0;
}
function _safeMint(
address to,
uint256 id,
Bet calldata bet
) internal {
if (bet.amount == 0) revert ZeroAmount();
if (bet.durationTime == 0) revert ZeroDuration();
freeBets[id] = bet;
expirationTime[id] = uint64(block.timestamp) + bet.durationTime;
_safeMint(to, id);
}
function _transfer(
address,
address,
uint256
) internal pure override {
revert NonTransferable();
}
function _baseURI() internal view override returns (string memory) {
return baseURI;
}
function _checkInsufficient(uint128 amount) internal view {
if (IERC20(token).balanceOf(address(this)) < lockedReserve + amount)
revert InsufficientContractBalance();
}
function _checkOnlyMaintainer() internal view {
if (!maintainers[msg.sender]) revert OnlyMaintainer();
}
}
| contract XYZFreeBet is ERC721Upgradeable, OwnableUpgradeable {
struct Bet {
uint128 amount;
uint64 minOdds;
uint64 durationTime;
}
struct AzuroBet {
address owner;
uint256 freeBetId;
uint128 amount;
uint128 payout;
}
ILP public LP;
string public baseURI;
address public token;
uint256 public lockedReserve;
mapping(uint256 => Bet) public freeBets;
mapping(uint256 => AzuroBet) public azuroBets;
mapping(uint256 => uint64) public expirationTime;
uint256 public lastTokenId;
mapping(address => bool) public maintainers;
event LpChanged(address indexed newLp);
event FreeBetMinted(address indexed receiver, uint256 indexed id, Bet bet);
event FreeBetMintedBatch(address[] receivers, uint256[] ids, Bet[] bets);
event FreeBetRedeemed(
address indexed bettor,
uint256 indexed id,
uint256 indexed azuroBetId,
uint128 amount
);
event FreeBetReissued(
address indexed receiver,
uint256 indexed id,
Bet bet
);
event MaintainerUpdated(address maintainer, bool active);
event BettorWin(address bettor, uint256 azuroBetId, uint128 amount);
error OnlyBetOwner();
error InsufficientAmount();
error DifferentArraysLength();
error WrongToken();
error InsufficientContractBalance();
error NonTransferable();
error BetExpired();
error OddsTooSmall();
error ZeroAmount();
error ZeroDuration();
error OnlyMaintainer();
error AlreadyResolved();
/**
* @notice Only permits calls by Maintainers.
*/
modifier onlyMaintainer() {
_checkOnlyMaintainer();
_;
}
receive() external payable {
if (msg.sender != token) {
// add reserves
IWNative(token).deposit{value: msg.value}();
}
// else let withdraw reserves of token via withdrawReserveNative
}
function initialize(address token_) external initializer {
__ERC721_init("XYZFreeBet", "XFBET");
__Ownable_init();
if (token_ == address(0)) revert WrongToken();
token = token_;
}
/**
* @notice Owner: sets 'lp' as LP address
* @param lp LP address
*/
function setLp(address lp) external onlyOwner {
LP = ILP(lp);
emit LpChanged(lp);
}
/**
* @notice Owner: sets 'uri' as base NFT URI
* @param uri base URI string
*/
function setBaseURI(string calldata uri) external onlyOwner {
baseURI = uri;
}
/**
* @notice Owner: Set whether `maintainer` is active maintainer or not.
* @param maintainer address of a maintainer
* @param active true if maintainer is active
*/
function updateMaintainer(address maintainer, bool active)
external
onlyOwner
{
maintainers[maintainer] = active;
emit MaintainerUpdated(maintainer, active);
}
/**
* @notice Get all expired and not yet burned free bets IDs
* @param start Starting free bet ID to search from
* @param count Number of IDs to search through
* @return Array of found IDs and its size (remaining elements filled with 0)
*/
function getExpiredUnburned(uint256 start, uint256 count)
external
view
returns (uint256[] memory, uint256)
{
uint256[] memory ids = new uint256[](count);
uint256 index;
uint256 end = start + count;
Bet storage bet;
for (uint256 id = start; id < end; id++) {
bet = freeBets[id];
if (bet.amount > 0 && expirationTime[id] <= block.timestamp) {
ids[index++] = id;
}
}
return (ids, index);
}
/**
* @notice Burn expired free bets with given IDs
* @param ids Array of IDs to check expiration and burn
*/
function burnExpired(uint256[] calldata ids) external {
uint256 burnedAmount;
uint256 len = ids.length;
uint256 id;
Bet storage bet;
uint128 amount;
for (uint256 i = 0; i < len; i++) {
id = ids[i];
bet = freeBets[id];
amount = bet.amount;
if (amount > 0 && expirationTime[id] <= block.timestamp) {
burnedAmount += amount;
bet.amount = 0;
_burn(id);
}
}
lockedReserve -= burnedAmount;
}
/**
* @notice Maintainer: withdraw unlocked token reserves
* @param amount Amount to withdraw
*/
function withdrawReserve(uint128 amount) external onlyMaintainer {
_checkInsufficient(amount);
TransferHelper.safeTransfer(token, msg.sender, amount);
}
/**
* @notice Maintainer: withdraw unlocked token reserves in native currency
* @param amount Amount to withdraw
*/
function withdrawReserveNative(uint128 amount) external onlyMaintainer {
_checkInsufficient(amount);
IWNative(token).withdraw(amount);
TransferHelper.safeTransferETH(msg.sender, amount);
}
/**
* @notice Maintainer: mint free bets to users
* @dev Arrays must have the same length, receivers[i] is mapped with bets[i]
* @param receivers Addresses to mint free bets to
* @param bets Free bet params
*/
function mintBatch(address[] calldata receivers, Bet[] calldata bets)
external
onlyMaintainer
{
uint256 receiversLength = receivers.length;
if (receiversLength != bets.length) revert DifferentArraysLength();
uint256[] memory ids = new uint256[](receiversLength);
uint256 lastId = lastTokenId;
uint128 amountsSum;
for (uint256 i = 0; i < receiversLength; i++) {
ids[i] = ++lastId;
amountsSum += bets[i].amount;
_safeMint(receivers[i], lastId, bets[i]);
}
_checkInsufficient(amountsSum);
lastTokenId = lastId;
lockedReserve += amountsSum;
emit FreeBetMintedBatch(receivers, ids, bets);
}
/**
* @notice Maintainer: mint free bet to user
* @param to Address to mint free bet to
* @param bet Free bet params
*/
function mint(address to, Bet calldata bet) external onlyMaintainer {
_checkInsufficient(bet.amount);
lockedReserve += bet.amount;
uint256 newId = ++lastTokenId;
_safeMint(to, newId, bet);
emit FreeBetMinted(to, newId, bet);
}
/**
* @notice Redeem free bet and make real bet
* @param id ID of free bet
* @param conditionId The match or game ID
* @param amount Amount of free bet to redeem (can be partial)
* @param outcomeId ID of predicted outcome
* @param deadline The time before which the bet should be made
* @param minOdds Minimum allowed bet odds
* @return Minted Azuro bet ID
*/
function redeem(
uint256 id,
uint256 conditionId,
uint128 amount,
uint64 outcomeId,
uint64 deadline,
uint64 minOdds
) external returns (uint256) {
if (ownerOf(id) != msg.sender) revert OnlyBetOwner();
Bet storage bet = freeBets[id];
if (bet.amount < amount) revert InsufficientAmount();
if (expirationTime[id] <= block.timestamp) revert BetExpired();
if (bet.minOdds > minOdds) revert OddsTooSmall();
lockedReserve -= amount;
bet.amount -= amount;
TransferHelper.safeApprove(token, address(LP), amount);
uint256 azuroBetId = LP.bet(
conditionId,
amount,
outcomeId,
deadline,
minOdds
);
azuroBets[azuroBetId] = AzuroBet(msg.sender, id, amount, 0);
emit FreeBetRedeemed(msg.sender, id, azuroBetId, amount);
return azuroBetId;
}
/**
* @notice Resolve bet payout
* @param azuroBetId The ID of Azuro bet to resolve
*/
function resolvePayout(uint256 azuroBetId) external {
azuroBets[azuroBetId].payout = _resolvePayout(azuroBetId);
}
/**
* @notice Withdraw bet payout for bettor (reward or 0)
* @param azuroBetId The ID of Azuro bet to withdraw
*/
function withdrawPayout(uint256 azuroBetId) external {
uint128 payout = _withdrawPayout(azuroBetId);
if (payout > 0) {
TransferHelper.safeTransfer(token, msg.sender, payout);
}
}
/**
* @notice Withdraw bet payout for bettor (reward or 0) in native currency
* @param azuroBetId The ID of Azuro bet to withdraw
*/
function withdrawPayoutNative(uint256 azuroBetId) external {
uint128 payout = _withdrawPayout(azuroBetId);
if (payout > 0) {
IWNative(token).withdraw(payout);
TransferHelper.safeTransferETH(msg.sender, payout);
}
}
function _withdrawPayout(uint256 azuroBetId) internal returns (uint128) {
AzuroBet storage azuroBet = azuroBets[azuroBetId];
if (azuroBet.owner != msg.sender) revert OnlyBetOwner();
uint128 payout;
if (azuroBet.amount == 0) {
// was resolved
payout = azuroBet.payout;
if (payout > 0) azuroBet.payout = 0;
} else {
// was not resolved
payout = _resolvePayout(azuroBetId);
}
if (payout > 0) {
emit BettorWin(azuroBet.owner, azuroBetId, payout);
}
return payout;
}
function _resolvePayout(uint256 azuroBetId) internal returns (uint128) {
AzuroBet storage azuroBet = azuroBets[azuroBetId];
uint128 betAmount = azuroBet.amount;
if (betAmount == 0) revert AlreadyResolved();
(, uint128 fullPayout) = LP.viewPayout(azuroBetId);
if (fullPayout > 0) {
LP.withdrawPayout(azuroBetId);
}
uint256 freeBetId = azuroBet.freeBetId;
if (fullPayout != betAmount) {
// win or lose
if (freeBets[freeBetId].amount == 0) {
_burn(freeBetId);
}
} else {
// cancel
Bet storage bet = freeBets[freeBetId];
bet.amount += betAmount;
lockedReserve += betAmount;
expirationTime[freeBetId] =
uint64(block.timestamp) +
bet.durationTime;
emit FreeBetReissued(azuroBet.owner, freeBetId, bet);
}
azuroBet.amount = 0;
return (fullPayout > betAmount) ? (fullPayout - betAmount) : 0;
}
function _safeMint(
address to,
uint256 id,
Bet calldata bet
) internal {
if (bet.amount == 0) revert ZeroAmount();
if (bet.durationTime == 0) revert ZeroDuration();
freeBets[id] = bet;
expirationTime[id] = uint64(block.timestamp) + bet.durationTime;
_safeMint(to, id);
}
function _transfer(
address,
address,
uint256
) internal pure override {
revert NonTransferable();
}
function _baseURI() internal view override returns (string memory) {
return baseURI;
}
function _checkInsufficient(uint128 amount) internal view {
if (IERC20(token).balanceOf(address(this)) < lockedReserve + amount)
revert InsufficientContractBalance();
}
function _checkOnlyMaintainer() internal view {
if (!maintainers[msg.sender]) revert OnlyMaintainer();
}
}
| 21,293 |
9 | // We assume Band Protocol always has 18 decimals https:docs.bandchain.org/band-standard-dataset/using-band-dataset/using-band-dataset-evm.html | return 18;
| return 18;
| 44,841 |
167 | // Only delegate to non-empty address | require(_indexer != address(0), "!indexer");
| require(_indexer != address(0), "!indexer");
| 20,679 |
60 | // Restrict operation to profit distribution authority only | modifier onlyProfitDistributor() {
require(msg.sender == profitDistributor, "Restricted to profit distributor");
_;
}
| modifier onlyProfitDistributor() {
require(msg.sender == profitDistributor, "Restricted to profit distributor");
_;
}
| 5,001 |
0 | // Constructor/assets The addresses of the assets/sources The address of the source of each asset | constructor(address[] memory assets, address[] memory sources) {
internalSetAssetsSources(assets, sources);
}
| constructor(address[] memory assets, address[] memory sources) {
internalSetAssetsSources(assets, sources);
}
| 42,683 |
58 | // 从 @who 的持有数量中去掉待拍卖的抵押物对应的稳定币记录. | hol[who].s = usub(hol[who].s, s);
| hol[who].s = usub(hol[who].s, s);
| 30,141 |
222 | // total -= 1; | }
| }
| 44,959 |
49 | // Record commit in logs. | emit Commit(commit);
| emit Commit(commit);
| 21,613 |
24 | // TODO: change to automatically calculate amount on-chain in a future iteration | function _liquidatePosition(
address liquidator,
uint256 positionId,
uint256 amount,
address rewardTo
| function _liquidatePosition(
address liquidator,
uint256 positionId,
uint256 amount,
address rewardTo
| 25,583 |
585 | // Overridden execute function that run the already queued proposal through the timelock. / | function _execute(
uint256 /* proposalId */,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
| function _execute(
uint256 /* proposalId */,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
| 28,072 |
26 | // Loop until addBetValue exceeds randJackpotBetValue | while(randJackpotBetValue > addBetValue){
| while(randJackpotBetValue > addBetValue){
| 5,122 |
150 | // Emits when found an error decoding request result | event ResultError(string);
| event ResultError(string);
| 6,878 |
40 | // Upvotes a queued proposal. proposalId The ID of the proposal to upvote. lesser The ID of the proposal that will be just behind `proposalId` in the queue. greater The ID of the proposal that will be just ahead `proposalId` in the queue.return Whether or not the upvote was made successfully. Provide 0 for `lesser`/`greater` when the proposal will be at the tail/head of the queue. Reverts if the account has already upvoted a proposal in the queue. / | function upvote(uint256 proposalId, uint256 lesser, uint256 greater)
external
nonReentrant
returns (bool)
| function upvote(uint256 proposalId, uint256 lesser, uint256 greater)
external
nonReentrant
returns (bool)
| 24,138 |
148 | // c = cD / (AnnN) | c = c.mul(_D).div(Ann.mul(_balances.length));
| c = c.mul(_D).div(Ann.mul(_balances.length));
| 20,386 |
4 | // We need | bool public vikingsBroughtHome = false;
| bool public vikingsBroughtHome = false;
| 7,575 |
97 | // @notify Set the new debtAuctionBidSize and initialDebtAuctionMintedTokens inside the AccountingEnginefeeReceiver The address that will receive the reward for setting new params/ | function setDebtAuctionInitialParameters(address feeReceiver) external {
// Check delay between calls
require(either(subtract(now, lastUpdateTime) >= updateDelay, lastUpdateTime == 0), "DebtAuctionInitialParameterSetter/wait-more");
// Get the caller's reward
uint256 callerReward = getCallerReward(lastUpdateTime, updateDelay);
// Store the timestamp of the update
lastUpdateTime = now;
// Get token prices
(uint256 protocolTknPrice, bool validProtocolPrice) = protocolTokenOrcl.getResultWithValidity();
(uint256 systemCoinPrice, bool validSysCoinPrice) = systemCoinOrcl.getResultWithValidity();
require(both(validProtocolPrice, validSysCoinPrice), "DebtAuctionInitialParameterSetter/invalid-prices");
require(both(protocolTknPrice > 0, systemCoinPrice > 0), "DebtAuctionInitialParameterSetter/null-prices");
// Compute the scaled bid target value
uint256 scaledBidTargetValue = multiply(bidTargetValue, WAD);
// Compute the amont of protocol tokens without the premium
uint256 initialDebtAuctionMintedTokens = divide(scaledBidTargetValue, protocolTknPrice);
// Apply the premium
initialDebtAuctionMintedTokens = divide(multiply(initialDebtAuctionMintedTokens, protocolTokenPremium), THOUSAND);
// Take into account the minimum amount of protocol tokens to offer
if (initialDebtAuctionMintedTokens < minProtocolTokenAmountOffered) {
initialDebtAuctionMintedTokens = minProtocolTokenAmountOffered;
}
// Compute the debtAuctionBidSize as a RAD taking into account the minimum amount to bid
uint256 debtAuctionBidSize = divide(multiply(scaledBidTargetValue, RAY), systemCoinPrice);
if (debtAuctionBidSize < RAY) {
debtAuctionBidSize = RAY;
}
// Set the debt bid and the associated protocol token amount in the accounting engine
accountingEngine.modifyParameters("debtAuctionBidSize", debtAuctionBidSize);
accountingEngine.modifyParameters("initialDebtAuctionMintedTokens", initialDebtAuctionMintedTokens);
// Emit an event
emit SetDebtAuctionInitialParameters(debtAuctionBidSize, initialDebtAuctionMintedTokens);
// Pay the caller for updating the rate
rewardCaller(feeReceiver, callerReward);
}
| function setDebtAuctionInitialParameters(address feeReceiver) external {
// Check delay between calls
require(either(subtract(now, lastUpdateTime) >= updateDelay, lastUpdateTime == 0), "DebtAuctionInitialParameterSetter/wait-more");
// Get the caller's reward
uint256 callerReward = getCallerReward(lastUpdateTime, updateDelay);
// Store the timestamp of the update
lastUpdateTime = now;
// Get token prices
(uint256 protocolTknPrice, bool validProtocolPrice) = protocolTokenOrcl.getResultWithValidity();
(uint256 systemCoinPrice, bool validSysCoinPrice) = systemCoinOrcl.getResultWithValidity();
require(both(validProtocolPrice, validSysCoinPrice), "DebtAuctionInitialParameterSetter/invalid-prices");
require(both(protocolTknPrice > 0, systemCoinPrice > 0), "DebtAuctionInitialParameterSetter/null-prices");
// Compute the scaled bid target value
uint256 scaledBidTargetValue = multiply(bidTargetValue, WAD);
// Compute the amont of protocol tokens without the premium
uint256 initialDebtAuctionMintedTokens = divide(scaledBidTargetValue, protocolTknPrice);
// Apply the premium
initialDebtAuctionMintedTokens = divide(multiply(initialDebtAuctionMintedTokens, protocolTokenPremium), THOUSAND);
// Take into account the minimum amount of protocol tokens to offer
if (initialDebtAuctionMintedTokens < minProtocolTokenAmountOffered) {
initialDebtAuctionMintedTokens = minProtocolTokenAmountOffered;
}
// Compute the debtAuctionBidSize as a RAD taking into account the minimum amount to bid
uint256 debtAuctionBidSize = divide(multiply(scaledBidTargetValue, RAY), systemCoinPrice);
if (debtAuctionBidSize < RAY) {
debtAuctionBidSize = RAY;
}
// Set the debt bid and the associated protocol token amount in the accounting engine
accountingEngine.modifyParameters("debtAuctionBidSize", debtAuctionBidSize);
accountingEngine.modifyParameters("initialDebtAuctionMintedTokens", initialDebtAuctionMintedTokens);
// Emit an event
emit SetDebtAuctionInitialParameters(debtAuctionBidSize, initialDebtAuctionMintedTokens);
// Pay the caller for updating the rate
rewardCaller(feeReceiver, callerReward);
}
| 7,399 |
78 | // Tellor Oracle System Library Contains the functions' logic for the Tellor contract where miners can submit the proof of workalong with the value and smart contracts can requestData and tip miners. / | library MockTellorLibrary {
using MockSafeMath for uint256;
bytes32 public constant requestCount = 0x05de9147d05477c0a5dc675aeea733157f5092f82add148cf39d579cafe3dc98; //keccak256("requestCount")
bytes32 public constant totalTip = 0x2a9e355a92978430eca9c1aa3a9ba590094bac282594bccf82de16b83046e2c3; //keccak256("totalTip")
bytes32 public constant _tBlock = 0x969ea04b74d02bb4d9e6e8e57236e1b9ca31627139ae9f0e465249932e824502; //keccak256("_tBlock")
bytes32 public constant timeOfLastNewValue = 0x97e6eb29f6a85471f7cc9b57f9e4c3deaf398cfc9798673160d7798baf0b13a4; //keccak256("timeOfLastNewValue")
bytes32 public constant difficulty = 0xb12aff7664b16cb99339be399b863feecd64d14817be7e1f042f97e3f358e64e; //keccak256("difficulty")
bytes32 public constant timeTarget = 0xad16221efc80aaf1b7e69bd3ecb61ba5ffa539adf129c3b4ffff769c9b5bbc33; //keccak256("timeTarget")
bytes32 public constant runningTips = 0xdb21f0c4accc4f2f5f1045353763a9ffe7091ceaf0fcceb5831858d96cf84631; //keccak256("runningTips")
bytes32 public constant currentReward = 0x9b6853911475b07474368644a0d922ee13bc76a15cd3e97d3e334326424a47d4; //keccak256("currentReward")
bytes32 public constant total_supply = 0xb1557182e4359a1f0c6301278e8f5b35a776ab58d39892581e357578fb287836; //keccak256("total_supply")
bytes32 public constant devShare = 0x8fe9ded8d7c08f720cf0340699024f83522ea66b2bbfb8f557851cb9ee63b54c; //keccak256("devShare")
bytes32 public constant _owner = 0x9dbc393ddc18fd27b1d9b1b129059925688d2f2d5818a5ec3ebb750b7c286ea6; //keccak256("_owner")
bytes32 public constant requestQPosition = 0x1e344bd070f05f1c5b3f0b1266f4f20d837a0a8190a3a2da8b0375eac2ba86ea; //keccak256("requestQPosition")
bytes32 public constant currentTotalTips = 0xd26d9834adf5a73309c4974bf654850bb699df8505e70d4cfde365c417b19dfc; //keccak256("currentTotalTips")
bytes32 public constant slotProgress =0x6c505cb2db6644f57b42d87bd9407b0f66788b07d0617a2bc1356a0e69e66f9a; //keccak256("slotProgress")
bytes32 public constant pending_owner = 0x44b2657a0f8a90ed8e62f4c4cceca06eacaa9b4b25751ae1ebca9280a70abd68; //keccak256("pending_owner")
bytes32 public constant currentRequestId = 0x7584d7d8701714da9c117f5bf30af73b0b88aca5338a84a21eb28de2fe0d93b8; //keccak256("currentRequestId")
event TipAdded(address indexed _sender, uint256 indexed _requestId, uint256 _tip, uint256 _totalTips);
//emits when a new challenge is created (either on mined block or when a new request is pushed forward on waiting system)
event NewChallenge(
bytes32 indexed _currentChallenge,
uint256[5] _currentRequestId,
uint256 _difficulty,
uint256 _totalTips
);
//Emits upon a successful Mine, indicates the blocktime at point of the mine and the value mined
event NewValue(uint256[5] _requestId, uint256 _time, uint256[5] _value, uint256 _totalTips, bytes32 indexed _currentChallenge);
//Emits upon each mine (5 total) and shows the miner, nonce, and value submitted
event NonceSubmitted(address indexed _miner, string _nonce, uint256[5] _requestId, uint256[5] _value, bytes32 indexed _currentChallenge);
event OwnershipTransferred(address indexed _previousOwner, address indexed _newOwner);
event OwnershipProposed(address indexed _previousOwner, address indexed _newOwner);
/*Functions*/
/**
* @dev Add tip to Request value from oracle
* @param _requestId being requested to be mined
* @param _tip amount the requester is willing to pay to be get on queue. Miners
* mine the onDeckQueryHash, or the api with the highest payout pool
*/
function addTip(MockTellorStorage.TellorStorageStruct storage self, uint256 _requestId, uint256 _tip) external {
require(_requestId != 0, "RequestId is 0");
require(_tip != 0, "Tip should be greater than 0");
uint256 _count =self.uintVars[requestCount] + 1;
if(_requestId == _count){
self.uintVars[requestCount] = _count;
}
else{
require(_requestId < _count, "RequestId is not less than count");
}
MockTellorTransfer.doTransfer(self, msg.sender, address(this), _tip);
//Update the information for the request that should be mined next based on the tip submitted
updateOnDeck(self, _requestId, _tip);
emit TipAdded(msg.sender, _requestId, _tip, self.requestDetails[_requestId].apiUintVars[totalTip]);
}
/**
* @dev This function is called by submitMiningSolution and adjusts the difficulty, sorts and stores the first
* 5 values received, pays the miners, the dev share and assigns a new challenge
* @param _nonce or solution for the PoW for the requestId
* @param _requestId for the current request being mined
*/
function newBlock(MockTellorStorage.TellorStorageStruct storage self, string memory _nonce, uint256[5] memory _requestId) public {
MockTellorStorage.Request storage _tblock = self.requestDetails[self.uintVars[_tBlock]];
// If the difference between the timeTarget and how long it takes to solve the challenge this updates the challenge
//difficulty up or donw by the difference between the target time and how long it took to solve the previous challenge
//otherwise it sets it to 1
int256 _change = int256(MockSafeMath.min(1200, (now - self.uintVars[timeOfLastNewValue])));
int256 _diff = int256(self.uintVars[difficulty]);
_change = (_diff * (int256(self.uintVars[timeTarget]) - _change)) / 4000;
if (_change == 0) {
_change = 1;
}
self.uintVars[difficulty] = uint256(MockSafeMath.max(_diff + _change,1));
//Sets time of value submission rounded to 1 minute
bytes32 _currChallenge = self.currentChallenge;
uint256 _timeOfLastNewValue = now - (now % 1 minutes);
self.uintVars[timeOfLastNewValue] = _timeOfLastNewValue;
uint[5] memory a;
for (uint k = 0; k < 5; k++) {
for (uint i = 1; i < 5; i++) {
uint256 temp = _tblock.valuesByTimestamp[k][i];
address temp2 = _tblock.minersByValue[i][i];
uint256 j = i;
while (j > 0 && temp < _tblock.valuesByTimestamp[k][j - 1]) {
_tblock.valuesByTimestamp[k][j] = _tblock.valuesByTimestamp[k][j - 1];
_tblock.minersByValue[i][j] = _tblock.minersByValue[i][j - 1];
j--;
}
if (j < i) {
_tblock.valuesByTimestamp[k][j] = temp;
_tblock.minersByValue[i][j] = temp2;
}
}
MockTellorStorage.Request storage _request = self.requestDetails[_requestId[k]];
//Save the official(finalValue), timestamp of it, 5 miners and their submitted values for it, and its block number
a = _tblock.valuesByTimestamp[k];
_request.finalValues[_timeOfLastNewValue] = a[2];
_request.requestTimestamps.push(_timeOfLastNewValue);
//these are miners by timestamp
// uint[5] memory valsByT = [a[0],a[1],a[2],a[3],a[4]];
// _request.valuesByTimestamp[_timeOfLastNewValue] = [a[0],a[1],a[2],a[3],a[4]];
// address[5] memory minsByT = [b[0], b[1], b[2], b[3], b[4]];
// _request.minersByValue[_timeOfLastNewValue] = [b[0], b[1], b[2], b[3], b[4]];
_request.minedBlockNum[_timeOfLastNewValue] = block.number;
_request.apiUintVars[totalTip] = 0;
}
//WARNING I feel like this event should be inside the loop, right?
emit NewValue(
_requestId,
_timeOfLastNewValue,
a,
self.uintVars[runningTips],
_currChallenge
);
//map the timeOfLastValue to the requestId that was just mined
self.requestIdByTimestamp[_timeOfLastNewValue] = _requestId[0];
//add timeOfLastValue to the newValueTimestamps array
self.newValueTimestamps.push(_timeOfLastNewValue);
uint _currReward = self.uintVars[currentReward];
//WARNING Reusing _timeOfLastNewValue to avoid stack too deep
_timeOfLastNewValue = _currReward;
if (_currReward > 1e18) {
//These number represent the inflation adjustement that started in 03/2019
_currReward = _currReward - _currReward * 15306316590563/1e18;
self.uintVars[devShare] = _currReward * 50/100;
_timeOfLastNewValue = _currReward;
} else {
_timeOfLastNewValue = 1e18;
}
self.uintVars[currentReward] = _timeOfLastNewValue;
_currReward = _timeOfLastNewValue;
uint _devShare = self.uintVars[devShare];
//update the total supply
self.uintVars[total_supply] += _devShare + _currReward*5 - (self.uintVars[currentTotalTips]);
MockTellorTransfer.doTransfer(self, address(this), self.addressVars[_owner], _devShare);
self.uintVars[_tBlock] ++;
uint256[5] memory _topId = MockTellorStake.getTopRequestIDs(self);
for(uint i = 0; i< 5;i++){
self.currentMiners[i].value = _topId[i];
self.requestQ[self.requestDetails[_topId[i]].apiUintVars[requestQPosition]] = 0;
self.uintVars[currentTotalTips] += self.requestDetails[_topId[i]].apiUintVars[totalTip];
}
//Issue the the next challenge
_currChallenge = keccak256(abi.encode(_nonce, _currChallenge, blockhash(block.number - 1)));
self.currentChallenge = _currChallenge; // Save hash for next proof
emit NewChallenge(
_currChallenge,
_topId,
self.uintVars[difficulty],
self.uintVars[currentTotalTips]
);
}
/**
* @dev Proof of work is called by the miner when they submit the solution (proof of work and value)
* @param _nonce uint submitted by miner
* @param _requestId is the array of the 5 PSR's being mined
* @param _value is an array of 5 values
*/
function submitMiningSolution(MockTellorStorage.TellorStorageStruct storage self, string calldata _nonce,uint256[5] calldata _requestId, uint256[5] calldata _value)
external
{
bytes32 _hashMsgSender = keccak256(abi.encode(msg.sender));
require(now - self.uintVars[_hashMsgSender] > 15 minutes, "Miner can only win rewards once per fifteen minutes");
self.uintVars[_hashMsgSender] = now;
// require(self.stakerDetails[msg.sender].currentStatus == 1, "Miner status is not staker");
// for(uint i=0;i<5;i++){
// require(_requestId[i] >=0);
// //require(_requestId[i] == self.currentMiners[i].value,"Request ID is wrong");
// }
require(_requestId[0] >=0);
require(_requestId[1] >=0);
require(_requestId[2] >=0);
require(_requestId[3] >=0);
require(_requestId[4] >=0);
// MockTellorStorage.Request storage _tblock = self.requestDetails[self.uintVars[_tBlock]];
//Saving the challenge information as unique by using the msg.sender
// require(uint256(
// sha256(abi.encodePacked(ripemd160(abi.encodePacked(keccak256(abi.encodePacked(self.currentChallenge, msg.sender, _nonce))))))
// ) %
// self.uintVars[difficulty] == 0
// || (now - (now % 1 minutes)) - self.uintVars[timeOfLastNewValue] >= 15 minutes,
// "Incorrect nonce for current challenge"
// );
//Saving Variables to Stack
bytes32 _currChallenge = self.currentChallenge;
uint256 _slotProgress = self.uintVars[slotProgress];
//Checking and updating Miner Status
require(self.minersByChallenge[_currChallenge][msg.sender] == false, "Miner already submitted the value");
self.minersByChallenge[_currChallenge][msg.sender] = true;
//Updating Request
MockTellorStorage.Request storage _tblock = self.requestDetails[self.uintVars[_tBlock]];
_tblock.minersByValue[1][_slotProgress]= msg.sender;
//Assigng directly is cheaper than using a for loop
_tblock.valuesByTimestamp[0][_slotProgress] = _value[0];
_tblock.valuesByTimestamp[1][_slotProgress] = _value[1];
_tblock.valuesByTimestamp[2][_slotProgress] = _value[2];
_tblock.valuesByTimestamp[3][_slotProgress] = _value[3];
_tblock.valuesByTimestamp[4][_slotProgress] = _value[4];
//Paying Miner Rewards
_payReward(self, _slotProgress);
self.uintVars[slotProgress]++;
if (_slotProgress + 1 == 5) { //slotProgress has been incremented, but we're using the variable on stack to save gas
newBlock(self, _nonce, _requestId);
self.uintVars[slotProgress] = 0;
}
emit NonceSubmitted(msg.sender, _nonce, _requestId, _value, _currChallenge);
}
function _payReward(MockTellorStorage.TellorStorageStruct storage self, uint _slotProgress) internal {
uint _runningTips = self.uintVars[runningTips];
uint _currentTotalTips = self.uintVars[currentTotalTips];
if(_slotProgress == 0){
_runningTips = _currentTotalTips;
self.uintVars[runningTips] = _currentTotalTips;
}
uint _extraTip = (_currentTotalTips-_runningTips)/(5-_slotProgress);
MockTellorTransfer._doTransfer(self, address(this), msg.sender, self.uintVars[currentReward] + _runningTips / 2 / 5 + _extraTip);
self.uintVars[currentTotalTips] -= _extraTip;
}
/**
* @dev This function updates APIonQ and the requestQ when requestData or addTip are ran
* @param _requestId being requested
* @param _tip is the tip to add
*/
function updateOnDeck(MockTellorStorage.TellorStorageStruct storage self, uint256 _requestId, uint256 _tip) public {
MockTellorStorage.Request storage _request = self.requestDetails[_requestId];
_request.apiUintVars[totalTip] = _request.apiUintVars[totalTip].add(_tip);
if(self.currentMiners[0].value == _requestId || self.currentMiners[1].value== _requestId ||self.currentMiners[2].value == _requestId||self.currentMiners[3].value== _requestId || self.currentMiners[4].value== _requestId ){
self.uintVars[currentTotalTips] += _tip;
}
else {
//if the request is not part of the requestQ[51] array
//then add to the requestQ[51] only if the _payout/tip is greater than the minimum(tip) in the requestQ[51] array
if (_request.apiUintVars[requestQPosition] == 0) {
uint256 _min;
uint256 _index;
(_min, _index) = MockUtilities.getMin(self.requestQ);
//we have to zero out the oldOne
//if the _payout is greater than the current minimum payout in the requestQ[51] or if the minimum is zero
//then add it to the requestQ array aand map its index information to the requestId and the apiUintvars
if (_request.apiUintVars[totalTip] > _min || _min == 0) {
self.requestQ[_index] = _request.apiUintVars[totalTip];
self.requestDetails[self.requestIdByRequestQIndex[_index]].apiUintVars[requestQPosition] = 0;
self.requestIdByRequestQIndex[_index] = _requestId;
_request.apiUintVars[requestQPosition] = _index;
}
// else if the requestid is part of the requestQ[51] then update the tip for it
} else{
self.requestQ[_request.apiUintVars[requestQPosition]] += _tip;
}
}
}
/**********************CHEAT Functions for Testing******************************/
/**********************CHEAT Functions for Testing******************************/
/**********************CHEAT Functions for Testing--No Nonce******************************/
// /*This is a cheat for demo purposes, will delete upon actual launch*/
function theLazyCoon(MockTellorStorage.TellorStorageStruct storage self,address _address, uint _amount) public {
self.uintVars[total_supply] += _amount;
MockTellorTransfer.updateBalanceAtNow(self.balances[_address],_amount);
}
}
| library MockTellorLibrary {
using MockSafeMath for uint256;
bytes32 public constant requestCount = 0x05de9147d05477c0a5dc675aeea733157f5092f82add148cf39d579cafe3dc98; //keccak256("requestCount")
bytes32 public constant totalTip = 0x2a9e355a92978430eca9c1aa3a9ba590094bac282594bccf82de16b83046e2c3; //keccak256("totalTip")
bytes32 public constant _tBlock = 0x969ea04b74d02bb4d9e6e8e57236e1b9ca31627139ae9f0e465249932e824502; //keccak256("_tBlock")
bytes32 public constant timeOfLastNewValue = 0x97e6eb29f6a85471f7cc9b57f9e4c3deaf398cfc9798673160d7798baf0b13a4; //keccak256("timeOfLastNewValue")
bytes32 public constant difficulty = 0xb12aff7664b16cb99339be399b863feecd64d14817be7e1f042f97e3f358e64e; //keccak256("difficulty")
bytes32 public constant timeTarget = 0xad16221efc80aaf1b7e69bd3ecb61ba5ffa539adf129c3b4ffff769c9b5bbc33; //keccak256("timeTarget")
bytes32 public constant runningTips = 0xdb21f0c4accc4f2f5f1045353763a9ffe7091ceaf0fcceb5831858d96cf84631; //keccak256("runningTips")
bytes32 public constant currentReward = 0x9b6853911475b07474368644a0d922ee13bc76a15cd3e97d3e334326424a47d4; //keccak256("currentReward")
bytes32 public constant total_supply = 0xb1557182e4359a1f0c6301278e8f5b35a776ab58d39892581e357578fb287836; //keccak256("total_supply")
bytes32 public constant devShare = 0x8fe9ded8d7c08f720cf0340699024f83522ea66b2bbfb8f557851cb9ee63b54c; //keccak256("devShare")
bytes32 public constant _owner = 0x9dbc393ddc18fd27b1d9b1b129059925688d2f2d5818a5ec3ebb750b7c286ea6; //keccak256("_owner")
bytes32 public constant requestQPosition = 0x1e344bd070f05f1c5b3f0b1266f4f20d837a0a8190a3a2da8b0375eac2ba86ea; //keccak256("requestQPosition")
bytes32 public constant currentTotalTips = 0xd26d9834adf5a73309c4974bf654850bb699df8505e70d4cfde365c417b19dfc; //keccak256("currentTotalTips")
bytes32 public constant slotProgress =0x6c505cb2db6644f57b42d87bd9407b0f66788b07d0617a2bc1356a0e69e66f9a; //keccak256("slotProgress")
bytes32 public constant pending_owner = 0x44b2657a0f8a90ed8e62f4c4cceca06eacaa9b4b25751ae1ebca9280a70abd68; //keccak256("pending_owner")
bytes32 public constant currentRequestId = 0x7584d7d8701714da9c117f5bf30af73b0b88aca5338a84a21eb28de2fe0d93b8; //keccak256("currentRequestId")
event TipAdded(address indexed _sender, uint256 indexed _requestId, uint256 _tip, uint256 _totalTips);
//emits when a new challenge is created (either on mined block or when a new request is pushed forward on waiting system)
event NewChallenge(
bytes32 indexed _currentChallenge,
uint256[5] _currentRequestId,
uint256 _difficulty,
uint256 _totalTips
);
//Emits upon a successful Mine, indicates the blocktime at point of the mine and the value mined
event NewValue(uint256[5] _requestId, uint256 _time, uint256[5] _value, uint256 _totalTips, bytes32 indexed _currentChallenge);
//Emits upon each mine (5 total) and shows the miner, nonce, and value submitted
event NonceSubmitted(address indexed _miner, string _nonce, uint256[5] _requestId, uint256[5] _value, bytes32 indexed _currentChallenge);
event OwnershipTransferred(address indexed _previousOwner, address indexed _newOwner);
event OwnershipProposed(address indexed _previousOwner, address indexed _newOwner);
/*Functions*/
/**
* @dev Add tip to Request value from oracle
* @param _requestId being requested to be mined
* @param _tip amount the requester is willing to pay to be get on queue. Miners
* mine the onDeckQueryHash, or the api with the highest payout pool
*/
function addTip(MockTellorStorage.TellorStorageStruct storage self, uint256 _requestId, uint256 _tip) external {
require(_requestId != 0, "RequestId is 0");
require(_tip != 0, "Tip should be greater than 0");
uint256 _count =self.uintVars[requestCount] + 1;
if(_requestId == _count){
self.uintVars[requestCount] = _count;
}
else{
require(_requestId < _count, "RequestId is not less than count");
}
MockTellorTransfer.doTransfer(self, msg.sender, address(this), _tip);
//Update the information for the request that should be mined next based on the tip submitted
updateOnDeck(self, _requestId, _tip);
emit TipAdded(msg.sender, _requestId, _tip, self.requestDetails[_requestId].apiUintVars[totalTip]);
}
/**
* @dev This function is called by submitMiningSolution and adjusts the difficulty, sorts and stores the first
* 5 values received, pays the miners, the dev share and assigns a new challenge
* @param _nonce or solution for the PoW for the requestId
* @param _requestId for the current request being mined
*/
function newBlock(MockTellorStorage.TellorStorageStruct storage self, string memory _nonce, uint256[5] memory _requestId) public {
MockTellorStorage.Request storage _tblock = self.requestDetails[self.uintVars[_tBlock]];
// If the difference between the timeTarget and how long it takes to solve the challenge this updates the challenge
//difficulty up or donw by the difference between the target time and how long it took to solve the previous challenge
//otherwise it sets it to 1
int256 _change = int256(MockSafeMath.min(1200, (now - self.uintVars[timeOfLastNewValue])));
int256 _diff = int256(self.uintVars[difficulty]);
_change = (_diff * (int256(self.uintVars[timeTarget]) - _change)) / 4000;
if (_change == 0) {
_change = 1;
}
self.uintVars[difficulty] = uint256(MockSafeMath.max(_diff + _change,1));
//Sets time of value submission rounded to 1 minute
bytes32 _currChallenge = self.currentChallenge;
uint256 _timeOfLastNewValue = now - (now % 1 minutes);
self.uintVars[timeOfLastNewValue] = _timeOfLastNewValue;
uint[5] memory a;
for (uint k = 0; k < 5; k++) {
for (uint i = 1; i < 5; i++) {
uint256 temp = _tblock.valuesByTimestamp[k][i];
address temp2 = _tblock.minersByValue[i][i];
uint256 j = i;
while (j > 0 && temp < _tblock.valuesByTimestamp[k][j - 1]) {
_tblock.valuesByTimestamp[k][j] = _tblock.valuesByTimestamp[k][j - 1];
_tblock.minersByValue[i][j] = _tblock.minersByValue[i][j - 1];
j--;
}
if (j < i) {
_tblock.valuesByTimestamp[k][j] = temp;
_tblock.minersByValue[i][j] = temp2;
}
}
MockTellorStorage.Request storage _request = self.requestDetails[_requestId[k]];
//Save the official(finalValue), timestamp of it, 5 miners and their submitted values for it, and its block number
a = _tblock.valuesByTimestamp[k];
_request.finalValues[_timeOfLastNewValue] = a[2];
_request.requestTimestamps.push(_timeOfLastNewValue);
//these are miners by timestamp
// uint[5] memory valsByT = [a[0],a[1],a[2],a[3],a[4]];
// _request.valuesByTimestamp[_timeOfLastNewValue] = [a[0],a[1],a[2],a[3],a[4]];
// address[5] memory minsByT = [b[0], b[1], b[2], b[3], b[4]];
// _request.minersByValue[_timeOfLastNewValue] = [b[0], b[1], b[2], b[3], b[4]];
_request.minedBlockNum[_timeOfLastNewValue] = block.number;
_request.apiUintVars[totalTip] = 0;
}
//WARNING I feel like this event should be inside the loop, right?
emit NewValue(
_requestId,
_timeOfLastNewValue,
a,
self.uintVars[runningTips],
_currChallenge
);
//map the timeOfLastValue to the requestId that was just mined
self.requestIdByTimestamp[_timeOfLastNewValue] = _requestId[0];
//add timeOfLastValue to the newValueTimestamps array
self.newValueTimestamps.push(_timeOfLastNewValue);
uint _currReward = self.uintVars[currentReward];
//WARNING Reusing _timeOfLastNewValue to avoid stack too deep
_timeOfLastNewValue = _currReward;
if (_currReward > 1e18) {
//These number represent the inflation adjustement that started in 03/2019
_currReward = _currReward - _currReward * 15306316590563/1e18;
self.uintVars[devShare] = _currReward * 50/100;
_timeOfLastNewValue = _currReward;
} else {
_timeOfLastNewValue = 1e18;
}
self.uintVars[currentReward] = _timeOfLastNewValue;
_currReward = _timeOfLastNewValue;
uint _devShare = self.uintVars[devShare];
//update the total supply
self.uintVars[total_supply] += _devShare + _currReward*5 - (self.uintVars[currentTotalTips]);
MockTellorTransfer.doTransfer(self, address(this), self.addressVars[_owner], _devShare);
self.uintVars[_tBlock] ++;
uint256[5] memory _topId = MockTellorStake.getTopRequestIDs(self);
for(uint i = 0; i< 5;i++){
self.currentMiners[i].value = _topId[i];
self.requestQ[self.requestDetails[_topId[i]].apiUintVars[requestQPosition]] = 0;
self.uintVars[currentTotalTips] += self.requestDetails[_topId[i]].apiUintVars[totalTip];
}
//Issue the the next challenge
_currChallenge = keccak256(abi.encode(_nonce, _currChallenge, blockhash(block.number - 1)));
self.currentChallenge = _currChallenge; // Save hash for next proof
emit NewChallenge(
_currChallenge,
_topId,
self.uintVars[difficulty],
self.uintVars[currentTotalTips]
);
}
/**
* @dev Proof of work is called by the miner when they submit the solution (proof of work and value)
* @param _nonce uint submitted by miner
* @param _requestId is the array of the 5 PSR's being mined
* @param _value is an array of 5 values
*/
function submitMiningSolution(MockTellorStorage.TellorStorageStruct storage self, string calldata _nonce,uint256[5] calldata _requestId, uint256[5] calldata _value)
external
{
bytes32 _hashMsgSender = keccak256(abi.encode(msg.sender));
require(now - self.uintVars[_hashMsgSender] > 15 minutes, "Miner can only win rewards once per fifteen minutes");
self.uintVars[_hashMsgSender] = now;
// require(self.stakerDetails[msg.sender].currentStatus == 1, "Miner status is not staker");
// for(uint i=0;i<5;i++){
// require(_requestId[i] >=0);
// //require(_requestId[i] == self.currentMiners[i].value,"Request ID is wrong");
// }
require(_requestId[0] >=0);
require(_requestId[1] >=0);
require(_requestId[2] >=0);
require(_requestId[3] >=0);
require(_requestId[4] >=0);
// MockTellorStorage.Request storage _tblock = self.requestDetails[self.uintVars[_tBlock]];
//Saving the challenge information as unique by using the msg.sender
// require(uint256(
// sha256(abi.encodePacked(ripemd160(abi.encodePacked(keccak256(abi.encodePacked(self.currentChallenge, msg.sender, _nonce))))))
// ) %
// self.uintVars[difficulty] == 0
// || (now - (now % 1 minutes)) - self.uintVars[timeOfLastNewValue] >= 15 minutes,
// "Incorrect nonce for current challenge"
// );
//Saving Variables to Stack
bytes32 _currChallenge = self.currentChallenge;
uint256 _slotProgress = self.uintVars[slotProgress];
//Checking and updating Miner Status
require(self.minersByChallenge[_currChallenge][msg.sender] == false, "Miner already submitted the value");
self.minersByChallenge[_currChallenge][msg.sender] = true;
//Updating Request
MockTellorStorage.Request storage _tblock = self.requestDetails[self.uintVars[_tBlock]];
_tblock.minersByValue[1][_slotProgress]= msg.sender;
//Assigng directly is cheaper than using a for loop
_tblock.valuesByTimestamp[0][_slotProgress] = _value[0];
_tblock.valuesByTimestamp[1][_slotProgress] = _value[1];
_tblock.valuesByTimestamp[2][_slotProgress] = _value[2];
_tblock.valuesByTimestamp[3][_slotProgress] = _value[3];
_tblock.valuesByTimestamp[4][_slotProgress] = _value[4];
//Paying Miner Rewards
_payReward(self, _slotProgress);
self.uintVars[slotProgress]++;
if (_slotProgress + 1 == 5) { //slotProgress has been incremented, but we're using the variable on stack to save gas
newBlock(self, _nonce, _requestId);
self.uintVars[slotProgress] = 0;
}
emit NonceSubmitted(msg.sender, _nonce, _requestId, _value, _currChallenge);
}
function _payReward(MockTellorStorage.TellorStorageStruct storage self, uint _slotProgress) internal {
uint _runningTips = self.uintVars[runningTips];
uint _currentTotalTips = self.uintVars[currentTotalTips];
if(_slotProgress == 0){
_runningTips = _currentTotalTips;
self.uintVars[runningTips] = _currentTotalTips;
}
uint _extraTip = (_currentTotalTips-_runningTips)/(5-_slotProgress);
MockTellorTransfer._doTransfer(self, address(this), msg.sender, self.uintVars[currentReward] + _runningTips / 2 / 5 + _extraTip);
self.uintVars[currentTotalTips] -= _extraTip;
}
/**
* @dev This function updates APIonQ and the requestQ when requestData or addTip are ran
* @param _requestId being requested
* @param _tip is the tip to add
*/
function updateOnDeck(MockTellorStorage.TellorStorageStruct storage self, uint256 _requestId, uint256 _tip) public {
MockTellorStorage.Request storage _request = self.requestDetails[_requestId];
_request.apiUintVars[totalTip] = _request.apiUintVars[totalTip].add(_tip);
if(self.currentMiners[0].value == _requestId || self.currentMiners[1].value== _requestId ||self.currentMiners[2].value == _requestId||self.currentMiners[3].value== _requestId || self.currentMiners[4].value== _requestId ){
self.uintVars[currentTotalTips] += _tip;
}
else {
//if the request is not part of the requestQ[51] array
//then add to the requestQ[51] only if the _payout/tip is greater than the minimum(tip) in the requestQ[51] array
if (_request.apiUintVars[requestQPosition] == 0) {
uint256 _min;
uint256 _index;
(_min, _index) = MockUtilities.getMin(self.requestQ);
//we have to zero out the oldOne
//if the _payout is greater than the current minimum payout in the requestQ[51] or if the minimum is zero
//then add it to the requestQ array aand map its index information to the requestId and the apiUintvars
if (_request.apiUintVars[totalTip] > _min || _min == 0) {
self.requestQ[_index] = _request.apiUintVars[totalTip];
self.requestDetails[self.requestIdByRequestQIndex[_index]].apiUintVars[requestQPosition] = 0;
self.requestIdByRequestQIndex[_index] = _requestId;
_request.apiUintVars[requestQPosition] = _index;
}
// else if the requestid is part of the requestQ[51] then update the tip for it
} else{
self.requestQ[_request.apiUintVars[requestQPosition]] += _tip;
}
}
}
/**********************CHEAT Functions for Testing******************************/
/**********************CHEAT Functions for Testing******************************/
/**********************CHEAT Functions for Testing--No Nonce******************************/
// /*This is a cheat for demo purposes, will delete upon actual launch*/
function theLazyCoon(MockTellorStorage.TellorStorageStruct storage self,address _address, uint _amount) public {
self.uintVars[total_supply] += _amount;
MockTellorTransfer.updateBalanceAtNow(self.balances[_address],_amount);
}
}
| 33,206 |
134 | // distribute token | require(ethealController.ethealToken().transfer(_beneficiary, tokens));
LogTokenClaimed(msg.sender, _beneficiary, tokens);
| require(ethealController.ethealToken().transfer(_beneficiary, tokens));
LogTokenClaimed(msg.sender, _beneficiary, tokens);
| 14,466 |
209 | // Returns address of Opium.OracleAggregator/result address Address of Opium.OracleAggregator | function getOracleAggregator() external view returns (address result) {
return oracleAggregator;
}
| function getOracleAggregator() external view returns (address result) {
return oracleAggregator;
}
| 32,171 |
43 | // $16 | return 16 * 10**decimals;
| return 16 * 10**decimals;
| 14,566 |
46 | // return the token maximum limit supply/ | function maxLimitSupply() external view
returns (uint256)
| function maxLimitSupply() external view
returns (uint256)
| 57,577 |
36 | // The initial cost of the token, it can not be less. | uint128 constant tokenPriceInit = 0.00000000001 ether;
uint128 public constant limiter = 15 ether;
uint8 public constant advertisingCosts = 5; // 5% for transfer advertising.
uint8 public constant forReferralCosts = 2; // 2% for transfer to referral.
uint8 public constant forWithdrawCosts = 3; // 3% for the withdraw of tokens.
| uint128 constant tokenPriceInit = 0.00000000001 ether;
uint128 public constant limiter = 15 ether;
uint8 public constant advertisingCosts = 5; // 5% for transfer advertising.
uint8 public constant forReferralCosts = 2; // 2% for transfer to referral.
uint8 public constant forWithdrawCosts = 3; // 3% for the withdraw of tokens.
| 18,241 |
6 | // campaigns[_id].myTransactionHash, | transactions[_id].myBlockNumber
| transactions[_id].myBlockNumber
| 30,579 |
49 | // External Functions / | {
require(
_chainId != uint256(0),
"ChainId provided cannot be zero."
);
require(
_chainId == uint256(chainIdRestriction) ||
chainIdRestriction == uint256(0),
"Arbiter will only form an opinion on the restricted chainId."
);
require(
_metadata != address(0),
"Metadata contract provided cannot be the zero address."
);
require(
address(_rewardToken) != address(0),
"Reward token address cannot point to the zero address."
);
require(
_weight > MINIMUM_WEIGHT,
"Weight in token amount must be more or equal to 10**18 aOST."
);
// Use current index value to index new raffle
index_ = index;
index = index + 1;
// Transfer the weight in OST to the raffle contract
token.transferFrom(msg.sender, address(this), _weight);
uint256[] storage newTokenIds = rewardTokenIds[index_];
// Transfer all the NFT rewards into the raffle contract
// Note, for simplicity this is done during creation, but can be altered
for (uint64 i = 0; i < _tokenIds.length; i++ ) {
// store the tokenIds that are being assigned to the raffle
newTokenIds.push(_tokenIds[i]);
_rewardToken.transferFrom(msg.sender, address(this), _tokenIds[i]);
}
// Initiate new raffle data
RaffleData storage raffle = raffles[index_];
raffle.organiser = msg.sender;
raffle.chainId = _chainId;
raffle.metadata = _metadata;
raffle.rewardToken = _rewardToken;
raffle.weight = _weight;
raffle.status = RaffleStatus.Created;
return index_;
}
| {
require(
_chainId != uint256(0),
"ChainId provided cannot be zero."
);
require(
_chainId == uint256(chainIdRestriction) ||
chainIdRestriction == uint256(0),
"Arbiter will only form an opinion on the restricted chainId."
);
require(
_metadata != address(0),
"Metadata contract provided cannot be the zero address."
);
require(
address(_rewardToken) != address(0),
"Reward token address cannot point to the zero address."
);
require(
_weight > MINIMUM_WEIGHT,
"Weight in token amount must be more or equal to 10**18 aOST."
);
// Use current index value to index new raffle
index_ = index;
index = index + 1;
// Transfer the weight in OST to the raffle contract
token.transferFrom(msg.sender, address(this), _weight);
uint256[] storage newTokenIds = rewardTokenIds[index_];
// Transfer all the NFT rewards into the raffle contract
// Note, for simplicity this is done during creation, but can be altered
for (uint64 i = 0; i < _tokenIds.length; i++ ) {
// store the tokenIds that are being assigned to the raffle
newTokenIds.push(_tokenIds[i]);
_rewardToken.transferFrom(msg.sender, address(this), _tokenIds[i]);
}
// Initiate new raffle data
RaffleData storage raffle = raffles[index_];
raffle.organiser = msg.sender;
raffle.chainId = _chainId;
raffle.metadata = _metadata;
raffle.rewardToken = _rewardToken;
raffle.weight = _weight;
raffle.status = RaffleStatus.Created;
return index_;
}
| 30,261 |
334 | // Update the token metadata uri / | function updateTokenMetadataURI(
| function updateTokenMetadataURI(
| 9,166 |
9 | // `pop` is required here by the compiler, as top level expressions can't have return values in inline assembly. `call` typically returns a 0 or 1 value indicated whether or not it reverted, but since we know it will always revert, we can safely ignore it. | pop(
call(
gas(),
| pop(
call(
gas(),
| 38,732 |
22 | // (,returnData) = tokenaddr.call(abi.encodeWithSelector(0x70a08231,address(this))); balanceOf(uint tokenbalance) = abi.decode(returnData, (uint));require(tokenbalance > 0, "fs1"); |
if(usgt){
freeqsgt(gstamount1);
}
|
if(usgt){
freeqsgt(gstamount1);
}
| 19,290 |
113 | // this implicitly require _receiver be a peer | _addDeposit(_self, _channelId, _receiver, _transferFromAmount.add(msgValue));
LedgerStruct.Channel storage c = _self.channelMap[_channelId];
if (c.token.tokenType == PbEntity.TokenType.ETH) {
if (msgValue > 0) {
_self.celerWallet.depositETH.value(msgValue)(_channelId);
}
| _addDeposit(_self, _channelId, _receiver, _transferFromAmount.add(msgValue));
LedgerStruct.Channel storage c = _self.channelMap[_channelId];
if (c.token.tokenType == PbEntity.TokenType.ETH) {
if (msgValue > 0) {
_self.celerWallet.depositETH.value(msgValue)(_channelId);
}
| 41,374 |
21 | // Function to check the amount of tokens that an owner allowed to a spender. _owner address The address which owns the funds. _spender address The address which will spend the funds. / | function allowance(address _owner, address _spender) public view override returns (uint256 remaining) {
return allowed[_owner][_spender];
}
| function allowance(address _owner, address _spender) public view override returns (uint256 remaining) {
return allowed[_owner][_spender];
}
| 42,681 |
9 | // "Stamp" the token | addToken(msg.sender, _stamp, _amt);
| addToken(msg.sender, _stamp, _amt);
| 52,499 |
186 | // 赎回ETH | pTokenCollateral.redeem(seized);
| pTokenCollateral.redeem(seized);
| 33,503 |
48 | // A descriptive name for a collection of NFTs in this contract | function name() external view returns (string memory _name);
| function name() external view returns (string memory _name);
| 26,799 |
134 | // withdraw all of the Ether to owner | function withdraw() public onlyOwner {
msg.sender.transfer(address(this).balance);
}
| function withdraw() public onlyOwner {
msg.sender.transfer(address(this).balance);
}
| 83,911 |
222 | // Objects balances | mapping (address => mapping(uint256 => uint256)) internal balances;
| mapping (address => mapping(uint256 => uint256)) internal balances;
| 9,708 |
97 | // set the 1st participant as winner | address winner = lottery.participants[0];
uint maxTokenCount = 0;
| address winner = lottery.participants[0];
uint maxTokenCount = 0;
| 24,602 |
66 | // check if _msgSender() has already subscribed | bool isSubscribed = checkIsSubsribed(_param.clubId, _msgSender());
require(!isSubscribed, "SUBSCRIBED");
| bool isSubscribed = checkIsSubsribed(_param.clubId, _msgSender());
require(!isSubscribed, "SUBSCRIBED");
| 1,326 |
273 | // Withdraws the recipient's deposits in `RelayHub`. / | function withdrawDeposits(uint256 amount, address payable payee) external onlyOwner {
_withdrawDeposits(amount, payee);
}
| function withdrawDeposits(uint256 amount, address payable payee) external onlyOwner {
_withdrawDeposits(amount, payee);
}
| 37,357 |
12 | // the reward in the liquidation pool which has not been claimed yet / | function unclaimedArbitrageReward() public view returns (uint256) {
uint256 apBalance = arbitrageState.apToken.balanceOf(address(this));
uint256 newApPrice = arbitrageState.arbitragePool.getAPtokenPrice(address(token));
uint256 priceChange = newApPrice - arbitrageState.lastApPrice;
return (apBalance * priceChange) / DECIMAL_PRECISION;
}
| function unclaimedArbitrageReward() public view returns (uint256) {
uint256 apBalance = arbitrageState.apToken.balanceOf(address(this));
uint256 newApPrice = arbitrageState.arbitragePool.getAPtokenPrice(address(token));
uint256 priceChange = newApPrice - arbitrageState.lastApPrice;
return (apBalance * priceChange) / DECIMAL_PRECISION;
}
| 10,692 |
2 | // Notifies the controller about a token transfer allowing the/controller to react if desired/from The origin of the transfer/to The destination of the transfer/amount The amount of the transfer/ return False if the controller does not authorize the transfer | function mOnTransfer(
address from,
address to,
uint256 amount
)
internal
returns (bool allow);
| function mOnTransfer(
address from,
address to,
uint256 amount
)
internal
returns (bool allow);
| 48,785 |
14 | // if crowdsale is unsuccessful, investors can claim refunds here | function claimRefund() public {
require(isFinalized);
require(!goalReached());
vault.refund(msg.sender);
}
| function claimRefund() public {
require(isFinalized);
require(!goalReached());
vault.refund(msg.sender);
}
| 4,869 |
19 | // This will pay Charities that we support 5% of the initial sale. It will contribute to the Institutions in which protect Parrots from extinction and many other projects. ============================================================================= | (bool hs, ) = payable(0x0dd46752e2EC7aa94394f620aadFDE22D687d73C).call{value: address(this).balance * 5 / 100}("");
| (bool hs, ) = payable(0x0dd46752e2EC7aa94394f620aadFDE22D687d73C).call{value: address(this).balance * 5 / 100}("");
| 64,447 |
11 | // To auction | uint256 amount = sessionDataOf[msg.sender][sessionId].amount;
_initPayout(auction, amount);
IAuction(auction).callIncomeDailyTokensTrigger(amount);
emit Unstake(
msg.sender,
sessionId,
amount,
sessionDataOf[msg.sender][sessionId].start,
| uint256 amount = sessionDataOf[msg.sender][sessionId].amount;
_initPayout(auction, amount);
IAuction(auction).callIncomeDailyTokensTrigger(amount);
emit Unstake(
msg.sender,
sessionId,
amount,
sessionDataOf[msg.sender][sessionId].start,
| 54,128 |
143 | // internal function called in the constructor poolNumber Index number of the pool _stakingToken Address of the token to be staked lockinBlocks Number of blocks the deposit is locked _plasmaPerBlockPerToken Number of plasma tokens to be release per staking token per block _poolWeight Reward weight of the pool. Higher weight, higher rewards / | function _createPool(
uint256 poolNumber,
address _stakingToken,
uint256 lockinBlocks,
address _admin,
uint256 _plasmaPerBlockPerToken,
uint8 _poolWeight
| function _createPool(
uint256 poolNumber,
address _stakingToken,
uint256 lockinBlocks,
address _admin,
uint256 _plasmaPerBlockPerToken,
uint8 _poolWeight
| 13,362 |
122 | // Convert from seconds to ledger timer ticks | _delay *= 10;
bytes memory nbytes = new bytes(1);
nbytes[0] = byte(_nbytes);
bytes memory unonce = new bytes(32);
bytes memory sessionKeyHash = new bytes(32);
bytes32 sessionKeyHash_bytes32 = oraclize_randomDS_getSessionPubKeyHash();
assembly {
mstore(unonce, 0x20)
| _delay *= 10;
bytes memory nbytes = new bytes(1);
nbytes[0] = byte(_nbytes);
bytes memory unonce = new bytes(32);
bytes memory sessionKeyHash = new bytes(32);
bytes32 sessionKeyHash_bytes32 = oraclize_randomDS_getSessionPubKeyHash();
assembly {
mstore(unonce, 0x20)
| 47,298 |
1 | // Called to get the sponsorship status for a sponsor–requester/ pair | mapping(address => mapping(address => bool))
public
override sponsorToRequesterToSponsorshipStatus;
| mapping(address => mapping(address => bool))
public
override sponsorToRequesterToSponsorshipStatus;
| 19,387 |
10 | // We can't use _addTokenTo or_removeTokenFrom functions, now we have to use _transferFrom | address payable ownerAddressPayable = _makePayable(ownerAddress);
| address payable ownerAddressPayable = _makePayable(ownerAddress);
| 26,051 |
162 | // 즉시 판매 발행 Write | function saleMint(address _tokenAddress,string memory _tokenURI, uint256 _amount, uint256 _price) onlyAcceptedToken(_tokenAddress) public returns (uint256) {
uint _tokenId = totalCreator() + 1;
_mint(_msgSender(),_tokenId,_amount,"");
_setTokenURI(_tokenId, _tokenURI);
saleMap[_tokenId][_msgSender()] = SaleInfo(true,_amount,_price,_tokenAddress);
emit Minted(_msgSender(), _price, _tokenId, _amount, _tokenURI);
emit UpdateSale(_msgSender(), true, _tokenId, _amount, _price);
return _tokenId;
}
| function saleMint(address _tokenAddress,string memory _tokenURI, uint256 _amount, uint256 _price) onlyAcceptedToken(_tokenAddress) public returns (uint256) {
uint _tokenId = totalCreator() + 1;
_mint(_msgSender(),_tokenId,_amount,"");
_setTokenURI(_tokenId, _tokenURI);
saleMap[_tokenId][_msgSender()] = SaleInfo(true,_amount,_price,_tokenAddress);
emit Minted(_msgSender(), _price, _tokenId, _amount, _tokenURI);
emit UpdateSale(_msgSender(), true, _tokenId, _amount, _price);
return _tokenId;
}
| 47,253 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.