Initial Commit

This commit is contained in:
2025-06-10 22:39:45 -04:00
commit c667dc197b
16 changed files with 3388 additions and 0 deletions

25
contracts/s_pricefeed.sol Normal file
View File

@@ -0,0 +1,25 @@
pragma solidity ^0.8.20;
interface AggregatorV3Interface {
function latestRoundData() external view returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
}
contract SPriceOracle {
AggregatorV3Interface public priceFeed;
constructor() {
priceFeed = AggregatorV3Interface(0x726D2E87d73567ecA1b75C063Bd09c1493655918);
}
/// @notice Returns the USD price of S in 1e18 based on API3
function getLatestPrice(address token) external view returns (uint256) {
(, int256 price,,,) = priceFeed.latestRoundData();
require(price > 0, "Invalid price from Chainlink");
return uint256(price);
}
}