@pendle/core-v2 4.5.1-beta-2 → 4.5.1-beta-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.
Files changed (104) hide show
  1. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleERC20WithSupplyCapSY.sol/PendleERC20WithSupplyCapSY.dbg.json +1 -1
  2. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleERC20WithSupplyCapSY.sol/PendleERC20WithSupplyCapSY.json +2 -2
  3. package/build/artifacts/contracts/core/StandardizedYield/implementations/Swell/PendleSwellRswETHStakingSY.sol/PendleSwellRswETHStakingSY.dbg.json +4 -0
  4. package/build/artifacts/contracts/core/StandardizedYield/implementations/Swell/PendleSwellRswETHStakingSY.sol/PendleSwellRswETHStakingSY.json +1049 -0
  5. package/build/artifacts/contracts/core/StandardizedYield/implementations/Swell/PendleSwellStakingERC20SY.sol/PendleSwellStakingERC20SY.dbg.json +4 -0
  6. package/build/artifacts/contracts/core/StandardizedYield/implementations/Swell/PendleSwellStakingERC20SY.sol/PendleSwellStakingERC20SY.json +1039 -0
  7. package/build/artifacts/contracts/interfaces/IPActionMiscV3.sol/IPActionMiscV3.dbg.json +1 -1
  8. package/build/artifacts/contracts/interfaces/IPActionMiscV3.sol/IPActionMiscV3.json +36 -2
  9. package/build/artifacts/contracts/interfaces/IPAllActionV3.sol/IPAllActionV3.dbg.json +1 -1
  10. package/build/artifacts/contracts/interfaces/IPAllActionV3.sol/IPAllActionV3.json +36 -2
  11. package/build/artifacts/contracts/interfaces/IPGovernanceProxy.sol/IPGovernanceProxy.dbg.json +4 -0
  12. package/build/artifacts/contracts/interfaces/IPGovernanceProxy.sol/IPGovernanceProxy.json +60 -0
  13. package/build/artifacts/contracts/interfaces/IPPausingInterface.sol/IPPausingInterface.dbg.json +4 -0
  14. package/build/artifacts/contracts/interfaces/IPPausingInterface.sol/IPPausingInterface.json +25 -0
  15. package/build/artifacts/contracts/interfaces/IPPtLpOracle.sol/IPPtLpOracle.dbg.json +1 -1
  16. package/build/artifacts/contracts/interfaces/Swell/ISwellSimpleStakingERC20.sol/ISwellSimpleStakingERC20.dbg.json +4 -0
  17. package/build/artifacts/contracts/interfaces/Swell/ISwellSimpleStakingERC20.sol/ISwellSimpleStakingERC20.json +207 -0
  18. package/build/artifacts/contracts/offchain-helpers/PendleGovernanceProxy.sol/PendleGovernanceProxy.dbg.json +4 -0
  19. package/build/artifacts/contracts/offchain-helpers/PendleGovernanceProxy.sol/PendleGovernanceProxy.json +401 -0
  20. package/build/artifacts/contracts/offchain-helpers/PendlePoolDeployHelper.sol/PendlePoolDeployHelper.dbg.json +1 -1
  21. package/build/artifacts/contracts/offchain-helpers/PendlePoolDeployHelper.sol/PendlePoolDeployHelper.json +2 -2
  22. package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionMarketAuxStatic.sol/ActionMarketAuxStatic.dbg.json +1 -1
  23. package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionMarketAuxStatic.sol/ActionMarketAuxStatic.json +2 -2
  24. package/build/artifacts/contracts/oracles/PendleLpOracleLib.sol/PendleLpOracleLib.dbg.json +1 -1
  25. package/build/artifacts/contracts/oracles/PendlePtLpOracle.sol/PendlePtLpOracle.dbg.json +1 -1
  26. package/build/artifacts/contracts/oracles/PendlePtOracleLib.sol/PendlePtOracleLib.dbg.json +1 -1
  27. package/build/artifacts/contracts/oracles/samples/BoringLpGlpOracle.sol/BoringLpGlpOracle.dbg.json +1 -1
  28. package/build/artifacts/contracts/oracles/samples/BoringPtUsdChainlinkOracle.sol/BoringPtUsdChainlinkOracle.dbg.json +1 -1
  29. package/build/artifacts/contracts/router/ActionAddRemoveLiqV3.sol/ActionAddRemoveLiqV3.dbg.json +1 -1
  30. package/build/artifacts/contracts/router/ActionAddRemoveLiqV3.sol/ActionAddRemoveLiqV3.json +2 -2
  31. package/build/artifacts/contracts/router/ActionMiscV3.sol/ActionMiscV3.dbg.json +1 -1
  32. package/build/artifacts/contracts/router/ActionMiscV3.sol/ActionMiscV3.json +38 -4
  33. package/build/artifacts/contracts/router/ActionSwapPTV3.sol/ActionSwapPTV3.dbg.json +1 -1
  34. package/build/artifacts/contracts/router/ActionSwapPTV3.sol/ActionSwapPTV3.json +2 -2
  35. package/build/artifacts/contracts/router/ActionSwapYTV3.sol/ActionSwapYTV3.dbg.json +1 -1
  36. package/build/artifacts/contracts/router/ActionSwapYTV3.sol/ActionSwapYTV3.json +2 -2
  37. package/build/artifacts/contracts/router/Reflector.sol/Reflector.dbg.json +4 -0
  38. package/build/artifacts/contracts/router/Reflector.sol/Reflector.json +39 -0
  39. package/build/artifacts/contracts/router/base/ActionBase.sol/ActionBase.dbg.json +1 -1
  40. package/contracts/core/StandardizedYield/implementations/PendleERC20WithSupplyCapSY.sol +6 -1
  41. package/contracts/core/StandardizedYield/implementations/Swell/PendleSwellRswETHStakingSY.sol +56 -0
  42. package/contracts/core/StandardizedYield/implementations/Swell/PendleSwellStakingERC20SY.sol +111 -0
  43. package/contracts/interfaces/IPActionMiscV3.sol +8 -2
  44. package/contracts/interfaces/IPGovernanceProxy.sol +14 -0
  45. package/contracts/interfaces/IPPausingInterface.sol +8 -0
  46. package/contracts/interfaces/Swell/ISwellSimpleStakingERC20.sol +66 -0
  47. package/contracts/offchain-helpers/PendleGovernanceProxy.sol +84 -0
  48. package/contracts/offchain-helpers/router-static/base/ActionMarketAuxStatic.sol +12 -4
  49. package/contracts/router/ActionMiscV3.sol +42 -3
  50. package/contracts/router/Reflector.sol +61 -0
  51. package/contracts/router/base/ActionBase.sol +0 -16
  52. package/deployments/1-markets/EZETH-MAINNET-SEP2024.json +11 -0
  53. package/deployments/1-markets/PUFETH-MAINNET-SEP2024.json +11 -0
  54. package/deployments/1-markets/RSETH-MAINNET-SEP2024.json +11 -0
  55. package/deployments/1-markets/RSWETH-SWELL-STAKING-MAINNET-JUL2024.json +11 -0
  56. package/deployments/1-markets/SUSDE-MAINNET-SEP2024.json +13 -0
  57. package/deployments/1-markets/UNIETH-MAINNET-SEP2024.json +13 -0
  58. package/deployments/1-markets/WEETH-MAINNET-SEP2024.json +11 -0
  59. package/deployments/42161-core.json +1 -1
  60. package/deployments/42161-markets/EZETH-ARB-SEP2024.json +11 -0
  61. package/deployments/42161-markets/RSETH-ARBITRUM-SEP2024.json +11 -0
  62. package/deployments/42161-markets/SILO-PTEETH-ARBITRUM-JUNE2024.json +11 -0
  63. package/deployments/42161-markets/SILO-PTEZETH-ARBITRUM-JUNE2024.json +11 -0
  64. package/deployments/42161-markets/WEETH-ARB-SEP2024.json +11 -0
  65. package/deployments/56-markets/WEETH-BSC-SEP2024.json +11 -0
  66. package/package.json +2 -2
  67. package/typechain-types/ActionMiscV3.ts +50 -6
  68. package/typechain-types/BoringPYUsdChainlinkAssetOracle.ts +244 -0
  69. package/typechain-types/BoringPYUsdChainlinkSYOracle.ts +243 -0
  70. package/typechain-types/IPActionMiscV3.ts +50 -6
  71. package/typechain-types/IPAllActionV3.ts +50 -6
  72. package/typechain-types/IPGovernanceProxy.ts +142 -0
  73. package/typechain-types/IPPYLpOracle.ts +379 -0
  74. package/typechain-types/IPPausingInterface.ts +112 -0
  75. package/typechain-types/IPossibleSupplyCapInterface.ts +142 -0
  76. package/typechain-types/PendleGovernanceProxy.ts +603 -0
  77. package/typechain-types/PendlePYLpOracle.ts +612 -0
  78. package/typechain-types/Reflector.ts +98 -0
  79. package/typechain-types/SupplyCapReader.ts +105 -0
  80. package/typechain-types/factories/ActionAddRemoveLiqV3__factory.ts +1 -1
  81. package/typechain-types/factories/ActionMarketAuxStatic__factory.ts +1 -1
  82. package/typechain-types/factories/ActionMiscV3__factory.ts +37 -3
  83. package/typechain-types/factories/ActionSwapPTV3__factory.ts +1 -1
  84. package/typechain-types/factories/ActionSwapYTV3__factory.ts +1 -1
  85. package/typechain-types/factories/BoringPYUsdChainlinkAssetOracle__factory.ts +269 -0
  86. package/typechain-types/factories/BoringPYUsdChainlinkSYOracle__factory.ts +267 -0
  87. package/typechain-types/factories/IPActionMiscV3__factory.ts +36 -2
  88. package/typechain-types/factories/IPAllActionV3__factory.ts +36 -2
  89. package/typechain-types/factories/IPGovernanceProxy__factory.ts +75 -0
  90. package/typechain-types/factories/IPPYLpOracle__factory.ts +214 -0
  91. package/typechain-types/factories/IPPausingInterface__factory.ts +40 -0
  92. package/typechain-types/factories/IPossibleSupplyCapInterface__factory.ts +82 -0
  93. package/typechain-types/factories/PendleERC20WithSupplyCapSY__factory.ts +1 -1
  94. package/typechain-types/factories/PendleGovernanceProxy__factory.ts +458 -0
  95. package/typechain-types/factories/PendlePYLpOracle__factory.ts +487 -0
  96. package/typechain-types/factories/PendlePoolDeployHelper__factory.ts +1 -1
  97. package/typechain-types/factories/PendleSwellRswETHStakingSY__factory.ts +1 -1
  98. package/typechain-types/factories/Reflector__factory.ts +89 -0
  99. package/typechain-types/factories/SupplyCapReader__factory.ts +88 -0
  100. package/typechain-types/hardhat.d.ts +81 -0
  101. package/typechain-types/index.ts +18 -0
  102. /package/deployments/1-markets/{EZETH-JUNE2024.json → EZETH-APR2024.json} +0 -0
  103. /package/deployments/42161-markets/{RSETH-MAY2024.json → RSETH-JUNE2024.json} +0 -0
  104. /package/deployments/42161-markets/{WEETH-MAY2024.json → WEETH-JUNE2024.json} +0 -0
@@ -0,0 +1,111 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ pragma solidity ^0.8.17;
3
+
4
+ import "../../SYBase.sol";
5
+ import "../../../../interfaces/Swell/ISwellSimpleStakingERC20.sol";
6
+
7
+ contract PendleSwellStakingERC20SY is SYBase {
8
+ using ArrayLib for address[];
9
+
10
+ address public constant SWELL_STAKING = 0x38D43a6Cb8DA0E855A42fB6b0733A0498531d774;
11
+
12
+ // solhint-disable immutable-vars-naming
13
+ address public immutable stakeToken;
14
+
15
+ constructor(string memory _name, string memory _symbol, address _stakeToken) SYBase(_name, _symbol, _stakeToken) {
16
+ stakeToken = _stakeToken;
17
+ _safeApproveInf(_stakeToken, SWELL_STAKING);
18
+ }
19
+
20
+ /*///////////////////////////////////////////////////////////////
21
+ DEPOSIT/REDEEM USING BASE TOKENS
22
+ //////////////////////////////////////////////////////////////*/
23
+
24
+ function _deposit(
25
+ address tokenIn,
26
+ uint256 amountDeposited
27
+ ) internal virtual override returns (uint256 /*amountSharesOut*/) {
28
+ if (tokenIn != stakeToken) {
29
+ amountDeposited = _wrapToStakeToken(tokenIn, amountDeposited);
30
+ }
31
+ ISwellSimpleStakingERC20(SWELL_STAKING).deposit(stakeToken, amountDeposited, address(this));
32
+ return amountDeposited;
33
+ }
34
+
35
+ function _redeem(
36
+ address receiver,
37
+ address /*tokenOut*/,
38
+ uint256 amountSharesToRedeem
39
+ ) internal virtual override returns (uint256 /*amountTokenOut*/) {
40
+ ISwellSimpleStakingERC20(SWELL_STAKING).withdraw(stakeToken, amountSharesToRedeem, receiver);
41
+ return amountSharesToRedeem;
42
+ }
43
+
44
+ /*///////////////////////////////////////////////////////////////
45
+ EXCHANGE-RATE
46
+ //////////////////////////////////////////////////////////////*/
47
+ function exchangeRate() public view virtual override returns (uint256) {
48
+ return PMath.ONE;
49
+ }
50
+
51
+ /*///////////////////////////////////////////////////////////////
52
+ MISC FUNCTIONS FOR METADATA
53
+ //////////////////////////////////////////////////////////////*/
54
+
55
+ function _previewDeposit(address tokenIn, uint256 amountTokenToDeposit) internal view override returns (uint256) {
56
+ if (tokenIn == stakeToken) {
57
+ return amountTokenToDeposit;
58
+ }
59
+ return _previewToStakeToken(tokenIn, amountTokenToDeposit);
60
+ }
61
+
62
+ function _previewRedeem(
63
+ address /*tokenOut*/,
64
+ uint256 amountSharesToRedeem
65
+ ) internal pure override returns (uint256 /*amountTokenOut*/) {
66
+ return amountSharesToRedeem;
67
+ }
68
+
69
+ function getTokensIn() public view virtual override returns (address[] memory) {
70
+ return ArrayLib.create(stakeToken).merge(_getAdditionalTokens());
71
+ }
72
+
73
+ function getTokensOut() public view virtual override returns (address[] memory) {
74
+ return ArrayLib.create(stakeToken);
75
+ }
76
+
77
+ function isValidTokenIn(address token) public view virtual override returns (bool) {
78
+ return token == stakeToken || _canWrapToStakeToken(token);
79
+ }
80
+
81
+ function isValidTokenOut(address token) public view virtual override returns (bool) {
82
+ return token == stakeToken;
83
+ }
84
+
85
+ function assetInfo()
86
+ external
87
+ view
88
+ virtual
89
+ returns (AssetType assetType, address assetAddress, uint8 assetDecimals)
90
+ {
91
+ return (AssetType.TOKEN, stakeToken, IERC20Metadata(stakeToken).decimals());
92
+ }
93
+
94
+ /*///////////////////////////////////////////////////////////////
95
+ ADDITIONAL TOKEN IN FUNCTIONS
96
+ //////////////////////////////////////////////////////////////*/
97
+
98
+ function _getAdditionalTokens() internal view virtual returns (address[] memory) {}
99
+
100
+ function _previewToStakeToken(address, uint256) internal view virtual returns (uint256) {
101
+ assert(false);
102
+ }
103
+
104
+ function _wrapToStakeToken(address, uint256) internal virtual returns (uint256) {
105
+ assert(false);
106
+ }
107
+
108
+ function _canWrapToStakeToken(address) internal view virtual returns (bool) {
109
+ return false;
110
+ }
111
+ }
@@ -105,7 +105,7 @@ interface IPActionMiscV3 {
105
105
  address indexed market,
106
106
  address indexed token,
107
107
  address receiver,
108
- uint256 netLpToRemove,
108
+ uint256 netLpIn,
109
109
  uint256 totalTokenOut,
110
110
  ExitPreExpReturnParams params
111
111
  );
@@ -114,7 +114,7 @@ interface IPActionMiscV3 {
114
114
  address indexed caller,
115
115
  address indexed market,
116
116
  address indexed receiver,
117
- uint256 netLpToRemove,
117
+ uint256 netLpIn,
118
118
  ExitPreExpReturnParams params
119
119
  );
120
120
 
@@ -235,6 +235,12 @@ interface IPActionMiscV3 {
235
235
  uint256 minSyOut
236
236
  ) external returns (ExitPostExpReturnParams memory params);
237
237
 
238
+ function multicallAlpha(
239
+ address payable reflector,
240
+ bytes calldata selfCall,
241
+ bytes calldata reflectCall
242
+ ) external payable returns (bytes memory selfRes, bytes memory reflectRes);
243
+
238
244
  function boostMarkets(address[] memory markets) external;
239
245
 
240
246
  function multicall(Call3[] calldata calls) external payable returns (Result[] memory res);
@@ -0,0 +1,14 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ pragma solidity ^0.8.0;
3
+
4
+ interface IPGovernanceProxy {
5
+ struct Call {
6
+ address target;
7
+ uint256 value;
8
+ bytes callData;
9
+ }
10
+
11
+ function pause(address[] calldata addrs) external;
12
+
13
+ function aggregate(Call[] calldata calls) external payable returns (bytes[] memory rtnData);
14
+ }
@@ -0,0 +1,8 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ pragma solidity ^0.8.0;
3
+
4
+ interface IPPausingInterface {
5
+ function pause() external;
6
+
7
+ function unpause() external;
8
+ }
@@ -0,0 +1,66 @@
1
+ // SPDX-License-Identifier: UNLICENSED
2
+ pragma solidity ^0.8.0;
3
+
4
+ interface ISwellSimpleStakingERC20 {
5
+ /// @notice Struct to hold the supported booleans
6
+ /// @param deposit true if deposit is supported
7
+ /// @param withdraw true if withdraw is supported
8
+ struct Supported {
9
+ bool deposit;
10
+ bool withdraw;
11
+ }
12
+
13
+ /// @notice Error emitted when the amount is null
14
+ error AMOUNT_NULL();
15
+
16
+ /// @notice Error emitted when the address is null
17
+ error ADDRESS_NULL();
18
+
19
+ /// @notice Error emitted when the balance is insufficient
20
+ error INSUFFICIENT_BALANCE();
21
+
22
+ /// @notice Error emitted when the token is not allowed
23
+ error TOKEN_NOT_ALLOWED(address token);
24
+
25
+ /// @notice Event emitted when a token is added or removed
26
+ /// @param token address of the token
27
+ /// @param supported struct with deposit and withdraw booleans
28
+ event SupportedToken(address indexed token, Supported supported);
29
+
30
+ /// @notice Event emitted when a deposit is made
31
+ /// @param token address of the token
32
+ /// @param staker address of the staker
33
+ /// @param amount amount of the deposit
34
+ event Deposit(address indexed token, address indexed staker, uint256 amount);
35
+
36
+ /// @notice Event emitted when a withdrawal is made
37
+ /// @param token address of the token
38
+ /// @param staker address of the staker
39
+ /// @param amount amount of the withdrawal
40
+ event Withdraw(address indexed token, address indexed staker, uint256 amount);
41
+
42
+ /// @notice Method to deposit tokens
43
+ /// @dev token are transferred from the sender, and the receiver is credited
44
+ /// @param _token address of the token
45
+ /// @param _amount amount to deposit
46
+ /// @param _receiver address of the receiver
47
+ function deposit(address _token, uint256 _amount, address _receiver) external;
48
+
49
+ /// @notice Method to rescue tokens, only callable by the owner
50
+ /// @dev difference between balance and internal balance is transferred to the owner
51
+ /// @param _token address of the token
52
+ function rescueERC20(address _token) external;
53
+
54
+ /// @notice Method to add or remove a token
55
+ /// @dev only callable by the owner
56
+ /// @param _token address of the token
57
+ /// @param _supported struct with deposit and withdraw booleans
58
+ function supportToken(address _token, Supported calldata _supported) external;
59
+
60
+ /// @notice Method to rescue tokens, only callable by the owner
61
+ /// @dev token are transferred to the receiver and sender is credited
62
+ /// @param _token address of the token
63
+ /// @param _amount amount to withdraw
64
+ /// @param _receiver address of the receiver
65
+ function withdraw(address _token, uint256 _amount, address _receiver) external;
66
+ }
@@ -0,0 +1,84 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.23;
3
+
4
+ import "../interfaces/IPPausingInterface.sol";
5
+ import "../interfaces/IPGovernanceProxy.sol";
6
+ import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
7
+ import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
8
+
9
+ // solhint-disable custom-errors
10
+ // solhint-disable no-inline-assembly
11
+ // solhint-disable no-empty-blocks
12
+
13
+ contract PendleGovernanceProxy is AccessControlUpgradeable, UUPSUpgradeable, IPGovernanceProxy {
14
+ bytes32 public constant GUARDIAN = keccak256("GUARDIAN");
15
+
16
+ modifier onlyGuardian() {
17
+ require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender) || hasRole(GUARDIAN, msg.sender), "not authorized");
18
+ _;
19
+ }
20
+
21
+ modifier onlyAdmin() {
22
+ require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "not authorized");
23
+ _;
24
+ }
25
+
26
+ constructor() {
27
+ _disableInitializers();
28
+ }
29
+
30
+ /*///////////////////////////////////////////////////////////////
31
+ PAUSING
32
+ //////////////////////////////////////////////////////////////*/
33
+
34
+ function pause(address[] calldata addrs) external onlyGuardian {
35
+ uint256 length = addrs.length;
36
+ for (uint256 i = 0; i < length; ) {
37
+ IPPausingInterface(addrs[i]).pause();
38
+ unchecked {
39
+ ++i;
40
+ }
41
+ }
42
+ }
43
+
44
+ /*///////////////////////////////////////////////////////////////
45
+ ADMIN CALL
46
+ //////////////////////////////////////////////////////////////*/
47
+
48
+ function aggregate(
49
+ IPGovernanceProxy.Call[] calldata calls
50
+ ) external payable onlyAdmin returns (bytes[] memory rtnData) {
51
+ uint256 length = calls.length;
52
+ rtnData = new bytes[](length);
53
+
54
+ Call calldata call;
55
+ for (uint256 i = 0; i < length; ) {
56
+ call = calls[i];
57
+
58
+ (bool success, bytes memory resp) = call.target.call{value: call.value}(call.callData);
59
+ if (!success) {
60
+ assembly {
61
+ revert(add(32, resp), mload(resp))
62
+ }
63
+ }
64
+
65
+ rtnData[i] = resp;
66
+
67
+ unchecked {
68
+ ++i;
69
+ }
70
+ }
71
+ }
72
+
73
+ receive() external payable {}
74
+
75
+ /*///////////////////////////////////////////////////////////////
76
+ UPGRADABLE RELATED
77
+ //////////////////////////////////////////////////////////////*/
78
+
79
+ function initialize(address governance) external initializer {
80
+ _grantRole(DEFAULT_ADMIN_ROLE, governance);
81
+ }
82
+
83
+ function _authorizeUpgrade(address) internal view override onlyAdmin {}
84
+ }
@@ -114,12 +114,20 @@ contract ActionMarketAuxStatic is IPActionMarketAuxStatic {
114
114
  function getLpToAssetRate(address market) public view returns (uint256) {
115
115
  MarketState memory state = _readState(market);
116
116
  PYIndex pyIndexCurrent = _pyIndex(market);
117
- MarketPreCompute memory comp = state.getMarketPreCompute(pyIndexCurrent, block.timestamp);
118
117
 
119
- int256 totalHypotheticalAsset = comp.totalAsset +
120
- state.totalPt.mulDown(int256(_getPtToAssetRate(market, state, pyIndexCurrent)));
118
+ int256 totalHypotheticalAsset;
119
+ if (state.expiry <= block.timestamp) {
120
+ // 1 PT = 1 Asset post-expiry
121
+ totalHypotheticalAsset = state.totalPt + pyIndexCurrent.syToAsset(state.totalSy);
122
+ } else {
123
+ MarketPreCompute memory comp = state.getMarketPreCompute(pyIndexCurrent, block.timestamp);
124
+
125
+ totalHypotheticalAsset =
126
+ comp.totalAsset +
127
+ state.totalPt.mulDown(int256(_getPtToAssetRate(market, state, pyIndexCurrent)));
128
+ }
121
129
 
122
- return uint256(totalHypotheticalAsset.divDown(state.totalLp));
130
+ return totalHypotheticalAsset.divDown(state.totalLp).Uint();
123
131
  }
124
132
 
125
133
  function getPtToAssetRate(address market) public view returns (uint256) {
@@ -3,6 +3,7 @@ pragma solidity ^0.8.17;
3
3
 
4
4
  import "./base/ActionBase.sol";
5
5
  import "../interfaces/IPActionMiscV3.sol";
6
+ import "./Reflector.sol";
6
7
 
7
8
  contract ActionMiscV3 is IPActionMiscV3, ActionBase {
8
9
  function mintSyFromToken(
@@ -116,8 +117,6 @@ contract ActionMiscV3 is IPActionMiscV3, ActionBase {
116
117
  netTokenOut = IStandardizedYield(SY).redeem(receiver, netSyInterm, tokenRedeemSy, minTokenOut, true);
117
118
  }
118
119
 
119
- // TODO: need to allow exit to SY as well
120
- // TODO: check against minOut
121
120
  // double check event orders
122
121
 
123
122
  function exitPreExpToToken(
@@ -173,7 +172,7 @@ contract ActionMiscV3 is IPActionMiscV3, ActionBase {
173
172
  }
174
173
 
175
174
  if (netPtIn > 0) {
176
- _transferIn(address(PT), address(this), netPtIn);
175
+ _transferIn(address(PT), msg.sender, netPtIn);
177
176
  }
178
177
 
179
178
  p.netPyRedeem = PMath.min(p.netPtFromRemove + netPtIn, netYtIn);
@@ -252,6 +251,17 @@ contract ActionMiscV3 is IPActionMiscV3, ActionBase {
252
251
  p.totalSyOut = p.netSyFromRemove + p.netSyFromRedeem;
253
252
  }
254
253
 
254
+ function multicallAlpha(
255
+ address payable reflector,
256
+ bytes calldata selfCall,
257
+ bytes calldata reflectCall
258
+ ) external payable returns (bytes memory selfRes, bytes memory reflectRes) {
259
+ (, selfRes) = _delegateToSelf(selfCall, false);
260
+ reflectRes = _callToReflector(reflector, reflectCall);
261
+
262
+ // ? We don't need to check balance here, can trust SDK?
263
+ }
264
+
255
265
  // ----------------- MISC FUNCTIONS -----------------
256
266
 
257
267
  function boostMarkets(address[] memory markets) external {
@@ -273,4 +283,33 @@ contract ActionMiscV3 is IPActionMiscV3, ActionBase {
273
283
  (bool success, bytes memory result) = target.delegatecall(data);
274
284
  revert Errors.SimulationResults(success, result);
275
285
  }
286
+
287
+ function _delegateToSelf(
288
+ bytes memory data,
289
+ bool allowFailure
290
+ ) internal returns (bool success, bytes memory result) {
291
+ (success, result) = address(this).delegatecall(data);
292
+
293
+ if (!success && !allowFailure) {
294
+ assembly {
295
+ // We use Yul's revert() to bubble up errors from the target contract.
296
+ revert(add(32, result), mload(result))
297
+ }
298
+ }
299
+ }
300
+
301
+ function _callToReflector(address payable reflector, bytes memory data) internal returns (bytes memory result) {
302
+ // TODO: should we allow arbitrary passing?
303
+ // TODO: is the payable necessary?
304
+
305
+ bool success;
306
+ (success, result) = Reflector(reflector).reflect(data);
307
+
308
+ if (!success) {
309
+ assembly {
310
+ // We use Yul's revert() to bubble up errors from the target contract.
311
+ revert(add(32, result), mload(result))
312
+ }
313
+ }
314
+ }
276
315
  }
@@ -0,0 +1,61 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ pragma solidity ^0.8.17;
3
+
4
+ import "../interfaces/IPAllActionV3.sol";
5
+ import "../core/libraries/TokenHelper.sol";
6
+
7
+ contract Reflector is TokenHelper {
8
+ using SafeERC20 for IERC20;
9
+
10
+ mapping(address => bool) internal approved;
11
+
12
+ receive() external payable {}
13
+
14
+ function reflect(bytes calldata inputData) external returns (bool success, bytes memory result) {
15
+ (uint256 value, bytes memory newCalldata) = _process1(inputData);
16
+ (success, result) = msg.sender.call{value: value}(newCalldata);
17
+ }
18
+
19
+ function _process1(bytes calldata inputData) internal returns (uint256 value, bytes memory newCalldata) {
20
+ bytes4 selector = bytes4(inputData[:4]);
21
+ bytes calldata data = inputData[4:];
22
+
23
+ // TODO: can we do nicer here?
24
+ if (selector == IPActionAddRemoveLiqV3.addLiquiditySingleToken.selector) {
25
+ (
26
+ address v1,
27
+ address v2,
28
+ uint256 v3,
29
+ ApproxParams memory v4,
30
+ TokenInput memory v5,
31
+ LimitOrderData memory v6
32
+ ) = abi.decode(data, (address, address, uint256, ApproxParams, TokenInput, LimitOrderData));
33
+
34
+ value = _process2(v5);
35
+ newCalldata = abi.encodeWithSelector(selector, v1, v2, v3, v4, v5, v6);
36
+ _safeApproveInf(v5.tokenIn, msg.sender);
37
+ } else if (selector == IPActionAddRemoveLiqV3.addLiquiditySingleTokenKeepYt.selector) {
38
+ (address v1, address v2, uint256 v3, uint256 v4, TokenInput memory v5) = abi.decode(
39
+ data,
40
+ (address, address, uint256, uint256, TokenInput)
41
+ );
42
+
43
+ value = _process2(v5);
44
+ newCalldata = abi.encodeWithSelector(selector, v1, v2, v3, v4, v5);
45
+ } else {
46
+ revert("UNSUPPORTED_SELECTOR");
47
+ }
48
+ }
49
+
50
+ function _process2(TokenInput memory inp) internal returns (uint256 ethValue) {
51
+ assert(inp.swapData.swapType == SwapType.NONE);
52
+
53
+ inp.netTokenIn = _selfBalance(inp.tokenIn);
54
+ ethValue = inp.tokenIn == NATIVE ? inp.netTokenIn : 0;
55
+
56
+ if (inp.tokenIn != NATIVE && !approved[inp.tokenIn]) {
57
+ IERC20(inp.tokenIn).safeApprove(msg.sender, type(uint256).max);
58
+ approved[inp.tokenIn] = true;
59
+ }
60
+ }
61
+ }
@@ -373,20 +373,4 @@ abstract contract ActionBase is TokenHelper, CallbackHelper, IPLimitOrderType {
373
373
  function _isEmptyLimit(LimitOrderData calldata a) internal pure returns (bool) {
374
374
  return a.normalFills.length == 0 && a.flashFills.length == 0;
375
375
  }
376
-
377
- // ----------------- DELEGATE CALL -----------------
378
-
379
- function _delegateToSelf(
380
- bytes memory data,
381
- bool allowFailure
382
- ) internal returns (bool success, bytes memory result) {
383
- (success, result) = address(this).delegatecall(data);
384
-
385
- if (!success && !allowFailure) {
386
- assembly {
387
- // We use Yul's revert() to bubble up errors from the target contract.
388
- revert(add(32, result), mload(result))
389
- }
390
- }
391
- }
392
376
  }
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "SY ezETH",
3
+ "SY": "0x22E12A50e3ca49FB183074235cB1db84Fe4C716D",
4
+ "YT": "0x1623F1A991584A6b69baBbdbffD26E2B46485465",
5
+ "PT": "0x248241244356D18f63d0c16082996839ecB0C7bF",
6
+ "market": "0xcDBD5ff3E03b6828Db9C32e2131A60ABA5137901",
7
+ "expiry": 1727308800,
8
+ "scalarRoot": "7728447732000000000",
9
+ "initAnchor": "1116672357000000000",
10
+ "lnFeeRateRoot": "2995508979000000"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "SY pufETH",
3
+ "SY": "0x253008ba4aE2f3E6488DC998a5321D4EB1a0c905",
4
+ "YT": "0x1a65eB80a2ac3ea6E41D456DdD6E9cC5728BEf7C",
5
+ "PT": "0xd4e75971eAF78a8d93D96df530f1FFf5f9F53288",
6
+ "market": "0xA54FC268101c8b97DE19eF3141d34751a11996B2",
7
+ "expiry": 1727308800,
8
+ "scalarRoot": "7770558179000000000",
9
+ "initAnchor": "1110275954000000000",
10
+ "lnFeeRateRoot": "2995508979000000"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "SY rsETH",
3
+ "SY": "0x730A5E2AcEbccAA5e9095723B3CB862739DA793c",
4
+ "YT": "0xE653E4048620E546AFff02D3689678896d22e236",
5
+ "PT": "0x7bAf258049cc8B9A78097723dc19a8b103D4098F",
6
+ "market": "0x6b4740722e46048874d84306B2877600ABCea3Ae",
7
+ "expiry": 1727308800,
8
+ "scalarRoot": "7770558179000000000",
9
+ "initAnchor": "1110275954000000000",
10
+ "lnFeeRateRoot": "2995508979000000"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "SY rswETH",
3
+ "SY": "0x4f3A7a07A968B67F1f9692b70242f10E665d38Ad",
4
+ "YT": "0xf0E4244Ca93Ac36752DA5939Afd9CB73B0637b06",
5
+ "PT": "0x0a0E172511114456EC63A85FF32E45C5e0E27D63",
6
+ "market": "0x1e0c2e41f3165ff6B8a660092f63E10BC0EebE26",
7
+ "expiry": 1721865600,
8
+ "scalarRoot": "8113474588000000000",
9
+ "initAnchor": "1061316437000000000",
10
+ "lnFeeRateRoot": "2995508979000000"
11
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "SUSDE-MAINNET-SEP2024",
3
+ "SY": "0x4139cDC6345aFFbaC0692b43bed4D059Df3e6d65",
4
+ "YT": "0xdc02b77a3986da62C7A78FED73949C9767850809",
5
+ "PT": "0x6c9f097e044506712B58EAC670c9a5fd4BCceF13",
6
+ "market": "0xd1D7D99764f8a52Aff007b7831cc02748b2013b5",
7
+ "expiry": 1727308800,
8
+ "lnFeeRateRoot": "2995508979000000",
9
+ "scalarRoot": "8580934398000000000",
10
+ "initAnchor": "1120006408000000000",
11
+ "doCacheIndexSameBlock": true,
12
+ "deployTxHash": "0x467c0c15148778d0b99a1d9f3bd7406fd0c58d8a6e3284a57a50e55ae0160165"
13
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "UNIETH-MAINNET-SEP2024",
3
+ "SY": "0xc430dB19339A3051192233B4c49f9aB3DC6D16b7",
4
+ "YT": "0xdF74bA4436478969A54eCB352093312fE97EBAa5",
5
+ "PT": "0x15fA86404BFbA8b46684552F792558128bFB6418",
6
+ "market": "0xBaE2Df4DfCd0c613018D6056A40077F2d1eFf28A",
7
+ "expiry": 1727308800,
8
+ "lnFeeRateRoot": "2995508979000000",
9
+ "scalarRoot": "7770558179000000000",
10
+ "initAnchor": "1110275954000000000",
11
+ "doCacheIndexSameBlock": true,
12
+ "deployTxHash": "0x4e509feb8502bee0c719c1a9eb2c73c9e1b070fc8424e1f4f31618bdc764a560"
13
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "SY weETH",
3
+ "SY": "0xAC0047886a985071476a1186bE89222659970d65",
4
+ "YT": "0xA54Df645A042D24121a737dAA89a57EbF8E0b71c",
5
+ "PT": "0x1c085195437738d73d75DC64bC5A3E098b7f93b1",
6
+ "market": "0xC8eDd52D0502Aa8b4D5C77361D4B3D300e8fC81c",
7
+ "expiry": 1727308800,
8
+ "scalarRoot": "7728447732000000000",
9
+ "initAnchor": "1116672357000000000",
10
+ "lnFeeRateRoot": "2995508979000000"
11
+ }
@@ -19,7 +19,7 @@
19
19
  "PENDLE": "0x0c880f6761F1af8d9Aa9C466984b80DAb9a8c9e8",
20
20
  "yieldContractFactory": "0x28dE02Ac3c3F5ef427e55c321F73fDc7F192e8E4",
21
21
  "marketFactory": "0xf5a7De2D276dbda3EEf1b62A9E718EFf4d29dDC8",
22
- "router": "0x888888888889758F76e7103c6CbF23ABbF58F946",
22
+ "router": "0xaBbCC1E99687b2d5B6db8bC5dD8904B142Eaf04b",
23
23
  "routerStatic": "0xAdB09F65bd90d19e3148D9ccb693F3161C6DB3E8",
24
24
  "pendleSwap": "0x63a45E0B2686F7be77Bb85735c35704D1046459a",
25
25
  "routerHelper": "0x462206b11d185ef6F64B41D344325401C37EC335",
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "SY ezETH",
3
+ "SY": "0x0dE802e3D6Cc9145A150bBDc8da9F988a98c5202",
4
+ "YT": "0xE58AfaA6E2abF9A9F243D5A55Bd5447628c4D811",
5
+ "PT": "0x2CCFce9bE49465CC6f947b5F6aC9383673733Da9",
6
+ "market": "0x35f3dB08a6e9cB4391348b0B404F493E7ae264c0",
7
+ "expiry": 1727308800,
8
+ "scalarRoot": "7728447732000000000",
9
+ "initAnchor": "1116672357000000000",
10
+ "lnFeeRateRoot": "2995508979000000"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "SY rsETH",
3
+ "SY": "0xf176fB51F4eB826136a54FDc71C50fCd2202E272",
4
+ "YT": "0x2FDc424946AA72D42E2F897447d7c335E64845F0",
5
+ "PT": "0x30c98c0139B62290E26aC2a2158AC341Dcaf1333",
6
+ "market": "0x1d38d4204159aA5e767aFbA8f76BE22117De61E5",
7
+ "expiry": 1727308800,
8
+ "scalarRoot": "7770558179000000000",
9
+ "initAnchor": "1110275954000000000",
10
+ "lnFeeRateRoot": "29999550000000"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "SY sETH-pteETHSilo",
3
+ "SY": "0xd0c4351a18F40b96b6446Da3A191496DF36d60F9",
4
+ "YT": "0x7Cfb81E9c9402D48c6F3161204a21800b210BAeA",
5
+ "PT": "0x2D5405688f253D741a9F1090DD90D8A285CF5C79",
6
+ "market": "0x6aBE9Ac2df48490693BdB9d66Fa898fc9cD7cc36",
7
+ "expiry": 1719446400,
8
+ "scalarRoot": "10324763686000000000",
9
+ "initAnchor": "1041846750000000000",
10
+ "lnFeeRateRoot": "499875041000000"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "SY sETH-ptezETHSilo",
3
+ "SY": "0x8242F81F7B06C1e67bC80DFD2B2716f58bD46651",
4
+ "YT": "0x8138E8cAC470Dc963437b055834B54D56d6d6a29",
5
+ "PT": "0xd7e810aEd2988B8A7eA0187d55C939110b178521",
6
+ "market": "0xCf602767e9c82194DaF58EB67a3169d60DbAaC62",
7
+ "expiry": 1719446400,
8
+ "scalarRoot": "10324763686000000000",
9
+ "initAnchor": "1041846750000000000",
10
+ "lnFeeRateRoot": "499875041000000"
11
+ }