@zoralabs/limit-orders 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/.turbo/turbo-build$colon$js.log +50 -49
  2. package/CHANGELOG.md +73 -0
  3. package/abis/ISetLimitOrderConfig.json +27 -0
  4. package/abis/IWETH.json +118 -0
  5. package/abis/IZoraLimitOrderBook.json +5 -0
  6. package/abis/LimitOrderLiquidity.json +7 -0
  7. package/abis/LimitOrderViews.json +62 -0
  8. package/abis/{SimpleAccessManaged.json → Ownable.json} +29 -10
  9. package/abis/Ownable2Step.json +115 -0
  10. package/abis/PermittedCallers.json +181 -0
  11. package/abis/SwapWithLimitOrders.json +134 -14
  12. package/abis/ZoraLimitOrderBook.json +187 -35
  13. package/cache/solidity-files-cache.json +1 -1
  14. package/dist/index.cjs +219 -34
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.js +219 -34
  17. package/dist/index.js.map +1 -1
  18. package/dist/wagmiGenerated.d.ts +254 -41
  19. package/dist/wagmiGenerated.d.ts.map +1 -1
  20. package/out/BalanceDelta.sol/BalanceDeltaLibrary.json +1 -1
  21. package/out/BeforeSwapDelta.sol/BeforeSwapDeltaLibrary.json +1 -1
  22. package/out/BitMath.sol/BitMath.json +1 -1
  23. package/out/BytesLib.sol/BytesLib.json +1 -1
  24. package/out/CoinCommon.sol/CoinCommon.json +1 -1
  25. package/out/CoinConfigurationVersions.sol/CoinConfigurationVersions.json +1 -1
  26. package/out/CoinConstants.sol/CoinConstants.json +1 -1
  27. package/out/Context.sol/Context.json +1 -1
  28. package/out/Currency.sol/CurrencyLibrary.json +1 -1
  29. package/out/CurrencyReserves.sol/CurrencyReserves.json +1 -1
  30. package/out/CustomRevert.sol/CustomRevert.json +1 -1
  31. package/out/DopplerMath.sol/DopplerMath.json +1 -1
  32. package/out/FixedPoint128.sol/FixedPoint128.json +1 -1
  33. package/out/FixedPoint96.sol/FixedPoint96.json +1 -1
  34. package/out/FullMath.sol/FullMath.json +1 -1
  35. package/out/IAllowanceTransfer.sol/IAllowanceTransfer.json +1 -1
  36. package/out/ICoin.sol/ICoin.json +1 -1
  37. package/out/ICoin.sol/IHasCoinType.json +1 -1
  38. package/out/ICoin.sol/IHasPoolKey.json +1 -1
  39. package/out/ICoin.sol/IHasSwapPath.json +1 -1
  40. package/out/ICoin.sol/IHasTotalSupplyForPositions.json +1 -1
  41. package/out/IDeployedCoinVersionLookup.sol/IDeployedCoinVersionLookup.json +1 -1
  42. package/out/IDopplerErrors.sol/IDopplerErrors.json +1 -1
  43. package/out/IEIP712.sol/IEIP712.json +1 -1
  44. package/out/IERC1363.sol/IERC1363.json +1 -1
  45. package/out/IERC165.sol/IERC165.json +1 -1
  46. package/out/IERC20.sol/IERC20.json +1 -1
  47. package/out/IERC20Minimal.sol/IERC20Minimal.json +1 -1
  48. package/out/IERC6909Claims.sol/IERC6909Claims.json +1 -1
  49. package/out/IERC7572.sol/IERC7572.json +1 -1
  50. package/out/IExtsload.sol/IExtsload.json +1 -1
  51. package/out/IExttload.sol/IExttload.json +1 -1
  52. package/out/IHasRewardsRecipients.sol/IHasRewardsRecipients.json +1 -1
  53. package/out/IHooks.sol/IHooks.json +1 -1
  54. package/out/IMsgSender.sol/IMsgSender.json +1 -1
  55. package/out/IPoolManager.sol/IPoolManager.json +1 -1
  56. package/out/IProtocolFees.sol/IProtocolFees.json +1 -1
  57. package/out/ISetLimitOrderConfig.sol/ISetLimitOrderConfig.json +1 -0
  58. package/out/ISupportsLimitOrderFill.sol/ISupportsLimitOrderFill.json +1 -1
  59. package/out/ISwapPathRouter.sol/ISwapPathRouter.json +1 -1
  60. package/out/ISwapRouter.sol/ISwapRouter.json +1 -1
  61. package/out/IUniswapV3SwapCallback.sol/IUniswapV3SwapCallback.json +1 -1
  62. package/out/IUpgradeableV4Hook.sol/IUpgradeableDestinationV4Hook.json +1 -1
  63. package/out/IUpgradeableV4Hook.sol/IUpgradeableDestinationV4HookWithUpdateableFee.json +1 -1
  64. package/out/IUpgradeableV4Hook.sol/IUpgradeableV4Hook.json +1 -1
  65. package/out/IWETH.sol/IWETH.json +1 -0
  66. package/out/IZoraHookRegistry.sol/IZoraHookRegistry.json +1 -1
  67. package/out/IZoraLimitOrderBook.sol/IZoraLimitOrderBook.json +1 -1
  68. package/out/IZoraLimitOrderBookCoinsInterface.sol/IZoraLimitOrderBookCoinsInterface.json +1 -1
  69. package/out/IZoraV4CoinHook.sol/IZoraV4CoinHook.json +1 -1
  70. package/out/LimitOrderBitmap.sol/LimitOrderBitmap.json +1 -1
  71. package/out/LimitOrderCommon.sol/LimitOrderCommon.json +1 -1
  72. package/out/LimitOrderCreate.sol/LimitOrderCreate.json +1 -1
  73. package/out/LimitOrderFill.sol/LimitOrderFill.json +1 -1
  74. package/out/LimitOrderLiquidity.sol/LimitOrderLiquidity.json +1 -1
  75. package/out/LimitOrderQueues.sol/LimitOrderQueues.json +1 -1
  76. package/out/LimitOrderStorage.sol/LimitOrderStorage.json +1 -1
  77. package/out/LimitOrderTypes.sol/LimitOrderTypes.json +1 -1
  78. package/out/LimitOrderViews.sol/LimitOrderViews.json +1 -0
  79. package/out/LimitOrderWithdraw.sol/LimitOrderWithdraw.json +1 -1
  80. package/out/LiquidityAmounts.sol/LiquidityAmounts.json +1 -1
  81. package/out/LiquidityMath.sol/LiquidityMath.json +1 -1
  82. package/out/Lock.sol/Lock.json +1 -1
  83. package/out/NonzeroDeltaCount.sol/NonzeroDeltaCount.json +1 -1
  84. package/out/Ownable.sol/Ownable.json +1 -0
  85. package/out/Ownable2Step.sol/Ownable2Step.json +1 -0
  86. package/out/Path.sol/Path.json +1 -1
  87. package/out/PathKey.sol/PathKeyLibrary.json +1 -1
  88. package/out/Permit2Payments.sol/Permit2Payments.json +1 -1
  89. package/out/PermittedCallers.sol/PermittedCallers.json +1 -0
  90. package/out/PoolId.sol/PoolIdLibrary.json +1 -1
  91. package/out/Position.sol/Position.json +1 -1
  92. package/out/SafeCast.sol/SafeCast.json +1 -1
  93. package/out/SafeCast160.sol/SafeCast160.json +1 -1
  94. package/out/SafeERC20.sol/SafeERC20.json +1 -1
  95. package/out/SqrtPriceMath.sol/SqrtPriceMath.json +1 -1
  96. package/out/StateLibrary.sol/StateLibrary.json +1 -1
  97. package/out/SwapLimitOrders.sol/SwapLimitOrders.json +1 -1
  98. package/out/SwapWithLimitOrders.sol/SwapWithLimitOrders.json +1 -1
  99. package/out/TickBitmap.sol/TickBitmap.json +1 -1
  100. package/out/TickMath.sol/TickMath.json +1 -1
  101. package/out/TransientSlot.sol/TransientSlot.json +1 -1
  102. package/out/TransientStateLibrary.sol/TransientStateLibrary.json +1 -1
  103. package/out/UniV4SwapToCurrency.sol/UniV4SwapToCurrency.json +1 -1
  104. package/out/UnsafeMath.sol/UnsafeMath.json +1 -1
  105. package/out/V3ToV4SwapLib.sol/V3ToV4SwapLib.json +1 -1
  106. package/out/ZoraLimitOrderBook.sol/ZoraLimitOrderBook.json +1 -1
  107. package/out/build-info/37e0124d88d60569.json +1 -0
  108. package/out/uniswap/BitMath.sol/BitMath.json +1 -1
  109. package/out/uniswap/CustomRevert.sol/CustomRevert.json +1 -1
  110. package/out/uniswap/FullMath.sol/FullMath.json +1 -1
  111. package/out/uniswap/SafeCast.sol/SafeCast.json +1 -1
  112. package/out/uniswap/TickMath.sol/TickMath.json +1 -1
  113. package/package/wagmiGenerated.ts +218 -33
  114. package/package.json +1 -1
  115. package/src/IZoraLimitOrderBook.sol +5 -5
  116. package/src/ZoraLimitOrderBook.sol +24 -41
  117. package/src/access/PermittedCallers.sol +41 -0
  118. package/src/libs/LimitOrderBitmap.sol +0 -51
  119. package/src/libs/LimitOrderCommon.sol +48 -30
  120. package/src/libs/LimitOrderCreate.sol +5 -18
  121. package/src/libs/LimitOrderFill.sol +32 -161
  122. package/src/libs/LimitOrderLiquidity.sol +92 -71
  123. package/src/libs/LimitOrderViews.sol +168 -0
  124. package/src/libs/LimitOrderWithdraw.sol +13 -4
  125. package/src/libs/SwapLimitOrders.sol +14 -7
  126. package/src/router/ISetLimitOrderConfig.sol +12 -0
  127. package/src/router/SwapWithLimitOrders.sol +46 -33
  128. package/test/LimitOrderAccessControl.t.sol +173 -156
  129. package/test/LimitOrderBitmap.t.sol +13 -7
  130. package/test/LimitOrderFill.t.sol +42 -4
  131. package/test/LimitOrderLibraries.t.sol +18 -10
  132. package/test/LimitOrderLiquidityPayouts.t.sol +280 -3
  133. package/test/LimitOrderWithdraw.t.sol +28 -1
  134. package/test/SwapWithLimitOrders.t.sol +3 -5
  135. package/test/SwapWithLimitOrdersRouter.t.sol +108 -13
  136. package/test/gas/LimitOrderFillGas.t.sol +0 -7
  137. package/test/gas/LimitOrderSwapGas.t.sol +0 -6
  138. package/test/unit/LimitOrderBitmapUnit.t.sol +0 -134
  139. package/test/unit/LimitOrderCreateUnit.t.sol +32 -0
  140. package/test/unit/SwapLimitOrdersUnit.t.sol +231 -33
  141. package/test/unit/SwapLimitOrdersValidation.t.sol +28 -42
  142. package/test/unit/SwapWithLimitOrdersUnit.t.sol +21 -88
  143. package/test/utils/BaseTest.sol +34 -22
  144. package/test/utils/MockWETH.sol +39 -0
  145. package/test/utils/TestableZoraLimitOrderBook.sol +5 -7
  146. package/abis/IAuthority.json +0 -31
  147. package/abis/SimpleAccessManager.json +0 -351
  148. package/out/IAuthority.sol/IAuthority.json +0 -1
  149. package/out/SimpleAccessManaged.sol/SimpleAccessManaged.json +0 -1
  150. package/out/SimpleAccessManager.sol/SimpleAccessManager.json +0 -1
  151. package/out/build-info/69718f10d1dc37f0.json +0 -1
  152. package/src/access/SimpleAccessManaged.sol +0 -76
  153. package/src/access/SimpleAccessManager.sol +0 -268
  154. package/test/SimpleAccessManager.t.sol +0 -420
@@ -1,17 +1,17 @@
1
1
 
2
- > @zoralabs/limit-orders@0.2.0 build:js /home/runner/work/zora-protocol-private/zora-protocol-private/packages/limit-orders
2
+ > @zoralabs/limit-orders@0.2.2 build:js /home/runner/work/zora-protocol-private/zora-protocol-private/packages/limit-orders
3
3
  > pnpm run wagmi:generate && pnpm run copy-abis && pnpm run prettier:write && tsup
4
4
 
5
5
 
6
- > @zoralabs/limit-orders@0.2.0 wagmi:generate /home/runner/work/zora-protocol-private/zora-protocol-private/packages/limit-orders
6
+ > @zoralabs/limit-orders@0.2.2 wagmi:generate /home/runner/work/zora-protocol-private/zora-protocol-private/packages/limit-orders
7
7
  > pnpm run build:contracts:minimal && wagmi generate && pnpm exec rename-generated-abi-casing ./package/wagmiGenerated.ts
8
8
 
9
9
 
10
- > @zoralabs/limit-orders@0.2.0 build:contracts:minimal /home/runner/work/zora-protocol-private/zora-protocol-private/packages/limit-orders
10
+ > @zoralabs/limit-orders@0.2.2 build:contracts:minimal /home/runner/work/zora-protocol-private/zora-protocol-private/packages/limit-orders
11
11
  > forge build src/ --no-metadata
12
12
 
13
- Compiling 90 files with Solc 0.8.28
14
- Solc 0.8.28 finished in 7.62s
13
+ Compiling 93 files with Solc 0.8.28
14
+ Solc 0.8.28 finished in 7.13s
15
15
  Compiler run successful!
16
16
  - Validating plugins
17
17
  ✔ Validating plugins
@@ -26,49 +26,50 @@ Compiler run successful!
26
26
  ✅ Updated ./package/wagmiGenerated.ts (3 replacements)
27
27
  ✨ All files processed successfully!
28
28
 
29
- > @zoralabs/limit-orders@0.2.0 copy-abis /home/runner/work/zora-protocol-private/zora-protocol-private/packages/limit-orders
29
+ > @zoralabs/limit-orders@0.2.2 copy-abis /home/runner/work/zora-protocol-private/zora-protocol-private/packages/limit-orders
30
30
  > pnpm exec bundle-abis
31
31
 
32
32
 
33
- > @zoralabs/limit-orders@0.2.0 prettier:write /home/runner/work/zora-protocol-private/zora-protocol-private/packages/limit-orders
33
+ > @zoralabs/limit-orders@0.2.2 prettier:write /home/runner/work/zora-protocol-private/zora-protocol-private/packages/limit-orders
34
34
  > prettier --write 'src/**/*.sol' 'test/**/*.sol'
35
35
 
36
- src/access/SimpleAccessManaged.sol 357ms (unchanged)
37
- src/access/SimpleAccessManager.sol 269ms (unchanged)
38
- src/IZoraLimitOrderBook.sol 59ms (unchanged)
39
- src/libs/LimitOrderBitmap.sol 153ms (unchanged)
40
- src/libs/LimitOrderCommon.sol 171ms (unchanged)
41
- src/libs/LimitOrderCreate.sol 359ms (unchanged)
42
- src/libs/LimitOrderFill.sol 360ms (unchanged)
43
- src/libs/LimitOrderLiquidity.sol 224ms (unchanged)
44
- src/libs/LimitOrderQueues.sol 44ms (unchanged)
45
- src/libs/LimitOrderStorage.sol 15ms (unchanged)
46
- src/libs/LimitOrderTypes.sol 2ms (unchanged)
47
- src/libs/LimitOrderWithdraw.sol 100ms (unchanged)
48
- src/libs/Permit2Payments.sol 23ms (unchanged)
49
- src/libs/SwapLimitOrders.sol 151ms (unchanged)
50
- src/router/SwapWithLimitOrders.sol 265ms (unchanged)
51
- src/ZoraLimitOrderBook.sol 121ms (unchanged)
52
- test/gas/LimitOrderFillGas.t.sol 821ms (unchanged)
53
- test/gas/LimitOrderSwapGas.t.sol 318ms (unchanged)
54
- test/LimitOrderAccessControl.t.sol 390ms (unchanged)
55
- test/LimitOrderBitmap.t.sol 217ms (unchanged)
56
- test/LimitOrderCreate.t.sol 395ms (unchanged)
57
- test/LimitOrderFill.t.sol 1038ms (unchanged)
58
- test/LimitOrderLibraries.t.sol 393ms (unchanged)
59
- test/LimitOrderLiquidityPayouts.t.sol 264ms (unchanged)
60
- test/LimitOrderV4Pools.t.sol 149ms (unchanged)
61
- test/LimitOrderWithdraw.t.sol 639ms (unchanged)
62
- test/SimpleAccessManager.t.sol 328ms (unchanged)
63
- test/SwapWithLimitOrders.t.sol 125ms (unchanged)
64
- test/SwapWithLimitOrdersRouter.t.sol 554ms (unchanged)
65
- test/unit/LimitOrderBitmapUnit.t.sol 176ms (unchanged)
66
- test/unit/LimitOrderCreateUnit.t.sol 151ms (unchanged)
67
- test/unit/SwapLimitOrdersUnit.t.sol 525ms (unchanged)
68
- test/unit/SwapLimitOrdersValidation.t.sol 253ms (unchanged)
69
- test/unit/SwapWithLimitOrdersUnit.t.sol 96ms (unchanged)
70
- test/utils/BaseTest.sol 606ms (unchanged)
71
- test/utils/TestableZoraLimitOrderBook.sol 37ms (unchanged)
36
+ src/access/PermittedCallers.sol 449ms (unchanged)
37
+ src/IZoraLimitOrderBook.sol 54ms (unchanged)
38
+ src/libs/LimitOrderBitmap.sol 57ms (unchanged)
39
+ src/libs/LimitOrderCommon.sol 210ms (unchanged)
40
+ src/libs/LimitOrderCreate.sol 374ms (unchanged)
41
+ src/libs/LimitOrderFill.sol 244ms (unchanged)
42
+ src/libs/LimitOrderLiquidity.sol 250ms (unchanged)
43
+ src/libs/LimitOrderQueues.sol 43ms (unchanged)
44
+ src/libs/LimitOrderStorage.sol 13ms (unchanged)
45
+ src/libs/LimitOrderTypes.sol 3ms (unchanged)
46
+ src/libs/LimitOrderViews.sol 114ms (unchanged)
47
+ src/libs/LimitOrderWithdraw.sol 109ms (unchanged)
48
+ src/libs/Permit2Payments.sol 17ms (unchanged)
49
+ src/libs/SwapLimitOrders.sol 173ms (unchanged)
50
+ src/router/ISetLimitOrderConfig.sol 1ms (unchanged)
51
+ src/router/SwapWithLimitOrders.sol 301ms (unchanged)
52
+ src/ZoraLimitOrderBook.sol 111ms (unchanged)
53
+ test/gas/LimitOrderFillGas.t.sol 792ms (unchanged)
54
+ test/gas/LimitOrderSwapGas.t.sol 283ms (unchanged)
55
+ test/LimitOrderAccessControl.t.sol 396ms (unchanged)
56
+ test/LimitOrderBitmap.t.sol 212ms (unchanged)
57
+ test/LimitOrderCreate.t.sol 364ms (unchanged)
58
+ test/LimitOrderFill.t.sol 999ms (unchanged)
59
+ test/LimitOrderLibraries.t.sol 371ms (unchanged)
60
+ test/LimitOrderLiquidityPayouts.t.sol 420ms (unchanged)
61
+ test/LimitOrderV4Pools.t.sol 141ms (unchanged)
62
+ test/LimitOrderWithdraw.t.sol 665ms (unchanged)
63
+ test/SwapWithLimitOrders.t.sol 88ms (unchanged)
64
+ test/SwapWithLimitOrdersRouter.t.sol 626ms (unchanged)
65
+ test/unit/LimitOrderBitmapUnit.t.sol 80ms (unchanged)
66
+ test/unit/LimitOrderCreateUnit.t.sol 193ms (unchanged)
67
+ test/unit/SwapLimitOrdersUnit.t.sol 601ms (unchanged)
68
+ test/unit/SwapLimitOrdersValidation.t.sol 228ms (unchanged)
69
+ test/unit/SwapWithLimitOrdersUnit.t.sol 63ms (unchanged)
70
+ test/utils/BaseTest.sol 593ms (unchanged)
71
+ test/utils/MockWETH.sol 34ms (unchanged)
72
+ test/utils/TestableZoraLimitOrderBook.sol 41ms (unchanged)
72
73
  CLI Building entry: package/index.ts
73
74
  CLI Using tsconfig: tsconfig.json
74
75
  CLI tsup v8.4.0
@@ -77,9 +78,9 @@ test/utils/TestableZoraLimitOrderBook.sol 37ms (unchanged)
77
78
  CLI Cleaning output folder
78
79
  CJS Build start
79
80
  ESM Build start
80
- ESM dist/index.js 20.36 KB
81
- ESM dist/index.js.map 36.51 KB
82
- ESM ⚡️ Build success in 34ms
83
- CJS dist/index.cjs 21.52 KB
84
- CJS dist/index.cjs.map 36.63 KB
85
- CJS ⚡️ Build success in 38ms
81
+ CJS dist/index.cjs 25.65 KB
82
+ CJS dist/index.cjs.map 44.14 KB
83
+ CJS ⚡️ Build success in 35ms
84
+ ESM dist/index.js 24.48 KB
85
+ ESM dist/index.js.map 44.03 KB
86
+ ESM ⚡️ Build success in 35ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,78 @@
1
1
  # @zoralabs/limit-orders
2
2
 
3
+ ## 0.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - bb2c2b76: Replace AccessManager with PermittedCallers + Ownable2Step for access control in ZoraLimitOrderBook and SwapWithLimitOrders contracts.
8
+
9
+ - Remove AccessManager and SimpleAccessManaged pattern
10
+ - Use OpenZeppelin Ownable2Step for two-step ownership transfer
11
+ - Add `permittedCallers` mapping to gate `create()` access (public by default, owner can restrict)
12
+ - Add `isPermittedCaller()` getter and `setPermittedCallers()` batch setter functions
13
+ - Owner (multisig) retains access to `setMaxFillCount()` and `setLimitOrderConfig()` functions
14
+
15
+ ## 0.2.1
16
+
17
+ ### Patch Changes
18
+
19
+ - dd012477: Add swap price data fields to SwapWithLimitOrdersExecuted event. The event now includes actual swap amounts (amount0 and amount1) and final sqrt price (sqrtPriceX96), while removing the redundant delta field. This breaking change provides more detailed swap information for indexers and frontends to track swaps with limit orders without requiring additional RPC calls.
20
+ - 517d3f74: Fix security vulnerability that allowed withdrawal of fillable limit orders. When a limit order becomes fillable due to market price crossing the limit price, users are now prevented from withdrawing the order and must execute it instead. This enforces proper market behavior and prevents users from backing out of orders that should be filled based on current market conditions.
21
+ - 0b183d5e: Improve payout swap path validation in limit order fulfillment. The `_resolvePayoutPath` function now validates that multi-hop swap paths from coins have their first hop matching the expected payout currency. If validation fails, the system automatically falls back to constructing a simple single-hop path, ensuring correct payouts regardless of the coin's swap path configuration.
22
+ - e84a6902: Fix CEI violation in limit order filling by moving order removal before external liquidity calls to prevent potential reentrancy issues
23
+ - 17bf2b5e: Fix limit order fill direction to derive from actual tick movement
24
+
25
+ Fixed limit order filling in `ZoraV4CoinHook` by deriving the fill direction from actual tick movement instead of using the swap direction parameter. The hook now only attempts to fill limit orders when there's an actual tick change, and determines the currency direction based on the comparison between before and after swap ticks. This ensures orders are filled correctly regardless of swap direction.
26
+
27
+ - 928b4f65: Fix limit order execution logic for correct tick queue placement
28
+
29
+ Fixed critical bug where limit orders were being enqueued at incorrect ticks, preventing proper execution. Currency0 orders now correctly execute when price rises to the upper tick, and Currency1 orders execute when price falls to the lower tick.
30
+
31
+ - 3d0bb73c: Fix router-based limit order fills to use correct currency direction
32
+
33
+ Fixed bug in SwapWithLimitOrders where router fallback incorrectly inverted the currency direction parameter when calling `_fillOrders`. This caused orders to be skipped when the hook doesn't support limit order fills. The router now correctly passes `isCoinCurrency0` instead of `!isCoinCurrency0`, ensuring fills occur in the proper direction.
34
+
35
+ - a61e0250: Remove duplicate validateOrderInputs call in handleCreateCallback
36
+
37
+ Eliminates redundant validation that was occurring in both \_prepareCreateData and handleCreateCallback functions, reducing gas costs while maintaining input validation security.
38
+
39
+ - 14f1314a: Fix tick misalignment in minAway calculation
40
+
41
+ Align baseTick to tick spacing before calculating minAway in \_tickForMultiple(). This prevents order creation from reverting when the current pool tick is not aligned to the pool's tick spacing.
42
+
43
+ - d2703bab: Fix stack too deep compilation error with internal refactoring of limit order creation.
44
+ - 851ca567: Fix router to fill pre-existing limit orders even when no new orders are created in the current swap
45
+
46
+ Previously, the router would skip filling crossed limit orders if `orders.length == 0` (no new orders created in current transaction). This prevented legitimate fills of pre-existing orders that were crossed by the swap. The fix removes this incorrect condition, allowing the router to properly fill any orders crossed during the swap, regardless of whether new orders were also created.
47
+
48
+ - 4ce5e4b6: Fix maxFillCount bounds checking to always cap it at the default max fill count, event if a higher value is passed.
49
+ - 9486742f: Rename liqDelta to callerDelta for clearer naming fixes #19
50
+ - 2cb9cb30: Remove fixed MIN_LIMIT_ORDER_SIZE threshold that made many tokens unusable. Limit orders now accept any positive amount instead of requiring at least 1e18 tokens, fixing compatibility issues with tokens using different decimal configurations.
51
+ - eec53af3: Remove unnecessary Permit2Payments inheritance and use direct PERMIT2 immutable reference instead. This simplifies the contract structure by eliminating unused inherited functions while maintaining identical functionality.
52
+ - 83726a0e: Remove unused settle negative deltas logic
53
+
54
+ - Remove redundant `_settleNegativeDeltas` function that was never executed
55
+ - Simplify limit order closure logic by removing unnecessary delta settlement
56
+
57
+ - 0a104aa2: Fix potential hash collision in order ID generation
58
+
59
+ Changed order ID derivation from `abi.encodePacked` to `abi.encode` to prevent potential hash collisions and ensure consistent hashing behavior. This security fix addresses audit finding MKT-47.
60
+
61
+ - b718117b: Fix limit order fulfillment to use correct currency when resolving payout paths
62
+
63
+ Limit order fulfillment now correctly consults the output currency's payout path configuration instead of the input currency's configuration. This ensures orders receive payouts based on the token being purchased rather than the token being sold, preventing potential currency mismatches when both tokens in a pair have different custom payout paths configured.
64
+
65
+ - d6323749: Simplify limit order filling logic by deriving fill direction from tick movement. The system now automatically determines the correct currency direction based on tick changes (increasing tick = currency0, decreasing tick = currency1) instead of using complex tick sorting logic. This fix resolves issues where limit orders would revert when ticks were in unexpected order.
66
+ - 2b054307: Fix limit order payout handling for dual positive deltas. Previously, when limit order positions accumulated fees in both tokens (dual positive deltas), the payout would revert with a `CurrencyNotSettled` error because only one currency was withdrawn from the pool manager. The fix swaps the non-payout currency to the payout currency and pays out the combined amount, properly settling both deltas.
67
+ - 05579fbc: Refetch pool tick before filling each order to ensure accurate tick validation
68
+
69
+ Improved the limit order filling logic to prevent orders from being filled with stale tick data. The fix adds a current tick refresh before checking if an order has crossed the current tick price during the execution loop. This ensures that orders are only filled when they have actually crossed the current tick price, preventing incorrect fills due to price movements during the fill operation.
70
+
71
+ - 5303b406: Fix native ETH settlement to prevent potential DoS by synchronizing pool manager state before settlement. This ensures accurate ETH balance tracking and prevents transaction failures when processing limit orders with native ETH.
72
+ - 16b3146c: Add WETH support for native ETH payouts in limit orders. When limit orders are filled or withdrawn with native ETH as the payout currency, the system now automatically wraps ETH into WETH before sending to recipients. This ensures compatibility with wallets and smart contracts that cannot receive native ETH directly, preventing transaction failures.
73
+
74
+ **Breaking Change**: The `ZoraLimitOrderBook` constructor now requires an additional `weth` parameter. This affects deployment scripts and deterministic address computation.
75
+
3
76
  ## 0.2.0
4
77
 
5
78
  ### Minor Changes
@@ -0,0 +1,27 @@
1
+ [
2
+ {
3
+ "type": "function",
4
+ "name": "setLimitOrderConfig",
5
+ "inputs": [
6
+ {
7
+ "name": "config",
8
+ "type": "tuple",
9
+ "internalType": "struct LimitOrderConfig",
10
+ "components": [
11
+ {
12
+ "name": "multiples",
13
+ "type": "uint256[]",
14
+ "internalType": "uint256[]"
15
+ },
16
+ {
17
+ "name": "percentages",
18
+ "type": "uint256[]",
19
+ "internalType": "uint256[]"
20
+ }
21
+ ]
22
+ }
23
+ ],
24
+ "outputs": [],
25
+ "stateMutability": "nonpayable"
26
+ }
27
+ ]
@@ -0,0 +1,118 @@
1
+ [
2
+ {
3
+ "type": "function",
4
+ "name": "approve",
5
+ "inputs": [
6
+ {
7
+ "name": "guy",
8
+ "type": "address",
9
+ "internalType": "address"
10
+ },
11
+ {
12
+ "name": "wad",
13
+ "type": "uint256",
14
+ "internalType": "uint256"
15
+ }
16
+ ],
17
+ "outputs": [
18
+ {
19
+ "name": "",
20
+ "type": "bool",
21
+ "internalType": "bool"
22
+ }
23
+ ],
24
+ "stateMutability": "nonpayable"
25
+ },
26
+ {
27
+ "type": "function",
28
+ "name": "balanceOf",
29
+ "inputs": [
30
+ {
31
+ "name": "guy",
32
+ "type": "address",
33
+ "internalType": "address"
34
+ }
35
+ ],
36
+ "outputs": [
37
+ {
38
+ "name": "",
39
+ "type": "uint256",
40
+ "internalType": "uint256"
41
+ }
42
+ ],
43
+ "stateMutability": "view"
44
+ },
45
+ {
46
+ "type": "function",
47
+ "name": "deposit",
48
+ "inputs": [],
49
+ "outputs": [],
50
+ "stateMutability": "payable"
51
+ },
52
+ {
53
+ "type": "function",
54
+ "name": "transfer",
55
+ "inputs": [
56
+ {
57
+ "name": "dst",
58
+ "type": "address",
59
+ "internalType": "address"
60
+ },
61
+ {
62
+ "name": "wad",
63
+ "type": "uint256",
64
+ "internalType": "uint256"
65
+ }
66
+ ],
67
+ "outputs": [
68
+ {
69
+ "name": "",
70
+ "type": "bool",
71
+ "internalType": "bool"
72
+ }
73
+ ],
74
+ "stateMutability": "nonpayable"
75
+ },
76
+ {
77
+ "type": "function",
78
+ "name": "transferFrom",
79
+ "inputs": [
80
+ {
81
+ "name": "src",
82
+ "type": "address",
83
+ "internalType": "address"
84
+ },
85
+ {
86
+ "name": "dst",
87
+ "type": "address",
88
+ "internalType": "address"
89
+ },
90
+ {
91
+ "name": "wad",
92
+ "type": "uint256",
93
+ "internalType": "uint256"
94
+ }
95
+ ],
96
+ "outputs": [
97
+ {
98
+ "name": "",
99
+ "type": "bool",
100
+ "internalType": "bool"
101
+ }
102
+ ],
103
+ "stateMutability": "nonpayable"
104
+ },
105
+ {
106
+ "type": "function",
107
+ "name": "withdraw",
108
+ "inputs": [
109
+ {
110
+ "name": "wad",
111
+ "type": "uint256",
112
+ "internalType": "uint256"
113
+ }
114
+ ],
115
+ "outputs": [],
116
+ "stateMutability": "nonpayable"
117
+ }
118
+ ]
@@ -585,6 +585,11 @@
585
585
  "name": "OrderClosed",
586
586
  "inputs": []
587
587
  },
588
+ {
589
+ "type": "error",
590
+ "name": "OrderFillable",
591
+ "inputs": []
592
+ },
588
593
  {
589
594
  "type": "error",
590
595
  "name": "OrderNotMaker",
@@ -0,0 +1,7 @@
1
+ [
2
+ {
3
+ "type": "error",
4
+ "name": "WethTransferFailed",
5
+ "inputs": []
6
+ }
7
+ ]
@@ -0,0 +1,62 @@
1
+ [
2
+ {
3
+ "type": "function",
4
+ "name": "liquidityForOrder",
5
+ "inputs": [
6
+ {
7
+ "name": "isCurrency0",
8
+ "type": "bool",
9
+ "internalType": "bool"
10
+ },
11
+ {
12
+ "name": "size",
13
+ "type": "uint256",
14
+ "internalType": "uint256"
15
+ },
16
+ {
17
+ "name": "tickLower",
18
+ "type": "int24",
19
+ "internalType": "int24"
20
+ },
21
+ {
22
+ "name": "tickUpper",
23
+ "type": "int24",
24
+ "internalType": "int24"
25
+ }
26
+ ],
27
+ "outputs": [
28
+ {
29
+ "name": "",
30
+ "type": "uint128",
31
+ "internalType": "uint128"
32
+ }
33
+ ],
34
+ "stateMutability": "pure"
35
+ },
36
+ {
37
+ "type": "error",
38
+ "name": "InvalidFillWindow",
39
+ "inputs": [
40
+ {
41
+ "name": "startTick",
42
+ "type": "int24",
43
+ "internalType": "int24"
44
+ },
45
+ {
46
+ "name": "endTick",
47
+ "type": "int24",
48
+ "internalType": "int24"
49
+ },
50
+ {
51
+ "name": "isCurrency0",
52
+ "type": "bool",
53
+ "internalType": "bool"
54
+ }
55
+ ]
56
+ },
57
+ {
58
+ "type": "error",
59
+ "name": "InvalidPoolKey",
60
+ "inputs": []
61
+ }
62
+ ]
@@ -1,7 +1,7 @@
1
1
  [
2
2
  {
3
3
  "type": "function",
4
- "name": "authority",
4
+ "name": "owner",
5
5
  "inputs": [],
6
6
  "outputs": [
7
7
  {
@@ -14,10 +14,17 @@
14
14
  },
15
15
  {
16
16
  "type": "function",
17
- "name": "setAuthority",
17
+ "name": "renounceOwnership",
18
+ "inputs": [],
19
+ "outputs": [],
20
+ "stateMutability": "nonpayable"
21
+ },
22
+ {
23
+ "type": "function",
24
+ "name": "transferOwnership",
18
25
  "inputs": [
19
26
  {
20
- "name": "newAuthority",
27
+ "name": "newOwner",
21
28
  "type": "address",
22
29
  "internalType": "address"
23
30
  }
@@ -27,12 +34,18 @@
27
34
  },
28
35
  {
29
36
  "type": "event",
30
- "name": "AuthorityUpdated",
37
+ "name": "OwnershipTransferred",
31
38
  "inputs": [
32
39
  {
33
- "name": "authority",
40
+ "name": "previousOwner",
34
41
  "type": "address",
35
- "indexed": false,
42
+ "indexed": true,
43
+ "internalType": "address"
44
+ },
45
+ {
46
+ "name": "newOwner",
47
+ "type": "address",
48
+ "indexed": true,
36
49
  "internalType": "address"
37
50
  }
38
51
  ],
@@ -40,10 +53,10 @@
40
53
  },
41
54
  {
42
55
  "type": "error",
43
- "name": "AccessManagedInvalidAuthority",
56
+ "name": "OwnableInvalidOwner",
44
57
  "inputs": [
45
58
  {
46
- "name": "authority",
59
+ "name": "owner",
47
60
  "type": "address",
48
61
  "internalType": "address"
49
62
  }
@@ -51,7 +64,13 @@
51
64
  },
52
65
  {
53
66
  "type": "error",
54
- "name": "AccessManagedUnauthorized",
55
- "inputs": []
67
+ "name": "OwnableUnauthorizedAccount",
68
+ "inputs": [
69
+ {
70
+ "name": "account",
71
+ "type": "address",
72
+ "internalType": "address"
73
+ }
74
+ ]
56
75
  }
57
76
  ]
@@ -0,0 +1,115 @@
1
+ [
2
+ {
3
+ "type": "function",
4
+ "name": "acceptOwnership",
5
+ "inputs": [],
6
+ "outputs": [],
7
+ "stateMutability": "nonpayable"
8
+ },
9
+ {
10
+ "type": "function",
11
+ "name": "owner",
12
+ "inputs": [],
13
+ "outputs": [
14
+ {
15
+ "name": "",
16
+ "type": "address",
17
+ "internalType": "address"
18
+ }
19
+ ],
20
+ "stateMutability": "view"
21
+ },
22
+ {
23
+ "type": "function",
24
+ "name": "pendingOwner",
25
+ "inputs": [],
26
+ "outputs": [
27
+ {
28
+ "name": "",
29
+ "type": "address",
30
+ "internalType": "address"
31
+ }
32
+ ],
33
+ "stateMutability": "view"
34
+ },
35
+ {
36
+ "type": "function",
37
+ "name": "renounceOwnership",
38
+ "inputs": [],
39
+ "outputs": [],
40
+ "stateMutability": "nonpayable"
41
+ },
42
+ {
43
+ "type": "function",
44
+ "name": "transferOwnership",
45
+ "inputs": [
46
+ {
47
+ "name": "newOwner",
48
+ "type": "address",
49
+ "internalType": "address"
50
+ }
51
+ ],
52
+ "outputs": [],
53
+ "stateMutability": "nonpayable"
54
+ },
55
+ {
56
+ "type": "event",
57
+ "name": "OwnershipTransferStarted",
58
+ "inputs": [
59
+ {
60
+ "name": "previousOwner",
61
+ "type": "address",
62
+ "indexed": true,
63
+ "internalType": "address"
64
+ },
65
+ {
66
+ "name": "newOwner",
67
+ "type": "address",
68
+ "indexed": true,
69
+ "internalType": "address"
70
+ }
71
+ ],
72
+ "anonymous": false
73
+ },
74
+ {
75
+ "type": "event",
76
+ "name": "OwnershipTransferred",
77
+ "inputs": [
78
+ {
79
+ "name": "previousOwner",
80
+ "type": "address",
81
+ "indexed": true,
82
+ "internalType": "address"
83
+ },
84
+ {
85
+ "name": "newOwner",
86
+ "type": "address",
87
+ "indexed": true,
88
+ "internalType": "address"
89
+ }
90
+ ],
91
+ "anonymous": false
92
+ },
93
+ {
94
+ "type": "error",
95
+ "name": "OwnableInvalidOwner",
96
+ "inputs": [
97
+ {
98
+ "name": "owner",
99
+ "type": "address",
100
+ "internalType": "address"
101
+ }
102
+ ]
103
+ },
104
+ {
105
+ "type": "error",
106
+ "name": "OwnableUnauthorizedAccount",
107
+ "inputs": [
108
+ {
109
+ "name": "account",
110
+ "type": "address",
111
+ "internalType": "address"
112
+ }
113
+ ]
114
+ }
115
+ ]