-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 43f6f64
Showing
6 changed files
with
27,058 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
}; |
Oops, something went wrong.