Skip to content

Revert "feat(multi-atm): linear accrual"#57

Merged
adam-hotait merged 1 commit intomainfrom
chore/revert
Feb 26, 2026
Merged

Revert "feat(multi-atm): linear accrual"#57
adam-hotait merged 1 commit intomainfrom
chore/revert

Conversation

@adam-hotait
Copy link
Copy Markdown
Contributor

This reverts commit 0e27d4a.

Copilot AI review requested due to automatic review settings February 26, 2026 18:16
@adam-hotait adam-hotait merged commit 91bb5d1 into main Feb 26, 2026
2 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 / PairUpdated interfaces to drop the accrualRounds parameter/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.

Comment on lines +279 to 281
(uint80 roundId, int256 latest, , , ) = oracle.latestRoundData();
(, int256 previous, , uint256 updatedAt, ) = oracle.getRoundData(roundId - 1);
require(block.timestamp < updatedAt + oracleTTL, OracleValueTooOld(oracle));
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_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).

Suggested change
(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));

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants