-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* WIP * Feat/ast 1952 v1 handler testing (#41) * update getAuctionStart to be a public helper, make an internal version that is more optimized(less calls/decoding), add tests * coverage testing for AstariaV1Settlement handler complete * coverage testing for AstariaV1Settlement handler complete * fix test name * feat/AST 1952 v1 handler testing (#43) * update getAuctionStart to be a public helper, make an internal version that is more optimized(less calls/decoding), add tests * coverage testing for AstariaV1Settlement handler complete * coverage testing for AstariaV1Settlement handler complete * fix test name * Astaria V1 Hook testing complete(-withdraw), Conduit Helper Removed, ConduitTransfer => AdditionalTransfer * remove commented code * final comment removal * feat/V1 hook updates (#44) * update getAuctionStart to be a public helper, make an internal version that is more optimized(less calls/decoding), add tests * coverage testing for AstariaV1Settlement handler complete * coverage testing for AstariaV1Settlement handler complete * fix test name * Astaria V1 Hook testing complete(-withdraw), Conduit Helper Removed, ConduitTransfer => AdditionalTransfer * remove commented code * final comment removal * additional tests for v1 hook as well as some cleanup/fixes * update snaphot * working caveat testing and reentrancy guard * remove ownable and change loan.issuer to lender --------- Co-authored-by: androolloyd <[email protected]>
- Loading branch information
1 parent
90411a2
commit 675328b
Showing
8 changed files
with
590 additions
and
140 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import {Ownable} from "solady/src/auth/Ownable.sol"; | ||
|
||
abstract contract PausableNonReentrant is Ownable { | ||
uint256 private constant _UNLOCKED = 0x1; | ||
uint256 private constant _LOCKED = 0x2; | ||
uint256 private constant _PAUSED = 0x3; | ||
|
||
uint256 private _state = _UNLOCKED; | ||
|
||
event Paused(); | ||
event Unpaused(); | ||
|
||
error IsPaused(); | ||
error IsLocked(); | ||
error NotPaused(); | ||
|
||
modifier pausableNonReentrant() { | ||
assembly { | ||
//If locked or paused, handle revert cases | ||
if gt(sload(_state.slot), _UNLOCKED) { | ||
if gt(sload(_state.slot), _LOCKED) { | ||
//Revert IsPaused | ||
mstore(0, 0x1309a563) | ||
revert(0x1c, 0x04) | ||
} | ||
//Revert IsLocked | ||
mstore(0, 0xcaa30f55) | ||
revert(0x1c, 0x04) | ||
} | ||
sstore(_state.slot, _LOCKED) | ||
} | ||
_; | ||
assembly { | ||
sstore(_state.slot, _UNLOCKED) | ||
} | ||
} | ||
|
||
function pause() external onlyOwner { | ||
assembly { | ||
//If locked, prevent owner from overriding state | ||
if eq(sload(_state.slot), _LOCKED) { | ||
//Revert IsLocked | ||
mstore(0, 0xcaa30f55) | ||
revert(0x1c, 0x04) | ||
} | ||
sstore(_state.slot, _PAUSED) | ||
} | ||
emit Paused(); | ||
} | ||
|
||
function unpause() external onlyOwner { | ||
assembly { | ||
//If not paused, prevent owner from overriding state | ||
if lt(sload(_state.slot), _PAUSED) { | ||
//Revert NotPaused | ||
mstore(0, 0x6cd60201) | ||
revert(0x1c, 0x04) | ||
} | ||
sstore(_state.slot, _UNLOCKED) | ||
} | ||
emit Unpaused(); | ||
} | ||
|
||
function paused() external view returns (bool) { | ||
return _state == _PAUSED; | ||
} | ||
} |
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.