Issue with `dTSLA::getUsdcValueOfUsd`
Closed this issue · 3 comments
In the sendRedeemRequest
function, we need to get the amountTslaInUsdc
in order to check for minimum usdc redeemption.
So, we are converting from TSLA -> USD -> USDC.
The getUsdValueOfTsla
returns the usd value that is used in getUsdcValueOfUsd
, where the latter function is expected to return the usdc value of the usd, but it does the other way round.
function getUsdcValueOfUsd(uint256 usdAmount) public view returns (uint256) {
return (usdAmount * getUsdcPrice()) / PRECISION;
}
Here the price feeds used to get getUsdcPrice()
is of USDC/USD
, therefore it returns the price of usd value of 1 usdc.
Therefore, the implementation for getUsdcValueOfUsd
is incorrect.
I think I'm following, I'd have to double check. So you're saying it's just backwards?
I think I'm following, I'd have to double check. So you're saying it's just backwards?
The implementation for getUsdcValueOfUsd
should be like below:
(Note: This function is required to convert the USD
amount to USDC
, where getUsdcPrice()
returns the USD
in 1 USDC
Therefore, let's say x USD
in 1 USDC
)
Therefore for usdAmount USD
, USDC
amount will be usdAmount / x
function getUsdcValueOfUsd(uint256 usdAmount) public view returns (uint256) {
return (usdAmount * PRECISION) / getUsdcPrice();
}
You're right. I've updated it here. Thank you!