@zoralabs/coins 0.7.1 → 1.0.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.log +106 -84
- package/CHANGELOG.md +68 -0
- package/abis/BadImpl.json +15 -0
- package/abis/BalanceDeltaLibrary.json +15 -0
- package/abis/BaseCoin.json +1350 -0
- package/abis/BaseCoinDeployHook.json +78 -0
- package/abis/BaseHook.json +897 -0
- package/abis/BaseTest.json +60 -91
- package/abis/BeforeSwapDeltaLibrary.json +15 -0
- package/abis/BuySupplyWithSwapRouterHook.json +126 -0
- package/abis/Coin.json +214 -150
- package/abis/CoinConstants.json +65 -0
- package/abis/CoinDopplerMultiCurve.json +38 -0
- package/abis/CoinRewardsV4.json +54 -0
- package/abis/CoinTest.json +66 -111
- package/abis/CoinUniV4Test.json +1053 -0
- package/abis/CoinV4.json +1687 -0
- package/abis/CurrencyLibrary.json +25 -0
- package/abis/DeployHooks.json +9 -0
- package/abis/DeployScript.json +47 -0
- package/abis/DeployedCoinVersionLookup.json +21 -0
- package/abis/DeployedCoinVersionLookupTest.json +716 -0
- package/abis/DifferentNamespaceVersionLookup.json +39 -0
- package/abis/DopplerUniswapV3Test.json +62 -184
- package/abis/ERC20.json +310 -0
- package/abis/FactoryTest.json +98 -98
- package/abis/FakeHookNoInterface.json +21 -0
- package/abis/FeeEstimatorHook.json +1528 -0
- package/abis/Hooks.json +28 -0
- package/abis/HooksDeployment.json +23 -0
- package/abis/HooksTest.json +698 -0
- package/abis/IAllowanceTransfer.json +486 -0
- package/abis/ICoin.json +62 -69
- package/abis/ICoinDeployHook.json +31 -0
- package/abis/ICoinV3.json +879 -0
- package/abis/ICoinV4.json +915 -0
- package/abis/IContractMetadata.json +28 -0
- package/abis/IDeployedCoinVersionLookup.json +21 -0
- package/abis/IEIP712.json +15 -0
- package/abis/IEIP712_v4.json +15 -0
- package/abis/IERC20Minimal.json +172 -0
- package/abis/IERC6909Claims.json +288 -0
- package/abis/IERC721.json +36 -36
- package/abis/IERC721Permit_v4.json +88 -0
- package/abis/IExtsload.json +64 -0
- package/abis/IExttload.json +40 -0
- package/abis/IHasAfterCoinDeploy.json +31 -0
- package/abis/IHasContractName.json +15 -0
- package/abis/IHasPoolKey.json +42 -0
- package/abis/IHasRewardsRecipients.json +54 -0
- package/abis/IHasSwapPath.json +60 -0
- package/abis/IHooks.json +789 -0
- package/abis/IImmutableState.json +15 -0
- package/abis/IMsgSender.json +15 -0
- package/abis/IMulticall_v4.json +21 -0
- package/abis/INotifier.json +187 -0
- package/abis/IPermit2.json +865 -0
- package/abis/IPermit2Forwarder.json +138 -0
- package/abis/IPoolConfigEncoding.json +46 -0
- package/abis/IPoolInitializer_v4.json +53 -0
- package/abis/IPoolManager.json +1286 -0
- package/abis/IPositionManager.json +712 -0
- package/abis/IProtocolFees.json +174 -0
- package/abis/ISignatureTransfer.json +394 -0
- package/abis/ISubscriber.json +89 -0
- package/abis/ISwapPathRouter.json +92 -0
- package/abis/ISwapRouter.json +82 -0
- package/abis/IUniversalRouter.json +61 -0
- package/abis/IUnlockCallback.json +21 -0
- package/abis/IUnorderedNonce.json +44 -0
- package/abis/IV4Quoter.json +310 -0
- package/abis/IV4Router.json +47 -0
- package/abis/IZoraFactory.json +328 -4
- package/abis/IZoraV4CoinHook.json +427 -0
- package/abis/ImmutableState.json +36 -0
- package/abis/LPFeeLibrary.json +65 -0
- package/abis/MockERC20.json +21 -0
- package/abis/MultiOwnableTest.json +60 -91
- package/abis/{CoinConfigurationVersions.json → Position.json} +1 -1
- package/abis/PrintUpgradeCommand.json +9 -0
- package/abis/ProxyShim.json +24 -0
- package/abis/Simulate.json +0 -91
- package/abis/StateLibrary.json +80 -0
- package/abis/TestDeployedCoinVersionLookupImplementation.json +39 -0
- package/abis/TestV4Swap.json +9 -0
- package/abis/{CoinSetup.json → UniV3BuySell.json} +5 -0
- package/abis/UniV3Errors.json +32 -0
- package/abis/UpgradeCoinImpl.json +47 -0
- package/abis/UpgradeFactoryImpl.json +9 -0
- package/abis/UpgradesTest.json +671 -0
- package/abis/Vm.json +1482 -111
- package/abis/VmSafe.json +856 -32
- package/abis/ZoraFactoryImpl.json +450 -1
- package/abis/ZoraV4CoinHook.json +1439 -0
- package/addresses/8453.json +8 -3
- package/addresses/84532.json +8 -3
- package/dist/index.cjs +1998 -184
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1989 -178
- package/dist/index.js.map +1 -1
- package/dist/wagmiGenerated.d.ts +2852 -688
- package/dist/wagmiGenerated.d.ts.map +1 -1
- package/package/wagmiGenerated.ts +1992 -173
- package/package.json +7 -2
- package/remappings.txt +6 -1
- package/script/CoinsDeployerBase.sol +105 -10
- package/script/DeployDevFactory.s.sol +21 -0
- package/script/DeployHooks.s.sol +22 -0
- package/script/PrintUpgradeCommand.s.sol +13 -0
- package/script/Simulate.s.sol +4 -12
- package/script/TestBackingCoinSwap.s.sol +146 -0
- package/script/TestV4Swap.s.sol +136 -0
- package/script/UpgradeCoinImpl.sol +2 -2
- package/script/UpgradeFactoryImpl.s.sol +23 -0
- package/src/BaseCoin.sol +176 -0
- package/src/Coin.sol +93 -515
- package/src/CoinV4.sol +121 -0
- package/src/ZoraFactoryImpl.sol +257 -57
- package/src/hooks/ZoraV4CoinHook.sol +195 -0
- package/src/hooks/deployment/BaseCoinDeployHook.sol +62 -0
- package/src/hooks/deployment/BuySupplyWithSwapRouterHook.sol +80 -0
- package/src/interfaces/ICoin.sol +35 -39
- package/src/interfaces/ICoinDeployHook.sol +8 -0
- package/src/interfaces/ICoinV3.sol +71 -0
- package/src/interfaces/ICoinV4.sol +69 -0
- package/src/interfaces/IDeployedCoinVersionLookup.sol +11 -0
- package/src/interfaces/IMsgSender.sol +9 -0
- package/src/interfaces/IPoolConfigEncoding.sol +14 -0
- package/src/interfaces/ISwapPathRouter.sol +14 -0
- package/src/interfaces/ISwapRouter.sol +1 -35
- package/src/interfaces/IZoraFactory.sol +97 -7
- package/src/interfaces/IZoraV4CoinHook.sol +116 -0
- package/src/libs/CoinCommon.sol +15 -0
- package/src/libs/CoinConfigurationVersions.sol +116 -1
- package/src/{utils → libs}/CoinConstants.sol +11 -6
- package/src/libs/CoinDopplerMultiCurve.sol +134 -0
- package/src/libs/CoinDopplerUniV3.sol +19 -171
- package/src/libs/CoinRewards.sol +195 -0
- package/src/libs/CoinRewardsV4.sol +180 -0
- package/src/libs/CoinSetup.sol +40 -20
- package/src/libs/CoinSetupV3.sol +50 -0
- package/src/libs/DopplerMath.sol +156 -0
- package/src/libs/HooksDeployment.sol +84 -0
- package/src/libs/MarketConstants.sol +4 -0
- package/src/libs/PoolStateReader.sol +22 -0
- package/src/libs/UniV3BuySell.sol +231 -0
- package/src/libs/UniV3Errors.sol +11 -0
- package/src/libs/UniV4SwapHelper.sol +65 -0
- package/src/libs/UniV4SwapToCurrency.sol +109 -0
- package/src/libs/V4Liquidity.sol +129 -0
- package/src/types/PoolConfiguration.sol +15 -0
- package/src/utils/DeployedCoinVersionLookup.sol +52 -0
- package/src/version/ContractVersionBase.sol +1 -1
- package/test/Coin.t.sol +94 -101
- package/test/CoinDopplerUniV3.t.sol +35 -184
- package/test/CoinUniV4.t.sol +752 -0
- package/test/DeploymentHooks.t.sol +270 -0
- package/test/Factory.t.sol +84 -50
- package/test/MultiOwnable.t.sol +6 -3
- package/test/Upgrades.t.sol +68 -0
- package/test/mocks/MockERC20.sol +12 -0
- package/test/utils/BaseTest.sol +124 -59
- package/test/utils/DeployedCoinVersionLookup.t.sol +127 -0
- package/test/utils/FeeEstimatorHook.sol +84 -0
- package/test/utils/ProxyShim.sol +17 -0
- package/wagmi.config.ts +10 -9
- package/src/libs/CoinLegacy.sol +0 -48
|
@@ -5,29 +5,14 @@ import {CoinConfigurationVersions} from "../src/libs/CoinConfigurationVersions.s
|
|
|
5
5
|
import {MarketConstants} from "../src/libs/MarketConstants.sol";
|
|
6
6
|
import {BaseTest} from "./utils/BaseTest.sol";
|
|
7
7
|
import {Coin} from "../src/Coin.sol";
|
|
8
|
+
import {CoinConstants} from "../src/libs/CoinConstants.sol";
|
|
8
9
|
import {IUniswapV3Pool} from "../src/interfaces/IUniswapV3Pool.sol";
|
|
9
10
|
import {LpPosition} from "../src/types/LpPosition.sol";
|
|
10
11
|
import {IDopplerErrors} from "../src/interfaces/IDopplerErrors.sol";
|
|
11
|
-
import {CoinDopplerUniV3} from "../src/libs/CoinDopplerUniV3.sol";
|
|
12
|
+
import {DopplerMath, CoinDopplerUniV3} from "../src/libs/CoinDopplerUniV3.sol";
|
|
12
13
|
import {TickMath} from "../src/utils/uniswap/TickMath.sol";
|
|
13
14
|
|
|
14
15
|
contract DopplerUniswapV3Test is BaseTest {
|
|
15
|
-
int24 internal constant DEFAULT_DISCOVERY_TICK_LOWER = -777000;
|
|
16
|
-
int24 internal constant DEFAULT_DISCOVERY_TICK_UPPER = 222000;
|
|
17
|
-
uint16 internal constant DEFAULT_NUM_DISCOVERY_POSITIONS = 10; // will be 11 total with tail position
|
|
18
|
-
uint256 internal constant DEFAULT_DISCOVERY_SUPPLY_SHARE = 0.495e18; // half of the 990m total pool supply
|
|
19
|
-
|
|
20
|
-
function _generatePoolConfig(
|
|
21
|
-
uint8 version_,
|
|
22
|
-
address currency_,
|
|
23
|
-
int24 tickLower_,
|
|
24
|
-
int24 tickUpper_,
|
|
25
|
-
uint16 numDiscoveryPositions_,
|
|
26
|
-
uint256 maxDiscoverySupplyShare_
|
|
27
|
-
) internal pure returns (bytes memory) {
|
|
28
|
-
return abi.encode(version_, currency_, tickLower_, tickUpper_, numDiscoveryPositions_, maxDiscoverySupplyShare_);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
16
|
function _deployCoin(bytes memory poolConfig_) internal {
|
|
32
17
|
vm.prank(users.creator);
|
|
33
18
|
(address coinAddress, ) = factory.deploy(
|
|
@@ -52,134 +37,7 @@ contract DopplerUniswapV3Test is BaseTest {
|
|
|
52
37
|
super.setUp();
|
|
53
38
|
}
|
|
54
39
|
|
|
55
|
-
function
|
|
56
|
-
bytes memory poolConfig = _generatePoolConfig(
|
|
57
|
-
CoinConfigurationVersions.LEGACY_POOL_VERSION,
|
|
58
|
-
address(weth),
|
|
59
|
-
MarketConstants.LP_TICK_LOWER_WETH,
|
|
60
|
-
0,
|
|
61
|
-
1,
|
|
62
|
-
0
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
_deployCoin(poolConfig);
|
|
66
|
-
|
|
67
|
-
assertEq(coin.currency(), address(weth), "currency");
|
|
68
|
-
assertEq(coin.totalSupply(), 1_000_000_000e18, "totalSupply");
|
|
69
|
-
assertEq(coin.balanceOf(users.creator), 10_000_000e18, "balanceOf creator");
|
|
70
|
-
assertGt(coin.balanceOf(coin.poolAddress()), 989_999_999e18, "balanceOf pool");
|
|
71
|
-
|
|
72
|
-
(
|
|
73
|
-
address asset,
|
|
74
|
-
address numeraire,
|
|
75
|
-
int24 tickLower,
|
|
76
|
-
int24 tickUpper,
|
|
77
|
-
uint16 numPositions,
|
|
78
|
-
bool isInitialized,
|
|
79
|
-
bool isExited,
|
|
80
|
-
uint256 maxShareToBeSold,
|
|
81
|
-
uint256 totalTokensOnBondingCurve
|
|
82
|
-
) = coin.poolState();
|
|
83
|
-
|
|
84
|
-
assertEq(asset, address(coin));
|
|
85
|
-
assertEq(numeraire, address(weth));
|
|
86
|
-
assertEq(numPositions, 1);
|
|
87
|
-
assertTrue(isInitialized);
|
|
88
|
-
assertFalse(isExited);
|
|
89
|
-
assertEq(maxShareToBeSold, 0);
|
|
90
|
-
assertEq(totalTokensOnBondingCurve, POOL_LAUNCH_SUPPLY);
|
|
91
|
-
|
|
92
|
-
bool isCoinToken0 = address(coin) < address(weth);
|
|
93
|
-
|
|
94
|
-
if (isCoinToken0) {
|
|
95
|
-
assertEq(tickLower, MarketConstants.LP_TICK_LOWER_WETH);
|
|
96
|
-
assertEq(tickUpper, MarketConstants.LP_TICK_UPPER);
|
|
97
|
-
} else {
|
|
98
|
-
assertEq(tickLower, -MarketConstants.LP_TICK_UPPER);
|
|
99
|
-
assertEq(tickUpper, -MarketConstants.LP_TICK_LOWER_WETH);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function test_invalid_tick_range() public {
|
|
104
|
-
bytes memory poolConfig = _generatePoolConfig(CoinConfigurationVersions.LEGACY_POOL_VERSION, address(weth), -100, 100, 100, 0.5e18);
|
|
105
|
-
|
|
106
|
-
vm.expectRevert();
|
|
107
|
-
factory.deploy(users.creator, _getDefaultOwners(), "https://test.com", "Testcoin", "TEST", poolConfig, users.platformReferrer, 0);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function test_inverted_tick_range_revert() public {
|
|
111
|
-
// These tick ranges are flipped
|
|
112
|
-
bytes memory poolConfig = _generatePoolConfig(CoinConfigurationVersions.LEGACY_POOL_VERSION, address(weth), 10000, -10000, 100, 0.5e18);
|
|
113
|
-
|
|
114
|
-
vm.expectRevert(abi.encodeWithSignature("InvalidWethLowerTick()"));
|
|
115
|
-
factory.deploy(users.creator, _getDefaultOwners(), "https://test.com", "Testcoin", "TEST", poolConfig, users.platformReferrer, 0);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function test_deploy_legacy_eth_config_with_prebuy(uint256 initialOrderSize) public {
|
|
119
|
-
vm.assume(initialOrderSize > MIN_ORDER_SIZE);
|
|
120
|
-
vm.assume(initialOrderSize < 10 ether);
|
|
121
|
-
|
|
122
|
-
vm.deal(users.creator, initialOrderSize);
|
|
123
|
-
|
|
124
|
-
bytes memory poolConfig = _generatePoolConfig(
|
|
125
|
-
CoinConfigurationVersions.LEGACY_POOL_VERSION,
|
|
126
|
-
address(weth),
|
|
127
|
-
MarketConstants.LP_TICK_LOWER_WETH,
|
|
128
|
-
0,
|
|
129
|
-
0,
|
|
130
|
-
0
|
|
131
|
-
);
|
|
132
|
-
|
|
133
|
-
vm.prank(users.creator);
|
|
134
|
-
(address coinAddress, ) = factory.deploy{value: initialOrderSize}(
|
|
135
|
-
users.creator,
|
|
136
|
-
_getDefaultOwners(),
|
|
137
|
-
"https://test.com",
|
|
138
|
-
"Testcoin",
|
|
139
|
-
"TEST",
|
|
140
|
-
poolConfig,
|
|
141
|
-
users.platformReferrer,
|
|
142
|
-
initialOrderSize
|
|
143
|
-
);
|
|
144
|
-
|
|
145
|
-
coin = Coin(payable(coinAddress));
|
|
146
|
-
pool = IUniswapV3Pool(coin.poolAddress());
|
|
147
|
-
|
|
148
|
-
assertGt(coin.balanceOf(users.creator), 10_000_000e18, "balanceOf creator");
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
function test_deploy_legacy_usdc_config_with_prebuy() public {
|
|
152
|
-
address[] memory owners = new address[](1);
|
|
153
|
-
owners[0] = users.creator;
|
|
154
|
-
|
|
155
|
-
uint256 orderSize = dealUSDC(users.creator, 100);
|
|
156
|
-
|
|
157
|
-
vm.prank(users.creator);
|
|
158
|
-
usdc.approve(address(factory), orderSize);
|
|
159
|
-
|
|
160
|
-
bytes memory poolConfig = _generatePoolConfig(CoinConfigurationVersions.LEGACY_POOL_VERSION, address(usdc), USDC_TICK_LOWER, 0, 0, 0);
|
|
161
|
-
|
|
162
|
-
vm.prank(users.creator);
|
|
163
|
-
(address coinAddress, uint256 coinsPurchased) = factory.deploy(
|
|
164
|
-
users.creator,
|
|
165
|
-
owners,
|
|
166
|
-
"https://testcoinusdcpair.com",
|
|
167
|
-
"Testcoinusdcpair",
|
|
168
|
-
"TESTCOINUSDCPAIR",
|
|
169
|
-
poolConfig,
|
|
170
|
-
users.platformReferrer,
|
|
171
|
-
orderSize
|
|
172
|
-
);
|
|
173
|
-
coin = Coin(payable(coinAddress));
|
|
174
|
-
pool = IUniswapV3Pool(coin.poolAddress());
|
|
175
|
-
vm.label(address(coin), "COIN");
|
|
176
|
-
vm.label(address(pool), "POOL");
|
|
177
|
-
|
|
178
|
-
assertEq(coin.currency(), address(usdc), "currency");
|
|
179
|
-
assertEq(coin.balanceOf(users.creator), CREATOR_LAUNCH_REWARD + coinsPurchased);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
function test_deploy_doppler_eth() public {
|
|
40
|
+
function test_supply_constants() public {
|
|
183
41
|
bytes memory poolConfig = _generatePoolConfig(
|
|
184
42
|
CoinConfigurationVersions.DOPPLER_UNI_V3_POOL_VERSION,
|
|
185
43
|
address(weth),
|
|
@@ -190,30 +48,19 @@ contract DopplerUniswapV3Test is BaseTest {
|
|
|
190
48
|
);
|
|
191
49
|
|
|
192
50
|
_deployCoin(poolConfig);
|
|
51
|
+
assertEq(CoinConstants.MAX_TOTAL_SUPPLY, CoinConstants.POOL_LAUNCH_SUPPLY + CoinConstants.CREATOR_LAUNCH_REWARD);
|
|
52
|
+
|
|
53
|
+
assertEq(CoinConstants.MAX_TOTAL_SUPPLY, 1_000_000_000e18);
|
|
54
|
+
assertEq(CoinConstants.POOL_LAUNCH_SUPPLY, 990_000_000e18);
|
|
55
|
+
assertEq(CoinConstants.CREATOR_LAUNCH_REWARD, 10_000_000e18);
|
|
193
56
|
|
|
194
|
-
(
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
,
|
|
198
|
-
,
|
|
199
|
-
uint16 numPositions,
|
|
200
|
-
bool isInitialized,
|
|
201
|
-
bool isExited,
|
|
202
|
-
uint256 maxShareToBeSold,
|
|
203
|
-
uint256 totalTokensOnBondingCurve
|
|
204
|
-
) = coin.poolState();
|
|
205
|
-
|
|
206
|
-
assertEq(asset, address(coin), "poolState.asset");
|
|
207
|
-
assertEq(numeraire, address(weth), "poolState.numeraire");
|
|
208
|
-
assertEq(numPositions, DEFAULT_NUM_DISCOVERY_POSITIONS, "poolState.numPositions");
|
|
209
|
-
assertTrue(isInitialized, "poolState.isInitialized");
|
|
210
|
-
assertFalse(isExited, "poolState.isExited");
|
|
211
|
-
assertEq(maxShareToBeSold, DEFAULT_DISCOVERY_SUPPLY_SHARE, "poolState.maxShareToBeSold");
|
|
212
|
-
assertEq(totalTokensOnBondingCurve, POOL_LAUNCH_SUPPLY, "poolState.totalTokensOnBondingCurve");
|
|
57
|
+
assertEq(coin.totalSupply(), CoinConstants.MAX_TOTAL_SUPPLY);
|
|
58
|
+
assertEq(coin.balanceOf(coin.payoutRecipient()), CoinConstants.CREATOR_LAUNCH_REWARD);
|
|
59
|
+
assertApproxEqAbs(coin.balanceOf(address(pool)), CoinConstants.POOL_LAUNCH_SUPPLY, 1e18);
|
|
213
60
|
}
|
|
214
61
|
|
|
215
62
|
function test_deploy_doppler_eth_with_prebuy(uint256 initialOrderSize) public {
|
|
216
|
-
vm.assume(initialOrderSize > MIN_ORDER_SIZE);
|
|
63
|
+
vm.assume(initialOrderSize > CoinConstants.MIN_ORDER_SIZE);
|
|
217
64
|
vm.assume(initialOrderSize < 1 ether);
|
|
218
65
|
|
|
219
66
|
vm.deal(users.creator, initialOrderSize);
|
|
@@ -244,7 +91,7 @@ contract DopplerUniswapV3Test is BaseTest {
|
|
|
244
91
|
|
|
245
92
|
assertEq(coin.currency(), address(weth), "currency");
|
|
246
93
|
assertGt(coinsPurchased, 0, "coinsPurchased > 0");
|
|
247
|
-
assertEq(coin.balanceOf(users.creator), CREATOR_LAUNCH_REWARD + coinsPurchased, "balanceOf creator");
|
|
94
|
+
assertEq(coin.balanceOf(users.creator), CoinConstants.CREATOR_LAUNCH_REWARD + coinsPurchased, "balanceOf creator");
|
|
248
95
|
assertGt(weth.balanceOf(address(pool)), 0, "Pool WETH balance");
|
|
249
96
|
}
|
|
250
97
|
|
|
@@ -274,40 +121,40 @@ contract DopplerUniswapV3Test is BaseTest {
|
|
|
274
121
|
int24 TICK_SPACING = 60;
|
|
275
122
|
int24 expected = 12300;
|
|
276
123
|
|
|
277
|
-
assertEq(
|
|
124
|
+
assertEq(DopplerMath.alignTickToTickSpacing(true, tick, TICK_SPACING), expected, "Align positive tick (token0)");
|
|
278
125
|
}
|
|
279
126
|
|
|
280
127
|
function test_alignTick_isToken0_negative() public pure {
|
|
281
128
|
int24 tick = -12345;
|
|
282
129
|
int24 TICK_SPACING = 60;
|
|
283
130
|
int24 expected = -12360;
|
|
284
|
-
assertEq(
|
|
131
|
+
assertEq(DopplerMath.alignTickToTickSpacing(true, tick, TICK_SPACING), expected, "Align negative tick (token0)");
|
|
285
132
|
}
|
|
286
133
|
|
|
287
134
|
function test_alignTick_isToken1_negative() public pure {
|
|
288
135
|
int24 tick = -12345;
|
|
289
136
|
int24 TICK_SPACING = 60;
|
|
290
137
|
int24 expected = -12300;
|
|
291
|
-
assertEq(
|
|
138
|
+
assertEq(DopplerMath.alignTickToTickSpacing(false, tick, TICK_SPACING), expected, "Align negative tick (token1)");
|
|
292
139
|
}
|
|
293
140
|
|
|
294
141
|
function test_alignTick_isToken1_zero() public pure {
|
|
295
142
|
int24 tick = 0;
|
|
296
143
|
int24 expected = 0;
|
|
297
|
-
assertEq(
|
|
144
|
+
assertEq(DopplerMath.alignTickToTickSpacing(false, tick, MarketConstants.TICK_SPACING), expected, "Align zero tick (token1)");
|
|
298
145
|
}
|
|
299
146
|
|
|
300
147
|
// Additional tick alignment test for full branch coverage
|
|
301
148
|
function test_alignTick_isToken0_zero() public pure {
|
|
302
149
|
int24 tick = 0;
|
|
303
150
|
int24 expected = 0;
|
|
304
|
-
assertEq(
|
|
151
|
+
assertEq(DopplerMath.alignTickToTickSpacing(true, tick, MarketConstants.TICK_SPACING), expected, "Align zero tick (token0)");
|
|
305
152
|
}
|
|
306
153
|
|
|
307
154
|
function test_alignTick_isToken1_positive() public pure {
|
|
308
155
|
int24 tick = 12345;
|
|
309
156
|
int24 expected = 12400; // Round up for token1
|
|
310
|
-
assertEq(
|
|
157
|
+
assertEq(DopplerMath.alignTickToTickSpacing(false, tick, MarketConstants.TICK_SPACING), expected, "Align positive tick (token1)");
|
|
311
158
|
}
|
|
312
159
|
|
|
313
160
|
function test_calculateLpTail_isToken0() public pure {
|
|
@@ -316,10 +163,10 @@ contract DopplerUniswapV3Test is BaseTest {
|
|
|
316
163
|
uint256 tailSupply = 1e18;
|
|
317
164
|
bool isToken0 = true;
|
|
318
165
|
|
|
319
|
-
LpPosition memory tail =
|
|
166
|
+
LpPosition memory tail = DopplerMath.calculateLpTail(tickLower, tickUpper, isToken0, tailSupply, MarketConstants.TICK_SPACING);
|
|
320
167
|
|
|
321
168
|
int24 expectedPosTickLower = tickUpper;
|
|
322
|
-
int24 expectedPosTickUpper =
|
|
169
|
+
int24 expectedPosTickUpper = DopplerMath.alignTickToTickSpacing(true, TickMath.MAX_TICK, MarketConstants.TICK_SPACING);
|
|
323
170
|
|
|
324
171
|
assertEq(tail.tickLower, expectedPosTickLower, "Tail tickLower (token0)");
|
|
325
172
|
assertEq(tail.tickUpper, expectedPosTickUpper, "Tail tickUpper (token0)");
|
|
@@ -332,9 +179,9 @@ contract DopplerUniswapV3Test is BaseTest {
|
|
|
332
179
|
uint256 tailSupply = 1e18;
|
|
333
180
|
bool isToken0 = false;
|
|
334
181
|
|
|
335
|
-
LpPosition memory tail =
|
|
182
|
+
LpPosition memory tail = DopplerMath.calculateLpTail(tickLower, tickUpper, isToken0, tailSupply, MarketConstants.TICK_SPACING);
|
|
336
183
|
|
|
337
|
-
int24 expectedPosTickLower =
|
|
184
|
+
int24 expectedPosTickLower = DopplerMath.alignTickToTickSpacing(false, TickMath.MIN_TICK, MarketConstants.TICK_SPACING);
|
|
338
185
|
int24 expectedPosTickUpper = tickLower;
|
|
339
186
|
|
|
340
187
|
assertEq(tail.tickLower, expectedPosTickLower, "Tail tickLower (token1)");
|
|
@@ -349,14 +196,15 @@ contract DopplerUniswapV3Test is BaseTest {
|
|
|
349
196
|
uint256 discoverySupply = 100e18;
|
|
350
197
|
LpPosition[] memory newPositions = new LpPosition[](DEFAULT_NUM_DISCOVERY_POSITIONS);
|
|
351
198
|
|
|
352
|
-
(LpPosition[] memory positions, uint256 totalAssetsSold) =
|
|
199
|
+
(LpPosition[] memory positions, uint256 totalAssetsSold) = DopplerMath.calculateLogNormalDistribution(
|
|
353
200
|
tickLower,
|
|
354
201
|
tickUpper,
|
|
355
202
|
MarketConstants.TICK_SPACING,
|
|
356
203
|
isToken0,
|
|
357
204
|
discoverySupply,
|
|
358
205
|
DEFAULT_NUM_DISCOVERY_POSITIONS,
|
|
359
|
-
newPositions
|
|
206
|
+
newPositions,
|
|
207
|
+
0
|
|
360
208
|
);
|
|
361
209
|
|
|
362
210
|
assertEq(positions.length, DEFAULT_NUM_DISCOVERY_POSITIONS, "Correct number of positions (token0)");
|
|
@@ -380,14 +228,15 @@ contract DopplerUniswapV3Test is BaseTest {
|
|
|
380
228
|
uint256 discoverySupply = 100e18;
|
|
381
229
|
LpPosition[] memory newPositions = new LpPosition[](DEFAULT_NUM_DISCOVERY_POSITIONS);
|
|
382
230
|
|
|
383
|
-
(LpPosition[] memory positions, uint256 totalAssetsSold) =
|
|
231
|
+
(LpPosition[] memory positions, uint256 totalAssetsSold) = DopplerMath.calculateLogNormalDistribution(
|
|
384
232
|
tickLower,
|
|
385
233
|
tickUpper,
|
|
386
234
|
MarketConstants.TICK_SPACING,
|
|
387
235
|
isToken0,
|
|
388
236
|
discoverySupply,
|
|
389
237
|
DEFAULT_NUM_DISCOVERY_POSITIONS,
|
|
390
|
-
newPositions
|
|
238
|
+
newPositions,
|
|
239
|
+
0
|
|
391
240
|
);
|
|
392
241
|
|
|
393
242
|
assertEq(positions.length, DEFAULT_NUM_DISCOVERY_POSITIONS, "Correct number of positions (token1)");
|
|
@@ -411,14 +260,15 @@ contract DopplerUniswapV3Test is BaseTest {
|
|
|
411
260
|
uint256 discoverySupply = 0;
|
|
412
261
|
LpPosition[] memory newPositions = new LpPosition[](DEFAULT_NUM_DISCOVERY_POSITIONS);
|
|
413
262
|
|
|
414
|
-
(LpPosition[] memory positions, uint256 totalAssetsSold) =
|
|
263
|
+
(LpPosition[] memory positions, uint256 totalAssetsSold) = DopplerMath.calculateLogNormalDistribution(
|
|
415
264
|
tickLower,
|
|
416
265
|
tickUpper,
|
|
417
266
|
MarketConstants.TICK_SPACING,
|
|
418
267
|
isToken0,
|
|
419
268
|
discoverySupply,
|
|
420
269
|
DEFAULT_NUM_DISCOVERY_POSITIONS,
|
|
421
|
-
newPositions
|
|
270
|
+
newPositions,
|
|
271
|
+
0
|
|
422
272
|
);
|
|
423
273
|
|
|
424
274
|
assertEq(positions.length, DEFAULT_NUM_DISCOVERY_POSITIONS, "Correct number of positions (zero supply)");
|
|
@@ -442,14 +292,15 @@ contract DopplerUniswapV3Test is BaseTest {
|
|
|
442
292
|
uint16 totalPositions = 1;
|
|
443
293
|
LpPosition[] memory newPositions = new LpPosition[](totalPositions);
|
|
444
294
|
|
|
445
|
-
(LpPosition[] memory positions, uint256 totalAssetsSold) =
|
|
295
|
+
(LpPosition[] memory positions, uint256 totalAssetsSold) = DopplerMath.calculateLogNormalDistribution(
|
|
446
296
|
tickLower,
|
|
447
297
|
tickUpper,
|
|
448
298
|
MarketConstants.TICK_SPACING,
|
|
449
299
|
isToken0,
|
|
450
300
|
discoverySupply,
|
|
451
301
|
totalPositions,
|
|
452
|
-
newPositions
|
|
302
|
+
newPositions,
|
|
303
|
+
0
|
|
453
304
|
);
|
|
454
305
|
|
|
455
306
|
assertEq(positions.length, totalPositions, "Correct number of positions");
|