62 lines
1.4 KiB
Solidity
62 lines
1.4 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity ^0.8.20;
|
|
|
|
interface AggregatorV3Interface {
|
|
function decimals() external view returns (uint8);
|
|
|
|
function description() external view returns (string memory);
|
|
|
|
function version() external view returns (uint256);
|
|
|
|
function getRoundData(
|
|
uint80 _roundId
|
|
)
|
|
external
|
|
view
|
|
returns (
|
|
uint80 roundId,
|
|
int256 answer,
|
|
uint256 startedAt,
|
|
uint256 updatedAt,
|
|
uint80 answeredInRound
|
|
);
|
|
|
|
function latestRoundData()
|
|
external
|
|
view
|
|
returns (
|
|
uint80 roundId,
|
|
int256 answer,
|
|
uint256 startedAt,
|
|
uint256 updatedAt,
|
|
uint80 answeredInRound
|
|
);
|
|
}
|
|
|
|
contract SargaTrxUsdPrice {
|
|
AggregatorV3Interface internal _priceFeed;
|
|
|
|
/**
|
|
* Network: Tron
|
|
* Aggregator: TRX/USD
|
|
* Address: TC6o8AakUg4Xz9nHY9qXpJNsgF7CQkwBqF
|
|
*/
|
|
constructor(address priceFeedAddress) {
|
|
_priceFeed = AggregatorV3Interface(priceFeedAddress);
|
|
}
|
|
|
|
/**
|
|
* Returns the latest price
|
|
*/
|
|
function getLatestPrice() public view returns (int) {
|
|
(
|
|
,
|
|
/* uint80 roundID */ int price /* uint startedAt */ /* uint timeStamp */ /* uint80 answeredInRound */,
|
|
,
|
|
,
|
|
|
|
) = _priceFeed.latestRoundData();
|
|
return price;
|
|
}
|
|
}
|