@pendle/core-v2 2.8.0-mainnet → 2.8.2-mainnet

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 (28) hide show
  1. package/build/artifacts/contracts/core/StandardizedYield/implementations/UniV2/PendleUniV2Base.sol/PendleCamelotV1Base.dbg.json +4 -0
  2. package/build/artifacts/contracts/core/StandardizedYield/implementations/UniV2/PendleUniV2Base.sol/PendleCamelotV1Base.json +63 -0
  3. package/build/artifacts/contracts/interfaces/ICamelotPair.sol/ICamelotPair.dbg.json +4 -0
  4. package/build/artifacts/contracts/interfaces/ICamelotPair.sol/ICamelotPair.json +716 -0
  5. package/build/artifacts/contracts/interfaces/ICamelotRouter.sol/ICamelotRouter.dbg.json +4 -0
  6. package/build/artifacts/contracts/interfaces/ICamelotRouter.sol/ICamelotRouter.json +647 -0
  7. package/contracts/core/StandardizedYield/implementations/BalancerStable/base/PendleAuraBalancerStableLPSYV2.sol +31 -10
  8. package/contracts/offchain-helpers/PendleMulticallV1.sol +61 -0
  9. package/deployments/1-markets/BALANCER-LP-AURA-STAFI-RETH-WETH-JUNE-27-2024.json +5 -5
  10. package/deployments/1-offchain-helper.json +1 -1
  11. package/deployments/42161-core.json +3 -3
  12. package/deployments/42161-offchain-helper.json +1 -1
  13. package/package.json +1 -1
  14. package/typechain-types/ICamelotPair.ts +972 -0
  15. package/typechain-types/ICamelotRouter.ts +955 -0
  16. package/typechain-types/PendleCamelotV1Base.ts +120 -0
  17. package/typechain-types/factories/ICamelotPair__factory.ts +728 -0
  18. package/typechain-types/factories/ICamelotRouter__factory.ts +662 -0
  19. package/typechain-types/factories/PendleCamelotV1Base__factory.ts +78 -0
  20. package/typechain-types/hardhat.d.ts +27 -99
  21. package/typechain-types/index.ts +6 -22
  22. package/contracts/offchain-helpers/PendleMulticall.sol +0 -26
  23. /package/deployments/1-markets/{BALANCER-LP-AURA-ANKRETH-WETH-MARCH-28-2024.json → deprecated/BALANCER-LP-AURA-ANKRETH-WETH-MARCH-28-2024.json} +0 -0
  24. /package/deployments/1-markets/{BALANCER-LP-AURA-RETH-WETH-28DEC.json → deprecated/BALANCER-LP-AURA-RETH-WETH-28DEC.json} +0 -0
  25. /package/deployments/1-markets/{BALANCER-LP-AURA-WSTETH-WETH-JUN272024.json → deprecated/BALANCER-LP-AURA-WSTETH-WETH-JUN272024.json} +0 -0
  26. /package/deployments/1-markets/{FRAXUSDC-CURVELP-MARCH30.json → deprecated/FRAXUSDC-CURVELP-MARCH30.json} +0 -0
  27. /package/deployments/1-markets/{LOOKS-STAKING-MARCH30.json → deprecated/LOOKS-STAKING-MARCH30.json} +0 -0
  28. /package/deployments/1-markets/{STETH-MARCH30.json → deprecated/STETH-MARCH30.json} +0 -0
@@ -21,6 +21,7 @@ abstract contract PendleAuraBalancerStableLPSYV2 is SYBaseWithRewards {
21
21
  address internal constant AURA_TOKEN = 0xC0c293ce456fF0ED870ADd98a0828Dd4d2903DBF;
22
22
  address internal constant AURA_BOOSTER = 0xA57b8d98dAE62B26Ec3bcC4a365338157060B234;
23
23
  address internal constant BALANCER_VAULT = 0xBA12222222228d8Ba445958a75a0704d566BF2C8;
24
+ uint256 internal constant DEFAULT_GAS_REENTRANCY_CHECK = 7000;
24
25
 
25
26
  address public immutable balLp;
26
27
  bytes32 public immutable balPoolId;
@@ -30,6 +31,7 @@ abstract contract PendleAuraBalancerStableLPSYV2 is SYBaseWithRewards {
30
31
 
31
32
  IBalancerStablePreview public immutable previewHelper;
32
33
 
34
+ uint256 public gasForReentrancyCheck;
33
35
  address[] public extraRewards;
34
36
 
35
37
  constructor(
@@ -53,6 +55,7 @@ abstract contract PendleAuraBalancerStableLPSYV2 is SYBaseWithRewards {
53
55
  }
54
56
 
55
57
  previewHelper = _previewHelper;
58
+ gasForReentrancyCheck = DEFAULT_GAS_REENTRANCY_CHECK;
56
59
  }
57
60
 
58
61
  function _getPoolInfo(uint256 _auraPid)
@@ -108,19 +111,32 @@ abstract contract PendleAuraBalancerStableLPSYV2 is SYBaseWithRewards {
108
111
  return IRateProvider(balLp).getRate();
109
112
  }
110
113
 
111
- /// @dev The `manageUserBalance` function is a non-view function that includes a reentrancy guard.
112
- /// When it is called by `staticcall`, one of two cases can occur:
113
- /// 1. The function passes the reentrancy guard. In this scenario, the `status` variable is set to 2,
114
- /// causing the EVM to panic (since the sub-call is a `staticcall`), resulting in a revert with
115
- /// no response (i.e., `response.length == 0`).
116
- /// 2. The function does not pass the reentrancy guard. In this situation, it reverts due to
117
- /// error `BAL#400`, which means that `response.length = 100.`
118
- /// To prevent read-only reentrancy, we simply need to verify that the revert corresponds to case 1,
119
- /// rather than case 2. checking `response.length == 0` is sufficient.
114
+ /*
115
+ * The `manageUserBalance` function is a non-view function that includes a reentrancy guard
116
+ in the form of `_require(_status != _ENTERED, Errors.REENTRANCY);`. To prevent
117
+ read-only reentrancy, it's important to ensure that our `manageUserBalance` has enough gas
118
+ to reach this check, so that it can fail if necessary.
119
+
120
+ * On the way to the check, there's at most one `COLD_SLOAD` plus miscellaneous decoding &
121
+ require, which we've found through testing to cost no more than 3200 gas. Therefore,
122
+ attaching 7000 gas should guarantee that it's always possible to reach the check.
123
+
124
+ * Once we've reached the check, one of two scenarios can occur:
125
+ 1. The call doesn't pass the check, and reverts with error `BAL#400` ⇒ `response.length = 100`.
126
+ 2. The call passes the check. Then, the call can either:
127
+ a. continue on to set the `status` variable to 2, causing the EVM to revert (since
128
+ the sub-call is a `staticcall`), and `response.length == 0`
129
+ b. run out of gas, which will also lead to a revert with `response.length == 0`
130
+ In both cases, to differentiate between 1 and 2, we check `response.length != 0`. If it's
131
+ true, then it's a read-only reentrancy. Otherwise, we're good (and we can ignore
132
+ differentiating between 2a and 2b).
133
+ */
120
134
  function _checkBalancerReadOnlyReentrancy() internal view {
121
135
  IVault.UserBalanceOp[] memory noop = new IVault.UserBalanceOp[](0);
122
136
 
123
- (bool isSuccess, bytes memory response) = BALANCER_VAULT.staticcall(
137
+ (bool isSuccess, bytes memory response) = BALANCER_VAULT.staticcall{
138
+ gas: gasForReentrancyCheck
139
+ }(
124
140
  abi.encodeWithSignature(
125
141
  "manageUserBalance((uint8,address,uint256,address,address)[])",
126
142
  noop
@@ -131,6 +147,11 @@ abstract contract PendleAuraBalancerStableLPSYV2 is SYBaseWithRewards {
131
147
  if (response.length != 0) revert Errors.SYBalancerReentrancy();
132
148
  }
133
149
 
150
+ function setGasForReentrancyCheck(uint256 newGas) external onlyOwner {
151
+ require(newGas >= DEFAULT_GAS_REENTRANCY_CHECK, "lower than default");
152
+ gasForReentrancyCheck = newGas;
153
+ }
154
+
134
155
  /*///////////////////////////////////////////////////////////////
135
156
  BALANCER-RELATED FUNCTIONS
136
157
  //////////////////////////////////////////////////////////////*/
@@ -0,0 +1,61 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity 0.8.17;
3
+
4
+ contract PendleMulticallV1 {
5
+ struct Call {
6
+ address target;
7
+ bytes callData;
8
+ }
9
+
10
+ struct Result {
11
+ bool success;
12
+ bytes returnData;
13
+ }
14
+
15
+ function aggregate(Call[] calldata calls) public payable virtual {
16
+ uint256 length = calls.length;
17
+ Call calldata call;
18
+ for (uint256 i = 0; i < length; ) {
19
+ call = calls[i];
20
+
21
+ (bool success, bytes memory resp) = call.target.call(call.callData);
22
+ if (!success) {
23
+ assembly {
24
+ revert(add(32, resp), mload(resp))
25
+ }
26
+ }
27
+
28
+ unchecked {
29
+ ++i;
30
+ }
31
+ }
32
+ }
33
+
34
+ function tryAggregate(
35
+ bool requireSuccess,
36
+ uint256 gasLimit,
37
+ Call[] calldata calls
38
+ ) public payable returns (Result[] memory returnData) {
39
+ uint256 length = calls.length;
40
+ returnData = new Result[](length);
41
+ Call calldata call;
42
+ for (uint256 i = 0; i < length; ) {
43
+ call = calls[i];
44
+
45
+ (bool success, bytes memory resp) = call.target.call{ gas: gasLimit }(
46
+ calls[i].callData
47
+ );
48
+ if (!success && requireSuccess) {
49
+ assembly {
50
+ revert(add(32, resp), mload(resp))
51
+ }
52
+ }
53
+
54
+ returnData[i] = Result(success, resp);
55
+
56
+ unchecked {
57
+ ++i;
58
+ }
59
+ }
60
+ }
61
+ }
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "SY Stafi rETH-WETH_BalancerLP Aura",
3
- "SY": "0x35BE86140EEC53Da42C265ae764E547df13891c3",
4
- "YT": "0xa57FEEDBd31F4ebD7761d5c3aeED7DeCCb8F95eE",
5
- "PT": "0x1abfE281466Dc43Ba5e2A7282661735c00BF82DE",
6
- "market": "0xB15a55519dBc3D770ddED079ebcDeEea69A49AdE",
3
+ "SY": "0x677885afde857b70f40741ff8B60F9aFbA95Dd49",
4
+ "YT": "0xCfD3A9e44957D5996663b58B69A79978CcFa778f",
5
+ "PT": "0xF77205F5A1eEab54555B13B231fa5e4e0Cf2fC1c",
6
+ "market": "0xd1434df1E2Ad0Cb7B3701a751D01981c7Cf2Dd62",
7
7
  "expiry": 1719446400,
8
- "bulkSeller": "0x6C4aC4B209Cc57B019b83F6771794D3C73BC47Af",
8
+ "bulkSeller": "0xD7c9e1B4f21cA8e192d831496f09938b4eda7790",
9
9
  "scalarRoot": "25304300000000000000",
10
10
  "initAnchor": "1139984000000000000"
11
11
  }
@@ -1,4 +1,4 @@
1
1
  {
2
- "multicall": "0x0E7cacc6C2A22Aa2D97a42a8C82edaF9F9eac259",
2
+ "multicall": "0xfd6Df9EFACfEfdF4E610d687A9c9b941D1b1Bf75",
3
3
  "implicitSwapfeeContract": "0x43D03031FAb845065e9CEfE89Dd122d63F72011F"
4
4
  }
@@ -19,9 +19,9 @@
19
19
  "marketFactory": "0xf5a7De2D276dbda3EEf1b62A9E718EFf4d29dDC8",
20
20
  "router": "0x0000000001e4ef00d069e71d6ba041b0a16f7ea0",
21
21
  "routerStatic": "0xAdB09F65bd90d19e3148D9ccb693F3161C6DB3E8",
22
- "pendleSwap": "0xDa78D46C4133EA548386e64eaca26FC456F71D2d",
22
+ "pendleSwap": "0xF0bF560F01d4196773a5c58A09d6D34b6bba4503",
23
+ "routerHelper": "0x462206b11d185ef6F64B41D344325401C37EC335",
23
24
  "receiverEndpoint": "0xC9215ae9EC67385F38C755D862C8eE3702B5793A",
24
25
  "vePendle": "0x3209E9412cca80B18338f2a56ADA59c484c39644",
25
- "gaugeController": "0x1e56299ebc8a1010cec26005d12e3e5c5cc2db00",
26
- "routerHelper": "0x462206b11d185ef6F64B41D344325401C37EC335"
26
+ "gaugeController": "0x1e56299ebc8a1010cec26005d12e3e5c5cc2db00"
27
27
  }
@@ -1,4 +1,4 @@
1
1
  {
2
- "multicall": "0x05d0Ea1dBFA239f9fBC47E306e850Ce971Fe632d",
2
+ "multicall": "0xfd6Df9EFACfEfdF4E610d687A9c9b941D1b1Bf75",
3
3
  "implicitSwapfeeContract": "0x704478Dd72FD7F9B83d1F1e0fc18C14B54F034d0"
4
4
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@pendle/core-v2",
3
3
  "description": "Core smart contracts of Pendle Protocol.",
4
4
  "license": "BUSL-1.1",
5
- "version": "2.8.0-mainnet",
5
+ "version": "2.8.2-mainnet",
6
6
  "homepage": "https://pendle.finance",
7
7
  "keywords": [
8
8
  "pendle",