-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMockPriceFeed.sol
More file actions
35 lines (30 loc) · 919 Bytes
/
Copy pathMockPriceFeed.sol
File metadata and controls
35 lines (30 loc) · 919 Bytes
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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
contract MockPriceFeed {
int256 private price;
uint8 private decimalsValue;
constructor(int256 _initialPrice, uint8 _decimals) {
price = _initialPrice; // Ex.: 2000 * 10^8 para ETH/USD = $2000
decimalsValue = _decimals; // Ex.: 8
}
function latestRoundData()
external
view
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
)
{
return (0, price, block.timestamp, block.timestamp, 0);
}
function decimals() external view returns (uint8) {
return decimalsValue;
}
// Função para atualizar preço manualmente durante testes
function setPrice(int256 _newPrice) external {
price = _newPrice;
}
}