-
Notifications
You must be signed in to change notification settings - Fork 505
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* move sub unsub * use struct * pass in bytes to setConfigId * ...
- Loading branch information
1 parent
4d56687
commit 469f856
Showing
17 changed files
with
171 additions
and
129 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
341062 | ||
341067 |
2 changes: 1 addition & 1 deletion
2
.forge-snapshots/PositionManager_mint_nativeWithSweep_withClose.snap
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 |
---|---|---|
@@ -1 +1 @@ | ||
349554 | ||
349559 |
2 changes: 1 addition & 1 deletion
2
.forge-snapshots/PositionManager_mint_nativeWithSweep_withSettlePair.snap
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 |
---|---|---|
@@ -1 +1 @@ | ||
348856 | ||
348861 |
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 |
---|---|---|
@@ -1 +1 @@ | ||
319044 | ||
319049 |
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 |
---|---|---|
@@ -1 +1 @@ | ||
319686 | ||
319691 |
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 |
---|---|---|
@@ -1 +1 @@ | ||
245268 | ||
245273 |
2 changes: 1 addition & 1 deletion
2
.forge-snapshots/PositionManager_mint_settleWithBalance_sweep.snap
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 |
---|---|---|
@@ -1 +1 @@ | ||
375086 | ||
375091 |
2 changes: 1 addition & 1 deletion
2
.forge-snapshots/PositionManager_mint_warmedPool_differentRange.snap
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 |
---|---|---|
@@ -1 +1 @@ | ||
325062 | ||
325067 |
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 |
---|---|---|
@@ -1 +1 @@ | ||
376362 | ||
376367 |
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 |
---|---|---|
@@ -1 +1 @@ | ||
375502 | ||
375507 |
2 changes: 1 addition & 1 deletion
2
.forge-snapshots/PositionManager_multicall_initialize_mint.snap
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 |
---|---|---|
@@ -1 +1 @@ | ||
420836 | ||
420841 |
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,39 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
pragma solidity ^0.8.24; | ||
|
||
/// @notice A configId is set per tokenId | ||
/// The lower 255 bits are used to store the truncated hash of the corresponding PositionConfig | ||
/// The upper bit is used to signal if the tokenId has a subscriber | ||
struct PositionConfigId { | ||
bytes32 id; | ||
} | ||
|
||
library PositionConfigIdLibrary { | ||
bytes32 constant MASK_UPPER_BIT = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; | ||
bytes32 constant DIRTY_UPPER_BIT = 0x8000000000000000000000000000000000000000000000000000000000000000; | ||
|
||
/// @notice returns the truncated hash of the PositionConfig for a given tokenId | ||
function getConfigId(PositionConfigId storage _configId) internal view returns (bytes32 configId) { | ||
configId = _configId.id & MASK_UPPER_BIT; | ||
} | ||
|
||
/// @dev We only set the config on mint, guaranteeing that the most significant bit is unset, so we can just assign the entire 32 bytes to the id. | ||
function setConfigId(PositionConfigId storage _configId, bytes32 configId) internal { | ||
_configId.id = configId; | ||
} | ||
|
||
function setSubscribe(PositionConfigId storage configId) internal { | ||
configId.id |= DIRTY_UPPER_BIT; | ||
} | ||
|
||
function setUnsubscribe(PositionConfigId storage configId) internal { | ||
configId.id &= MASK_UPPER_BIT; | ||
} | ||
|
||
function hasSubscriber(PositionConfigId storage configId) internal view returns (bool subscribed) { | ||
bytes32 _id = configId.id; | ||
assembly ("memory-safe") { | ||
subscribed := shr(255, _id) | ||
} | ||
} | ||
} |
Oops, something went wrong.