Skip to content

Commit

Permalink
fix 0 timewindow
Browse files Browse the repository at this point in the history
  • Loading branch information
Arvolear committed Oct 5, 2023
1 parent 2e0fd33 commit 9ce2451
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion contracts/oracles/UniswapV2Oracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ abstract contract UniswapV2Oracle is Initializable {
*
* May be called at any time. The time window automatically adjusts
*/
function updatePrices() public {
function updatePrices() public virtual {
uint256 pairsLength_ = _pairs.length();

for (uint256 i = 0; i < pairsLength_; i++) {
Expand Down Expand Up @@ -161,6 +161,8 @@ abstract contract UniswapV2Oracle is Initializable {
* @param newTimeWindow_ the new time window value in seconds
*/
function _setTimeWindow(uint256 newTimeWindow_) internal {
require(newTimeWindow_ > 0, "UniswapV2Oracle: time window can't be 0");

timeWindow = newTimeWindow_;
}

Expand Down
4 changes: 4 additions & 0 deletions test/oracles/UniswapV2Oracle.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ describe("UniswapV2Oracle", () => {
assert.equal(await oracle.timeWindow(), 20);
});

it("shouldn't set 0 timewindow", async () => {
await truffleAssert.reverts(oracle.setTimeWindow(0), "UniswapV2Oracle: time window can't be 0");
});

it("should add paths correctly", async () => {
await createPairs();

Expand Down

0 comments on commit 9ce2451

Please sign in to comment.