Feature Tip: Add private address tag to any address under My Name Tag !
Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Transfer Ownersh... | 14660216 | 1092 days ago | IN | 0 ETH | 0.00122837 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Name:
PriceCalculatorDrop25PerDay
Compiler Version
v0.8.12+commit.f00d7308
Optimization Enabled:
Yes with 1000000 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.2; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "./interfaces/IPriceCalculator.sol"; contract PriceCalculatorDrop25PerDay is IPriceCalculator, Ownable { function calculateCurrentPrice( uint256 startingPrice, uint256 listedOn ) external view returns (uint256) { return _calculate(startingPrice, listedOn, block.timestamp); } function calculatePrice( uint256 startingPrice, uint256 listedOn, uint256 time ) external pure returns (uint256) { return _calculate(startingPrice, listedOn, time); } function isPriceAllowed( uint256 startingPrice ) external pure returns (bool) { (bool isSuccess,) = SafeMath.tryMul(startingPrice, 3); if (isSuccess == false) { return false; } uint256 nextDayPrice = startingPrice * 3 / 4; uint256 diff = startingPrice - nextDayPrice; (isSuccess,) = SafeMath.tryMul(diff, 86399); if (isSuccess == false) { return false; } return true; } function _calculate( uint256 startingPrice, uint256 listedOn, uint256 currentTime ) internal pure returns (uint256) { uint256 daysGone = (currentTime - listedOn) / 86400; uint256 currentPrice = startingPrice; for (uint256 index = 0; index < daysGone; index++) { currentPrice = currentPrice * 3 / 4; if (currentPrice == 0) { return 0; } } uint256 partInADay = (currentTime - listedOn) % 86400; if (partInADay != 0) { uint256 nextDayPrice = currentPrice * 3 / 4; uint256 partInADayPrice = (currentPrice - nextDayPrice) * partInADay / 86400; currentPrice = currentPrice - partInADayPrice; } return currentPrice; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol) pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.2; interface IPriceCalculator { function calculatePrice( uint256 startingPrice, uint256 listedOn, uint256 time ) external pure returns (uint256); function calculateCurrentPrice( uint256 startingPrice, uint256 listedOn ) external view returns (uint256); function isPriceAllowed( uint256 startingPrice ) external pure returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
{ "optimizer": { "enabled": true, "runs": 1000000 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[{"internalType":"uint256","name":"startingPrice","type":"uint256"},{"internalType":"uint256","name":"listedOn","type":"uint256"}],"name":"calculateCurrentPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"startingPrice","type":"uint256"},{"internalType":"uint256","name":"listedOn","type":"uint256"},{"internalType":"uint256","name":"time","type":"uint256"}],"name":"calculatePrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"startingPrice","type":"uint256"}],"name":"isPriceAllowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b5061001a3361001f565b61006f565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6106fc8061007e6000396000f3fe608060405234801561001057600080fd5b50600436106100725760003560e01c8063b1ab13ff11610050578063b1ab13ff146100d1578063e015c62a146100f2578063f2fde38b1461010557600080fd5b8063111439e314610077578063715018a61461009f5780638da5cb5b146100a9575b600080fd5b61008a610085366004610516565b610118565b60405190151581526020015b60405180910390f35b6100a761018b565b005b60005460405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610096565b6100e46100df36600461052f565b61021d565b604051908152602001610096565b6100e4610100366004610551565b610231565b6100a761011336600461057d565b610246565b600080610126836003610376565b509050806101375750600092915050565b600060046101468560036105e2565b610150919061064e565b9050600061015e8286610662565b905061016d816201517f610376565b5092508261018057506000949350505050565b506001949350505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610211576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b61021b60006103be565b565b600061022a838342610433565b9392505050565b600061023e848484610433565b949350505050565b60005473ffffffffffffffffffffffffffffffffffffffff1633146102c7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610208565b73ffffffffffffffffffffffffffffffffffffffff811661036a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610208565b610373816103be565b50565b6000808361038a57506001905060006103b7565b8383028385828161039d5761039d61061f565b04146103b05760008092509250506103b7565b6001925090505b9250929050565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600080620151806104448585610662565b61044e919061064e565b90508460005b828110156104985760046104698360036105e2565b610473919061064e565b915081610486576000935050505061022a565b8061049081610679565b915050610454565b506000620151806104a98787610662565b6104b391906106b2565b9050801561050c57600060046104ca8460036105e2565b6104d4919061064e565b9050600062015180836104e78487610662565b6104f191906105e2565b6104fb919061064e565b90506105078185610662565b935050505b5095945050505050565b60006020828403121561052857600080fd5b5035919050565b6000806040838503121561054257600080fd5b50508035926020909101359150565b60008060006060848603121561056657600080fd5b505081359360208301359350604090920135919050565b60006020828403121561058f57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff8116811461022a57600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561061a5761061a6105b3565b500290565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60008261065d5761065d61061f565b500490565b600082821015610674576106746105b3565b500390565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156106ab576106ab6105b3565b5060010190565b6000826106c1576106c161061f565b50069056fea26469706673582212202330217b6695258b26cd075987b5e6daca3733fa3d002a14212bc9ecfc6c405c64736f6c634300080c0033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100725760003560e01c8063b1ab13ff11610050578063b1ab13ff146100d1578063e015c62a146100f2578063f2fde38b1461010557600080fd5b8063111439e314610077578063715018a61461009f5780638da5cb5b146100a9575b600080fd5b61008a610085366004610516565b610118565b60405190151581526020015b60405180910390f35b6100a761018b565b005b60005460405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610096565b6100e46100df36600461052f565b61021d565b604051908152602001610096565b6100e4610100366004610551565b610231565b6100a761011336600461057d565b610246565b600080610126836003610376565b509050806101375750600092915050565b600060046101468560036105e2565b610150919061064e565b9050600061015e8286610662565b905061016d816201517f610376565b5092508261018057506000949350505050565b506001949350505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610211576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b61021b60006103be565b565b600061022a838342610433565b9392505050565b600061023e848484610433565b949350505050565b60005473ffffffffffffffffffffffffffffffffffffffff1633146102c7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610208565b73ffffffffffffffffffffffffffffffffffffffff811661036a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610208565b610373816103be565b50565b6000808361038a57506001905060006103b7565b8383028385828161039d5761039d61061f565b04146103b05760008092509250506103b7565b6001925090505b9250929050565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600080620151806104448585610662565b61044e919061064e565b90508460005b828110156104985760046104698360036105e2565b610473919061064e565b915081610486576000935050505061022a565b8061049081610679565b915050610454565b506000620151806104a98787610662565b6104b391906106b2565b9050801561050c57600060046104ca8460036105e2565b6104d4919061064e565b9050600062015180836104e78487610662565b6104f191906105e2565b6104fb919061064e565b90506105078185610662565b935050505b5095945050505050565b60006020828403121561052857600080fd5b5035919050565b6000806040838503121561054257600080fd5b50508035926020909101359150565b60008060006060848603121561056657600080fd5b505081359360208301359350604090920135919050565b60006020828403121561058f57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff8116811461022a57600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561061a5761061a6105b3565b500290565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60008261065d5761065d61061f565b500490565b600082821015610674576106746105b3565b500390565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156106ab576106ab6105b3565b5060010190565b6000826106c1576106c161061f565b50069056fea26469706673582212202330217b6695258b26cd075987b5e6daca3733fa3d002a14212bc9ecfc6c405c64736f6c634300080c0033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.