Revert "feat(multi-atm): linear accrual"#57
Conversation
This reverts commit 0e27d4a.
There was a problem hiding this comment.
Pull request overview
Reverts the previously introduced “linear accrual” (linear regression pricing) changes for MultiATM, restoring the simpler 2-point oracle pricing model and updating the test suite accordingly.
Changes:
- Removes accrual-related state, validation, and pricing logic from
contracts/token/MultiATM.sol. - Updates
setPair/PairUpdatedinterfaces to drop theaccrualRoundsparameter/field. - Deletes accrual-focused tests and adjusts oracle staleness timing assertions in
test/main.test.js.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
contracts/token/MultiATM.sol |
Removes linear accrual pricing and simplifies _getPrices and setPair back to non-accrual behavior. |
test/main.test.js |
Updates setPair calls/event expectations and removes accrual regression test coverage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| (uint80 roundId, int256 latest, , , ) = oracle.latestRoundData(); | ||
| (, int256 previous, , uint256 updatedAt, ) = oracle.getRoundData(roundId - 1); | ||
| require(block.timestamp < updatedAt + oracleTTL, OracleValueTooOld(oracle)); |
There was a problem hiding this comment.
_getPrices() calls oracle.getRoundData(roundId - 1) without ensuring roundId >= 1. Since Oracle roundIds are 0-indexed, if only one price has been published (latest roundId == 0) this will underflow and revert with a Solidity panic instead of a controlled error. Add an explicit guard (e.g., require(roundId > 0, ...)) before subtracting, and consider returning a clear custom error for insufficient oracle history.
Also, the TTL check currently uses updatedAt from the previous round only. Because Oracle.publishPrice accepts arbitrary (non-monotonic) timepoints, this can miss the case where the latest round’s updatedAt is older than the previous round’s and should be considered stale. A robust approach is to fetch updatedAt from latestRoundData and getRoundData(roundId-1) and enforce staleness against the older of the two timestamps (or check both).
| (uint80 roundId, int256 latest, , , ) = oracle.latestRoundData(); | |
| (, int256 previous, , uint256 updatedAt, ) = oracle.getRoundData(roundId - 1); | |
| require(block.timestamp < updatedAt + oracleTTL, OracleValueTooOld(oracle)); | |
| (uint80 roundId, int256 latest, , uint256 latestUpdatedAt, ) = oracle.latestRoundData(); | |
| require(roundId > 0, "MultiATM: insufficient oracle history"); | |
| (, int256 previous, , uint256 previousUpdatedAt, ) = oracle.getRoundData(roundId - 1); | |
| uint256 oldestUpdatedAt = Math.min(latestUpdatedAt, previousUpdatedAt); | |
| require(block.timestamp < oldestUpdatedAt + oracleTTL, OracleValueTooOld(oracle)); |
This reverts commit 0e27d4a.