@pendle/core-v2 2.12.0-mainnet → 2.13.0-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.
@@ -19,16 +19,20 @@ import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
19
19
  */
20
20
  contract CamelotRewardHelper is TokenHelper, ICamelotNFTHandler {
21
21
  uint256 internal constant POSITION_UNINITIALIZED = type(uint256).max;
22
- uint256 internal constant MINIMUM_LIQUIDITY = 10**3;
22
+ uint256 internal constant MINIMUM_LIQUIDITY = 10 ** 3;
23
23
  bytes4 internal constant _ERC721_RECEIVED = 0x150b7a02;
24
24
 
25
+ uint256 public YIELD_BOOSTER_STATUS = 1;
26
+
27
+
25
28
  address public immutable nftPool;
26
29
  address public immutable nitroPool;
27
- address public immutable yieldBooster;
28
30
  address public immutable GRAIL;
29
31
  address public immutable xGRAIL;
30
32
  uint256 public positionId = POSITION_UNINITIALIZED;
31
33
 
34
+ address public yieldBooster;
35
+
32
36
  error InvalidTokenId(uint256 tokenId, uint256 positionId);
33
37
 
34
38
  modifier ensureValidTokenId(uint256 tokenId) {
@@ -44,10 +48,9 @@ contract CamelotRewardHelper is TokenHelper, ICamelotNFTHandler {
44
48
  nftPool = ICamelotNitroPool(nitroPool).nftPool();
45
49
  GRAIL = ICamelotNitroPool(nitroPool).grailToken();
46
50
  xGRAIL = ICamelotNitroPool(nitroPool).xGrailToken();
47
- yieldBooster = ICamelotNFTPool(nftPool).yieldBooster();
48
51
 
49
52
  _safeApproveInf(_lp, nftPool);
50
- IXGrail(xGRAIL).approveUsage(yieldBooster, type(uint256).max);
53
+ _updateYieldBoosterAddress();
51
54
  }
52
55
 
53
56
  /**
@@ -57,19 +60,33 @@ contract CamelotRewardHelper is TokenHelper, ICamelotNFTHandler {
57
60
  * We decided to go with the second option (keep allocating xGRAIL to boost APR)
58
61
  */
59
62
  function _allocateXGrail() internal {
63
+ if (YIELD_BOOSTER_STATUS == 2) return; // Yield booster update pending
64
+
60
65
  uint256 amount = _selfBalance(xGRAIL);
61
66
  if (amount == 0) return;
62
67
 
63
68
  // there should be no reward without minimum liquidity minted
64
69
  assert(positionId != POSITION_UNINITIALIZED);
65
70
 
66
- IXGrail(xGRAIL).allocate(yieldBooster, amount, abi.encode(nftPool, positionId));
71
+ IXGrail(xGRAIL).allocate(yieldBooster, amount, _getAllocationData());
72
+ }
73
+
74
+ function _prepareForReallocation() internal {
75
+ uint256 amountAllocated = IXGrail(xGRAIL).usageAllocations(address(this), yieldBooster);
76
+ IXGrail(xGRAIL).deallocate(yieldBooster, amountAllocated, _getAllocationData());
77
+ IXGrail(xGRAIL).approveUsage(yieldBooster, 0);
78
+ YIELD_BOOSTER_STATUS = 2;
67
79
  }
68
80
 
69
- function _increaseNftPoolPosition(uint256 amountLp)
70
- internal
71
- returns (uint256 amountLpAccountedForUser)
72
- {
81
+ function _finalizeReallocation() internal {
82
+ YIELD_BOOSTER_STATUS = 1;
83
+ _updateYieldBoosterAddress();
84
+ _allocateXGrail();
85
+ }
86
+
87
+ function _increaseNftPoolPosition(
88
+ uint256 amountLp
89
+ ) internal returns (uint256 amountLpAccountedForUser) {
73
90
  // first time minting from this contract
74
91
  if (positionId == POSITION_UNINITIALIZED) {
75
92
  positionId = ICamelotNFTPool(nftPool).lastTokenId() + 1;
@@ -101,6 +118,15 @@ contract CamelotRewardHelper is TokenHelper, ICamelotNFTHandler {
101
118
  ICamelotNitroPool(nitroPool).withdraw(positionId);
102
119
  }
103
120
 
121
+ function _updateYieldBoosterAddress() private {
122
+ yieldBooster = ICamelotNFTPool(nftPool).yieldBooster();
123
+ IXGrail(xGRAIL).approveUsage(yieldBooster, type(uint256).max);
124
+ }
125
+
126
+ function _getAllocationData() private view returns (bytes memory) {
127
+ return abi.encode(nftPool, positionId);
128
+ }
129
+
104
130
  /**
105
131
  * ==================================================================
106
132
  * CAMELOT NFT RELATED
@@ -205,6 +205,14 @@ contract PendleCamelotV1VolatileSY is
205
205
  OWNER ONLY FUNCTIONS
206
206
  //////////////////////////////////////////////////////////////*/
207
207
 
208
+ function prepareForReallocation() external onlyOwner {
209
+ _prepareForReallocation();
210
+ }
211
+
212
+ function finalizeReallocation() external onlyOwner {
213
+ _finalizeReallocation();
214
+ }
215
+
208
216
  /// @dev Use emergencyWithdraw to ensure LP withdrawal is always successful
209
217
  function setRewardDisabled(bool doRewardIndexUpdate) external onlyOwner {
210
218
  if (doRewardIndexUpdate) _updateRewardIndex();
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "SY PENDLE-ETH_Camelot",
3
+ "SY": "0x4665d514e82B2F9c78Fa2B984e450F33d9efc842",
4
+ "YT": "0xA728C4d0D94A42B3E87458E55595A919f3d84b99",
5
+ "PT": "0x4C1C121849B8AcE08E037EF620552476852F2212",
6
+ "market": "0x0BE708c78166183f12DE9aFa134Fd091F26D4210",
7
+ "expiry": 1719446400,
8
+ "scalarRoot": "5388097000000000000",
9
+ "initAnchor": "1485252000000000000"
10
+ }
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.12.0-mainnet",
5
+ "version": "2.13.0-mainnet",
6
6
  "homepage": "https://pendle.finance",
7
7
  "keywords": [
8
8
  "pendle",
@@ -1,10 +0,0 @@
1
- {
2
- "name": "SY PENDLE-ETH_Camelot",
3
- "SY": "0xA972fB7828f0bff8a22f7f8C63b17cfB971BFC0a",
4
- "YT": "0x9Bb47fF1AdE2bC22c9F0761560063bAa3Df883B5",
5
- "PT": "0x877b050d26a780bB43642171859434FdF496F1aE",
6
- "market": "0xc85910daF21367Cc293eB82876d094C31583b0B7",
7
- "expiry": 1719446400,
8
- "scalarRoot": "5388097000000000000",
9
- "initAnchor": "1485252000000000000"
10
- }