-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: chrismaree <christopher.maree@gmail.com>
- Loading branch information
1 parent
95533b2
commit 2f4845d
Showing
11 changed files
with
95 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.17; | ||
|
||
import "openzeppelin-contracts/contracts/access/Ownable.sol"; | ||
import "../OevOracle.sol"; | ||
import "../interfaces/IBaseController.sol"; | ||
|
||
contract BaseController is IBaseController, OevOracle, Ownable { | ||
constructor(address _sourceAdapter) OevOracle(_sourceAdapter) {} | ||
|
||
mapping(address => bool) public updaters; | ||
|
||
uint256 public permissionWindow = 10 minutes; | ||
|
||
function setUpdater(address _updater, bool allowed) public onlyOwner { | ||
updaters[_updater] = allowed; | ||
} | ||
|
||
function setPermissionWindow(uint256 _permissionWindow) public onlyOwner { | ||
permissionWindow = _permissionWindow; | ||
} | ||
|
||
function canUpdate(address caller, uint256 cachedLatestTimestamp) | ||
public | ||
view | ||
override(IBaseController, OevOracle) | ||
returns (bool) | ||
{ | ||
return updaters[caller] || (block.timestamp - cachedLatestTimestamp) > permissionWindow; | ||
} | ||
|
||
function validateUpdate(int256 rawLatestAnswer, uint256 rawLatestTimestamp) | ||
public | ||
view | ||
override(IBaseController, OevOracle) | ||
returns (bool) | ||
{ | ||
// sample dummy check. | ||
return rawLatestAnswer > 0 && rawLatestTimestamp > 0; | ||
} | ||
|
||
function canReturnCachedValue(uint256 cachedLatestTimestamp) | ||
public | ||
view | ||
override(IBaseController, OevOracle) | ||
returns (bool) | ||
{ | ||
return (block.timestamp - cachedLatestTimestamp < permissionWindow); | ||
} | ||
|
||
function canSetSourceOracleAdapter(address caller) | ||
public | ||
view | ||
override(IBaseController, OevOracle) | ||
returns (bool) | ||
{ | ||
return caller == owner(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.17; | ||
|
||
interface IBaseController { | ||
function canUpdate(address caller, uint256 cachedLatestTimestamp) external view returns (bool); | ||
|
||
//TODO: think if we actually want this validation here. this means we have 2 forms of validation, one within the source adapter and the second here. is this needed? | ||
function validateUpdate(int256 rawLatestAnswer, uint256 rawLatestTimestamp) external view returns (bool); | ||
|
||
function canReturnCachedValue(uint256 cachedLatestTimestamp) external view returns (bool); | ||
|
||
function canSetSourceOracleAdapter(address caller) external view returns (bool); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters