@pendle/core-v2 2.17.5-tradingbot → 2.17.6-tradingbot

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 (287) hide show
  1. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol/PendleMsgReceiveEndpointUpg.dbg.json +1 -1
  2. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol/PendleMsgReceiveEndpointUpg.json +2 -2
  3. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiverAppUpg.sol/PendleMsgReceiverAppUpg.dbg.json +1 -1
  4. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol/PendleMsgSendEndpointUpg.dbg.json +1 -1
  5. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol/PendleMsgSendEndpointUpg.json +2 -2
  6. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSenderAppUpg.sol/PendleMsgSenderAppUpg.dbg.json +1 -1
  7. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol/PendleGaugeControllerBaseUpg.dbg.json +1 -1
  8. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.dbg.json +1 -1
  9. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.json +2 -2
  10. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.dbg.json +1 -1
  11. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.json +2 -2
  12. package/build/artifacts/contracts/LiquidityMining/VeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.dbg.json +1 -1
  13. package/build/artifacts/contracts/LiquidityMining/VeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.json +2 -2
  14. package/build/artifacts/contracts/LiquidityMining/VeDistributor/PendleFeeDistributorV2.sol/PendleFeeDistributorV2.dbg.json +1 -1
  15. package/build/artifacts/contracts/LiquidityMining/VeDistributor/PendleFeeDistributorV2.sol/PendleFeeDistributorV2.json +2 -2
  16. package/build/artifacts/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.dbg.json +1 -1
  17. package/build/artifacts/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.json +2 -2
  18. package/build/artifacts/contracts/LiquidityMining/VotingController/VotingControllerStorageUpg.sol/VotingControllerStorageUpg.dbg.json +1 -1
  19. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.dbg.json +1 -1
  20. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.json +2 -2
  21. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.dbg.json +1 -1
  22. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.json +2 -2
  23. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol/VotingEscrowTokenBase.dbg.json +1 -1
  24. package/build/artifacts/contracts/LiquidityMining/libraries/VeBalanceLib.sol/VeBalanceLib.dbg.json +1 -1
  25. package/build/artifacts/contracts/LiquidityMining/libraries/VeBalanceLib.sol/VeBalanceLib.json +2 -2
  26. package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/CheckpointHelper.dbg.json +1 -1
  27. package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/CheckpointHelper.json +2 -2
  28. package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/Checkpoints.dbg.json +1 -1
  29. package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/Checkpoints.json +2 -2
  30. package/build/artifacts/contracts/core/BulkSeller/BulkSeller.sol/BulkSeller.dbg.json +1 -1
  31. package/build/artifacts/contracts/core/BulkSeller/BulkSeller.sol/BulkSeller.json +2 -2
  32. package/build/artifacts/contracts/core/BulkSeller/BulkSellerFactory.sol/BulkSellerFactory.dbg.json +1 -1
  33. package/build/artifacts/contracts/core/BulkSeller/BulkSellerFactory.sol/BulkSellerFactory.json +2 -2
  34. package/build/artifacts/contracts/core/BulkSeller/BulkSellerMathCore.sol/BulkSellerMathCore.dbg.json +1 -1
  35. package/build/artifacts/contracts/core/BulkSeller/BulkSellerMathCore.sol/BulkSellerMathCore.json +2 -2
  36. package/build/artifacts/contracts/core/Market/MarketMathCore.sol/MarketMathCore.dbg.json +1 -1
  37. package/build/artifacts/contracts/core/Market/MarketMathCore.sol/MarketMathCore.json +2 -2
  38. package/build/artifacts/contracts/core/Market/OracleLib.sol/OracleLib.dbg.json +1 -1
  39. package/build/artifacts/contracts/core/Market/OracleLib.sol/OracleLib.json +2 -2
  40. package/build/artifacts/contracts/core/Market/PendleGauge.sol/PendleGauge.dbg.json +1 -1
  41. package/build/artifacts/contracts/core/Market/PendleMarket.sol/PendleMarket.dbg.json +1 -1
  42. package/build/artifacts/contracts/core/Market/PendleMarket.sol/PendleMarket.json +2 -2
  43. package/build/artifacts/contracts/core/Market/PendleMarketFactory.sol/PendleMarketFactory.dbg.json +1 -1
  44. package/build/artifacts/contracts/core/Market/PendleMarketFactory.sol/PendleMarketFactory.json +2 -2
  45. package/build/artifacts/contracts/core/StandardizedYield/SYBase.sol/SYBase.dbg.json +1 -1
  46. package/build/artifacts/contracts/core/StandardizedYield/SYBaseWithRewards.sol/SYBaseWithRewards.dbg.json +1 -1
  47. package/build/artifacts/contracts/core/StandardizedYield/implementations/Ape/sAPE.sol/sAPE.dbg.json +1 -1
  48. package/build/artifacts/contracts/core/StandardizedYield/implementations/Ape/sAPE.sol/sAPE.json +2 -2
  49. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraBbAWethSwethSY.sol/PendleAuraBbAWethSwethSY.dbg.json +1 -1
  50. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraBbAWethSwethSY.sol/PendleAuraBbAWethSwethSY.json +2 -2
  51. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethAnkrethSYV2.sol/PendleAuraWethAnkrethSYV2.dbg.json +1 -1
  52. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethAnkrethSYV2.sol/PendleAuraWethAnkrethSYV2.json +2 -2
  53. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethRocketEthSYV2.sol/PendleAuraWethRocketEthSYV2.dbg.json +1 -1
  54. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethRocketEthSYV2.sol/PendleAuraWethRocketEthSYV2.json +2 -2
  55. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethStafiEthSY.sol/PendleAuraWethStafiEthSY.dbg.json +1 -1
  56. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethStafiEthSY.sol/PendleAuraWethStafiEthSY.json +2 -2
  57. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethWstethSYV2.sol/PendleAuraWethWstethSYV2.dbg.json +1 -1
  58. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethWstethSYV2.sol/PendleAuraWethWstethSYV2.json +2 -2
  59. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/PendleAuraBalancerStableLPSYV2.sol/PendleAuraBalancerStableLPSYV2.dbg.json +1 -1
  60. package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.dbg.json +1 -1
  61. package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.json +2 -2
  62. package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol/PendleQiTokenSY.dbg.json +1 -1
  63. package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol/PendleQiTokenSY.json +2 -2
  64. package/build/artifacts/contracts/core/StandardizedYield/implementations/CamelotV1Volatile/PendleCamelotV1VolatileSY.sol/PendleCamelotV1VolatileSY.dbg.json +1 -1
  65. package/build/artifacts/contracts/core/StandardizedYield/implementations/CamelotV1Volatile/PendleCamelotV1VolatileSY.sol/PendleCamelotV1VolatileSY.json +2 -2
  66. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol/PendleCurveFraxUsdcSY.dbg.json +1 -1
  67. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol/PendleCurveFraxUsdcSY.json +2 -2
  68. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol/PendleCurveUsdd3CrvSY.dbg.json +1 -1
  69. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol/PendleCurveUsdd3CrvSY.json +2 -2
  70. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/PendleConvexLPSY.sol/PendleConvexLPSY.dbg.json +1 -1
  71. package/build/artifacts/contracts/core/StandardizedYield/implementations/GLP/PendleGlpSY.sol/PendleGlpSY.dbg.json +1 -1
  72. package/build/artifacts/contracts/core/StandardizedYield/implementations/GLP/PendleGlpSY.sol/PendleGlpSY.json +2 -2
  73. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleArbitrumStakedEthSY.sol/PendleArbitrumStakedEthSY.dbg.json +4 -0
  74. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleArbitrumStakedEthSY.sol/PendleArbitrumStakedEthSY.json +976 -0
  75. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleBinanceEth.sol/PendleBinanceEth.dbg.json +4 -0
  76. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleBinanceEth.sol/PendleBinanceEth.json +979 -0
  77. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleGdaiSY.sol/PendleGDaiSY.dbg.json +1 -1
  78. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleGdaiSY.sol/PendleGDaiSY.json +2 -2
  79. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleLooksStakingSY.sol/PendleLooksStakingSY.dbg.json +1 -1
  80. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleLooksStakingSY.sol/PendleLooksStakingSY.json +2 -2
  81. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleSfrxEthSY.sol/PendleSfrxEthSY.dbg.json +1 -1
  82. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleSfrxEthSY.sol/PendleSfrxEthSY.json +2 -2
  83. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleStargateLPSY.sol/PendleStargateLPSY.dbg.json +1 -1
  84. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleStargateLPSY.sol/PendleStargateLPSY.json +2 -2
  85. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol/PendleWstEthSY.dbg.json +1 -1
  86. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol/PendleWstEthSY.json +2 -2
  87. package/build/artifacts/contracts/core/YieldContracts/PendlePrincipalToken.sol/PendlePrincipalToken.dbg.json +1 -1
  88. package/build/artifacts/contracts/core/YieldContracts/PendlePrincipalToken.sol/PendlePrincipalToken.json +2 -2
  89. package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.dbg.json +1 -1
  90. package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.json +2 -2
  91. package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.dbg.json +1 -1
  92. package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.json +2 -2
  93. package/build/artifacts/contracts/core/YieldContractsV2/PendlePrincipalTokenV2.sol/PendlePrincipalTokenV2.dbg.json +1 -1
  94. package/build/artifacts/contracts/core/YieldContractsV2/PendlePrincipalTokenV2.sol/PendlePrincipalTokenV2.json +2 -2
  95. package/build/artifacts/contracts/core/YieldContractsV2/PendleYieldContractFactoryV2.sol/PendleYieldContractFactoryV2.dbg.json +1 -1
  96. package/build/artifacts/contracts/core/YieldContractsV2/PendleYieldContractFactoryV2.sol/PendleYieldContractFactoryV2.json +2 -2
  97. package/build/artifacts/contracts/core/YieldContractsV2/PendleYieldTokenV2.sol/PendleYieldTokenV2.dbg.json +1 -1
  98. package/build/artifacts/contracts/core/YieldContractsV2/PendleYieldTokenV2.sol/PendleYieldTokenV2.json +2 -2
  99. package/build/artifacts/contracts/core/libraries/Errors.sol/Errors.dbg.json +1 -1
  100. package/build/artifacts/contracts/core/libraries/Errors.sol/Errors.json +2 -151
  101. package/build/artifacts/contracts/interfaces/BinanceEth/IWBETH.sol/IWBETH.dbg.json +4 -0
  102. package/build/artifacts/contracts/interfaces/BinanceEth/IWBETH.sol/IWBETH.json +42 -0
  103. package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.dbg.json +1 -1
  104. package/build/artifacts/contracts/interfaces/IPActionInfoStatic.sol/IPActionInfoStatic.dbg.json +1 -1
  105. package/build/artifacts/contracts/interfaces/IPActionMarketAuxStatic.sol/IPActionMarketAuxStatic.dbg.json +1 -1
  106. package/build/artifacts/contracts/interfaces/IPActionMarketAuxStatic.sol/IPActionMarketAuxStatic.json +82 -6
  107. package/build/artifacts/contracts/interfaces/IPActionMarketCoreStatic.sol/IPActionMarketCoreStatic.dbg.json +1 -1
  108. package/build/artifacts/contracts/interfaces/IPActionMarketCoreStatic.sol/IPActionMarketCoreStatic.json +22 -22
  109. package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.dbg.json +1 -1
  110. package/build/artifacts/contracts/interfaces/IPActionMintRedeemStatic.sol/IPActionMintRedeemStatic.dbg.json +1 -1
  111. package/build/artifacts/contracts/interfaces/IPActionMintRedeemStatic.sol/IPActionMintRedeemStatic.json +42 -4
  112. package/build/artifacts/contracts/interfaces/IPActionStorageStatic.sol/IPActionStorageStatic.dbg.json +1 -1
  113. package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.dbg.json +1 -1
  114. package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.dbg.json +1 -1
  115. package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.dbg.json +1 -1
  116. package/build/artifacts/contracts/interfaces/IPBulkSeller.sol/IPBulkSeller.dbg.json +1 -1
  117. package/build/artifacts/contracts/interfaces/IPMarket.sol/IPMarket.dbg.json +1 -1
  118. package/build/artifacts/contracts/interfaces/IPRouterHelper.sol/IPRouterHelper.dbg.json +1 -1
  119. package/build/artifacts/contracts/interfaces/IPRouterStatic.sol/IPRouterStatic.dbg.json +1 -1
  120. package/build/artifacts/contracts/interfaces/IPRouterStatic.sol/IPRouterStatic.json +146 -32
  121. package/build/artifacts/contracts/interfaces/IPVotingController.sol/IPVotingController.dbg.json +1 -1
  122. package/build/artifacts/contracts/interfaces/IPVotingEscrowMainchain.sol/IPVotingEscrowMainchain.dbg.json +1 -1
  123. package/build/artifacts/contracts/interfaces/IStandardizedYield.sol/IStandardizedYield.dbg.json +1 -1
  124. package/build/artifacts/contracts/offchain-helpers/BoringLpSeller.sol/BoringLpSeller.dbg.json +1 -1
  125. package/build/artifacts/contracts/offchain-helpers/BoringPtSeller.sol/BoringPtSeller.dbg.json +1 -1
  126. package/build/artifacts/contracts/offchain-helpers/Broadcaster.sol/Broadcaster.dbg.json +1 -1
  127. package/build/artifacts/contracts/offchain-helpers/Broadcaster.sol/Broadcaster.json +2 -2
  128. package/build/artifacts/contracts/offchain-helpers/BulkSellerOffchain.sol/BulkSellerOffchain.dbg.json +1 -1
  129. package/build/artifacts/contracts/offchain-helpers/BulkSellerOffchain.sol/BulkSellerOffchain.json +2 -2
  130. package/build/artifacts/contracts/offchain-helpers/MarketExchangeRateLib.sol/MarketExchangeRateLib.dbg.json +1 -1
  131. package/build/artifacts/contracts/offchain-helpers/MarketExchangeRateLib.sol/MarketExchangeRateLib.json +2 -2
  132. package/build/artifacts/contracts/offchain-helpers/PtAndLpToAsset.sol/PtAndLpToAsset.dbg.json +4 -0
  133. package/build/artifacts/contracts/offchain-helpers/PtAndLpToAsset.sol/PtAndLpToAsset.json +97 -0
  134. package/build/artifacts/contracts/offchain-helpers/router-static/PendleRouterStatic.sol/PendleRouterStatic.dbg.json +1 -1
  135. package/build/artifacts/contracts/offchain-helpers/router-static/PendleRouterStatic.sol/PendleRouterStatic.json +2 -2
  136. package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionInfoStatic.sol/ActionInfoStatic.dbg.json +1 -1
  137. package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionInfoStatic.sol/ActionInfoStatic.json +2 -2
  138. package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionMarketAuxStatic.sol/ActionMarketAuxStatic.dbg.json +1 -1
  139. package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionMarketAuxStatic.sol/ActionMarketAuxStatic.json +84 -8
  140. package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionMarketCoreStatic.sol/ActionMarketCoreStatic.dbg.json +1 -1
  141. package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionMarketCoreStatic.sol/ActionMarketCoreStatic.json +24 -24
  142. package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionMintRedeemStatic.sol/ActionMintRedeemStatic.dbg.json +1 -1
  143. package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionMintRedeemStatic.sol/ActionMintRedeemStatic.json +44 -6
  144. package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionStorageStatic.sol/ActionStorageStatic.dbg.json +1 -1
  145. package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionStorageStatic.sol/ActionStorageStatic.json +2 -2
  146. package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionVePendleStatic.sol/ActionVePendleStatic.dbg.json +1 -1
  147. package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionVePendleStatic.sol/ActionVePendleStatic.json +2 -2
  148. package/build/artifacts/contracts/offchain-helpers/router-static/base/StorageLayout.sol/StorageLayout.dbg.json +1 -1
  149. package/build/artifacts/contracts/oracles/PendleLpOracleLib.sol/PendleLpOracleLib.dbg.json +1 -1
  150. package/build/artifacts/contracts/oracles/PendleLpOracleLib.sol/PendleLpOracleLib.json +2 -2
  151. package/build/artifacts/contracts/oracles/PendlePtOracle.sol/PendlePtOracle.dbg.json +1 -1
  152. package/build/artifacts/contracts/oracles/PendlePtOracle.sol/PendlePtOracle.json +2 -2
  153. package/build/artifacts/contracts/oracles/PendlePtOracleLib.sol/PendlePtOracleLib.dbg.json +1 -1
  154. package/build/artifacts/contracts/oracles/PendlePtOracleLib.sol/PendlePtOracleLib.json +2 -2
  155. package/build/artifacts/contracts/oracles/samples/PendleLpGlpOracle.sol/PendleLpGlpOracle.dbg.json +1 -1
  156. package/build/artifacts/contracts/oracles/samples/PendleLpGlpOracle.sol/PendleLpGlpOracle.json +2 -2
  157. package/build/artifacts/contracts/oracles/samples/PendlePtGlpOracle.sol/PendlePtGlpOracle.dbg.json +1 -1
  158. package/build/artifacts/contracts/oracles/samples/PendlePtGlpOracle.sol/PendlePtGlpOracle.json +2 -2
  159. package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.dbg.json +1 -1
  160. package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.json +2 -2
  161. package/build/artifacts/contracts/router/ActionMintRedeem.sol/ActionMintRedeem.dbg.json +1 -1
  162. package/build/artifacts/contracts/router/ActionMintRedeem.sol/ActionMintRedeem.json +2 -2
  163. package/build/artifacts/contracts/router/ActionSwapPT.sol/ActionSwapPT.dbg.json +1 -1
  164. package/build/artifacts/contracts/router/ActionSwapPT.sol/ActionSwapPT.json +2 -2
  165. package/build/artifacts/contracts/router/ActionSwapYT.sol/ActionSwapYT.dbg.json +1 -1
  166. package/build/artifacts/contracts/router/ActionSwapYT.sol/ActionSwapYT.json +2 -2
  167. package/build/artifacts/contracts/router/PendleRouter.sol/PendleRouter.dbg.json +1 -1
  168. package/build/artifacts/contracts/router/PendleRouter.sol/PendleRouter.json +2 -2
  169. package/build/artifacts/contracts/router/PendleRouterHelper.sol/PendleRouterHelper.dbg.json +1 -1
  170. package/build/artifacts/contracts/router/PendleRouterHelper.sol/PendleRouterHelper.json +2 -2
  171. package/build/artifacts/contracts/router/base/ActionBaseCallback.sol/ActionBaseCallback.dbg.json +1 -1
  172. package/build/artifacts/contracts/router/base/ActionBaseMintRedeem.sol/ActionBaseMintRedeem.dbg.json +1 -1
  173. package/build/artifacts/contracts/router/base/CallbackHelper.sol/CallbackHelper.dbg.json +1 -1
  174. package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtInLib.dbg.json +1 -1
  175. package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtInLib.json +2 -2
  176. package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtOutLib.dbg.json +1 -1
  177. package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtOutLib.json +2 -2
  178. package/contracts/core/TradingBot/BotActionCallback.sol +1 -1
  179. package/contracts/core/TradingBot/BotDecisionHelper.sol +306 -0
  180. package/contracts/core/TradingBot/BotSimulationLib.sol +8 -7
  181. package/contracts/core/TradingBot/LongYieldTradingBot.sol +20 -24
  182. package/contracts/core/TradingBot/MarketExtLib.sol +64 -31
  183. package/contracts/core/TradingBot/README.md +27 -25
  184. package/contracts/core/TradingBot/TradingBotBase.sol +36 -16
  185. package/contracts/interfaces/TradingBot/IBotDecisionHelper.sol +91 -0
  186. package/contracts/interfaces/TradingBot/ILongYieldTradingBot.sol +7 -32
  187. package/contracts/interfaces/TradingBot/ITradingBotBase.sol +6 -4
  188. package/package.json +1 -1
  189. package/typechain-types/ActionMarketAuxStatic.ts +191 -38
  190. package/typechain-types/ActionMarketCoreStatic.ts +600 -134
  191. package/typechain-types/ActionMintRedeemStatic.ts +92 -26
  192. package/typechain-types/IPActionMarketAuxStatic.ts +191 -38
  193. package/typechain-types/IPActionMarketCoreStatic.ts +600 -134
  194. package/typechain-types/IPActionMintRedeemStatic.ts +92 -26
  195. package/typechain-types/IPRouterStatic.ts +888 -197
  196. package/typechain-types/IWBETH.ts +128 -0
  197. package/typechain-types/PendleBinanceEth.ts +1229 -0
  198. package/typechain-types/PtAndLpToAsset.ts +136 -0
  199. package/typechain-types/factories/ActionAddRemoveLiq__factory.ts +1 -1
  200. package/typechain-types/factories/ActionInfoStatic__factory.ts +1 -1
  201. package/typechain-types/factories/ActionMarketAuxStatic__factory.ts +83 -7
  202. package/typechain-types/factories/ActionMarketCoreStatic__factory.ts +23 -23
  203. package/typechain-types/factories/ActionMintRedeemStatic__factory.ts +43 -5
  204. package/typechain-types/factories/ActionMintRedeem__factory.ts +1 -1
  205. package/typechain-types/factories/ActionStorageStatic__factory.ts +1 -1
  206. package/typechain-types/factories/ActionSwapPT__factory.ts +1 -1
  207. package/typechain-types/factories/ActionSwapYT__factory.ts +1 -1
  208. package/typechain-types/factories/ActionVePendleStatic__factory.ts +1 -1
  209. package/typechain-types/factories/Broadcaster__factory.ts +1 -1
  210. package/typechain-types/factories/BulkSellerFactory__factory.ts +1 -1
  211. package/typechain-types/factories/BulkSellerOffchain__factory.ts +1 -1
  212. package/typechain-types/factories/BulkSeller__factory.ts +1 -1
  213. package/typechain-types/factories/Errors__factory.ts +1 -150
  214. package/typechain-types/factories/IPActionMarketAuxStatic__factory.ts +82 -6
  215. package/typechain-types/factories/IPActionMarketCoreStatic__factory.ts +22 -22
  216. package/typechain-types/factories/IPActionMintRedeemStatic__factory.ts +42 -4
  217. package/typechain-types/factories/IPRouterStatic__factory.ts +146 -32
  218. package/typechain-types/factories/IWBETH__factory.ts +51 -0
  219. package/typechain-types/factories/OracleLib__factory.ts +1 -1
  220. package/typechain-types/factories/PendleAuraBbAWethSwethSY__factory.ts +1 -1
  221. package/typechain-types/factories/PendleAuraWethAnkrethSYV2__factory.ts +1 -1
  222. package/typechain-types/factories/PendleAuraWethRocketEthSYV2__factory.ts +1 -1
  223. package/typechain-types/factories/PendleAuraWethStafiEthSY__factory.ts +1 -1
  224. package/typechain-types/factories/PendleAuraWethWstethSYV2__factory.ts +1 -1
  225. package/typechain-types/factories/PendleBinanceEth__factory.ts +1052 -0
  226. package/typechain-types/factories/PendleCamelotV1VolatileSY__factory.ts +1 -1
  227. package/typechain-types/factories/PendleCurveFraxUsdcSY__factory.ts +1 -1
  228. package/typechain-types/factories/PendleCurveUsdd3CrvSY__factory.ts +1 -1
  229. package/typechain-types/factories/PendleFeeDistributorV2__factory.ts +1 -1
  230. package/typechain-types/factories/PendleFeeDistributor__factory.ts +1 -1
  231. package/typechain-types/factories/PendleGDaiSY__factory.ts +1 -1
  232. package/typechain-types/factories/PendleGaugeControllerMainchainUpg__factory.ts +1 -1
  233. package/typechain-types/factories/PendleGaugeControllerSidechainUpg__factory.ts +1 -1
  234. package/typechain-types/factories/PendleGlpSY__factory.ts +1 -1
  235. package/typechain-types/factories/PendleLooksStakingSY__factory.ts +1 -1
  236. package/typechain-types/factories/PendleLpGlpOracle__factory.ts +1 -1
  237. package/typechain-types/factories/PendleMarketFactory__factory.ts +1 -1
  238. package/typechain-types/factories/PendleMarket__factory.ts +1 -1
  239. package/typechain-types/factories/PendleMsgReceiveEndpointUpg__factory.ts +1 -1
  240. package/typechain-types/factories/PendleMsgSendEndpointUpg__factory.ts +1 -1
  241. package/typechain-types/factories/PendlePrincipalTokenV2__factory.ts +1 -1
  242. package/typechain-types/factories/PendlePrincipalToken__factory.ts +1 -1
  243. package/typechain-types/factories/PendlePtGlpOracle__factory.ts +1 -1
  244. package/typechain-types/factories/PendlePtOracle__factory.ts +1 -1
  245. package/typechain-types/factories/PendleQiTokenHelper__factory.ts +1 -1
  246. package/typechain-types/factories/PendleQiTokenSY__factory.ts +1 -1
  247. package/typechain-types/factories/PendleRouterHelper__factory.ts +1 -1
  248. package/typechain-types/factories/PendleRouterStatic__factory.ts +1 -1
  249. package/typechain-types/factories/PendleRouter__factory.ts +1 -1
  250. package/typechain-types/factories/PendleSfrxEthSY__factory.ts +1 -1
  251. package/typechain-types/factories/PendleStargateLPSY__factory.ts +1 -1
  252. package/typechain-types/factories/PendleVotingControllerUpg__factory.ts +1 -1
  253. package/typechain-types/factories/PendleWstEthSY__factory.ts +1 -1
  254. package/typechain-types/factories/PendleYieldContractFactoryV2__factory.ts +1 -1
  255. package/typechain-types/factories/PendleYieldContractFactory__factory.ts +1 -1
  256. package/typechain-types/factories/PendleYieldTokenV2__factory.ts +1 -1
  257. package/typechain-types/factories/PendleYieldToken__factory.ts +1 -1
  258. package/typechain-types/factories/PtAndLpToAsset__factory.ts +150 -0
  259. package/typechain-types/factories/SAPE__factory.ts +1 -1
  260. package/typechain-types/factories/VotingEscrowPendleMainchain__factory.ts +1 -1
  261. package/typechain-types/factories/VotingEscrowPendleSidechain__factory.ts +1 -1
  262. package/typechain-types/hardhat.d.ts +36 -81
  263. package/typechain-types/index.ts +8 -18
  264. package/build/artifacts/contracts/core/TradingBot/BotActionCallback.sol/BotActionCallback.dbg.json +0 -4
  265. package/build/artifacts/contracts/core/TradingBot/BotActionCallback.sol/BotActionCallback.json +0 -638
  266. package/build/artifacts/contracts/core/TradingBot/BotActionHelper.sol/BotActionHelper.dbg.json +0 -4
  267. package/build/artifacts/contracts/core/TradingBot/BotActionHelper.sol/BotActionHelper.json +0 -638
  268. package/build/artifacts/contracts/core/TradingBot/BotDecisionLib.sol/BotDecisionLib.dbg.json +0 -4
  269. package/build/artifacts/contracts/core/TradingBot/BotDecisionLib.sol/BotDecisionLib.json +0 -589
  270. package/build/artifacts/contracts/core/TradingBot/BotSimulationLib.sol/BotSimulationLib.dbg.json +0 -4
  271. package/build/artifacts/contracts/core/TradingBot/BotSimulationLib.sol/BotSimulationLib.json +0 -10
  272. package/build/artifacts/contracts/core/TradingBot/LongYieldTradingBot.sol/LongYieldTradingBot.dbg.json +0 -4
  273. package/build/artifacts/contracts/core/TradingBot/LongYieldTradingBot.sol/LongYieldTradingBot.json +0 -1887
  274. package/build/artifacts/contracts/core/TradingBot/MarketExtLib.sol/MarketExtLib.dbg.json +0 -4
  275. package/build/artifacts/contracts/core/TradingBot/MarketExtLib.sol/MarketExtLib.json +0 -24
  276. package/build/artifacts/contracts/core/TradingBot/TradingBotBase.sol/TradingBotBase.dbg.json +0 -4
  277. package/build/artifacts/contracts/core/TradingBot/TradingBotBase.sol/TradingBotBase.json +0 -588
  278. package/build/artifacts/contracts/core/TradingBot/TradingBotOffchain.sol/TradingBotOffchain.dbg.json +0 -4
  279. package/build/artifacts/contracts/core/TradingBot/TradingBotOffchain.sol/TradingBotOffchain.json +0 -1075
  280. package/build/artifacts/contracts/core/libraries/TokenAmountLib.sol/TokenAmountLib.dbg.json +0 -4
  281. package/build/artifacts/contracts/core/libraries/TokenAmountLib.sol/TokenAmountLib.json +0 -10
  282. package/build/artifacts/contracts/interfaces/TradingBot/ILongYieldTradingBot.sol/ILongYieldTradingBot.dbg.json +0 -4
  283. package/build/artifacts/contracts/interfaces/TradingBot/ILongYieldTradingBot.sol/ILongYieldTradingBot.json +0 -889
  284. package/build/artifacts/contracts/interfaces/TradingBot/ITradingBotBase.sol/ITradingBotBase.dbg.json +0 -4
  285. package/build/artifacts/contracts/interfaces/TradingBot/ITradingBotBase.sol/ITradingBotBase.json +0 -390
  286. package/contracts/core/TradingBot/BotDecisionLib.sol +0 -274
  287. package/contracts/core/TradingBot/TradingBotOffchain.sol +0 -141
@@ -3,7 +3,6 @@ pragma solidity 0.8.17;
3
3
 
4
4
  import "./TradingBotBase.sol";
5
5
  import "./BotActionHelper.sol";
6
- import "./BotDecisionLib.sol";
7
6
  import "../../interfaces/TradingBot/ILongYieldTradingBot.sol";
8
7
  import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
9
8
 
@@ -14,14 +13,14 @@ contract LongYieldTradingBot is
14
13
  UUPSUpgradeable
15
14
  {
16
15
  LongTradingSpecs public specs;
17
- address public immutable decisionLib;
16
+ IBotDecisionHelper public immutable decisionHelper;
18
17
 
19
18
  constructor(
20
19
  address _market,
21
20
  address _PENDLE,
22
- address _decisionLib
21
+ address _decisionHelper
23
22
  ) TradingBotBase(_market, _PENDLE) {
24
- decisionLib = _decisionLib;
23
+ decisionHelper = BotDecisionHelper(_decisionHelper);
25
24
  }
26
25
 
27
26
  function _authorizeUpgrade(address) internal override onlyOwner {}
@@ -36,22 +35,27 @@ contract LongYieldTradingBot is
36
35
  }
37
36
 
38
37
  function _setSpecs(LongTradingSpecs memory _specs) internal {
38
+ require(_specs.lowerIyLimit <= _specs.upperIyLimit, "INVALID_IY_LIMITS");
39
+ require(
40
+ _specs.floatingSyRatioLimit >= _specs.floatingSyRatioTarget,
41
+ "INVALID_FLOATING_SY_RATIO"
42
+ );
43
+ require(_specs.ytPtRatioLimit >= _specs.ytPtRatioTarget, "INVALID_YT_PT_RATIO");
44
+
39
45
  specs = _specs;
40
46
  }
41
47
 
42
48
  function swapSyToYt(
43
49
  address router,
44
- StrategyState memory oldState,
45
50
  ApproxParams calldata botParams,
46
51
  uint256 minYtOut,
47
52
  uint256 maxSyIn
48
53
  ) external onlyOwner returns (uint256 exactYtOut, uint256 netSyIn) {
49
- exactYtOut = BotDecisionLib(decisionLib).binarySearchUntilSwitchState(
54
+ (exactYtOut, ) = decisionHelper.searchForBotParam(
50
55
  readBotState(),
51
56
  readMarketExtState(router),
52
57
  specs,
53
58
  ActionType.SwapSyToYt,
54
- oldState,
55
59
  botParams,
56
60
  botParams // only placeholder, value doesn't matter
57
61
  );
@@ -59,23 +63,21 @@ contract LongYieldTradingBot is
59
63
  if (exactYtOut < minYtOut) revert Errors.BotInsufficientYtOut(exactYtOut, minYtOut);
60
64
  netSyIn = _swapSyToYt(router, exactYtOut, maxSyIn);
61
65
 
62
- emit SwapSyToYt(oldState, botParams, maxSyIn, exactYtOut, netSyIn);
66
+ emit SwapSyToYt(botParams, maxSyIn, exactYtOut, netSyIn);
63
67
  }
64
68
 
65
69
  function addLiqKeepYt(
66
70
  address router,
67
- StrategyState memory oldState,
68
71
  ApproxParams calldata botParams,
69
72
  uint256 maxSyIn,
70
73
  uint256 minLpOut,
71
74
  uint256 minYtOut
72
75
  ) external onlyOwner returns (uint256 netSyIn, uint256 netLpOut, uint256 netYtOut) {
73
- netSyIn = BotDecisionLib(decisionLib).binarySearchUntilSwitchState(
76
+ (netSyIn, ) = decisionHelper.searchForBotParam(
74
77
  readBotState(),
75
78
  readMarketExtState(router),
76
79
  specs,
77
80
  ActionType.AddLiqKeepYt,
78
- oldState,
79
81
  botParams,
80
82
  botParams // only placeholder, value doesn't matter
81
83
  );
@@ -83,63 +85,57 @@ contract LongYieldTradingBot is
83
85
  if (netSyIn > maxSyIn) revert Errors.BotExceededLimitSyIn(netSyIn, maxSyIn);
84
86
  (netLpOut, netYtOut) = _addLiqKeepYt(router, netSyIn, minLpOut, minYtOut);
85
87
 
86
- emit AddLiqKeepYt(oldState, botParams, maxSyIn, netSyIn, netLpOut, netYtOut);
88
+ emit AddLiqKeepYt(botParams, maxSyIn, netSyIn, netLpOut, netYtOut);
87
89
  }
88
90
 
89
91
  function addLiqFromSy(
90
- StrategyState memory oldState,
91
92
  ApproxParams calldata botParams,
92
93
  uint256 minLpOut,
93
94
  uint256 maxSyIn
94
95
  ) external onlyOwner returns (uint256 netPtFromSwap, uint256 netLpOut, uint256 netSyIn) {
95
- netPtFromSwap = BotDecisionLib(decisionLib).binarySearchUntilSwitchState(
96
+ (netPtFromSwap, ) = decisionHelper.searchForBotParam(
96
97
  readBotState(),
97
98
  readMarketExtState(address(this)),
98
99
  specs,
99
100
  ActionType.AddLiqFromSy,
100
- oldState,
101
101
  botParams,
102
102
  botParams // only placeholder, value doesn't matter
103
103
  );
104
104
 
105
105
  (netLpOut, netSyIn) = _addLiqFromSy(netPtFromSwap, minLpOut, maxSyIn);
106
106
 
107
- emit AddLiqFromSy(oldState, botParams, maxSyIn, netSyIn, netLpOut);
107
+ emit AddLiqFromSy(botParams, maxSyIn, netSyIn, netLpOut);
108
108
  }
109
109
 
110
110
  function addLiqFromYt(
111
- StrategyState memory oldState,
112
111
  ApproxParams calldata botParams,
113
112
  uint256 minLpOut,
114
113
  uint256 maxYtIn
115
114
  ) external onlyOwner returns (uint256 netPtFromSwap, uint256 netLpOut, uint256 netYtIn) {
116
- netPtFromSwap = BotDecisionLib(decisionLib).binarySearchUntilSwitchState(
115
+ (netPtFromSwap, ) = decisionHelper.searchForBotParam(
117
116
  readBotState(),
118
117
  readMarketExtState(address(this)),
119
118
  specs,
120
119
  ActionType.AddLiqFromYt,
121
- oldState,
122
120
  botParams,
123
121
  botParams // only placeholder, value doesn't matter
124
122
  );
125
123
  (netLpOut, netYtIn) = _addLiqFromYt(netPtFromSwap, minLpOut, maxYtIn);
126
124
 
127
- emit AddLiqFromYt(oldState, botParams, maxYtIn, netYtIn, netLpOut);
125
+ emit AddLiqFromYt(botParams, maxYtIn, netYtIn, netLpOut);
128
126
  }
129
127
 
130
128
  function removeLiqToYt(
131
- StrategyState memory oldState,
132
129
  ApproxParams calldata botParams,
133
130
  ApproxParams calldata guessTotalPtToSwap,
134
131
  uint256 maxLpRemoved,
135
132
  uint256 minYtOut
136
133
  ) external onlyOwner returns (uint256 netLpRemoved, uint256 netYtOut, uint256 totalPtToSwap) {
137
- netLpRemoved = BotDecisionLib(decisionLib).binarySearchUntilSwitchState(
134
+ (netLpRemoved, ) = decisionHelper.searchForBotParam(
138
135
  readBotState(),
139
136
  readMarketExtState(address(this)),
140
137
  specs,
141
138
  ActionType.RemoveLiqToYt,
142
- oldState,
143
139
  botParams,
144
140
  guessTotalPtToSwap // value DOES matter
145
141
  );
@@ -149,6 +145,6 @@ contract LongYieldTradingBot is
149
145
 
150
146
  (netYtOut, totalPtToSwap) = _removeLiqToYt(netLpRemoved, guessTotalPtToSwap, minYtOut);
151
147
 
152
- emit RemoveLiqToYt(oldState, botParams, maxLpRemoved, netLpRemoved, netYtOut);
148
+ emit RemoveLiqToYt(botParams, maxLpRemoved, netLpRemoved, netYtOut);
153
149
  }
154
150
  }
@@ -77,11 +77,7 @@ library MarketExtLib {
77
77
 
78
78
  netYtOut = marketExt.index.syToAsset(netSyToPt);
79
79
 
80
- (, netLpOut, , ) = marketExt.state.addLiquidity(
81
- netSyIn - netSyToPt,
82
- netYtOut,
83
- marketExt.blockTime
84
- );
80
+ netLpOut = addLiqDual(marketExt, netSyIn - netSyToPt, netYtOut);
85
81
  }
86
82
 
87
83
  function addLiqFromSy(
@@ -96,11 +92,7 @@ library MarketExtLib {
96
92
  uint256 netSyToAdd = (netPtFromSwap * marketExt.state.totalSy.Uint()) /
97
93
  marketExt.state.totalPt.Uint();
98
94
 
99
- (, netLpOut, , ) = marketExt.state.addLiquidity(
100
- netSyToAdd,
101
- netPtFromSwap,
102
- marketExt.blockTime
103
- );
95
+ netLpOut = addLiqDual(marketExt, netSyToAdd, netPtFromSwap);
104
96
  netSyIn = netSyToSwap + netSyToAdd;
105
97
  }
106
98
 
@@ -126,11 +118,7 @@ library MarketExtLib {
126
118
  uint256 netSyFromPy = marketExt.index.assetToSy(netYtIn);
127
119
  uint256 netSyToAdd = netSyFromPy - netSyToSwap;
128
120
 
129
- (, netLpOut, , ) = marketExt.state.addLiquidity(
130
- netSyToAdd,
131
- netPtToAdd,
132
- marketExt.blockTime
133
- );
121
+ netLpOut = addLiqDual(marketExt, netSyToAdd, netPtToAdd);
134
122
  }
135
123
 
136
124
  /// @dev Simulates PendleRouter's removeLiquidityDualSyAndPt then swapExactPtForYt
@@ -138,15 +126,14 @@ library MarketExtLib {
138
126
  MarketExtState memory marketExt,
139
127
  uint256 netLpToRemove,
140
128
  ApproxParams memory approxParams
141
- ) internal pure returns (uint256 /*netYtOut*/) {
142
- (uint256 netSyRemoved, uint256 netPtRemoved) = marketExt.state.removeLiquidity(
143
- netLpToRemove
144
- );
129
+ ) internal pure returns (uint256 netYtOut, uint256 totalPtToSwap) {
130
+ (uint256 netSyRemoved, uint256 netPtRemoved) = removeLiqDual(marketExt, netLpToRemove);
145
131
 
146
132
  uint256 netYtFromSy = marketExt.index.syToAsset(netSyRemoved);
147
133
  uint256 netPtToSwap = netPtRemoved + netYtFromSy;
148
134
 
149
- (uint256 netYtFromSwap, uint256 totalPtToSwap, ) = marketExt.state.approxSwapExactPtForYt(
135
+ uint256 netYtFromSwap;
136
+ (netYtFromSwap, totalPtToSwap, ) = marketExt.state.approxSwapExactPtForYt(
150
137
  marketExt.index,
151
138
  netPtToSwap,
152
139
  marketExt.blockTime,
@@ -155,7 +142,61 @@ library MarketExtLib {
155
142
 
156
143
  marketExt.state.swapExactPtForSy(marketExt.index, totalPtToSwap, marketExt.blockTime);
157
144
 
158
- return netYtFromSy + netYtFromSwap;
145
+ netYtOut = netYtFromSy + netYtFromSwap;
146
+ }
147
+
148
+ /// @dev Simplified version of MarketMathCore's addLiquidity
149
+ function addLiqDual(
150
+ MarketExtState memory marketExt,
151
+ uint256 netSyIn,
152
+ uint256 netPtIn
153
+ ) internal pure returns (uint256 /*netLpOut*/) {
154
+ require(
155
+ !MiniHelpers.isExpired(marketExt.state.expiry, marketExt.blockTime),
156
+ "MarketExtLib: expired market"
157
+ );
158
+ require(marketExt.state.totalLp > 0, "MarketExtLib: LP < 0");
159
+
160
+ int256 syDesired = netSyIn.Int();
161
+ int256 ptDesired = netPtIn.Int();
162
+ int256 lpToAccount;
163
+ int256 ptUsed;
164
+ int256 syUsed;
165
+
166
+ int256 netLpByPt = (ptDesired * marketExt.state.totalLp) / marketExt.state.totalPt;
167
+ int256 netLpBySy = (syDesired * marketExt.state.totalLp) / marketExt.state.totalSy;
168
+ if (netLpByPt < netLpBySy) {
169
+ lpToAccount = netLpByPt;
170
+ ptUsed = ptDesired;
171
+ syUsed = (marketExt.state.totalSy * lpToAccount) / marketExt.state.totalLp;
172
+ } else {
173
+ lpToAccount = netLpBySy;
174
+ syUsed = syDesired;
175
+ ptUsed = (marketExt.state.totalPt * lpToAccount) / marketExt.state.totalLp;
176
+ }
177
+
178
+ marketExt.state.totalSy += syUsed;
179
+ marketExt.state.totalPt += ptUsed;
180
+ marketExt.state.totalLp += lpToAccount;
181
+
182
+ return lpToAccount.Uint();
183
+ }
184
+
185
+ /// @dev Simplified version of MarketMathCore's removeLiquidity
186
+ function removeLiqDual(
187
+ MarketExtState memory marketExt,
188
+ uint256 netLpToRemove
189
+ ) internal pure returns (uint256 /*netSyToAccount*/, uint256 /*netPtToAccount*/) {
190
+ int256 lpToRemove = netLpToRemove.Int();
191
+
192
+ int256 netSyToAccount = (lpToRemove * marketExt.state.totalSy) / marketExt.state.totalLp;
193
+ int256 netPtToAccount = (lpToRemove * marketExt.state.totalPt) / marketExt.state.totalLp;
194
+
195
+ marketExt.state.totalLp = marketExt.state.totalLp.subNoNeg(lpToRemove);
196
+ marketExt.state.totalPt = marketExt.state.totalPt.subNoNeg(netPtToAccount);
197
+ marketExt.state.totalSy = marketExt.state.totalSy.subNoNeg(netSyToAccount);
198
+
199
+ return (netSyToAccount.Uint(), netPtToAccount.Uint());
159
200
  }
160
201
 
161
202
  function previewPyToSy(
@@ -165,14 +206,6 @@ library MarketExtLib {
165
206
  return marketExt.index.assetToSy(netPYToRedeem);
166
207
  }
167
208
 
168
- function previewAssetsFromLp(
169
- MarketExtState memory marketExt,
170
- uint256 lpBalance
171
- ) internal pure returns (uint256 syInLp, uint256 ptInLp) {
172
- syInLp = (lpBalance * marketExt.state.totalSy.Uint()) / marketExt.state.totalLp.Uint();
173
- ptInLp = (lpBalance * marketExt.state.totalPt.Uint()) / marketExt.state.totalLp.Uint();
174
- }
175
-
176
209
  /// @notice Returns the trade exchange rate, fee excluded
177
210
  function exchangeRate(MarketExtState memory marketExt) internal pure returns (uint256) {
178
211
  MarketPreCompute memory comp = marketExt.state.getMarketPreCompute(
@@ -230,10 +263,10 @@ library MarketExtLib {
230
263
 
231
264
  function calcMaxPtIn(MarketExtState memory marketExt) internal pure returns (uint256) {
232
265
  return
233
- MarketApproxPtInLib.calcMaxPtIn(
266
+ (MarketApproxPtInLib.calcMaxPtIn(
234
267
  marketExt.state,
235
268
  marketExt.state.getMarketPreCompute(marketExt.index, marketExt.blockTime)
236
- ) * 9 / 10;
269
+ ) * 9) / 10;
237
270
  }
238
271
 
239
272
  function calcMaxPtOut(MarketExtState memory marketExt) internal pure returns (uint256) {
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Structs and enums
4
4
 
5
- ### MarketExtLib
5
+ ### MarketExtState
6
6
 
7
7
  Struct for external market state.
8
8
 
@@ -20,8 +20,10 @@ Struct for bot's trading limits:
20
20
 
21
21
  - `lowerIyLimit`: apeYtApy
22
22
  - `upperIyLimit`: sellYtApy
23
- - `floatingSyRatioLimit`: f/TVL limit, TVL calculated in number of SY.
24
- - `ytPtRatioLimit`: limit for YT/PT
23
+ - `floatingSyRatioLimit`: h_r - f/TVL limit, TVL calculated in number of SY.
24
+ - `floatingSyRatioTarget`: l_r - f/TVL target.
25
+ - `ytPtRatioLimit`: h_x - limit for YT/PT
26
+ - `ytPtRatioTarget`: l_x - target for YT/PT
25
27
 
26
28
  ### ActionType
27
29
 
@@ -79,10 +81,13 @@ Claim rewards from SY, YT, market. Then compound the rewards into SY.
79
81
  - If `inp.netTokenIn` is set to `2**256 - 1` then it will be set to `_selfBalance()` internally.
80
82
  - Needs sender's approval to bot & bot's approval to router for tokens.
81
83
 
82
- ### 6. readMarketExtState
84
+ ### 6. claimWithoutCompound
85
+ Intended to be static called from offchain. Claim rewards from SY, YT, market, then return amounts of tokens claimed.
86
+
87
+ ### 7. readMarketExtState
83
88
  Return the current `MarketExtState`: state of market, YT's index, current block timestamp.
84
89
 
85
- ### 7. readBotState
90
+ ### 8. readBotState
86
91
  Return the current `BotState`: The bot's balance in LP, SY, YT.
87
92
 
88
93
 
@@ -94,7 +99,7 @@ There are 5 functions for rebalancing actions.
94
99
 
95
100
  ### 1. setSpecs
96
101
 
97
- Set the bot's specs: apeYtApy, sellYtApy, r (f/TVL limit), x (YT/PT ratio).
102
+ Set the bot's specs: apeYtApy, sellYtApy, h_r (f/TVL limit), l_r (f/TVL target), h_x (YT/PT ratio limit), l_x (YT/PT ratio target).
98
103
 
99
104
  ### 2. swapSyToYt
100
105
 
@@ -117,35 +122,32 @@ Rebalance by selling YT to LP.
117
122
  Rebalance by zapping out LP to YT.
118
123
 
119
124
  - `intParams`: ApproxParams for internal approx function (approxSwapExactPtForYt).
120
- - Zapping LP to YT can lose a few percent of trading value. Zapping out too much can cause a significant change in TVL, so the resulting strategy state can differ from expected, which can cause unintended behaviour.
125
+ - Zapping LP to YT can lose a few percent of the `tvlInSy`, the estimated TVL of bot in SY. Zapping out too much can cause a significant change in `tvlInSy`, which can unintentionally increase the estimated f/TVL.
121
126
 
122
- ## TradingBotOffchain.sol
127
+ ## BotDecisionHelper.sol
123
128
 
124
129
  Offchain helper for trading bot.
125
130
 
126
- ### 1. claimForBot
127
- Claim rewards for bot, return the list of reward tokens and amounts claimed.
128
-
129
- ### 2. simulateAction
130
- Simulate rebalancing action (swap/add/remove) from BotState and MarketExtState.
131
+ ### 1. searchForBotParam
132
+ Binary search for the optimal `botParam` for the rebalancing action. To be used in bot's actual rebalancing actions.
131
133
 
132
- ### 3. searchForBotParam
133
- Binary search for the optimal `botParam` for the rebalancing action. Simulate the same process used in the bot's rebalancing functions.
134
-
135
- - Searches for the minimum `botParam` so that the bot trades just until the bot's new strategy state would differ from `initialState`.
134
+ - Searches for the minimum `botParam` so that the bot trades just "target" is met.
135
+ - Target to meet is calculated based on the `action` (desired f/TVL, YT/PT, IY).
136
136
  - `botParam`: The parameter for the rebalancing function (e.g. `netPtFromSwap` for addLiqFromSy).
137
137
 
138
- ### 4. searchForIntParam
139
- (Only useful for `removeLiqToYt`).
140
- Given the `botParam`, binary search for the optimal `intParam` for the internal calculations (for `approxSwapExactPtForYt`).
138
+ ### 2. searchForIntParam
139
+ (Only useful for `removeLiqToYt`)
140
+ Given `botParam`, binary search for the optimal `intParam` for the internal calculations (e.g. `approxSwapExactPtForYt`).
141
141
 
142
- ### 5. strategyState
142
+ ### 3. strategyState
143
143
  Calculate the strategy state from BotState, MarketExtState, LongTradingSpecs.
144
144
 
145
- ### 6. actionToTake
146
- Return optimal action to take based on the strategy state.
145
+ ### 4. actionToTake
146
+ Return optimal action to take based on the BotState and StrategyState.
147
147
 
148
- ### 7. tvlInSy
148
+ ### 5. previewAction
149
+ Simulate rebalancing action (swap/add/remove) from BotState and MarketExtState.
149
150
 
150
- Calculate the TVL in equivalent SY amount.
151
+ ### 6. botExtStats
152
+ Calculate the external stats for the bot: Estimated TVL in equivalent SY amount, current IY, current f/TVL ratio, current YT/PT ratio
151
153
 
@@ -3,12 +3,12 @@ pragma solidity 0.8.17;
3
3
 
4
4
  import "../libraries/BoringOwnableUpgradeable.sol";
5
5
  import "../libraries/TokenHelper.sol";
6
- import "../../interfaces/IPAllAction.sol";
7
6
  import "../../interfaces/TradingBot/ITradingBotBase.sol";
8
7
 
9
8
  import "./BotSimulationLib.sol";
10
9
 
11
10
  abstract contract TradingBotBase is BoringOwnableUpgradeable, TokenHelper, ITradingBotBase {
11
+ using TokenAmountLib for TokenAmount[];
12
12
  using PYIndexLib for IPYieldToken;
13
13
 
14
14
  address public immutable market;
@@ -30,6 +30,21 @@ abstract contract TradingBotBase is BoringOwnableUpgradeable, TokenHelper, ITrad
30
30
  __BoringOwnable_init();
31
31
  }
32
32
 
33
+ function approveInf(MultiApproval[] calldata arr) external onlyOwner {
34
+ for (uint256 i = 0; i < arr.length; ) {
35
+ MultiApproval calldata ele = arr[i];
36
+ for (uint256 j = 0; j < ele.tokens.length; ) {
37
+ _safeApproveInf(ele.tokens[j], ele.spender);
38
+ unchecked {
39
+ j++;
40
+ }
41
+ }
42
+ unchecked {
43
+ i++;
44
+ }
45
+ }
46
+ }
47
+
33
48
  function depositSy(uint256 netSyIn) external onlyOwner {
34
49
  _transferIn(SY, msg.sender, netSyIn);
35
50
  emit DepositSy(netSyIn);
@@ -66,6 +81,26 @@ abstract contract TradingBotBase is BoringOwnableUpgradeable, TokenHelper, ITrad
66
81
  emit ClaimAndCompound(netSyOut, netPendleOut);
67
82
  }
68
83
 
84
+ /// Claim without compound, intended for offchain usage
85
+ /// @dev SY interest from YT is excluded
86
+ function claimWithoutCompound() external onlyOwner returns (TokenAmount[] memory rewards) {
87
+ address[] memory ytRewardTokens = IPYieldToken(YT).getRewardTokens();
88
+ (, uint256[] memory ytRewardAmounts) = IPYieldToken(YT).redeemDueInterestAndRewards(
89
+ address(this),
90
+ true,
91
+ true
92
+ );
93
+ rewards = rewards.add(ytRewardTokens, ytRewardAmounts);
94
+
95
+ address[] memory syRewardTokens = IStandardizedYield(SY).getRewardTokens();
96
+ uint256[] memory syRewardAmounts = IStandardizedYield(SY).claimRewards(address(this));
97
+ rewards = rewards.add(syRewardTokens, syRewardAmounts);
98
+
99
+ address[] memory lpRewardTokens = IPMarket(market).getRewardTokens();
100
+ uint256[] memory lpRewardAmounts = IPMarket(market).redeemRewards(address(this));
101
+ rewards = rewards.add(lpRewardTokens, lpRewardAmounts);
102
+ }
103
+
69
104
  function readMarketExtState(address router) public returns (MarketExtState memory marketExt) {
70
105
  marketExt.state = IPMarket(market).readState(router);
71
106
  marketExt.index = IPYieldToken(YT).newIndex();
@@ -113,19 +148,4 @@ abstract contract TradingBotBase is BoringOwnableUpgradeable, TokenHelper, ITrad
113
148
  value: inp.tokenIn == NATIVE ? inp.netTokenIn : 0
114
149
  }(address(this), SY, minSyOut, inp);
115
150
  }
116
-
117
- function approveInf(MultiApproval[] calldata arr) external onlyOwner {
118
- for (uint256 i = 0; i < arr.length; ) {
119
- MultiApproval calldata ele = arr[i];
120
- for (uint256 j = 0; j < ele.tokens.length; ) {
121
- _safeApproveInf(ele.tokens[j], ele.spender);
122
- unchecked {
123
- j++;
124
- }
125
- }
126
- unchecked {
127
- i++;
128
- }
129
- }
130
- }
131
151
  }
@@ -0,0 +1,91 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ pragma solidity 0.8.17;
3
+
4
+ import "../../core/TradingBot/BotSimulationLib.sol";
5
+
6
+ struct LongTradingSpecs {
7
+ uint256 lowerIyLimit; // apeYtApy
8
+ uint256 upperIyLimit; // sellYtApy
9
+ uint256 floatingSyRatioLimit; // h_r
10
+ uint256 floatingSyRatioTarget; // l_r
11
+ uint256 ytPtRatioLimit; // h_x
12
+ uint256 ytPtRatioTarget; // l_x
13
+ }
14
+
15
+ enum ActionType {
16
+ SwapSyToYt, // Buy YT with SY
17
+ AddLiqKeepYt, // ZPI Zap
18
+ AddLiqFromSy, // Single sided LP
19
+ AddLiqFromYt, // Sell YT for LP
20
+ RemoveLiqToYt, // Zap out to YT,
21
+ NONE
22
+ }
23
+
24
+ enum StrategyFlag {
25
+ GOOD,
26
+ TOO_LOW,
27
+ TOO_HIGH
28
+ }
29
+
30
+ struct StrategyState {
31
+ StrategyFlag iyFlag;
32
+ StrategyFlag syRatioFlag;
33
+ }
34
+
35
+ interface IBotDecisionHelper {
36
+ enum RebalanceResult {
37
+ FAIL,
38
+ TARGET_REACHED,
39
+ TARGET_NOT_REACHED
40
+ }
41
+
42
+ struct RebalanceDetails {
43
+ BotState bot;
44
+ MarketExtState marketExt;
45
+ LongTradingSpecs specs;
46
+ ActionType action;
47
+ }
48
+
49
+ function searchForBotParam(
50
+ BotState memory bot,
51
+ MarketExtState memory marketExt,
52
+ LongTradingSpecs memory specs,
53
+ ActionType action,
54
+ ApproxParams memory botParams,
55
+ ApproxParams memory intParams
56
+ ) external pure returns (uint256, RebalanceResult);
57
+
58
+ function searchForIntParam(
59
+ MarketExtState memory marketExt,
60
+ ActionType action,
61
+ uint256 botParam,
62
+ ApproxParams memory intParams
63
+ ) external pure returns (uint256);
64
+
65
+ function strategyState(
66
+ BotState memory bot,
67
+ MarketExtState memory marketExt,
68
+ LongTradingSpecs memory specs
69
+ ) external pure returns (StrategyState memory);
70
+
71
+ function actionToTake(
72
+ BotState memory botState,
73
+ StrategyState memory currentState
74
+ ) external pure returns (ActionType);
75
+
76
+ function previewAction(
77
+ BotState memory botData,
78
+ MarketExtState memory marketExtData,
79
+ ActionType action,
80
+ uint256 botParam,
81
+ ApproxParams memory swapApproxParams
82
+ ) external pure returns (bool, BotState memory, MarketExtState memory);
83
+
84
+ function botExtStats(
85
+ BotState memory bot,
86
+ MarketExtState memory marketExt
87
+ )
88
+ external
89
+ pure
90
+ returns (uint256 tvlInSy, uint256 iy, uint256 currentSyRatio, uint256 currentYtPtRatio);
91
+ }
@@ -2,21 +2,12 @@
2
2
  pragma solidity 0.8.17;
3
3
 
4
4
  import "./ITradingBotBase.sol";
5
- import "../../core/TradingBot/BotDecisionLib.sol";
5
+ import "./IBotDecisionHelper.sol";
6
6
 
7
- interface ILongYieldTradingBot {
8
- function setSpecs(LongTradingSpecs calldata _specs) external;
9
-
10
- event SwapSyToYt(
11
- StrategyState state,
12
- ApproxParams botParams,
13
- uint256 maxSyIn,
14
- uint256 exactYtOut,
15
- uint256 netSyIn
16
- );
7
+ interface ILongYieldTradingBot is ITradingBotBase {
8
+ event SwapSyToYt(ApproxParams botParams, uint256 maxSyIn, uint256 exactYtOut, uint256 netSyIn);
17
9
 
18
10
  event AddLiqKeepYt(
19
- StrategyState state,
20
11
  ApproxParams botParams,
21
12
  uint256 maxSyIn,
22
13
  uint256 netSyIn,
@@ -24,33 +15,21 @@ interface ILongYieldTradingBot {
24
15
  uint256 netYtOut
25
16
  );
26
17
 
27
- event AddLiqFromSy(
28
- StrategyState state,
29
- ApproxParams botParams,
30
- uint256 maxSyIn,
31
- uint256 netSyIn,
32
- uint256 netLpOut
33
- );
18
+ event AddLiqFromSy(ApproxParams botParams, uint256 maxSyIn, uint256 netSyIn, uint256 netLpOut);
34
19
 
35
- event AddLiqFromYt(
36
- StrategyState state,
37
- ApproxParams botParams,
38
- uint256 maxYtIn,
39
- uint256 netYtIn,
40
- uint256 netLpOut
41
- );
20
+ event AddLiqFromYt(ApproxParams botParams, uint256 maxYtIn, uint256 netYtIn, uint256 netLpOut);
42
21
 
43
22
  event RemoveLiqToYt(
44
- StrategyState state,
45
23
  ApproxParams botParams,
46
24
  uint256 maxLpRemoved,
47
25
  uint256 netLpIn,
48
26
  uint256 netYtOut
49
27
  );
50
28
 
29
+ function setSpecs(LongTradingSpecs calldata _specs) external;
30
+
51
31
  function swapSyToYt(
52
32
  address router,
53
- StrategyState memory oldState,
54
33
  ApproxParams calldata botParams,
55
34
  uint256 minYtOut,
56
35
  uint256 maxSyIn
@@ -58,7 +37,6 @@ interface ILongYieldTradingBot {
58
37
 
59
38
  function addLiqKeepYt(
60
39
  address router,
61
- StrategyState memory oldState,
62
40
  ApproxParams calldata botParams,
63
41
  uint256 maxSyIn,
64
42
  uint256 minLpOut,
@@ -66,21 +44,18 @@ interface ILongYieldTradingBot {
66
44
  ) external returns (uint256 netSyIn, uint256 netLpOut, uint256 netYtOut);
67
45
 
68
46
  function addLiqFromSy(
69
- StrategyState memory oldState,
70
47
  ApproxParams calldata botParams,
71
48
  uint256 minLpOut,
72
49
  uint256 maxSyIn
73
50
  ) external returns (uint256 netPtFromSwap, uint256 netLpOut, uint256 netSyIn);
74
51
 
75
52
  function addLiqFromYt(
76
- StrategyState memory oldState,
77
53
  ApproxParams calldata botParams,
78
54
  uint256 minLpOut,
79
55
  uint256 maxYtIn
80
56
  ) external returns (uint256 netPtFromSwap, uint256 netLpOut, uint256 netYtIn);
81
57
 
82
58
  function removeLiqToYt(
83
- StrategyState memory oldState,
84
59
  ApproxParams calldata botParams,
85
60
  ApproxParams calldata guessTotalPtToSwap,
86
61
  uint256 maxLpRemoved,