-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkgas.sol
90 lines (61 loc) · 1.76 KB
/
kgas.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
pragma solidity ^0.6.7;
import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
contract PriceConsumerV3 {
event below20(int _price);
event below30(int _price);
event below40(int _price);
event below50(int _price);
event below60(int _price);
AggregatorV3Interface internal priceFeed;
/**
* Network: Kovan
* Aggregator: ETH/USD
* Address: 0x9326BFA02ADD2366b30bacB125260Af641031331
*/
constructor() public {
priceFeed = AggregatorV3Interface(0x3D400312Bb3456f4dC06D528B55707F08dFFD664);
}
/**
* Returns the latest price
*/
function getThePrice() public view returns (int) {
(
uint80 roundID,
int price,
uint startedAt,
uint timeStamp,
uint80 answeredInRound
) = priceFeed.latestRoundData();
price = price/10**9;
return price;
}
function updateThePrice() public returns (int) {
(
uint80 roundID,
int price,
uint startedAt,
uint timeStamp,
uint80 answeredInRound
) = priceFeed.latestRoundData();
price = price/10**9;
if(price <20){
emit below20(price);
}
else if(price <30){
emit below30(price);
}
else if(price <40){
emit below40(price);
}
else if(price <50){
emit below50(price);
}
return price/10**9;
}
// function throwevent(uint curr) public returns () {
// if(curr < 20)
// {
// emit
// }
// }
}