-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' into feat/veion-ui
- Loading branch information
Showing
267 changed files
with
116,518 additions
and
6,371 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
36 changes: 36 additions & 0 deletions
36
packages/contracts/contracts/compound/CTokenOracleProtected.sol
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,36 @@ | ||
// SPDX-License-Identifier: Unlicense | ||
pragma solidity ^0.8.22; | ||
|
||
import { CErc20Storage } from "./CTokenInterfaces.sol"; | ||
import { IHypernativeOracle } from "../external/hypernative/interfaces/IHypernativeOracle.sol"; | ||
|
||
contract CTokenOracleProtected is CErc20Storage { | ||
error InteractionNotAllowed(); | ||
|
||
modifier onlyOracleApproved() { | ||
address oracleAddress = ap.getAddress("HYPERNATIVE_ORACLE"); | ||
if (oracleAddress == address(0)) { | ||
_; | ||
return; | ||
} | ||
IHypernativeOracle oracle = IHypernativeOracle(oracleAddress); | ||
if (oracle.isBlacklistedContext(msg.sender, tx.origin) || !oracle.isTimeExceeded(msg.sender)) { | ||
revert InteractionNotAllowed(); | ||
} | ||
_; | ||
} | ||
|
||
modifier onlyOracleApprovedAllowEOA() { | ||
address oracleAddress = ap.getAddress("HYPERNATIVE_ORACLE"); | ||
if (oracleAddress == address(0)) { | ||
_; | ||
return; | ||
} | ||
|
||
IHypernativeOracle oracle = IHypernativeOracle(oracleAddress); | ||
if (oracle.isBlacklistedAccount(msg.sender) || msg.sender != tx.origin) { | ||
revert InteractionNotAllowed(); | ||
} | ||
_; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
packages/contracts/contracts/external/hypernative/interfaces/IHypernativeOracle.sol
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,10 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.22; | ||
|
||
interface IHypernativeOracle { | ||
function register(address account) external; | ||
function registerStrict(address account) external; | ||
function isBlacklistedAccount(address account) external view returns (bool); | ||
function isBlacklistedContext(address sender, address origin) external view returns (bool); | ||
function isTimeExceeded(address account) external view returns (bool); | ||
} |
Oops, something went wrong.