@bananapus/router-terminal-v6 0.0.1 → 0.0.3
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bananapus/router-terminal-v6",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"artifacts": "source ./.env && npx sphinx artifacts --org-id 'ea165b21-7cdc-4d7b-be59-ecdd4c26bee4' --project-name 'nana-router-terminal-v6'"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@bananapus/core-v6": "^0.0.
|
|
20
|
+
"@bananapus/core-v6": "^0.0.5",
|
|
21
21
|
"@openzeppelin/contracts": "^5.2.0",
|
|
22
22
|
"@uniswap/permit2": "github:Uniswap/permit2",
|
|
23
23
|
"@uniswap/v3-core": "github:Uniswap/v3-core#0.8",
|
|
@@ -45,9 +45,8 @@ library RouterTerminalDeploymentLib {
|
|
|
45
45
|
view
|
|
46
46
|
returns (RouterTerminalDeployment memory deployment)
|
|
47
47
|
{
|
|
48
|
-
deployment.terminal =
|
|
49
|
-
_getDeploymentAddress(path, "nana-router-terminal-v6", network_name, "JBRouterTerminal")
|
|
50
|
-
);
|
|
48
|
+
deployment.terminal =
|
|
49
|
+
IJBRouterTerminal(_getDeploymentAddress(path, "nana-router-terminal-v6", network_name, "JBRouterTerminal"));
|
|
51
50
|
|
|
52
51
|
deployment.registry = IJBRouterTerminalRegistry(
|
|
53
52
|
_getDeploymentAddress(path, "nana-router-terminal-v6", network_name, "JBRouterTerminalRegistry")
|
package/src/JBRouterTerminal.sol
CHANGED
|
@@ -402,9 +402,7 @@ contract JBRouterTerminal is
|
|
|
402
402
|
BalanceDelta delta = POOL_MANAGER.swap({
|
|
403
403
|
key: key,
|
|
404
404
|
params: SwapParams({
|
|
405
|
-
zeroForOne: zeroForOne,
|
|
406
|
-
amountSpecified: amountSpecified,
|
|
407
|
-
sqrtPriceLimitX96: sqrtPriceLimitX96
|
|
405
|
+
zeroForOne: zeroForOne, amountSpecified: amountSpecified, sqrtPriceLimitX96: sqrtPriceLimitX96
|
|
408
406
|
}),
|
|
409
407
|
hookData: ""
|
|
410
408
|
});
|
|
@@ -462,10 +460,8 @@ contract JBRouterTerminal is
|
|
|
462
460
|
// Check for credit source override.
|
|
463
461
|
uint256 sourceProjectIdOverride;
|
|
464
462
|
{
|
|
465
|
-
(bool creditExists, bytes memory creditData) =
|
|
466
|
-
id: JBMetadataResolver.getId("cashOutSource"),
|
|
467
|
-
metadata: metadata
|
|
468
|
-
});
|
|
463
|
+
(bool creditExists, bytes memory creditData) =
|
|
464
|
+
JBMetadataResolver.getDataFor({id: JBMetadataResolver.getId("cashOutSource"), metadata: metadata});
|
|
469
465
|
if (creditExists) {
|
|
470
466
|
(sourceProjectIdOverride,) = abi.decode(creditData, (uint256, uint256));
|
|
471
467
|
}
|
|
@@ -501,11 +497,7 @@ contract JBRouterTerminal is
|
|
|
501
497
|
|
|
502
498
|
// Convert tokenIn -> tokenOut (no-op if they match, wrap/unwrap, or swap).
|
|
503
499
|
amountOut = _convert({
|
|
504
|
-
tokenIn: tokenIn,
|
|
505
|
-
tokenOut: tokenOut,
|
|
506
|
-
amount: amount,
|
|
507
|
-
projectId: destProjectId,
|
|
508
|
-
metadata: metadata
|
|
500
|
+
tokenIn: tokenIn, tokenOut: tokenOut, amount: amount, projectId: destProjectId, metadata: metadata
|
|
509
501
|
});
|
|
510
502
|
}
|
|
511
503
|
|
|
@@ -527,10 +519,8 @@ contract JBRouterTerminal is
|
|
|
527
519
|
{
|
|
528
520
|
// 1. Metadata override — payer specifies tokenOut explicitly.
|
|
529
521
|
{
|
|
530
|
-
(bool exists, bytes memory routeData) =
|
|
531
|
-
id: JBMetadataResolver.getId("routeTokenOut"),
|
|
532
|
-
metadata: metadata
|
|
533
|
-
});
|
|
522
|
+
(bool exists, bytes memory routeData) =
|
|
523
|
+
JBMetadataResolver.getDataFor({id: JBMetadataResolver.getId("routeTokenOut"), metadata: metadata});
|
|
534
524
|
if (exists) {
|
|
535
525
|
(tokenOut) = abi.decode(routeData, (address));
|
|
536
526
|
destTerminal = DIRECTORY.primaryTerminalOf({projectId: projectId, token: tokenOut});
|
|
@@ -694,13 +684,10 @@ contract JBRouterTerminal is
|
|
|
694
684
|
}
|
|
695
685
|
|
|
696
686
|
// Different tokens — swap via Uniswap (V3 or V4).
|
|
697
|
-
return
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
amount: amount,
|
|
702
|
-
metadata: metadata
|
|
703
|
-
});
|
|
687
|
+
return
|
|
688
|
+
_handleSwap({
|
|
689
|
+
projectId: projectId, tokenIn: tokenIn, tokenOut: tokenOut, amount: amount, metadata: metadata
|
|
690
|
+
});
|
|
704
691
|
}
|
|
705
692
|
|
|
706
693
|
/// @notice Execute a Uniswap swap from tokenIn to tokenOut (V3 or V4).
|
|
@@ -822,13 +809,10 @@ contract JBRouterTerminal is
|
|
|
822
809
|
address v4In = normalizedTokenIn == address(WETH) ? address(0) : normalizedTokenIn;
|
|
823
810
|
bool zeroForOne = Currency.unwrap(key.currency0) == v4In;
|
|
824
811
|
|
|
825
|
-
uint160 sqrtPriceLimitX96 = zeroForOne
|
|
826
|
-
? TickMath.MIN_SQRT_RATIO + 1
|
|
827
|
-
: TickMath.MAX_SQRT_RATIO - 1;
|
|
812
|
+
uint160 sqrtPriceLimitX96 = zeroForOne ? TickMath.MIN_SQRT_RATIO + 1 : TickMath.MAX_SQRT_RATIO - 1;
|
|
828
813
|
|
|
829
|
-
bytes memory result =
|
|
830
|
-
abi.encode(key, zeroForOne, int256(amount), sqrtPriceLimitX96, minAmountOut)
|
|
831
|
-
);
|
|
814
|
+
bytes memory result =
|
|
815
|
+
POOL_MANAGER.unlock(abi.encode(key, zeroForOne, int256(amount), sqrtPriceLimitX96, minAmountOut));
|
|
832
816
|
|
|
833
817
|
amountOut = abi.decode(result, (uint256));
|
|
834
818
|
}
|
|
@@ -879,10 +863,8 @@ contract JBRouterTerminal is
|
|
|
879
863
|
pool = _discoverPool(normalizedTokenIn, normalizedTokenOut);
|
|
880
864
|
|
|
881
865
|
// Check for a user-provided quote.
|
|
882
|
-
(bool exists, bytes memory quote) =
|
|
883
|
-
id: JBMetadataResolver.getId("quoteForSwap"),
|
|
884
|
-
metadata: metadata
|
|
885
|
-
});
|
|
866
|
+
(bool exists, bytes memory quote) =
|
|
867
|
+
JBMetadataResolver.getDataFor({id: JBMetadataResolver.getId("quoteForSwap"), metadata: metadata});
|
|
886
868
|
|
|
887
869
|
if (exists) {
|
|
888
870
|
(minAmountOut) = abi.decode(quote, (uint256));
|
|
@@ -981,10 +963,7 @@ contract JBRouterTerminal is
|
|
|
981
963
|
|
|
982
964
|
if (amount > type(uint128).max) revert JBRouterTerminal_AmountOverflow(amount);
|
|
983
965
|
minAmountOut = OracleLibrary.getQuoteAtTick({
|
|
984
|
-
tick: tick,
|
|
985
|
-
baseAmount: uint128(amount),
|
|
986
|
-
baseToken: normalizedTokenIn,
|
|
987
|
-
quoteToken: normalizedTokenOut
|
|
966
|
+
tick: tick, baseAmount: uint128(amount), baseToken: normalizedTokenIn, quoteToken: normalizedTokenOut
|
|
988
967
|
});
|
|
989
968
|
|
|
990
969
|
minAmountOut -= (minAmountOut * slippageTolerance) / SLIPPAGE_DENOMINATOR;
|
|
@@ -1235,20 +1214,15 @@ contract JBRouterTerminal is
|
|
|
1235
1214
|
function _acceptFundsFor(address token, uint256 amount, bytes calldata metadata) internal returns (uint256) {
|
|
1236
1215
|
// Check for credit cash-out metadata.
|
|
1237
1216
|
{
|
|
1238
|
-
(bool creditExists, bytes memory creditData) =
|
|
1239
|
-
id: JBMetadataResolver.getId("cashOutSource"),
|
|
1240
|
-
metadata: metadata
|
|
1241
|
-
});
|
|
1217
|
+
(bool creditExists, bytes memory creditData) =
|
|
1218
|
+
JBMetadataResolver.getDataFor({id: JBMetadataResolver.getId("cashOutSource"), metadata: metadata});
|
|
1242
1219
|
|
|
1243
1220
|
if (creditExists) {
|
|
1244
1221
|
(uint256 sourceProjectId, uint256 creditAmount) = abi.decode(creditData, (uint256, uint256));
|
|
1245
1222
|
|
|
1246
1223
|
// Pull credits from the payer.
|
|
1247
1224
|
TOKENS.transferCreditsFrom({
|
|
1248
|
-
holder: _msgSender(),
|
|
1249
|
-
projectId: sourceProjectId,
|
|
1250
|
-
recipient: address(this),
|
|
1251
|
-
count: creditAmount
|
|
1225
|
+
holder: _msgSender(), projectId: sourceProjectId, recipient: address(this), count: creditAmount
|
|
1252
1226
|
});
|
|
1253
1227
|
|
|
1254
1228
|
return creditAmount;
|
|
@@ -162,8 +162,7 @@ contract RouterTerminalTest is Test {
|
|
|
162
162
|
abi.encode(mockTerminal)
|
|
163
163
|
);
|
|
164
164
|
|
|
165
|
-
(address tokenOut, IJBTerminal destTerminal) =
|
|
166
|
-
routerTerminal.exposed_resolveTokenOut(projectId, tokenIn, "");
|
|
165
|
+
(address tokenOut, IJBTerminal destTerminal) = routerTerminal.exposed_resolveTokenOut(projectId, tokenIn, "");
|
|
167
166
|
|
|
168
167
|
assertEq(tokenOut, tokenIn);
|
|
169
168
|
assertEq(address(destTerminal), mockTerminal);
|
|
@@ -220,9 +219,7 @@ contract RouterTerminalTest is Test {
|
|
|
220
219
|
JBAccountingContext[] memory contexts = new JBAccountingContext[](1);
|
|
221
220
|
contexts[0] =
|
|
222
221
|
JBAccountingContext({token: acceptedToken, decimals: 18, currency: uint32(uint160(acceptedToken))});
|
|
223
|
-
vm.mockCall(
|
|
224
|
-
mockTerminal, abi.encodeCall(IJBTerminal.accountingContextsOf, (projectId)), abi.encode(contexts)
|
|
225
|
-
);
|
|
222
|
+
vm.mockCall(mockTerminal, abi.encodeCall(IJBTerminal.accountingContextsOf, (projectId)), abi.encode(contexts));
|
|
226
223
|
|
|
227
224
|
// Mock V3 pool discovery: pool exists at 0.3% fee tier with liquidity.
|
|
228
225
|
vm.mockCall(
|
|
@@ -252,8 +249,7 @@ contract RouterTerminalTest is Test {
|
|
|
252
249
|
// Mock V4 — no pools found (extsload returns 0 for all).
|
|
253
250
|
_mockV4NoPools(tokenIn, acceptedToken);
|
|
254
251
|
|
|
255
|
-
(address tokenOut, IJBTerminal destTerminal) =
|
|
256
|
-
routerTerminal.exposed_resolveTokenOut(projectId, tokenIn, "");
|
|
252
|
+
(address tokenOut, IJBTerminal destTerminal) = routerTerminal.exposed_resolveTokenOut(projectId, tokenIn, "");
|
|
257
253
|
|
|
258
254
|
assertEq(tokenOut, acceptedToken);
|
|
259
255
|
assertEq(address(destTerminal), mockTerminal);
|
|
@@ -297,11 +293,7 @@ contract RouterTerminalTest is Test {
|
|
|
297
293
|
vm.etch(tokenIn, hex"00");
|
|
298
294
|
|
|
299
295
|
// Not a JB token.
|
|
300
|
-
vm.mockCall(
|
|
301
|
-
address(mockTokens),
|
|
302
|
-
abi.encodeWithSelector(IJBTokens.projectIdOf.selector),
|
|
303
|
-
abi.encode(uint256(0))
|
|
304
|
-
);
|
|
296
|
+
vm.mockCall(address(mockTokens), abi.encodeWithSelector(IJBTokens.projectIdOf.selector), abi.encode(uint256(0)));
|
|
305
297
|
|
|
306
298
|
// Project accepts tokenIn directly.
|
|
307
299
|
vm.mockCall(
|
|
@@ -311,18 +303,14 @@ contract RouterTerminalTest is Test {
|
|
|
311
303
|
);
|
|
312
304
|
|
|
313
305
|
// Mock token transfer from payer.
|
|
314
|
-
vm.mockCall(
|
|
315
|
-
tokenIn, abi.encodeCall(IERC20.allowance, (payer, address(routerTerminal))), abi.encode(amount)
|
|
316
|
-
);
|
|
306
|
+
vm.mockCall(tokenIn, abi.encodeCall(IERC20.allowance, (payer, address(routerTerminal))), abi.encode(amount));
|
|
317
307
|
vm.mockCall(
|
|
318
308
|
tokenIn, abi.encodeCall(IERC20.transferFrom, (payer, address(routerTerminal), amount)), abi.encode(true)
|
|
319
309
|
);
|
|
320
310
|
|
|
321
311
|
// Mock safeIncreaseAllowance: allowance check + approve.
|
|
322
312
|
vm.mockCall(
|
|
323
|
-
tokenIn,
|
|
324
|
-
abi.encodeCall(IERC20.allowance, (address(routerTerminal), mockTerminal)),
|
|
325
|
-
abi.encode(uint256(0))
|
|
313
|
+
tokenIn, abi.encodeCall(IERC20.allowance, (address(routerTerminal), mockTerminal)), abi.encode(uint256(0))
|
|
326
314
|
);
|
|
327
315
|
vm.mockCall(tokenIn, abi.encodeCall(IERC20.approve, (mockTerminal, amount)), abi.encode(true));
|
|
328
316
|
|
|
@@ -414,9 +402,7 @@ contract RouterTerminalTest is Test {
|
|
|
414
402
|
bytes memory data = abi.encode(uint256(1), tokenIn, tokenOut);
|
|
415
403
|
|
|
416
404
|
vm.prank(fakePool);
|
|
417
|
-
vm.expectRevert(
|
|
418
|
-
abi.encodeWithSelector(IJBRouterTerminal.JBRouterTerminal_CallerNotPool.selector, fakePool)
|
|
419
|
-
);
|
|
405
|
+
vm.expectRevert(abi.encodeWithSelector(IJBRouterTerminal.JBRouterTerminal_CallerNotPool.selector, fakePool));
|
|
420
406
|
routerTerminal.uniswapV3SwapCallback(int256(-200), int256(100), data);
|
|
421
407
|
}
|
|
422
408
|
|
|
@@ -434,11 +420,7 @@ contract RouterTerminalTest is Test {
|
|
|
434
420
|
vm.etch(tokenIn, hex"00");
|
|
435
421
|
|
|
436
422
|
// Not a JB token.
|
|
437
|
-
vm.mockCall(
|
|
438
|
-
address(mockTokens),
|
|
439
|
-
abi.encodeWithSelector(IJBTokens.projectIdOf.selector),
|
|
440
|
-
abi.encode(uint256(0))
|
|
441
|
-
);
|
|
423
|
+
vm.mockCall(address(mockTokens), abi.encodeWithSelector(IJBTokens.projectIdOf.selector), abi.encode(uint256(0)));
|
|
442
424
|
|
|
443
425
|
// Project accepts tokenIn.
|
|
444
426
|
vm.mockCall(
|
|
@@ -448,18 +430,14 @@ contract RouterTerminalTest is Test {
|
|
|
448
430
|
);
|
|
449
431
|
|
|
450
432
|
// Mock token transfer.
|
|
451
|
-
vm.mockCall(
|
|
452
|
-
tokenIn, abi.encodeCall(IERC20.allowance, (payer, address(routerTerminal))), abi.encode(amount)
|
|
453
|
-
);
|
|
433
|
+
vm.mockCall(tokenIn, abi.encodeCall(IERC20.allowance, (payer, address(routerTerminal))), abi.encode(amount));
|
|
454
434
|
vm.mockCall(
|
|
455
435
|
tokenIn, abi.encodeCall(IERC20.transferFrom, (payer, address(routerTerminal), amount)), abi.encode(true)
|
|
456
436
|
);
|
|
457
437
|
|
|
458
438
|
// Mock safeIncreaseAllowance.
|
|
459
439
|
vm.mockCall(
|
|
460
|
-
tokenIn,
|
|
461
|
-
abi.encodeCall(IERC20.allowance, (address(routerTerminal), mockTerminal)),
|
|
462
|
-
abi.encode(uint256(0))
|
|
440
|
+
tokenIn, abi.encodeCall(IERC20.allowance, (address(routerTerminal), mockTerminal)), abi.encode(uint256(0))
|
|
463
441
|
);
|
|
464
442
|
vm.mockCall(tokenIn, abi.encodeCall(IERC20.approve, (mockTerminal, amount)), abi.encode(true));
|
|
465
443
|
|
|
@@ -492,9 +470,7 @@ contract RouterTerminalTest is Test {
|
|
|
492
470
|
|
|
493
471
|
// Pool at 0.05% has higher liquidity.
|
|
494
472
|
vm.mockCall(
|
|
495
|
-
address(mockFactory),
|
|
496
|
-
abi.encodeCall(IUniswapV3Factory.getPool, (tokenA, tokenB, 500)),
|
|
497
|
-
abi.encode(pool500)
|
|
473
|
+
address(mockFactory), abi.encodeCall(IUniswapV3Factory.getPool, (tokenA, tokenB, 500)), abi.encode(pool500)
|
|
498
474
|
);
|
|
499
475
|
vm.mockCall(pool500, abi.encodeWithSignature("liquidity()"), abi.encode(uint128(500e18)));
|
|
500
476
|
|
|
@@ -530,9 +506,7 @@ contract RouterTerminalTest is Test {
|
|
|
530
506
|
// No V4 pools.
|
|
531
507
|
_mockV4NoPools(tokenA, tokenB);
|
|
532
508
|
|
|
533
|
-
vm.expectRevert(
|
|
534
|
-
abi.encodeWithSelector(IJBRouterTerminal.JBRouterTerminal_NoPoolFound.selector, tokenA, tokenB)
|
|
535
|
-
);
|
|
509
|
+
vm.expectRevert(abi.encodeWithSelector(IJBRouterTerminal.JBRouterTerminal_NoPoolFound.selector, tokenA, tokenB));
|
|
536
510
|
routerTerminal.exposed_discoverPool(tokenA, tokenB);
|
|
537
511
|
}
|
|
538
512
|
|
|
@@ -550,10 +524,7 @@ contract RouterTerminalTest is Test {
|
|
|
550
524
|
//*********************************************************************//
|
|
551
525
|
|
|
552
526
|
function test_migrateBalanceOf_returnsZero() public {
|
|
553
|
-
assertEq(
|
|
554
|
-
routerTerminal.migrateBalanceOf(1, makeAddr("token"), IJBTerminal(makeAddr("terminal"))),
|
|
555
|
-
0
|
|
556
|
-
);
|
|
527
|
+
assertEq(routerTerminal.migrateBalanceOf(1, makeAddr("token"), IJBTerminal(makeAddr("terminal"))), 0);
|
|
557
528
|
}
|
|
558
529
|
|
|
559
530
|
function test_addAccountingContextsFor_noOp() public {
|
|
@@ -573,9 +544,7 @@ contract RouterTerminalTest is Test {
|
|
|
573
544
|
|
|
574
545
|
// V3 pool with moderate liquidity.
|
|
575
546
|
vm.mockCall(
|
|
576
|
-
address(mockFactory),
|
|
577
|
-
abi.encodeCall(IUniswapV3Factory.getPool, (tokenA, tokenB, 3000)),
|
|
578
|
-
abi.encode(v3Pool)
|
|
547
|
+
address(mockFactory), abi.encodeCall(IUniswapV3Factory.getPool, (tokenA, tokenB, 3000)), abi.encode(v3Pool)
|
|
579
548
|
);
|
|
580
549
|
vm.mockCall(v3Pool, abi.encodeWithSignature("liquidity()"), abi.encode(uint128(100e18)));
|
|
581
550
|
|
|
@@ -609,7 +578,7 @@ contract RouterTerminalTest is Test {
|
|
|
609
578
|
PoolId v4Id = v4Key.toId();
|
|
610
579
|
|
|
611
580
|
// Mock getSlot0 via extsload — pool exists (sqrtPriceX96 != 0).
|
|
612
|
-
_mockV4PoolExists(v4Id, uint160(
|
|
581
|
+
_mockV4PoolExists(v4Id, uint160(79_228_162_514_264_337_593_543_950_336), 500e18);
|
|
613
582
|
|
|
614
583
|
// Mock other V4 fee tiers as non-existent.
|
|
615
584
|
_mockV4PoolNotExists(sorted0, sorted1, 500, int24(10));
|
|
@@ -631,9 +600,7 @@ contract RouterTerminalTest is Test {
|
|
|
631
600
|
|
|
632
601
|
// V3 pool with high liquidity.
|
|
633
602
|
vm.mockCall(
|
|
634
|
-
address(mockFactory),
|
|
635
|
-
abi.encodeCall(IUniswapV3Factory.getPool, (tokenA, tokenB, 3000)),
|
|
636
|
-
abi.encode(v3Pool)
|
|
603
|
+
address(mockFactory), abi.encodeCall(IUniswapV3Factory.getPool, (tokenA, tokenB, 3000)), abi.encode(v3Pool)
|
|
637
604
|
);
|
|
638
605
|
vm.mockCall(v3Pool, abi.encodeWithSignature("liquidity()"), abi.encode(uint128(1000e18)));
|
|
639
606
|
|
|
@@ -665,7 +632,7 @@ contract RouterTerminalTest is Test {
|
|
|
665
632
|
});
|
|
666
633
|
PoolId v4Id = v4Key.toId();
|
|
667
634
|
|
|
668
|
-
_mockV4PoolExists(v4Id, uint160(
|
|
635
|
+
_mockV4PoolExists(v4Id, uint160(79_228_162_514_264_337_593_543_950_336), 50e18);
|
|
669
636
|
|
|
670
637
|
_mockV4PoolNotExists(sorted0, sorted1, 500, int24(10));
|
|
671
638
|
_mockV4PoolNotExists(sorted0, sorted1, 10_000, int24(200));
|
|
@@ -699,7 +666,7 @@ contract RouterTerminalTest is Test {
|
|
|
699
666
|
// First fee tier (3000/60) doesn't exist.
|
|
700
667
|
_mockV4PoolNotExists(sorted0, sorted1, 3000, int24(60));
|
|
701
668
|
// Second fee tier (500/10) exists.
|
|
702
|
-
_mockV4PoolExists(v4Id, uint160(
|
|
669
|
+
_mockV4PoolExists(v4Id, uint160(79_228_162_514_264_337_593_543_950_336), 200e18);
|
|
703
670
|
// Other tiers don't exist.
|
|
704
671
|
_mockV4PoolNotExists(sorted0, sorted1, 10_000, int24(200));
|
|
705
672
|
_mockV4PoolNotExists(sorted0, sorted1, 100, int24(1));
|
|
@@ -732,9 +699,7 @@ contract RouterTerminalTest is Test {
|
|
|
732
699
|
|
|
733
700
|
// V3 pool exists.
|
|
734
701
|
vm.mockCall(
|
|
735
|
-
address(mockFactory),
|
|
736
|
-
abi.encodeCall(IUniswapV3Factory.getPool, (tokenA, tokenB, 3000)),
|
|
737
|
-
abi.encode(v3Pool)
|
|
702
|
+
address(mockFactory), abi.encodeCall(IUniswapV3Factory.getPool, (tokenA, tokenB, 3000)), abi.encode(v3Pool)
|
|
738
703
|
);
|
|
739
704
|
vm.mockCall(v3Pool, abi.encodeWithSignature("liquidity()"), abi.encode(uint128(100e18)));
|
|
740
705
|
|
|
@@ -797,7 +762,7 @@ contract RouterTerminalTest is Test {
|
|
|
797
762
|
hooks: IHooks(address(0))
|
|
798
763
|
});
|
|
799
764
|
PoolId v4Id = v4Key.toId();
|
|
800
|
-
_mockV4PoolExists(v4Id, uint160(
|
|
765
|
+
_mockV4PoolExists(v4Id, uint160(79_228_162_514_264_337_593_543_950_336), 300e18);
|
|
801
766
|
|
|
802
767
|
_mockV4PoolNotExists(sorted0, sorted1, 500, int24(10));
|
|
803
768
|
_mockV4PoolNotExists(sorted0, sorted1, 10_000, int24(200));
|
|
@@ -821,9 +786,7 @@ contract RouterTerminalTest is Test {
|
|
|
821
786
|
// Pack slot0: sqrtPriceX96 (160 bits) | tick (24 bits) | protocolFee (24 bits) | lpFee (24 bits)
|
|
822
787
|
bytes32 slot0Data = bytes32(uint256(sqrtPriceX96));
|
|
823
788
|
vm.mockCall(
|
|
824
|
-
address(mockPoolManager),
|
|
825
|
-
abi.encodeWithSignature("extsload(bytes32)", stateSlot),
|
|
826
|
-
abi.encode(slot0Data)
|
|
789
|
+
address(mockPoolManager), abi.encodeWithSignature("extsload(bytes32)", stateSlot), abi.encode(slot0Data)
|
|
827
790
|
);
|
|
828
791
|
|
|
829
792
|
// Liquidity is at stateSlot + 3.
|
|
@@ -848,9 +811,7 @@ contract RouterTerminalTest is Test {
|
|
|
848
811
|
bytes32 stateSlot = keccak256(abi.encodePacked(PoolId.unwrap(id), bytes32(uint256(6))));
|
|
849
812
|
|
|
850
813
|
vm.mockCall(
|
|
851
|
-
address(mockPoolManager),
|
|
852
|
-
abi.encodeWithSignature("extsload(bytes32)", stateSlot),
|
|
853
|
-
abi.encode(bytes32(0))
|
|
814
|
+
address(mockPoolManager), abi.encodeWithSignature("extsload(bytes32)", stateSlot), abi.encode(bytes32(0))
|
|
854
815
|
);
|
|
855
816
|
}
|
|
856
817
|
|
|
@@ -256,9 +256,7 @@ contract RouterTerminalRegistryTest is Test {
|
|
|
256
256
|
|
|
257
257
|
vm.prank(projectOwner);
|
|
258
258
|
vm.expectRevert(
|
|
259
|
-
abi.encodeWithSelector(
|
|
260
|
-
JBRouterTerminalRegistry.JBRouterTerminalRegistry_TerminalNotSet.selector, projectId
|
|
261
|
-
)
|
|
259
|
+
abi.encodeWithSelector(JBRouterTerminalRegistry.JBRouterTerminalRegistry_TerminalNotSet.selector, projectId)
|
|
262
260
|
);
|
|
263
261
|
registry.lockTerminalFor(projectId);
|
|
264
262
|
}
|
|
@@ -283,11 +281,7 @@ contract RouterTerminalRegistryTest is Test {
|
|
|
283
281
|
registry.setDefaultTerminal(terminalA);
|
|
284
282
|
|
|
285
283
|
// Mock the terminal's pay to return 100.
|
|
286
|
-
vm.mockCall(
|
|
287
|
-
address(terminalA),
|
|
288
|
-
abi.encodeWithSelector(IJBTerminal.pay.selector),
|
|
289
|
-
abi.encode(uint256(100))
|
|
290
|
-
);
|
|
284
|
+
vm.mockCall(address(terminalA), abi.encodeWithSelector(IJBTerminal.pay.selector), abi.encode(uint256(100)));
|
|
291
285
|
|
|
292
286
|
// Send native tokens.
|
|
293
287
|
vm.deal(address(this), 1 ether);
|
|
@@ -313,11 +307,7 @@ contract RouterTerminalRegistryTest is Test {
|
|
|
313
307
|
registry.setDefaultTerminal(terminalA);
|
|
314
308
|
|
|
315
309
|
// Mock the terminal's addToBalanceOf.
|
|
316
|
-
vm.mockCall(
|
|
317
|
-
address(terminalA),
|
|
318
|
-
abi.encodeWithSelector(IJBTerminal.addToBalanceOf.selector),
|
|
319
|
-
abi.encode()
|
|
320
|
-
);
|
|
310
|
+
vm.mockCall(address(terminalA), abi.encodeWithSelector(IJBTerminal.addToBalanceOf.selector), abi.encode());
|
|
321
311
|
|
|
322
312
|
// Send native tokens.
|
|
323
313
|
vm.deal(address(this), 1 ether);
|