@pendle/core-v2 0.1.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.
Files changed (182) hide show
  1. package/LICENSE +100 -0
  2. package/contracts/SuperComposableYield/ISuperComposableYield.sol +68 -0
  3. package/contracts/SuperComposableYield/SCYUtils.sol +14 -0
  4. package/contracts/SuperComposableYield/implementations/RewardManager.sol +117 -0
  5. package/contracts/SuperComposableYield/implementations/SCYBase.sol +126 -0
  6. package/contracts/SuperComposableYield/implementations/SCYBaseWithRewards.sol +79 -0
  7. package/contracts/core/PendleBaseToken.sol +39 -0
  8. package/contracts/core/PendleMarket.sol +248 -0
  9. package/contracts/core/PendleMarketFactory.sol +60 -0
  10. package/contracts/core/PendleOwnershipToken.sol +44 -0
  11. package/contracts/core/PendleSCYImpl/AaveV3/PendleAaveV3SCY.sol +139 -0
  12. package/contracts/core/PendleSCYImpl/AaveV3/WadRayMath.sol +126 -0
  13. package/contracts/core/PendleSCYImpl/PendleBenQiErc20SCY.sol +127 -0
  14. package/contracts/core/PendleSCYImpl/PendleBtrflySCY.sol +125 -0
  15. package/contracts/core/PendleSCYImpl/PendleYearnVaultSCY.sol +115 -0
  16. package/contracts/core/PendleYieldContractFactory.sol +109 -0
  17. package/contracts/core/PendleYieldToken.sol +240 -0
  18. package/contracts/core/misc/BoringOwnable.sol +62 -0
  19. package/contracts/core/misc/BoringOwnableUpg.sol +64 -0
  20. package/contracts/core/misc/PendleJoeSwapHelperUpg.sol +82 -0
  21. package/contracts/core/router/PendleRouterCoreUpg.sol +219 -0
  22. package/contracts/core/router/PendleRouterProxy.sol +64 -0
  23. package/contracts/core/router/PendleRouterYTUpg.sol +134 -0
  24. package/contracts/core/router/base/PendleRouterOTBaseUpg.sol +218 -0
  25. package/contracts/core/router/base/PendleRouterSCYAndForgeBaseUpg.sol +141 -0
  26. package/contracts/core/router/base/PendleRouterYTBaseUpg.sol +212 -0
  27. package/contracts/interfaces/IAToken.sol +34 -0
  28. package/contracts/interfaces/IAavePool.sol +41 -0
  29. package/contracts/interfaces/IAaveRewardsController.sol +32 -0
  30. package/contracts/interfaces/IBenQiComptroller.sol +33 -0
  31. package/contracts/interfaces/IJoePair.sol +98 -0
  32. package/contracts/interfaces/IJoeRouter01.sol +162 -0
  33. package/contracts/interfaces/IPBaseToken.sol +9 -0
  34. package/contracts/interfaces/IPFlashCallBack.sol +10 -0
  35. package/contracts/interfaces/IPGovernanceManager.sol +28 -0
  36. package/contracts/interfaces/IPMarket.sol +57 -0
  37. package/contracts/interfaces/IPMarketAddRemoveCallback.sol +18 -0
  38. package/contracts/interfaces/IPMarketFactory.sol +8 -0
  39. package/contracts/interfaces/IPMarketSwapCallback.sol +10 -0
  40. package/contracts/interfaces/IPOwnershipToken.sol +15 -0
  41. package/contracts/interfaces/IPPermissionsV2.sol +28 -0
  42. package/contracts/interfaces/IPRouterCore.sol +108 -0
  43. package/contracts/interfaces/IPRouterYT.sol +47 -0
  44. package/contracts/interfaces/IPYieldContractFactory.sol +36 -0
  45. package/contracts/interfaces/IPYieldToken.sol +19 -0
  46. package/contracts/interfaces/IQiErc20.sol +35 -0
  47. package/contracts/interfaces/IQiToken.sol +29 -0
  48. package/contracts/interfaces/IREDACTEDStaking.sol +35 -0
  49. package/contracts/interfaces/IWETH.sol +34 -0
  50. package/contracts/interfaces/IWXBTRFLY.sol +37 -0
  51. package/contracts/interfaces/IYearnVault.sol +32 -0
  52. package/contracts/libraries/JoeLibrary.sol +121 -0
  53. package/contracts/libraries/SCYIndex.sol +55 -0
  54. package/contracts/libraries/helpers/ExpiryUtilsLib.sol +166 -0
  55. package/contracts/libraries/math/FixedPoint.sol +208 -0
  56. package/contracts/libraries/math/LogExpMath.sol +515 -0
  57. package/contracts/libraries/math/MarketApproxLib.sol +140 -0
  58. package/contracts/libraries/math/MarketMathLib.sol +606 -0
  59. package/contracts/periphery/PendleGovernanceManager.sol +36 -0
  60. package/contracts/periphery/PermissionsV2.sol +23 -0
  61. package/package.json +76 -0
  62. package/typechain-types/BoringOwnable.ts +194 -0
  63. package/typechain-types/BoringOwnableData.ts +100 -0
  64. package/typechain-types/BoringOwnableUpg.ts +194 -0
  65. package/typechain-types/BoringOwnableUpgData.ts +100 -0
  66. package/typechain-types/ERC1967UpgradeUpgradeable.ts +97 -0
  67. package/typechain-types/ERC20.ts +417 -0
  68. package/typechain-types/IAToken.ts +331 -0
  69. package/typechain-types/IAavePool.ts +192 -0
  70. package/typechain-types/IAaveRewardsController.ts +148 -0
  71. package/typechain-types/IBeaconUpgradeable.ts +87 -0
  72. package/typechain-types/IBenQiComptroller.ts +125 -0
  73. package/typechain-types/IERC1822ProxiableUpgradeable.ts +87 -0
  74. package/typechain-types/IERC20.ts +300 -0
  75. package/typechain-types/IERC20Metadata.ts +339 -0
  76. package/typechain-types/IJoePair.ts +888 -0
  77. package/typechain-types/IJoeRouter01.ts +1107 -0
  78. package/typechain-types/IPBaseToken.ts +365 -0
  79. package/typechain-types/IPFlashCallback.ts +115 -0
  80. package/typechain-types/IPGovernanceManager.ts +84 -0
  81. package/typechain-types/IPMarket.ts +701 -0
  82. package/typechain-types/IPMarketAddRemoveCallback.ts +169 -0
  83. package/typechain-types/IPMarketFactory.ts +109 -0
  84. package/typechain-types/IPMarketSwapCallback.ts +115 -0
  85. package/typechain-types/IPOwnershipToken.ts +488 -0
  86. package/typechain-types/IPRouterCore.ts +759 -0
  87. package/typechain-types/IPRouterYT.ts +405 -0
  88. package/typechain-types/IPYieldContractFactory.ts +192 -0
  89. package/typechain-types/IPYieldToken.ts +525 -0
  90. package/typechain-types/IPermissionsV2.ts +87 -0
  91. package/typechain-types/IQiErc20.ts +402 -0
  92. package/typechain-types/IQiToken.ts +327 -0
  93. package/typechain-types/IREDACTEDStaking.ts +216 -0
  94. package/typechain-types/ISuperComposableYield.ts +652 -0
  95. package/typechain-types/IWETH.ts +380 -0
  96. package/typechain-types/IWXBTRFLY.ts +254 -0
  97. package/typechain-types/IYearnVault.ts +152 -0
  98. package/typechain-types/PendleAaveV3SCY.ts +901 -0
  99. package/typechain-types/PendleBaseToken.ts +505 -0
  100. package/typechain-types/PendleBenQiErc20SCY.ts +914 -0
  101. package/typechain-types/PendleBtrflyScy.ts +794 -0
  102. package/typechain-types/PendleGovernanceManager.ts +187 -0
  103. package/typechain-types/PendleJoeSwapHelperUpg.ts +97 -0
  104. package/typechain-types/PendleMarket.ts +1008 -0
  105. package/typechain-types/PendleMarketFactory.ts +246 -0
  106. package/typechain-types/PendleOwnershipToken.ts +628 -0
  107. package/typechain-types/PendleRouterCoreUpg.ts +780 -0
  108. package/typechain-types/PendleRouterProxy.ts +417 -0
  109. package/typechain-types/PendleRouterSCYAndForgeBaseUpg.ts +98 -0
  110. package/typechain-types/PendleRouterYTBaseUpg.ts +134 -0
  111. package/typechain-types/PendleRouterYTUpg.ts +453 -0
  112. package/typechain-types/PendleYearnVaultScy.ts +784 -0
  113. package/typechain-types/PendleYieldContractFactory.ts +479 -0
  114. package/typechain-types/PendleYieldToken.ts +1030 -0
  115. package/typechain-types/PermissionsV2.ts +87 -0
  116. package/typechain-types/Proxy.ts +57 -0
  117. package/typechain-types/RewardManager.ts +172 -0
  118. package/typechain-types/SCYBase.ts +734 -0
  119. package/typechain-types/SCYBaseWithRewards.ts +819 -0
  120. package/typechain-types/UUPSUpgradeable.ts +197 -0
  121. package/typechain-types/common.ts +44 -0
  122. package/typechain-types/factories/BoringOwnableData__factory.ts +90 -0
  123. package/typechain-types/factories/BoringOwnableUpgData__factory.ts +94 -0
  124. package/typechain-types/factories/BoringOwnableUpg__factory.ts +139 -0
  125. package/typechain-types/factories/BoringOwnable__factory.ts +149 -0
  126. package/typechain-types/factories/ERC1967UpgradeUpgradeable__factory.ts +75 -0
  127. package/typechain-types/factories/ERC20__factory.ts +348 -0
  128. package/typechain-types/factories/IAToken__factory.ts +225 -0
  129. package/typechain-types/factories/IAavePool__factory.ts +99 -0
  130. package/typechain-types/factories/IAaveRewardsController__factory.ts +78 -0
  131. package/typechain-types/factories/IBeaconUpgradeable__factory.ts +39 -0
  132. package/typechain-types/factories/IBenQiComptroller__factory.ts +59 -0
  133. package/typechain-types/factories/IERC1822ProxiableUpgradeable__factory.ts +43 -0
  134. package/typechain-types/factories/IERC20Metadata__factory.ts +248 -0
  135. package/typechain-types/factories/IERC20__factory.ts +203 -0
  136. package/typechain-types/factories/IJoePair__factory.ts +674 -0
  137. package/typechain-types/factories/IJoeRouter01__factory.ts +772 -0
  138. package/typechain-types/factories/IPBaseToken__factory.ts +271 -0
  139. package/typechain-types/factories/IPFlashCallback__factory.ts +49 -0
  140. package/typechain-types/factories/IPGovernanceManager__factory.ts +39 -0
  141. package/typechain-types/factories/IPMarketAddRemoveCallback__factory.ts +86 -0
  142. package/typechain-types/factories/IPMarketFactory__factory.ts +58 -0
  143. package/typechain-types/factories/IPMarketSwapCallback__factory.ts +53 -0
  144. package/typechain-types/factories/IPMarket__factory.ts +559 -0
  145. package/typechain-types/factories/IPOwnershipToken__factory.ts +349 -0
  146. package/typechain-types/factories/IPRouterCore__factory.ts +516 -0
  147. package/typechain-types/factories/IPRouterYT__factory.ts +246 -0
  148. package/typechain-types/factories/IPYieldContractFactory__factory.ts +117 -0
  149. package/typechain-types/factories/IPYieldToken__factory.ts +383 -0
  150. package/typechain-types/factories/IPermissionsV2__factory.ts +39 -0
  151. package/typechain-types/factories/IQiErc20__factory.ts +270 -0
  152. package/typechain-types/factories/IQiToken__factory.ts +219 -0
  153. package/typechain-types/factories/IREDACTEDStaking__factory.ts +107 -0
  154. package/typechain-types/factories/ISuperComposableYield__factory.ts +438 -0
  155. package/typechain-types/factories/IWETH__factory.ts +261 -0
  156. package/typechain-types/factories/IWXBTRFLY__factory.ts +131 -0
  157. package/typechain-types/factories/IYearnVault__factory.ts +74 -0
  158. package/typechain-types/factories/PendleAaveV3SCY__factory.ts +727 -0
  159. package/typechain-types/factories/PendleBaseToken__factory.ts +386 -0
  160. package/typechain-types/factories/PendleBenQiErc20SCY__factory.ts +753 -0
  161. package/typechain-types/factories/PendleBtrflyScy__factory.ts +652 -0
  162. package/typechain-types/factories/PendleGovernanceManager__factory.ts +149 -0
  163. package/typechain-types/factories/PendleJoeSwapHelperUpg__factory.ts +56 -0
  164. package/typechain-types/factories/PendleMarketFactory__factory.ts +207 -0
  165. package/typechain-types/factories/PendleMarket__factory.ts +891 -0
  166. package/typechain-types/factories/PendleOwnershipToken__factory.ts +565 -0
  167. package/typechain-types/factories/PendleRouterCoreUpg__factory.ts +620 -0
  168. package/typechain-types/factories/PendleRouterProxy__factory.ts +316 -0
  169. package/typechain-types/factories/PendleRouterSCYAndForgeBaseUpg__factory.ts +56 -0
  170. package/typechain-types/factories/PendleRouterYTBaseUpg__factory.ts +66 -0
  171. package/typechain-types/factories/PendleRouterYTUpg__factory.ts +363 -0
  172. package/typechain-types/factories/PendleYearnVaultScy__factory.ts +630 -0
  173. package/typechain-types/factories/PendleYieldContractFactory__factory.ts +368 -0
  174. package/typechain-types/factories/PendleYieldToken__factory.ts +814 -0
  175. package/typechain-types/factories/PermissionsV2__factory.ts +36 -0
  176. package/typechain-types/factories/Proxy__factory.ts +28 -0
  177. package/typechain-types/factories/RewardManager__factory.ts +89 -0
  178. package/typechain-types/factories/SCYBaseWithRewards__factory.ts +535 -0
  179. package/typechain-types/factories/SCYBase__factory.ts +479 -0
  180. package/typechain-types/factories/UUPSUpgradeable__factory.ts +115 -0
  181. package/typechain-types/hardhat.d.ts +564 -0
  182. package/typechain-types/index.ts +122 -0
@@ -0,0 +1,212 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ pragma solidity 0.8.9;
3
+
4
+ import "../../../interfaces/IPMarketFactory.sol";
5
+ import "../../../interfaces/IPMarket.sol";
6
+ import "../../../interfaces/IPMarketAddRemoveCallback.sol";
7
+ import "../../../interfaces/IPMarketSwapCallback.sol";
8
+ import "../../../SuperComposableYield/SCYUtils.sol";
9
+ import "../../../libraries/math/MarketApproxLib.sol";
10
+ import "openzeppelin-solidity/contracts/token/ERC20/utils/SafeERC20.sol";
11
+
12
+ abstract contract PendleRouterYTBaseUpg is IPMarketSwapCallback {
13
+ using FixedPoint for uint256;
14
+ using FixedPoint for int256;
15
+ using MarketMathLib for MarketParameters;
16
+ using MarketApproxLib for MarketParameters;
17
+ using SafeERC20 for ISuperComposableYield;
18
+ using SafeERC20 for IPYieldToken;
19
+
20
+ // solhint-disable-next-line
21
+ enum YT_SWAP_TYPE {
22
+ ExactYtForScy,
23
+ SCYForExactYt,
24
+ ExactScyForYt
25
+ }
26
+
27
+ address public immutable marketFactory;
28
+
29
+ modifier onlyPendleMarket(address market) {
30
+ require(IPMarketFactory(marketFactory).isValidMarket(market), "INVALID_MARKET");
31
+ _;
32
+ }
33
+
34
+ /// @dev since this contract will be proxied, it must not contains non-immutable variables
35
+ constructor(
36
+ address _marketFactory //solhint-disable-next-line no-empty-blocks
37
+ ) {
38
+ marketFactory = _marketFactory;
39
+ }
40
+
41
+ function _swapExactScyForYt(
42
+ address receiver,
43
+ address market,
44
+ uint256 exactScyIn,
45
+ uint256 minYtOut,
46
+ uint256 netYtOutGuessMin,
47
+ uint256 netYtOutGuessMax,
48
+ bool doPull
49
+ ) internal returns (uint256 netYtOut) {
50
+ {
51
+ (ISuperComposableYield SCY, , IPYieldToken YT) = IPMarket(market).readTokens();
52
+ {
53
+ MarketParameters memory state = IPMarket(market).readState();
54
+
55
+ netYtOut = state.approxSwapExactScyForYt(
56
+ SCYIndexLib.newIndex(SCY),
57
+ exactScyIn,
58
+ block.timestamp,
59
+ netYtOutGuessMin,
60
+ netYtOutGuessMax
61
+ );
62
+ require(netYtOut >= minYtOut, "insufficient out");
63
+ }
64
+
65
+ if (doPull) {
66
+ SCY.safeTransferFrom(msg.sender, address(YT), exactScyIn);
67
+ }
68
+ }
69
+
70
+ {
71
+ uint256 exactOtIn = netYtOut;
72
+ IPMarket(market).swapExactOtForScy(
73
+ receiver,
74
+ exactOtIn,
75
+ 1,
76
+ abi.encode(YT_SWAP_TYPE.ExactScyForYt, receiver)
77
+ );
78
+ }
79
+ }
80
+
81
+ /**
82
+ * @dev inner working of this function:
83
+ - YT is transferred to the YT contract
84
+ - market.swap is called, which will transfer OT directly to the YT contract, and callback is invoked
85
+ - callback will call YT's redeemYO, which will redeem the outcome SCY to this router, then
86
+ all SCY owed to the market will be paid, the rest is transferred to the receiver
87
+ */
88
+ function _swapExactYtForScy(
89
+ address receiver,
90
+ address market,
91
+ uint256 exactYtIn,
92
+ uint256 minScyOut,
93
+ bool doPull
94
+ ) internal returns (uint256 netScyOut) {
95
+ (ISuperComposableYield SCY, , IPYieldToken YT) = IPMarket(market).readTokens();
96
+
97
+ // takes out the same amount of OT as exactYtIn, to pair together
98
+ uint256 exactOtOut = exactYtIn;
99
+
100
+ uint256 preBalanceScy = SCY.balanceOf(receiver);
101
+
102
+ if (doPull) {
103
+ YT.safeTransferFrom(msg.sender, address(YT), exactYtIn);
104
+ }
105
+
106
+ IPMarket(market).swapScyForExactOt(
107
+ receiver,
108
+ exactOtOut,
109
+ type(uint256).max,
110
+ abi.encode(YT_SWAP_TYPE.ExactYtForScy, receiver)
111
+ );
112
+
113
+ netScyOut = SCY.balanceOf(receiver) - preBalanceScy;
114
+ require(netScyOut >= minScyOut, "INSUFFICIENT_SCY_OUT");
115
+ }
116
+
117
+ /**
118
+ * @dev inner working of this function:
119
+ - market.swap is called, which will transfer SCY directly to the YT contract, and callback is invoked
120
+ - callback will pull more SCY if necessary, do call YT's mintYO, which will mint OT to the market & YT to the receiver
121
+ */
122
+ function _swapScyForExactYt(
123
+ address receiver,
124
+ address market,
125
+ uint256 exactYtOut,
126
+ uint256 maxScyIn
127
+ ) internal returns (uint256 netScyIn) {
128
+ (ISuperComposableYield SCY, , ) = IPMarket(market).readTokens();
129
+
130
+ uint256 exactOtIn = exactYtOut;
131
+ uint256 preBalanceScy = SCY.balanceOf(receiver);
132
+
133
+ IPMarket(market).swapExactOtForScy(
134
+ receiver,
135
+ exactOtIn,
136
+ 1,
137
+ abi.encode(YT_SWAP_TYPE.SCYForExactYt, msg.sender, receiver)
138
+ );
139
+
140
+ netScyIn = preBalanceScy - SCY.balanceOf(receiver);
141
+
142
+ require(netScyIn <= maxScyIn, "exceed out limit");
143
+ }
144
+
145
+ function swapCallback(
146
+ int256 otToAccount,
147
+ int256 scyToAccount,
148
+ bytes calldata data
149
+ ) external override onlyPendleMarket(msg.sender) {
150
+ (YT_SWAP_TYPE swapType, ) = abi.decode(data, (YT_SWAP_TYPE, bytes));
151
+
152
+ if (swapType == YT_SWAP_TYPE.ExactScyForYt) {
153
+ _swapExactScyForYt_callback(msg.sender, data);
154
+ } else if (swapType == YT_SWAP_TYPE.ExactYtForScy) {
155
+ _swapExactYtForScy_callback(msg.sender, scyToAccount, data);
156
+ } else if (swapType == YT_SWAP_TYPE.SCYForExactYt) {
157
+ _swapScyForExactYt_callback(msg.sender, otToAccount, scyToAccount, data);
158
+ } else {
159
+ require(false, "unknown swapType");
160
+ }
161
+ }
162
+
163
+ function _swapExactScyForYt_callback(address market, bytes calldata data) internal {
164
+ (, , IPYieldToken YT) = IPMarket(market).readTokens();
165
+ (, address receiver) = abi.decode(data, (YT_SWAP_TYPE, address));
166
+
167
+ YT.mintYO(market, receiver);
168
+ }
169
+
170
+ function _swapScyForExactYt_callback(
171
+ address market,
172
+ int256 otToAccount,
173
+ int256 scyToAccount,
174
+ bytes calldata data
175
+ ) internal {
176
+ (, address payer, address receiver) = abi.decode(data, (YT_SWAP_TYPE, address, address));
177
+ (ISuperComposableYield SCY, , IPYieldToken YT) = IPMarket(market).readTokens();
178
+
179
+ uint256 otOwed = otToAccount.neg().Uint();
180
+ uint256 scyReceived = scyToAccount.Uint();
181
+
182
+ // otOwed = totalAsset
183
+ uint256 scyNeedTotal = SCYUtils.assetToScy(SCY.scyIndexCurrent(), otOwed);
184
+
185
+ uint256 netScyToPull = scyNeedTotal.subMax0(scyReceived);
186
+ SCY.safeTransferFrom(payer, address(YT), netScyToPull);
187
+
188
+ YT.mintYO(market, receiver);
189
+ }
190
+
191
+ /**
192
+ @dev receive OT -> pair with YT to redeem SCY -> payback SCY
193
+ */
194
+ function _swapExactYtForScy_callback(
195
+ address market,
196
+ int256 scyToAccount,
197
+ bytes calldata data
198
+ ) internal {
199
+ (, address receiver) = abi.decode(data, (YT_SWAP_TYPE, address));
200
+ (ISuperComposableYield SCY, , IPYieldToken YT) = IPMarket(market).readTokens();
201
+
202
+ uint256 scyOwed = scyToAccount.neg().Uint();
203
+
204
+ uint256 netScyReceived = YT.redeemYO(address(this));
205
+
206
+ SCY.safeTransfer(market, scyOwed);
207
+
208
+ if (receiver != address(this)) {
209
+ SCY.safeTransfer(receiver, netScyReceived - scyOwed);
210
+ }
211
+ }
212
+ }
@@ -0,0 +1,34 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ /*
3
+ * MIT License
4
+ * ===========
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ */
23
+ pragma solidity 0.8.9;
24
+ import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";
25
+
26
+ interface IAToken is IERC20 {
27
+ /**
28
+ * @dev Returns the scaled balance of the user. The scaled balance is the sum of all the
29
+ * updated stored balance divided by the reserve's liquidity index at the moment of the update
30
+ * @param user The user whose balance is calculated
31
+ * @return The scaled balance of the user
32
+ **/
33
+ function scaledBalanceOf(address user) external view returns (uint256);
34
+ }
@@ -0,0 +1,41 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ /*
3
+ * MIT License
4
+ * ===========
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ */
23
+
24
+ pragma solidity 0.8.9;
25
+
26
+ interface IAavePool {
27
+ function supply(
28
+ address asset,
29
+ uint256 amount,
30
+ address onBehalfOf,
31
+ uint16 referralCode
32
+ ) external;
33
+
34
+ function withdraw(
35
+ address asset,
36
+ uint256 amount,
37
+ address to
38
+ ) external returns (uint256);
39
+
40
+ function getReserveNormalizedIncome(address asset) external view returns (uint256);
41
+ }
@@ -0,0 +1,32 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ /*
3
+ * MIT License
4
+ * ===========
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ */
23
+
24
+ pragma solidity 0.8.9;
25
+
26
+ interface IAaveRewardsController {
27
+ function claimAllRewards(address[] calldata assets, address to)
28
+ external
29
+ returns (address[] memory rewardsList, uint256[] memory claimedAmounts);
30
+
31
+ function getRewardsByAsset(address asset) external view returns (address[] memory);
32
+ }
@@ -0,0 +1,33 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ /*
3
+ * MIT License
4
+ * ===========
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ */
23
+ pragma solidity 0.8.9;
24
+
25
+ interface IBenQiComptroller {
26
+ function claimReward(
27
+ uint8 rewardType,
28
+ address[] memory holders,
29
+ address[] memory qiTokens,
30
+ bool borrowers,
31
+ bool suppliers
32
+ ) external;
33
+ }
@@ -0,0 +1,98 @@
1
+ // SPDX-License-Identifier: GPL-3.0
2
+
3
+ pragma solidity >=0.5.0;
4
+
5
+ interface IJoePair {
6
+ event Approval(address indexed owner, address indexed spender, uint256 value);
7
+ event Transfer(address indexed from, address indexed to, uint256 value);
8
+
9
+ function name() external pure returns (string memory);
10
+
11
+ function symbol() external pure returns (string memory);
12
+
13
+ function decimals() external pure returns (uint8);
14
+
15
+ function totalSupply() external view returns (uint256);
16
+
17
+ function balanceOf(address owner) external view returns (uint256);
18
+
19
+ function allowance(address owner, address spender) external view returns (uint256);
20
+
21
+ function approve(address spender, uint256 value) external returns (bool);
22
+
23
+ function transfer(address to, uint256 value) external returns (bool);
24
+
25
+ function transferFrom(
26
+ address from,
27
+ address to,
28
+ uint256 value
29
+ ) external returns (bool);
30
+
31
+ function DOMAIN_SEPARATOR() external view returns (bytes32);
32
+
33
+ function PERMIT_TYPEHASH() external pure returns (bytes32);
34
+
35
+ function nonces(address owner) external view returns (uint256);
36
+
37
+ function permit(
38
+ address owner,
39
+ address spender,
40
+ uint256 value,
41
+ uint256 deadline,
42
+ uint8 v,
43
+ bytes32 r,
44
+ bytes32 s
45
+ ) external;
46
+
47
+ event Mint(address indexed sender, uint256 amount0, uint256 amount1);
48
+ event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to);
49
+ event Swap(
50
+ address indexed sender,
51
+ uint256 amount0In,
52
+ uint256 amount1In,
53
+ uint256 amount0Out,
54
+ uint256 amount1Out,
55
+ address indexed to
56
+ );
57
+ event Sync(uint112 reserve0, uint112 reserve1);
58
+
59
+ function MINIMUM_LIQUIDITY() external pure returns (uint256);
60
+
61
+ function factory() external view returns (address);
62
+
63
+ function token0() external view returns (address);
64
+
65
+ function token1() external view returns (address);
66
+
67
+ function getReserves()
68
+ external
69
+ view
70
+ returns (
71
+ uint112 reserve0,
72
+ uint112 reserve1,
73
+ uint32 blockTimestampLast
74
+ );
75
+
76
+ function price0CumulativeLast() external view returns (uint256);
77
+
78
+ function price1CumulativeLast() external view returns (uint256);
79
+
80
+ function kLast() external view returns (uint256);
81
+
82
+ function mint(address to) external returns (uint256 liquidity);
83
+
84
+ function burn(address to) external returns (uint256 amount0, uint256 amount1);
85
+
86
+ function swap(
87
+ uint256 amount0Out,
88
+ uint256 amount1Out,
89
+ address to,
90
+ bytes calldata data
91
+ ) external;
92
+
93
+ function skim(address to) external;
94
+
95
+ function sync() external;
96
+
97
+ function initialize(address, address) external;
98
+ }
@@ -0,0 +1,162 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+
3
+ pragma solidity 0.8.9;
4
+
5
+ interface IJoeRouter01 {
6
+ function addLiquidity(
7
+ address tokenA,
8
+ address tokenB,
9
+ uint256 amountADesired,
10
+ uint256 amountBDesired,
11
+ uint256 amountAMin,
12
+ uint256 amountBMin,
13
+ address to,
14
+ uint256 deadline
15
+ )
16
+ external
17
+ returns (
18
+ uint256 amountA,
19
+ uint256 amountB,
20
+ uint256 liquidity
21
+ );
22
+
23
+ function addLiquidityAVAX(
24
+ address token,
25
+ uint256 amountTokenDesired,
26
+ uint256 amountTokenMin,
27
+ uint256 amountAVAXMin,
28
+ address to,
29
+ uint256 deadline
30
+ )
31
+ external
32
+ payable
33
+ returns (
34
+ uint256 amountToken,
35
+ uint256 amountAVAX,
36
+ uint256 liquidity
37
+ );
38
+
39
+ function removeLiquidity(
40
+ address tokenA,
41
+ address tokenB,
42
+ uint256 liquidity,
43
+ uint256 amountAMin,
44
+ uint256 amountBMin,
45
+ address to,
46
+ uint256 deadline
47
+ ) external returns (uint256 amountA, uint256 amountB);
48
+
49
+ function removeLiquidityAVAX(
50
+ address token,
51
+ uint256 liquidity,
52
+ uint256 amountTokenMin,
53
+ uint256 amountAVAXMin,
54
+ address to,
55
+ uint256 deadline
56
+ ) external returns (uint256 amountToken, uint256 amountAVAX);
57
+
58
+ function removeLiquidityWithPermit(
59
+ address tokenA,
60
+ address tokenB,
61
+ uint256 liquidity,
62
+ uint256 amountAMin,
63
+ uint256 amountBMin,
64
+ address to,
65
+ uint256 deadline,
66
+ bool approveMax,
67
+ uint8 v,
68
+ bytes32 r,
69
+ bytes32 s
70
+ ) external returns (uint256 amountA, uint256 amountB);
71
+
72
+ function removeLiquidityAVAXWithPermit(
73
+ address token,
74
+ uint256 liquidity,
75
+ uint256 amountTokenMin,
76
+ uint256 amountAVAXMin,
77
+ address to,
78
+ uint256 deadline,
79
+ bool approveMax,
80
+ uint8 v,
81
+ bytes32 r,
82
+ bytes32 s
83
+ ) external returns (uint256 amountToken, uint256 amountAVAX);
84
+
85
+ function swapExactTokensForTokens(
86
+ uint256 amountIn,
87
+ uint256 amountOutMin,
88
+ address[] calldata path,
89
+ address to,
90
+ uint256 deadline
91
+ ) external returns (uint256[] memory amounts);
92
+
93
+ function swapTokensForExactTokens(
94
+ uint256 amountOut,
95
+ uint256 amountInMax,
96
+ address[] calldata path,
97
+ address to,
98
+ uint256 deadline
99
+ ) external returns (uint256[] memory amounts);
100
+
101
+ function swapExactAVAXForTokens(
102
+ uint256 amountOutMin,
103
+ address[] calldata path,
104
+ address to,
105
+ uint256 deadline
106
+ ) external payable returns (uint256[] memory amounts);
107
+
108
+ function swapTokensForExactAVAX(
109
+ uint256 amountOut,
110
+ uint256 amountInMax,
111
+ address[] calldata path,
112
+ address to,
113
+ uint256 deadline
114
+ ) external returns (uint256[] memory amounts);
115
+
116
+ function swapExactTokensForAVAX(
117
+ uint256 amountIn,
118
+ uint256 amountOutMin,
119
+ address[] calldata path,
120
+ address to,
121
+ uint256 deadline
122
+ ) external returns (uint256[] memory amounts);
123
+
124
+ function swapAVAXForExactTokens(
125
+ uint256 amountOut,
126
+ address[] calldata path,
127
+ address to,
128
+ uint256 deadline
129
+ ) external payable returns (uint256[] memory amounts);
130
+
131
+ function getAmountsOut(uint256 amountIn, address[] calldata path)
132
+ external
133
+ view
134
+ returns (uint256[] memory amounts);
135
+
136
+ function getAmountsIn(uint256 amountOut, address[] calldata path)
137
+ external
138
+ view
139
+ returns (uint256[] memory amounts);
140
+
141
+ function quote(
142
+ uint256 amountA,
143
+ uint256 reserveA,
144
+ uint256 reserveB
145
+ ) external pure returns (uint256 amountB);
146
+
147
+ function getAmountOut(
148
+ uint256 amountIn,
149
+ uint256 reserveIn,
150
+ uint256 reserveOut
151
+ ) external pure returns (uint256 amountOut);
152
+
153
+ function getAmountIn(
154
+ uint256 amountOut,
155
+ uint256 reserveIn,
156
+ uint256 reserveOut
157
+ ) external pure returns (uint256 amountIn);
158
+
159
+ function factory() external pure returns (address);
160
+
161
+ function WAVAX() external pure returns (address);
162
+ }
@@ -0,0 +1,9 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ pragma solidity 0.8.9;
3
+ import "openzeppelin-solidity/contracts/token/ERC20/extensions/IERC20Metadata.sol";
4
+
5
+ interface IPBaseToken is IERC20Metadata {
6
+ function expiry() external view returns (uint256);
7
+
8
+ function isExpired() external view returns (bool);
9
+ }
@@ -0,0 +1,10 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ pragma solidity 0.8.9;
3
+
4
+ interface IPFlashCallback {
5
+ function pendleFlashCallback(
6
+ address[] calldata tokens,
7
+ uint256[] calldata amountsToPay,
8
+ bytes calldata data
9
+ ) external;
10
+ }
@@ -0,0 +1,28 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ /*
3
+ * MIT License
4
+ * ===========
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ */
23
+
24
+ pragma solidity 0.8.9;
25
+
26
+ interface IPGovernanceManager {
27
+ function governance() external view returns (address);
28
+ }