Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
0xF16 committed Apr 25, 2022
0 parents commit 43f6f64
Show file tree
Hide file tree
Showing 6 changed files with 27,058 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules
.env
coverage
coverage.json
typechain

#Hardhat files
cache
artifacts
38 changes: 38 additions & 0 deletions contracts/BetVault.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

// import "hardhat/console.sol";
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";

contract BetVault {

struct Bet {
bool active;
uint256 bidPrice;
uint256 bidCollateral;
}

address public assetAddr;
AggregatorV3Interface internal priceFeed;
uint256 public biddingTimeEnd;
uint256 public endTime;

mapping(address => Bet) public bets;
address[] public bidders;

constructor(address _assetAddr, address _priceFeed, uint256 _biddingTimeEnd, uint256 _endTime) {
require(_biddingTimeEnd <= _endTime, "Bidding time must be before whole bid ends");
require(_biddingTimeEnd > block.timestamp, "Bidding must end after now");
assetAddr = _assetAddr;
biddingTimeEnd = _biddingTimeEnd;
endTime = _endTime;
priceFeed = AggregatorV3Interface(_priceFeed);
}

function placeBid(uint256 _bidPrice) external payable {
require(bets[msg.sender].active == false, "Already placed a bid");
require(block.timestamp < biddingTimeEnd, "Too late to place a bid");
bets[msg.sender] = Bet(true, _bidPrice, msg.value);
bidders.push(msg.sender);
}
}
21 changes: 21 additions & 0 deletions hardhat.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require("@nomiclabs/hardhat-waffle");

// This is a sample Hardhat task. To learn how to create your own go to
// https://hardhat.org/guides/create-task.html
task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
const accounts = await hre.ethers.getSigners();

for (const account of accounts) {
console.log(account.address);
}
});

// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more

/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
solidity: "0.8.4",
};
Loading

0 comments on commit 43f6f64

Please sign in to comment.