-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds Arbitrum's sequencer healthy check. #180
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,106 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.10; | ||
|
||
import {Test, console2} from "forge-std/Test.sol"; | ||
import {OverlayV1Market} from "contracts/OverlayV1Market.sol"; | ||
import {OverlayV1Factory} from "contracts/OverlayV1Factory.sol"; | ||
import {OverlayV1Token} from "contracts/OverlayV1Token.sol"; | ||
import {OverlayV1Deployer} from "contracts/OverlayV1Deployer.sol"; | ||
import {Position} from "contracts/libraries/Position.sol"; | ||
import {AggregatorMock} from "contracts/mocks/AggregatorMock.sol"; | ||
|
||
contract SequencerTest is Test { | ||
bytes32 constant ADMIN = 0x00; | ||
bytes32 constant MINTER_ROLE = keccak256("MINTER"); | ||
bytes32 constant BURNER_ROLE = keccak256("BURNER"); | ||
bytes32 constant GOVERNOR_ROLE = keccak256("GOVERNOR"); | ||
bytes32 constant GUARDIAN_ROLE = keccak256("GUARDIAN"); | ||
bytes32 constant PAUSER_ROLE = keccak256("PAUSER"); | ||
|
||
address immutable GOVERNOR = makeAddr("governor"); | ||
address immutable FEE_RECIPIENT = makeAddr("fee-recipient"); | ||
address immutable PAUSER = makeAddr("pauser"); | ||
address immutable USER = makeAddr("user"); | ||
address constant FEED_FACTORY = 0x92ee7A26Dbc18E9C0157831d79C2906A02fD1FAe; | ||
address constant FEED = 0x46B4143CAf2fE2965349FCa53730e83f91247E2C; | ||
AggregatorMock sequencer_oracle; | ||
|
||
OverlayV1Token ov; | ||
OverlayV1Factory factory; | ||
OverlayV1Market market; | ||
OverlayV1Deployer deployer; | ||
|
||
function setUp() public { | ||
vm.createSelectFork(vm.envString("RPC"), 169_490_320); | ||
ov = new OverlayV1Token(); | ||
sequencer_oracle = new AggregatorMock(); | ||
factory = | ||
new OverlayV1Factory(address(ov), FEE_RECIPIENT, address(sequencer_oracle), 30 minutes); | ||
|
||
ov.grantRole(ADMIN, address(factory)); | ||
ov.grantRole(ADMIN, GOVERNOR); | ||
ov.grantRole(MINTER_ROLE, GOVERNOR); | ||
ov.grantRole(GOVERNOR_ROLE, GOVERNOR); | ||
ov.grantRole(PAUSER_ROLE, PAUSER); | ||
|
||
uint256[15] memory params; | ||
params[0] = 115740740740; | ||
params[1] = 750000000000000000; | ||
params[2] = 2475000000000000; | ||
params[3] = 5000000000000000000; | ||
params[4] = 20000000000000000000000; | ||
params[5] = 10000000000000000000; | ||
params[6] = 2592000; | ||
params[7] = 1666666666666666666666; | ||
params[8] = 40000000000000000; | ||
params[9] = 50000000000000000; | ||
params[10] = 50000000000000000; | ||
params[11] = 750000000000000; | ||
params[12] = 100000000000000; | ||
params[13] = 87000000000000; | ||
params[14] = 250; | ||
|
||
vm.startPrank(GOVERNOR); | ||
factory.addFeedFactory(FEED_FACTORY); | ||
|
||
market = OverlayV1Market(factory.deployMarket(FEED_FACTORY, FEED, params)); | ||
|
||
ov.mint(USER, 100e18); | ||
} | ||
|
||
function testSequencerDown() public { | ||
sequencer_oracle.setData(1, 1); //Sequencer Down | ||
vm.startPrank(USER); | ||
ov.approve(address(market), type(uint256).max); | ||
vm.expectRevert("OVV1:!sequencer"); | ||
market.build(1e18, 1e18, true, type(uint256).max); | ||
|
||
vm.stopPrank(); | ||
sequencer_oracle.setData(2, 0); //Sequencer Up | ||
skip(15 minutes); | ||
|
||
vm.startPrank(USER); | ||
vm.expectRevert(); // Grace period not over | ||
market.build(1e18, 1e18, true, type(uint256).max); | ||
|
||
skip(45 minutes); | ||
market.build(1e18, 1e18, true, type(uint256).max); | ||
|
||
vm.stopPrank(); | ||
sequencer_oracle.setData(3, 1); //Sequencer Down | ||
skip(60 minutes); | ||
|
||
vm.startPrank(USER); | ||
vm.expectRevert(); | ||
market.unwind(0, 1e18, 0); | ||
|
||
vm.stopPrank(); | ||
sequencer_oracle.setData(4, 0); | ||
skip(60 minutes); | ||
|
||
vm.startPrank(USER); | ||
market.unwind(0, 1e18, 0); | ||
|
||
assertLt(ov.balanceOf(USER), 100e18); | ||
} | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we are using the
lastUpdatedTimestamp
field (timestamp of when the round was updated), which is what AAVE is doing as well.However, in the Chainlink docs, the
startedAt
(timestamp of when the round started) timestamp is used instead.I think both implementations should be correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From ArbitrumSequencerUptimeFeed.sol - latestRoundData() we see that both variables are actually the same.
Conceptually, we should use the one that's higher.