文件 1 的 9:GBM.sol
pragma solidity 0.8.5;
import "./IGBM.sol";
import "./IGBMInitiator.sol";
import "../tokens/IERC20.sol";
import "../tokens/IERC721.sol";
import "../tokens/IERC721TokenReceiver.sol";
import "../tokens/IERC1155.sol";
import "../tokens/IERC1155TokenReceiver.sol";
import "../tokens/Ownable.sol";
contract GBM is IGBM, IERC1155TokenReceiver, IERC721TokenReceiver {
struct token_representation {
address contractAddress;
uint256 tokenID;
bytes4 tokenKind;
uint256 tokenAmount;
}
struct Auction {
uint256 dueIncentives;
uint256 debt;
address highestBidder;
uint256 highestBid;
bool biddingAllowed;
uint256 startTime;
uint256 endTime;
uint256 hammerTimeDuration;
uint256 bidDecimals;
uint256 stepMin;
uint256 incMin;
uint256 incMax;
uint256 bidMultiplier;
}
struct Collection {
uint256 startTime;
uint256 endTime;
uint256 hammerTimeDuration;
uint256 bidDecimals;
uint256 stepMin;
uint256 incMin;
uint256 incMax;
uint256 bidMultiplier;
bool biddingAllowed;
}
address public override owner;
mapping(uint256 => token_representation) internal tokenMapping;
mapping(address => mapping(bytes4 => mapping(uint256 => mapping(uint256 => uint256)))) auctionMapping;
mapping(address => mapping(bytes4 => mapping(uint256 => mapping(uint256 => uint256)))) previousAuctionData;
mapping(address => Collection) collections;
mapping(uint256 => bool) claimed;
mapping(uint256 => Auction) auctions;
mapping(address => mapping(uint256 => uint256)) eRC1155_tokensIndex;
mapping(address => mapping(uint256 => uint256)) eRC721_tokensIndex;
mapping(address => mapping(uint256 => uint256)) eRC1155_tokensUnderAuction;
modifier onlyTokenOwner(address _contract) {
require(msg.sender == Ownable(_contract).owner(), "Only allowed to the owner of the token contract");
_;
}
constructor()
{
owner = address(0x2a2C412c440Dfb0E7cae46EFF581e3E26aFd1Cd0);
}
function bid(uint256 _auctionID, uint256 _bidAmount, uint256 _highestBid) external payable override {
require(tokenMapping[_auctionID].contractAddress != address(0x0), "bid: auctionID does not exist");
require(collections[tokenMapping[_auctionID].contractAddress].biddingAllowed, "bid: bidding is currently not allowed");
require(_bidAmount > 1, "bid: _bidAmount cannot be 0");
require(_highestBid == auctions[_auctionID].highestBid, "bid: current highest bid do not match the submitted transaction _highestBid");
require(getAuctionStartTime(_auctionID) <= block.timestamp && getAuctionStartTime(_auctionID) != 0, "bid: Auction has not started yet");
require(getAuctionEndTime(_auctionID) >= block.timestamp, "bid: Auction has already ended");
require(_bidAmount > _highestBid, "bid: _bidAmount must be higher than _highestBid");
require((_highestBid * (getAuctionBidDecimals(_auctionID) + getAuctionStepMin(_auctionID))) <= (_bidAmount * getAuctionBidDecimals(_auctionID)),
"bid: _bidAmount must meet the minimum bid"
);
require(msg.value == _bidAmount, "The bid amount doesn't match the amount of currency sent");
if(getAuctionEndTime(_auctionID) < block.timestamp + getHammerTimeDuration(_auctionID)) {
auctions[_auctionID].endTime = block.timestamp + getHammerTimeDuration(_auctionID);
emit Auction_EndTimeUpdated(_auctionID, auctions[_auctionID].endTime);
}
uint256 duePay = auctions[_auctionID].dueIncentives;
address previousHighestBidder = auctions[_auctionID].highestBidder;
uint256 previousHighestBid = auctions[_auctionID].highestBid;
if(previousHighestBidder != address(0)) {
emit Auction_BidRemoved(_auctionID, previousHighestBidder, previousHighestBid);
}
if(duePay != 0) {
auctions[_auctionID].debt = auctions[_auctionID].debt + duePay;
emit Auction_IncentivePaid(_auctionID, previousHighestBidder, duePay);
}
emit Auction_BidPlaced(_auctionID, msg.sender, _bidAmount);
auctions[_auctionID].dueIncentives = calculateIncentives(_auctionID, _bidAmount);
auctions[_auctionID].highestBidder = msg.sender;
auctions[_auctionID].highestBid = _bidAmount;
if((previousHighestBid + duePay) != 0) {
(bool sent, bytes memory data) = previousHighestBidder.call{value: previousHighestBid + duePay}("");
}
}
function claim(uint256 _auctionID) external override {
address _ca = tokenMapping[_auctionID].contractAddress;
uint256 _tid = tokenMapping[_auctionID].tokenID;
bytes4 _tkd = tokenMapping[_auctionID].tokenKind;
uint256 _tam = tokenMapping[_auctionID].tokenAmount;
require(_ca != address(0x0), "claim: auctionID does not exist");
require(collections[_ca].biddingAllowed, "claim: Claiming is currently not allowed");
require(getAuctionEndTime(_auctionID) < block.timestamp, "claim: Auction has not yet ended");
require(!claimed[_auctionID], "claim: this auction has alredy been claimed");
claimed[_auctionID] = true;
if (auctions[_auctionID].highestBid == 0) {
auctions[_auctionID].highestBidder = Ownable(_ca).owner();
}
uint256 finalAmount = auctions[_auctionID].highestBid - auctions[_auctionID].debt;
(bool sent, bytes memory data) = owner.call{value: finalAmount}("");
if (tokenMapping[_auctionID].tokenKind == bytes4(keccak256("ERC721"))) {
IERC721(_ca).safeTransferFrom(address(this), auctions[_auctionID].highestBidder, _tid);
auctionMapping[_ca][_tkd][_tid][0] = 0;
} else if (tokenMapping[_auctionID].tokenKind == bytes4(keccak256("ERC1155"))) {
IERC1155(_ca).safeTransferFrom(address(this), auctions[_auctionID].highestBidder, _tid, _tam, "");
eRC1155_tokensUnderAuction[_ca][_tid] = eRC1155_tokensUnderAuction[_ca][_tid] - _tam;
}
emit Auction_Claimed(_auctionID);
}
function registerAnAuctionContract(address _contract, address _initiator) public override onlyTokenOwner(_contract) {
collections[_contract].startTime = IGBMInitiator(_initiator).getStartTime(uint256(uint160(_contract)));
collections[_contract].endTime = IGBMInitiator(_initiator).getEndTime(uint256(uint160(_contract)));
collections[_contract].hammerTimeDuration = IGBMInitiator(_initiator).getHammerTimeDuration(uint256(uint160(_contract)));
collections[_contract].bidDecimals = IGBMInitiator(_initiator).getBidDecimals(uint256(uint160(_contract)));
collections[_contract].stepMin = IGBMInitiator(_initiator).getStepMin(uint256(uint160(_contract)));
collections[_contract].incMin = IGBMInitiator(_initiator).getIncMin(uint256(uint160(_contract)));
collections[_contract].incMax = IGBMInitiator(_initiator).getIncMax(uint256(uint160(_contract)));
collections[_contract].bidMultiplier = IGBMInitiator(_initiator).getBidMultiplier(uint256(uint160(_contract)));
require(collections[_contract].startTime > 0, "registerAnAuctionContract: Start time is not correct");
}
function setBiddingAllowed(address _contract, bool _value) external override onlyTokenOwner(_contract) {
collections[_contract].biddingAllowed = _value;
}
function registerAnAuctionToken(address _contract, uint256 _tokenID, bytes4 _tokenKind, uint256 _tokenAmount, address _initiator) public override onlyTokenOwner(_contract) {
registerAuctionData(_contract, _tokenID, _tokenKind, _tokenAmount, _initiator);
}
function modifyAnAuctionToken(uint256 _auctionID, address _initiator) external override {
modifyAnAuctionToken(_auctionID, 0, _initiator);
}
function modifyAnAuctionToken(uint256 _auctionID, uint256 _tokenAmount, address _initiator) public override {
address _ca = tokenMapping[_auctionID].contractAddress;
bytes4 _tki = tokenMapping[_auctionID].tokenKind;
uint256 _tid = tokenMapping[_auctionID].tokenID;
uint256 _tam = tokenMapping[_auctionID].tokenAmount;
require(msg.sender == Ownable(_ca).owner(), "modifyAnAuctionToken: Only the owner of a contract can modify an auction");
require(_ca != address(0), "modifyAnAuctionToken: Auction ID is not correct");
require(auctions[_auctionID].startTime > block.timestamp, "modifyAnAuctionToken: Auction has already started");
require(_initiator != address(0), "modifyAnAuctionToken: Initiator address is not correct");
if (_tam != _tokenAmount && _tokenAmount != 0) {
require(_tki == bytes4(keccak256("ERC1155")), "modifyAnAuctionToken: Token amount for auction token kind not correct");
require(_tokenAmount >= 1, "modifyAnAuctionToken: Token amount not correct");
tokenMapping[_auctionID].tokenAmount = _tokenAmount;
uint256 _tokenDiff;
if (_tam < _tokenAmount) {
_tokenDiff = _tokenAmount - _tam;
require((eRC1155_tokensUnderAuction[_ca][_tid] + _tokenDiff) <= IERC1155(_ca).balanceOf(address(this), _tid),
"modifyAnAuctionToken: Cannot set to auction that amount of tokens");
eRC1155_tokensUnderAuction[_ca][_tid] = eRC1155_tokensUnderAuction[_ca][_tid] + _tokenDiff;
} else {
_tokenDiff = _tam - _tokenAmount;
require((eRC1155_tokensUnderAuction[_ca][_tid] - _tokenDiff) <= IERC1155(_ca).balanceOf(address(this), _tid),
"modifyAnAuctionToken: Cannot set to auction that amount of tokens");
eRC1155_tokensUnderAuction[_ca][_tid] = eRC1155_tokensUnderAuction[_ca][_tid] - _tokenDiff;
}
}
auctions[_auctionID].startTime = IGBMInitiator(_initiator).getStartTime(_auctionID);
auctions[_auctionID].endTime = IGBMInitiator(_initiator).getEndTime(_auctionID);
auctions[_auctionID].hammerTimeDuration = IGBMInitiator(_initiator).getHammerTimeDuration(_auctionID);
auctions[_auctionID].bidDecimals = IGBMInitiator(_initiator).getBidDecimals(_auctionID);
auctions[_auctionID].stepMin = IGBMInitiator(_initiator).getStepMin(_auctionID);
auctions[_auctionID].incMin = IGBMInitiator(_initiator).getIncMin(_auctionID);
auctions[_auctionID].incMax = IGBMInitiator(_initiator).getIncMax(_auctionID);
auctions[_auctionID].bidMultiplier = IGBMInitiator(_initiator).getBidMultiplier(_auctionID);
require(auctions[_auctionID].startTime > 0, "modifyAnAuctionToken: Start time is not correct");
}
function registerAuctionData(address _contract, uint256 _tokenID, bytes4 _tokenKind, uint256 _tokenAmount, address _initiator) internal {
require(msg.sender == Ownable(_contract).owner(), "registerAuctionData: Only the owner of a contract can allow/disallow bidding");
if (_tokenKind == bytes4(keccak256("ERC721"))) {
require(_tokenAmount == 1, "registerAuctionData: Token amount not correct");
require(auctionMapping[_contract][_tokenKind][_tokenID][0] == 0, "registerAuctionData: The auction already exist for the specified token");
} else {
require(_tokenAmount >= 1, "registerAuctionData: Token amount not correct");
require(auctionMapping[_contract][_tokenKind][_tokenID][eRC1155_tokensIndex[_contract][_tokenID]] == 0, "registerAuctionData: The auction already exist for the specified token");
}
require(_tokenKind == bytes4(keccak256("ERC721")) || _tokenKind == bytes4(keccak256("ERC1155")),
"registerAuctionData: Only ERC1155 and ERC721 tokens are supported"
);
token_representation memory newAuction;
newAuction.contractAddress = _contract;
newAuction.tokenID = _tokenID;
newAuction.tokenKind = _tokenKind;
newAuction.tokenAmount = _tokenAmount;
uint256 auctionId;
if (_tokenKind == bytes4(keccak256("ERC721"))) {
require(
msg.sender == Ownable(_contract).owner() ||
address(this) == IERC721(_contract).ownerOf(_tokenID),
"registerAuctionData: the specified ERC-721 token cannot be auctionned"
);
uint256 _721Index = eRC721_tokensIndex[_contract][_tokenID];
auctionId = uint256(keccak256(abi.encodePacked(_contract, _tokenID, _tokenKind, block.number)));
auctionMapping[_contract][_tokenKind][_tokenID][0] = auctionId;
previousAuctionData[_contract][_tokenKind][_tokenID][_721Index] = auctionId;
eRC721_tokensIndex[_contract][_tokenID] = _721Index + 1;
} else {
require(
msg.sender == Ownable(_contract).owner() ||
(eRC1155_tokensUnderAuction[_contract][_tokenID] + _tokenAmount) <= IERC1155(_contract).balanceOf(address(this), _tokenID),
"registerAuctionData: the specified ERC-1155 token cannot be auctionned"
);
uint256 _1155Index = eRC1155_tokensIndex[_contract][_tokenID];
auctionId = uint256(keccak256(abi.encodePacked(_contract, _tokenID, _tokenKind, _1155Index, block.number)));
auctionMapping[_contract][_tokenKind][_tokenID][_1155Index] = auctionId;
eRC1155_tokensIndex[_contract][_tokenID] = eRC1155_tokensIndex[_contract][_tokenID] + 1;
eRC1155_tokensUnderAuction[_contract][_tokenID] = eRC1155_tokensUnderAuction[_contract][_tokenID] + _tokenAmount;
}
tokenMapping[auctionId] = newAuction;
if(_initiator != address(0x0)) {
auctions[auctionId].startTime = IGBMInitiator(_initiator).getStartTime(auctionId);
auctions[auctionId].endTime = IGBMInitiator(_initiator).getEndTime(auctionId);
auctions[auctionId].hammerTimeDuration = IGBMInitiator(_initiator).getHammerTimeDuration(auctionId);
auctions[auctionId].bidDecimals = IGBMInitiator(_initiator).getBidDecimals(auctionId);
auctions[auctionId].stepMin = IGBMInitiator(_initiator).getStepMin(auctionId);
auctions[auctionId].incMin = IGBMInitiator(_initiator).getIncMin(auctionId);
auctions[auctionId].incMax = IGBMInitiator(_initiator).getIncMax(auctionId);
auctions[auctionId].bidMultiplier = IGBMInitiator(_initiator).getBidMultiplier(auctionId);
require(auctions[auctionId].startTime > 0, "registerAuctionData: Start time is not correct");
}
emit Auction_Initialized(auctionId, _tokenID, _contract, _tokenKind);
emit Auction_StartTimeUpdated(auctionId, getAuctionStartTime(auctionId));
}
function massRegistrerERC721Each(address _initiator, address _ERC721Contract, uint256 _tokenIDStart, uint256 _tokenIDEnd) external override {
while(_tokenIDStart < _tokenIDEnd) {
IERC721(_ERC721Contract).safeTransferFrom(msg.sender, address(this), _tokenIDStart, "");
registerAnAuctionToken(_ERC721Contract, _tokenIDStart, bytes4(keccak256("ERC721")), 1, _initiator);
_tokenIDStart++;
}
}
function massRegistrerERC1155Each(address _initiator, address _ERC1155Contract, uint256 _tokenID, uint256 _indexStart, uint256 _indexEnd) external override {
registerAnAuctionContract(_ERC1155Contract, _initiator);
IERC1155(_ERC1155Contract).safeTransferFrom(msg.sender, address(this), _tokenID, _indexEnd - _indexStart, "");
while(_indexStart < _indexEnd) {
registerAnAuctionToken(_ERC1155Contract, _tokenID, bytes4(keccak256("ERC1155")), 1, _initiator);
_indexStart++;
}
}
function getAuctionHighestBidder(uint256 _auctionID) external override view returns(address) {
return auctions[_auctionID].highestBidder;
}
function getAuctionHighestBid(uint256 _auctionID) external override view returns(uint256) {
return auctions[_auctionID].highestBid;
}
function getAuctionDebt(uint256 _auctionID) external override view returns(uint256) {
return auctions[_auctionID].debt;
}
function getAuctionDueIncentives(uint256 _auctionID) external override view returns(uint256) {
return auctions[_auctionID].dueIncentives;
}
function getAuctionID(address _contract, bytes4 _tokenKind, uint256 _tokenID, uint256 _index) external override view returns(uint256) {
if (_tokenKind == bytes4(keccak256("ERC721"))) {
return previousAuctionData[_contract][_tokenKind][_tokenID][_index];
} else {
return auctionMapping[_contract][_tokenKind][_tokenID][_index];
}
}
function getTokenKind(uint256 _auctionID) external override view returns(bytes4) {
return tokenMapping[_auctionID].tokenKind;
}
function getTokenId(uint256 _auctionID) external override view returns(uint256) {
return tokenMapping[_auctionID].tokenID;
}
function getTokenAmount(uint256 _auctionID) external override view returns(uint256){
return tokenMapping[_auctionID].tokenAmount;
}
function getContractAddress(uint256 _auctionID) external override view returns(address) {
return tokenMapping[_auctionID].contractAddress;
}
function getAuctionStartTime(uint256 _auctionID) public override view returns(uint256) {
if(auctions[_auctionID].startTime != 0) {
return auctions[_auctionID].startTime;
} else {
return collections[tokenMapping[_auctionID].contractAddress].startTime;
}
}
function getAuctionEndTime(uint256 _auctionID) public override view returns(uint256) {
if(auctions[_auctionID].endTime != 0) {
return auctions[_auctionID].endTime;
} else {
return collections[tokenMapping[_auctionID].contractAddress].endTime;
}
}
function getHammerTimeDuration(uint256 _auctionID) public override view returns(uint256) {
if(auctions[_auctionID].hammerTimeDuration != 0) {
return auctions[_auctionID].hammerTimeDuration;
} else {
return collections[tokenMapping[_auctionID].contractAddress].hammerTimeDuration;
}
}
function getAuctionBidDecimals(uint256 _auctionID) public override view returns(uint256) {
if(auctions[_auctionID].bidDecimals != 0) {
return auctions[_auctionID].bidDecimals;
} else {
return collections[tokenMapping[_auctionID].contractAddress].bidDecimals;
}
}
function getAuctionStepMin(uint256 _auctionID) public override view returns(uint256) {
if(auctions[_auctionID].stepMin != 0) {
return auctions[_auctionID].stepMin;
} else {
return collections[tokenMapping[_auctionID].contractAddress].stepMin;
}
}
function getAuctionIncMin(uint256 _auctionID) public override view returns(uint256) {
if(auctions[_auctionID].incMin != 0) {
return auctions[_auctionID].incMin;
} else {
return collections[tokenMapping[_auctionID].contractAddress].incMin;
}
}
function getAuctionIncMax(uint256 _auctionID) public override view returns(uint256) {
if(auctions[_auctionID].incMax != 0) {
return auctions[_auctionID].incMax;
} else {
return collections[tokenMapping[_auctionID].contractAddress].incMax;
}
}
function getAuctionBidMultiplier(uint256 _auctionID) public override view returns(uint256) {
if(auctions[_auctionID].bidMultiplier != 0) {
return auctions[_auctionID].bidMultiplier;
} else {
return collections[tokenMapping[_auctionID].contractAddress].bidMultiplier;
}
}
function onERC721Received(address , address , uint256 , bytes calldata ) external pure override returns(bytes4) {
return bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"));
}
function onERC1155Received(address , address , uint256 , uint256 , bytes calldata ) external pure override returns(bytes4) {
return bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"));
}
function onERC1155BatchReceived(address , address , uint256[] calldata , uint256[] calldata , bytes calldata ) external pure override returns(bytes4) {
return bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"));
}
function calculateIncentives(uint256 _auctionID, uint256 _newBidValue) internal view returns (uint256) {
uint256 bidDecimals = getAuctionBidDecimals(_auctionID);
uint256 bidIncMax = getAuctionIncMax(_auctionID);
uint256 baseBid = auctions[_auctionID].highestBid * (bidDecimals + getAuctionStepMin(_auctionID)) / bidDecimals;
if(baseBid == 0) {
baseBid = 1;
}
uint256 decimaledRatio = ((bidDecimals * getAuctionBidMultiplier(_auctionID) * (_newBidValue - baseBid) ) / baseBid) +
getAuctionIncMin(_auctionID) * bidDecimals;
if(decimaledRatio > (bidDecimals * bidIncMax)) {
decimaledRatio = bidDecimals * bidIncMax;
}
return (_newBidValue * decimaledRatio)/(bidDecimals*bidDecimals);
}
}
文件 2 的 9:IERC1155.sol
pragma solidity 0.8.5;
interface IERC1155 {
event TransferSingle(address indexed _operator, address indexed _from, address indexed _to, uint256 _id, uint256 _value);
event TransferBatch(address indexed _operator, address indexed _from, address indexed _to, uint256[] _ids, uint256[] _values);
event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
event URI(string _value, uint256 indexed _id);
function safeTransferFrom(address _from, address _to, uint256 _id, uint256 _value, bytes calldata _data) external;
function safeBatchTransferFrom(address _from, address _to, uint256[] calldata _ids, uint256[] calldata _values, bytes calldata _data) external;
function balanceOf(address _owner, uint256 _id) external view returns (uint256);
function balanceOfBatch(address[] calldata _owners, uint256[] calldata _ids) external view returns (uint256[] memory);
function setApprovalForAll(address _operator, bool _approved) external;
function isApprovedForAll(address _owner, address _operator) external view returns (bool);
}
文件 3 的 9:IERC1155TokenReceiver.sol
pragma solidity 0.8.5;
interface IERC1155TokenReceiver {
function onERC1155Received(address _operator, address _from, uint256 _id, uint256 _value, bytes calldata _data) external returns(bytes4);
function onERC1155BatchReceived(address _operator, address _from, uint256[] calldata _ids, uint256[] calldata _values, bytes calldata _data) external returns(bytes4);
}
文件 4 的 9:IERC20.sol
pragma solidity 0.8.5;
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
function balanceOf(address who) external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
function transfer(address to, uint256 value) external returns (bool);
function approve(address spender, uint256 value) external returns (bool);
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
文件 5 的 9:IERC721.sol
pragma solidity 0.8.5;
interface IERC721 {
event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId);
event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId);
event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
function balanceOf(address _owner) external view returns (uint256);
function ownerOf(uint256 _tokenId) external view returns (address);
function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes calldata data) external payable;
function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable;
function transferFrom(address _from, address _to, uint256 _tokenId) external payable;
function approve(address _approved, uint256 _tokenId) external payable;
function setApprovalForAll(address _operator, bool _approved) external;
function getApproved(uint256 _tokenId) external view returns (address);
function isApprovedForAll(address _owner, address _operator) external view returns (bool);
}
文件 6 的 9:IERC721TokenReceiver.sol
pragma solidity 0.8.5;
interface IERC721TokenReceiver {
function onERC721Received(address _operator, address _from, uint256 _tokenId, bytes calldata _data) external returns(bytes4);
}
文件 7 的 9:IGBM.sol
pragma solidity 0.8.5;
interface IGBM {
event Auction_Initialized(uint256 indexed _auctionID, uint256 indexed _tokenID, address indexed _contractAddress, bytes4 _tokenKind);
event Auction_StartTimeUpdated(uint256 indexed _auctionID, uint256 _startTime);
event Auction_EndTimeUpdated(uint256 indexed _auctionID, uint256 _endTime);
event Auction_BidPlaced(uint256 indexed _auctionID, address indexed _bidder, uint256 _bidAmount);
event Auction_BidRemoved(uint256 indexed _auctionID, address indexed _bidder, uint256 _bidAmount);
event Auction_IncentivePaid(uint256 indexed _auctionID, address indexed _earner, uint256 _incentiveAmount);
event Auction_Claimed(uint256 indexed _auctionID);
function bid(uint256 _auctionID, uint256 _bidAmount, uint256 _highestBid) external payable;
function claim(uint256 _auctionID) external;
function registerAnAuctionContract(address _contract, address _initiator) external;
function setBiddingAllowed(address _contract, bool _value) external;
function registerAnAuctionToken(address _contract, uint256 _tokenId, bytes4 _tokenKind, uint256 _tokenAmount, address _initiator) external;
function modifyAnAuctionToken(uint256 _auctionID, address _initiator) external;
function modifyAnAuctionToken(uint256 _auctionID, uint256 _tokenAmount, address _initiator) external;
function massRegistrerERC721Each(address _initiator, address _ERC721Contract, uint256 _tokenIDStart, uint256 _tokenIDEnd) external;
function massRegistrerERC1155Each(address _initiator, address _ERC1155Contract, uint256 _tokenID, uint256 _indexStart, uint256 _indexEnd) external;
function owner() external returns(address);
function getAuctionID(address _contract, bytes4 _tokenKind, uint256 _tokenID, uint256 _tokenIndex) external view returns(uint256);
function getTokenId(uint256 _auctionID) external view returns(uint256);
function getContractAddress(uint256 _auctionID) external view returns(address);
function getTokenKind(uint256 _auctionID) external view returns(bytes4);
function getTokenAmount(uint256 _auctionID) external view returns(uint256);
function getAuctionHighestBidder(uint256 _auctionID) external view returns(address);
function getAuctionHighestBid(uint256 _auctionID) external view returns(uint256);
function getAuctionDebt(uint256 _auctionID) external view returns(uint256);
function getAuctionDueIncentives(uint256 _auctionID) external view returns(uint256);
function getAuctionStartTime(uint256 _auctionID) external view returns(uint256);
function getAuctionEndTime(uint256 _auctionID) external view returns(uint256);
function getHammerTimeDuration(uint256 _auctionID) external view returns(uint256);
function getAuctionBidDecimals(uint256 _auctionID) external view returns(uint256);
function getAuctionStepMin(uint256 _auctionID) external view returns(uint256);
function getAuctionIncMin(uint256 _auctionID) external view returns(uint256);
function getAuctionIncMax(uint256 _auctionID) external view returns(uint256);
function getAuctionBidMultiplier(uint256 _auctionID) external view returns(uint256);
}
文件 8 的 9:IGBMInitiator.sol
pragma solidity 0.8.5;
interface IGBMInitiator {
function getStartTime(uint256 _auctionId) external view returns(uint256);
function getEndTime(uint256 _auctionId) external view returns(uint256);
function getHammerTimeDuration(uint256 _auctionId) external view returns(uint256);
function getBidDecimals(uint256 _auctionId) external view returns(uint256);
function getStepMin(uint256 _auctionId) external view returns(uint256);
function getIncMin(uint256 _auctionId) external view returns(uint256);
function getIncMax(uint256 _auctionId) external view returns(uint256);
function getBidMultiplier(uint256 _auctionId) external view returns(uint256);
}
文件 9 的 9:Ownable.sol
pragma solidity 0.8.5;
interface Ownable {
function owner() external returns(address);
}
{
"compilationTarget": {
"contracts/GBM/GBM.sol": "GBM"
},
"evmVersion": "berlin",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_auctionID","type":"uint256"},{"indexed":true,"internalType":"address","name":"_bidder","type":"address"},{"indexed":false,"internalType":"uint256","name":"_bidAmount","type":"uint256"}],"name":"Auction_BidPlaced","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_auctionID","type":"uint256"},{"indexed":true,"internalType":"address","name":"_bidder","type":"address"},{"indexed":false,"internalType":"uint256","name":"_bidAmount","type":"uint256"}],"name":"Auction_BidRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_auctionID","type":"uint256"}],"name":"Auction_Claimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_auctionID","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_endTime","type":"uint256"}],"name":"Auction_EndTimeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_auctionID","type":"uint256"},{"indexed":true,"internalType":"address","name":"_earner","type":"address"},{"indexed":false,"internalType":"uint256","name":"_incentiveAmount","type":"uint256"}],"name":"Auction_IncentivePaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_auctionID","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"_tokenID","type":"uint256"},{"indexed":true,"internalType":"address","name":"_contractAddress","type":"address"},{"indexed":false,"internalType":"bytes4","name":"_tokenKind","type":"bytes4"}],"name":"Auction_Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_auctionID","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_startTime","type":"uint256"}],"name":"Auction_StartTimeUpdated","type":"event"},{"inputs":[{"internalType":"uint256","name":"_auctionID","type":"uint256"},{"internalType":"uint256","name":"_bidAmount","type":"uint256"},{"internalType":"uint256","name":"_highestBid","type":"uint256"}],"name":"bid","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_auctionID","type":"uint256"}],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_auctionID","type":"uint256"}],"name":"getAuctionBidDecimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_auctionID","type":"uint256"}],"name":"getAuctionBidMultiplier","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_auctionID","type":"uint256"}],"name":"getAuctionDebt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_auctionID","type":"uint256"}],"name":"getAuctionDueIncentives","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_auctionID","type":"uint256"}],"name":"getAuctionEndTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_auctionID","type":"uint256"}],"name":"getAuctionHighestBid","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_auctionID","type":"uint256"}],"name":"getAuctionHighestBidder","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_contract","type":"address"},{"internalType":"bytes4","name":"_tokenKind","type":"bytes4"},{"internalType":"uint256","name":"_tokenID","type":"uint256"},{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"getAuctionID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_auctionID","type":"uint256"}],"name":"getAuctionIncMax","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_auctionID","type":"uint256"}],"name":"getAuctionIncMin","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_auctionID","type":"uint256"}],"name":"getAuctionStartTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_auctionID","type":"uint256"}],"name":"getAuctionStepMin","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_auctionID","type":"uint256"}],"name":"getContractAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_auctionID","type":"uint256"}],"name":"getHammerTimeDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_auctionID","type":"uint256"}],"name":"getTokenAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_auctionID","type":"uint256"}],"name":"getTokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_auctionID","type":"uint256"}],"name":"getTokenKind","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_initiator","type":"address"},{"internalType":"address","name":"_ERC1155Contract","type":"address"},{"internalType":"uint256","name":"_tokenID","type":"uint256"},{"internalType":"uint256","name":"_indexStart","type":"uint256"},{"internalType":"uint256","name":"_indexEnd","type":"uint256"}],"name":"massRegistrerERC1155Each","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_initiator","type":"address"},{"internalType":"address","name":"_ERC721Contract","type":"address"},{"internalType":"uint256","name":"_tokenIDStart","type":"uint256"},{"internalType":"uint256","name":"_tokenIDEnd","type":"uint256"}],"name":"massRegistrerERC721Each","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_auctionID","type":"uint256"},{"internalType":"uint256","name":"_tokenAmount","type":"uint256"},{"internalType":"address","name":"_initiator","type":"address"}],"name":"modifyAnAuctionToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_auctionID","type":"uint256"},{"internalType":"address","name":"_initiator","type":"address"}],"name":"modifyAnAuctionToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_contract","type":"address"},{"internalType":"address","name":"_initiator","type":"address"}],"name":"registerAnAuctionContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_contract","type":"address"},{"internalType":"uint256","name":"_tokenID","type":"uint256"},{"internalType":"bytes4","name":"_tokenKind","type":"bytes4"},{"internalType":"uint256","name":"_tokenAmount","type":"uint256"},{"internalType":"address","name":"_initiator","type":"address"}],"name":"registerAnAuctionToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_contract","type":"address"},{"internalType":"bool","name":"_value","type":"bool"}],"name":"setBiddingAllowed","outputs":[],"stateMutability":"nonpayable","type":"function"}]