Address Contract Verified
Address
0x89437857bbc7DD6BC16fdA669F04a4D5e7C0554F
Balance
0 ETH
Nonce
1
Code Size
5096 bytes
Creator
0x7F91208F...F911 at tx 0x8d025dac...a4888f
Indexed Transactions
0
Contract Bytecode
5096 bytes
0x60806040526004361061012a5760003560e01c80637d9f6db5116100ab578063ce9c7c0d1161006f578063ce9c7c0d14610366578063d5563f3114610386578063db2e1eed146103a6578063ec91f2a4146103bc578063f25efffc146103d2578063f2fde38b146103e757600080fd5b80637d9f6db51461027e5780638456cb59146102f25780638da5cb5b14610307578063a4d0a17e14610325578063b296024d1461033a57600080fd5b80635c975abb116100f25780635c975abb146101e7578063659dd2b4146102165780637120334b14610229578063715018a6146102495780637d85b7f71461025e57600080fd5b80630c0b6f461461012f578063159f58191461015857806336ebdb38146101905780633f4ba83a146101b25780634a3d3d98146101c7575b600080fd5b34801561013b57600080fd5b5061014560045481565b6040519081526020015b60405180910390f35b34801561016457600080fd5b50600254610178906001600160a01b031681565b6040516001600160a01b03909116815260200161014f565b34801561019c57600080fd5b506101b06101ab366004611183565b610407565b005b3480156101be57600080fd5b506101b0610458565b3480156101d357600080fd5b506101b06101e23660046111c2565b610472565b3480156101f357600080fd5b5060065461020690610100900460ff1681565b604051901515815260200161014f565b6101b06102243660046111df565b61049c565b34801561023557600080fd5b506101b06102443660046111df565b61084b565b34801561025557600080fd5b506101b0610888565b34801561026a57600080fd5b506101b06102793660046111df565b61089a565b34801561028a57600080fd5b50600754600854600954600a54600b546102ba94939291906001600160a01b03811690600160a01b900460ff1686565b6040805196875260208701959095529385019290925260608401526001600160a01b03166080830152151560a082015260c00161014f565b3480156102fe57600080fd5b506101b06108a7565b34801561031357600080fd5b506000546001600160a01b0316610178565b34801561033157600080fd5b506101b06108c3565b34801561034657600080fd5b506006546103549060ff1681565b60405160ff909116815260200161014f565b34801561037257600080fd5b506101b06103813660046111df565b6108e4565b34801561039257600080fd5b506101b06103a13660046111df565b610921565b3480156103b257600080fd5b5061014560055481565b3480156103c857600080fd5b5061014560035481565b3480156103de57600080fd5b506101b0610a26565b3480156103f357600080fd5b506101b06104023660046111c2565b610a81565b61040f610af7565b6006805460ff191660ff83169081179091556040519081527fec5ccd96cc77b6219e9d44143df916af68fc169339ea7de5008ff15eae13450d906020015b60405180910390a150565b610460610af7565b6104706006805461ff0019169055565b565b61047a610af7565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b6104a4610b51565b600654610100900460ff16156104ea5760405162461bcd60e51b81526020600482015260066024820152651c185d5cd95960d21b60448201526064015b60405180910390fd5b6040805160c0810182526007548152600854602082015260095491810191909152600a546060820152600b546001600160a01b0381166080830152600160a01b900460ff16151560a082015233321461056f5760405162461bcd60e51b81526020600482015260076024820152666e6f7420656f6160c81b60448201526064016104e1565b805182146105bf5760405162461bcd60e51b815260206004820152601d60248201527f42616e64536175727573206e6f7420757020666f722061756374696f6e00000060448201526064016104e1565b806040015142116106085760405162461bcd60e51b8152602060048201526013602482015272105d58dd1a5bdb881b9bdd081cdd185c9d1959606a1b60448201526064016104e1565b8060600151421061064d5760405162461bcd60e51b815260206004820152600f60248201526e105d58dd1a5bdb88195e1c1a5c9959608a1b60448201526064016104e1565b60055434101561069f5760405162461bcd60e51b815260206004820152601f60248201527f4d7573742073656e64206174206c65617374207265736572766550726963650060448201526064016104e1565b60065460208201516064916106b99160ff9091169061120e565b6106c3919061123b565b81602001516106d2919061124f565b341015610749576040805162461bcd60e51b81526020600482015260248101919091527f4d7573742073656e64206d6f7265207468616e206c617374206269642062792060448201527f6d696e426964496e6372656d656e7450657263656e7461676520616d6f756e7460648201526084016104e1565b60808101516001600160a01b0381161561076b5761076b818360200151610baa565b34600855600b80546001600160a01b03191633179055600354606083015160009190610798904290611262565b10905080156107b9576003546107ae904261124f565b60608401819052600a555b8251604080513381523460208201528315158183015290517f1159164c56f277e6fc99c11731bd380e0347deb969b75523398734c252706ea39181900360600190a2801561083c57825160608401516040519081527f6e912a3a9105bdd2af817ba5adc14e6c127c1035b5b648faa29ca0d58ab8ff4e9060200160405180910390a25b50505061084860018055565b50565b610853610af7565b60038190556040518181527f1b55d9f7002bda4490f467e326f22a4a847629c0f2d1ed421607d318d25b410d9060200161044d565b610890610af7565b6104706000610c23565b6108a2610af7565b600455565b6108af610af7565b6104706006805461ff001916610100179055565b6108cb610af7565b6108d3610b51565b6108db610c73565b61047060018055565b6108ec610af7565b60058190556040518181527f6ab2e127d7fdf53b8f304e59d3aab5bfe97979f52a85479691a6fab27a28a6b29060200161044d565b610929610af7565b610931610b51565b600654610100900460ff166109755760405162461bcd60e51b815260206004820152600a6024820152691b9bdd081c185d5cd95960b21b60448201526064016104e1565b6040805160c08101825260075481526008546020820152600954918101829052600a546060820152600b546001600160a01b0381166080830152600160a01b900460ff16151560a08201529015806109ce57508060a001515b610a135760405162461bcd60e51b815260206004820152601660248201527520bab1ba34b7b7103430b9903737ba1032b73232b21760511b60448201526064016104e1565b610a1c82610f28565b5061084860018055565b610a2e610b51565b600654610100900460ff1615610a6f5760405162461bcd60e51b81526020600482015260066024820152651c185d5cd95960d21b60448201526064016104e1565b610a77610c73565b6108db6000610f28565b610a89610af7565b6001600160a01b038116610aee5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016104e1565b61084881610c23565b6000546001600160a01b031633146104705760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104e1565b600260015403610ba35760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016104e1565b6002600155565b610bb48282611103565b610c1f57610bd3610bcd6000546001600160a01b031690565b82611103565b610c1f5760405162461bcd60e51b815260206004820152601e60248201527f72656365697665722072656a656374656420455448207472616e73666572000060448201526064016104e1565b5050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040805160c08101825260075481526008546020820152600954918101829052600a546060820152600b546001600160a01b0381166080830152600160a01b900460ff16151560a082015290600003610d055760405162461bcd60e51b815260206004820152601460248201527320bab1ba34b7b7103430b9b713ba103132b3bab760611b60448201526064016104e1565b8060a0015115610d575760405162461bcd60e51b815260206004820181905260248201527f41756374696f6e2068617320616c7265616479206265656e20736574746c656460448201526064016104e1565b8060600151421015610dab5760405162461bcd60e51b815260206004820152601860248201527f41756374696f6e206861736e277420636f6d706c65746564000000000000000060448201526064016104e1565b600b805460ff60a01b1916600160a01b17905560808101516001600160a01b0316610e3b576002548151604051630852cd8d60e31b81526001600160a01b03909216916342966c6891610e049160040190815260200190565b600060405180830381600087803b158015610e1e57600080fd5b505af1158015610e32573d6000803e3d6000fd5b50505050610eaf565b600254608082015182516040516323b872dd60e01b81523060048201526001600160a01b03928316602482015260448101919091529116906323b872dd90606401600060405180830381600087803b158015610e9657600080fd5b505af1158015610eaa573d6000803e3d6000fd5b505050505b602081015115610ed857610ed8610ece6000546001600160a01b031690565b8260200151610baa565b80516080820151602080840151604080516001600160a01b039094168452918301527fc9f72b276a388619c6d185d146697036241880c36654b1a3ffdad07c24038d99910160405180910390a250565b8015610f7257804210610f6d5760405162461bcd60e51b815260206004820152600d60248201526c696e76616c69642076616c756560981b60448201526064016104e1565b610f75565b50425b600260009054906101000a90046001600160a01b03166001600160a01b0316631249c58b6040518163ffffffff1660e01b81526004016020604051808303816000875af1925050508015610fe6575060408051601f3d908101601f19168201909252610fe391810190611275565b60015b61103157610ff261128e565b806308c379a00361102557506110066112e5565b806110115750611027565b610c1f6006805461ff001916610100179055565b505b3d6000803e3d6000fd5b600454600090611044620151808561136f565b61104e9085611262565b611058919061124f565b90508083106110715761106e620151808261124f565b90505b6040805160c08101825283815260006020808301829052828401879052606083018590526080830182905260a090920181905260078590556008556009859055600a839055600b80546001600160a81b0319169055815185815290810183905283917fd6eddd1118d71820909c1197aa966dbc15ed6f508554252169cc3d5ccac756ca910160405180910390a2505050565b6040805160008082526020820190925281906001600160a01b038516906175309085906040516111339190611383565b600060405180830381858888f193505050503d8060008114611171576040519150601f19603f3d011682016040523d82523d6000602084013e611176565b606091505b5090925050505b92915050565b60006020828403121561119557600080fd5b813560ff811681146111a657600080fd5b9392505050565b6001600160a01b038116811461084857600080fd5b6000602082840312156111d457600080fd5b81356111a6816111ad565b6000602082840312156111f157600080fd5b5035919050565b634e487b7160e01b600052601160045260246000fd5b808202811582820484141761117d5761117d6111f8565b634e487b7160e01b600052601260045260246000fd5b60008261124a5761124a611225565b500490565b8082018082111561117d5761117d6111f8565b8181038181111561117d5761117d6111f8565b60006020828403121561128757600080fd5b5051919050565b600060033d11156112a75760046000803e5060005160e01c5b90565b601f8201601f1916810167ffffffffffffffff811182821017156112de57634e487b7160e01b600052604160045260246000fd5b6040525050565b600060443d10156112f35790565b6040516003193d81016004833e81513d67ffffffffffffffff816024840111818411171561132357505050505090565b828501915081518181111561133b5750505050505090565b843d87010160208285010111156113555750505050505090565b611364602082860101876112aa565b509095945050505050565b60008261137e5761137e611225565b500690565b6000825160005b818110156113a4576020818601810151858301520161138a565b50600092019182525091905056fea2646970667358221220908d8b34dfa9aca43261923b2cd698a256309a55b1d88a45ea8673fbf7b9f42864736f6c63430008110033
Verified Source Code Full Match
Compiler: v0.8.17+commit.8df45f5f
EVM: london
Optimization: Yes (200 runs)
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (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 Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
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);
}
}
ReentrancyGuard.sol 69 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
IERC721.sol 145 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}
Context.sol 24 lines
// 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;
}
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
BandSaurusAuctionHouse.sol 258 lines
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.6;
// LICENSE
// BandSaurusAuctionHouse.sol is a modified version of nounsDAO's NounsAuctionHouse.sol:
// https://github.com/nounsDAO/nouns-monorepo/blob/master/packages/nouns-contracts/contracts/NounsAuctionHouse.sol
//
// NounsAuctionHouse.sol source code Copyright nounsDAO licensed under the GPL-3.0 license.
// With modifications by Chimney Town DAO.
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import { IBandSaurusAuctionHouse } from './interfaces/IBandSaurusAuctionHouse.sol';
import { IBandSaurus } from './interfaces/IBandSaurus.sol';
contract BandSaurusAuctionHouse is IBandSaurusAuctionHouse, Ownable, ReentrancyGuard {
modifier whenNotPaused() {
require(!paused, "paused");
_;
}
modifier whenPaused() {
require(paused, "not paused");
_;
}
// The BandSaurus ERC721 token contract
IBandSaurus public bandSaurus;
// The minimum amount of time left in an auction after a new bid is created
uint256 public timeBuffer = 300; // 5min
// Offset time for auction closing time (Based on UTC+0)
uint256 public endTimeOffset = 3600 * 12;
// The minimum price accepted in an auction
uint256 public reservePrice = 10000000000000000; // 0.01eth
// The minimum percentage difference between the last bid amount and the current bid
uint8 public minBidIncrementPercentage = 5; // 5%
bool public paused = true;
// The active auction
IBandSaurusAuctionHouse.Auction public auction;
/**
* @notice Settle the current auction, mint a new BandSaurus, and put it up for auction.
*/
function settleCurrentAndCreateNewAuction() external override nonReentrant whenNotPaused {
_settleAuction();
_createAuction(0);
}
/**
* @notice Settle the current auction.
* @dev Only callable by the owner.
*/
function settleAuction() external override onlyOwner nonReentrant {
_settleAuction();
}
/**
* @notice Mint a new BandSaurus, and put it up for auction.
* @dev Only callable by the owner.
*/
function createAuction(uint256 startTime) external override onlyOwner nonReentrant whenPaused {
IBandSaurusAuctionHouse.Auction memory _auction = auction;
require(_auction.startTime == 0 || _auction.settled, 'Auction has not ended.');
_createAuction(startTime);
}
/**
* @notice Create a bid for a BandSaurus, with a given amount.
* @dev This contract only accepts payment in ETH.
*/
function createBid(uint256 tokenId) external payable override nonReentrant whenNotPaused {
IBandSaurusAuctionHouse.Auction memory _auction = auction;
require(tx.origin == msg.sender, "not eoa");
require(_auction.tokenId == tokenId, 'BandSaurus not up for auction');
require(block.timestamp > _auction.startTime, 'Auction not started');
require(block.timestamp < _auction.endTime, 'Auction expired');
require(msg.value >= reservePrice, 'Must send at least reservePrice');
require(
msg.value >= _auction.amount + ((_auction.amount * minBidIncrementPercentage) / 100),
'Must send more than last bid by minBidIncrementPercentage amount'
);
address payable lastBidder = _auction.bidder;
// Refund the last bidder, if applicable
if (lastBidder != address(0)) {
_safeTransferETHWithFallback(lastBidder, _auction.amount);
}
auction.amount = msg.value;
auction.bidder = payable(msg.sender);
// Extend the auction if the bid was received within `timeBuffer` of the auction end time
bool extended = _auction.endTime - block.timestamp < timeBuffer;
if (extended) {
auction.endTime = _auction.endTime = block.timestamp + timeBuffer;
}
emit AuctionBid(_auction.tokenId, msg.sender, msg.value, extended);
if (extended) {
emit AuctionExtended(_auction.tokenId, _auction.endTime);
}
}
/**
* @notice Pause the BandSaurus auction house.
* @dev This function can only be called by the owner when the
* contract is unpaused. While no new auctions can be started when paused,
* anyone can settle an ongoing auction.
*/
function pause() external override onlyOwner {
_pause();
}
/**
* @notice Unpause the BandSaurus auction house.
* @dev This function can only be called by the owner.
*/
function unpause() external override onlyOwner {
_unpause();
}
/**
* @notice Set the auction time buffer.
* @dev Only callable by the owner.
*/
function setTimeBuffer(uint256 _timeBuffer) external override onlyOwner {
timeBuffer = _timeBuffer;
emit AuctionTimeBufferUpdated(_timeBuffer);
}
/**
* @notice Set the auction reserve price.
* @dev Only callable by the owner.
*/
function setReservePrice(uint256 _reservePrice) external override onlyOwner {
reservePrice = _reservePrice;
emit AuctionReservePriceUpdated(_reservePrice);
}
/**
* @notice Set the auction minimum bid increment percentage.
* @dev Only callable by the owner.
*/
function setMinBidIncrementPercentage(uint8 _minBidIncrementPercentage) external override onlyOwner {
minBidIncrementPercentage = _minBidIncrementPercentage;
emit AuctionMinBidIncrementPercentageUpdated(_minBidIncrementPercentage);
}
function setEndTimeOffset(uint256 _endTimeOffset ) external override onlyOwner {
endTimeOffset = _endTimeOffset;
}
function setBandSaurusContract(IBandSaurus _bandSaurus ) external onlyOwner {
bandSaurus = _bandSaurus;
}
/**
* @notice Create an auction.
* @dev Store the auction details in the `auction` state variable and emit an AuctionCreated event.
* If the mint reverts, the minter was updated without pausing this contract first. To remedy this,
* catch the revert and pause this contract.
*/
function _createAuction(uint256 startTime) internal {
if(startTime > 0){
require(block.timestamp < startTime, 'invalid value');
}else{
startTime = block.timestamp;
}
try bandSaurus.mint() returns (uint256 tokenId) {
uint256 endTime = startTime - startTime % 86400 + endTimeOffset;
if(startTime >= endTime){
endTime += 86400;
}
auction = Auction({
tokenId: tokenId,
amount: 0,
startTime: startTime,
endTime: endTime,
bidder: payable(0),
settled: false
});
emit AuctionCreated(tokenId, startTime, endTime);
} catch Error(string memory) {
_pause();
}
}
/**
* @notice Settle an auction, finalizing the bid and paying out to the owner.
* @dev If there are no bids, the BandSaurus is burned.
*/
function _settleAuction() internal {
IBandSaurusAuctionHouse.Auction memory _auction = auction;
require(_auction.startTime != 0, "Auction hasn't begun");
require(!_auction.settled, 'Auction has already been settled');
require(block.timestamp >= _auction.endTime, "Auction hasn't completed");
auction.settled = true;
if (_auction.bidder == address(0)) {
bandSaurus.burn(_auction.tokenId);
} else {
bandSaurus.transferFrom(address(this), _auction.bidder, _auction.tokenId);
}
if (_auction.amount > 0) {
_safeTransferETHWithFallback(owner(), _auction.amount);
}
emit AuctionSettled(_auction.tokenId, _auction.bidder, _auction.amount);
}
/**
* @notice Transfer ETH. If the ETH transfer fails,send to Owner.
*/
function _safeTransferETHWithFallback(address to, uint256 amount) internal {
if (!_safeTransferETH(to, amount)) {
require(_safeTransferETH(owner(), amount), "receiver rejected ETH transfer");
}
}
/**
* @notice Transfer ETH and return the success status.
* @dev This function only forwards 30,000 gas to the callee.
*/
function _safeTransferETH(address to, uint256 value) internal returns (bool) {
(bool success, ) = to.call{ value: value, gas: 30_000 }(new bytes(0));
return success;
}
function _pause() internal {
paused = true;
}
function _unpause() internal {
paused = false;
}
}
IBandSaurus.sol 20 lines
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.6;
import { IERC721 } from '@openzeppelin/contracts/token/ERC721/IERC721.sol';
interface IBandSaurus is IERC721 {
event BandSaurusCreated(uint256 indexed tokenId);
event BandSaurusBurned(uint256 indexed tokenId);
event MinterUpdated(address minter);
function mint() external returns (uint256);
function burn(uint256 tokenId) external;
function setMinter(address minter) external;
function setMaxSupply(uint256 maxSupply) external;
}
IBandSaurusAuctionHouse.sol 55 lines
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.6;
interface IBandSaurusAuctionHouse {
struct Auction {
// ID for the BandSaurus (ERC721 token ID)
uint256 tokenId;
// The current highest bid amount
uint256 amount;
// The time that the auction started
uint256 startTime;
// The time that the auction is scheduled to end
uint256 endTime;
// The address of the current highest bid
address payable bidder;
// Whether or not the auction has been settled
bool settled;
}
event AuctionCreated(uint256 indexed tokenId, uint256 startTime, uint256 endTime);
event AuctionBid(uint256 indexed tokenId, address sender, uint256 value, bool extended);
event AuctionExtended(uint256 indexed tokenId, uint256 endTime);
event AuctionSettled(uint256 indexed tokenId, address winner, uint256 amount);
event AuctionTimeBufferUpdated(uint256 timeBuffer);
event AuctionReservePriceUpdated(uint256 reservePrice);
event AuctionMinBidIncrementPercentageUpdated(uint256 minBidIncrementPercentage);
event AuctionEndTimeOffsetUpdated(uint256 endTimeOffset);
function settleAuction() external;
function settleCurrentAndCreateNewAuction() external;
function createBid(uint256 tokenId) external payable;
function createAuction(uint256 startTime) external;
function pause() external;
function unpause() external;
function setTimeBuffer(uint256 timeBuffer) external;
function setReservePrice(uint256 reservePrice) external;
function setMinBidIncrementPercentage(uint8 minBidIncrementPercentage) external;
function setEndTimeOffset(uint256 endTimeOffset) external;
}
Read Contract
auction 0x7d9f6db5 → uint256, uint256, uint256, uint256, address, bool
bandSaurus 0x159f5819 → address
endTimeOffset 0x0c0b6f46 → uint256
minBidIncrementPercentage 0xb296024d → uint8
owner 0x8da5cb5b → address
paused 0x5c975abb → bool
reservePrice 0xdb2e1eed → uint256
timeBuffer 0xec91f2a4 → uint256
Write Contract 13 functions
These functions modify contract state and require a wallet transaction to execute.
createAuction 0xd5563f31
uint256 startTime
createBid 0x659dd2b4
uint256 tokenId
pause 0x8456cb59
No parameters
renounceOwnership 0x715018a6
No parameters
setBandSaurusContract 0x4a3d3d98
address _bandSaurus
setEndTimeOffset 0x7d85b7f7
uint256 _endTimeOffset
setMinBidIncrementPercentage 0x36ebdb38
uint8 _minBidIncrementPercentage
setReservePrice 0xce9c7c0d
uint256 _reservePrice
setTimeBuffer 0x7120334b
uint256 _timeBuffer
settleAuction 0xa4d0a17e
No parameters
settleCurrentAndCreateNewAuction 0xf25efffc
No parameters
transferOwnership 0xf2fde38b
address newOwner
unpause 0x3f4ba83a
No parameters
Recent Transactions
No transactions found for this address