@pendle/core-v2 0.7.1-beta → 0.7.1-beta-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/build/artifacts/contracts/SuperComposableYield/SCY-implementations/AaveV3/PendleAaveV3SCY.sol/PendleAaveV3SCY.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/AaveV3/WadRayMath.sol/WadRayMath.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/BenQi/PendleQiTokenSCY.sol/PendleQiTokenSCY.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleBtrflySCY.sol/PendleBtrflyScy.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleERC4626SCY.sol/PendleERC4626SCY.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleJoeLpSCY.sol/PendleJoeLpSCY.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleWstEthSCY.sol/PendleWstEthSCY.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/SCY-implementations/PendleYearnVaultScy.sol/PendleYearnVaultSCY.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/base-implementations/SCYBase.sol/SCYBase.dbg.json +1 -1
- package/build/artifacts/contracts/SuperComposableYield/base-implementations/SCYBaseWithRewards.sol/SCYBaseWithRewards.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/CelerAbstracts/CelerReceiverUpg.sol/CelerReceiverUpg.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/CelerAbstracts/CelerSenderUpg.sol/CelerSenderUpg.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol/PendleGaugeControllerBaseUpg.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerMainchain.sol/PendleGaugeControllerMainchainUpg.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/GaugeController/PendleGaugeControllerSidechain.sol/PendleGaugeControllerSidechainUpg.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/PendleGauge.sol/PendleGauge.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/VotingController/VotingControllerStorageUpg.sol/VotingControllerStorageUpg.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.dbg.json +1 -1
- package/build/artifacts/contracts/core/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol/VotingEscrowTokenBase.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/PendleMarket.sol/PendleMarket.dbg.json +1 -1
- package/build/artifacts/contracts/core/Market/PendleMarketFactory.sol/PendleMarketFactory.dbg.json +1 -1
- package/build/artifacts/contracts/core/PendleERC20.sol/PendleERC20.dbg.json +1 -1
- package/build/artifacts/contracts/core/PendleERC20Permit.sol/PendleERC20Permit.dbg.json +1 -1
- package/build/artifacts/contracts/core/PendleRouter.sol/PendleRouter.dbg.json +1 -1
- package/build/artifacts/contracts/core/PendleRouter.sol/PendleRouter.json +2 -2
- package/build/artifacts/contracts/core/YieldContracts/InterestManagerYT.sol/InterestManagerYT.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendlePrincipalToken.sol/PendlePrincipalToken.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.dbg.json +1 -1
- package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.dbg.json +1 -1
- package/build/artifacts/contracts/core/actions/ActionCallback.sol/ActionCallback.dbg.json +1 -1
- package/build/artifacts/contracts/core/actions/ActionCore.sol/ActionCore.dbg.json +1 -1
- package/build/artifacts/contracts/core/actions/ActionYT.sol/ActionYT.dbg.json +1 -1
- package/build/artifacts/contracts/core/actions/base/ActionSCYAndPTBase.sol/ActionSCYAndPTBase.dbg.json +1 -1
- package/build/artifacts/contracts/core/actions/base/ActionSCYAndPYBase.sol/ActionSCYAndPYBase.dbg.json +1 -1
- package/build/artifacts/contracts/core/actions/base/ActionSCYAndYTBase.sol/ActionSCYAndYTBase.dbg.json +1 -1
- package/build/artifacts/contracts/core/actions/base/CallbackHelper.sol/CallbackHelper.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IAToken.sol/IAToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IAavePool.sol/IAavePool.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IAaveRewardsController.sol/IAaveRewardsController.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IBenQiComptroller.sol/IBenQiComptroller.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IBenQiInterestRateModel.sol/IBenQiInterestRateModel.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ICelerMessageBus.sol/ICelerMessageBus.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ICelerMessageReceiverApp.sol/ICelerMessageReceiverApp.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IERC4626.sol/IERC4626.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IJoePair.sol/IJoePair.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IJoeRouter01.sol/IJoeRouter01.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IJoeRouter02.sol/IJoeRouter02.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionCore.sol/IPActionCore.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPActionYT.sol/IPActionYT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPGaugeController.sol/IPGaugeController.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPGaugeControllerMainchain.sol/IPGaugeControllerMainchain.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPGovernanceManager.sol/IPGovernanceManager.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPInterestManagerYT.sol/IPInterestManagerYT.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMarket.sol/IPMarket.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMarketAddRemoveCallback.sol/IPMarketAddRemoveCallback.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMarketFactory.sol/IPMarketFactory.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPMarketSwapCallback.sol/IPMarketSwapCallback.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPPermissionsV2Upg.sol/IPermissionsV2Upg.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPPrincipalToken.sol/IPPrincipalToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPRouterStatic.sol/IPRouterStatic.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPRouterStatic.sol/IPRouterStatic.json +20 -15
- package/build/artifacts/contracts/interfaces/IPVeToken.sol/IPVeToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPVotingController.sol/IPVotingController.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPVotingEscrow.sol/IPVotingEscrow.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPYieldContractFactory.sol/IPYieldContractFactory.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IPYieldToken.sol/IPYieldToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IQiAvax.sol/IQiAvax.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IQiErc20.sol/IQiErc20.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IQiToken.sol/IQiToken.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IREDACTEDStaking.sol/IREDACTEDStaking.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IRewardManager.sol/IRewardManager.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/ISuperComposableYield.sol/ISuperComposableYield.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IWETH.sol/IWETH.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IWXBTRFLY.sol/IWXBTRFLY.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IWstETH.sol/IWstETH.dbg.json +1 -1
- package/build/artifacts/contracts/interfaces/IYearnVault.sol/IYearnVault.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/RewardManager.sol/RewardManager.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/RewardManagerAbstract.sol/RewardManagerAbstract.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/SCY/SCYIndex.sol/SCYIndexLib.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/SCY/SCYUtils.sol/SCYUtils.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/VeBalanceLib.sol/VeBalanceLib.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/VeHistoryLib.sol/Checkpoints.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/helpers/ArrayLib.sol/ArrayLib.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/helpers/ExpiryUtilsLib.sol/ExpiryUtils.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/helpers/MiniHelpers.sol/MiniHelpers.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/helpers/SSTORE2Deployer.sol/SSTORE2Deployer.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/helpers/TokenHelper.sol/TokenHelper.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/math/LogExpMath.sol/LogExpMath.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/math/MarketApproxLib.sol/MarketApproxLib.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/math/MarketMathCore.sol/MarketMathCore.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/math/Math.sol/Math.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/math/WeekMath.sol/WeekMath.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/solmate/SSTORE2.sol/SSTORE2.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/traderjoe/JoeLibrary.sol/JoeLibrary.dbg.json +1 -1
- package/build/artifacts/contracts/libraries/traderjoe/PendleJoeSwapHelperUpg.sol/PendleJoeSwapHelperUpg.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.dbg.json +1 -1
- package/build/artifacts/contracts/offchain-helpers/RouterStatic.sol/RouterStatic.json +166 -13
- package/build/artifacts/contracts/periphery/PermissionsV2Upg.sol/PermissionsV2Upg.dbg.json +1 -1
- package/contracts/interfaces/IPRouterStatic.sol +67 -47
- package/contracts/offchain-helpers/RouterStatic.sol +143 -114
- package/deployments/43113-core.json +2 -0
- package/deployments/80001-core.json +2 -0
- package/package.json +1 -1
- package/typechain-types/IPRouterStatic.ts +64 -41
- package/typechain-types/RouterStatic.ts +297 -24
- package/typechain-types/factories/IPRouterStatic__factory.ts +20 -15
- package/typechain-types/factories/PendleRouter__factory.ts +1 -1
- package/typechain-types/factories/RouterStatic__factory.ts +165 -12
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
2
|
pragma solidity 0.8.15;
|
|
3
3
|
|
|
4
|
+
import "./ISuperComposableYield.sol";
|
|
4
5
|
import "../libraries/math/MarketMathCore.sol";
|
|
5
6
|
|
|
6
7
|
interface IPRouterStatic {
|
|
@@ -9,6 +10,12 @@ interface IPRouterStatic {
|
|
|
9
10
|
uint256 amount;
|
|
10
11
|
}
|
|
11
12
|
|
|
13
|
+
struct AssetAmount {
|
|
14
|
+
ISuperComposableYield.AssetType assetType;
|
|
15
|
+
address assetAddress;
|
|
16
|
+
uint256 amount;
|
|
17
|
+
}
|
|
18
|
+
|
|
12
19
|
struct RewardIndex {
|
|
13
20
|
address rewardToken;
|
|
14
21
|
uint256 index;
|
|
@@ -28,15 +35,64 @@ interface IPRouterStatic {
|
|
|
28
35
|
uint256 lpBalance;
|
|
29
36
|
TokenAmount ptBalance;
|
|
30
37
|
TokenAmount scyBalance;
|
|
31
|
-
|
|
38
|
+
AssetAmount assetBalance;
|
|
32
39
|
}
|
|
33
40
|
|
|
41
|
+
// ============= SYSTEM INFO =============
|
|
42
|
+
|
|
43
|
+
function getPYInfo(address py)
|
|
44
|
+
external
|
|
45
|
+
returns (
|
|
46
|
+
uint256 exchangeRate,
|
|
47
|
+
uint256 totalSupply,
|
|
48
|
+
RewardIndex[] memory rewardIndexes
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
function getPendleTokenType(address token)
|
|
52
|
+
external
|
|
53
|
+
view
|
|
54
|
+
returns (
|
|
55
|
+
bool isPT,
|
|
56
|
+
bool isYT,
|
|
57
|
+
bool isMarket
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
function getMarketInfo(address market)
|
|
61
|
+
external
|
|
62
|
+
view
|
|
63
|
+
returns (
|
|
64
|
+
address pt,
|
|
65
|
+
address scy,
|
|
66
|
+
MarketState memory state,
|
|
67
|
+
int256 impliedYield
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
// ============= USER INFO =============
|
|
71
|
+
|
|
72
|
+
function getUserPYPositionsByPYs(address user, address[] calldata pys)
|
|
73
|
+
external
|
|
74
|
+
view
|
|
75
|
+
returns (UserPYInfo[] memory userPYPositions);
|
|
76
|
+
|
|
77
|
+
function getUserMarketPositions(address user, address[] calldata markets)
|
|
78
|
+
external
|
|
79
|
+
view
|
|
80
|
+
returns (UserMarketInfo[] memory userMarketPositions);
|
|
81
|
+
|
|
82
|
+
function getUserSCYInfo(address scy, address user)
|
|
83
|
+
external
|
|
84
|
+
view
|
|
85
|
+
returns (uint256 balance, TokenAmount[] memory rewards);
|
|
86
|
+
|
|
87
|
+
// ============= MARKET ACTIONS =============
|
|
88
|
+
|
|
34
89
|
function addLiquidityStatic(
|
|
35
90
|
address market,
|
|
36
91
|
uint256 scyDesired,
|
|
37
92
|
uint256 ptDesired
|
|
38
93
|
)
|
|
39
94
|
external
|
|
95
|
+
view
|
|
40
96
|
returns (
|
|
41
97
|
uint256 netLpOut,
|
|
42
98
|
uint256 scyUsed,
|
|
@@ -50,70 +106,34 @@ interface IPRouterStatic {
|
|
|
50
106
|
|
|
51
107
|
function swapPtForScyStatic(address market, uint256 exactPtIn)
|
|
52
108
|
external
|
|
109
|
+
view
|
|
53
110
|
returns (uint256 netScyOut, uint256 netScyFee);
|
|
54
111
|
|
|
55
112
|
function swapScyForPtStatic(address market, uint256 exactPtOut)
|
|
56
113
|
external
|
|
114
|
+
view
|
|
57
115
|
returns (uint256 netScyIn, uint256 netScyFee);
|
|
58
116
|
|
|
59
|
-
|
|
117
|
+
// ============= OTHER HELPERS =============
|
|
60
118
|
|
|
61
|
-
function
|
|
119
|
+
function scyIndex(address market) external view returns (SCYIndex index);
|
|
62
120
|
|
|
63
|
-
function
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
returns (
|
|
67
|
-
bool isPT,
|
|
68
|
-
bool isYT,
|
|
69
|
-
bool isMarket
|
|
70
|
-
);
|
|
121
|
+
function getPY(address py) external view returns (address pt, address yt);
|
|
122
|
+
|
|
123
|
+
function getPtImpliedYield(address market) external view returns (int256);
|
|
71
124
|
|
|
72
125
|
function getUserPYInfo(address py, address user)
|
|
73
126
|
external
|
|
74
127
|
view
|
|
75
128
|
returns (UserPYInfo memory userPYInfo);
|
|
76
129
|
|
|
77
|
-
function getPYInfo(address py)
|
|
78
|
-
external
|
|
79
|
-
returns (
|
|
80
|
-
uint256 exchangeRate,
|
|
81
|
-
uint256 totalSupply,
|
|
82
|
-
RewardIndex[] memory rewardIndexes
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
function getPY(address py) external view returns (address yt, address pt);
|
|
86
|
-
|
|
87
|
-
function getMarketInfo(address market)
|
|
88
|
-
external
|
|
89
|
-
view
|
|
90
|
-
returns (
|
|
91
|
-
address pt,
|
|
92
|
-
address scy,
|
|
93
|
-
MarketState memory state,
|
|
94
|
-
int256 impliedYield,
|
|
95
|
-
uint256 exchangeRate
|
|
96
|
-
);
|
|
97
|
-
|
|
98
130
|
function getUserMarketInfo(address market, address user)
|
|
99
131
|
external
|
|
100
132
|
view
|
|
101
133
|
returns (UserMarketInfo memory userMarketInfo);
|
|
102
134
|
|
|
103
|
-
function
|
|
135
|
+
function hasPYPosition(UserPYInfo calldata userPYInfo)
|
|
104
136
|
external
|
|
105
|
-
|
|
106
|
-
returns (
|
|
107
|
-
|
|
108
|
-
function getUserMarketPositions(address user, address[] calldata markets)
|
|
109
|
-
external
|
|
110
|
-
view
|
|
111
|
-
returns (UserMarketInfo[] memory userMarketPositions);
|
|
112
|
-
|
|
113
|
-
function hasPYPosition(UserPYInfo memory userPYInfo) external pure returns (bool hasPosition);
|
|
114
|
-
|
|
115
|
-
function getUserSCYInfo(address scy, address user)
|
|
116
|
-
external
|
|
117
|
-
view
|
|
118
|
-
returns (uint256 balance, TokenAmount[] memory rewards);
|
|
137
|
+
pure
|
|
138
|
+
returns (bool hasPosition);
|
|
119
139
|
}
|
|
@@ -7,11 +7,12 @@ import "../interfaces/IPRouterStatic.sol";
|
|
|
7
7
|
import "../interfaces/IPMarket.sol";
|
|
8
8
|
import "../interfaces/IPYieldContractFactory.sol";
|
|
9
9
|
import "../interfaces/IPMarketFactory.sol";
|
|
10
|
+
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
|
|
10
11
|
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
|
|
11
12
|
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
|
|
12
13
|
|
|
13
14
|
/// EXCLUDED FROM ALL AUDITS, TO BE CALLED ONLY BY PENDLE's SDK
|
|
14
|
-
contract RouterStatic is IPRouterStatic {
|
|
15
|
+
contract RouterStatic is IPRouterStatic, Initializable, UUPSUpgradeable, OwnableUpgradeable {
|
|
15
16
|
using MarketMathCore for MarketState;
|
|
16
17
|
using Math for uint256;
|
|
17
18
|
using Math for int256;
|
|
@@ -20,17 +21,125 @@ contract RouterStatic is IPRouterStatic {
|
|
|
20
21
|
IPYieldContractFactory public immutable yieldContractFactory;
|
|
21
22
|
IPMarketFactory public immutable marketFactory;
|
|
22
23
|
|
|
23
|
-
constructor(IPYieldContractFactory _yieldContractFactory, IPMarketFactory _marketFactory)
|
|
24
|
+
constructor(IPYieldContractFactory _yieldContractFactory, IPMarketFactory _marketFactory)
|
|
25
|
+
initializer
|
|
26
|
+
{
|
|
24
27
|
yieldContractFactory = _yieldContractFactory;
|
|
25
28
|
marketFactory = _marketFactory;
|
|
26
29
|
}
|
|
27
30
|
|
|
31
|
+
function initialize() external initializer {
|
|
32
|
+
__UUPSUpgradeable_init();
|
|
33
|
+
__Ownable_init();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// ============= SYSTEM INFO =============
|
|
37
|
+
|
|
38
|
+
function getPYInfo(address py)
|
|
39
|
+
external
|
|
40
|
+
returns (
|
|
41
|
+
uint256 exchangeRate,
|
|
42
|
+
uint256 totalSupply,
|
|
43
|
+
RewardIndex[] memory rewardIndexes
|
|
44
|
+
)
|
|
45
|
+
{
|
|
46
|
+
(address yt, ) = getPY(py);
|
|
47
|
+
IPYieldToken YT = IPYieldToken(yt);
|
|
48
|
+
exchangeRate = YT.scyIndexCurrent();
|
|
49
|
+
totalSupply = YT.totalSupply();
|
|
50
|
+
address[] memory rewardTokens = YT.getRewardTokens();
|
|
51
|
+
rewardIndexes = new RewardIndex[](rewardTokens.length);
|
|
52
|
+
|
|
53
|
+
uint256[] memory indexes = YT.rewardIndexesCurrent();
|
|
54
|
+
for (uint256 i = 0; i < rewardTokens.length; ++i) {
|
|
55
|
+
address rewardToken = rewardTokens[i];
|
|
56
|
+
rewardIndexes[i].rewardToken = rewardToken;
|
|
57
|
+
rewardIndexes[i].index = indexes[i];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function getPendleTokenType(address token)
|
|
62
|
+
external
|
|
63
|
+
view
|
|
64
|
+
returns (
|
|
65
|
+
bool isPT,
|
|
66
|
+
bool isYT,
|
|
67
|
+
bool isMarket
|
|
68
|
+
)
|
|
69
|
+
{
|
|
70
|
+
if (yieldContractFactory.isPT(token)) isPT = true;
|
|
71
|
+
else if (yieldContractFactory.isYT(token)) isYT = true;
|
|
72
|
+
else if (marketFactory.isValidMarket(token)) isMarket = true;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function getMarketInfo(address market)
|
|
76
|
+
external
|
|
77
|
+
view
|
|
78
|
+
returns (
|
|
79
|
+
address pt,
|
|
80
|
+
address scy,
|
|
81
|
+
MarketState memory state,
|
|
82
|
+
int256 impliedYield
|
|
83
|
+
)
|
|
84
|
+
{
|
|
85
|
+
IPMarket _market = IPMarket(market);
|
|
86
|
+
(ISuperComposableYield SCY, IPPrincipalToken PT, ) = IPMarket(market).readTokens();
|
|
87
|
+
|
|
88
|
+
pt = address(PT);
|
|
89
|
+
scy = address(SCY);
|
|
90
|
+
state = _market.readState(true);
|
|
91
|
+
impliedYield = getPtImpliedYield(market);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// ============= USER INFO =============
|
|
95
|
+
|
|
96
|
+
function getUserPYPositionsByPYs(address user, address[] calldata pys)
|
|
97
|
+
external
|
|
98
|
+
view
|
|
99
|
+
returns (UserPYInfo[] memory userPYPositions)
|
|
100
|
+
{
|
|
101
|
+
userPYPositions = new UserPYInfo[](pys.length);
|
|
102
|
+
for (uint256 i = 0; i < pys.length; ++i) {
|
|
103
|
+
userPYPositions[i] = getUserPYInfo(pys[i], user);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function getUserMarketPositions(address user, address[] calldata markets)
|
|
108
|
+
external
|
|
109
|
+
view
|
|
110
|
+
returns (UserMarketInfo[] memory userMarketPositions)
|
|
111
|
+
{
|
|
112
|
+
userMarketPositions = new UserMarketInfo[](markets.length);
|
|
113
|
+
for (uint256 i = 0; i < markets.length; ++i) {
|
|
114
|
+
userMarketPositions[i] = getUserMarketInfo(markets[i], user);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function getUserSCYInfo(address scy, address user)
|
|
119
|
+
external
|
|
120
|
+
view
|
|
121
|
+
returns (uint256 balance, TokenAmount[] memory rewards)
|
|
122
|
+
{
|
|
123
|
+
ISuperComposableYield SCY = ISuperComposableYield(scy);
|
|
124
|
+
balance = SCY.balanceOf(scy);
|
|
125
|
+
address[] memory rewardTokens = SCY.getRewardTokens();
|
|
126
|
+
rewards = new TokenAmount[](rewardTokens.length);
|
|
127
|
+
for (uint256 i = 0; i < rewardTokens.length; ++i) {
|
|
128
|
+
address rewardToken = rewardTokens[i];
|
|
129
|
+
rewards[i].token = rewardToken;
|
|
130
|
+
(, rewards[i].amount) = IRewardManager(scy).userReward(rewardToken, user);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// ============= MARKET ACTIONS =============
|
|
135
|
+
|
|
28
136
|
function addLiquidityStatic(
|
|
29
137
|
address market,
|
|
30
138
|
uint256 scyDesired,
|
|
31
139
|
uint256 ptDesired
|
|
32
140
|
)
|
|
33
141
|
external
|
|
142
|
+
view
|
|
34
143
|
returns (
|
|
35
144
|
uint256 netLpOut,
|
|
36
145
|
uint256 scyUsed,
|
|
@@ -57,6 +166,7 @@ contract RouterStatic is IPRouterStatic {
|
|
|
57
166
|
|
|
58
167
|
function swapPtForScyStatic(address market, uint256 exactPtIn)
|
|
59
168
|
external
|
|
169
|
+
view
|
|
60
170
|
returns (uint256 netScyOut, uint256 netScyFee)
|
|
61
171
|
{
|
|
62
172
|
MarketState memory state = IPMarket(market).readState(false);
|
|
@@ -69,6 +179,7 @@ contract RouterStatic is IPRouterStatic {
|
|
|
69
179
|
|
|
70
180
|
function swapScyForPtStatic(address market, uint256 exactPtOut)
|
|
71
181
|
external
|
|
182
|
+
view
|
|
72
183
|
returns (uint256 netScyIn, uint256 netScyFee)
|
|
73
184
|
{
|
|
74
185
|
MarketState memory state = IPMarket(market).readState(false);
|
|
@@ -79,12 +190,24 @@ contract RouterStatic is IPRouterStatic {
|
|
|
79
190
|
);
|
|
80
191
|
}
|
|
81
192
|
|
|
193
|
+
// ============= OTHER HELPERS =============
|
|
194
|
+
|
|
82
195
|
function scyIndex(address market) public view returns (SCYIndex index) {
|
|
83
196
|
(ISuperComposableYield SCY, , ) = IPMarket(market).readTokens();
|
|
84
197
|
|
|
85
198
|
return SCYIndexLib.newIndex(SCY);
|
|
86
199
|
}
|
|
87
200
|
|
|
201
|
+
function getPY(address py) public view returns (address pt, address yt) {
|
|
202
|
+
if (yieldContractFactory.isYT(py)) {
|
|
203
|
+
pt = IPYieldToken(py).PT();
|
|
204
|
+
yt = py;
|
|
205
|
+
} else {
|
|
206
|
+
pt = py;
|
|
207
|
+
yt = IPPrincipalToken(py).YT();
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
88
211
|
function getPtImpliedYield(address market) public view returns (int256) {
|
|
89
212
|
MarketState memory state = IPMarket(market).readState(false);
|
|
90
213
|
|
|
@@ -92,20 +215,6 @@ contract RouterStatic is IPRouterStatic {
|
|
|
92
215
|
return lnImpliedRate.exp();
|
|
93
216
|
}
|
|
94
217
|
|
|
95
|
-
function getPendleTokenType(address token)
|
|
96
|
-
external
|
|
97
|
-
view
|
|
98
|
-
returns (
|
|
99
|
-
bool isPT,
|
|
100
|
-
bool isYT,
|
|
101
|
-
bool isMarket
|
|
102
|
-
)
|
|
103
|
-
{
|
|
104
|
-
if (yieldContractFactory.isPT(token)) isPT = true;
|
|
105
|
-
else if (yieldContractFactory.isYT(token)) isYT = true;
|
|
106
|
-
else if (marketFactory.isValidMarket(token)) isMarket = true;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
218
|
function getUserPYInfo(address py, address user)
|
|
110
219
|
public
|
|
111
220
|
view
|
|
@@ -135,119 +244,39 @@ contract RouterStatic is IPRouterStatic {
|
|
|
135
244
|
}
|
|
136
245
|
}
|
|
137
246
|
|
|
138
|
-
function getPYInfo(address py)
|
|
139
|
-
external
|
|
140
|
-
returns (
|
|
141
|
-
uint256 exchangeRate,
|
|
142
|
-
uint256 totalSupply,
|
|
143
|
-
RewardIndex[] memory rewardIndexes
|
|
144
|
-
)
|
|
145
|
-
{
|
|
146
|
-
(address yt, ) = getPY(py);
|
|
147
|
-
IPYieldToken YT = IPYieldToken(yt);
|
|
148
|
-
exchangeRate = YT.scyIndexCurrent();
|
|
149
|
-
totalSupply = YT.totalSupply();
|
|
150
|
-
address[] memory rewardTokens = YT.getRewardTokens();
|
|
151
|
-
rewardIndexes = new RewardIndex[](rewardTokens.length);
|
|
152
|
-
|
|
153
|
-
uint256[] memory indexes = YT.rewardIndexesCurrent();
|
|
154
|
-
for (uint256 i = 0; i < rewardTokens.length; ++i) {
|
|
155
|
-
address rewardToken = rewardTokens[i];
|
|
156
|
-
rewardIndexes[i].rewardToken = rewardToken;
|
|
157
|
-
rewardIndexes[i].index = indexes[i];
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function getPY(address py) public view returns (address pt, address yt) {
|
|
162
|
-
if (yieldContractFactory.isYT(py)) {
|
|
163
|
-
yt = py;
|
|
164
|
-
pt = IPYieldToken(py).PT();
|
|
165
|
-
} else {
|
|
166
|
-
yt = IPPrincipalToken(py).YT();
|
|
167
|
-
pt = py;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
function getMarketInfo(address market)
|
|
172
|
-
external
|
|
173
|
-
view
|
|
174
|
-
returns (
|
|
175
|
-
address pt,
|
|
176
|
-
address scy,
|
|
177
|
-
MarketState memory state,
|
|
178
|
-
int256 impliedYield,
|
|
179
|
-
uint256 exchangeRate
|
|
180
|
-
)
|
|
181
|
-
{
|
|
182
|
-
IPMarket _market = IPMarket(market);
|
|
183
|
-
(ISuperComposableYield SCY, IPPrincipalToken PT, ) = IPMarket(market).readTokens();
|
|
184
|
-
|
|
185
|
-
pt = address(PT);
|
|
186
|
-
scy = address(SCY);
|
|
187
|
-
state = _market.readState(true);
|
|
188
|
-
impliedYield = getPtImpliedYield(market);
|
|
189
|
-
exchangeRate = 0; // TODO: get the actual exchange rate
|
|
190
|
-
}
|
|
191
|
-
|
|
192
247
|
function getUserMarketInfo(address market, address user)
|
|
193
248
|
public
|
|
194
249
|
view
|
|
195
250
|
returns (UserMarketInfo memory userMarketInfo)
|
|
196
251
|
{
|
|
197
252
|
IPMarket _market = IPMarket(market);
|
|
198
|
-
|
|
199
|
-
userMarketInfo.lpBalance = _market.balanceOf(user);
|
|
200
|
-
// TODO: Is there a way to convert LP to PT and SCY?
|
|
201
|
-
(ISuperComposableYield SCY, IPPrincipalToken PT, ) = IPMarket(market).readTokens();
|
|
253
|
+
uint256 userLp = _market.balanceOf(user);
|
|
202
254
|
|
|
203
|
-
userMarketInfo.
|
|
204
|
-
userMarketInfo.
|
|
205
|
-
// TODO: Get this from SCY once it is in the interface
|
|
206
|
-
userMarketInfo.assetBalance = TokenAmount(address(0), 0);
|
|
207
|
-
}
|
|
255
|
+
userMarketInfo.market = market;
|
|
256
|
+
userMarketInfo.lpBalance = userLp;
|
|
208
257
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
{
|
|
214
|
-
userPYPositions = new UserPYInfo[](pys.length);
|
|
215
|
-
for (uint256 i = 0; i < pys.length; ++i) {
|
|
216
|
-
userPYPositions[i] = getUserPYInfo(pys[i], user);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
258
|
+
MarketState memory state = _market.readState(true);
|
|
259
|
+
uint256 totalLp = uint256(state.totalLp);
|
|
260
|
+
uint256 userPt = (userLp * uint256(state.totalPt)) / totalLp;
|
|
261
|
+
uint256 userScy = (userLp * uint256(state.totalScy)) / totalLp;
|
|
219
262
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
for (uint256 i = 0; i < markets.length; ++i) {
|
|
227
|
-
userMarketPositions[i] = getUserMarketInfo(markets[i], user);
|
|
228
|
-
}
|
|
263
|
+
(ISuperComposableYield SCY, IPPrincipalToken PT, ) = _market.readTokens();
|
|
264
|
+
userMarketInfo.ptBalance = TokenAmount(address(PT), userPt);
|
|
265
|
+
userMarketInfo.scyBalance = TokenAmount(address(SCY), userScy);
|
|
266
|
+
(userMarketInfo.assetBalance.assetType, userMarketInfo.assetBalance.assetAddress, ) = SCY
|
|
267
|
+
.assetInfo();
|
|
268
|
+
userMarketInfo.assetBalance.amount = (userScy * SCY.exchangeRate()) / Math.ONE;
|
|
229
269
|
}
|
|
230
270
|
|
|
231
|
-
function hasPYPosition(UserPYInfo
|
|
271
|
+
function hasPYPosition(UserPYInfo calldata userPYInfo) public pure returns (bool hasPosition) {
|
|
232
272
|
hasPosition = (userPYInfo.ytBalance > 0 ||
|
|
233
273
|
userPYInfo.ptBalance > 0 ||
|
|
234
274
|
userPYInfo.unclaimedInterest.amount > 0 ||
|
|
235
275
|
userPYInfo.unclaimedRewards.length > 0);
|
|
236
276
|
}
|
|
237
277
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
{
|
|
243
|
-
ISuperComposableYield SCY = ISuperComposableYield(scy);
|
|
244
|
-
balance = SCY.balanceOf(scy);
|
|
245
|
-
address[] memory rewardTokens = SCY.getRewardTokens();
|
|
246
|
-
rewards = new TokenAmount[](rewardTokens.length);
|
|
247
|
-
for (uint256 i = 0; i < rewardTokens.length; ++i) {
|
|
248
|
-
address rewardToken = rewardTokens[i];
|
|
249
|
-
rewards[i].token = rewardToken;
|
|
250
|
-
(, rewards[i].amount) = IRewardManager(scy).userReward(rewardToken, user);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
278
|
+
// ============= UPGRADES =============
|
|
279
|
+
|
|
280
|
+
// solhint-disable-next-line no-empty-blocks
|
|
281
|
+
function _authorizeUpgrade(address newImplementation) internal override onlyOwner {}
|
|
253
282
|
}
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
"PENDLE": "0xd6403Ff542290C38EE4fCFf48552FA85fbe8539B",
|
|
8
8
|
"yieldContractFactory": "0x0EA46a4C257071352b57E9F6d054fC137F6E14b9",
|
|
9
9
|
"marketFactory": "0x9e7be80205815111617B9578157e130ECd9757e4",
|
|
10
|
+
"router": "0xb359F0A97Ca269Ae5574dc75be48b0e81eFD1dA2",
|
|
11
|
+
"routerStatic": "0x860D23ADA1652CEEE1e3c77210CCE068bB4BD4e1",
|
|
10
12
|
"startTime": 1656547200,
|
|
11
13
|
"vePendle": "0x5CA98fBE317f0165499E886286A2737FE5A913E7",
|
|
12
14
|
"votingController": "0xcb0d3d9147845C7F2B77DCFBE4dB8114d928DC93",
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
"PENDLE": "0x53F435CEC95c597d905f0903a13F4dAbEA8491dB",
|
|
8
8
|
"yieldContractFactory": "0x4e5De6339FC7Ef63c176f9A7e7a8B2aC21744B8D",
|
|
9
9
|
"marketFactory": "0xCAd502Bb55d1A3F79952F969BFF3f011CF30a94a",
|
|
10
|
+
"router": "0xA972fB7828f0bff8a22f7f8C63b17cfB971BFC0a",
|
|
11
|
+
"routerStatic": "0x9a8Ff151BDA518ece44Cb1125F368F4C893D63b7",
|
|
10
12
|
"startTime": 1656547200,
|
|
11
13
|
"vePendle": "0x69A23F16974024A1b6A5362ac2A11BFeEEFd5827",
|
|
12
14
|
"gaugeController": "0x847da006F940833bB44709CBa241c99e3c531F38"
|