@pendle/core-v2 0.2.2 → 0.3.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 +1 -5
- package/contracts/SuperComposableYield/implementations/RewardManager.sol +2 -2
- package/contracts/SuperComposableYield/implementations/SCYBase.sol +2 -2
- 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/{PendleRouterStatic.sol → 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 +1 -1
- 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 +3 -11
- package/typechain-types/OwnableUpgradeable.ts +165 -0
- package/typechain-types/PendleAaveV3SCY.ts +3 -11
- package/typechain-types/PendleBenQiErc20SCY.ts +3 -11
- package/typechain-types/PendleBtrflyScy.ts +3 -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 +3 -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 +3 -11
- package/typechain-types/SCYBaseWithRewards.ts +3 -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 +0 -5
- package/typechain-types/factories/OwnableUpgradeable__factory.ts +78 -0
- package/typechain-types/factories/PendleAaveV3SCY__factory.ts +1 -6
- package/typechain-types/factories/PendleBenQiErc20SCY__factory.ts +1 -6
- package/typechain-types/factories/PendleBtrflyScy__factory.ts +1 -6
- 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 +1 -6
- 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 +0 -5
- package/typechain-types/factories/SCYBase__factory.ts +0 -5
- 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
|
@@ -12,6 +12,10 @@ import * as Contracts from ".";
|
|
|
12
12
|
|
|
13
13
|
declare module "hardhat/types/runtime" {
|
|
14
14
|
interface HardhatEthersHelpers extends HardhatEthersHelpersBase {
|
|
15
|
+
getContractFactory(
|
|
16
|
+
name: "OwnableUpgradeable",
|
|
17
|
+
signerOrOptions?: ethers.Signer | FactoryOptions
|
|
18
|
+
): Promise<Contracts.OwnableUpgradeable__factory>;
|
|
15
19
|
getContractFactory(
|
|
16
20
|
name: "IERC1822ProxiableUpgradeable",
|
|
17
21
|
signerOrOptions?: ethers.Signer | FactoryOptions
|
|
@@ -44,26 +48,6 @@ declare module "hardhat/types/runtime" {
|
|
|
44
48
|
name: "IERC20",
|
|
45
49
|
signerOrOptions?: ethers.Signer | FactoryOptions
|
|
46
50
|
): Promise<Contracts.IERC20__factory>;
|
|
47
|
-
getContractFactory(
|
|
48
|
-
name: "BoringOwnable",
|
|
49
|
-
signerOrOptions?: ethers.Signer | FactoryOptions
|
|
50
|
-
): Promise<Contracts.BoringOwnable__factory>;
|
|
51
|
-
getContractFactory(
|
|
52
|
-
name: "BoringOwnableData",
|
|
53
|
-
signerOrOptions?: ethers.Signer | FactoryOptions
|
|
54
|
-
): Promise<Contracts.BoringOwnableData__factory>;
|
|
55
|
-
getContractFactory(
|
|
56
|
-
name: "BoringOwnableUpg",
|
|
57
|
-
signerOrOptions?: ethers.Signer | FactoryOptions
|
|
58
|
-
): Promise<Contracts.BoringOwnableUpg__factory>;
|
|
59
|
-
getContractFactory(
|
|
60
|
-
name: "BoringOwnableUpgData",
|
|
61
|
-
signerOrOptions?: ethers.Signer | FactoryOptions
|
|
62
|
-
): Promise<Contracts.BoringOwnableUpgData__factory>;
|
|
63
|
-
getContractFactory(
|
|
64
|
-
name: "PendleJoeSwapHelperUpg",
|
|
65
|
-
signerOrOptions?: ethers.Signer | FactoryOptions
|
|
66
|
-
): Promise<Contracts.PendleJoeSwapHelperUpg__factory>;
|
|
67
51
|
getContractFactory(
|
|
68
52
|
name: "PendleBaseToken",
|
|
69
53
|
signerOrOptions?: ethers.Signer | FactoryOptions
|
|
@@ -185,9 +169,9 @@ declare module "hardhat/types/runtime" {
|
|
|
185
169
|
signerOrOptions?: ethers.Signer | FactoryOptions
|
|
186
170
|
): Promise<Contracts.IPOwnershipToken__factory>;
|
|
187
171
|
getContractFactory(
|
|
188
|
-
name: "
|
|
172
|
+
name: "IPermissionsV2Upg",
|
|
189
173
|
signerOrOptions?: ethers.Signer | FactoryOptions
|
|
190
|
-
): Promise<Contracts.
|
|
174
|
+
): Promise<Contracts.IPermissionsV2Upg__factory>;
|
|
191
175
|
getContractFactory(
|
|
192
176
|
name: "IPRouterCore",
|
|
193
177
|
signerOrOptions?: ethers.Signer | FactoryOptions
|
|
@@ -237,9 +221,13 @@ declare module "hardhat/types/runtime" {
|
|
|
237
221
|
signerOrOptions?: ethers.Signer | FactoryOptions
|
|
238
222
|
): Promise<Contracts.PendleGovernanceManager__factory>;
|
|
239
223
|
getContractFactory(
|
|
240
|
-
name: "
|
|
224
|
+
name: "PendleJoeSwapHelperUpg",
|
|
241
225
|
signerOrOptions?: ethers.Signer | FactoryOptions
|
|
242
|
-
): Promise<Contracts.
|
|
226
|
+
): Promise<Contracts.PendleJoeSwapHelperUpg__factory>;
|
|
227
|
+
getContractFactory(
|
|
228
|
+
name: "PermissionsV2Upg",
|
|
229
|
+
signerOrOptions?: ethers.Signer | FactoryOptions
|
|
230
|
+
): Promise<Contracts.PermissionsV2Upg__factory>;
|
|
243
231
|
getContractFactory(
|
|
244
232
|
name: "RewardManager",
|
|
245
233
|
signerOrOptions?: ethers.Signer | FactoryOptions
|
|
@@ -257,6 +245,11 @@ declare module "hardhat/types/runtime" {
|
|
|
257
245
|
signerOrOptions?: ethers.Signer | FactoryOptions
|
|
258
246
|
): Promise<Contracts.ISuperComposableYield__factory>;
|
|
259
247
|
|
|
248
|
+
getContractAt(
|
|
249
|
+
name: "OwnableUpgradeable",
|
|
250
|
+
address: string,
|
|
251
|
+
signer?: ethers.Signer
|
|
252
|
+
): Promise<Contracts.OwnableUpgradeable>;
|
|
260
253
|
getContractAt(
|
|
261
254
|
name: "IERC1822ProxiableUpgradeable",
|
|
262
255
|
address: string,
|
|
@@ -297,31 +290,6 @@ declare module "hardhat/types/runtime" {
|
|
|
297
290
|
address: string,
|
|
298
291
|
signer?: ethers.Signer
|
|
299
292
|
): Promise<Contracts.IERC20>;
|
|
300
|
-
getContractAt(
|
|
301
|
-
name: "BoringOwnable",
|
|
302
|
-
address: string,
|
|
303
|
-
signer?: ethers.Signer
|
|
304
|
-
): Promise<Contracts.BoringOwnable>;
|
|
305
|
-
getContractAt(
|
|
306
|
-
name: "BoringOwnableData",
|
|
307
|
-
address: string,
|
|
308
|
-
signer?: ethers.Signer
|
|
309
|
-
): Promise<Contracts.BoringOwnableData>;
|
|
310
|
-
getContractAt(
|
|
311
|
-
name: "BoringOwnableUpg",
|
|
312
|
-
address: string,
|
|
313
|
-
signer?: ethers.Signer
|
|
314
|
-
): Promise<Contracts.BoringOwnableUpg>;
|
|
315
|
-
getContractAt(
|
|
316
|
-
name: "BoringOwnableUpgData",
|
|
317
|
-
address: string,
|
|
318
|
-
signer?: ethers.Signer
|
|
319
|
-
): Promise<Contracts.BoringOwnableUpgData>;
|
|
320
|
-
getContractAt(
|
|
321
|
-
name: "PendleJoeSwapHelperUpg",
|
|
322
|
-
address: string,
|
|
323
|
-
signer?: ethers.Signer
|
|
324
|
-
): Promise<Contracts.PendleJoeSwapHelperUpg>;
|
|
325
293
|
getContractAt(
|
|
326
294
|
name: "PendleBaseToken",
|
|
327
295
|
address: string,
|
|
@@ -473,10 +441,10 @@ declare module "hardhat/types/runtime" {
|
|
|
473
441
|
signer?: ethers.Signer
|
|
474
442
|
): Promise<Contracts.IPOwnershipToken>;
|
|
475
443
|
getContractAt(
|
|
476
|
-
name: "
|
|
444
|
+
name: "IPermissionsV2Upg",
|
|
477
445
|
address: string,
|
|
478
446
|
signer?: ethers.Signer
|
|
479
|
-
): Promise<Contracts.
|
|
447
|
+
): Promise<Contracts.IPermissionsV2Upg>;
|
|
480
448
|
getContractAt(
|
|
481
449
|
name: "IPRouterCore",
|
|
482
450
|
address: string,
|
|
@@ -538,10 +506,15 @@ declare module "hardhat/types/runtime" {
|
|
|
538
506
|
signer?: ethers.Signer
|
|
539
507
|
): Promise<Contracts.PendleGovernanceManager>;
|
|
540
508
|
getContractAt(
|
|
541
|
-
name: "
|
|
509
|
+
name: "PendleJoeSwapHelperUpg",
|
|
510
|
+
address: string,
|
|
511
|
+
signer?: ethers.Signer
|
|
512
|
+
): Promise<Contracts.PendleJoeSwapHelperUpg>;
|
|
513
|
+
getContractAt(
|
|
514
|
+
name: "PermissionsV2Upg",
|
|
542
515
|
address: string,
|
|
543
516
|
signer?: ethers.Signer
|
|
544
|
-
): Promise<Contracts.
|
|
517
|
+
): Promise<Contracts.PermissionsV2Upg>;
|
|
545
518
|
getContractAt(
|
|
546
519
|
name: "RewardManager",
|
|
547
520
|
address: string,
|
package/typechain-types/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* Autogenerated file. Do not edit manually. */
|
|
2
2
|
/* tslint:disable */
|
|
3
3
|
/* eslint-disable */
|
|
4
|
+
export type { OwnableUpgradeable } from "./OwnableUpgradeable";
|
|
4
5
|
export type { IERC1822ProxiableUpgradeable } from "./IERC1822ProxiableUpgradeable";
|
|
5
6
|
export type { IBeaconUpgradeable } from "./IBeaconUpgradeable";
|
|
6
7
|
export type { ERC1967UpgradeUpgradeable } from "./ERC1967UpgradeUpgradeable";
|
|
@@ -9,11 +10,6 @@ export type { Proxy } from "./Proxy";
|
|
|
9
10
|
export type { ERC20 } from "./ERC20";
|
|
10
11
|
export type { IERC20Metadata } from "./IERC20Metadata";
|
|
11
12
|
export type { IERC20 } from "./IERC20";
|
|
12
|
-
export type { BoringOwnable } from "./BoringOwnable";
|
|
13
|
-
export type { BoringOwnableData } from "./BoringOwnableData";
|
|
14
|
-
export type { BoringOwnableUpg } from "./BoringOwnableUpg";
|
|
15
|
-
export type { BoringOwnableUpgData } from "./BoringOwnableUpgData";
|
|
16
|
-
export type { PendleJoeSwapHelperUpg } from "./PendleJoeSwapHelperUpg";
|
|
17
13
|
export type { PendleBaseToken } from "./PendleBaseToken";
|
|
18
14
|
export type { PendleMarket } from "./PendleMarket";
|
|
19
15
|
export type { PendleMarketFactory } from "./PendleMarketFactory";
|
|
@@ -44,7 +40,7 @@ export type { IPMarketAddRemoveCallback } from "./IPMarketAddRemoveCallback";
|
|
|
44
40
|
export type { IPMarketFactory } from "./IPMarketFactory";
|
|
45
41
|
export type { IPMarketSwapCallback } from "./IPMarketSwapCallback";
|
|
46
42
|
export type { IPOwnershipToken } from "./IPOwnershipToken";
|
|
47
|
-
export type {
|
|
43
|
+
export type { IPermissionsV2Upg } from "./IPermissionsV2Upg";
|
|
48
44
|
export type { IPRouterCore } from "./IPRouterCore";
|
|
49
45
|
export type { IPRouterStatic } from "./IPRouterStatic";
|
|
50
46
|
export type { IPRouterYT } from "./IPRouterYT";
|
|
@@ -57,12 +53,14 @@ export type { IWETH } from "./IWETH";
|
|
|
57
53
|
export type { IWXBTRFLY } from "./IWXBTRFLY";
|
|
58
54
|
export type { IYearnVault } from "./IYearnVault";
|
|
59
55
|
export type { PendleGovernanceManager } from "./PendleGovernanceManager";
|
|
60
|
-
export type {
|
|
56
|
+
export type { PendleJoeSwapHelperUpg } from "./PendleJoeSwapHelperUpg";
|
|
57
|
+
export type { PermissionsV2Upg } from "./PermissionsV2Upg";
|
|
61
58
|
export type { RewardManager } from "./RewardManager";
|
|
62
59
|
export type { SCYBase } from "./SCYBase";
|
|
63
60
|
export type { SCYBaseWithRewards } from "./SCYBaseWithRewards";
|
|
64
61
|
export type { ISuperComposableYield } from "./ISuperComposableYield";
|
|
65
62
|
|
|
63
|
+
export { OwnableUpgradeable__factory } from "./factories/OwnableUpgradeable__factory";
|
|
66
64
|
export { IERC1822ProxiableUpgradeable__factory } from "./factories/IERC1822ProxiableUpgradeable__factory";
|
|
67
65
|
export { IBeaconUpgradeable__factory } from "./factories/IBeaconUpgradeable__factory";
|
|
68
66
|
export { ERC1967UpgradeUpgradeable__factory } from "./factories/ERC1967UpgradeUpgradeable__factory";
|
|
@@ -71,11 +69,6 @@ export { Proxy__factory } from "./factories/Proxy__factory";
|
|
|
71
69
|
export { ERC20__factory } from "./factories/ERC20__factory";
|
|
72
70
|
export { IERC20Metadata__factory } from "./factories/IERC20Metadata__factory";
|
|
73
71
|
export { IERC20__factory } from "./factories/IERC20__factory";
|
|
74
|
-
export { BoringOwnable__factory } from "./factories/BoringOwnable__factory";
|
|
75
|
-
export { BoringOwnableData__factory } from "./factories/BoringOwnableData__factory";
|
|
76
|
-
export { BoringOwnableUpg__factory } from "./factories/BoringOwnableUpg__factory";
|
|
77
|
-
export { BoringOwnableUpgData__factory } from "./factories/BoringOwnableUpgData__factory";
|
|
78
|
-
export { PendleJoeSwapHelperUpg__factory } from "./factories/PendleJoeSwapHelperUpg__factory";
|
|
79
72
|
export { PendleBaseToken__factory } from "./factories/PendleBaseToken__factory";
|
|
80
73
|
export { PendleMarket__factory } from "./factories/PendleMarket__factory";
|
|
81
74
|
export { PendleMarketFactory__factory } from "./factories/PendleMarketFactory__factory";
|
|
@@ -106,7 +99,7 @@ export { IPMarketAddRemoveCallback__factory } from "./factories/IPMarketAddRemov
|
|
|
106
99
|
export { IPMarketFactory__factory } from "./factories/IPMarketFactory__factory";
|
|
107
100
|
export { IPMarketSwapCallback__factory } from "./factories/IPMarketSwapCallback__factory";
|
|
108
101
|
export { IPOwnershipToken__factory } from "./factories/IPOwnershipToken__factory";
|
|
109
|
-
export {
|
|
102
|
+
export { IPermissionsV2Upg__factory } from "./factories/IPermissionsV2Upg__factory";
|
|
110
103
|
export { IPRouterCore__factory } from "./factories/IPRouterCore__factory";
|
|
111
104
|
export { IPRouterStatic__factory } from "./factories/IPRouterStatic__factory";
|
|
112
105
|
export { IPRouterYT__factory } from "./factories/IPRouterYT__factory";
|
|
@@ -119,7 +112,8 @@ export { IWETH__factory } from "./factories/IWETH__factory";
|
|
|
119
112
|
export { IWXBTRFLY__factory } from "./factories/IWXBTRFLY__factory";
|
|
120
113
|
export { IYearnVault__factory } from "./factories/IYearnVault__factory";
|
|
121
114
|
export { PendleGovernanceManager__factory } from "./factories/PendleGovernanceManager__factory";
|
|
122
|
-
export {
|
|
115
|
+
export { PendleJoeSwapHelperUpg__factory } from "./factories/PendleJoeSwapHelperUpg__factory";
|
|
116
|
+
export { PermissionsV2Upg__factory } from "./factories/PermissionsV2Upg__factory";
|
|
123
117
|
export { RewardManager__factory } from "./factories/RewardManager__factory";
|
|
124
118
|
export { SCYBase__factory } from "./factories/SCYBase__factory";
|
|
125
119
|
export { SCYBaseWithRewards__factory } from "./factories/SCYBaseWithRewards__factory";
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.9;
|
|
3
|
-
|
|
4
|
-
// Audit on 5-Jan-2021 by Keno and BoringCrypto
|
|
5
|
-
// Source: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol + Claimable.sol
|
|
6
|
-
// Edited by BoringCrypto
|
|
7
|
-
|
|
8
|
-
contract BoringOwnableData {
|
|
9
|
-
address public owner;
|
|
10
|
-
address public pendingOwner;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
contract BoringOwnable is BoringOwnableData {
|
|
14
|
-
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
|
|
15
|
-
|
|
16
|
-
/// @notice Only allows the `owner` to execute the function.
|
|
17
|
-
modifier onlyOwner() {
|
|
18
|
-
require(msg.sender == owner, "Ownable: caller is not the owner");
|
|
19
|
-
_;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
constructor(address _owner) {
|
|
23
|
-
owner = _owner;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/// @notice Transfers ownership to `newOwner`. Either directly or claimable by the new pending owner.
|
|
27
|
-
/// Can only be invoked by the current `owner`.
|
|
28
|
-
/// @param newOwner Address of the new owner.
|
|
29
|
-
/// @param direct True if `newOwner` should be set immediately. False if `newOwner` needs to use `claimOwnership`.
|
|
30
|
-
/// @param renounce Allows the `newOwner` to be `address(0)` if `direct` and `renounce` is True. Has no effect otherwise.
|
|
31
|
-
function transferOwnership(
|
|
32
|
-
address newOwner,
|
|
33
|
-
bool direct,
|
|
34
|
-
bool renounce
|
|
35
|
-
) public onlyOwner {
|
|
36
|
-
if (direct) {
|
|
37
|
-
// Checks
|
|
38
|
-
require(newOwner != address(0) || renounce, "Ownable: zero address");
|
|
39
|
-
|
|
40
|
-
// Effects
|
|
41
|
-
emit OwnershipTransferred(owner, newOwner);
|
|
42
|
-
owner = newOwner;
|
|
43
|
-
pendingOwner = address(0);
|
|
44
|
-
} else {
|
|
45
|
-
// Effects
|
|
46
|
-
pendingOwner = newOwner;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/// @notice Needs to be called by `pendingOwner` to claim ownership.
|
|
51
|
-
function claimOwnership() public {
|
|
52
|
-
address _pendingOwner = pendingOwner;
|
|
53
|
-
|
|
54
|
-
// Checks
|
|
55
|
-
require(msg.sender == _pendingOwner, "Ownable: caller != pending owner");
|
|
56
|
-
|
|
57
|
-
// Effects
|
|
58
|
-
emit OwnershipTransferred(owner, _pendingOwner);
|
|
59
|
-
owner = _pendingOwner;
|
|
60
|
-
pendingOwner = address(0);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.9;
|
|
3
|
-
|
|
4
|
-
import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol";
|
|
5
|
-
|
|
6
|
-
/// Modified by the Pendle team, needs to audit
|
|
7
|
-
|
|
8
|
-
contract BoringOwnableUpgData {
|
|
9
|
-
address public owner;
|
|
10
|
-
address public pendingOwner;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
contract BoringOwnableUpg is BoringOwnableUpgData, Initializable {
|
|
14
|
-
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
|
|
15
|
-
|
|
16
|
-
function __BoringOwnable_init() internal onlyInitializing {
|
|
17
|
-
owner = msg.sender;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/// @notice Transfers ownership to `newOwner`. Either directly or claimable by the new pending owner.
|
|
21
|
-
/// Can only be invoked by the current `owner`.
|
|
22
|
-
/// @param newOwner Address of the new owner.
|
|
23
|
-
/// @param direct True if `newOwner` should be set immediately. False if `newOwner` needs to use `claimOwnership`.
|
|
24
|
-
/// @param renounce Allows the `newOwner` to be `address(0)` if `direct` and `renounce` is True. Has no effect otherwise.
|
|
25
|
-
function transferOwnership(
|
|
26
|
-
address newOwner,
|
|
27
|
-
bool direct,
|
|
28
|
-
bool renounce
|
|
29
|
-
) public onlyOwner {
|
|
30
|
-
if (direct) {
|
|
31
|
-
// Checks
|
|
32
|
-
require(newOwner != address(0) || renounce, "Ownable: zero address");
|
|
33
|
-
|
|
34
|
-
// Effects
|
|
35
|
-
emit OwnershipTransferred(owner, newOwner);
|
|
36
|
-
owner = newOwner;
|
|
37
|
-
pendingOwner = address(0);
|
|
38
|
-
} else {
|
|
39
|
-
// Effects
|
|
40
|
-
pendingOwner = newOwner;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/// @notice Needs to be called by `pendingOwner` to claim ownership.
|
|
45
|
-
function claimOwnership() public {
|
|
46
|
-
address _pendingOwner = pendingOwner;
|
|
47
|
-
|
|
48
|
-
// Checks
|
|
49
|
-
require(msg.sender == _pendingOwner, "Ownable: caller != pending owner");
|
|
50
|
-
|
|
51
|
-
// Effects
|
|
52
|
-
emit OwnershipTransferred(owner, _pendingOwner);
|
|
53
|
-
owner = _pendingOwner;
|
|
54
|
-
pendingOwner = address(0);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/// @notice Only allows the `owner` to execute the function.
|
|
58
|
-
modifier onlyOwner() {
|
|
59
|
-
require(msg.sender == owner, "Ownable: caller is not the owner");
|
|
60
|
-
_;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
uint256[48] private __gap;
|
|
64
|
-
}
|
|
@@ -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
|
-
}
|