@pendle/core-v2 0.2.3 → 0.4.0
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 +15 -5
- package/contracts/SuperComposableYield/implementations/RewardManager.sol +2 -2
- package/contracts/SuperComposableYield/implementations/SCYBase.sol +23 -3
- package/contracts/SuperComposableYield/implementations/SCYBaseWithRewards.sol +4 -7
- package/contracts/core/PendleMarket.sol +24 -22
- package/contracts/core/PendleMarketFactory.sol +7 -6
- package/contracts/core/PendleSCYImpl/PendleBenQiErc20SCY.sol +1 -1
- package/contracts/core/PendleSCYImpl/PendleBtrflySCY.sol +2 -7
- package/contracts/core/PendleSCYImpl/PendleYearnVaultSCY.sol +2 -7
- package/contracts/core/PendleYieldContractFactory.sol +12 -7
- package/contracts/core/PendleYieldToken.sol +93 -55
- package/contracts/core/router/PendleRouterCoreUpg.sol +35 -21
- package/contracts/core/router/PendleRouterProxy.sol +12 -6
- package/contracts/core/router/PendleRouterStaticUpg.sol +43 -18
- package/contracts/core/router/PendleRouterYTUpg.sol +47 -13
- package/contracts/core/router/base/PendleRouterOTBaseUpg.sol +22 -32
- package/contracts/core/router/base/PendleRouterSCYAndForgeBaseUpg.sol +4 -4
- package/contracts/core/router/base/PendleRouterYTBaseUpg.sol +62 -43
- package/contracts/interfaces/IPMarket.sol +4 -2
- package/contracts/interfaces/{IPPermissionsV2.sol → IPPermissionsV2Upg.sol} +1 -1
- package/contracts/interfaces/IPRouterCore.sol +24 -21
- package/contracts/interfaces/IPRouterStatic.sol +10 -1
- package/contracts/interfaces/IPRouterYT.sol +16 -4
- package/contracts/interfaces/IPYieldContractFactory.sol +4 -0
- package/contracts/interfaces/IPYieldToken.sol +2 -4
- package/contracts/libraries/SCYIndex.sol +3 -3
- package/contracts/libraries/math/LogExpMath.sol +1 -90
- package/contracts/libraries/math/MarketApproxLib.sol +336 -94
- package/contracts/libraries/math/MarketMathAux.sol +101 -0
- package/contracts/libraries/math/MarketMathCore.sol +423 -0
- package/contracts/libraries/math/Math.sol +144 -0
- package/contracts/{core/misc → periphery}/PendleJoeSwapHelperUpg.sol +2 -2
- package/contracts/periphery/{PermissionsV2.sol → PermissionsV2Upg.sol} +2 -2
- package/package.json +1 -1
- package/typechain-types/IPMarket.ts +22 -11
- package/typechain-types/IPRouterCore.ts +68 -58
- package/typechain-types/IPRouterStatic.ts +52 -0
- package/typechain-types/IPRouterYT.ts +96 -12
- package/typechain-types/IPYieldContractFactory.ts +32 -0
- package/typechain-types/IPYieldToken.ts +14 -48
- package/typechain-types/IPermissionsV2Upg.ts +87 -0
- package/typechain-types/ISuperComposableYield.ts +98 -11
- package/typechain-types/OwnableUpgradeable.ts +165 -0
- package/typechain-types/PendleAaveV3SCY.ts +98 -11
- package/typechain-types/PendleBenQiErc20SCY.ts +98 -11
- package/typechain-types/PendleBtrflyScy.ts +98 -11
- package/typechain-types/PendleMarket.ts +22 -11
- package/typechain-types/PendleRouterCoreUpg.ts +66 -48
- package/typechain-types/PendleRouterProxy.ts +15 -118
- package/typechain-types/PendleRouterStaticUpg.ts +92 -0
- package/typechain-types/PendleRouterYTUpg.ts +96 -12
- package/typechain-types/PendleYearnVaultScy.ts +98 -11
- package/typechain-types/PendleYieldContractFactory.ts +40 -113
- package/typechain-types/PendleYieldToken.ts +106 -7
- package/typechain-types/PermissionsV2Upg.ts +87 -0
- package/typechain-types/SCYBase.ts +98 -11
- package/typechain-types/SCYBaseWithRewards.ts +98 -11
- package/typechain-types/factories/IPMarket__factory.ts +8 -2
- package/typechain-types/factories/IPRouterCore__factory.ts +38 -23
- package/typechain-types/factories/IPRouterStatic__factory.ts +29 -0
- package/typechain-types/factories/IPRouterYT__factory.ts +65 -6
- package/typechain-types/factories/IPYieldContractFactory__factory.ts +38 -0
- package/typechain-types/factories/IPYieldToken__factory.ts +1 -20
- package/typechain-types/factories/IPermissionsV2Upg__factory.ts +39 -0
- package/typechain-types/factories/ISuperComposableYield__factory.ts +65 -2
- package/typechain-types/factories/OwnableUpgradeable__factory.ts +78 -0
- package/typechain-types/factories/PendleAaveV3SCY__factory.ts +66 -3
- package/typechain-types/factories/PendleBenQiErc20SCY__factory.ts +66 -3
- package/typechain-types/factories/PendleBtrflyScy__factory.ts +66 -3
- package/typechain-types/factories/PendleMarketFactory__factory.ts +1 -1
- package/typechain-types/factories/PendleMarket__factory.ts +9 -3
- package/typechain-types/factories/PendleRouterCoreUpg__factory.ts +26 -11
- package/typechain-types/factories/PendleRouterProxy__factory.ts +14 -67
- package/typechain-types/factories/PendleRouterStaticUpg__factory.ts +63 -17
- package/typechain-types/factories/PendleRouterYTUpg__factory.ts +66 -7
- package/typechain-types/factories/PendleYearnVaultScy__factory.ts +66 -3
- package/typechain-types/factories/PendleYieldContractFactory__factory.ts +39 -54
- package/typechain-types/factories/PendleYieldToken__factory.ts +53 -2
- package/typechain-types/factories/PermissionsV2Upg__factory.ts +39 -0
- package/typechain-types/factories/SCYBaseWithRewards__factory.ts +65 -2
- package/typechain-types/factories/SCYBase__factory.ts +65 -2
- package/typechain-types/hardhat.d.ts +26 -53
- package/typechain-types/index.ts +8 -14
- package/contracts/core/misc/BoringOwnable.sol +0 -62
- package/contracts/core/misc/BoringOwnableUpg.sol +0 -64
- package/contracts/libraries/math/FixedPoint.sol +0 -205
- package/contracts/libraries/math/MarketMathLib.sol +0 -614
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
-
// This program is free software: you can redistribute it and/or modify
|
|
3
|
-
// it under the terms of the GNU General Public License as published by
|
|
4
|
-
// the Free Software Foundation, either version 3 of the License, or
|
|
5
|
-
// (at your option) any later version.
|
|
6
|
-
|
|
7
|
-
// This program is distributed in the hope that it will be useful,
|
|
8
|
-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9
|
-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
10
|
-
// GNU General Public License for more details.
|
|
11
|
-
|
|
12
|
-
// You should have received a copy of the GNU General Public License
|
|
13
|
-
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
14
|
-
|
|
15
|
-
pragma solidity 0.8.9;
|
|
16
|
-
|
|
17
|
-
import "./LogExpMath.sol";
|
|
18
|
-
|
|
19
|
-
/* solhint-disable private-vars-leading-underscore, reason-string */
|
|
20
|
-
|
|
21
|
-
library FixedPoint {
|
|
22
|
-
uint256 internal constant ONE = 1e18; // 18 decimal places
|
|
23
|
-
int256 internal constant ONE_INT = 1e18; // 18 decimal places
|
|
24
|
-
|
|
25
|
-
uint256 internal constant MAX_POW_RELATIVE_ERROR = 10000; // 10^(-14)
|
|
26
|
-
|
|
27
|
-
function subMax0(uint256 a, uint256 b) internal pure returns (uint256) {
|
|
28
|
-
return (a >= b ? a - b : 0);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function subNoNeg(int256 a, int256 b) internal pure returns (int256) {
|
|
32
|
-
require(a >= b, "NEGATIVE");
|
|
33
|
-
return a - b;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function subNoNeg(int256 a, uint256 b) internal pure returns (int256) {
|
|
37
|
-
int256 _b = Int(b);
|
|
38
|
-
require(a >= _b, "NEGATIVE");
|
|
39
|
-
return a - _b;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function mulDown(uint256 a, uint256 b) internal pure returns (uint256) {
|
|
43
|
-
uint256 product = a * b;
|
|
44
|
-
return product / ONE;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function mulDown(int256 a, int256 b) internal pure returns (int256) {
|
|
48
|
-
int256 product = a * b;
|
|
49
|
-
return product / ONE_INT;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function mulDown(int256 a, uint256 b) internal pure returns (int256) {
|
|
53
|
-
return mulDown(a, Int(b));
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function mulDown(uint256 a, int256 b) internal pure returns (int256) {
|
|
57
|
-
return mulDown(Int(a), b);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function mulUp(uint256 a, uint256 b) internal pure returns (uint256) {
|
|
61
|
-
uint256 product = a * b;
|
|
62
|
-
|
|
63
|
-
if (product == 0) {
|
|
64
|
-
return 0;
|
|
65
|
-
} else {
|
|
66
|
-
// The traditional divUp formula is:
|
|
67
|
-
// divUp(x, y) := (x + y - 1) / y
|
|
68
|
-
// To avoid intermediate overflow in the addition, we distribute the division and get:
|
|
69
|
-
// divUp(x, y) := (x - 1) / y + 1
|
|
70
|
-
// Note that this requires x != 0, which we already tested for.
|
|
71
|
-
|
|
72
|
-
return ((product - 1) / ONE) + 1;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function divDown(uint256 a, uint256 b) internal pure returns (uint256) {
|
|
77
|
-
if (a == 0) {
|
|
78
|
-
return 0;
|
|
79
|
-
} else {
|
|
80
|
-
uint256 aInflated = a * ONE;
|
|
81
|
-
return aInflated / b;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function divDown(int256 a, int256 b) internal pure returns (int256) {
|
|
86
|
-
if (a == 0) {
|
|
87
|
-
return 0;
|
|
88
|
-
} else {
|
|
89
|
-
int256 aInflated = a * ONE_INT;
|
|
90
|
-
return aInflated / b;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function divDown(uint256 a, int256 b) internal pure returns (int256) {
|
|
95
|
-
return divDown(Int(a), b);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function divDown(int256 a, uint256 b) internal pure returns (int256) {
|
|
99
|
-
return divDown(a, Int(b));
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function divUp(uint256 a, uint256 b) internal pure returns (uint256) {
|
|
103
|
-
if (a == 0) {
|
|
104
|
-
return 0;
|
|
105
|
-
} else {
|
|
106
|
-
uint256 aInflated = a * ONE;
|
|
107
|
-
// The traditional divUp formula is:
|
|
108
|
-
// divUp(x, y) := (x + y - 1) / y
|
|
109
|
-
// To avoid intermediate overflow in the addition, we distribute the division and get:
|
|
110
|
-
// divUp(x, y) := (x - 1) / y + 1
|
|
111
|
-
// Note that this requires x != 0, which we already tested for.
|
|
112
|
-
|
|
113
|
-
return ((aInflated - 1) / b) + 1;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* @dev Returns x^y, assuming both are fixed point numbers, rounding down. The result is guaranteed to not be above
|
|
119
|
-
* the true value (that is, the error function expected - actual is always positive).
|
|
120
|
-
*/
|
|
121
|
-
function powDown(uint256 x, uint256 y) internal pure returns (uint256) {
|
|
122
|
-
uint256 raw = LogExpMath.pow(x, y);
|
|
123
|
-
uint256 maxError = mulUp(raw, MAX_POW_RELATIVE_ERROR) + 1;
|
|
124
|
-
|
|
125
|
-
if (raw < maxError) {
|
|
126
|
-
return 0;
|
|
127
|
-
} else {
|
|
128
|
-
return raw - maxError;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* @dev Returns x^y, assuming both are fixed point numbers, rounding up. The result is guaranteed to not be below
|
|
134
|
-
* the true value (that is, the error function expected - actual is always negative).
|
|
135
|
-
*/
|
|
136
|
-
function powUp(uint256 x, uint256 y) internal pure returns (uint256) {
|
|
137
|
-
uint256 raw = LogExpMath.pow(x, y);
|
|
138
|
-
uint256 maxError = mulUp(raw, MAX_POW_RELATIVE_ERROR) + 1;
|
|
139
|
-
|
|
140
|
-
return raw + maxError;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* @dev Returns the complement of a value (1 - x), capped to 0 if x is larger than 1.
|
|
145
|
-
*
|
|
146
|
-
* Useful when computing the complement for values with some level of relative error, as it strips this error and
|
|
147
|
-
* prevents intermediate negative values.
|
|
148
|
-
*/
|
|
149
|
-
function complement(uint256 x) internal pure returns (uint256) {
|
|
150
|
-
return (x < ONE) ? (ONE - x) : 0;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
function abs(int256 x) internal pure returns (uint256) {
|
|
154
|
-
return uint256(x > 0 ? x : -x);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function neg(int256 x) internal pure returns (int256) {
|
|
158
|
-
return -x;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function neg(uint256 x) internal pure returns (int256) {
|
|
162
|
-
return -Int(x);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
function max(uint256 x, uint256 y) internal pure returns (uint256) {
|
|
166
|
-
return (x > y ? x : y);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
function max(int256 x, int256 y) internal pure returns (int256) {
|
|
170
|
-
return (x > y ? x : y);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
function min(uint256 x, uint256 y) internal pure returns (uint256) {
|
|
174
|
-
return (x < y ? x : y);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function min(int256 x, int256 y) internal pure returns (int256) {
|
|
178
|
-
return (x < y ? x : y);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function Uint(int256 x) internal pure returns (uint256) {
|
|
182
|
-
require(x >= 0);
|
|
183
|
-
return uint256(x);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function Int(uint256 x) internal pure returns (int256) {
|
|
187
|
-
require(x <= uint256(type(int256).max));
|
|
188
|
-
return int256(x);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
function Int128(int256 x) internal pure returns (int128) {
|
|
192
|
-
require(x <= type(int128).max);
|
|
193
|
-
return int128(x);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function Uint32(uint256 x) internal pure returns (uint32) {
|
|
197
|
-
require(x <= type(uint32).max);
|
|
198
|
-
return uint32(x);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
function Uint112(uint256 x) internal pure returns (uint112) {
|
|
202
|
-
require(0 <= x && x <= type(uint112).max);
|
|
203
|
-
return uint112(x);
|
|
204
|
-
}
|
|
205
|
-
}
|