Skip to content
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

rename EPOCH_DEFAULT to EPOCH_NOT_INITIALIZED #118

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions contracts/hooks/examples/LimitOrder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ contract LimitOrder is BaseHook {

bytes internal constant ZERO_BYTES = bytes("");

Epoch private constant EPOCH_DEFAULT = Epoch.wrap(0);
Epoch private constant EPOCH_EMPTY = Epoch.wrap(0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i dont mind this - but i'd maybe go for ZERO_EPOCH? to match when we use things like ZERO_ADDRESS?


mapping(PoolId => int24) public tickLowerLasts;
Epoch public epochNext = Epoch.wrap(1);
Expand Down Expand Up @@ -159,7 +159,7 @@ contract LimitOrder is BaseHook {

function _fillEpoch(PoolKey calldata key, int24 lower, bool zeroForOne) internal {
Epoch epoch = getEpoch(key, lower, zeroForOne);
if (!epoch.equals(EPOCH_DEFAULT)) {
if (!epoch.equals(EPOCH_EMPTY)) {
EpochInfo storage epochInfo = epochInfos[epoch];

epochInfo.filled = true;
Expand All @@ -172,7 +172,7 @@ contract LimitOrder is BaseHook {
epochInfo.token1Total += amount1;
}

setEpoch(key, lower, zeroForOne, EPOCH_DEFAULT);
setEpoch(key, lower, zeroForOne, EPOCH_EMPTY);

emit Fill(epoch, key, lower, zeroForOne);
}
Expand Down Expand Up @@ -233,7 +233,7 @@ contract LimitOrder is BaseHook {

EpochInfo storage epochInfo;
Epoch epoch = getEpoch(key, tickLower, zeroForOne);
if (epoch.equals(EPOCH_DEFAULT)) {
if (epoch.equals(EPOCH_EMPTY)) {
unchecked {
setEpoch(key, tickLower, zeroForOne, epoch = epochNext);
// since epoch was just assigned the current value of epochNext,
Expand Down
Loading