In summary, the current implementation incorrectly uses a single timestamp for all tokens, which does not align with the documentation claiming to provide token-specific timestamps. By implementing a mapping for individual token timestamps, you can ensure that users receive accurate information about when each token's price was last updated. This change will enhance the clarity and functionality of the contract.
In the current implementation, there is a single state variable:
This variable is intended to store the timestamp of the last price update. However, it is a global variable that applies to all tokens managed by the contract.
The problem arises in the getLatestPrice
function:
Here, when a user calls getLatestPrice
for a specific token ID, the function returns the price of that token along with the lastUpdateTimestamp
. However, this timestamp does not reflect when the price for that specific token was last updated. Instead, it reflects the last time any token's price was updated.
The documentation for the getLatestPrice
function states:
This comment implies that the function returns a timestamp specific to the token identified by _tokenId
. However, since lastUpdateTimestamp
is a single global variable, it does not provide a token-specific timestamp. This discrepancy can lead to confusion for users of the contract, as they might expect the timestamp to reflect the last update for the specific token they are querying.
To resolve this issue, you should implement a mapping that tracks the last update timestamp for each token individually. For example:
Then, in the setHousePrice
function, you would update this mapping whenever a token's price is set:
Finally, you would modify the getLatestPrice
function to return the specific timestamp for the queried token:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.