Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- StrategyStandardSaleForFixedPriceV1B
- Optimization enabled
- true
- Compiler version
- v0.8.7+commit.e28d00a7
- Optimization runs
- 888888
- EVM Version
- default
- Verified at
- 2023-02-28T08:15:42.896247Z
Contract source code
// Sources flattened with hardhat v2.9.3 https://hardhat.org
// File @openzeppelin/contracts/utils/[email protected]
// 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;
}
}
// File @openzeppelin/contracts/access/[email protected]
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
pragma solidity ^0.8.0;
/**
* @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);
}
}
// File contracts/libraries/OrderTypes.sol
pragma solidity ^0.8.0;
/**
* @title OrderTypes
* @notice This library contains order types for the MojitoNFT exchange.
*/
library OrderTypes {
// keccak256("MakerOrder(bool isOrderAsk,address signer,address collection,uint256 price,uint256 tokenId,uint256 amount,address strategy,address currency,uint256 nonce,uint256 startTime,uint256 endTime,uint256 minPercentageToAsk,bytes params)")
bytes32 internal constant MAKER_ORDER_HASH = 0x40261ade532fa1d2c7293df30aaadb9b3c616fae525a0b56d3d411c841a85028;
struct MakerOrder {
bool isOrderAsk; // true --> ask / false --> bid
address signer; // signer of the maker order
address collection; // collection address
uint256 price; // price (used as )
uint256 tokenId; // id of the token
uint256 amount; // amount of tokens to sell/purchase (must be 1 for ERC721, 1+ for ERC1155)
address strategy; // strategy for trade execution (e.g., DutchAuction, StandardSaleForFixedPrice)
address currency; // currency (e.g., WETH)
uint256 nonce; // order nonce (must be unique unless new maker order is meant to override existing one e.g., lower ask price)
uint256 startTime; // startTime in timestamp
uint256 endTime; // endTime in timestamp
uint256 minPercentageToAsk; // slippage protection (9000 --> 90% of the final price must return to ask)
bytes params; // additional parameters
uint8 v; // v: parameter (27 or 28)
bytes32 r; // r: parameter
bytes32 s; // s: parameter
}
struct TakerOrder {
bool isOrderAsk; // true --> ask / false --> bid
address taker; // msg.sender
uint256 price; // final price for the purchase
uint256 tokenId;
uint256 minPercentageToAsk; // // slippage protection (9000 --> 90% of the final price must return to ask)
bytes params; // other params (e.g., tokenId)
}
function hash(MakerOrder memory makerOrder) internal pure returns (bytes32) {
return
keccak256(
abi.encode(
MAKER_ORDER_HASH,
makerOrder.isOrderAsk,
makerOrder.signer,
makerOrder.collection,
makerOrder.price,
makerOrder.tokenId,
makerOrder.amount,
makerOrder.strategy,
makerOrder.currency,
makerOrder.nonce,
makerOrder.startTime,
makerOrder.endTime,
makerOrder.minPercentageToAsk,
keccak256(makerOrder.params)
)
);
}
}
// File contracts/interfaces/IExecutionStrategy.sol
pragma solidity ^0.8.0;
interface IExecutionStrategy {
function canExecuteTakerAsk(OrderTypes.TakerOrder calldata takerAsk, OrderTypes.MakerOrder calldata makerBid)
external
view
returns (
bool,
uint256,
uint256
);
function canExecuteTakerBid(OrderTypes.TakerOrder calldata takerBid, OrderTypes.MakerOrder calldata makerAsk)
external
view
returns (
bool,
uint256,
uint256
);
function viewProtocolFee() external view returns (uint256);
}
// File contracts/executionStrategies/StrategyStandardSaleForFixedPriceV1B.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @title StrategyStandardSaleForFixedPriceV1B
* @notice Strategy that executes an order at a fixed price that
* can be taken either by a bid or an ask.
*/
contract StrategyStandardSaleForFixedPriceV1B is Ownable, IExecutionStrategy {
// Event if the protocol fee changes
event NewProtocolFee(uint256 protocolFee);
// Protocol fee
uint256 internal _protocolFee = 150;
/**
* @notice Check whether a taker ask order can be executed against a maker bid
* @param takerAsk taker ask order
* @param makerBid maker bid order
* @return (whether strategy can be executed, tokenId to execute, amount of tokens to execute)
*/
function canExecuteTakerAsk(OrderTypes.TakerOrder calldata takerAsk, OrderTypes.MakerOrder calldata makerBid)
external
view
override
returns (
bool,
uint256,
uint256
)
{
return (
((makerBid.price == takerAsk.price) &&
(makerBid.tokenId == takerAsk.tokenId) &&
(makerBid.startTime <= block.timestamp) &&
(makerBid.endTime >= block.timestamp)),
makerBid.tokenId,
makerBid.amount
);
}
/**
* @notice Check whether a taker bid order can be executed against a maker ask
* @param takerBid taker bid order
* @param makerAsk maker ask order
* @return (whether strategy can be executed, tokenId to execute, amount of tokens to execute)
*/
function canExecuteTakerBid(OrderTypes.TakerOrder calldata takerBid, OrderTypes.MakerOrder calldata makerAsk)
external
view
override
returns (
bool,
uint256,
uint256
)
{
return (
((makerAsk.price == takerBid.price) &&
(makerAsk.tokenId == takerBid.tokenId) &&
(makerAsk.startTime <= block.timestamp) &&
(makerAsk.endTime >= block.timestamp)),
makerAsk.tokenId,
makerAsk.amount
);
}
/**
* @notice Set new protocol fee for this strategy
* @param newProtocolFee protocol fee
*/
function setProtocolFee(uint256 newProtocolFee) external onlyOwner {
require(newProtocolFee <= 200, "Owner: Protocol fee too high");
_protocolFee = newProtocolFee;
emit NewProtocolFee(newProtocolFee);
}
/**
* @notice Return protocol fee for this strategy
* @return protocol fee
*/
function viewProtocolFee() external view override returns (uint256) {
return _protocolFee;
}
}
Contract ABI
[{"type":"event","name":"NewProtocolFee","inputs":[{"type":"uint256","name":"protocolFee","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"}],"name":"canExecuteTakerAsk","inputs":[{"type":"tuple","name":"takerAsk","internalType":"struct OrderTypes.TakerOrder","components":[{"type":"bool","name":"isOrderAsk","internalType":"bool"},{"type":"address","name":"taker","internalType":"address"},{"type":"uint256","name":"price","internalType":"uint256"},{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"uint256","name":"minPercentageToAsk","internalType":"uint256"},{"type":"bytes","name":"params","internalType":"bytes"}]},{"type":"tuple","name":"makerBid","internalType":"struct OrderTypes.MakerOrder","components":[{"type":"bool","name":"isOrderAsk","internalType":"bool"},{"type":"address","name":"signer","internalType":"address"},{"type":"address","name":"collection","internalType":"address"},{"type":"uint256","name":"price","internalType":"uint256"},{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"address","name":"strategy","internalType":"address"},{"type":"address","name":"currency","internalType":"address"},{"type":"uint256","name":"nonce","internalType":"uint256"},{"type":"uint256","name":"startTime","internalType":"uint256"},{"type":"uint256","name":"endTime","internalType":"uint256"},{"type":"uint256","name":"minPercentageToAsk","internalType":"uint256"},{"type":"bytes","name":"params","internalType":"bytes"},{"type":"uint8","name":"v","internalType":"uint8"},{"type":"bytes32","name":"r","internalType":"bytes32"},{"type":"bytes32","name":"s","internalType":"bytes32"}]}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"}],"name":"canExecuteTakerBid","inputs":[{"type":"tuple","name":"takerBid","internalType":"struct OrderTypes.TakerOrder","components":[{"type":"bool","name":"isOrderAsk","internalType":"bool"},{"type":"address","name":"taker","internalType":"address"},{"type":"uint256","name":"price","internalType":"uint256"},{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"uint256","name":"minPercentageToAsk","internalType":"uint256"},{"type":"bytes","name":"params","internalType":"bytes"}]},{"type":"tuple","name":"makerAsk","internalType":"struct OrderTypes.MakerOrder","components":[{"type":"bool","name":"isOrderAsk","internalType":"bool"},{"type":"address","name":"signer","internalType":"address"},{"type":"address","name":"collection","internalType":"address"},{"type":"uint256","name":"price","internalType":"uint256"},{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"address","name":"strategy","internalType":"address"},{"type":"address","name":"currency","internalType":"address"},{"type":"uint256","name":"nonce","internalType":"uint256"},{"type":"uint256","name":"startTime","internalType":"uint256"},{"type":"uint256","name":"endTime","internalType":"uint256"},{"type":"uint256","name":"minPercentageToAsk","internalType":"uint256"},{"type":"bytes","name":"params","internalType":"bytes"},{"type":"uint8","name":"v","internalType":"uint8"},{"type":"bytes32","name":"r","internalType":"bytes32"},{"type":"bytes32","name":"s","internalType":"bytes32"}]}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setProtocolFee","inputs":[{"type":"uint256","name":"newProtocolFee","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"viewProtocolFee","inputs":[]}]
Contract Creation Code
0x6080604052609660015534801561001557600080fd5b5061001f33610024565b610074565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6105d8806100836000396000f3fe608060405234801561001057600080fd5b506004361061007d5760003560e01c80638da5cb5b1161005b5780638da5cb5b146100d45780639dd1cda6146100fc578063ad2390ac1461009f578063f2fde38b1461010d57600080fd5b8063715018a614610082578063787dce3d1461008c578063865781ca1461009f575b600080fd5b61008a610120565b005b61008a61009a366004610589565b6101b2565b6100b26100ad366004610515565b6102d9565b6040805193151584526020840192909252908201526060015b60405180910390f35b60005460405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100cb565b6001546040519081526020016100cb565b61008a61011b3660046104d8565b610333565b60005473ffffffffffffffffffffffffffffffffffffffff1633146101a6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b6101b06000610463565b565b60005473ffffffffffffffffffffffffffffffffffffffff163314610233576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161019d565b60c881111561029e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4f776e65723a2050726f746f636f6c2066656520746f6f206869676800000000604482015260640161019d565b60018190556040518181527f3e1c6f794380f768303ee10adb978482d0ee037b0517bdabf3118141632078a69060200160405180910390a150565b6000806000846040013584606001351480156102fc575084606001358460800135145b801561030d57504284610120013511155b801561031e57504284610140013510155b92505050608082013560a08301359250925092565b60005473ffffffffffffffffffffffffffffffffffffffff1633146103b4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161019d565b73ffffffffffffffffffffffffffffffffffffffff8116610457576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161019d565b61046081610463565b50565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000602082840312156104ea57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff8116811461050e57600080fd5b9392505050565b6000806040838503121561052857600080fd5b823567ffffffffffffffff8082111561054057600080fd5b9084019060c0828703121561055457600080fd5b9092506020840135908082111561056a57600080fd5b508301610200818603121561057e57600080fd5b809150509250929050565b60006020828403121561059b57600080fd5b503591905056fea2646970667358221220f1229f13d131a3ea6f04ad111857eff17552805b4b35d3673e40fa1e538d77dc64736f6c63430008070033
Deployed ByteCode
0x608060405234801561001057600080fd5b506004361061007d5760003560e01c80638da5cb5b1161005b5780638da5cb5b146100d45780639dd1cda6146100fc578063ad2390ac1461009f578063f2fde38b1461010d57600080fd5b8063715018a614610082578063787dce3d1461008c578063865781ca1461009f575b600080fd5b61008a610120565b005b61008a61009a366004610589565b6101b2565b6100b26100ad366004610515565b6102d9565b6040805193151584526020840192909252908201526060015b60405180910390f35b60005460405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100cb565b6001546040519081526020016100cb565b61008a61011b3660046104d8565b610333565b60005473ffffffffffffffffffffffffffffffffffffffff1633146101a6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b6101b06000610463565b565b60005473ffffffffffffffffffffffffffffffffffffffff163314610233576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161019d565b60c881111561029e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4f776e65723a2050726f746f636f6c2066656520746f6f206869676800000000604482015260640161019d565b60018190556040518181527f3e1c6f794380f768303ee10adb978482d0ee037b0517bdabf3118141632078a69060200160405180910390a150565b6000806000846040013584606001351480156102fc575084606001358460800135145b801561030d57504284610120013511155b801561031e57504284610140013510155b92505050608082013560a08301359250925092565b60005473ffffffffffffffffffffffffffffffffffffffff1633146103b4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161019d565b73ffffffffffffffffffffffffffffffffffffffff8116610457576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161019d565b61046081610463565b50565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000602082840312156104ea57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff8116811461050e57600080fd5b9392505050565b6000806040838503121561052857600080fd5b823567ffffffffffffffff8082111561054057600080fd5b9084019060c0828703121561055457600080fd5b9092506020840135908082111561056a57600080fd5b508301610200818603121561057e57600080fd5b809150509250929050565b60006020828403121561059b57600080fd5b503591905056fea2646970667358221220f1229f13d131a3ea6f04ad111857eff17552805b4b35d3673e40fa1e538d77dc64736f6c63430008070033