Skip to content

Commit

Permalink
Fix V3 Serialization (#276)
Browse files Browse the repository at this point in the history
* Add input to serialization

* Correct ordering

* fmt
  • Loading branch information
codyborn authored Sep 25, 2024
1 parent 062b516 commit 278d265
Show file tree
Hide file tree
Showing 22 changed files with 28 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
198132
198780
2 changes: 1 addition & 1 deletion .forge-snapshots/Base-V3DutchOrder-ExecuteBatch.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
229797
231116
Original file line number Diff line number Diff line change
@@ -1 +1 @@
243298
244626
Original file line number Diff line number Diff line change
@@ -1 +1 @@
300708
302041
Original file line number Diff line number Diff line change
@@ -1 +1 @@
223323
224642
2 changes: 1 addition & 1 deletion .forge-snapshots/Base-V3DutchOrder-ExecuteSingle.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
164517
165165
Original file line number Diff line number Diff line change
@@ -1 +1 @@
150079
150727
Original file line number Diff line number Diff line change
@@ -1 +1 @@
173829
174481
2 changes: 1 addition & 1 deletion .forge-snapshots/Base-V3DutchOrder-RevertInvalidNonce.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
43133
43785
2 changes: 1 addition & 1 deletion .forge-snapshots/Base-V3DutchOrder-V3-ExclusiveFiller.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
168443
169089
2 changes: 1 addition & 1 deletion .forge-snapshots/Base-V3DutchOrder-V3-InputOverride.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
168524
169170
2 changes: 1 addition & 1 deletion .forge-snapshots/Base-V3DutchOrder-V3-OutputOverride.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
168467
169113
2 changes: 1 addition & 1 deletion .forge-snapshots/V3-DutchDecay.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20920
13179
2 changes: 1 addition & 1 deletion .forge-snapshots/V3-DutchDecayBounded.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1209
1199
2 changes: 1 addition & 1 deletion .forge-snapshots/V3-DutchDecayFullyDecayed.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
11797
6677
2 changes: 1 addition & 1 deletion .forge-snapshots/V3-DutchDecayFullyDecayedNegative.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
11485
6365
2 changes: 1 addition & 1 deletion .forge-snapshots/V3-ExtendedMultiPointDutchDecay.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
209206
88354
2 changes: 1 addition & 1 deletion .forge-snapshots/V3-LocateCurvePositionMulti.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
40525
20492
2 changes: 1 addition & 1 deletion .forge-snapshots/V3-LocateCurvePositionSingle.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12623
6860
2 changes: 1 addition & 1 deletion .forge-snapshots/V3-MultiPointDutchDecay.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
48878
26242
9 changes: 7 additions & 2 deletions src/lib/V3DutchOrderLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,13 @@ library V3DutchOrderLib {
abi.encodePacked("NonlinearDutchDecay(", "uint256 relativeBlocks,", "int256[] relativeAmounts)");
bytes32 internal constant NON_LINEAR_DECAY_TYPE_HASH = keccak256(NON_LINEAR_DECAY_TYPE);

bytes internal constant ORDER_TYPE =
abi.encodePacked(NON_LINEAR_DECAY_TYPE, V3_DUTCH_ORDER_TYPE, V3_DUTCH_OUTPUT_TYPE, OrderInfoLib.ORDER_INFO_TYPE);
bytes internal constant ORDER_TYPE = abi.encodePacked(
NON_LINEAR_DECAY_TYPE,
V3_DUTCH_INPUT_TYPE,
V3_DUTCH_ORDER_TYPE,
V3_DUTCH_OUTPUT_TYPE,
OrderInfoLib.ORDER_INFO_TYPE
);
bytes32 internal constant ORDER_TYPE_HASH = keccak256(ORDER_TYPE);

/// @dev Note that sub-structs have to be defined in alphabetical order in the EIP-712 spec
Expand Down
2 changes: 1 addition & 1 deletion src/types/Uint16Array.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function toUint16Array(uint16[] memory inputArray) pure returns (Uint16Array uin

library Uint16ArrayLibrary {
// Retrieve the nth uint16 value from a packed uint256
function getElement(Uint16Array packedData, uint256 n) public pure returns (uint16) {
function getElement(Uint16Array packedData, uint256 n) internal pure returns (uint16) {
if (n >= 16) {
revert IndexOutOfBounds();
}
Expand Down

0 comments on commit 278d265

Please sign in to comment.