Collateral Size Determination & Oracle
How Will The Collateral Size Determined Against The Issued Bonds?
// Importing the required contracts and libraries
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
// Defining the contract for RDTN price oracle
contract RDTNPriceOracle {
// Defining the aggregator contract for RDTN price feed
AggregatorV3Interface internal priceFeed;
// Constructor function to set the RDTN price feed contract address
constructor() public {
priceFeed = AggregatorV3Interface(0x9326BFA02ADD2366b30bacB125260Af641031331);
}
// Function to get the current RDTN price in USD
function getRDTNPrice() public view returns (uint256) {
(
uint80 roundID,
int256 price,
uint256 startedAt,
uint256 timeStamp,
uint80 answeredInRound
) = priceFeed.latestRoundData();
return uint256(price);
}
// Function to calculate the amount of RDTN to be locked in collateral pool
function calculateCollateralAmount(uint256 totalBondAmount) public view returns (uint256) {
uint256 rdtPrice = getRDTNPrice();
uint256 collateralAmount = totalBondAmount * rdtPrice / 1e18;
return collateralAmount;
}
}
Last updated