@pendle/core-v2 0.5.1-beta-5 → 0.6.2
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/contracts/SuperComposableYield/ISuperComposableYield.sol +2 -0
- package/contracts/SuperComposableYield/implementations/RewardManager.sol +35 -20
- package/contracts/SuperComposableYield/implementations/SCYBase.sol +39 -19
- package/contracts/SuperComposableYield/implementations/SCYBaseWithRewards.sol +26 -14
- package/contracts/core/PendleBaseToken.sol +2 -2
- package/contracts/core/PendleMarket.sol +145 -61
- package/contracts/core/PendleMarketFactory.sol +30 -19
- package/contracts/core/{PendleOwnershipToken.sol → PendlePrincipalToken.sol} +14 -2
- package/contracts/core/PendleRouter.sol +23 -9
- package/contracts/core/PendleSCYImpl/AaveV3/PendleAaveV3SCY.sol +21 -20
- package/contracts/core/PendleSCYImpl/PendleBenQiErc20SCY.sol +22 -16
- package/contracts/core/PendleSCYImpl/PendleBtrflySCY.sol +13 -13
- package/contracts/core/PendleSCYImpl/PendleStETHSCY.sol +107 -0
- package/contracts/core/PendleSCYImpl/PendleYearnVaultSCY.sol +14 -15
- package/contracts/core/PendleYieldContractFactory.sol +29 -14
- package/contracts/core/PendleYieldToken.sol +130 -76
- package/contracts/core/RouterStatic.sol +51 -51
- package/contracts/core/actions/ActionCallback.sol +36 -18
- package/contracts/core/actions/ActionCore.sol +41 -88
- package/contracts/core/actions/ActionRedeem.sol +36 -0
- package/contracts/core/actions/ActionYT.sol +41 -59
- package/contracts/core/actions/base/{ActionSCYAndOTBase.sol → ActionSCYAndPTBase.sol} +59 -45
- package/contracts/core/actions/base/{ActionSCYAndYOBase.sol → ActionSCYAndPYBase.sol} +57 -19
- package/contracts/core/actions/base/ActionSCYAndYTBase.sol +31 -21
- package/contracts/interfaces/IPActionCore.sol +21 -28
- package/contracts/interfaces/IPActionRedeem.sol +17 -0
- package/contracts/interfaces/IPActionYT.sol +5 -12
- package/contracts/interfaces/IPAllAction.sol +2 -2
- package/contracts/interfaces/IPMarket.sol +33 -10
- package/contracts/interfaces/IPMarketAddRemoveCallback.sol +2 -2
- package/contracts/interfaces/IPMarketFactory.sol +3 -1
- package/contracts/interfaces/IPMarketSwapCallback.sol +1 -1
- package/contracts/interfaces/{IPOwnershipToken.sol → IPPrincipalToken.sol} +1 -1
- package/contracts/interfaces/IPRouterStatic.sol +19 -19
- package/contracts/interfaces/IPYieldContractFactory.sol +10 -2
- package/contracts/interfaces/IPYieldToken.sol +14 -5
- package/contracts/interfaces/IWstETH.sol +10 -0
- package/contracts/libraries/JoeLibrary.sol +1 -1
- package/contracts/libraries/math/LogExpMath.sol +1 -1
- package/contracts/libraries/math/MarketApproxLib.sol +128 -88
- package/contracts/libraries/math/MarketMathAux.sol +13 -13
- package/contracts/libraries/math/MarketMathCore.sol +62 -93
- package/contracts/libraries/math/Math.sol +14 -2
- package/contracts/periphery/PendleGovernanceManager.sol +5 -3
- package/package.json +3 -2
- package/typechain-types/IPRouterStatic.ts +480 -0
- package/typechain-types/RouterStatic.ts +484 -4
- package/typechain-types/factories/IPRouterStatic__factory.ts +616 -0
- package/typechain-types/factories/PendleRouter__factory.ts +1 -1
- package/typechain-types/factories/RouterStatic__factory.ts +619 -3
- package/typechain-types/ActionSCYAndYOBase.ts +0 -223
- package/typechain-types/PendleRouterRedeemUpg.ts +0 -125
- package/typechain-types/factories/ActionSCYAndYOBase__factory.ts +0 -200
- package/typechain-types/factories/PendleRouterRedeemUpg__factory.ts +0 -112
|
@@ -4,6 +4,6 @@ pragma solidity 0.8.9;
|
|
|
4
4
|
|
|
5
5
|
import "./IPActionCore.sol";
|
|
6
6
|
import "./IPActionYT.sol";
|
|
7
|
-
import "./
|
|
7
|
+
import "./IPActionRedeem.sol";
|
|
8
8
|
|
|
9
|
-
interface IPAllAction is IPActionCore, IPActionYT {}
|
|
9
|
+
interface IPAllAction is IPActionCore, IPActionYT, IPActionRedeem {}
|
|
@@ -2,47 +2,70 @@
|
|
|
2
2
|
pragma solidity 0.8.9;
|
|
3
3
|
|
|
4
4
|
import "./IPBaseToken.sol";
|
|
5
|
-
import "./
|
|
5
|
+
import "./IPPrincipalToken.sol";
|
|
6
6
|
import "./IPYieldToken.sol";
|
|
7
7
|
import "../libraries/math/MarketMathCore.sol";
|
|
8
8
|
|
|
9
9
|
interface IPMarket is IPBaseToken {
|
|
10
|
+
event AddLiquidity(
|
|
11
|
+
address indexed receiver,
|
|
12
|
+
uint256 lpToAccount,
|
|
13
|
+
uint256 scyUsed,
|
|
14
|
+
uint256 ptUsed
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
event RemoveLiquidity(
|
|
18
|
+
address indexed receiver,
|
|
19
|
+
uint256 lpRemoved,
|
|
20
|
+
uint256 scyToAccount,
|
|
21
|
+
uint256 ptToAccount
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
event Swap(
|
|
25
|
+
address indexed receiver,
|
|
26
|
+
int256 ptToAccount,
|
|
27
|
+
int256 scyToAccount,
|
|
28
|
+
uint256 netScyToReserve
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
event UpdateImpliedRate(uint256 indexed timestamp, uint256 lnLastImpliedRate);
|
|
32
|
+
|
|
10
33
|
function addLiquidity(
|
|
11
34
|
address receiver,
|
|
12
35
|
uint256 scyDesired,
|
|
13
|
-
uint256
|
|
36
|
+
uint256 ptDesired,
|
|
14
37
|
bytes calldata data
|
|
15
38
|
)
|
|
16
39
|
external
|
|
17
40
|
returns (
|
|
18
41
|
uint256 lpToAccount,
|
|
19
42
|
uint256 scyUsed,
|
|
20
|
-
uint256
|
|
43
|
+
uint256 ptUsed
|
|
21
44
|
);
|
|
22
45
|
|
|
23
46
|
function removeLiquidity(
|
|
24
47
|
address receiver,
|
|
25
48
|
uint256 lpToRemove,
|
|
26
49
|
bytes calldata data
|
|
27
|
-
) external returns (uint256 scyToAccount, uint256
|
|
50
|
+
) external returns (uint256 scyToAccount, uint256 ptToAccount);
|
|
28
51
|
|
|
29
|
-
function
|
|
52
|
+
function swapExactPtForScy(
|
|
30
53
|
address receiver,
|
|
31
|
-
uint256
|
|
54
|
+
uint256 exactPtIn,
|
|
32
55
|
uint256 minScyOut,
|
|
33
56
|
bytes calldata data
|
|
34
57
|
) external returns (uint256 netScyOut, uint256 netScyToReserve);
|
|
35
58
|
|
|
36
|
-
function
|
|
59
|
+
function swapScyForExactPt(
|
|
37
60
|
address receiver,
|
|
38
|
-
uint256
|
|
61
|
+
uint256 exactPtOut,
|
|
39
62
|
uint256 maxScyIn,
|
|
40
63
|
bytes calldata data
|
|
41
64
|
) external returns (uint256 netScyIn, uint256 netScyToReserve);
|
|
42
65
|
|
|
43
66
|
function readState(bool updateRateOracle) external view returns (MarketState memory market);
|
|
44
67
|
|
|
45
|
-
function
|
|
68
|
+
function PT() external view returns (address);
|
|
46
69
|
|
|
47
70
|
function YT() external view returns (address);
|
|
48
71
|
|
|
@@ -53,7 +76,7 @@ interface IPMarket is IPBaseToken {
|
|
|
53
76
|
view
|
|
54
77
|
returns (
|
|
55
78
|
ISuperComposableYield _SCY,
|
|
56
|
-
|
|
79
|
+
IPPrincipalToken _PT,
|
|
57
80
|
IPYieldToken _YT
|
|
58
81
|
);
|
|
59
82
|
}
|
|
@@ -5,14 +5,14 @@ interface IPMarketAddRemoveCallback {
|
|
|
5
5
|
function addLiquidityCallback(
|
|
6
6
|
uint256 lpToAccount,
|
|
7
7
|
uint256 scyOwed,
|
|
8
|
-
uint256
|
|
8
|
+
uint256 ptOwed,
|
|
9
9
|
bytes calldata data
|
|
10
10
|
) external;
|
|
11
11
|
|
|
12
12
|
function removeLiquidityCallback(
|
|
13
13
|
uint256 lpOwed,
|
|
14
14
|
uint256 scyToAccount,
|
|
15
|
-
uint256
|
|
15
|
+
uint256 ptToAccount,
|
|
16
16
|
bytes calldata data
|
|
17
17
|
) external;
|
|
18
18
|
}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
pragma solidity 0.8.9;
|
|
3
3
|
|
|
4
4
|
interface IPMarketFactory {
|
|
5
|
+
event CreateNewMarket(address indexed PT, int256 scalarRoot, int256 initialAnchor);
|
|
6
|
+
|
|
5
7
|
function isValidMarket(address market) external view returns (bool);
|
|
6
8
|
|
|
7
9
|
function treasury() external view returns (address);
|
|
@@ -12,7 +14,7 @@ interface IPMarketFactory {
|
|
|
12
14
|
view
|
|
13
15
|
returns (
|
|
14
16
|
address treasury,
|
|
15
|
-
uint96
|
|
17
|
+
uint96 lnFeeRateRoot,
|
|
16
18
|
uint32 rateOracleTimeWindow,
|
|
17
19
|
uint8 reserveFeePercent
|
|
18
20
|
);
|
|
@@ -14,11 +14,11 @@ interface IPRouterStatic {
|
|
|
14
14
|
uint256 index;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
struct
|
|
17
|
+
struct UserPYInfo {
|
|
18
18
|
address yt;
|
|
19
|
-
address
|
|
19
|
+
address pt;
|
|
20
20
|
uint256 ytBalance;
|
|
21
|
-
uint256
|
|
21
|
+
uint256 ptBalance;
|
|
22
22
|
TokenAmount unclaimedInterest;
|
|
23
23
|
TokenAmount[] unclaimedRewards;
|
|
24
24
|
}
|
|
@@ -26,7 +26,7 @@ interface IPRouterStatic {
|
|
|
26
26
|
struct UserMarketInfo {
|
|
27
27
|
address market;
|
|
28
28
|
uint256 lpBalance;
|
|
29
|
-
TokenAmount
|
|
29
|
+
TokenAmount ptBalance;
|
|
30
30
|
TokenAmount scyBalance;
|
|
31
31
|
TokenAmount assetBalance;
|
|
32
32
|
}
|
|
@@ -34,47 +34,47 @@ interface IPRouterStatic {
|
|
|
34
34
|
function addLiquidityStatic(
|
|
35
35
|
address market,
|
|
36
36
|
uint256 scyDesired,
|
|
37
|
-
uint256
|
|
37
|
+
uint256 ptDesired
|
|
38
38
|
)
|
|
39
39
|
external
|
|
40
40
|
returns (
|
|
41
41
|
uint256 netLpOut,
|
|
42
42
|
uint256 scyUsed,
|
|
43
|
-
uint256
|
|
43
|
+
uint256 ptUsed
|
|
44
44
|
);
|
|
45
45
|
|
|
46
46
|
function removeLiquidityStatic(address market, uint256 lpToRemove)
|
|
47
47
|
external
|
|
48
48
|
view
|
|
49
|
-
returns (uint256 netScyOut, uint256
|
|
49
|
+
returns (uint256 netScyOut, uint256 netPtOut);
|
|
50
50
|
|
|
51
|
-
function
|
|
51
|
+
function swapPtForScyStatic(address market, uint256 exactPtIn)
|
|
52
52
|
external
|
|
53
53
|
returns (uint256 netScyOut, uint256 netScyFee);
|
|
54
54
|
|
|
55
|
-
function
|
|
55
|
+
function swapScyForPtStatic(address market, uint256 exactPtOut)
|
|
56
56
|
external
|
|
57
57
|
returns (uint256 netScyIn, uint256 netScyFee);
|
|
58
58
|
|
|
59
59
|
function scyIndex(address market) external returns (SCYIndex index);
|
|
60
60
|
|
|
61
|
-
function
|
|
61
|
+
function getPtImpliedYield(address market) external view returns (int256);
|
|
62
62
|
|
|
63
63
|
function getPendleTokenType(address token)
|
|
64
64
|
external
|
|
65
65
|
view
|
|
66
66
|
returns (
|
|
67
|
-
bool
|
|
67
|
+
bool isPT,
|
|
68
68
|
bool isYT,
|
|
69
69
|
bool isMarket
|
|
70
70
|
);
|
|
71
71
|
|
|
72
|
-
function
|
|
72
|
+
function getUserPYInfo(address py, address user)
|
|
73
73
|
external
|
|
74
74
|
view
|
|
75
|
-
returns (
|
|
75
|
+
returns (UserPYInfo memory userPYInfo);
|
|
76
76
|
|
|
77
|
-
function
|
|
77
|
+
function getPYInfo(address py)
|
|
78
78
|
external
|
|
79
79
|
returns (
|
|
80
80
|
uint256 exchangeRate,
|
|
@@ -82,13 +82,13 @@ interface IPRouterStatic {
|
|
|
82
82
|
RewardIndex[] memory rewardIndexes
|
|
83
83
|
);
|
|
84
84
|
|
|
85
|
-
function
|
|
85
|
+
function getPY(address py) external view returns (address yt, address pt);
|
|
86
86
|
|
|
87
87
|
function getMarketInfo(address market)
|
|
88
88
|
external
|
|
89
89
|
view
|
|
90
90
|
returns (
|
|
91
|
-
address
|
|
91
|
+
address pt,
|
|
92
92
|
address scy,
|
|
93
93
|
MarketState memory state,
|
|
94
94
|
int256 impliedYield,
|
|
@@ -100,17 +100,17 @@ interface IPRouterStatic {
|
|
|
100
100
|
view
|
|
101
101
|
returns (UserMarketInfo memory userMarketInfo);
|
|
102
102
|
|
|
103
|
-
function
|
|
103
|
+
function getUserPYPositionsByPYs(address user, address[] calldata pys)
|
|
104
104
|
external
|
|
105
105
|
view
|
|
106
|
-
returns (
|
|
106
|
+
returns (UserPYInfo[] memory userPYPositions);
|
|
107
107
|
|
|
108
108
|
function getUserMarketPositions(address user, address[] calldata markets)
|
|
109
109
|
external
|
|
110
110
|
view
|
|
111
111
|
returns (UserMarketInfo[] memory userMarketPositions);
|
|
112
112
|
|
|
113
|
-
function
|
|
113
|
+
function hasPYPosition(UserPYInfo memory userPYInfo) external pure returns (bool hasPosition);
|
|
114
114
|
|
|
115
115
|
function getUserSCYInfo(address scy, address user)
|
|
116
116
|
external
|
|
@@ -24,7 +24,15 @@
|
|
|
24
24
|
pragma solidity 0.8.9;
|
|
25
25
|
|
|
26
26
|
interface IPYieldContractFactory {
|
|
27
|
-
|
|
27
|
+
event CreateYieldContract(address indexed SCY, address PT, address YT, uint256 expiry);
|
|
28
|
+
|
|
29
|
+
event SetExpiryDivisor(uint256 newExpiryDivisor);
|
|
30
|
+
|
|
31
|
+
event SetInterestFeeRate(uint256 newInterestFeeRate);
|
|
32
|
+
|
|
33
|
+
event SetTreasury(address indexed treasury);
|
|
34
|
+
|
|
35
|
+
function getPT(address SCY, uint256 expiry) external view returns (address);
|
|
28
36
|
|
|
29
37
|
function getYT(address SCY, uint256 expiry) external view returns (address);
|
|
30
38
|
|
|
@@ -34,7 +42,7 @@ interface IPYieldContractFactory {
|
|
|
34
42
|
|
|
35
43
|
function treasury() external view returns (address);
|
|
36
44
|
|
|
37
|
-
function
|
|
45
|
+
function isPT(address) external view returns (bool);
|
|
38
46
|
|
|
39
47
|
function isYT(address) external view returns (bool);
|
|
40
48
|
}
|
|
@@ -4,11 +4,20 @@ import "./IPBaseToken.sol";
|
|
|
4
4
|
import "../SuperComposableYield/implementations/IRewardManager.sol";
|
|
5
5
|
|
|
6
6
|
interface IPYieldToken is IPBaseToken, IRewardManager {
|
|
7
|
-
|
|
7
|
+
event RedeemReward(address indexed user, uint256[] amountRewardsOut);
|
|
8
|
+
event RedeemInterest(address indexed user, uint256 interestOut);
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
event WithdrawFeeToTreasury(uint256[] amountRewardsOut, uint256 scyOut);
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
function mintPY(address receiverPT, address receiverYT) external returns (uint256 amountPYOut);
|
|
13
|
+
|
|
14
|
+
function redeemPY(address receiver) external returns (uint256 amountScyOut);
|
|
15
|
+
|
|
16
|
+
// minimum of PT & YT balance
|
|
17
|
+
|
|
18
|
+
function redeemDueInterestAndRewards(address user)
|
|
19
|
+
external
|
|
20
|
+
returns (uint256 interestOut, uint256[] memory rewardsOut);
|
|
12
21
|
|
|
13
22
|
function redeemDueInterest(address user) external returns (uint256 interestOut);
|
|
14
23
|
|
|
@@ -25,11 +34,11 @@ interface IPYieldToken is IPBaseToken, IRewardManager {
|
|
|
25
34
|
view
|
|
26
35
|
returns (uint256 lastScyIndex, uint256 dueInterest);
|
|
27
36
|
|
|
28
|
-
function
|
|
37
|
+
function getScyIndex() external returns (uint256 currentIndex, uint256 lastIndexBeforeExpiry);
|
|
29
38
|
|
|
30
39
|
function withdrawFeeToTreasury() external;
|
|
31
40
|
|
|
32
41
|
function SCY() external view returns (address);
|
|
33
42
|
|
|
34
|
-
function
|
|
43
|
+
function PT() external view returns (address);
|
|
35
44
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
pragma solidity 0.8.9;
|
|
3
|
+
|
|
4
|
+
interface IWstETH {
|
|
5
|
+
function wrap(uint256 _stETHAmount) external returns (uint256);
|
|
6
|
+
|
|
7
|
+
function unwrap(uint256 _wstETHAmount) external returns (uint256);
|
|
8
|
+
|
|
9
|
+
function stEthPerToken() external view returns (uint256);
|
|
10
|
+
}
|
|
@@ -98,7 +98,7 @@ library JoeLibrary {
|
|
|
98
98
|
require(path.length >= 2, "JoeLibrary: INVALID_PATH");
|
|
99
99
|
amounts = new uint256[](path.length);
|
|
100
100
|
amounts[0] = amountIn;
|
|
101
|
-
for (uint256 i; i < path.length - 1; i++) {
|
|
101
|
+
for (uint256 i = 0; i < path.length - 1; i++) {
|
|
102
102
|
(uint256 reserveIn, uint256 reserveOut) = getReserves(factory, path[i], path[i + 1]);
|
|
103
103
|
amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);
|
|
104
104
|
}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
13
13
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
14
14
|
|
|
15
|
-
pragma solidity
|
|
15
|
+
pragma solidity 0.8.9;
|
|
16
16
|
|
|
17
17
|
/* solhint-disable */
|
|
18
18
|
|