@pendle/core-v2 2.17.4-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 (292) 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/BotDecisionLib.ts +17 -12
  193. package/typechain-types/IPActionMarketAuxStatic.ts +191 -38
  194. package/typechain-types/IPActionMarketCoreStatic.ts +600 -134
  195. package/typechain-types/IPActionMintRedeemStatic.ts +92 -26
  196. package/typechain-types/IPRouterStatic.ts +888 -197
  197. package/typechain-types/IWBETH.ts +128 -0
  198. package/typechain-types/PendleBinanceEth.ts +1229 -0
  199. package/typechain-types/PtAndLpToAsset.ts +136 -0
  200. package/typechain-types/TradingBotOffchain.ts +19 -14
  201. package/typechain-types/factories/ActionAddRemoveLiq__factory.ts +1 -1
  202. package/typechain-types/factories/ActionInfoStatic__factory.ts +1 -1
  203. package/typechain-types/factories/ActionMarketAuxStatic__factory.ts +83 -7
  204. package/typechain-types/factories/ActionMarketCoreStatic__factory.ts +23 -23
  205. package/typechain-types/factories/ActionMintRedeemStatic__factory.ts +43 -5
  206. package/typechain-types/factories/ActionMintRedeem__factory.ts +1 -1
  207. package/typechain-types/factories/ActionStorageStatic__factory.ts +1 -1
  208. package/typechain-types/factories/ActionSwapPT__factory.ts +1 -1
  209. package/typechain-types/factories/ActionSwapYT__factory.ts +1 -1
  210. package/typechain-types/factories/ActionVePendleStatic__factory.ts +1 -1
  211. package/typechain-types/factories/BotDecisionLib__factory.ts +23 -1
  212. package/typechain-types/factories/Broadcaster__factory.ts +1 -1
  213. package/typechain-types/factories/BulkSellerFactory__factory.ts +1 -1
  214. package/typechain-types/factories/BulkSellerOffchain__factory.ts +1 -1
  215. package/typechain-types/factories/BulkSeller__factory.ts +1 -1
  216. package/typechain-types/factories/Errors__factory.ts +1 -150
  217. package/typechain-types/factories/IPActionMarketAuxStatic__factory.ts +82 -6
  218. package/typechain-types/factories/IPActionMarketCoreStatic__factory.ts +22 -22
  219. package/typechain-types/factories/IPActionMintRedeemStatic__factory.ts +42 -4
  220. package/typechain-types/factories/IPRouterStatic__factory.ts +146 -32
  221. package/typechain-types/factories/IWBETH__factory.ts +51 -0
  222. package/typechain-types/factories/LongYieldTradingBot__factory.ts +1 -1
  223. package/typechain-types/factories/OracleLib__factory.ts +1 -1
  224. package/typechain-types/factories/PendleAuraBbAWethSwethSY__factory.ts +1 -1
  225. package/typechain-types/factories/PendleAuraWethAnkrethSYV2__factory.ts +1 -1
  226. package/typechain-types/factories/PendleAuraWethRocketEthSYV2__factory.ts +1 -1
  227. package/typechain-types/factories/PendleAuraWethStafiEthSY__factory.ts +1 -1
  228. package/typechain-types/factories/PendleAuraWethWstethSYV2__factory.ts +1 -1
  229. package/typechain-types/factories/PendleBinanceEth__factory.ts +1052 -0
  230. package/typechain-types/factories/PendleCamelotV1VolatileSY__factory.ts +1 -1
  231. package/typechain-types/factories/PendleCurveFraxUsdcSY__factory.ts +1 -1
  232. package/typechain-types/factories/PendleCurveUsdd3CrvSY__factory.ts +1 -1
  233. package/typechain-types/factories/PendleFeeDistributorV2__factory.ts +1 -1
  234. package/typechain-types/factories/PendleFeeDistributor__factory.ts +1 -1
  235. package/typechain-types/factories/PendleGDaiSY__factory.ts +1 -1
  236. package/typechain-types/factories/PendleGaugeControllerMainchainUpg__factory.ts +1 -1
  237. package/typechain-types/factories/PendleGaugeControllerSidechainUpg__factory.ts +1 -1
  238. package/typechain-types/factories/PendleGlpSY__factory.ts +1 -1
  239. package/typechain-types/factories/PendleLooksStakingSY__factory.ts +1 -1
  240. package/typechain-types/factories/PendleLpGlpOracle__factory.ts +1 -1
  241. package/typechain-types/factories/PendleMarketFactory__factory.ts +1 -1
  242. package/typechain-types/factories/PendleMarket__factory.ts +1 -1
  243. package/typechain-types/factories/PendleMsgReceiveEndpointUpg__factory.ts +1 -1
  244. package/typechain-types/factories/PendleMsgSendEndpointUpg__factory.ts +1 -1
  245. package/typechain-types/factories/PendlePrincipalTokenV2__factory.ts +1 -1
  246. package/typechain-types/factories/PendlePrincipalToken__factory.ts +1 -1
  247. package/typechain-types/factories/PendlePtGlpOracle__factory.ts +1 -1
  248. package/typechain-types/factories/PendlePtOracle__factory.ts +1 -1
  249. package/typechain-types/factories/PendleQiTokenHelper__factory.ts +1 -1
  250. package/typechain-types/factories/PendleQiTokenSY__factory.ts +1 -1
  251. package/typechain-types/factories/PendleRouterHelper__factory.ts +1 -1
  252. package/typechain-types/factories/PendleRouterStatic__factory.ts +1 -1
  253. package/typechain-types/factories/PendleRouter__factory.ts +1 -1
  254. package/typechain-types/factories/PendleSfrxEthSY__factory.ts +1 -1
  255. package/typechain-types/factories/PendleStargateLPSY__factory.ts +1 -1
  256. package/typechain-types/factories/PendleVotingControllerUpg__factory.ts +1 -1
  257. package/typechain-types/factories/PendleWstEthSY__factory.ts +1 -1
  258. package/typechain-types/factories/PendleYieldContractFactoryV2__factory.ts +1 -1
  259. package/typechain-types/factories/PendleYieldContractFactory__factory.ts +1 -1
  260. package/typechain-types/factories/PendleYieldTokenV2__factory.ts +1 -1
  261. package/typechain-types/factories/PendleYieldToken__factory.ts +1 -1
  262. package/typechain-types/factories/PtAndLpToAsset__factory.ts +150 -0
  263. package/typechain-types/factories/SAPE__factory.ts +1 -1
  264. package/typechain-types/factories/TradingBotOffchain__factory.ts +23 -1
  265. package/typechain-types/factories/VotingEscrowPendleMainchain__factory.ts +1 -1
  266. package/typechain-types/factories/VotingEscrowPendleSidechain__factory.ts +1 -1
  267. package/typechain-types/hardhat.d.ts +36 -81
  268. package/typechain-types/index.ts +8 -18
  269. package/build/artifacts/contracts/core/TradingBot/BotActionCallback.sol/BotActionCallback.dbg.json +0 -4
  270. package/build/artifacts/contracts/core/TradingBot/BotActionCallback.sol/BotActionCallback.json +0 -638
  271. package/build/artifacts/contracts/core/TradingBot/BotActionHelper.sol/BotActionHelper.dbg.json +0 -4
  272. package/build/artifacts/contracts/core/TradingBot/BotActionHelper.sol/BotActionHelper.json +0 -638
  273. package/build/artifacts/contracts/core/TradingBot/BotDecisionLib.sol/BotDecisionLib.dbg.json +0 -4
  274. package/build/artifacts/contracts/core/TradingBot/BotDecisionLib.sol/BotDecisionLib.json +0 -567
  275. package/build/artifacts/contracts/core/TradingBot/BotSimulationLib.sol/BotSimulationLib.dbg.json +0 -4
  276. package/build/artifacts/contracts/core/TradingBot/BotSimulationLib.sol/BotSimulationLib.json +0 -10
  277. package/build/artifacts/contracts/core/TradingBot/LongYieldTradingBot.sol/LongYieldTradingBot.dbg.json +0 -4
  278. package/build/artifacts/contracts/core/TradingBot/LongYieldTradingBot.sol/LongYieldTradingBot.json +0 -1887
  279. package/build/artifacts/contracts/core/TradingBot/MarketExtLib.sol/MarketExtLib.dbg.json +0 -4
  280. package/build/artifacts/contracts/core/TradingBot/MarketExtLib.sol/MarketExtLib.json +0 -24
  281. package/build/artifacts/contracts/core/TradingBot/TradingBotBase.sol/TradingBotBase.dbg.json +0 -4
  282. package/build/artifacts/contracts/core/TradingBot/TradingBotBase.sol/TradingBotBase.json +0 -588
  283. package/build/artifacts/contracts/core/TradingBot/TradingBotOffchain.sol/TradingBotOffchain.dbg.json +0 -4
  284. package/build/artifacts/contracts/core/TradingBot/TradingBotOffchain.sol/TradingBotOffchain.json +0 -1053
  285. package/build/artifacts/contracts/core/libraries/TokenAmountLib.sol/TokenAmountLib.dbg.json +0 -4
  286. package/build/artifacts/contracts/core/libraries/TokenAmountLib.sol/TokenAmountLib.json +0 -10
  287. package/build/artifacts/contracts/interfaces/TradingBot/ILongYieldTradingBot.sol/ILongYieldTradingBot.dbg.json +0 -4
  288. package/build/artifacts/contracts/interfaces/TradingBot/ILongYieldTradingBot.sol/ILongYieldTradingBot.json +0 -889
  289. package/build/artifacts/contracts/interfaces/TradingBot/ITradingBotBase.sol/ITradingBotBase.dbg.json +0 -4
  290. package/build/artifacts/contracts/interfaces/TradingBot/ITradingBotBase.sol/ITradingBotBase.json +0 -390
  291. package/contracts/core/TradingBot/BotDecisionLib.sol +0 -274
  292. package/contracts/core/TradingBot/TradingBotOffchain.sol +0 -141
@@ -1,4 +0,0 @@
1
- {
2
- "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../../build-info/fce85bdc27ce8a2eb27931e27bdb334a.json"
4
- }
@@ -1,390 +0,0 @@
1
- {
2
- "_format": "hh-sol-artifact-1",
3
- "contractName": "ITradingBotBase",
4
- "sourceName": "contracts/interfaces/TradingBot/ITradingBotBase.sol",
5
- "abi": [
6
- {
7
- "anonymous": false,
8
- "inputs": [
9
- {
10
- "indexed": false,
11
- "internalType": "uint256",
12
- "name": "netSyOut",
13
- "type": "uint256"
14
- },
15
- {
16
- "indexed": false,
17
- "internalType": "uint256",
18
- "name": "netPendleOut",
19
- "type": "uint256"
20
- }
21
- ],
22
- "name": "ClaimAndCompound",
23
- "type": "event"
24
- },
25
- {
26
- "anonymous": false,
27
- "inputs": [
28
- {
29
- "indexed": false,
30
- "internalType": "uint256",
31
- "name": "netSyIn",
32
- "type": "uint256"
33
- }
34
- ],
35
- "name": "DepositSy",
36
- "type": "event"
37
- },
38
- {
39
- "anonymous": false,
40
- "inputs": [
41
- {
42
- "indexed": true,
43
- "internalType": "address",
44
- "name": "token",
45
- "type": "address"
46
- },
47
- {
48
- "indexed": false,
49
- "internalType": "uint256",
50
- "name": "netTokenIn",
51
- "type": "uint256"
52
- }
53
- ],
54
- "name": "DepositToken",
55
- "type": "event"
56
- },
57
- {
58
- "anonymous": false,
59
- "inputs": [
60
- {
61
- "indexed": true,
62
- "internalType": "address",
63
- "name": "token",
64
- "type": "address"
65
- },
66
- {
67
- "indexed": false,
68
- "internalType": "uint256",
69
- "name": "amount",
70
- "type": "uint256"
71
- }
72
- ],
73
- "name": "WithdrawFunds",
74
- "type": "event"
75
- },
76
- {
77
- "inputs": [
78
- {
79
- "internalType": "address",
80
- "name": "router",
81
- "type": "address"
82
- },
83
- {
84
- "components": [
85
- {
86
- "internalType": "address",
87
- "name": "tokenIn",
88
- "type": "address"
89
- },
90
- {
91
- "internalType": "uint256",
92
- "name": "netTokenIn",
93
- "type": "uint256"
94
- },
95
- {
96
- "internalType": "address",
97
- "name": "tokenMintSy",
98
- "type": "address"
99
- },
100
- {
101
- "internalType": "address",
102
- "name": "bulk",
103
- "type": "address"
104
- },
105
- {
106
- "internalType": "address",
107
- "name": "pendleSwap",
108
- "type": "address"
109
- },
110
- {
111
- "components": [
112
- {
113
- "internalType": "enum SwapType",
114
- "name": "swapType",
115
- "type": "uint8"
116
- },
117
- {
118
- "internalType": "address",
119
- "name": "extRouter",
120
- "type": "address"
121
- },
122
- {
123
- "internalType": "bytes",
124
- "name": "extCalldata",
125
- "type": "bytes"
126
- },
127
- {
128
- "internalType": "bool",
129
- "name": "needScale",
130
- "type": "bool"
131
- }
132
- ],
133
- "internalType": "struct SwapData",
134
- "name": "swapData",
135
- "type": "tuple"
136
- }
137
- ],
138
- "internalType": "struct TokenInput[]",
139
- "name": "inps",
140
- "type": "tuple[]"
141
- },
142
- {
143
- "internalType": "uint256",
144
- "name": "minSyOut",
145
- "type": "uint256"
146
- }
147
- ],
148
- "name": "claimAndCompound",
149
- "outputs": [
150
- {
151
- "internalType": "uint256",
152
- "name": "netSyOut",
153
- "type": "uint256"
154
- },
155
- {
156
- "internalType": "uint256",
157
- "name": "netPendleOut",
158
- "type": "uint256"
159
- }
160
- ],
161
- "stateMutability": "nonpayable",
162
- "type": "function"
163
- },
164
- {
165
- "inputs": [
166
- {
167
- "internalType": "uint256",
168
- "name": "netSyIn",
169
- "type": "uint256"
170
- }
171
- ],
172
- "name": "depositSy",
173
- "outputs": [],
174
- "stateMutability": "nonpayable",
175
- "type": "function"
176
- },
177
- {
178
- "inputs": [
179
- {
180
- "internalType": "address",
181
- "name": "router",
182
- "type": "address"
183
- },
184
- {
185
- "components": [
186
- {
187
- "internalType": "address",
188
- "name": "tokenIn",
189
- "type": "address"
190
- },
191
- {
192
- "internalType": "uint256",
193
- "name": "netTokenIn",
194
- "type": "uint256"
195
- },
196
- {
197
- "internalType": "address",
198
- "name": "tokenMintSy",
199
- "type": "address"
200
- },
201
- {
202
- "internalType": "address",
203
- "name": "bulk",
204
- "type": "address"
205
- },
206
- {
207
- "internalType": "address",
208
- "name": "pendleSwap",
209
- "type": "address"
210
- },
211
- {
212
- "components": [
213
- {
214
- "internalType": "enum SwapType",
215
- "name": "swapType",
216
- "type": "uint8"
217
- },
218
- {
219
- "internalType": "address",
220
- "name": "extRouter",
221
- "type": "address"
222
- },
223
- {
224
- "internalType": "bytes",
225
- "name": "extCalldata",
226
- "type": "bytes"
227
- },
228
- {
229
- "internalType": "bool",
230
- "name": "needScale",
231
- "type": "bool"
232
- }
233
- ],
234
- "internalType": "struct SwapData",
235
- "name": "swapData",
236
- "type": "tuple"
237
- }
238
- ],
239
- "internalType": "struct TokenInput",
240
- "name": "inp",
241
- "type": "tuple"
242
- },
243
- {
244
- "internalType": "uint256",
245
- "name": "minSyOut",
246
- "type": "uint256"
247
- }
248
- ],
249
- "name": "depositToken",
250
- "outputs": [],
251
- "stateMutability": "payable",
252
- "type": "function"
253
- },
254
- {
255
- "inputs": [],
256
- "name": "readBotState",
257
- "outputs": [
258
- {
259
- "components": [
260
- {
261
- "internalType": "uint256",
262
- "name": "lpBalance",
263
- "type": "uint256"
264
- },
265
- {
266
- "internalType": "uint256",
267
- "name": "ytBalance",
268
- "type": "uint256"
269
- },
270
- {
271
- "internalType": "uint256",
272
- "name": "syBalance",
273
- "type": "uint256"
274
- }
275
- ],
276
- "internalType": "struct BotState",
277
- "name": "botState",
278
- "type": "tuple"
279
- }
280
- ],
281
- "stateMutability": "view",
282
- "type": "function"
283
- },
284
- {
285
- "inputs": [
286
- {
287
- "internalType": "address",
288
- "name": "router",
289
- "type": "address"
290
- }
291
- ],
292
- "name": "readMarketExtState",
293
- "outputs": [
294
- {
295
- "components": [
296
- {
297
- "components": [
298
- {
299
- "internalType": "int256",
300
- "name": "totalPt",
301
- "type": "int256"
302
- },
303
- {
304
- "internalType": "int256",
305
- "name": "totalSy",
306
- "type": "int256"
307
- },
308
- {
309
- "internalType": "int256",
310
- "name": "totalLp",
311
- "type": "int256"
312
- },
313
- {
314
- "internalType": "address",
315
- "name": "treasury",
316
- "type": "address"
317
- },
318
- {
319
- "internalType": "int256",
320
- "name": "scalarRoot",
321
- "type": "int256"
322
- },
323
- {
324
- "internalType": "uint256",
325
- "name": "expiry",
326
- "type": "uint256"
327
- },
328
- {
329
- "internalType": "uint256",
330
- "name": "lnFeeRateRoot",
331
- "type": "uint256"
332
- },
333
- {
334
- "internalType": "uint256",
335
- "name": "reserveFeePercent",
336
- "type": "uint256"
337
- },
338
- {
339
- "internalType": "uint256",
340
- "name": "lastLnImpliedRate",
341
- "type": "uint256"
342
- }
343
- ],
344
- "internalType": "struct MarketState",
345
- "name": "state",
346
- "type": "tuple"
347
- },
348
- {
349
- "internalType": "PYIndex",
350
- "name": "index",
351
- "type": "uint256"
352
- },
353
- {
354
- "internalType": "uint256",
355
- "name": "blockTime",
356
- "type": "uint256"
357
- }
358
- ],
359
- "internalType": "struct MarketExtState",
360
- "name": "marketExt",
361
- "type": "tuple"
362
- }
363
- ],
364
- "stateMutability": "nonpayable",
365
- "type": "function"
366
- },
367
- {
368
- "inputs": [
369
- {
370
- "internalType": "address",
371
- "name": "token",
372
- "type": "address"
373
- },
374
- {
375
- "internalType": "uint256",
376
- "name": "amount",
377
- "type": "uint256"
378
- }
379
- ],
380
- "name": "withdrawFunds",
381
- "outputs": [],
382
- "stateMutability": "nonpayable",
383
- "type": "function"
384
- }
385
- ],
386
- "bytecode": "0x",
387
- "deployedBytecode": "0x",
388
- "linkReferences": {},
389
- "deployedLinkReferences": {}
390
- }
@@ -1,274 +0,0 @@
1
- // SPDX-License-Identifier: GPL-3.0-or-later
2
- pragma solidity ^0.8.0;
3
-
4
- import "./BotSimulationLib.sol";
5
- import "../libraries/Errors.sol";
6
-
7
- struct LongTradingSpecs {
8
- uint256 lowerIyLimit; // apeYtApy
9
- uint256 upperIyLimit; // sellYtApy
10
- uint256 floatingSyRatioLimit; // r
11
- uint256 ytPtRatioLimit; // ytPtRatio (x)
12
- }
13
-
14
- enum ActionType {
15
- SwapSyToYt, // Buy YT with SY
16
- AddLiqKeepYt, // ZPI Zap
17
- AddLiqFromSy, // Single sided LP
18
- AddLiqFromYt, // Sell YT for LP
19
- RemoveLiqToYt, // Zap out to YT,
20
- NONE
21
- }
22
-
23
- enum StrategyFlag {
24
- GOOD,
25
- TOO_LOW,
26
- TOO_HIGH
27
- }
28
-
29
- struct StrategyState {
30
- StrategyFlag iyFlag;
31
- StrategyFlag syRatioFlag;
32
- }
33
-
34
- contract BotDecisionLib {
35
- using MarketExtLib for MarketExtState;
36
- using MarketExtLib for ApproxParams;
37
- using BotSimulationLib for BotState;
38
- using Math for uint256;
39
-
40
- enum RebalanceResult {
41
- FAIL,
42
- OLD_STATE,
43
- NEW_STATE
44
- }
45
-
46
- struct RebalanceDetails {
47
- BotState bot;
48
- MarketExtState marketExt;
49
- LongTradingSpecs specs;
50
- ActionType action;
51
- StrategyState oldState;
52
- }
53
-
54
- /**
55
- * Finds the smallest paramater such that the bot reaches a new state, otherwise finds the
56
- * largest parameter possible that doesn't fail.
57
- *
58
- * @param botParams ApproxParams for this binary search function
59
- * @param oldState The initial StrategyState, to be moved away from
60
- * @param intParams ApproxParams for public action's approximation (e.g. for router's swap)
61
- * @dev For `botParams`, eps = the precision such that slightly lower
62
- * ((return value) * (1 - eps)) does not reach a new state
63
- *
64
- * - Returns `botParams.guessOffchain` if verifies that it reaches a new state,
65
- * and slightly lower does not reach a new state.
66
- * - Reverts if `botParams.guessMin` is invalid, or returns `botParams.guessMin` if reaches a
67
- * new state
68
- * - Returns `botParams.guessMax` if it is valid & does not reach a new state
69
- * - Otherwise, binary search for `guess` such that it reaches a new state, and slightly lower
70
- * does not reach a new state
71
- *
72
- */
73
- function binarySearchUntilSwitchState(
74
- BotState memory bot,
75
- MarketExtState memory marketExt,
76
- LongTradingSpecs memory specs,
77
- ActionType action,
78
- StrategyState memory oldState,
79
- ApproxParams memory botParams,
80
- ApproxParams memory intParams
81
- ) public pure returns (uint256) {
82
- RebalanceDetails memory rebalance = RebalanceDetails(
83
- bot,
84
- marketExt,
85
- specs,
86
- action,
87
- oldState
88
- );
89
-
90
- if (botParams.guessOffchain != 0) {
91
- uint256 guessOffchainMinusDelta = botParams.guessOffchain.mulDown(
92
- Math.ONE - botParams.eps
93
- );
94
- if (
95
- _rebalanceResult(rebalance, botParams.guessOffchain, intParams) ==
96
- RebalanceResult.NEW_STATE &&
97
- _rebalanceResult(rebalance, guessOffchainMinusDelta, intParams) ==
98
- RebalanceResult.OLD_STATE
99
- ) return botParams.guessOffchain;
100
- }
101
-
102
- {
103
- uint256 guessUpperBound = _weakUpperBound(bot, marketExt, action);
104
- if (botParams.guessMax > guessUpperBound) botParams.guessMax = guessUpperBound;
105
- if (botParams.guessMin > botParams.guessMax)
106
- revert Errors.BotBinarySearchInvalidRange(
107
- uint256(action),
108
- botParams.guessMin,
109
- botParams.guessMax
110
- );
111
-
112
- if (
113
- _rebalanceResult(rebalance, botParams.guessMax, intParams) ==
114
- RebalanceResult.OLD_STATE
115
- ) return botParams.guessMax;
116
- }
117
-
118
- {
119
- RebalanceResult guessMinResult = _rebalanceResult(
120
- rebalance,
121
- botParams.guessMin,
122
- intParams
123
- );
124
- if (guessMinResult == RebalanceResult.FAIL)
125
- revert Errors.BotBinarySearchGuessMinInvalid(uint256(action), botParams.guessMin);
126
- if (guessMinResult == RebalanceResult.NEW_STATE) return botParams.guessMin;
127
- }
128
-
129
- for (uint256 iter = 0; iter < botParams.maxIteration; ++iter) {
130
- uint256 guess = botParams.guessMin + (botParams.guessMax - botParams.guessMin) / 2;
131
-
132
- if (_rebalanceResult(rebalance, guess, intParams) == RebalanceResult.OLD_STATE) {
133
- botParams.guessMin = guess;
134
- } else {
135
- botParams.guessMax = guess;
136
- }
137
-
138
- if (Math.isASmallerApproxB(botParams.guessMin, botParams.guessMax, botParams.eps)) {
139
- if (
140
- _rebalanceResult(rebalance, botParams.guessMax, intParams) ==
141
- RebalanceResult.FAIL
142
- ) return botParams.guessMin;
143
-
144
- return botParams.guessMax;
145
- }
146
- }
147
-
148
- revert Errors.BotBinarySearchFail();
149
- }
150
-
151
- function _rebalanceResult(
152
- RebalanceDetails memory rebalance,
153
- uint256 botParam,
154
- ApproxParams memory intParams
155
- ) private pure returns (RebalanceResult) {
156
- (bool success, StrategyState memory newState) = _stateAfterRebalance(
157
- rebalance,
158
- botParam,
159
- intParams
160
- );
161
-
162
- if (!success) return RebalanceResult.FAIL;
163
- if (_sameStrategyState(rebalance.oldState, newState)) return RebalanceResult.OLD_STATE;
164
- return RebalanceResult.NEW_STATE;
165
- }
166
-
167
- function _sameStrategyState(
168
- StrategyState memory initialState,
169
- StrategyState memory otherState
170
- ) private pure returns (bool) {
171
- return
172
- (initialState.iyFlag == otherState.iyFlag) &&
173
- (initialState.syRatioFlag == otherState.syRatioFlag);
174
- }
175
-
176
- function _stateAfterRebalance(
177
- RebalanceDetails memory rebalance,
178
- uint256 botParam,
179
- ApproxParams memory intParams
180
- ) private pure returns (bool success, StrategyState memory currentState) {
181
- BotState memory botClone = rebalance.bot.clone();
182
- MarketExtState memory marketExtClone = rebalance.marketExt.clone();
183
-
184
- if (rebalance.action == ActionType.SwapSyToYt) {
185
- success = botClone.swapSyToYt(marketExtClone, botParam);
186
- } else if (rebalance.action == ActionType.AddLiqKeepYt) {
187
- success = botClone.addLiqKeepYt(marketExtClone, botParam);
188
- } else if (rebalance.action == ActionType.AddLiqFromSy) {
189
- success = botClone.addLiqFromSy(marketExtClone, botParam);
190
- } else if (rebalance.action == ActionType.AddLiqFromYt) {
191
- success = botClone.addLiqFromYt(marketExtClone, botParam);
192
- } else if (rebalance.action == ActionType.RemoveLiqToYt) {
193
- success = botClone.removeLiqToYt(marketExtClone, botParam, intParams.clone());
194
- } else {
195
- success = false;
196
- }
197
-
198
- if (success) {
199
- currentState = strategyState(botClone, marketExtClone, rebalance.specs);
200
- }
201
- }
202
-
203
- /// @dev Gives a weak upper bound so that MarketExtLib's simulation doesn't revert
204
- function _weakUpperBound(
205
- BotState memory bot,
206
- MarketExtState memory marketExt,
207
- ActionType action
208
- ) private pure returns (uint256) {
209
- if (action == ActionType.SwapSyToYt) {
210
- return marketExt.calcMaxPtIn();
211
- } else if (action == ActionType.AddLiqKeepYt) {
212
- return bot.syBalance;
213
- } else if (action == ActionType.AddLiqFromSy) {
214
- return marketExt.calcMaxPtOut();
215
- } else if (action == ActionType.AddLiqFromYt) {
216
- return marketExt.calcMaxPtOut();
217
- } else if (action == ActionType.RemoveLiqToYt) {
218
- return bot.lpBalance;
219
- } else {
220
- return 0;
221
- }
222
- }
223
-
224
- function strategyState(
225
- BotState memory bot,
226
- MarketExtState memory marketExt,
227
- LongTradingSpecs memory specs
228
- ) public pure returns (StrategyState memory currentState) {
229
- uint256 iy = marketExt.impliedYield();
230
- (, uint256 ptInLp) = marketExt.previewAssetsFromLp(bot.lpBalance);
231
- uint256 currentYtPtRatio = (
232
- ptInLp == 0 ? type(uint256).max : bot.ytBalance.divDown(ptInLp)
233
- );
234
-
235
- if (iy < specs.lowerIyLimit) {
236
- currentState.iyFlag = StrategyFlag.TOO_LOW;
237
- } else if (specs.upperIyLimit < iy && currentYtPtRatio > specs.ytPtRatioLimit) {
238
- currentState.iyFlag = StrategyFlag.TOO_HIGH;
239
- } else {
240
- currentState.iyFlag = StrategyFlag.GOOD;
241
- }
242
-
243
- uint256 currentSyRatio = bot.syBalance.divDown(bot.tvlInSy(marketExt));
244
- if (currentSyRatio > specs.floatingSyRatioLimit) {
245
- currentState.syRatioFlag = StrategyFlag.TOO_HIGH;
246
- } else {
247
- currentState.syRatioFlag = StrategyFlag.GOOD;
248
- }
249
- }
250
-
251
- function actionToTake(BotState memory botState, StrategyState memory currentState) public pure returns (ActionType) {
252
- if (currentState.iyFlag == StrategyFlag.TOO_LOW) {
253
- if (currentState.syRatioFlag == StrategyFlag.TOO_HIGH) {
254
- return ActionType.SwapSyToYt;
255
- } else {
256
- if (botState.lpBalance == 0) return ActionType.NONE;
257
- return ActionType.RemoveLiqToYt;
258
- }
259
- } else if (currentState.iyFlag == StrategyFlag.GOOD) {
260
- if (currentState.syRatioFlag == StrategyFlag.TOO_HIGH) {
261
- return ActionType.AddLiqKeepYt;
262
- } else {
263
- return ActionType.NONE;
264
- }
265
- } else {
266
- if (currentState.syRatioFlag == StrategyFlag.TOO_HIGH) {
267
- return ActionType.AddLiqFromSy;
268
- } else {
269
- if (botState.ytBalance == 0) return ActionType.NONE;
270
- return ActionType.AddLiqFromYt;
271
- }
272
- }
273
- }
274
- }