@pendle/core-v2 2.17.5-tradingbot → 2.17.7-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 (162) hide show
  1. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiveEndpointUpg.sol/PendleMsgReceiveEndpointUpg.dbg.json +1 -1
  2. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgReceiverAppUpg.sol/PendleMsgReceiverAppUpg.dbg.json +1 -1
  3. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSendEndpointUpg.sol/PendleMsgSendEndpointUpg.dbg.json +1 -1
  4. package/build/artifacts/contracts/LiquidityMining/CrossChainMsg/PendleMsgSenderAppUpg.sol/PendleMsgSenderAppUpg.dbg.json +1 -1
  5. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerBaseUpg.sol/PendleGaugeControllerBaseUpg.dbg.json +1 -1
  6. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerMainchainUpg.sol/PendleGaugeControllerMainchainUpg.dbg.json +1 -1
  7. package/build/artifacts/contracts/LiquidityMining/GaugeController/PendleGaugeControllerSidechainUpg.sol/PendleGaugeControllerSidechainUpg.dbg.json +1 -1
  8. package/build/artifacts/contracts/LiquidityMining/VeDistributor/PendleFeeDistributor.sol/PendleFeeDistributor.dbg.json +1 -1
  9. package/build/artifacts/contracts/LiquidityMining/VeDistributor/PendleFeeDistributorV2.sol/PendleFeeDistributorV2.dbg.json +1 -1
  10. package/build/artifacts/contracts/LiquidityMining/VotingController/PendleVotingControllerUpg.sol/PendleVotingControllerUpg.dbg.json +1 -1
  11. package/build/artifacts/contracts/LiquidityMining/VotingController/VotingControllerStorageUpg.sol/VotingControllerStorageUpg.dbg.json +1 -1
  12. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleMainchain.sol/VotingEscrowPendleMainchain.dbg.json +1 -1
  13. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowPendleSidechain.sol/VotingEscrowPendleSidechain.dbg.json +1 -1
  14. package/build/artifacts/contracts/LiquidityMining/VotingEscrow/VotingEscrowTokenBase.sol/VotingEscrowTokenBase.dbg.json +1 -1
  15. package/build/artifacts/contracts/LiquidityMining/libraries/VeBalanceLib.sol/VeBalanceLib.dbg.json +1 -1
  16. package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/CheckpointHelper.dbg.json +1 -1
  17. package/build/artifacts/contracts/LiquidityMining/libraries/VeHistoryLib.sol/Checkpoints.dbg.json +1 -1
  18. package/build/artifacts/contracts/core/BulkSeller/BulkSeller.sol/BulkSeller.dbg.json +1 -1
  19. package/build/artifacts/contracts/core/BulkSeller/BulkSellerFactory.sol/BulkSellerFactory.dbg.json +1 -1
  20. package/build/artifacts/contracts/core/BulkSeller/BulkSellerMathCore.sol/BulkSellerMathCore.dbg.json +1 -1
  21. package/build/artifacts/contracts/core/Market/MarketMathCore.sol/MarketMathCore.dbg.json +1 -1
  22. package/build/artifacts/contracts/core/Market/OracleLib.sol/OracleLib.dbg.json +1 -1
  23. package/build/artifacts/contracts/core/Market/PendleGauge.sol/PendleGauge.dbg.json +1 -1
  24. package/build/artifacts/contracts/core/Market/PendleMarket.sol/PendleMarket.dbg.json +1 -1
  25. package/build/artifacts/contracts/core/Market/PendleMarketFactory.sol/PendleMarketFactory.dbg.json +1 -1
  26. package/build/artifacts/contracts/core/StandardizedYield/SYBase.sol/SYBase.dbg.json +1 -1
  27. package/build/artifacts/contracts/core/StandardizedYield/SYBaseWithRewards.sol/SYBaseWithRewards.dbg.json +1 -1
  28. package/build/artifacts/contracts/core/StandardizedYield/implementations/Ape/sAPE.sol/sAPE.dbg.json +1 -1
  29. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraBbAWethSwethSY.sol/PendleAuraBbAWethSwethSY.dbg.json +1 -1
  30. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethAnkrethSYV2.sol/PendleAuraWethAnkrethSYV2.dbg.json +1 -1
  31. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethRocketEthSYV2.sol/PendleAuraWethRocketEthSYV2.dbg.json +1 -1
  32. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethStafiEthSY.sol/PendleAuraWethStafiEthSY.dbg.json +1 -1
  33. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/PendleAuraWethWstethSYV2.sol/PendleAuraWethWstethSYV2.dbg.json +1 -1
  34. package/build/artifacts/contracts/core/StandardizedYield/implementations/BalancerStable/base/PendleAuraBalancerStableLPSYV2.sol/PendleAuraBalancerStableLPSYV2.dbg.json +1 -1
  35. package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenHelper.sol/PendleQiTokenHelper.dbg.json +1 -1
  36. package/build/artifacts/contracts/core/StandardizedYield/implementations/BenQi/PendleQiTokenSY.sol/PendleQiTokenSY.dbg.json +1 -1
  37. package/build/artifacts/contracts/core/StandardizedYield/implementations/CamelotV1Volatile/PendleCamelotV1VolatileSY.sol/PendleCamelotV1VolatileSY.dbg.json +1 -1
  38. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveFraxUsdcSY.sol/PendleCurveFraxUsdcSY.dbg.json +1 -1
  39. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/PendleCurveUsdd3CrvSY.sol/PendleCurveUsdd3CrvSY.dbg.json +1 -1
  40. package/build/artifacts/contracts/core/StandardizedYield/implementations/Convex/base/PendleConvexLPSY.sol/PendleConvexLPSY.dbg.json +1 -1
  41. package/build/artifacts/contracts/core/StandardizedYield/implementations/GLP/PendleGlpSY.sol/PendleGlpSY.dbg.json +1 -1
  42. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleGdaiSY.sol/PendleGDaiSY.dbg.json +1 -1
  43. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleLooksStakingSY.sol/PendleLooksStakingSY.dbg.json +1 -1
  44. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleSfrxEthSY.sol/PendleSfrxEthSY.dbg.json +1 -1
  45. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleStargateLPSY.sol/PendleStargateLPSY.dbg.json +1 -1
  46. package/build/artifacts/contracts/core/StandardizedYield/implementations/PendleWstEthSY.sol/PendleWstEthSY.dbg.json +1 -1
  47. package/build/artifacts/contracts/core/TradingBot/BotActionCallback.sol/BotActionCallback.dbg.json +1 -1
  48. package/build/artifacts/contracts/core/TradingBot/BotActionCallback.sol/BotActionCallback.json +25 -0
  49. package/build/artifacts/contracts/core/TradingBot/BotActionHelper.sol/BotActionHelper.dbg.json +1 -1
  50. package/build/artifacts/contracts/core/TradingBot/BotActionHelper.sol/BotActionHelper.json +25 -0
  51. package/build/artifacts/contracts/core/TradingBot/BotDecisionHelper.sol/BotDecisionHelper.dbg.json +4 -0
  52. package/build/artifacts/contracts/core/TradingBot/BotDecisionHelper.sol/BotDecisionHelper.json +1070 -0
  53. package/build/artifacts/contracts/core/TradingBot/BotSimulationLib.sol/BotSimulationLib.dbg.json +1 -1
  54. package/build/artifacts/contracts/core/TradingBot/BotSimulationLib.sol/BotSimulationLib.json +2 -2
  55. package/build/artifacts/contracts/core/TradingBot/LongYieldTradingBot.sol/LongYieldTradingBot.dbg.json +1 -1
  56. package/build/artifacts/contracts/core/TradingBot/LongYieldTradingBot.sol/LongYieldTradingBot.json +60 -180
  57. package/build/artifacts/contracts/core/TradingBot/MarketExtLib.sol/MarketExtLib.dbg.json +1 -1
  58. package/build/artifacts/contracts/core/TradingBot/MarketExtLib.sol/MarketExtLib.json +2 -2
  59. package/build/artifacts/contracts/core/TradingBot/TradingBotBase.sol/TradingBotBase.dbg.json +1 -1
  60. package/build/artifacts/contracts/core/TradingBot/TradingBotBase.sol/TradingBotBase.json +25 -0
  61. package/build/artifacts/contracts/core/YieldContracts/PendlePrincipalToken.sol/PendlePrincipalToken.dbg.json +1 -1
  62. package/build/artifacts/contracts/core/YieldContracts/PendleYieldContractFactory.sol/PendleYieldContractFactory.dbg.json +1 -1
  63. package/build/artifacts/contracts/core/YieldContracts/PendleYieldToken.sol/PendleYieldToken.dbg.json +1 -1
  64. package/build/artifacts/contracts/core/YieldContractsV2/PendlePrincipalTokenV2.sol/PendlePrincipalTokenV2.dbg.json +1 -1
  65. package/build/artifacts/contracts/core/YieldContractsV2/PendleYieldContractFactoryV2.sol/PendleYieldContractFactoryV2.dbg.json +1 -1
  66. package/build/artifacts/contracts/core/YieldContractsV2/PendleYieldTokenV2.sol/PendleYieldTokenV2.dbg.json +1 -1
  67. package/build/artifacts/contracts/core/libraries/Errors.sol/Errors.dbg.json +1 -1
  68. package/build/artifacts/contracts/core/libraries/TokenAmountLib.sol/TokenAmountLib.dbg.json +1 -1
  69. package/build/artifacts/contracts/interfaces/IPActionAddRemoveLiq.sol/IPActionAddRemoveLiq.dbg.json +1 -1
  70. package/build/artifacts/contracts/interfaces/IPActionInfoStatic.sol/IPActionInfoStatic.dbg.json +1 -1
  71. package/build/artifacts/contracts/interfaces/IPActionMarketAuxStatic.sol/IPActionMarketAuxStatic.dbg.json +1 -1
  72. package/build/artifacts/contracts/interfaces/IPActionMarketCoreStatic.sol/IPActionMarketCoreStatic.dbg.json +1 -1
  73. package/build/artifacts/contracts/interfaces/IPActionMintRedeem.sol/IPActionMintRedeem.dbg.json +1 -1
  74. package/build/artifacts/contracts/interfaces/IPActionMintRedeemStatic.sol/IPActionMintRedeemStatic.dbg.json +1 -1
  75. package/build/artifacts/contracts/interfaces/IPActionStorageStatic.sol/IPActionStorageStatic.dbg.json +1 -1
  76. package/build/artifacts/contracts/interfaces/IPActionSwapPT.sol/IPActionSwapPT.dbg.json +1 -1
  77. package/build/artifacts/contracts/interfaces/IPActionSwapYT.sol/IPActionSwapYT.dbg.json +1 -1
  78. package/build/artifacts/contracts/interfaces/IPAllAction.sol/IPAllAction.dbg.json +1 -1
  79. package/build/artifacts/contracts/interfaces/IPBulkSeller.sol/IPBulkSeller.dbg.json +1 -1
  80. package/build/artifacts/contracts/interfaces/IPMarket.sol/IPMarket.dbg.json +1 -1
  81. package/build/artifacts/contracts/interfaces/IPRouterHelper.sol/IPRouterHelper.dbg.json +1 -1
  82. package/build/artifacts/contracts/interfaces/IPRouterStatic.sol/IPRouterStatic.dbg.json +1 -1
  83. package/build/artifacts/contracts/interfaces/IPVotingController.sol/IPVotingController.dbg.json +1 -1
  84. package/build/artifacts/contracts/interfaces/IPVotingEscrowMainchain.sol/IPVotingEscrowMainchain.dbg.json +1 -1
  85. package/build/artifacts/contracts/interfaces/IStandardizedYield.sol/IStandardizedYield.dbg.json +1 -1
  86. package/build/artifacts/contracts/interfaces/TradingBot/IBotDecisionHelper.sol/IBotDecisionHelper.dbg.json +4 -0
  87. package/build/artifacts/contracts/interfaces/TradingBot/IBotDecisionHelper.sol/IBotDecisionHelper.json +917 -0
  88. package/build/artifacts/contracts/interfaces/TradingBot/ILongYieldTradingBot.sol/ILongYieldTradingBot.dbg.json +1 -1
  89. package/build/artifacts/contracts/interfaces/TradingBot/ILongYieldTradingBot.sol/ILongYieldTradingBot.json +425 -161
  90. package/build/artifacts/contracts/interfaces/TradingBot/ITradingBotBase.sol/ITradingBotBase.dbg.json +1 -1
  91. package/build/artifacts/contracts/interfaces/TradingBot/ITradingBotBase.sol/ITradingBotBase.json +50 -0
  92. package/build/artifacts/contracts/offchain-helpers/BoringLpSeller.sol/BoringLpSeller.dbg.json +1 -1
  93. package/build/artifacts/contracts/offchain-helpers/BoringPtSeller.sol/BoringPtSeller.dbg.json +1 -1
  94. package/build/artifacts/contracts/offchain-helpers/Broadcaster.sol/Broadcaster.dbg.json +1 -1
  95. package/build/artifacts/contracts/offchain-helpers/BulkSellerOffchain.sol/BulkSellerOffchain.dbg.json +1 -1
  96. package/build/artifacts/contracts/offchain-helpers/MarketExchangeRateLib.sol/MarketExchangeRateLib.dbg.json +1 -1
  97. package/build/artifacts/contracts/offchain-helpers/router-static/PendleRouterStatic.sol/PendleRouterStatic.dbg.json +1 -1
  98. package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionInfoStatic.sol/ActionInfoStatic.dbg.json +1 -1
  99. package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionMarketAuxStatic.sol/ActionMarketAuxStatic.dbg.json +1 -1
  100. package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionMarketCoreStatic.sol/ActionMarketCoreStatic.dbg.json +1 -1
  101. package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionMintRedeemStatic.sol/ActionMintRedeemStatic.dbg.json +1 -1
  102. package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionStorageStatic.sol/ActionStorageStatic.dbg.json +1 -1
  103. package/build/artifacts/contracts/offchain-helpers/router-static/base/ActionVePendleStatic.sol/ActionVePendleStatic.dbg.json +1 -1
  104. package/build/artifacts/contracts/offchain-helpers/router-static/base/StorageLayout.sol/StorageLayout.dbg.json +1 -1
  105. package/build/artifacts/contracts/oracles/PendleLpOracleLib.sol/PendleLpOracleLib.dbg.json +1 -1
  106. package/build/artifacts/contracts/oracles/PendlePtOracle.sol/PendlePtOracle.dbg.json +1 -1
  107. package/build/artifacts/contracts/oracles/PendlePtOracleLib.sol/PendlePtOracleLib.dbg.json +1 -1
  108. package/build/artifacts/contracts/oracles/samples/PendleLpGlpOracle.sol/PendleLpGlpOracle.dbg.json +1 -1
  109. package/build/artifacts/contracts/oracles/samples/PendlePtGlpOracle.sol/PendlePtGlpOracle.dbg.json +1 -1
  110. package/build/artifacts/contracts/router/ActionAddRemoveLiq.sol/ActionAddRemoveLiq.dbg.json +1 -1
  111. package/build/artifacts/contracts/router/ActionMintRedeem.sol/ActionMintRedeem.dbg.json +1 -1
  112. package/build/artifacts/contracts/router/ActionSwapPT.sol/ActionSwapPT.dbg.json +1 -1
  113. package/build/artifacts/contracts/router/ActionSwapYT.sol/ActionSwapYT.dbg.json +1 -1
  114. package/build/artifacts/contracts/router/PendleRouter.sol/PendleRouter.dbg.json +1 -1
  115. package/build/artifacts/contracts/router/PendleRouterHelper.sol/PendleRouterHelper.dbg.json +1 -1
  116. package/build/artifacts/contracts/router/base/ActionBaseCallback.sol/ActionBaseCallback.dbg.json +1 -1
  117. package/build/artifacts/contracts/router/base/ActionBaseMintRedeem.sol/ActionBaseMintRedeem.dbg.json +1 -1
  118. package/build/artifacts/contracts/router/base/CallbackHelper.sol/CallbackHelper.dbg.json +1 -1
  119. package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtInLib.dbg.json +1 -1
  120. package/build/artifacts/contracts/router/base/MarketApproxLib.sol/MarketApproxPtOutLib.dbg.json +1 -1
  121. package/contracts/core/TradingBot/BotActionCallback.sol +1 -1
  122. package/contracts/core/TradingBot/BotDecisionHelper.sol +306 -0
  123. package/contracts/core/TradingBot/BotSimulationLib.sol +8 -7
  124. package/contracts/core/TradingBot/LongYieldTradingBot.sol +20 -24
  125. package/contracts/core/TradingBot/MarketExtLib.sol +64 -31
  126. package/contracts/core/TradingBot/README.md +27 -25
  127. package/contracts/core/TradingBot/TradingBotBase.sol +36 -16
  128. package/contracts/interfaces/TradingBot/IBotDecisionHelper.sol +91 -0
  129. package/contracts/interfaces/TradingBot/ILongYieldTradingBot.sol +7 -32
  130. package/contracts/interfaces/TradingBot/ITradingBotBase.sol +6 -4
  131. package/package.json +1 -1
  132. package/typechain-types/BotActionCallback.ts +36 -0
  133. package/typechain-types/BotActionHelper.ts +36 -0
  134. package/typechain-types/BotDecisionHelper.ts +527 -0
  135. package/typechain-types/IBotDecisionHelper.ts +507 -0
  136. package/typechain-types/ILongYieldTradingBot.ts +481 -129
  137. package/typechain-types/ITradingBotBase.ts +76 -0
  138. package/typechain-types/IWBETH.ts +128 -0
  139. package/typechain-types/LongYieldTradingBot.ts +85 -141
  140. package/typechain-types/PendleBinanceEth.ts +1229 -0
  141. package/typechain-types/PtAndLpToAsset.ts +136 -0
  142. package/typechain-types/TradingBotBase.ts +36 -0
  143. package/typechain-types/factories/BotActionCallback__factory.ts +25 -0
  144. package/typechain-types/factories/BotActionHelper__factory.ts +25 -0
  145. package/typechain-types/factories/BotDecisionHelper__factory.ts +1123 -0
  146. package/typechain-types/factories/IBotDecisionHelper__factory.ts +932 -0
  147. package/typechain-types/factories/ILongYieldTradingBot__factory.ts +425 -161
  148. package/typechain-types/factories/ITradingBotBase__factory.ts +50 -0
  149. package/typechain-types/factories/IWBETH__factory.ts +51 -0
  150. package/typechain-types/factories/LongYieldTradingBot__factory.ts +63 -183
  151. package/typechain-types/factories/MarketExtLib__factory.ts +1 -1
  152. package/typechain-types/factories/PendleBinanceEth__factory.ts +1052 -0
  153. package/typechain-types/factories/PtAndLpToAsset__factory.ts +150 -0
  154. package/typechain-types/factories/TradingBotBase__factory.ts +25 -0
  155. package/typechain-types/hardhat.d.ts +49 -13
  156. package/typechain-types/index.ts +12 -4
  157. package/build/artifacts/contracts/core/TradingBot/BotDecisionLib.sol/BotDecisionLib.dbg.json +0 -4
  158. package/build/artifacts/contracts/core/TradingBot/BotDecisionLib.sol/BotDecisionLib.json +0 -589
  159. package/build/artifacts/contracts/core/TradingBot/TradingBotOffchain.sol/TradingBotOffchain.dbg.json +0 -4
  160. package/build/artifacts/contracts/core/TradingBot/TradingBotOffchain.sol/TradingBotOffchain.json +0 -1075
  161. package/contracts/core/TradingBot/BotDecisionLib.sol +0 -274
  162. package/contracts/core/TradingBot/TradingBotOffchain.sol +0 -141
@@ -73,6 +73,31 @@
73
73
  "name": "WithdrawFunds",
74
74
  "type": "event"
75
75
  },
76
+ {
77
+ "inputs": [
78
+ {
79
+ "components": [
80
+ {
81
+ "internalType": "address[]",
82
+ "name": "tokens",
83
+ "type": "address[]"
84
+ },
85
+ {
86
+ "internalType": "address",
87
+ "name": "spender",
88
+ "type": "address"
89
+ }
90
+ ],
91
+ "internalType": "struct ITradingBotBase.MultiApproval[]",
92
+ "name": "arr",
93
+ "type": "tuple[]"
94
+ }
95
+ ],
96
+ "name": "approveInf",
97
+ "outputs": [],
98
+ "stateMutability": "nonpayable",
99
+ "type": "function"
100
+ },
76
101
  {
77
102
  "inputs": [
78
103
  {
@@ -161,6 +186,31 @@
161
186
  "stateMutability": "nonpayable",
162
187
  "type": "function"
163
188
  },
189
+ {
190
+ "inputs": [],
191
+ "name": "claimWithoutCompound",
192
+ "outputs": [
193
+ {
194
+ "components": [
195
+ {
196
+ "internalType": "address",
197
+ "name": "token",
198
+ "type": "address"
199
+ },
200
+ {
201
+ "internalType": "uint256",
202
+ "name": "amount",
203
+ "type": "uint256"
204
+ }
205
+ ],
206
+ "internalType": "struct TokenAmount[]",
207
+ "name": "rewards",
208
+ "type": "tuple[]"
209
+ }
210
+ ],
211
+ "stateMutability": "nonpayable",
212
+ "type": "function"
213
+ },
164
214
  {
165
215
  "inputs": [
166
216
  {
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/5c3de2907fbe79e061fec785d27e50e4.json"
3
+ "buildInfo": "../../../build-info/cc56e782217e84241a017d65d57770d1.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/5c3de2907fbe79e061fec785d27e50e4.json"
3
+ "buildInfo": "../../../build-info/cc56e782217e84241a017d65d57770d1.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/5c3de2907fbe79e061fec785d27e50e4.json"
3
+ "buildInfo": "../../../build-info/cc56e782217e84241a017d65d57770d1.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/5c3de2907fbe79e061fec785d27e50e4.json"
3
+ "buildInfo": "../../../build-info/cc56e782217e84241a017d65d57770d1.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/5c3de2907fbe79e061fec785d27e50e4.json"
3
+ "buildInfo": "../../../build-info/cc56e782217e84241a017d65d57770d1.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../../build-info/5c3de2907fbe79e061fec785d27e50e4.json"
3
+ "buildInfo": "../../../../build-info/cc56e782217e84241a017d65d57770d1.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../../../build-info/5c3de2907fbe79e061fec785d27e50e4.json"
3
+ "buildInfo": "../../../../../build-info/cc56e782217e84241a017d65d57770d1.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../../../build-info/5c3de2907fbe79e061fec785d27e50e4.json"
3
+ "buildInfo": "../../../../../build-info/cc56e782217e84241a017d65d57770d1.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../../../build-info/5c3de2907fbe79e061fec785d27e50e4.json"
3
+ "buildInfo": "../../../../../build-info/cc56e782217e84241a017d65d57770d1.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../../../build-info/5c3de2907fbe79e061fec785d27e50e4.json"
3
+ "buildInfo": "../../../../../build-info/cc56e782217e84241a017d65d57770d1.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../../../build-info/5c3de2907fbe79e061fec785d27e50e4.json"
3
+ "buildInfo": "../../../../../build-info/cc56e782217e84241a017d65d57770d1.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../../../build-info/5c3de2907fbe79e061fec785d27e50e4.json"
3
+ "buildInfo": "../../../../../build-info/cc56e782217e84241a017d65d57770d1.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../../../build-info/5c3de2907fbe79e061fec785d27e50e4.json"
3
+ "buildInfo": "../../../../../build-info/cc56e782217e84241a017d65d57770d1.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/5c3de2907fbe79e061fec785d27e50e4.json"
3
+ "buildInfo": "../../../build-info/cc56e782217e84241a017d65d57770d1.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/5c3de2907fbe79e061fec785d27e50e4.json"
3
+ "buildInfo": "../../../build-info/cc56e782217e84241a017d65d57770d1.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/5c3de2907fbe79e061fec785d27e50e4.json"
3
+ "buildInfo": "../../../build-info/cc56e782217e84241a017d65d57770d1.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../../build-info/5c3de2907fbe79e061fec785d27e50e4.json"
3
+ "buildInfo": "../../../../build-info/cc56e782217e84241a017d65d57770d1.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../../build-info/5c3de2907fbe79e061fec785d27e50e4.json"
3
+ "buildInfo": "../../../../build-info/cc56e782217e84241a017d65d57770d1.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/5c3de2907fbe79e061fec785d27e50e4.json"
3
+ "buildInfo": "../../../build-info/cc56e782217e84241a017d65d57770d1.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/5c3de2907fbe79e061fec785d27e50e4.json"
3
+ "buildInfo": "../../../build-info/cc56e782217e84241a017d65d57770d1.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/5c3de2907fbe79e061fec785d27e50e4.json"
3
+ "buildInfo": "../../../build-info/cc56e782217e84241a017d65d57770d1.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/5c3de2907fbe79e061fec785d27e50e4.json"
3
+ "buildInfo": "../../../build-info/cc56e782217e84241a017d65d57770d1.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/5c3de2907fbe79e061fec785d27e50e4.json"
3
+ "buildInfo": "../../../build-info/cc56e782217e84241a017d65d57770d1.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/5c3de2907fbe79e061fec785d27e50e4.json"
3
+ "buildInfo": "../../../build-info/cc56e782217e84241a017d65d57770d1.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../../build-info/5c3de2907fbe79e061fec785d27e50e4.json"
3
+ "buildInfo": "../../../../build-info/cc56e782217e84241a017d65d57770d1.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../../build-info/5c3de2907fbe79e061fec785d27e50e4.json"
3
+ "buildInfo": "../../../../build-info/cc56e782217e84241a017d65d57770d1.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../../build-info/5c3de2907fbe79e061fec785d27e50e4.json"
3
+ "buildInfo": "../../../../build-info/cc56e782217e84241a017d65d57770d1.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../../build-info/5c3de2907fbe79e061fec785d27e50e4.json"
3
+ "buildInfo": "../../../../build-info/cc56e782217e84241a017d65d57770d1.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../../build-info/5c3de2907fbe79e061fec785d27e50e4.json"
3
+ "buildInfo": "../../../../build-info/cc56e782217e84241a017d65d57770d1.json"
4
4
  }
@@ -2,7 +2,7 @@
2
2
  pragma solidity 0.8.17;
3
3
 
4
4
  import "../../interfaces/IPMarketSwapCallback.sol";
5
- import "./BotDecisionLib.sol";
5
+ import "./BotDecisionHelper.sol";
6
6
  import "./TradingBotBase.sol";
7
7
 
8
8
  abstract contract BotActionCallback is TradingBotBase, IPMarketSwapCallback {
@@ -0,0 +1,306 @@
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
+ import "../../interfaces/TradingBot/IBotDecisionHelper.sol";
7
+
8
+ contract BotDecisionHelper is IBotDecisionHelper {
9
+ using MarketExtLib for MarketExtState;
10
+ using MarketExtLib for ApproxParams;
11
+ using MarketMathCore for MarketState;
12
+ using MarketApproxPtInLib for MarketState;
13
+ using BotSimulationLib for BotState;
14
+ using PYIndexLib for PYIndex;
15
+ using Math for uint256;
16
+
17
+ /**
18
+ * Binary search for the smallest parameter `botParam` for the corresponding rebalancing action
19
+ * such that the bot reaches desired target, otherwise give the largest `botParam` possible
20
+ * that action doesn't revert.
21
+ *
22
+ * @param action Action to take, from which target is derived
23
+ * @param botParams ApproxParams for `botParam`
24
+ * @param intParams ApproxParams for internal action's approximation (e.g. for router's swap)
25
+ *
26
+ * For `botParams`, eps = the precision such that slightly lower
27
+ * (param = (return value) * (1 - eps)) does not reach target
28
+ *
29
+ * - Returns `botParams.guessOffchain` if it reaches target, and slightly lower does not
30
+ * - Reverts if `botParams.guessMin` is invalid, or returns `botParams.guessMin` if reaches
31
+ * target
32
+ * - Returns `botParams.guessMax` if it is valid & does not reach target
33
+ * - Otherwise, binary search for `guess` such that it reaches target, and slightly lower does
34
+ * not
35
+ *
36
+ */
37
+ function searchForBotParam(
38
+ BotState memory bot,
39
+ MarketExtState memory marketExt,
40
+ LongTradingSpecs memory specs,
41
+ ActionType action,
42
+ ApproxParams memory botParams,
43
+ ApproxParams memory intParams
44
+ ) public pure returns (uint256, RebalanceResult) {
45
+ RebalanceDetails memory rebalance = RebalanceDetails(bot, marketExt, specs, action);
46
+
47
+ if (botParams.guessOffchain != 0) {
48
+ uint256 guessOffchainMinusDelta = botParams.guessOffchain.mulDown(
49
+ Math.ONE - botParams.eps
50
+ );
51
+ if (
52
+ _rebalanceResult(rebalance, botParams.guessOffchain, intParams) ==
53
+ RebalanceResult.TARGET_REACHED &&
54
+ _rebalanceResult(rebalance, guessOffchainMinusDelta, intParams) ==
55
+ RebalanceResult.TARGET_NOT_REACHED
56
+ ) return (botParams.guessOffchain, RebalanceResult.TARGET_REACHED);
57
+ }
58
+
59
+ {
60
+ uint256 guessUpperBound = _weakUpperBound(bot, marketExt, action);
61
+ if (botParams.guessMax > guessUpperBound) botParams.guessMax = guessUpperBound;
62
+ if (botParams.guessMin > botParams.guessMax)
63
+ revert Errors.BotBinarySearchInvalidRange(
64
+ uint256(action),
65
+ botParams.guessMin,
66
+ botParams.guessMax
67
+ );
68
+
69
+ if (
70
+ _rebalanceResult(rebalance, botParams.guessMax, intParams) ==
71
+ RebalanceResult.TARGET_NOT_REACHED
72
+ ) return (botParams.guessMax, RebalanceResult.TARGET_NOT_REACHED);
73
+ }
74
+
75
+ {
76
+ RebalanceResult guessMinResult = _rebalanceResult(
77
+ rebalance,
78
+ botParams.guessMin,
79
+ intParams
80
+ );
81
+ if (guessMinResult == RebalanceResult.FAIL)
82
+ revert Errors.BotBinarySearchGuessMinInvalid(uint256(action), botParams.guessMin);
83
+ if (guessMinResult == RebalanceResult.TARGET_REACHED)
84
+ return (botParams.guessMin, RebalanceResult.TARGET_REACHED);
85
+ }
86
+
87
+ for (uint256 iter = 0; iter < botParams.maxIteration; ++iter) {
88
+ uint256 guess = botParams.guessMin + (botParams.guessMax - botParams.guessMin) / 2;
89
+
90
+ if (
91
+ _rebalanceResult(rebalance, guess, intParams) == RebalanceResult.TARGET_NOT_REACHED
92
+ ) {
93
+ botParams.guessMin = guess;
94
+ } else {
95
+ botParams.guessMax = guess;
96
+ }
97
+
98
+ if (Math.isASmallerApproxB(botParams.guessMin, botParams.guessMax, botParams.eps)) {
99
+ if (
100
+ _rebalanceResult(rebalance, botParams.guessMin, intParams) ==
101
+ RebalanceResult.FAIL
102
+ )
103
+ return (
104
+ botParams.guessMin,
105
+ _rebalanceResult(rebalance, botParams.guessMin, intParams)
106
+ );
107
+
108
+ return (
109
+ botParams.guessMax,
110
+ _rebalanceResult(rebalance, botParams.guessMax, intParams)
111
+ );
112
+ }
113
+ }
114
+
115
+ revert Errors.BotBinarySearchFail();
116
+ }
117
+
118
+ /**
119
+ * Given the rebalancing action and its `botParam`, binary search for the optimal internal
120
+ * parameter `intParam` for the internal action's approximation (e.g. for router's swap)
121
+ */
122
+ function searchForIntParam(
123
+ MarketExtState memory marketExt,
124
+ ActionType action,
125
+ uint256 botParam,
126
+ ApproxParams memory intParams
127
+ ) public pure returns (uint256) {
128
+ if (action == ActionType.RemoveLiqToYt) {
129
+ (, uint256 totalPtToSwap) = marketExt.clone().removeLiqToYt(botParam, intParams);
130
+ return totalPtToSwap;
131
+ } else {
132
+ return 0;
133
+ }
134
+ }
135
+
136
+ function strategyState(
137
+ BotState memory bot,
138
+ MarketExtState memory marketExt,
139
+ LongTradingSpecs memory specs
140
+ ) public pure returns (StrategyState memory currentState) {
141
+ (, uint256 iy, uint256 currentSyRatio, uint256 currentYtPtRatio) = botExtStats(
142
+ bot,
143
+ marketExt
144
+ );
145
+
146
+ if (iy < specs.lowerIyLimit) {
147
+ currentState.iyFlag = StrategyFlag.TOO_LOW;
148
+ } else if (specs.upperIyLimit < iy && currentYtPtRatio > specs.ytPtRatioLimit) {
149
+ currentState.iyFlag = StrategyFlag.TOO_HIGH;
150
+ } else {
151
+ currentState.iyFlag = StrategyFlag.GOOD;
152
+ }
153
+
154
+ if (currentSyRatio > specs.floatingSyRatioLimit) {
155
+ currentState.syRatioFlag = StrategyFlag.TOO_HIGH;
156
+ } else {
157
+ currentState.syRatioFlag = StrategyFlag.GOOD;
158
+ }
159
+ }
160
+
161
+ function actionToTake(
162
+ BotState memory botState,
163
+ StrategyState memory currentState
164
+ ) public pure returns (ActionType) {
165
+ if (currentState.iyFlag == StrategyFlag.TOO_LOW) {
166
+ if (currentState.syRatioFlag == StrategyFlag.TOO_HIGH) {
167
+ if (botState.syBalance == 0) return ActionType.NONE;
168
+ return ActionType.SwapSyToYt;
169
+ } else {
170
+ if (botState.lpBalance == 0) return ActionType.NONE;
171
+ return ActionType.RemoveLiqToYt;
172
+ }
173
+ } else if (currentState.iyFlag == StrategyFlag.GOOD) {
174
+ if (currentState.syRatioFlag == StrategyFlag.TOO_HIGH) {
175
+ if (botState.syBalance == 0) return ActionType.NONE;
176
+ return ActionType.AddLiqKeepYt;
177
+ } else {
178
+ return ActionType.NONE;
179
+ }
180
+ } else {
181
+ if (currentState.syRatioFlag == StrategyFlag.TOO_HIGH) {
182
+ if (botState.syBalance == 0) return ActionType.NONE;
183
+ return ActionType.AddLiqFromSy;
184
+ } else {
185
+ if (botState.ytBalance == 0) return ActionType.NONE;
186
+ return ActionType.AddLiqFromYt;
187
+ }
188
+ }
189
+ }
190
+
191
+ /// @dev Does not modify params, structs are cloned before simulation
192
+ function previewAction(
193
+ BotState memory botData,
194
+ MarketExtState memory marketExtData,
195
+ ActionType action,
196
+ uint256 botParam,
197
+ ApproxParams memory swapApproxParams
198
+ ) public pure returns (bool success, BotState memory bot, MarketExtState memory marketExt) {
199
+ bot = botData.clone();
200
+ marketExt = marketExtData.clone();
201
+
202
+ if (action == ActionType.SwapSyToYt) {
203
+ success = bot.swapSyToYt(marketExt, botParam);
204
+ } else if (action == ActionType.AddLiqKeepYt) {
205
+ success = bot.addLiqKeepYt(marketExt, botParam);
206
+ } else if (action == ActionType.AddLiqFromSy) {
207
+ success = bot.addLiqFromSy(marketExt, botParam);
208
+ } else if (action == ActionType.AddLiqFromYt) {
209
+ success = bot.addLiqFromYt(marketExt, botParam);
210
+ } else if (action == ActionType.RemoveLiqToYt) {
211
+ success = bot.removeLiqToYt(marketExt, botParam, swapApproxParams);
212
+ } else {
213
+ success = false;
214
+ }
215
+ }
216
+
217
+ function botExtStats(
218
+ BotState memory bot,
219
+ MarketExtState memory marketExt
220
+ )
221
+ public
222
+ pure
223
+ returns (uint256 tvlInSy, uint256 iy, uint256 currentSyRatio, uint256 currentYtPtRatio)
224
+ {
225
+ tvlInSy = bot.tvlInSy(marketExt);
226
+
227
+ iy = marketExt.impliedYield();
228
+
229
+ currentSyRatio = bot.syBalance.divDown(tvlInSy);
230
+
231
+ (, uint256 ptInLp) = marketExt.clone().removeLiqDual(bot.lpBalance);
232
+ currentYtPtRatio = (ptInLp == 0 ? type(uint256).max : bot.ytBalance.divDown(ptInLp));
233
+ }
234
+
235
+ /// @dev Gives a weak upper bound so that MarketExtLib's simulation doesn't revert
236
+ function _weakUpperBound(
237
+ BotState memory bot,
238
+ MarketExtState memory marketExt,
239
+ ActionType action
240
+ ) private pure returns (uint256) {
241
+ if (action == ActionType.SwapSyToYt) {
242
+ return marketExt.calcMaxPtIn();
243
+ } else if (action == ActionType.AddLiqKeepYt) {
244
+ return bot.syBalance;
245
+ } else if (action == ActionType.AddLiqFromSy) {
246
+ return marketExt.calcMaxPtOut();
247
+ } else if (action == ActionType.AddLiqFromYt) {
248
+ return marketExt.calcMaxPtOut();
249
+ } else if (action == ActionType.RemoveLiqToYt) {
250
+ return bot.lpBalance;
251
+ } else {
252
+ return 0;
253
+ }
254
+ }
255
+
256
+ function _rebalanceResult(
257
+ RebalanceDetails memory rebalance,
258
+ uint256 botParam,
259
+ ApproxParams memory intParams
260
+ ) private pure returns (RebalanceResult) {
261
+ (bool success, BotState memory bot, MarketExtState memory marketExt) = previewAction(
262
+ rebalance.bot,
263
+ rebalance.marketExt,
264
+ rebalance.action,
265
+ botParam,
266
+ intParams
267
+ );
268
+
269
+ if (!success) return RebalanceResult.FAIL;
270
+ if (_reachedTarget(bot, marketExt, rebalance.specs, rebalance.action)) {
271
+ return RebalanceResult.TARGET_REACHED;
272
+ }
273
+ return RebalanceResult.TARGET_NOT_REACHED;
274
+ }
275
+
276
+ function _reachedTarget(
277
+ BotState memory bot,
278
+ MarketExtState memory marketExt,
279
+ LongTradingSpecs memory specs,
280
+ ActionType action
281
+ ) private pure returns (bool) {
282
+ uint256 targetIy = (specs.lowerIyLimit + specs.upperIyLimit) / 2;
283
+
284
+ (, uint256 iy, uint256 currentSyRatio, uint256 currentYtPtRatio) = botExtStats(
285
+ bot,
286
+ marketExt
287
+ );
288
+
289
+ if (action == ActionType.SwapSyToYt) {
290
+ return iy >= targetIy || currentSyRatio <= specs.floatingSyRatioTarget;
291
+ } else if (action == ActionType.AddLiqKeepYt) {
292
+ return currentSyRatio <= specs.floatingSyRatioTarget;
293
+ } else if (action == ActionType.AddLiqFromSy) {
294
+ return
295
+ iy <= targetIy ||
296
+ currentSyRatio <= specs.floatingSyRatioTarget ||
297
+ currentYtPtRatio <= specs.ytPtRatioTarget;
298
+ } else if (action == ActionType.AddLiqFromYt) {
299
+ return iy <= targetIy || currentYtPtRatio <= specs.ytPtRatioTarget;
300
+ } else if (action == ActionType.RemoveLiqToYt) {
301
+ return iy >= targetIy;
302
+ } else {
303
+ return true;
304
+ }
305
+ }
306
+ }
@@ -84,7 +84,7 @@ library BotSimulationLib {
84
84
  ) internal pure returns (bool /*success*/) {
85
85
  if (netLpToRemove > bot.lpBalance) return false;
86
86
 
87
- uint256 netYtOut = marketExt.removeLiqToYt(netLpToRemove, approxParams);
87
+ (uint256 netYtOut, ) = marketExt.removeLiqToYt(netLpToRemove, approxParams);
88
88
 
89
89
  bot.lpBalance -= netLpToRemove;
90
90
  bot.ytBalance += netYtOut;
@@ -92,19 +92,20 @@ library BotSimulationLib {
92
92
  return true;
93
93
  }
94
94
 
95
- /// @dev Only for estimation, does not reflect exact SY amount that would be redeemed
96
95
  function tvlInSy(
97
96
  BotState memory bot,
98
97
  MarketExtState memory marketExt
99
98
  ) internal pure returns (uint256) {
100
- (uint256 syInLp, uint256 ptInLp) = marketExt.previewAssetsFromLp(bot.lpBalance);
99
+ MarketExtState memory marketExtClone = marketExt.clone();
100
+
101
+ (uint256 syInLp, uint256 ptInLp) = marketExtClone.removeLiqDual(bot.lpBalance);
101
102
  uint256 totalValue = bot.syBalance + syInLp;
102
103
  if (ptInLp <= bot.ytBalance) {
103
- totalValue += marketExt.previewPyToSy(ptInLp);
104
- totalValue += marketExt.clone().swapYtToSy(bot.ytBalance - ptInLp);
104
+ totalValue += marketExtClone.previewPyToSy(ptInLp);
105
+ totalValue += marketExtClone.swapYtToSy(bot.ytBalance - ptInLp);
105
106
  } else {
106
- totalValue += marketExt.previewPyToSy(bot.ytBalance);
107
- totalValue += marketExt.clone().swapPtToSy(ptInLp - bot.ytBalance);
107
+ totalValue += marketExtClone.previewPyToSy(bot.ytBalance);
108
+ totalValue += marketExtClone.swapPtToSy(ptInLp - bot.ytBalance);
108
109
  }
109
110
  return totalValue;
110
111
  }