@zoralabs/limit-orders 0.2.0
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.
- package/.turbo/turbo-build$colon$js.log +85 -0
- package/AUDIT_NOTES.md +33 -0
- package/AUDIT_RFP.md +408 -0
- package/CHANGELOG.md +25 -0
- package/GAS_COMPARISON_RESULTS.md +194 -0
- package/LICENSE +21 -0
- package/README.md +650 -0
- package/SPEC.md +291 -0
- package/abis/BalanceDeltaLibrary.json +15 -0
- package/abis/BeforeSwapDeltaLibrary.json +15 -0
- package/abis/CurrencyLibrary.json +25 -0
- package/abis/CustomRevert.json +28 -0
- package/abis/IAllowanceTransfer.json +486 -0
- package/abis/IAuthority.json +31 -0
- package/abis/ICoin.json +1074 -0
- package/abis/IDeployedCoinVersionLookup.json +21 -0
- package/abis/IDopplerErrors.json +44 -0
- package/abis/IEIP712.json +15 -0
- package/abis/IERC1363.json +373 -0
- package/abis/IERC165.json +21 -0
- package/abis/IERC20.json +185 -0
- package/abis/IERC20Minimal.json +172 -0
- package/abis/IERC6909Claims.json +288 -0
- package/abis/IERC7572.json +21 -0
- package/abis/IExtsload.json +64 -0
- package/abis/IExttload.json +40 -0
- package/abis/IHasCoinType.json +15 -0
- package/abis/IHasPoolKey.json +42 -0
- package/abis/IHasRewardsRecipients.json +54 -0
- package/abis/IHasSwapPath.json +60 -0
- package/abis/IHasTotalSupplyForPositions.json +15 -0
- package/abis/IHooks.json +789 -0
- package/abis/IMsgSender.json +15 -0
- package/abis/IPoolManager.json +1286 -0
- package/abis/IProtocolFees.json +174 -0
- package/abis/ISupportsLimitOrderFill.json +15 -0
- package/abis/ISwapPathRouter.json +92 -0
- package/abis/ISwapRouter.json +219 -0
- package/abis/IUniswapV3SwapCallback.json +25 -0
- package/abis/IUpgradeableDestinationV4Hook.json +84 -0
- package/abis/IUpgradeableDestinationV4HookWithUpdateableFee.json +95 -0
- package/abis/IUpgradeableV4Hook.json +112 -0
- package/abis/IZoraHookRegistry.json +188 -0
- package/abis/IZoraLimitOrderBook.json +623 -0
- package/abis/IZoraLimitOrderBookCoinsInterface.json +67 -0
- package/abis/IZoraV4CoinHook.json +610 -0
- package/abis/Permit2Payments.json +7 -0
- package/abis/Position.json +7 -0
- package/abis/SafeCast.json +7 -0
- package/abis/SafeCast160.json +7 -0
- package/abis/SafeERC20.json +34 -0
- package/abis/SimpleAccessManaged.json +57 -0
- package/abis/SimpleAccessManager.json +351 -0
- package/abis/SqrtPriceMath.json +22 -0
- package/abis/StateLibrary.json +80 -0
- package/abis/SwapLimitOrders.json +22 -0
- package/abis/SwapWithLimitOrders.json +457 -0
- package/abis/TickBitmap.json +18 -0
- package/abis/TickMath.json +24 -0
- package/abis/V3ToV4SwapLib.json +28 -0
- package/abis/ZoraLimitOrderBook.json +771 -0
- package/cache/solidity-files-cache.json +1 -0
- package/dist/index.cjs +760 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +731 -0
- package/dist/index.js.map +1 -0
- package/dist/wagmiGenerated.d.ts +1012 -0
- package/dist/wagmiGenerated.d.ts.map +1 -0
- package/foundry.toml +29 -0
- package/gas_comparison.py +49 -0
- package/out/BalanceDelta.sol/BalanceDeltaLibrary.json +1 -0
- package/out/BeforeSwapDelta.sol/BeforeSwapDeltaLibrary.json +1 -0
- package/out/BitMath.sol/BitMath.json +1 -0
- package/out/BytesLib.sol/BytesLib.json +1 -0
- package/out/CoinCommon.sol/CoinCommon.json +1 -0
- package/out/CoinConfigurationVersions.sol/CoinConfigurationVersions.json +1 -0
- package/out/CoinConstants.sol/CoinConstants.json +1 -0
- package/out/Context.sol/Context.json +1 -0
- package/out/Currency.sol/CurrencyLibrary.json +1 -0
- package/out/CurrencyReserves.sol/CurrencyReserves.json +1 -0
- package/out/CustomRevert.sol/CustomRevert.json +1 -0
- package/out/DopplerMath.sol/DopplerMath.json +1 -0
- package/out/FixedPoint128.sol/FixedPoint128.json +1 -0
- package/out/FixedPoint96.sol/FixedPoint96.json +1 -0
- package/out/FullMath.sol/FullMath.json +1 -0
- package/out/IAllowanceTransfer.sol/IAllowanceTransfer.json +1 -0
- package/out/IAuthority.sol/IAuthority.json +1 -0
- package/out/ICoin.sol/ICoin.json +1 -0
- package/out/ICoin.sol/IHasCoinType.json +1 -0
- package/out/ICoin.sol/IHasPoolKey.json +1 -0
- package/out/ICoin.sol/IHasSwapPath.json +1 -0
- package/out/ICoin.sol/IHasTotalSupplyForPositions.json +1 -0
- package/out/IDeployedCoinVersionLookup.sol/IDeployedCoinVersionLookup.json +1 -0
- package/out/IDopplerErrors.sol/IDopplerErrors.json +1 -0
- package/out/IEIP712.sol/IEIP712.json +1 -0
- package/out/IERC1363.sol/IERC1363.json +1 -0
- package/out/IERC165.sol/IERC165.json +1 -0
- package/out/IERC20.sol/IERC20.json +1 -0
- package/out/IERC20Minimal.sol/IERC20Minimal.json +1 -0
- package/out/IERC6909Claims.sol/IERC6909Claims.json +1 -0
- package/out/IERC7572.sol/IERC7572.json +1 -0
- package/out/IExtsload.sol/IExtsload.json +1 -0
- package/out/IExttload.sol/IExttload.json +1 -0
- package/out/IHasRewardsRecipients.sol/IHasRewardsRecipients.json +1 -0
- package/out/IHooks.sol/IHooks.json +1 -0
- package/out/IMsgSender.sol/IMsgSender.json +1 -0
- package/out/IPoolManager.sol/IPoolManager.json +1 -0
- package/out/IProtocolFees.sol/IProtocolFees.json +1 -0
- package/out/ISupportsLimitOrderFill.sol/ISupportsLimitOrderFill.json +1 -0
- package/out/ISwapPathRouter.sol/ISwapPathRouter.json +1 -0
- package/out/ISwapRouter.sol/ISwapRouter.json +1 -0
- package/out/IUniswapV3SwapCallback.sol/IUniswapV3SwapCallback.json +1 -0
- package/out/IUpgradeableV4Hook.sol/IUpgradeableDestinationV4Hook.json +1 -0
- package/out/IUpgradeableV4Hook.sol/IUpgradeableDestinationV4HookWithUpdateableFee.json +1 -0
- package/out/IUpgradeableV4Hook.sol/IUpgradeableV4Hook.json +1 -0
- package/out/IZoraHookRegistry.sol/IZoraHookRegistry.json +1 -0
- package/out/IZoraLimitOrderBook.sol/IZoraLimitOrderBook.json +1 -0
- package/out/IZoraLimitOrderBookCoinsInterface.sol/IZoraLimitOrderBookCoinsInterface.json +1 -0
- package/out/IZoraV4CoinHook.sol/IZoraV4CoinHook.json +1 -0
- package/out/LimitOrderBitmap.sol/LimitOrderBitmap.json +1 -0
- package/out/LimitOrderCommon.sol/LimitOrderCommon.json +1 -0
- package/out/LimitOrderCreate.sol/LimitOrderCreate.json +1 -0
- package/out/LimitOrderFill.sol/LimitOrderFill.json +1 -0
- package/out/LimitOrderLiquidity.sol/LimitOrderLiquidity.json +1 -0
- package/out/LimitOrderQueues.sol/LimitOrderQueues.json +1 -0
- package/out/LimitOrderStorage.sol/LimitOrderStorage.json +1 -0
- package/out/LimitOrderTypes.sol/LimitOrderTypes.json +1 -0
- package/out/LimitOrderWithdraw.sol/LimitOrderWithdraw.json +1 -0
- package/out/LiquidityAmounts.sol/LiquidityAmounts.json +1 -0
- package/out/LiquidityMath.sol/LiquidityMath.json +1 -0
- package/out/Lock.sol/Lock.json +1 -0
- package/out/NonzeroDeltaCount.sol/NonzeroDeltaCount.json +1 -0
- package/out/Path.sol/Path.json +1 -0
- package/out/PathKey.sol/PathKeyLibrary.json +1 -0
- package/out/Permit2Payments.sol/Permit2Payments.json +1 -0
- package/out/PoolId.sol/PoolIdLibrary.json +1 -0
- package/out/Position.sol/Position.json +1 -0
- package/out/SafeCast.sol/SafeCast.json +1 -0
- package/out/SafeCast160.sol/SafeCast160.json +1 -0
- package/out/SafeERC20.sol/SafeERC20.json +1 -0
- package/out/SimpleAccessManaged.sol/SimpleAccessManaged.json +1 -0
- package/out/SimpleAccessManager.sol/SimpleAccessManager.json +1 -0
- package/out/SqrtPriceMath.sol/SqrtPriceMath.json +1 -0
- package/out/StateLibrary.sol/StateLibrary.json +1 -0
- package/out/SwapLimitOrders.sol/SwapLimitOrders.json +1 -0
- package/out/SwapWithLimitOrders.sol/SwapWithLimitOrders.json +1 -0
- package/out/TickBitmap.sol/TickBitmap.json +1 -0
- package/out/TickMath.sol/TickMath.json +1 -0
- package/out/TransientSlot.sol/TransientSlot.json +1 -0
- package/out/TransientStateLibrary.sol/TransientStateLibrary.json +1 -0
- package/out/UniV4SwapToCurrency.sol/UniV4SwapToCurrency.json +1 -0
- package/out/UnsafeMath.sol/UnsafeMath.json +1 -0
- package/out/V3ToV4SwapLib.sol/V3ToV4SwapLib.json +1 -0
- package/out/ZoraLimitOrderBook.sol/ZoraLimitOrderBook.json +1 -0
- package/out/build-info/69718f10d1dc37f0.json +1 -0
- package/out/uniswap/BitMath.sol/BitMath.json +1 -0
- package/out/uniswap/CustomRevert.sol/CustomRevert.json +1 -0
- package/out/uniswap/FullMath.sol/FullMath.json +1 -0
- package/out/uniswap/SafeCast.sol/SafeCast.json +1 -0
- package/out/uniswap/TickMath.sol/TickMath.json +1 -0
- package/package/index.ts +1 -0
- package/package/wagmiGenerated.ts +738 -0
- package/package.json +57 -0
- package/remappings.txt +11 -0
- package/src/IZoraLimitOrderBook.sol +195 -0
- package/src/ZoraLimitOrderBook.sol +220 -0
- package/src/access/SimpleAccessManaged.sol +76 -0
- package/src/access/SimpleAccessManager.sol +268 -0
- package/src/libs/LimitOrderBitmap.sol +84 -0
- package/src/libs/LimitOrderCommon.sol +91 -0
- package/src/libs/LimitOrderCreate.sol +277 -0
- package/src/libs/LimitOrderFill.sol +362 -0
- package/src/libs/LimitOrderLiquidity.sol +222 -0
- package/src/libs/LimitOrderQueues.sol +101 -0
- package/src/libs/LimitOrderStorage.sol +34 -0
- package/src/libs/LimitOrderTypes.sol +41 -0
- package/src/libs/LimitOrderWithdraw.sol +100 -0
- package/src/libs/Permit2Payments.sol +41 -0
- package/src/libs/SwapLimitOrders.sol +209 -0
- package/src/router/SwapWithLimitOrders.sol +454 -0
- package/test/LimitOrderAccessControl.t.sol +461 -0
- package/test/LimitOrderBitmap.t.sol +194 -0
- package/test/LimitOrderCreate.t.sol +348 -0
- package/test/LimitOrderFill.t.sol +1005 -0
- package/test/LimitOrderLibraries.t.sol +354 -0
- package/test/LimitOrderLiquidityPayouts.t.sol +333 -0
- package/test/LimitOrderV4Pools.t.sol +157 -0
- package/test/LimitOrderWithdraw.t.sol +653 -0
- package/test/SimpleAccessManager.t.sol +420 -0
- package/test/SwapWithLimitOrders.t.sol +107 -0
- package/test/SwapWithLimitOrdersRouter.t.sol +1073 -0
- package/test/gas/LimitOrderFillGas.t.sol +1008 -0
- package/test/gas/LimitOrderSwapGas.t.sol +403 -0
- package/test/gas/logs/gas_benchmarks_fill_20251201.log +30 -0
- package/test/gas/logs/gas_benchmarks_swap_20251201.log +27 -0
- package/test/unit/LimitOrderBitmapUnit.t.sol +276 -0
- package/test/unit/LimitOrderCreateUnit.t.sol +358 -0
- package/test/unit/SwapLimitOrdersUnit.t.sol +672 -0
- package/test/unit/SwapLimitOrdersValidation.t.sol +423 -0
- package/test/unit/SwapWithLimitOrdersUnit.t.sol +321 -0
- package/test/utils/BaseTest.sol +793 -0
- package/test/utils/TestableZoraLimitOrderBook.sol +54 -0
- package/tsconfig.build.json +10 -0
- package/tsconfig.json +9 -0
- package/tsup.config.ts +11 -0
- package/wagmi.config.ts +18 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# Gas Comparison Results: Current Swaps vs Swaps w/ Internal Swap Detection
|
|
2
|
+
|
|
3
|
+
**Date:** 2025-12-01
|
|
4
|
+
**Branches Compared:**
|
|
5
|
+
- **Baseline (Branch 1):** `rohan/gas-benchmarking` - Gas benchmarking infrastructure without optimization
|
|
6
|
+
- **Optimized (Branch 2):** `rohan/internal-swap-optimization` - With `_isInternalSwap` hook optimization
|
|
7
|
+
|
|
8
|
+
## Terminology: Understanding "Hops"
|
|
9
|
+
|
|
10
|
+
The term "hops" appears in two different contexts in these benchmarks:
|
|
11
|
+
|
|
12
|
+
### Payout Conversion Hops (Backend Fill Operations)
|
|
13
|
+
|
|
14
|
+
When the backend calls `limitOrderBook.fill()` to execute orders, **"hops"** refers to how order payouts are converted:
|
|
15
|
+
|
|
16
|
+
**0/1 Payout-Hop (Direct)**
|
|
17
|
+
- Order fill pays out directly in the desired currency without conversion
|
|
18
|
+
- Example: Order on creatorCoin pool → payout in ZORA (other side of the pair)
|
|
19
|
+
- Minimal internal swaps for payout
|
|
20
|
+
|
|
21
|
+
**2 Payout-Hops (Conversion Required)**
|
|
22
|
+
- Order fill requires payout conversion through intermediate pools
|
|
23
|
+
- Example: Order on contentCoin pool → payout path: contentCoin → creatorCoin → ZORA
|
|
24
|
+
- Each conversion hop triggers hook execution (where our optimization saves gas!)
|
|
25
|
+
|
|
26
|
+
### User Swap Routing + Payout Conversion (User Autofill Operations)
|
|
27
|
+
|
|
28
|
+
When users initiate swaps that cross limit orders, there are **TWO sources of internal swaps**:
|
|
29
|
+
|
|
30
|
+
1. **User's multi-hop routing**: The path users take to reach the pool (e.g., ZORA → creator → content)
|
|
31
|
+
2. **Order payout conversion**: Internal swaps to convert filled order payouts back to desired currency
|
|
32
|
+
|
|
33
|
+
Both routing hops and payout conversion hops trigger the hook, so the optimization provides compounding gas savings. The "User Swap + Autofill Operations" tests measure the total gas including both types of internal swaps.
|
|
34
|
+
|
|
35
|
+
## Executive Summary
|
|
36
|
+
|
|
37
|
+
The `_isInternalSwap` optimization provides **18-62% gas savings** across all test scenarios by detecting internal/recursive swaps and skipping unnecessary fee collection logic in the ZoraV4CoinHook.
|
|
38
|
+
|
|
39
|
+
## Detailed Comparison
|
|
40
|
+
|
|
41
|
+
### Backend Fill Operations
|
|
42
|
+
|
|
43
|
+
Backend services call `limitOrderBook.fill()` to execute existing limit orders. These tests measure the gas cost of filling N orders in a single transaction.
|
|
44
|
+
|
|
45
|
+
| Orders Filled | Baseline Gas | Optimized Gas | Gas Saved | % Improvement |
|
|
46
|
+
|---------------|--------------|---------------|-----------|---------------|
|
|
47
|
+
| 1 order (0/1 payout-hop) | 3,982,669 | 3,260,509 | 722,160 | 18.1% |
|
|
48
|
+
| 1 order (2 payout-hops) | 7,496,038 | 6,144,078 | 1,351,960 | 18.0% |
|
|
49
|
+
| 5 orders (2 payout-hops) | 11,682,458 | 7,792,758 | 3,889,700 | 33.3% |
|
|
50
|
+
| 10 orders (2 payout-hops) | 13,940,712 | 9,872,756 | 4,067,956 | 29.2% |
|
|
51
|
+
| 50 orders | 59,311,104 | 26,598,104 | 32,713,000 | 55.2% |
|
|
52
|
+
| 100 orders | 111,074,619 | 47,656,019 | 63,418,600 | 57.1% |
|
|
53
|
+
| 150 orders | 164,396,574 | 68,957,450 | 95,439,124 | 58.1% |
|
|
54
|
+
|
|
55
|
+
### User Swap + Autofill Operations
|
|
56
|
+
|
|
57
|
+
Users initiate swaps that automatically trigger order fills as a side effect. These tests measure the total gas cost when a user swap crosses multiple orders.
|
|
58
|
+
|
|
59
|
+
| Orders Filled | Baseline Gas | Optimized Gas | Gas Saved | % Improvement |
|
|
60
|
+
|---------------|--------------|---------------|-----------|---------------|
|
|
61
|
+
| 10 orders | 15,204,181 | 8,700,941 | 6,503,240 | 42.8% |
|
|
62
|
+
| 25 orders | 25,052,062 | 14,201,062 | 10,851,000 | 43.3% |
|
|
63
|
+
| 40 orders | 34,638,545 | 19,625,345 | 15,013,200 | 43.4% |
|
|
64
|
+
| 50 orders | 40,982,404 | 23,168,604 | 17,813,800 | 43.5% |
|
|
65
|
+
| 75 orders | 60,183,892 | 32,899,292 | 27,284,600 | 45.3% |
|
|
66
|
+
| 100 orders | 112,356,369 | 42,545,248 | 69,811,121 | 62.1% |
|
|
67
|
+
|
|
68
|
+
### Specialized Scenarios
|
|
69
|
+
|
|
70
|
+
| Test Scenario | Baseline Gas | Optimized Gas | Gas Saved | % Improvement |
|
|
71
|
+
|--------------|--------------|---------------|-----------|---------------|
|
|
72
|
+
| Empty fill | 209,668 | 143,268 | 66,400 | 31.7% |
|
|
73
|
+
| Large swap w/ fee conversion | 2,454,346 | 2,008,446 | 445,900 | 18.2% |
|
|
74
|
+
| Max fillcount (25) | 22,842,877 | 16,128,877 | 6,714,000 | 29.4% |
|
|
75
|
+
| Mixed sizes | 11,682,945 | 7,793,945 | 3,889,000 | 33.3% |
|
|
76
|
+
| Same tick | 11,103,207 | 7,444,207 | 3,659,000 | 33.0% |
|
|
77
|
+
| User swap 1-hop autofill (40) | 23,377,551 | 16,707,751 | 6,669,800 | 28.5% |
|
|
78
|
+
| User swap 1-hop autofill (50) | 29,066,384 | 20,375,584 | 8,690,800 | 29.9% |
|
|
79
|
+
|
|
80
|
+
## Key Insights
|
|
81
|
+
|
|
82
|
+
### Optimization Impact by Scale
|
|
83
|
+
|
|
84
|
+
1. **Small Backend Fills (18-33% savings)**
|
|
85
|
+
- Single order fills: 18% improvements
|
|
86
|
+
- 5-order batches: 33% savings
|
|
87
|
+
- 10-order batches: 29% savings
|
|
88
|
+
|
|
89
|
+
2. **Medium Scale (43-55% savings)**
|
|
90
|
+
- User autofill operations (10-75 orders): consistently save 43-45%
|
|
91
|
+
- Backend fills (50 orders): achieve 55% savings
|
|
92
|
+
|
|
93
|
+
3. **Large Scale (57-62% savings)**
|
|
94
|
+
- 100-order user swaps: 62.1% improvement (69.8M gas saved!)
|
|
95
|
+
- 100-order backend fills: 57.1% improvement (63.4M gas saved)
|
|
96
|
+
- 150-order backend fills: 58.1% improvement (95.4M gas saved)
|
|
97
|
+
|
|
98
|
+
### Why
|
|
99
|
+
|
|
100
|
+
The optimization becomes more impactful at scale because:
|
|
101
|
+
- Each order triggers multiple internal swaps for fee conversions
|
|
102
|
+
- The baseline performs full fee collection logic for every internal swap
|
|
103
|
+
- The optimization skips all this logic, multiplying savings across orders
|
|
104
|
+
- At 100+ orders, the cumulative effect is massive (60-62% reduction)
|
|
105
|
+
|
|
106
|
+
### Technical Implementation
|
|
107
|
+
|
|
108
|
+
The optimization adds `_isInternalSwap()` detection to ZoraV4CoinHook:
|
|
109
|
+
|
|
110
|
+
```solidity
|
|
111
|
+
function _isInternalSwap(address sender) internal view returns (bool) {
|
|
112
|
+
return sender == address(this) ||
|
|
113
|
+
sender == address(zoraLimitOrderBook) ||
|
|
114
|
+
zoraHookRegistry.isRegisteredHook(sender);
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Early returns in `_beforeSwap()` and `_afterSwap()` when internal swaps are detected:
|
|
119
|
+
|
|
120
|
+
```solidity
|
|
121
|
+
function _beforeSwap(...) internal virtual override returns (...) {
|
|
122
|
+
if (_isInternalSwap(sender)) {
|
|
123
|
+
return (BaseHook.beforeSwap.selector, BeforeSwapDelta.wrap(0), 0);
|
|
124
|
+
}
|
|
125
|
+
// ... rest of fee collection logic
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Cost Impact Examples
|
|
130
|
+
|
|
131
|
+
Using 100-order user swap scenario (69.8M gas saved) at $3,000/ETH:
|
|
132
|
+
|
|
133
|
+
| Base Fee | Baseline Cost | Optimized Cost | $ Saved |
|
|
134
|
+
|----------|---------------|----------------|---------|
|
|
135
|
+
| 0.0001 gwei (100,000 wei) | $0.0337 | $0.0128 | $0.0209 |
|
|
136
|
+
| 0.001 gwei (1,000,000 wei) | $0.337 | $0.128 | $0.209 |
|
|
137
|
+
| 0.01 gwei (10,000,000 wei) | $3.37 | $1.28 | $2.09 |
|
|
138
|
+
|
|
139
|
+
## Conclusion
|
|
140
|
+
|
|
141
|
+
The `_isInternalSwap` optimization provides substantial gas savings across all scenarios, with the largest impact on high-volume operations. The 18-62% improvement range makes this optimization critical for production deployment, especially for backend fill operations and user-facing autofill scenarios.
|
|
142
|
+
|
|
143
|
+
**Recommendation:** Merge this optimization into production immediately. The gas savings are significant and the implementation is clean with no breaking changes to external interfaces.
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
## Latest Benchmarks (current branch, rerun 2025-12-01)
|
|
147
|
+
|
|
148
|
+
### LimitOrderSwapGas (fork @ block 38,875,958; production router)
|
|
149
|
+
| Scenario | Gas |
|
|
150
|
+
| --- | --- |
|
|
151
|
+
| Hop1 (ZORA → creator) fill5 | **4,204,840** |
|
|
152
|
+
| Hop1 fill10 | **4,671,165** |
|
|
153
|
+
| Hop1 fill25 | **6,008,081** |
|
|
154
|
+
| Hop1 fill50 | **8,317,174** |
|
|
155
|
+
| Hop2 (ZORA → creator → content) fill5 | **7,062,539** |
|
|
156
|
+
| Hop2 fill10 | **7,688,068** |
|
|
157
|
+
| Hop2 fill25 | **9,569,256** |
|
|
158
|
+
| Hop2 fill50 | **12,684,187** |
|
|
159
|
+
| Hop3 (USDC → ZORA → creator) fill0 | **5,504,247** |
|
|
160
|
+
| Hop3 fill5 | **9,673,686** |
|
|
161
|
+
| Hop3 fill10 | **10,299,041** |
|
|
162
|
+
| Hop3 fill25 | **12,179,705** |
|
|
163
|
+
| Hop3 fill50 | **15,293,763** |
|
|
164
|
+
| Hop4 (WETH → USDC → ZORA → creator) fill0 | **5,625,730** |
|
|
165
|
+
| Hop4 fill5 | **9,977,871** |
|
|
166
|
+
| Hop4 fill10 | **10,603,389** |
|
|
167
|
+
| Hop4 fill25 | **12,484,542** |
|
|
168
|
+
| Hop4 fill50 | **15,599,414** |
|
|
169
|
+
|
|
170
|
+
### LimitOrderFillGas (local/anvil)
|
|
171
|
+
| Scenario | Gas |
|
|
172
|
+
| --- | --- |
|
|
173
|
+
| Baseline swap (no orders) | **1,696,598** |
|
|
174
|
+
| Single order (direct payout) | **133,925** |
|
|
175
|
+
| Single order (multihop payout) | **166,591** |
|
|
176
|
+
| Five orders (multihop payout) | **567,240** |
|
|
177
|
+
| Ten orders (multihop payout) | **1,068,298** |
|
|
178
|
+
| Empty fill | **79,723** |
|
|
179
|
+
| Large swap w/ fee conversion | **1,925,776** |
|
|
180
|
+
| Max fillcount (25 orders) | **2,575,596** |
|
|
181
|
+
| User swap autofill 10 orders | **5,899,189** |
|
|
182
|
+
| User swap autofill 25 orders | **8,036,447** |
|
|
183
|
+
| User swap autofill 40 orders | **10,066,795** |
|
|
184
|
+
| User swap autofill 50 orders | **11,369,269** |
|
|
185
|
+
| User swap autofill 75 orders | **14,684,719** |
|
|
186
|
+
| User swap autofill 100 orders | **17,868,828** |
|
|
187
|
+
| User swap autofill 1-hop 40 orders | **5,758,247** |
|
|
188
|
+
| User swap autofill 1-hop 50 orders | **6,685,848** |
|
|
189
|
+
| User swap w/ autofill (multihop) | **5,094,889** |
|
|
190
|
+
| Backend fill 50 orders | **5,096,006** |
|
|
191
|
+
| Backend fill 100 orders | **10,171,297** |
|
|
192
|
+
| Backend fill 150 orders | **15,299,656** |
|
|
193
|
+
| Mixed sizes | **566,754** |
|
|
194
|
+
| Same tick | **549,968** |
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Zora Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|