Commit b0963cbd authored by BHAVYA CHOUDHARY's avatar BHAVYA CHOUDHARY

add Structure of Vickery Auction

parent ed1a47ad
pragma solidity ^0.4.4;
import "DAuction.sol";
contract DVickreyAuction is DAuction {
uint256 public bidDepositAmount;
uint256 public revealBlocksNum;
uint256 secondHighestBid;
bool refundCalled;
bool finalizeCalled;
// constructor
function DVickreyAuction(uint256 reservePrice, address judgeAddress, uint256 commitTimePeriod, uint256 revealTimePeriod, uint256 _bidDepositAmount) DAuction(reservePrice, commitTimePeriod, judgeAddress) {
bidDepositAmount = _bidDepositAmount;
revealBlockNum = revealTimePeriod;
}
function commitBid(bytes32 bidCommitment) biddingOpen payable returns(bool) {
throw;
}
function revealBid(uint256 nonce) revealOpen payable returns(address highestBidder) {
throw;
}
function finalize() auctionover {
require(msg.sender == highestBidder);
require(!refundCalled && !finalizeCalled);
finalizeCalled=true;
creator.transfer(secondHighestBid);
}
function refund(uint256 refundAmount) auctionOver judgeOnly {
require(highestBidder!=0);
require(refundAmount<= this.balance);
require(!finalizeCalled && !refundCalled);
refundCalled=true;
highestBidder.transfer(refundAmount);
creator.transfer(secondHighestBid-refundAmount);
}
function withdraw() auctionover returns (uint){
throw;
}
modifier auctionover {
require(block.blockNum > startBlockNum+biddingBlocksNum+revealBlocksNum);
_;
}
modifier biddingOpen {
require(block.blockNum <= startBlockNum+biddingBlocksNum);
_;
}
modifier revealOpen {
require(block.blockNum > startBlockNum+biddingBlocksNum);
require(block.blockNum <= startBlockNum+biddingBlocksNum+revealBlocksNum);
_;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment