-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Market Status Provider into protocol, add test setup
- Loading branch information
Showing
9 changed files
with
147 additions
and
2 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
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,32 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
interface IMarketStatus { | ||
function allowed(address) external view returns (bool); | ||
|
||
function exchanges(bytes32) external view returns (bytes32); | ||
|
||
function status(bytes32) external view returns (uint256); | ||
|
||
function setStatus(bytes32[] calldata, bool[] calldata) external; | ||
|
||
function setTickers(bytes32[] calldata, bytes32[] calldata) external; | ||
|
||
function setAllowed(address, bool) external; | ||
|
||
function getExchangeStatus(bytes32) external view returns (bool); | ||
|
||
function getExchangeStatuses( | ||
bytes32[] calldata | ||
) external view returns (bool[] memory); | ||
|
||
function getExchange(bytes32) external view returns (bytes32); | ||
|
||
function getTickerStatus(bytes32) external view returns (bool); | ||
|
||
function getTickerStatuses( | ||
bytes32[] calldata | ||
) external view returns (bool[] memory); | ||
|
||
function owner() external view returns (address); | ||
} |
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 @@ | ||
pragma solidity ^0.8.0; | ||
|
||
contract MockMarketStatus { | ||
mapping(bytes32 => bool) public tickers; | ||
|
||
function setTickerStatus(bytes32 _ticker, bool _status) external { | ||
tickers[_ticker] = _status; | ||
} | ||
|
||
function getTickerStatus(bytes32 _ticker) external view returns (bool) { | ||
return tickers[_ticker]; | ||
} | ||
} |
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,76 @@ | ||
// solhint-disable state-visibility, max-states-count, no-empty-blocks, no-console | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import {Deployed} from "scripts/deploy/libs/Deployed.s.sol"; | ||
import {Log, Help} from "kresko-lib/utils/Libs.s.sol"; | ||
import {ShortAssert} from "kresko-lib/utils/ShortAssert.t.sol"; | ||
import {Tested} from "kresko-lib/utils/Tested.t.sol"; | ||
import {IKresko} from "periphery/IKresko.sol"; | ||
import {IWETH9} from "kresko-lib/token/IWETH9.sol"; | ||
import {FacetCut, FacetCutAction} from "diamond/DSTypes.sol"; | ||
import {CommonConfigFacet} from "common/facets/CommonConfigFacet.sol"; | ||
import {CommonStateFacet} from "common/facets/CommonStateFacet.sol"; | ||
import {MockMarketStatus} from "src/contracts/mocks/MockMarketStatus.sol"; | ||
import {ProtocolUpgrader} from "scripts/utils/ProtocolUpgrader.s.sol"; | ||
|
||
contract MarketStatusTest is Tested, ProtocolUpgrader { | ||
using Log for *; | ||
using Help for *; | ||
using Deployed for *; | ||
using ShortAssert for *; | ||
|
||
IKresko kresko = IKresko(0x0000000000177abD99485DCaea3eFaa91db3fe72); | ||
|
||
address safe = 0x266489Bde85ff0dfe1ebF9f0a7e6Fed3a973cEc3; | ||
|
||
CommonConfigFacet config; | ||
CommonStateFacet state; | ||
MockMarketStatus provider; | ||
|
||
function setUp() public pranked(safe) { | ||
vm.createSelectFork("arbitrum", 205696320); | ||
|
||
// Deploy new facets and market status | ||
config = new CommonConfigFacet(); | ||
state = new CommonStateFacet(); | ||
provider = new MockMarketStatus(); | ||
|
||
// Update CommonConfigFacet | ||
bytes4[] memory selectors = getSelectors("CommonConfigFacet"); | ||
address oldFacet = kresko.facetAddress(selectors[0]); | ||
bytes4[] memory oldSelectors = kresko.facetFunctionSelectors(oldFacet); | ||
|
||
FacetCut[] memory cuts = new FacetCut[](1); | ||
// Remove Config facet | ||
cuts[0] = (FacetCut({facetAddress: address(0), action: FacetCutAction.Remove, functionSelectors: oldSelectors})); | ||
kresko.diamondCut(cuts, address(0), ""); | ||
// Add Config facet | ||
cuts[0] = FacetCut(address(config), FacetCutAction.Add, selectors); | ||
kresko.diamondCut(cuts, address(0), ""); | ||
|
||
// Update CommonStateFacet | ||
selectors = getSelectors("CommonStateFacet"); | ||
oldFacet = kresko.facetAddress(selectors[0]); | ||
oldSelectors = kresko.facetFunctionSelectors(oldFacet); | ||
|
||
// Remove State facet | ||
cuts[0] = FacetCut({facetAddress: address(0), action: FacetCutAction.Remove, functionSelectors: oldSelectors}); | ||
kresko.diamondCut(cuts, address(0), ""); | ||
// Add State facet | ||
cuts[0] = FacetCut(address(state), FacetCutAction.Add, selectors); | ||
kresko.diamondCut(cuts, address(0), ""); | ||
|
||
// Set Market Status Provider | ||
kresko.getMarketStatusProvider().eq(address(0)); | ||
|
||
kresko.setMarketStatusProvider(address(provider)); | ||
} | ||
|
||
function test_Facets_Update() external { | ||
kresko.getMarketStatusProvider().eq(address(provider)); | ||
kresko.getPythEndpoint().notEq(address(0)); | ||
kresko.getFeeRecipient().eq(safe); | ||
kresko.getGatingManager().notEq(address(0)); | ||
} | ||
} |