@bananapus/suckers-v6 0.0.60 → 0.0.62
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/README.md +12 -7
- package/package.json +3 -3
- package/src/JBSucker.sol +1 -1
- package/src/libraries/JBSwapLib.sol +15 -15
package/README.md
CHANGED
|
@@ -2,13 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
`@bananapus/suckers-v6` provides cross-chain bridging for Juicebox project tokens and the terminal assets that back them. A pair of suckers lets users burn on one chain, move value across a bridge, and mint the same project token representation on another chain.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
|
|
6
|
+
## Documentation
|
|
7
|
+
|
|
8
|
+
- [INVARIANTS.md](./INVARIANTS.md) — guarantees this code enforces at runtime, organized by user/operator/contract.
|
|
9
|
+
- [ARCHITECTURE.md](./ARCHITECTURE.md) — system layout, contract responsibilities, and the bridge-variant taxonomy.
|
|
10
|
+
- [ADMINISTRATION.md](./ADMINISTRATION.md) — change-management posture, Safe-controlled surfaces, and operational roles.
|
|
11
|
+
- [RISKS.md](./RISKS.md) — bridge-flavored risk register: AMB trust, merkle progression, mapping, deprecation, atomicity.
|
|
12
|
+
- [USER_JOURNEYS.md](./USER_JOURNEYS.md) — end-to-end flows for token holders, operators, and integrators.
|
|
13
|
+
- [AUDIT_INSTRUCTIONS.md](./AUDIT_INSTRUCTIONS.md) — scope, entrypoints, and reading order for security review.
|
|
14
|
+
- [SKILLS.md](./SKILLS.md) — reusable patterns and gotchas distilled from this codebase.
|
|
15
|
+
- [STYLE_GUIDE.md](./STYLE_GUIDE.md) — Solidity conventions used across this repo.
|
|
16
|
+
- [CHANGELOG.md](./CHANGELOG.md) — versioned change history.
|
|
12
17
|
|
|
13
18
|
The codebase includes multiple bridge variants, but the canonical deployment and discovery tooling in this repo is narrower than the full runtime surface. Treat the deployment scripts and helper libraries as the source of truth for what is operationally supported today.
|
|
14
19
|
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bananapus/suckers-v6",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.62",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/Bananapus/nana-suckers-v6"
|
|
7
|
+
"url": "git+https://github.com/Bananapus/nana-suckers-v6.git"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"foundry.toml",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@arbitrum/nitro-contracts": "3.2.0",
|
|
29
|
-
"@bananapus/core-v6": "^0.0.
|
|
29
|
+
"@bananapus/core-v6": "^0.0.72",
|
|
30
30
|
"@bananapus/permission-ids-v6": "^0.0.27",
|
|
31
31
|
"@chainlink/contracts-ccip": "1.6.4",
|
|
32
32
|
"@chainlink/local": "0.2.7",
|
package/src/JBSucker.sol
CHANGED
|
@@ -360,7 +360,7 @@ abstract contract JBSucker is ERC2771Context, JBPermissioned, Initializable, ERC
|
|
|
360
360
|
|
|
361
361
|
/// @notice Emergency escape hatch: lets a user reclaim their project tokens and terminal tokens on the chain they
|
|
362
362
|
/// originally deposited from, when the bridge has become permanently non-functional. Must be enabled by the project
|
|
363
|
-
/// owner via
|
|
363
|
+
/// owner via `enableEmergencyHatchFor`.
|
|
364
364
|
/// @param claimData The terminal token, merkle tree leaf, and proof for the claim.
|
|
365
365
|
function exitThroughEmergencyHatch(JBClaim calldata claimData) external override {
|
|
366
366
|
// Does all the needed validation to ensure that the claim is valid *and* that claiming through the emergency
|
|
@@ -9,19 +9,19 @@ import {TickMath} from "@uniswap/v3-core/contracts/libraries/TickMath.sol";
|
|
|
9
9
|
/// @dev Uses continuous sigmoid formula for smooth slippage tolerance across all swap sizes.
|
|
10
10
|
library JBSwapLib {
|
|
11
11
|
/// @notice The denominator used for slippage tolerance basis points.
|
|
12
|
-
uint256 internal constant
|
|
12
|
+
uint256 internal constant _SLIPPAGE_DENOMINATOR = 10_000;
|
|
13
13
|
|
|
14
14
|
/// @notice The maximum slippage ceiling (88%).
|
|
15
|
-
uint256 internal constant
|
|
15
|
+
uint256 internal constant _MAX_SLIPPAGE = 8800;
|
|
16
16
|
|
|
17
17
|
/// @notice The precision multiplier for impact calculations.
|
|
18
18
|
/// @dev Using 1e18 instead of 1e5 gives 13 extra orders of magnitude,
|
|
19
19
|
/// preventing small-swap-in-deep-pool impacts from rounding to zero.
|
|
20
|
-
uint256 internal constant
|
|
20
|
+
uint256 internal constant _IMPACT_PRECISION = 1e18;
|
|
21
21
|
|
|
22
|
-
/// @notice The K parameter for the sigmoid curve, scaled to match
|
|
22
|
+
/// @notice The K parameter for the sigmoid curve, scaled to match _IMPACT_PRECISION.
|
|
23
23
|
/// @dev K_new = 5000 * 1e18 / 1e5 = 5e16
|
|
24
|
-
uint256 internal constant
|
|
24
|
+
uint256 internal constant _SIGMOID_K = 5e16;
|
|
25
25
|
|
|
26
26
|
//*********************************************************************//
|
|
27
27
|
// -------------------- Slippage Tolerance -------------------------- //
|
|
@@ -29,22 +29,22 @@ library JBSwapLib {
|
|
|
29
29
|
|
|
30
30
|
/// @notice Compute a continuous sigmoid slippage tolerance based on swap impact and pool fee.
|
|
31
31
|
/// @dev tolerance = minSlippage + (maxSlippage - minSlippage) * impact / (impact + K)
|
|
32
|
-
/// @param impact The estimated price impact from calculateImpact (scaled by
|
|
32
|
+
/// @param impact The estimated price impact from calculateImpact (scaled by _IMPACT_PRECISION).
|
|
33
33
|
/// @param poolFeeBps The pool fee in basis points (e.g., 30 for 0.3%).
|
|
34
|
-
/// @return tolerance The slippage tolerance in basis points of
|
|
34
|
+
/// @return tolerance The slippage tolerance in basis points of _SLIPPAGE_DENOMINATOR.
|
|
35
35
|
function getSlippageTolerance(uint256 impact, uint256 poolFeeBps) internal pure returns (uint256) {
|
|
36
|
-
if (poolFeeBps >=
|
|
36
|
+
if (poolFeeBps >= _MAX_SLIPPAGE) return _MAX_SLIPPAGE;
|
|
37
37
|
|
|
38
38
|
uint256 minSlippage = poolFeeBps + 100;
|
|
39
39
|
if (minSlippage < 200) minSlippage = 200;
|
|
40
|
-
if (minSlippage >=
|
|
40
|
+
if (minSlippage >= _MAX_SLIPPAGE) return _MAX_SLIPPAGE;
|
|
41
41
|
|
|
42
42
|
if (impact == 0) return minSlippage;
|
|
43
43
|
|
|
44
|
-
if (impact > type(uint256).max -
|
|
44
|
+
if (impact > type(uint256).max - _SIGMOID_K) return _MAX_SLIPPAGE;
|
|
45
45
|
|
|
46
|
-
uint256 range =
|
|
47
|
-
uint256 tolerance = minSlippage + mulDiv({x: range, y: impact, denominator: impact +
|
|
46
|
+
uint256 range = _MAX_SLIPPAGE - minSlippage;
|
|
47
|
+
uint256 tolerance = minSlippage + mulDiv({x: range, y: impact, denominator: impact + _SIGMOID_K});
|
|
48
48
|
|
|
49
49
|
return tolerance;
|
|
50
50
|
}
|
|
@@ -53,12 +53,12 @@ library JBSwapLib {
|
|
|
53
53
|
// -------------------- Impact Calculation -------------------------- //
|
|
54
54
|
//*********************************************************************//
|
|
55
55
|
|
|
56
|
-
/// @notice Estimate the price impact of a swap, scaled by
|
|
56
|
+
/// @notice Estimate the price impact of a swap, scaled by _IMPACT_PRECISION.
|
|
57
57
|
/// @param amountIn The amount of tokens to swap in.
|
|
58
58
|
/// @param liquidity The pool's in-range liquidity.
|
|
59
59
|
/// @param sqrtP The sqrt price in Q96 format.
|
|
60
60
|
/// @param zeroForOne Whether the swap is token0 -> token1.
|
|
61
|
-
/// @return impact The estimated price impact scaled by
|
|
61
|
+
/// @return impact The estimated price impact scaled by _IMPACT_PRECISION.
|
|
62
62
|
function calculateImpact(
|
|
63
63
|
uint256 amountIn,
|
|
64
64
|
uint128 liquidity,
|
|
@@ -71,7 +71,7 @@ library JBSwapLib {
|
|
|
71
71
|
{
|
|
72
72
|
if (liquidity == 0 || sqrtP == 0) return 0;
|
|
73
73
|
|
|
74
|
-
uint256 base = mulDiv({x: amountIn, y:
|
|
74
|
+
uint256 base = mulDiv({x: amountIn, y: _IMPACT_PRECISION, denominator: uint256(liquidity)});
|
|
75
75
|
|
|
76
76
|
impact = zeroForOne
|
|
77
77
|
? mulDiv({x: base, y: uint256(sqrtP), denominator: uint256(1) << 96})
|