@exponent-labs/exponent-sdk 0.9.1 → 0.9.3

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 (1117) hide show
  1. package/build/addressLookupTableUtil.d.ts +13 -13
  2. package/build/addressLookupTableUtil.js +5 -5
  3. package/build/addressLookupTableUtil.js.map +1 -1
  4. package/build/client/clmm/accounts/lpPosition.js +5 -6
  5. package/build/client/clmm/accounts/lpPosition.js.map +1 -1
  6. package/build/client/clmm/accounts/marketThree.js +5 -6
  7. package/build/client/clmm/accounts/marketThree.js.map +1 -1
  8. package/build/client/clmm/accounts/vault.js +5 -6
  9. package/build/client/clmm/accounts/vault.js.map +1 -1
  10. package/build/client/clmm/index.d.ts +1 -2
  11. package/build/client/clmm/instructions/addFarm.js +1 -2
  12. package/build/client/clmm/instructions/addFarm.js.map +1 -1
  13. package/build/client/clmm/instructions/addLiquidity.js +1 -2
  14. package/build/client/clmm/instructions/addLiquidity.js.map +1 -1
  15. package/build/client/clmm/instructions/addMarketEmission.js +1 -2
  16. package/build/client/clmm/instructions/addMarketEmission.js.map +1 -1
  17. package/build/client/clmm/instructions/buyPt.js +1 -2
  18. package/build/client/clmm/instructions/buyPt.js.map +1 -1
  19. package/build/client/clmm/instructions/buyYt.js +1 -2
  20. package/build/client/clmm/instructions/buyYt.js.map +1 -1
  21. package/build/client/clmm/instructions/claimFarmEmission.js +1 -2
  22. package/build/client/clmm/instructions/claimFarmEmission.js.map +1 -1
  23. package/build/client/clmm/instructions/closeMarket.js +1 -2
  24. package/build/client/clmm/instructions/closeMarket.js.map +1 -1
  25. package/build/client/clmm/instructions/depositLiquidity.js +1 -2
  26. package/build/client/clmm/instructions/depositLiquidity.js.map +1 -1
  27. package/build/client/clmm/instructions/initializeMarket.js +1 -2
  28. package/build/client/clmm/instructions/initializeMarket.js.map +1 -1
  29. package/build/client/clmm/instructions/marketAccrueEmission.js +1 -2
  30. package/build/client/clmm/instructions/marketAccrueEmission.js.map +1 -1
  31. package/build/client/clmm/instructions/marketCollectEmission.js +1 -2
  32. package/build/client/clmm/instructions/marketCollectEmission.js.map +1 -1
  33. package/build/client/clmm/instructions/modifyFarm.js +1 -2
  34. package/build/client/clmm/instructions/modifyFarm.js.map +1 -1
  35. package/build/client/clmm/instructions/modifyMarketSetting.js +1 -2
  36. package/build/client/clmm/instructions/modifyMarketSetting.js.map +1 -1
  37. package/build/client/clmm/instructions/sellPt.js +1 -2
  38. package/build/client/clmm/instructions/sellPt.js.map +1 -1
  39. package/build/client/clmm/instructions/sellYt.js +1 -2
  40. package/build/client/clmm/instructions/sellYt.js.map +1 -1
  41. package/build/client/clmm/instructions/tradePt.js +1 -2
  42. package/build/client/clmm/instructions/tradePt.js.map +1 -1
  43. package/build/client/clmm/instructions/tradePtExactOut.js +1 -2
  44. package/build/client/clmm/instructions/tradePtExactOut.js.map +1 -1
  45. package/build/client/clmm/instructions/withdrawLiquidity.js +1 -2
  46. package/build/client/clmm/instructions/withdrawLiquidity.js.map +1 -1
  47. package/build/client/clmm/instructions/wrapperBuyYt.js +1 -2
  48. package/build/client/clmm/instructions/wrapperBuyYt.js.map +1 -1
  49. package/build/client/clmm/instructions/wrapperProvideLiquidity.js +1 -2
  50. package/build/client/clmm/instructions/wrapperProvideLiquidity.js.map +1 -1
  51. package/build/client/clmm/instructions/wrapperProvideLiquidityBase.js +1 -2
  52. package/build/client/clmm/instructions/wrapperProvideLiquidityBase.js.map +1 -1
  53. package/build/client/clmm/instructions/wrapperProvideLiquidityClassic.js +1 -2
  54. package/build/client/clmm/instructions/wrapperProvideLiquidityClassic.js.map +1 -1
  55. package/build/client/clmm/instructions/wrapperSellYt.js +1 -2
  56. package/build/client/clmm/instructions/wrapperSellYt.js.map +1 -1
  57. package/build/client/clmm/instructions/wrapperWithdrawLiquidity.js +1 -2
  58. package/build/client/clmm/instructions/wrapperWithdrawLiquidity.js.map +1 -1
  59. package/build/client/clmm/instructions/wrapperWithdrawLiquidityClassic.js +1 -2
  60. package/build/client/clmm/instructions/wrapperWithdrawLiquidityClassic.js.map +1 -1
  61. package/build/client/clmm/types/addFarmEvent.d.ts +1 -25
  62. package/build/client/clmm/types/amount.d.ts +1 -19
  63. package/build/client/clmm/types/amount.js +3 -3
  64. package/build/client/clmm/types/amount.js.map +1 -1
  65. package/build/client/clmm/types/buyPtEvent.d.ts +1 -16
  66. package/build/client/clmm/types/buyYtEvent.d.ts +1 -40
  67. package/build/client/clmm/types/claimFarmEmissionsEvent.d.ts +1 -149
  68. package/build/client/clmm/types/claimLimits.d.ts +1 -16
  69. package/build/client/clmm/types/closeMarketEvent.d.ts +1 -16
  70. package/build/client/clmm/types/configurationOptions.d.ts +1 -25
  71. package/build/client/clmm/types/cpiAccounts.d.ts +1 -99
  72. package/build/client/clmm/types/cpiCoreAccounts.d.ts +1 -42
  73. package/build/client/clmm/types/cpiInterfaceContext.d.ts +1 -13
  74. package/build/client/clmm/types/crossingSplit.d.ts +1 -109
  75. package/build/client/clmm/types/depositLiquidityEvent.d.ts +1 -149
  76. package/build/client/clmm/types/depositLiquidityReturnData.d.ts +1 -49
  77. package/build/client/clmm/types/emissionInfo.d.ts +1 -25
  78. package/build/client/clmm/types/farmEmission.d.ts +1 -16
  79. package/build/client/clmm/types/liquidityNetBalanceLimits.d.ts +1 -19
  80. package/build/client/clmm/types/lpFarm.d.ts +1 -30
  81. package/build/client/clmm/types/marketAccrueEmissionEvent.d.ts +1 -134
  82. package/build/client/clmm/types/marketAdminAction.d.ts +1 -306
  83. package/build/client/clmm/types/marketAdminAction.js +3 -3
  84. package/build/client/clmm/types/marketAdminAction.js.map +1 -1
  85. package/build/client/clmm/types/marketCollectEmissionEvent.d.ts +1 -143
  86. package/build/client/clmm/types/marketEmission.d.ts +1 -13
  87. package/build/client/clmm/types/marketEmissions.d.ts +1 -23
  88. package/build/client/clmm/types/marketFinancials.d.ts +1 -19
  89. package/build/client/clmm/types/marketThreeInitEvent.d.ts +1 -52
  90. package/build/client/clmm/types/mergeEvent.d.ts +1 -61
  91. package/build/client/clmm/types/modifiedTick.d.ts +1 -13
  92. package/build/client/clmm/types/modifiedTicks.d.ts +1 -35
  93. package/build/client/clmm/types/modifyFarmEvent.d.ts +1 -31
  94. package/build/client/clmm/types/number.d.ts +1 -1
  95. package/build/client/clmm/types/personalYieldTracker.d.ts +1 -10
  96. package/build/client/clmm/types/personalYieldTrackers.d.ts +1 -19
  97. package/build/client/clmm/types/principalShare.d.ts +1 -42
  98. package/build/client/clmm/types/principalShareTrackers.d.ts +1 -59
  99. package/build/client/clmm/types/sellPtEvent.d.ts +1 -16
  100. package/build/client/clmm/types/sellYtEvent.d.ts +1 -34
  101. package/build/client/clmm/types/stripEvent.d.ts +1 -61
  102. package/build/client/clmm/types/swapDirection.d.ts +1 -1
  103. package/build/client/clmm/types/tradePtEvent.d.ts +1 -90
  104. package/build/client/clmm/types/withdrawLiquidityEvent.d.ts +1 -158
  105. package/build/client/clmm/types/withdrawLiquidityReturnData.d.ts +1 -34
  106. package/build/client/clmm/types/wrapperBuyYtEvent.d.ts +1 -16
  107. package/build/client/clmm/types/wrapperProvideLiquidityBaseEvent.d.ts +1 -40
  108. package/build/client/clmm/types/wrapperProvideLiquidityClassicEvent.d.ts +1 -37
  109. package/build/client/clmm/types/wrapperProvideLiquidityEvent.d.ts +1 -40
  110. package/build/client/clmm/types/wrapperSellYtEvent.d.ts +1 -16
  111. package/build/client/clmm/types/wrapperWithdrawLiquidityClassicEvent.d.ts +1 -43
  112. package/build/client/clmm/types/wrapperWithdrawLiquidityEvent.d.ts +1 -43
  113. package/build/client/core/accounts/admin.js +5 -6
  114. package/build/client/core/accounts/admin.js.map +1 -1
  115. package/build/client/core/accounts/lpPosition.js +5 -6
  116. package/build/client/core/accounts/lpPosition.js.map +1 -1
  117. package/build/client/core/accounts/marketTwo.js +5 -6
  118. package/build/client/core/accounts/marketTwo.js.map +1 -1
  119. package/build/client/core/accounts/vault.js +5 -6
  120. package/build/client/core/accounts/vault.js.map +1 -1
  121. package/build/client/core/accounts/yieldTokenPosition.js +5 -6
  122. package/build/client/core/accounts/yieldTokenPosition.js.map +1 -1
  123. package/build/client/core/index.d.ts +1 -2
  124. package/build/client/core/instructions/addEmission.js +1 -2
  125. package/build/client/core/instructions/addEmission.js.map +1 -1
  126. package/build/client/core/instructions/addFarm.js +1 -2
  127. package/build/client/core/instructions/addFarm.js.map +1 -1
  128. package/build/client/core/instructions/addLpTokensMetadata.js +1 -2
  129. package/build/client/core/instructions/addLpTokensMetadata.js.map +1 -1
  130. package/build/client/core/instructions/addMarketEmission.js +1 -2
  131. package/build/client/core/instructions/addMarketEmission.js.map +1 -1
  132. package/build/client/core/instructions/buyYt.js +1 -2
  133. package/build/client/core/instructions/buyYt.js.map +1 -1
  134. package/build/client/core/instructions/claimFarmEmissions.js +1 -2
  135. package/build/client/core/instructions/claimFarmEmissions.js.map +1 -1
  136. package/build/client/core/instructions/collectEmission.js +1 -2
  137. package/build/client/core/instructions/collectEmission.js.map +1 -1
  138. package/build/client/core/instructions/collectInterest.js +1 -2
  139. package/build/client/core/instructions/collectInterest.js.map +1 -1
  140. package/build/client/core/instructions/collectTreasuryEmission.js +1 -2
  141. package/build/client/core/instructions/collectTreasuryEmission.js.map +1 -1
  142. package/build/client/core/instructions/collectTreasuryInterest.js +1 -2
  143. package/build/client/core/instructions/collectTreasuryInterest.js.map +1 -1
  144. package/build/client/core/instructions/depositYt.js +1 -2
  145. package/build/client/core/instructions/depositYt.js.map +1 -1
  146. package/build/client/core/instructions/initLpPosition.js +1 -2
  147. package/build/client/core/instructions/initLpPosition.js.map +1 -1
  148. package/build/client/core/instructions/initMarketTwo.js +1 -2
  149. package/build/client/core/instructions/initMarketTwo.js.map +1 -1
  150. package/build/client/core/instructions/initializeVault.js +1 -2
  151. package/build/client/core/instructions/initializeVault.js.map +1 -1
  152. package/build/client/core/instructions/initializeYieldPosition.js +1 -2
  153. package/build/client/core/instructions/initializeYieldPosition.js.map +1 -1
  154. package/build/client/core/instructions/marketCollectEmission.js +1 -2
  155. package/build/client/core/instructions/marketCollectEmission.js.map +1 -1
  156. package/build/client/core/instructions/marketDepositLp.js +1 -2
  157. package/build/client/core/instructions/marketDepositLp.js.map +1 -1
  158. package/build/client/core/instructions/marketTwoDepositLiquidity.js +1 -2
  159. package/build/client/core/instructions/marketTwoDepositLiquidity.js.map +1 -1
  160. package/build/client/core/instructions/marketTwoWithdrawLiquidity.js +1 -2
  161. package/build/client/core/instructions/marketTwoWithdrawLiquidity.js.map +1 -1
  162. package/build/client/core/instructions/marketWithdrawLp.js +1 -2
  163. package/build/client/core/instructions/marketWithdrawLp.js.map +1 -1
  164. package/build/client/core/instructions/merge.js +1 -2
  165. package/build/client/core/instructions/merge.js.map +1 -1
  166. package/build/client/core/instructions/modifyFarm.js +1 -2
  167. package/build/client/core/instructions/modifyFarm.js.map +1 -1
  168. package/build/client/core/instructions/modifyMarketSetting.js +1 -2
  169. package/build/client/core/instructions/modifyMarketSetting.js.map +1 -1
  170. package/build/client/core/instructions/modifyVaultSetting.js +1 -2
  171. package/build/client/core/instructions/modifyVaultSetting.js.map +1 -1
  172. package/build/client/core/instructions/reallocMarket.js +1 -2
  173. package/build/client/core/instructions/reallocMarket.js.map +1 -1
  174. package/build/client/core/instructions/sellYt.js +1 -2
  175. package/build/client/core/instructions/sellYt.js.map +1 -1
  176. package/build/client/core/instructions/stageYtYield.js +1 -2
  177. package/build/client/core/instructions/stageYtYield.js.map +1 -1
  178. package/build/client/core/instructions/strip.js +1 -2
  179. package/build/client/core/instructions/strip.js.map +1 -1
  180. package/build/client/core/instructions/tradePt.js +1 -2
  181. package/build/client/core/instructions/tradePt.js.map +1 -1
  182. package/build/client/core/instructions/withdrawYt.js +1 -2
  183. package/build/client/core/instructions/withdrawYt.js.map +1 -1
  184. package/build/client/core/instructions/wrapperBuyPt.js +1 -2
  185. package/build/client/core/instructions/wrapperBuyPt.js.map +1 -1
  186. package/build/client/core/instructions/wrapperBuyYt.js +1 -2
  187. package/build/client/core/instructions/wrapperBuyYt.js.map +1 -1
  188. package/build/client/core/instructions/wrapperCollectInterest.js +1 -2
  189. package/build/client/core/instructions/wrapperCollectInterest.js.map +1 -1
  190. package/build/client/core/instructions/wrapperMerge.js +1 -2
  191. package/build/client/core/instructions/wrapperMerge.js.map +1 -1
  192. package/build/client/core/instructions/wrapperProvideLiquidity.js +1 -2
  193. package/build/client/core/instructions/wrapperProvideLiquidity.js.map +1 -1
  194. package/build/client/core/instructions/wrapperProvideLiquidityBase.js +1 -2
  195. package/build/client/core/instructions/wrapperProvideLiquidityBase.js.map +1 -1
  196. package/build/client/core/instructions/wrapperProvideLiquidityClassic.js +1 -2
  197. package/build/client/core/instructions/wrapperProvideLiquidityClassic.js.map +1 -1
  198. package/build/client/core/instructions/wrapperSellPt.js +1 -2
  199. package/build/client/core/instructions/wrapperSellPt.js.map +1 -1
  200. package/build/client/core/instructions/wrapperSellYt.js +1 -2
  201. package/build/client/core/instructions/wrapperSellYt.js.map +1 -1
  202. package/build/client/core/instructions/wrapperStrip.js +1 -2
  203. package/build/client/core/instructions/wrapperStrip.js.map +1 -1
  204. package/build/client/core/instructions/wrapperWithdrawLiquidity.js +1 -2
  205. package/build/client/core/instructions/wrapperWithdrawLiquidity.js.map +1 -1
  206. package/build/client/core/instructions/wrapperWithdrawLiquidityClassic.js +1 -2
  207. package/build/client/core/instructions/wrapperWithdrawLiquidityClassic.js.map +1 -1
  208. package/build/client/core/types/adminAction.d.ts +1 -269
  209. package/build/client/core/types/adminAction.js +3 -3
  210. package/build/client/core/types/adminAction.js.map +1 -1
  211. package/build/client/core/types/amount.d.ts +1 -19
  212. package/build/client/core/types/amount.js +3 -3
  213. package/build/client/core/types/amount.js.map +1 -1
  214. package/build/client/core/types/buyPtEvent.d.ts +1 -19
  215. package/build/client/core/types/buyYtEvent.d.ts +1 -49
  216. package/build/client/core/types/claimFarmEmissionsEvent.d.ts +1 -31
  217. package/build/client/core/types/claimFarmEmissionsEventV2.d.ts +1 -83
  218. package/build/client/core/types/claimLimits.d.ts +1 -16
  219. package/build/client/core/types/collectEmissionEvent.d.ts +1 -25
  220. package/build/client/core/types/collectEmissionEventV2.d.ts +1 -55
  221. package/build/client/core/types/collectInterestEvent.d.ts +1 -22
  222. package/build/client/core/types/collectInterestEventV2.d.ts +1 -52
  223. package/build/client/core/types/collectTreasuryEmissionKind.d.ts +1 -1
  224. package/build/client/core/types/collectTreasuryInterestKind.d.ts +1 -1
  225. package/build/client/core/types/cpiAccounts.d.ts +1 -99
  226. package/build/client/core/types/cpiInterfaceContext.d.ts +1 -13
  227. package/build/client/core/types/depositLiquidityEvent.d.ts +1 -49
  228. package/build/client/core/types/depositLpEvent.d.ts +1 -31
  229. package/build/client/core/types/depositLpEventV2.d.ts +1 -83
  230. package/build/client/core/types/depositYtEvent.d.ts +1 -40
  231. package/build/client/core/types/depositYtEventV2.d.ts +1 -70
  232. package/build/client/core/types/emissionInfo.d.ts +1 -25
  233. package/build/client/core/types/farmEmission.d.ts +1 -16
  234. package/build/client/core/types/initLpPositionEvent.d.ts +1 -25
  235. package/build/client/core/types/initializeYieldPositionEvent.d.ts +1 -16
  236. package/build/client/core/types/liquidityNetBalanceLimits.d.ts +1 -19
  237. package/build/client/core/types/lpFarm.d.ts +1 -30
  238. package/build/client/core/types/marketAdminAction.d.ts +1 -239
  239. package/build/client/core/types/marketAdminAction.js +3 -3
  240. package/build/client/core/types/marketAdminAction.js.map +1 -1
  241. package/build/client/core/types/marketCollectEmissionEvent.d.ts +1 -28
  242. package/build/client/core/types/marketCollectEmissionEventV2.d.ts +1 -80
  243. package/build/client/core/types/marketEmission.d.ts +1 -13
  244. package/build/client/core/types/marketEmissions.d.ts +1 -23
  245. package/build/client/core/types/marketFinancials.d.ts +1 -22
  246. package/build/client/core/types/mergeEvent.d.ts +1 -61
  247. package/build/client/core/types/number.d.ts +1 -1
  248. package/build/client/core/types/personalYieldTracker.d.ts +1 -10
  249. package/build/client/core/types/personalYieldTrackers.d.ts +1 -19
  250. package/build/client/core/types/principleDetails.d.ts +1 -7
  251. package/build/client/core/types/principles.d.ts +1 -70
  252. package/build/client/core/types/sellPtEvent.d.ts +1 -19
  253. package/build/client/core/types/sellYtEvent.d.ts +1 -43
  254. package/build/client/core/types/stageYieldEvent.d.ts +1 -31
  255. package/build/client/core/types/stageYieldEventV2.d.ts +1 -58
  256. package/build/client/core/types/stripEvent.d.ts +1 -61
  257. package/build/client/core/types/tradePtEvent.d.ts +1 -37
  258. package/build/client/core/types/withdrawLiquidityEvent.d.ts +1 -43
  259. package/build/client/core/types/withdrawLpEvent.d.ts +1 -31
  260. package/build/client/core/types/withdrawLpEventV2.d.ts +1 -83
  261. package/build/client/core/types/withdrawYtEvent.d.ts +1 -40
  262. package/build/client/core/types/withdrawYtEventV2.d.ts +1 -70
  263. package/build/client/core/types/wrapperBuyYtEvent.d.ts +1 -19
  264. package/build/client/core/types/wrapperCollectInterestEvent.d.ts +1 -16
  265. package/build/client/core/types/wrapperMergeEvent.d.ts +1 -19
  266. package/build/client/core/types/wrapperProvideLiquidityBaseEvent.d.ts +1 -25
  267. package/build/client/core/types/wrapperProvideLiquidityClassicEvent.d.ts +1 -22
  268. package/build/client/core/types/wrapperProvideLiquidityEvent.d.ts +1 -22
  269. package/build/client/core/types/wrapperSellYtEvent.d.ts +1 -19
  270. package/build/client/core/types/wrapperStripEvent.d.ts +1 -19
  271. package/build/client/core/types/wrapperWithdrawLiquidityClassicEvent.d.ts +1 -22
  272. package/build/client/core/types/wrapperWithdrawLiquidityEvent.d.ts +1 -19
  273. package/build/client/core/types/yieldTokenTracker.d.ts +1 -10
  274. package/build/client/orderbook/accounts/cpiAccountsOrderbook.js +5 -6
  275. package/build/client/orderbook/accounts/cpiAccountsOrderbook.js.map +1 -1
  276. package/build/client/orderbook/accounts/vault.js +5 -6
  277. package/build/client/orderbook/accounts/vault.js.map +1 -1
  278. package/build/client/orderbook/index.d.ts +1 -2
  279. package/build/client/orderbook/instructions/collectAdminEmission.js +1 -2
  280. package/build/client/orderbook/instructions/collectAdminEmission.js.map +1 -1
  281. package/build/client/orderbook/instructions/collectAdminFee.js +1 -2
  282. package/build/client/orderbook/instructions/collectAdminFee.js.map +1 -1
  283. package/build/client/orderbook/instructions/collectInterest.js +1 -2
  284. package/build/client/orderbook/instructions/collectInterest.js.map +1 -1
  285. package/build/client/orderbook/instructions/initializeOrderbook.js +1 -2
  286. package/build/client/orderbook/instructions/initializeOrderbook.js.map +1 -1
  287. package/build/client/orderbook/instructions/marketOffer.js +1 -2
  288. package/build/client/orderbook/instructions/marketOffer.js.map +1 -1
  289. package/build/client/orderbook/instructions/postOffer.js +1 -2
  290. package/build/client/orderbook/instructions/postOffer.js.map +1 -1
  291. package/build/client/orderbook/instructions/reallocOrderbookAccount.js +1 -2
  292. package/build/client/orderbook/instructions/reallocOrderbookAccount.js.map +1 -1
  293. package/build/client/orderbook/instructions/removeExpiredOffers.js +1 -2
  294. package/build/client/orderbook/instructions/removeExpiredOffers.js.map +1 -1
  295. package/build/client/orderbook/instructions/removeOffer.js +1 -2
  296. package/build/client/orderbook/instructions/removeOffer.js.map +1 -1
  297. package/build/client/orderbook/instructions/setConfigurationOptions.js +1 -2
  298. package/build/client/orderbook/instructions/setConfigurationOptions.js.map +1 -1
  299. package/build/client/orderbook/instructions/withdrawFunds.js +1 -2
  300. package/build/client/orderbook/instructions/withdrawFunds.js.map +1 -1
  301. package/build/client/orderbook/instructions/wrapperCollectAdminFee.js +1 -2
  302. package/build/client/orderbook/instructions/wrapperCollectAdminFee.js.map +1 -1
  303. package/build/client/orderbook/instructions/wrapperCollectInterest.js +1 -2
  304. package/build/client/orderbook/instructions/wrapperCollectInterest.js.map +1 -1
  305. package/build/client/orderbook/instructions/wrapperMarketOffer.js +1 -2
  306. package/build/client/orderbook/instructions/wrapperMarketOffer.js.map +1 -1
  307. package/build/client/orderbook/instructions/wrapperPostOffer.js +1 -2
  308. package/build/client/orderbook/instructions/wrapperPostOffer.js.map +1 -1
  309. package/build/client/orderbook/instructions/wrapperRemoveOffer.js +1 -2
  310. package/build/client/orderbook/instructions/wrapperRemoveOffer.js.map +1 -1
  311. package/build/client/orderbook/instructions/wrapperWithdrawFunds.js +1 -2
  312. package/build/client/orderbook/instructions/wrapperWithdrawFunds.js.map +1 -1
  313. package/build/client/orderbook/types/amount.d.ts +1 -19
  314. package/build/client/orderbook/types/amount.js +3 -3
  315. package/build/client/orderbook/types/amount.js.map +1 -1
  316. package/build/client/orderbook/types/claimLimits.d.ts +1 -16
  317. package/build/client/orderbook/types/collectAdminEmissionEvent.d.ts +1 -19
  318. package/build/client/orderbook/types/collectAdminFeeEvent.d.ts +1 -19
  319. package/build/client/orderbook/types/collectEmissionEventV2.d.ts +1 -55
  320. package/build/client/orderbook/types/collectInterestEventV2.d.ts +1 -52
  321. package/build/client/orderbook/types/collectUserInterestEvent.d.ts +1 -16
  322. package/build/client/orderbook/types/cpiAccounts.d.ts +1 -99
  323. package/build/client/orderbook/types/cpiInterfaceContext.d.ts +1 -13
  324. package/build/client/orderbook/types/emissionInfo.d.ts +1 -25
  325. package/build/client/orderbook/types/exponentCoreCpiAccounts.d.ts +1 -99
  326. package/build/client/orderbook/types/filledOffersEvent.d.ts +1 -22
  327. package/build/client/orderbook/types/marketOfferEvent.d.ts +1 -74
  328. package/build/client/orderbook/types/mergeEvent.d.ts +1 -61
  329. package/build/client/orderbook/types/number.d.ts +1 -1
  330. package/build/client/orderbook/types/offerOptions.d.ts +1 -13
  331. package/build/client/orderbook/types/offerOptions.js +3 -3
  332. package/build/client/orderbook/types/offerOptions.js.map +1 -1
  333. package/build/client/orderbook/types/offerType.d.ts +1 -1
  334. package/build/client/orderbook/types/orderbookInitEvent.d.ts +1 -28
  335. package/build/client/orderbook/types/postOfferEvent.d.ts +1 -96
  336. package/build/client/orderbook/types/removeOfferEvent.d.ts +1 -28
  337. package/build/client/orderbook/types/setConfigurationOptionsEnum.d.ts +1 -49
  338. package/build/client/orderbook/types/setConfigurationOptionsEnum.js +3 -3
  339. package/build/client/orderbook/types/setConfigurationOptionsEnum.js.map +1 -1
  340. package/build/client/orderbook/types/stripEvent.d.ts +1 -61
  341. package/build/client/orderbook/types/withdrawFundsEvent.d.ts +1 -28
  342. package/build/client/orderbook/types/wrapperCollectAdminFeeEvent.d.ts +1 -13
  343. package/build/client/orderbook/types/wrapperCollectInterestEvent.d.ts +1 -10
  344. package/build/client/orderbook/types/wrapperMarketOfferEvent.d.ts +1 -13
  345. package/build/client/orderbook/types/wrapperPostOfferEvent.d.ts +1 -28
  346. package/build/client/orderbook/types/wrapperRemoveOfferEvent.d.ts +1 -10
  347. package/build/client/orderbook/types/wrapperWithdrawFundsEvent.d.ts +1 -19
  348. package/build/client/orderbook/types/yieldTokenTracker.d.ts +1 -10
  349. package/build/client/vaults/accounts/actionProposal.js +5 -6
  350. package/build/client/vaults/accounts/actionProposal.js.map +1 -1
  351. package/build/client/vaults/accounts/exponentStrategyVault.js +5 -6
  352. package/build/client/vaults/accounts/exponentStrategyVault.js.map +1 -1
  353. package/build/client/vaults/accounts/programConfig.js +5 -6
  354. package/build/client/vaults/accounts/programConfig.js.map +1 -1
  355. package/build/client/vaults/accounts/voteAccount.js +5 -6
  356. package/build/client/vaults/accounts/voteAccount.js.map +1 -1
  357. package/build/client/vaults/accounts/withdrawalAccount.js +5 -6
  358. package/build/client/vaults/accounts/withdrawalAccount.js.map +1 -1
  359. package/build/client/vaults/eventRegistry.d.ts +8 -2
  360. package/build/client/vaults/eventRegistry.js +6 -0
  361. package/build/client/vaults/eventRegistry.js.map +1 -1
  362. package/build/client/vaults/index.d.ts +4 -2
  363. package/build/client/vaults/index.js +3 -0
  364. package/build/client/vaults/index.js.map +1 -1
  365. package/build/client/vaults/instructions/activateProposal.d.ts +2 -0
  366. package/build/client/vaults/instructions/activateProposal.js +3 -2
  367. package/build/client/vaults/instructions/activateProposal.js.map +1 -1
  368. package/build/client/vaults/instructions/addPolicy.js +1 -2
  369. package/build/client/vaults/instructions/addPolicy.js.map +1 -1
  370. package/build/client/vaults/instructions/appendProposalActions.js +1 -2
  371. package/build/client/vaults/instructions/appendProposalActions.js.map +1 -1
  372. package/build/client/vaults/instructions/cancelProposal.d.ts +2 -0
  373. package/build/client/vaults/instructions/cancelProposal.js +3 -2
  374. package/build/client/vaults/instructions/cancelProposal.js.map +1 -1
  375. package/build/client/vaults/instructions/cancelWithdrawal.d.ts +2 -0
  376. package/build/client/vaults/instructions/cancelWithdrawal.js +3 -2
  377. package/build/client/vaults/instructions/cancelWithdrawal.js.map +1 -1
  378. package/build/client/vaults/instructions/collectManagementFee.js +1 -2
  379. package/build/client/vaults/instructions/collectManagementFee.js.map +1 -1
  380. package/build/client/vaults/instructions/depositLiquidity.js +1 -2
  381. package/build/client/vaults/instructions/depositLiquidity.js.map +1 -1
  382. package/build/client/vaults/instructions/executeProposal.d.ts +2 -0
  383. package/build/client/vaults/instructions/executeProposal.js +3 -2
  384. package/build/client/vaults/instructions/executeProposal.js.map +1 -1
  385. package/build/client/vaults/instructions/executeWithdrawal.js +1 -2
  386. package/build/client/vaults/instructions/executeWithdrawal.js.map +1 -1
  387. package/build/client/vaults/instructions/executeWithdrawalFromReserves.d.ts +2 -0
  388. package/build/client/vaults/instructions/executeWithdrawalFromReserves.js +3 -2
  389. package/build/client/vaults/instructions/executeWithdrawalFromReserves.js.map +1 -1
  390. package/build/client/vaults/instructions/fillWithdrawal.js +1 -2
  391. package/build/client/vaults/instructions/fillWithdrawal.js.map +1 -1
  392. package/build/client/vaults/instructions/finalizeProposal.d.ts +2 -0
  393. package/build/client/vaults/instructions/finalizeProposal.js +3 -2
  394. package/build/client/vaults/instructions/finalizeProposal.js.map +1 -1
  395. package/build/client/vaults/instructions/initProposal.js +1 -2
  396. package/build/client/vaults/instructions/initProposal.js.map +1 -1
  397. package/build/client/vaults/instructions/initializePrices.js +1 -2
  398. package/build/client/vaults/instructions/initializePrices.js.map +1 -1
  399. package/build/client/vaults/instructions/initializeVault.js +1 -2
  400. package/build/client/vaults/instructions/initializeVault.js.map +1 -1
  401. package/build/client/vaults/instructions/makeSentienelManager.js +1 -2
  402. package/build/client/vaults/instructions/makeSentienelManager.js.map +1 -1
  403. package/build/client/vaults/instructions/managePrices.js +1 -2
  404. package/build/client/vaults/instructions/managePrices.js.map +1 -1
  405. package/build/client/vaults/instructions/manageVaultSettings.js +1 -2
  406. package/build/client/vaults/instructions/manageVaultSettings.js.map +1 -1
  407. package/build/client/vaults/instructions/managerUpdatePosition.js +1 -2
  408. package/build/client/vaults/instructions/managerUpdatePosition.js.map +1 -1
  409. package/build/client/vaults/instructions/queueWithdrawal.d.ts +2 -0
  410. package/build/client/vaults/instructions/queueWithdrawal.js +3 -2
  411. package/build/client/vaults/instructions/queueWithdrawal.js.map +1 -1
  412. package/build/client/vaults/instructions/removePolicy.js +1 -2
  413. package/build/client/vaults/instructions/removePolicy.js.map +1 -1
  414. package/build/client/vaults/instructions/sentinelSetVaultFlags.d.ts +2 -0
  415. package/build/client/vaults/instructions/sentinelSetVaultFlags.js +3 -2
  416. package/build/client/vaults/instructions/sentinelSetVaultFlags.js.map +1 -1
  417. package/build/client/vaults/instructions/stakeVote.d.ts +2 -0
  418. package/build/client/vaults/instructions/stakeVote.js +3 -2
  419. package/build/client/vaults/instructions/stakeVote.js.map +1 -1
  420. package/build/client/vaults/instructions/unstakeVote.js +1 -2
  421. package/build/client/vaults/instructions/unstakeVote.js.map +1 -1
  422. package/build/client/vaults/instructions/updatePolicy.js +1 -2
  423. package/build/client/vaults/instructions/updatePolicy.js.map +1 -1
  424. package/build/client/vaults/instructions/updatePolicyManager.js +1 -2
  425. package/build/client/vaults/instructions/updatePolicyManager.js.map +1 -1
  426. package/build/client/vaults/instructions/updatePrice.js +1 -2
  427. package/build/client/vaults/instructions/updatePrice.js.map +1 -1
  428. package/build/client/vaults/instructions/validateInteractionHook.js +1 -2
  429. package/build/client/vaults/instructions/validateInteractionHook.js.map +1 -1
  430. package/build/client/vaults/instructions/wrapperAddPolicy.js +1 -2
  431. package/build/client/vaults/instructions/wrapperAddPolicy.js.map +1 -1
  432. package/build/client/vaults/instructions/wrapperExecuteWithdrawal.js +1 -2
  433. package/build/client/vaults/instructions/wrapperExecuteWithdrawal.js.map +1 -1
  434. package/build/client/vaults/instructions/wrapperManageVaultSettings.js +1 -2
  435. package/build/client/vaults/instructions/wrapperManageVaultSettings.js.map +1 -1
  436. package/build/client/vaults/instructions/wrapperManagerUpdatePosition.js +1 -2
  437. package/build/client/vaults/instructions/wrapperManagerUpdatePosition.js.map +1 -1
  438. package/build/client/vaults/instructions/wrapperRemovePolicy.js +1 -2
  439. package/build/client/vaults/instructions/wrapperRemovePolicy.js.map +1 -1
  440. package/build/client/vaults/instructions/wrapperUpdatePolicy.js +1 -2
  441. package/build/client/vaults/instructions/wrapperUpdatePolicy.js.map +1 -1
  442. package/build/client/vaults/types/accountConstraint.d.ts +1 -13
  443. package/build/client/vaults/types/accountConstraintType.d.ts +1 -1
  444. package/build/client/vaults/types/accountConstraintType.js +3 -3
  445. package/build/client/vaults/types/accountConstraintType.js.map +1 -1
  446. package/build/client/vaults/types/allowedSettingsChange.d.ts +1 -54
  447. package/build/client/vaults/types/allowedSettingsChange.js +3 -3
  448. package/build/client/vaults/types/allowedSettingsChange.js.map +1 -1
  449. package/build/client/vaults/types/cancelProposalEvent.d.ts +1 -19
  450. package/build/client/vaults/types/cancelWithdrawalEvent.d.ts +12 -0
  451. package/build/client/vaults/types/cancelWithdrawalEvent.js +29 -0
  452. package/build/client/vaults/types/cancelWithdrawalEvent.js.map +1 -0
  453. package/build/client/vaults/types/clmmPositionEntry.d.ts +1 -80
  454. package/build/client/vaults/types/dataConstraint.d.ts +1 -109
  455. package/build/client/vaults/types/dataOperator.d.ts +1 -1
  456. package/build/client/vaults/types/dataValue.d.ts +1 -73
  457. package/build/client/vaults/types/dataValue.js +3 -3
  458. package/build/client/vaults/types/dataValue.js.map +1 -1
  459. package/build/client/vaults/types/depositLiquidityEvent.d.ts +1 -40
  460. package/build/client/vaults/types/executeProposalEvent.d.ts +1 -19
  461. package/build/client/vaults/types/executeWithdrawalEvent.d.ts +8 -10
  462. package/build/client/vaults/types/executeWithdrawalEvent.js +19 -0
  463. package/build/client/vaults/types/executeWithdrawalEvent.js.map +1 -1
  464. package/build/client/vaults/types/executeWithdrawalFromReservesEvent.d.ts +19 -0
  465. package/build/client/vaults/types/executeWithdrawalFromReservesEvent.js +48 -0
  466. package/build/client/vaults/types/executeWithdrawalFromReservesEvent.js.map +1 -0
  467. package/build/client/vaults/types/fillParam.d.ts +1 -10
  468. package/build/client/vaults/types/finalizeProposalEvent.d.ts +1 -34
  469. package/build/client/vaults/types/hook.d.ts +1 -35
  470. package/build/client/vaults/types/hookCompiledInstruction.d.ts +1 -13
  471. package/build/client/vaults/types/index.d.ts +3 -0
  472. package/build/client/vaults/types/index.js +3 -0
  473. package/build/client/vaults/types/index.js.map +1 -1
  474. package/build/client/vaults/types/instructionConstraint.d.ts +1 -165
  475. package/build/client/vaults/types/internalFundTransferPolicyCreationPayload.d.ts +1 -13
  476. package/build/client/vaults/types/kaminoFarmEntry.d.ts +1 -10
  477. package/build/client/vaults/types/kaminoObligationEntry.d.ts +1 -122
  478. package/build/client/vaults/types/limitedQuantityConstraints.d.ts +1 -7
  479. package/build/client/vaults/types/limitedSpendingLimit.d.ts +1 -97
  480. package/build/client/vaults/types/limitedTimeConstraints.d.ts +1 -61
  481. package/build/client/vaults/types/loopscaleLoanEntry.d.ts +1 -7
  482. package/build/client/vaults/types/loopscaleStrategyEntry.d.ts +1 -7
  483. package/build/client/vaults/types/number.d.ts +1 -1
  484. package/build/client/vaults/types/obligationType.js +3 -3
  485. package/build/client/vaults/types/obligationType.js.map +1 -1
  486. package/build/client/vaults/types/orderbookEntry.d.ts +1 -54
  487. package/build/client/vaults/types/periodV2.d.ts +1 -37
  488. package/build/client/vaults/types/periodV2.js +3 -3
  489. package/build/client/vaults/types/periodV2.js.map +1 -1
  490. package/build/client/vaults/types/permissions.d.ts +1 -7
  491. package/build/client/vaults/types/policyAction.d.ts +1 -40
  492. package/build/client/vaults/types/policyAction.js +3 -3
  493. package/build/client/vaults/types/policyAction.js.map +1 -1
  494. package/build/client/vaults/types/policyCreationPayload.d.ts +1 -260
  495. package/build/client/vaults/types/policyCreationPayload.js +3 -3
  496. package/build/client/vaults/types/policyCreationPayload.js.map +1 -1
  497. package/build/client/vaults/types/policyExpirationArgs.d.ts +1 -19
  498. package/build/client/vaults/types/policyExpirationArgs.js +3 -3
  499. package/build/client/vaults/types/policyExpirationArgs.js.map +1 -1
  500. package/build/client/vaults/types/positionUpdate.js +3 -3
  501. package/build/client/vaults/types/positionUpdate.js.map +1 -1
  502. package/build/client/vaults/types/priceId.d.ts +1 -25
  503. package/build/client/vaults/types/priceId.js +3 -3
  504. package/build/client/vaults/types/priceId.js.map +1 -1
  505. package/build/client/vaults/types/priceType.d.ts +1 -1
  506. package/build/client/vaults/types/proposalAction.d.ts +2 -204
  507. package/build/client/vaults/types/proposalAction.js +6 -3
  508. package/build/client/vaults/types/proposalAction.js.map +1 -1
  509. package/build/client/vaults/types/proposalActionKind.d.ts +1 -1
  510. package/build/client/vaults/types/proposalStatus.d.ts +1 -1
  511. package/build/client/vaults/types/proposalVoteConfig.d.ts +1 -34
  512. package/build/client/vaults/types/proposeActionEvent.d.ts +1 -34
  513. package/build/client/vaults/types/quantityConstraints.d.ts +1 -13
  514. package/build/client/vaults/types/queueWithdrawalEvent.d.ts +11 -0
  515. package/build/client/vaults/types/queueWithdrawalEvent.js +31 -0
  516. package/build/client/vaults/types/queueWithdrawalEvent.js.map +1 -0
  517. package/build/client/vaults/types/reserveFarmMapping.d.ts +1 -13
  518. package/build/client/vaults/types/reservePriceMapping.d.ts +1 -42
  519. package/build/client/vaults/types/settingsChangePolicyCreationPayload.d.ts +1 -77
  520. package/build/client/vaults/types/spendingLimitPolicyCreationPayload.d.ts +1 -130
  521. package/build/client/vaults/types/stakeVoteEvent.d.ts +1 -28
  522. package/build/client/vaults/types/strategyPosition.js +3 -3
  523. package/build/client/vaults/types/strategyPosition.js.map +1 -1
  524. package/build/client/vaults/types/timeConstraints.d.ts +1 -64
  525. package/build/client/vaults/types/tokenAccountBalance.d.ts +1 -45
  526. package/build/client/vaults/types/tokenAccountEntry.d.ts +1 -66
  527. package/build/client/vaults/types/tokenEntry.d.ts +1 -51
  528. package/build/client/vaults/types/unstakeVoteEvent.d.ts +1 -25
  529. package/build/client/vaults/types/updatePriceAction.d.ts +1 -124
  530. package/build/client/vaults/types/updatePriceAction.js +3 -3
  531. package/build/client/vaults/types/updatePriceAction.js.map +1 -1
  532. package/build/client/vaults/types/updatePriceInput.d.ts +1 -10
  533. package/build/client/vaults/types/usageState.d.ts +1 -10
  534. package/build/client/vaults/types/vaultConfig.d.ts +1 -74
  535. package/build/client/vaults/types/vaultFinancials.d.ts +1 -43
  536. package/build/client/vaults/types/vaultFlagAction.d.ts +1 -37
  537. package/build/client/vaults/types/vaultFlagAction.js +3 -3
  538. package/build/client/vaults/types/vaultFlagAction.js.map +1 -1
  539. package/build/client/vaults/types/vaultFlagsUpdatedEvent.d.ts +1 -16
  540. package/build/client/vaults/types/vaultRoleKind.d.ts +1 -1
  541. package/build/client/vaults/types/vaultRoles.d.ts +1 -16
  542. package/build/client/vaults/types/vaultSettingsAction.js +3 -3
  543. package/build/client/vaults/types/vaultSettingsAction.js.map +1 -1
  544. package/build/client/vaults/types/voteChoice.d.ts +1 -1
  545. package/build/client/vaults/types/withdrawalPeriodSettings.d.ts +1 -31
  546. package/build/client/vaults/types/withdrawalPeriodSettings.js +3 -3
  547. package/build/client/vaults/types/withdrawalPeriodSettings.js.map +1 -1
  548. package/build/client/vaults/types/withdrawalTokenFill.d.ts +1 -13
  549. package/build/client/vaults/types/yieldPositionEntry.d.ts +1 -45
  550. package/build/clmm/codamaEvents.d.ts +1 -2
  551. package/build/codamaEvents.d.ts +1 -2
  552. package/build/exponentVaults/aumCalculator.d.ts +0 -2
  553. package/build/exponentVaults/aumCalculator.js +20 -10
  554. package/build/exponentVaults/aumCalculator.js.map +1 -1
  555. package/build/exponentVaults/events.d.ts +1 -2
  556. package/build/exponentVaults/fetcher.js +4 -4
  557. package/build/exponentVaults/fetcher.js.map +1 -1
  558. package/build/exponentVaults/index.d.ts +1 -1
  559. package/build/exponentVaults/index.js +20 -9
  560. package/build/exponentVaults/index.js.map +1 -1
  561. package/build/exponentVaults/kamino-farms.d.ts +0 -2
  562. package/build/exponentVaults/kamino-farms.js +14 -14
  563. package/build/exponentVaults/kamino-farms.js.map +1 -1
  564. package/build/exponentVaults/kamino-markets.d.ts +394 -394
  565. package/build/exponentVaults/kamino-markets.js +2 -2
  566. package/build/exponentVaults/kamino-markets.js.map +1 -1
  567. package/build/exponentVaults/loopscale/helpers.js +6 -7
  568. package/build/exponentVaults/loopscale/helpers.js.map +1 -1
  569. package/build/exponentVaults/loopscale/prepared-transactions.js +1 -2
  570. package/build/exponentVaults/loopscale/prepared-transactions.js.map +1 -1
  571. package/build/exponentVaults/policyBuilders.d.ts +73 -75
  572. package/build/exponentVaults/policyBuilders.js +26 -27
  573. package/build/exponentVaults/policyBuilders.js.map +1 -1
  574. package/build/exponentVaults/policyMatcher.js +6 -7
  575. package/build/exponentVaults/policyMatcher.js.map +1 -1
  576. package/build/exponentVaults/pricePathResolver.js +7 -8
  577. package/build/exponentVaults/pricePathResolver.js.map +1 -1
  578. package/build/exponentVaults/scope-refresh.js +1 -2
  579. package/build/exponentVaults/scope-refresh.js.map +1 -1
  580. package/build/exponentVaults/squadsVaultTxnResolver/helpers.js +6 -7
  581. package/build/exponentVaults/squadsVaultTxnResolver/helpers.js.map +1 -1
  582. package/build/exponentVaults/squadsVaultTxnResolver/resolvers/exponent.js +5 -6
  583. package/build/exponentVaults/squadsVaultTxnResolver/resolvers/exponent.js.map +1 -1
  584. package/build/exponentVaults/squadsVaultTxnResolver/resolvers/helpers.js +1 -2
  585. package/build/exponentVaults/squadsVaultTxnResolver/resolvers/helpers.js.map +1 -1
  586. package/build/exponentVaults/squadsVaultTxnResolver/resolvers/kamino.js +1 -2
  587. package/build/exponentVaults/squadsVaultTxnResolver/resolvers/kamino.js.map +1 -1
  588. package/build/exponentVaults/squadsVaultTxnResolver/resolvers/loopscale.js +1 -2
  589. package/build/exponentVaults/squadsVaultTxnResolver/resolvers/loopscale.js.map +1 -1
  590. package/build/exponentVaults/squadsVaultTxnResolver/resolvers/titan.js +1 -2
  591. package/build/exponentVaults/squadsVaultTxnResolver/resolvers/titan.js.map +1 -1
  592. package/build/exponentVaults/squadsVaultTxnResolver/utils.d.ts +1 -3
  593. package/build/exponentVaults/squadsVaultTxnResolver/utils.js +1 -2
  594. package/build/exponentVaults/squadsVaultTxnResolver/utils.js.map +1 -1
  595. package/build/exponentVaults/syncTransaction.d.ts +1 -1
  596. package/build/exponentVaults/syncTransaction.js +4 -4
  597. package/build/exponentVaults/syncTransaction.js.map +1 -1
  598. package/build/exponentVaults/titan-quote.js +1 -2
  599. package/build/exponentVaults/titan-quote.js.map +1 -1
  600. package/build/exponentVaults/vault-instruction-types.d.ts +1 -1
  601. package/build/exponentVaults/vault-interaction.d.ts +58 -2576
  602. package/build/exponentVaults/vault-interaction.js +325 -75
  603. package/build/exponentVaults/vault-interaction.js.map +1 -1
  604. package/build/exponentVaults/vault.d.ts +9 -25
  605. package/build/exponentVaults/vault.js +28 -12
  606. package/build/exponentVaults/vault.js.map +1 -1
  607. package/build/exponentVaults/vaultTransactionBuilder.js +35 -30
  608. package/build/exponentVaults/vaultTransactionBuilder.js.map +1 -1
  609. package/build/flavors.js +19 -20
  610. package/build/flavors.js.map +1 -1
  611. package/build/index.js +17 -7
  612. package/build/index.js.map +1 -1
  613. package/build/market.d.ts +31 -31
  614. package/build/market.js +17 -7
  615. package/build/market.js.map +1 -1
  616. package/build/marketThree.d.ts +42 -48
  617. package/build/marketThree.js +20 -8
  618. package/build/marketThree.js.map +1 -1
  619. package/build/orderbook/codamaEvents.d.ts +1 -2
  620. package/build/orderbook/index.js +17 -7
  621. package/build/orderbook/index.js.map +1 -1
  622. package/build/orderbook/math.d.ts +4 -4
  623. package/build/orderbook/math.js +13 -13
  624. package/build/orderbook/math.js.map +1 -1
  625. package/build/orderbook/orderbook.d.ts +19 -21
  626. package/build/orderbook/orderbook.js +17 -7
  627. package/build/orderbook/orderbook.js.map +1 -1
  628. package/build/orderbook/types.js +17 -7
  629. package/build/orderbook/types.js.map +1 -1
  630. package/build/orderbook/utils.js +6 -7
  631. package/build/orderbook/utils.js.map +1 -1
  632. package/build/syPosition.js +3 -4
  633. package/build/syPosition.js.map +1 -1
  634. package/build/tokenUtil.js +2 -3
  635. package/build/tokenUtil.js.map +1 -1
  636. package/build/utils/altUtil.js +2 -3
  637. package/build/utils/altUtil.js.map +1 -1
  638. package/build/utils/binSolver.js +1 -2
  639. package/build/utils/binSolver.js.map +1 -1
  640. package/build/utils/index.d.ts +2 -2
  641. package/build/utils/index.js +3 -4
  642. package/build/utils/index.js.map +1 -1
  643. package/build/vault.d.ts +11 -12
  644. package/build/vault.js +20 -10
  645. package/build/vault.js.map +1 -1
  646. package/build/ytPosition.d.ts +7 -7
  647. package/build/ytPosition.js +17 -7
  648. package/build/ytPosition.js.map +1 -1
  649. package/package.json +36 -32
  650. package/build/client/vaults/instructions/proposeAction.d.ts +0 -16
  651. package/build/client/vaults/instructions/proposeAction.js +0 -29
  652. package/build/client/vaults/instructions/proposeAction.js.map +0 -1
  653. package/build/exponentVaults/loopscale/client.test.d.ts +0 -1
  654. package/build/exponentVaults/loopscale/client.test.js +0 -183
  655. package/build/exponentVaults/loopscale/client.test.js.map +0 -1
  656. package/build/exponentVaults/loopscale/prepared-transactions.test.d.ts +0 -1
  657. package/build/exponentVaults/loopscale/prepared-transactions.test.js +0 -400
  658. package/build/exponentVaults/loopscale/prepared-transactions.test.js.map +0 -1
  659. package/build/exponentVaults/loopscale/response-plan.d.ts +0 -69
  660. package/build/exponentVaults/loopscale/response-plan.js +0 -141
  661. package/build/exponentVaults/loopscale/response-plan.js.map +0 -1
  662. package/build/exponentVaults/loopscale/response-plan.test.d.ts +0 -1
  663. package/build/exponentVaults/loopscale/response-plan.test.js +0 -139
  664. package/build/exponentVaults/loopscale/response-plan.test.js.map +0 -1
  665. package/build/exponentVaults/loopscale/send-plan.d.ts +0 -75
  666. package/build/exponentVaults/loopscale/send-plan.js +0 -235
  667. package/build/exponentVaults/loopscale/send-plan.js.map +0 -1
  668. package/build/exponentVaults/loopscale-client.d.ts +0 -130
  669. package/build/exponentVaults/loopscale-client.js +0 -489
  670. package/build/exponentVaults/loopscale-client.js.map +0 -1
  671. package/build/exponentVaults/loopscale-client.test.d.ts +0 -1
  672. package/build/exponentVaults/loopscale-client.test.js +0 -162
  673. package/build/exponentVaults/loopscale-client.test.js.map +0 -1
  674. package/build/exponentVaults/loopscale-client.types.d.ts +0 -425
  675. package/build/exponentVaults/loopscale-client.types.js +0 -3
  676. package/build/exponentVaults/loopscale-client.types.js.map +0 -1
  677. package/build/exponentVaults/loopscale-execution.d.ts +0 -125
  678. package/build/exponentVaults/loopscale-execution.js +0 -341
  679. package/build/exponentVaults/loopscale-execution.js.map +0 -1
  680. package/build/exponentVaults/loopscale-execution.test.d.ts +0 -1
  681. package/build/exponentVaults/loopscale-execution.test.js +0 -139
  682. package/build/exponentVaults/loopscale-execution.test.js.map +0 -1
  683. package/build/exponentVaults/loopscale-vault.d.ts +0 -115
  684. package/build/exponentVaults/loopscale-vault.js +0 -275
  685. package/build/exponentVaults/loopscale-vault.js.map +0 -1
  686. package/build/exponentVaults/loopscale-vault.test.d.ts +0 -1
  687. package/build/exponentVaults/loopscale-vault.test.js +0 -102
  688. package/build/exponentVaults/loopscale-vault.test.js.map +0 -1
  689. package/build/exponentVaults/pricePathResolver.test.d.ts +0 -1
  690. package/build/exponentVaults/pricePathResolver.test.js +0 -369
  691. package/build/exponentVaults/pricePathResolver.test.js.map +0 -1
  692. package/build/exponentVaults/vaultTransactionBuilder.test.d.ts +0 -1
  693. package/build/exponentVaults/vaultTransactionBuilder.test.js +0 -214
  694. package/build/exponentVaults/vaultTransactionBuilder.test.js.map +0 -1
  695. package/build/marketThree.test.d.ts +0 -1
  696. package/build/marketThree.test.js +0 -166
  697. package/build/marketThree.test.js.map +0 -1
  698. package/build/utils/binSolver.test.d.ts +0 -1
  699. package/build/utils/binSolver.test.js +0 -16
  700. package/build/utils/binSolver.test.js.map +0 -1
  701. package/jest.config.js +0 -5
  702. package/src/CodamaEventDecoder.ts +0 -151
  703. package/src/addressLookupTableUtil.ts +0 -110
  704. package/src/client/clmm/accounts/lpPosition.ts +0 -143
  705. package/src/client/clmm/accounts/marketThree.ts +0 -274
  706. package/src/client/clmm/accounts/vault.ts +0 -234
  707. package/src/client/clmm/eventRegistry.ts +0 -92
  708. package/src/client/clmm/index.ts +0 -82
  709. package/src/client/clmm/instructions/addFarm.ts +0 -57
  710. package/src/client/clmm/instructions/addLiquidity.ts +0 -78
  711. package/src/client/clmm/instructions/addMarketEmission.ts +0 -50
  712. package/src/client/clmm/instructions/buyPt.ts +0 -73
  713. package/src/client/clmm/instructions/buyYt.ts +0 -80
  714. package/src/client/clmm/instructions/claimFarmEmission.ts +0 -56
  715. package/src/client/clmm/instructions/closeMarket.ts +0 -47
  716. package/src/client/clmm/instructions/depositLiquidity.ts +0 -71
  717. package/src/client/clmm/instructions/initializeMarket.ts +0 -127
  718. package/src/client/clmm/instructions/marketAccrueEmission.ts +0 -39
  719. package/src/client/clmm/instructions/marketCollectEmission.ts +0 -57
  720. package/src/client/clmm/instructions/modifyFarm.ts +0 -55
  721. package/src/client/clmm/instructions/modifyMarketSetting.ts +0 -45
  722. package/src/client/clmm/instructions/sellPt.ts +0 -73
  723. package/src/client/clmm/instructions/sellYt.ts +0 -80
  724. package/src/client/clmm/instructions/tradePt.ts +0 -73
  725. package/src/client/clmm/instructions/tradePtExactOut.ts +0 -75
  726. package/src/client/clmm/instructions/withdrawLiquidity.ts +0 -67
  727. package/src/client/clmm/instructions/wrapperBuyYt.ts +0 -85
  728. package/src/client/clmm/instructions/wrapperProvideLiquidity.ts +0 -100
  729. package/src/client/clmm/instructions/wrapperProvideLiquidityBase.ts +0 -98
  730. package/src/client/clmm/instructions/wrapperProvideLiquidityClassic.ts +0 -86
  731. package/src/client/clmm/instructions/wrapperSellYt.ts +0 -83
  732. package/src/client/clmm/instructions/wrapperWithdrawLiquidity.ts +0 -75
  733. package/src/client/clmm/instructions/wrapperWithdrawLiquidityClassic.ts +0 -69
  734. package/src/client/clmm/types/addFarmEvent.ts +0 -51
  735. package/src/client/clmm/types/amount.ts +0 -51
  736. package/src/client/clmm/types/buyPtEvent.ts +0 -36
  737. package/src/client/clmm/types/buyYtEvent.ts +0 -74
  738. package/src/client/clmm/types/claimFarmEmissionsEvent.ts +0 -94
  739. package/src/client/clmm/types/claimLimits.ts +0 -15
  740. package/src/client/clmm/types/closeMarketEvent.ts +0 -36
  741. package/src/client/clmm/types/configurationOptions.ts +0 -29
  742. package/src/client/clmm/types/cpiAccounts.ts +0 -21
  743. package/src/client/clmm/types/cpiCoreAccounts.ts +0 -15
  744. package/src/client/clmm/types/cpiInterfaceContext.ts +0 -13
  745. package/src/client/clmm/types/crossingSplit.ts +0 -40
  746. package/src/client/clmm/types/depositLiquidityEvent.ts +0 -93
  747. package/src/client/clmm/types/depositLiquidityReturnData.ts +0 -81
  748. package/src/client/clmm/types/emissionInfo.ts +0 -44
  749. package/src/client/clmm/types/farmEmission.ts +0 -31
  750. package/src/client/clmm/types/index.ts +0 -48
  751. package/src/client/clmm/types/liquidityNetBalanceLimits.ts +0 -22
  752. package/src/client/clmm/types/lpFarm.ts +0 -12
  753. package/src/client/clmm/types/marketAccrueEmissionEvent.ts +0 -69
  754. package/src/client/clmm/types/marketAdminAction.ts +0 -239
  755. package/src/client/clmm/types/marketCollectEmissionEvent.ts +0 -83
  756. package/src/client/clmm/types/marketEmission.ts +0 -28
  757. package/src/client/clmm/types/marketEmissions.ts +0 -10
  758. package/src/client/clmm/types/marketFinancials.ts +0 -17
  759. package/src/client/clmm/types/marketThreeInitEvent.ts +0 -92
  760. package/src/client/clmm/types/mergeEvent.ts +0 -118
  761. package/src/client/clmm/types/modifiedTick.ts +0 -13
  762. package/src/client/clmm/types/modifiedTicks.ts +0 -18
  763. package/src/client/clmm/types/modifyFarmEvent.ts +0 -56
  764. package/src/client/clmm/types/number.ts +0 -7
  765. package/src/client/clmm/types/personalYieldTracker.ts +0 -12
  766. package/src/client/clmm/types/personalYieldTrackers.ts +0 -13
  767. package/src/client/clmm/types/principalShare.ts +0 -22
  768. package/src/client/clmm/types/principalShareTrackers.ts +0 -10
  769. package/src/client/clmm/types/sellPtEvent.ts +0 -36
  770. package/src/client/clmm/types/sellYtEvent.ts +0 -69
  771. package/src/client/clmm/types/stripEvent.ts +0 -124
  772. package/src/client/clmm/types/swapDirection.ts +0 -8
  773. package/src/client/clmm/types/tradePtEvent.ts +0 -76
  774. package/src/client/clmm/types/withdrawLiquidityEvent.ts +0 -99
  775. package/src/client/clmm/types/withdrawLiquidityReturnData.ts +0 -27
  776. package/src/client/clmm/types/wrapperBuyYtEvent.ts +0 -36
  777. package/src/client/clmm/types/wrapperProvideLiquidityBaseEvent.ts +0 -60
  778. package/src/client/clmm/types/wrapperProvideLiquidityClassicEvent.ts +0 -58
  779. package/src/client/clmm/types/wrapperProvideLiquidityEvent.ts +0 -60
  780. package/src/client/clmm/types/wrapperSellYtEvent.ts +0 -36
  781. package/src/client/clmm/types/wrapperWithdrawLiquidityClassicEvent.ts +0 -62
  782. package/src/client/clmm/types/wrapperWithdrawLiquidityEvent.ts +0 -62
  783. package/src/client/core/accounts/admin.ts +0 -112
  784. package/src/client/core/accounts/lpPosition.ts +0 -122
  785. package/src/client/core/accounts/marketTwo.ts +0 -234
  786. package/src/client/core/accounts/vault.ts +0 -234
  787. package/src/client/core/accounts/yieldTokenPosition.ts +0 -126
  788. package/src/client/core/eventRegistry.ts +0 -134
  789. package/src/client/core/index.ts +0 -113
  790. package/src/client/core/instructions/addEmission.ts +0 -62
  791. package/src/client/core/instructions/addFarm.ts +0 -53
  792. package/src/client/core/instructions/addLpTokensMetadata.ts +0 -62
  793. package/src/client/core/instructions/addMarketEmission.ts +0 -52
  794. package/src/client/core/instructions/buyYt.ts +0 -79
  795. package/src/client/core/instructions/claimFarmEmissions.ts +0 -54
  796. package/src/client/core/instructions/collectEmission.ts +0 -66
  797. package/src/client/core/instructions/collectInterest.ts +0 -64
  798. package/src/client/core/instructions/collectTreasuryEmission.ts +0 -64
  799. package/src/client/core/instructions/collectTreasuryInterest.ts +0 -62
  800. package/src/client/core/instructions/depositYt.ts +0 -59
  801. package/src/client/core/instructions/initLpPosition.ts +0 -35
  802. package/src/client/core/instructions/initMarketTwo.ts +0 -103
  803. package/src/client/core/instructions/initializeVault.ts +0 -107
  804. package/src/client/core/instructions/initializeYieldPosition.ts +0 -33
  805. package/src/client/core/instructions/marketCollectEmission.ts +0 -55
  806. package/src/client/core/instructions/marketDepositLp.ts +0 -59
  807. package/src/client/core/instructions/marketTwoDepositLiquidity.ts +0 -65
  808. package/src/client/core/instructions/marketTwoWithdrawLiquidity.ts +0 -65
  809. package/src/client/core/instructions/marketWithdrawLp.ts +0 -59
  810. package/src/client/core/instructions/merge.ts +0 -61
  811. package/src/client/core/instructions/modifyFarm.ts +0 -51
  812. package/src/client/core/instructions/modifyMarketSetting.ts +0 -47
  813. package/src/client/core/instructions/modifyVaultSetting.ts +0 -44
  814. package/src/client/core/instructions/reallocMarket.ts +0 -45
  815. package/src/client/core/instructions/sellYt.ts +0 -79
  816. package/src/client/core/instructions/stageYtYield.ts +0 -39
  817. package/src/client/core/instructions/strip.ts +0 -61
  818. package/src/client/core/instructions/tradePt.ts +0 -59
  819. package/src/client/core/instructions/withdrawYt.ts +0 -61
  820. package/src/client/core/instructions/wrapperBuyPt.ts +0 -63
  821. package/src/client/core/instructions/wrapperBuyYt.ts +0 -93
  822. package/src/client/core/instructions/wrapperCollectInterest.ts +0 -63
  823. package/src/client/core/instructions/wrapperMerge.ts +0 -77
  824. package/src/client/core/instructions/wrapperProvideLiquidity.ts +0 -103
  825. package/src/client/core/instructions/wrapperProvideLiquidityBase.ts +0 -81
  826. package/src/client/core/instructions/wrapperProvideLiquidityClassic.ts +0 -77
  827. package/src/client/core/instructions/wrapperSellPt.ts +0 -63
  828. package/src/client/core/instructions/wrapperSellYt.ts +0 -87
  829. package/src/client/core/instructions/wrapperStrip.ts +0 -81
  830. package/src/client/core/instructions/wrapperWithdrawLiquidity.ts +0 -77
  831. package/src/client/core/instructions/wrapperWithdrawLiquidityClassic.ts +0 -73
  832. package/src/client/core/types/adminAction.ts +0 -255
  833. package/src/client/core/types/amount.ts +0 -51
  834. package/src/client/core/types/buyPtEvent.ts +0 -39
  835. package/src/client/core/types/buyYtEvent.ts +0 -95
  836. package/src/client/core/types/claimFarmEmissionsEvent.ts +0 -75
  837. package/src/client/core/types/claimFarmEmissionsEventV2.ts +0 -83
  838. package/src/client/core/types/claimLimits.ts +0 -15
  839. package/src/client/core/types/collectEmissionEvent.ts +0 -51
  840. package/src/client/core/types/collectEmissionEventV2.ts +0 -60
  841. package/src/client/core/types/collectInterestEvent.ts +0 -48
  842. package/src/client/core/types/collectInterestEventV2.ts +0 -57
  843. package/src/client/core/types/collectTreasuryEmissionKind.ts +0 -8
  844. package/src/client/core/types/collectTreasuryInterestKind.ts +0 -8
  845. package/src/client/core/types/cpiAccounts.ts +0 -21
  846. package/src/client/core/types/cpiInterfaceContext.ts +0 -13
  847. package/src/client/core/types/depositLiquidityEvent.ts +0 -101
  848. package/src/client/core/types/depositLpEvent.ts +0 -75
  849. package/src/client/core/types/depositLpEventV2.ts +0 -83
  850. package/src/client/core/types/depositYtEvent.ts +0 -82
  851. package/src/client/core/types/depositYtEventV2.ts +0 -91
  852. package/src/client/core/types/emissionInfo.ts +0 -44
  853. package/src/client/core/types/farmEmission.ts +0 -31
  854. package/src/client/core/types/index.ts +0 -60
  855. package/src/client/core/types/initLpPositionEvent.ts +0 -57
  856. package/src/client/core/types/initializeYieldPositionEvent.ts +0 -43
  857. package/src/client/core/types/liquidityNetBalanceLimits.ts +0 -22
  858. package/src/client/core/types/lpFarm.ts +0 -12
  859. package/src/client/core/types/marketAdminAction.ts +0 -212
  860. package/src/client/core/types/marketCollectEmissionEvent.ts +0 -67
  861. package/src/client/core/types/marketCollectEmissionEventV2.ts +0 -75
  862. package/src/client/core/types/marketEmission.ts +0 -28
  863. package/src/client/core/types/marketEmissions.ts +0 -10
  864. package/src/client/core/types/marketFinancials.ts +0 -19
  865. package/src/client/core/types/mergeEvent.ts +0 -118
  866. package/src/client/core/types/number.ts +0 -7
  867. package/src/client/core/types/personalYieldTracker.ts +0 -12
  868. package/src/client/core/types/personalYieldTrackers.ts +0 -13
  869. package/src/client/core/types/principleDetails.ts +0 -25
  870. package/src/client/core/types/principles.ts +0 -23
  871. package/src/client/core/types/sellPtEvent.ts +0 -39
  872. package/src/client/core/types/sellYtEvent.ts +0 -90
  873. package/src/client/core/types/stageYieldEvent.ts +0 -63
  874. package/src/client/core/types/stageYieldEventV2.ts +0 -69
  875. package/src/client/core/types/stripEvent.ts +0 -124
  876. package/src/client/core/types/tradePtEvent.ts +0 -80
  877. package/src/client/core/types/withdrawLiquidityEvent.ts +0 -97
  878. package/src/client/core/types/withdrawLpEvent.ts +0 -75
  879. package/src/client/core/types/withdrawLpEventV2.ts +0 -83
  880. package/src/client/core/types/withdrawYtEvent.ts +0 -82
  881. package/src/client/core/types/withdrawYtEventV2.ts +0 -91
  882. package/src/client/core/types/wrapperBuyYtEvent.ts +0 -39
  883. package/src/client/core/types/wrapperCollectInterestEvent.ts +0 -37
  884. package/src/client/core/types/wrapperMergeEvent.ts +0 -38
  885. package/src/client/core/types/wrapperProvideLiquidityBaseEvent.ts +0 -43
  886. package/src/client/core/types/wrapperProvideLiquidityClassicEvent.ts +0 -41
  887. package/src/client/core/types/wrapperProvideLiquidityEvent.ts +0 -41
  888. package/src/client/core/types/wrapperSellYtEvent.ts +0 -39
  889. package/src/client/core/types/wrapperStripEvent.ts +0 -38
  890. package/src/client/core/types/wrapperWithdrawLiquidityClassicEvent.ts +0 -41
  891. package/src/client/core/types/wrapperWithdrawLiquidityEvent.ts +0 -39
  892. package/src/client/core/types/yieldTokenTracker.ts +0 -12
  893. package/src/client/orderbook/accounts/cpiAccountsOrderbook.ts +0 -101
  894. package/src/client/orderbook/accounts/vault.ts +0 -234
  895. package/src/client/orderbook/eventRegistry.ts +0 -71
  896. package/src/client/orderbook/index.ts +0 -55
  897. package/src/client/orderbook/instructions/collectAdminEmission.ts +0 -48
  898. package/src/client/orderbook/instructions/collectAdminFee.ts +0 -59
  899. package/src/client/orderbook/instructions/collectInterest.ts +0 -66
  900. package/src/client/orderbook/instructions/initializeOrderbook.ts +0 -104
  901. package/src/client/orderbook/instructions/marketOffer.ts +0 -89
  902. package/src/client/orderbook/instructions/postOffer.ts +0 -96
  903. package/src/client/orderbook/instructions/reallocOrderbookAccount.ts +0 -45
  904. package/src/client/orderbook/instructions/removeExpiredOffers.ts +0 -37
  905. package/src/client/orderbook/instructions/removeOffer.ts +0 -73
  906. package/src/client/orderbook/instructions/setConfigurationOptions.ts +0 -43
  907. package/src/client/orderbook/instructions/withdrawFunds.ts +0 -78
  908. package/src/client/orderbook/instructions/wrapperCollectAdminFee.ts +0 -73
  909. package/src/client/orderbook/instructions/wrapperCollectInterest.ts +0 -65
  910. package/src/client/orderbook/instructions/wrapperMarketOffer.ts +0 -94
  911. package/src/client/orderbook/instructions/wrapperPostOffer.ts +0 -99
  912. package/src/client/orderbook/instructions/wrapperRemoveOffer.ts +0 -75
  913. package/src/client/orderbook/instructions/wrapperWithdrawFunds.ts +0 -80
  914. package/src/client/orderbook/types/amount.ts +0 -51
  915. package/src/client/orderbook/types/claimLimits.ts +0 -15
  916. package/src/client/orderbook/types/collectAdminEmissionEvent.ts +0 -39
  917. package/src/client/orderbook/types/collectAdminFeeEvent.ts +0 -17
  918. package/src/client/orderbook/types/collectEmissionEventV2.ts +0 -60
  919. package/src/client/orderbook/types/collectInterestEventV2.ts +0 -57
  920. package/src/client/orderbook/types/collectUserInterestEvent.ts +0 -36
  921. package/src/client/orderbook/types/cpiAccounts.ts +0 -21
  922. package/src/client/orderbook/types/cpiInterfaceContext.ts +0 -13
  923. package/src/client/orderbook/types/emissionInfo.ts +0 -44
  924. package/src/client/orderbook/types/exponentCoreCpiAccounts.ts +0 -21
  925. package/src/client/orderbook/types/filledOffersEvent.ts +0 -19
  926. package/src/client/orderbook/types/index.ts +0 -30
  927. package/src/client/orderbook/types/marketOfferEvent.ts +0 -72
  928. package/src/client/orderbook/types/mergeEvent.ts +0 -118
  929. package/src/client/orderbook/types/number.ts +0 -7
  930. package/src/client/orderbook/types/offerOptions.ts +0 -56
  931. package/src/client/orderbook/types/offerType.ts +0 -8
  932. package/src/client/orderbook/types/orderbookInitEvent.ts +0 -54
  933. package/src/client/orderbook/types/postOfferEvent.ts +0 -78
  934. package/src/client/orderbook/types/removeOfferEvent.ts +0 -67
  935. package/src/client/orderbook/types/setConfigurationOptionsEnum.ts +0 -116
  936. package/src/client/orderbook/types/stripEvent.ts +0 -124
  937. package/src/client/orderbook/types/withdrawFundsEvent.ts +0 -65
  938. package/src/client/orderbook/types/wrapperCollectAdminFeeEvent.ts +0 -13
  939. package/src/client/orderbook/types/wrapperCollectInterestEvent.ts +0 -25
  940. package/src/client/orderbook/types/wrapperMarketOfferEvent.ts +0 -27
  941. package/src/client/orderbook/types/wrapperPostOfferEvent.ts +0 -72
  942. package/src/client/orderbook/types/wrapperRemoveOfferEvent.ts +0 -25
  943. package/src/client/orderbook/types/wrapperWithdrawFundsEvent.ts +0 -38
  944. package/src/client/orderbook/types/yieldTokenTracker.ts +0 -12
  945. package/src/client/vaults/accounts/actionProposal.ts +0 -144
  946. package/src/client/vaults/accounts/exponentStrategyVault.ts +0 -211
  947. package/src/client/vaults/accounts/programConfig.ts +0 -123
  948. package/src/client/vaults/accounts/voteAccount.ts +0 -132
  949. package/src/client/vaults/accounts/withdrawalAccount.ts +0 -132
  950. package/src/client/vaults/eventRegistry.ts +0 -45
  951. package/src/client/vaults/index.ts +0 -113
  952. package/src/client/vaults/instructions/activateProposal.ts +0 -46
  953. package/src/client/vaults/instructions/addPolicy.ts +0 -57
  954. package/src/client/vaults/instructions/appendProposalActions.ts +0 -47
  955. package/src/client/vaults/instructions/cancelProposal.ts +0 -28
  956. package/src/client/vaults/instructions/cancelWithdrawal.ts +0 -34
  957. package/src/client/vaults/instructions/collectManagementFee.ts +0 -32
  958. package/src/client/vaults/instructions/depositLiquidity.ts +0 -62
  959. package/src/client/vaults/instructions/executeProposal.ts +0 -36
  960. package/src/client/vaults/instructions/executeWithdrawal.ts +0 -58
  961. package/src/client/vaults/instructions/executeWithdrawalFromReserves.ts +0 -66
  962. package/src/client/vaults/instructions/fillWithdrawal.ts +0 -59
  963. package/src/client/vaults/instructions/finalizeProposal.ts +0 -28
  964. package/src/client/vaults/instructions/initProposal.ts +0 -46
  965. package/src/client/vaults/instructions/initializePrices.ts +0 -28
  966. package/src/client/vaults/instructions/initializeVault.ts +0 -148
  967. package/src/client/vaults/instructions/makeSentienelManager.ts +0 -28
  968. package/src/client/vaults/instructions/managePrices.ts +0 -46
  969. package/src/client/vaults/instructions/manageVaultSettings.ts +0 -48
  970. package/src/client/vaults/instructions/managerUpdatePosition.ts +0 -45
  971. package/src/client/vaults/instructions/queueWithdrawal.ts +0 -50
  972. package/src/client/vaults/instructions/removePolicy.ts +0 -44
  973. package/src/client/vaults/instructions/sentinelSetVaultFlags.ts +0 -44
  974. package/src/client/vaults/instructions/stakeVote.ts +0 -57
  975. package/src/client/vaults/instructions/unstakeVote.ts +0 -42
  976. package/src/client/vaults/instructions/updatePolicy.ts +0 -59
  977. package/src/client/vaults/instructions/updatePolicyManager.ts +0 -44
  978. package/src/client/vaults/instructions/updatePrice.ts +0 -42
  979. package/src/client/vaults/instructions/validateInteractionHook.ts +0 -60
  980. package/src/client/vaults/instructions/wrapperAddPolicy.ts +0 -57
  981. package/src/client/vaults/instructions/wrapperExecuteWithdrawal.ts +0 -76
  982. package/src/client/vaults/instructions/wrapperManageVaultSettings.ts +0 -48
  983. package/src/client/vaults/instructions/wrapperManagerUpdatePosition.ts +0 -45
  984. package/src/client/vaults/instructions/wrapperRemovePolicy.ts +0 -44
  985. package/src/client/vaults/instructions/wrapperUpdatePolicy.ts +0 -59
  986. package/src/client/vaults/types/accountConstraint.ts +0 -35
  987. package/src/client/vaults/types/accountConstraintType.ts +0 -93
  988. package/src/client/vaults/types/allowedSettingsChange.ts +0 -136
  989. package/src/client/vaults/types/cancelProposalEvent.ts +0 -47
  990. package/src/client/vaults/types/clmmPositionEntry.ts +0 -37
  991. package/src/client/vaults/types/dataConstraint.ts +0 -16
  992. package/src/client/vaults/types/dataOperator.ts +0 -13
  993. package/src/client/vaults/types/dataValue.ts +0 -119
  994. package/src/client/vaults/types/depositLiquidityEvent.ts +0 -89
  995. package/src/client/vaults/types/executeProposalEvent.ts +0 -47
  996. package/src/client/vaults/types/executeWithdrawalEvent.ts +0 -12
  997. package/src/client/vaults/types/fillParam.ts +0 -12
  998. package/src/client/vaults/types/finalizeProposalEvent.ts +0 -51
  999. package/src/client/vaults/types/hook.ts +0 -40
  1000. package/src/client/vaults/types/hookCompiledInstruction.ts +0 -20
  1001. package/src/client/vaults/types/index.ts +0 -68
  1002. package/src/client/vaults/types/instructionConstraint.ts +0 -33
  1003. package/src/client/vaults/types/internalFundTransferPolicyCreationPayload.ts +0 -35
  1004. package/src/client/vaults/types/kaminoFarmEntry.ts +0 -32
  1005. package/src/client/vaults/types/kaminoObligationEntry.ts +0 -51
  1006. package/src/client/vaults/types/limitedQuantityConstraints.ts +0 -10
  1007. package/src/client/vaults/types/limitedSpendingLimit.ts +0 -35
  1008. package/src/client/vaults/types/limitedTimeConstraints.ts +0 -15
  1009. package/src/client/vaults/types/loopscaleLoanEntry.ts +0 -23
  1010. package/src/client/vaults/types/loopscaleStrategyEntry.ts +0 -23
  1011. package/src/client/vaults/types/number.ts +0 -8
  1012. package/src/client/vaults/types/obligationType.ts +0 -63
  1013. package/src/client/vaults/types/orderbookEntry.ts +0 -50
  1014. package/src/client/vaults/types/periodV2.ts +0 -76
  1015. package/src/client/vaults/types/permissions.ts +0 -8
  1016. package/src/client/vaults/types/policyAction.ts +0 -74
  1017. package/src/client/vaults/types/policyConfig.ts +0 -32
  1018. package/src/client/vaults/types/policyCreationPayload.ts +0 -147
  1019. package/src/client/vaults/types/policyExpirationArgs.ts +0 -67
  1020. package/src/client/vaults/types/positionUpdate.ts +0 -313
  1021. package/src/client/vaults/types/priceId.ts +0 -57
  1022. package/src/client/vaults/types/priceType.ts +0 -23
  1023. package/src/client/vaults/types/programInteractionPolicyCreationPayload.ts +0 -32
  1024. package/src/client/vaults/types/proposalAction.ts +0 -97
  1025. package/src/client/vaults/types/proposalActionKind.ts +0 -11
  1026. package/src/client/vaults/types/proposalStatus.ts +0 -13
  1027. package/src/client/vaults/types/proposalVoteConfig.ts +0 -36
  1028. package/src/client/vaults/types/proposeActionEvent.ts +0 -62
  1029. package/src/client/vaults/types/quantityConstraints.ts +0 -14
  1030. package/src/client/vaults/types/reserveFarmMapping.ts +0 -35
  1031. package/src/client/vaults/types/reservePriceMapping.ts +0 -26
  1032. package/src/client/vaults/types/settingsChangePolicyCreationPayload.ts +0 -14
  1033. package/src/client/vaults/types/spendingLimitPolicyCreationPayload.ts +0 -54
  1034. package/src/client/vaults/types/stakeVoteEvent.ts +0 -54
  1035. package/src/client/vaults/types/strategyPosition.ts +0 -178
  1036. package/src/client/vaults/types/timeConstraints.ts +0 -22
  1037. package/src/client/vaults/types/tokenAccountBalance.ts +0 -35
  1038. package/src/client/vaults/types/tokenAccountEntry.ts +0 -30
  1039. package/src/client/vaults/types/tokenEntry.ts +0 -48
  1040. package/src/client/vaults/types/unstakeVoteEvent.ts +0 -53
  1041. package/src/client/vaults/types/updatePriceAction.ts +0 -268
  1042. package/src/client/vaults/types/updatePriceInput.ts +0 -12
  1043. package/src/client/vaults/types/usageState.ts +0 -12
  1044. package/src/client/vaults/types/vaultConfig.ts +0 -38
  1045. package/src/client/vaults/types/vaultFinancials.ts +0 -40
  1046. package/src/client/vaults/types/vaultFlagAction.ts +0 -75
  1047. package/src/client/vaults/types/vaultFlagsUpdatedEvent.ts +0 -37
  1048. package/src/client/vaults/types/vaultRoleKind.ts +0 -11
  1049. package/src/client/vaults/types/vaultRoles.ts +0 -59
  1050. package/src/client/vaults/types/vaultSettingsAction.ts +0 -533
  1051. package/src/client/vaults/types/voteChoice.ts +0 -9
  1052. package/src/client/vaults/types/withdrawalPeriodSettings.ts +0 -83
  1053. package/src/client/vaults/types/withdrawalTokenFill.ts +0 -35
  1054. package/src/client/vaults/types/yieldPositionEntry.ts +0 -35
  1055. package/src/clmm/codamaEvents.ts +0 -34
  1056. package/src/clmm/index.ts +0 -1
  1057. package/src/codamaEvents.ts +0 -27
  1058. package/src/environment.ts +0 -21
  1059. package/src/exponentVaults/aumCalculator.ts +0 -1350
  1060. package/src/exponentVaults/events.ts +0 -15
  1061. package/src/exponentVaults/fetcher.ts +0 -257
  1062. package/src/exponentVaults/index.ts +0 -322
  1063. package/src/exponentVaults/kamino-farms.ts +0 -538
  1064. package/src/exponentVaults/kamino-markets.ts +0 -363
  1065. package/src/exponentVaults/loopscale/client.ts +0 -808
  1066. package/src/exponentVaults/loopscale/helpers.ts +0 -172
  1067. package/src/exponentVaults/loopscale/index.ts +0 -57
  1068. package/src/exponentVaults/loopscale/prepared-transactions.ts +0 -435
  1069. package/src/exponentVaults/loopscale/prepared-types.ts +0 -73
  1070. package/src/exponentVaults/loopscale/types.ts +0 -466
  1071. package/src/exponentVaults/policyBuilders.ts +0 -1729
  1072. package/src/exponentVaults/policyMatcher.ts +0 -895
  1073. package/src/exponentVaults/pricePathResolver.test.ts +0 -466
  1074. package/src/exponentVaults/pricePathResolver.ts +0 -273
  1075. package/src/exponentVaults/scope-refresh.ts +0 -169
  1076. package/src/exponentVaults/squadsVaultTxnResolver/constants.ts +0 -59
  1077. package/src/exponentVaults/squadsVaultTxnResolver/helpers.ts +0 -355
  1078. package/src/exponentVaults/squadsVaultTxnResolver/index.ts +0 -16
  1079. package/src/exponentVaults/squadsVaultTxnResolver/resolvers/exponent.ts +0 -472
  1080. package/src/exponentVaults/squadsVaultTxnResolver/resolvers/helpers.ts +0 -33
  1081. package/src/exponentVaults/squadsVaultTxnResolver/resolvers/index.ts +0 -38
  1082. package/src/exponentVaults/squadsVaultTxnResolver/resolvers/kamino.ts +0 -83
  1083. package/src/exponentVaults/squadsVaultTxnResolver/resolvers/loopscale.ts +0 -94
  1084. package/src/exponentVaults/squadsVaultTxnResolver/resolvers/titan.ts +0 -41
  1085. package/src/exponentVaults/squadsVaultTxnResolver/squadsVaultTxnResolver.ts +0 -91
  1086. package/src/exponentVaults/squadsVaultTxnResolver/types.ts +0 -171
  1087. package/src/exponentVaults/squadsVaultTxnResolver/utils.ts +0 -3
  1088. package/src/exponentVaults/syncTransaction.ts +0 -500
  1089. package/src/exponentVaults/titan-quote.ts +0 -446
  1090. package/src/exponentVaults/vault-instruction-types.ts +0 -493
  1091. package/src/exponentVaults/vault-interaction.ts +0 -5070
  1092. package/src/exponentVaults/vault.ts +0 -2667
  1093. package/src/exponentVaults/vaultTransactionBuilder.test.ts +0 -256
  1094. package/src/exponentVaults/vaultTransactionBuilder.ts +0 -927
  1095. package/src/flavors.ts +0 -841
  1096. package/src/index.ts +0 -26
  1097. package/src/lpPosition.ts +0 -155
  1098. package/src/market.ts +0 -2432
  1099. package/src/marketThree.test.ts +0 -210
  1100. package/src/marketThree.ts +0 -2861
  1101. package/src/orderbook/codamaEvents.ts +0 -28
  1102. package/src/orderbook/index.ts +0 -13
  1103. package/src/orderbook/math.ts +0 -138
  1104. package/src/orderbook/orderbook.ts +0 -1354
  1105. package/src/orderbook/types.ts +0 -40
  1106. package/src/orderbook/utils.ts +0 -66
  1107. package/src/router.ts +0 -810
  1108. package/src/syPosition.ts +0 -182
  1109. package/src/tokenUtil.ts +0 -23
  1110. package/src/utils/altUtil.ts +0 -52
  1111. package/src/utils/binSolver.test.ts +0 -17
  1112. package/src/utils/binSolver.ts +0 -44
  1113. package/src/utils/index.ts +0 -33
  1114. package/src/utils/ix.ts +0 -7
  1115. package/src/vault.ts +0 -1033
  1116. package/src/ytPosition.ts +0 -319
  1117. package/tsconfig.json +0 -46
package/src/market.ts DELETED
@@ -1,2432 +0,0 @@
1
- import {
2
- TOKEN_PROGRAM_ID,
3
- createAssociatedTokenAccountIdempotentInstruction,
4
- getAssociatedTokenAddressSync,
5
- } from "@solana/spl-token"
6
-
7
- import { ExponentFetcher, LiquidityNetBalanceLimits, LpFarm } from "@exponent-labs/exponent-fetcher"
8
- import { ExponentPDA } from "@exponent-labs/exponent-pda"
9
- import {
10
- AnchorizedPNum,
11
- CpiAccountsRaw,
12
- CpiAccountsRawJson,
13
- Flavor,
14
- SyPosition,
15
- serializeCpiAccountsRaw,
16
- } from "@exponent-labs/exponent-types"
17
- import {
18
- FlavorGenericStateJson,
19
- SyPositionJson,
20
- VaultJson,
21
- deserializeCpiAccountsRaw,
22
- } from "@exponent-labs/exponent-types"
23
- import { LiquidityAdd, MarketCalculator, lpOutForTokensIn } from "@exponent-labs/market-math"
24
- import { PreciseNumber } from "@exponent-labs/precise-number"
25
-
26
- import { fetchAddressLookupTable, makeCpiAccountMetaLists } from "./addressLookupTableUtil"
27
- import { Environment } from "./environment"
28
- import {
29
- deserializeFlavor,
30
- makeFlavorGenericSync,
31
- makeFlavorJitoRestakingSync,
32
- makeFlavorKaminoSync,
33
- makeFlavorMarginfiSync,
34
- makeFlavorPerenaSync,
35
- serializeFlavor,
36
- } from "./flavors"
37
- import { deserializeSyPosition, serializeSyPosition } from "./syPosition"
38
- import { makeSyPosition } from "./syPosition"
39
- import { getMultipleMintSupply } from "./tokenUtil"
40
- import { emitEventAuthority, getExponentAdminStatePda, uniqueRemainingAccounts } from "./utils"
41
- import { extendAddressLookupTable } from "./utils/altUtil"
42
- import { Vault } from "./vault"
43
- import { Connection, PublicKey, SYSVAR_RENT_PUBKEY, SystemProgram, TransactionInstruction } from "@solana/web3.js"
44
- import * as exponentCore from "./client/core"
45
- import BN from 'bn.js'
46
- export type { LiquidityAdd }
47
-
48
- const SECONDS_PER_YEAR = 365 * 24 * 60 * 60
49
-
50
- interface Emission {
51
- /** Token account that holds emission tokens */
52
- escrowAccountAddress: PublicKey
53
-
54
- /** Mint for the emission token */
55
- mint: PublicKey
56
-
57
- /** Token program ID for the emission token */
58
- tokenProgramAddress: PublicKey
59
-
60
- /** How many emissions have been claimed by SY holders */
61
- totalClaimed: bigint
62
-
63
- /** How many emissions have been earned by the SY robot over its lifetime */
64
- lastSeenTotalAccruedEmissions: bigint
65
-
66
- /** Global index for sharing out rewards to SY holders */
67
- index: AnchorizedPNum
68
- }
69
-
70
- export type MarketAdminAction = exponentCore.MarketAdminAction
71
-
72
- type MarketArgs = {
73
- ptBalance: bigint
74
- syBalance: bigint
75
- lpSupply: bigint
76
- sySupply: bigint
77
- lpEscrowAmount: bigint
78
- maxLpSupply: bigint
79
- rateScalarRoot: number
80
- lnFeeRateRoot: number
81
- lastLnImpliedRate: number
82
- expirationTs: number
83
- addressLookupTable: PublicKey
84
- mintSy: PublicKey
85
- mintPt: PublicKey
86
- vault: Vault
87
- mintLp: PublicKey
88
- tokenPtEscrow: PublicKey
89
- tokenSyEscrow: PublicKey
90
- tokenLpEscrow: PublicKey
91
- syProgram: PublicKey
92
- statusFlags: number
93
- cpiAccounts: CpiAccountsRaw
94
- feeTreasurySyBps: number
95
- tokenFeeTreasurySy: PublicKey
96
- isCurrentFlashSwap: boolean
97
- lpFarm: LpFarm
98
- flavor: Flavor
99
- liquidityNetBalanceLimits: LiquidityNetBalanceLimits
100
- syPosition: SyPosition
101
- emissions: {
102
- trackers: {
103
- tokenEscrow: PublicKey
104
- lpShareIndex: number
105
- lastSeenStaged: number
106
- }[]
107
- }
108
- seedId: number[]
109
- }
110
-
111
-
112
- export interface MarketLoadOptions {
113
- syConfig?: {
114
- skipWrap?: boolean
115
- }
116
- }
117
-
118
- export class Market {
119
- xponPda: ExponentPDA
120
-
121
- constructor(
122
- public state: MarketArgs,
123
- public selfAddress: PublicKey,
124
- public env: Environment,
125
- public connection: Connection,
126
- ) {
127
- this.xponPda = new ExponentPDA(env.coreProgramId)
128
- }
129
-
130
- static async load(
131
- env: Environment,
132
- connection: Connection,
133
- address: PublicKey,
134
- vault?: Vault,
135
- options: MarketLoadOptions = {},
136
- ): Promise<Market> {
137
- const fetcher = new ExponentFetcher({ connection })
138
- const fetchedMarket = await fetcher.fetchMarket(address)
139
- const [[lpSupply, sySupply], alt, loadedVault] = await Promise.all([
140
- getMultipleMintSupply(connection, [fetchedMarket.mintLp, fetchedMarket.mintSy]),
141
- fetchAddressLookupTable(connection, fetchedMarket.addressLookupTable),
142
- vault || Vault.load(env, connection, fetchedMarket.vault, options),
143
- ])
144
- const cpiAccounts = makeCpiAccountMetaLists(alt, fetchedMarket.cpiAccounts)
145
-
146
- const flavor = (() => {
147
- switch (loadedVault.flavor.flavor) {
148
- case "marginfi":
149
- return makeFlavorMarginfiSync(loadedVault.flavor)
150
- case "kamino":
151
- return makeFlavorKaminoSync(loadedVault.flavor)
152
- case "jitoRestaking":
153
- return makeFlavorJitoRestakingSync(loadedVault.flavor)
154
- case "perena":
155
- return makeFlavorPerenaSync(loadedVault.flavor)
156
- case "generic":
157
- return makeFlavorGenericSync(loadedVault.flavor, options.syConfig)
158
- default:
159
- throw new Error(`Unknown flavor: ${loadedVault.flavor}`)
160
- }
161
- })()
162
-
163
- const syPosition = await makeSyPosition(fetcher, flavor, fetchedMarket.syProgram, address)
164
-
165
- const state: MarketArgs = {
166
- ...fetchedMarket,
167
- vault: loadedVault,
168
- cpiAccounts,
169
- lpSupply,
170
- sySupply,
171
- flavor,
172
- syPosition,
173
- }
174
- return new Market(state, address, env, connection)
175
- }
176
-
177
- async reload(connection: Connection = this.connection) {
178
- const market = await Market.load(this.env, connection, this.selfAddress)
179
- this.state = market.state
180
- return market
181
- }
182
-
183
- /** Convert to a JSON representation */
184
- toJson() {
185
- return toJson(this)
186
- }
187
-
188
- get vault() {
189
- return this.state.vault
190
- }
191
-
192
- get flavor() {
193
- return this.state.flavor
194
- }
195
-
196
- get lpSupply() {
197
- return this.state.lpSupply
198
- }
199
-
200
- get syBalance() {
201
- return this.state.syBalance
202
- }
203
-
204
- get ptBalance() {
205
- return this.state.ptBalance
206
- }
207
-
208
- get mintSy() {
209
- return this.state.mintSy
210
- }
211
-
212
- get mintPt() {
213
- return this.state.mintPt
214
- }
215
-
216
- get statusFlags() {
217
- return this.state.statusFlags
218
- }
219
-
220
- get mintYt() {
221
- return this.vault.mintYt
222
- }
223
-
224
- get mintLp() {
225
- return this.state.mintLp
226
- }
227
-
228
- get addressLookupTable() {
229
- return this.state.addressLookupTable
230
- }
231
-
232
- get syProgram() {
233
- return this.state.syProgram
234
- }
235
-
236
- get cpiAccounts() {
237
- return this.state.cpiAccounts
238
- }
239
-
240
- get marketEmissions() {
241
- return this.state.emissions
242
- }
243
-
244
- get emissions(): Emission[] {
245
- if (this.flavor.flavor === "marginfi") {
246
- return this.flavor.mfiSyState.account.emissions.map((e) => ({
247
- escrowAccountAddress: e.escrowAccount,
248
- mint: e.mint,
249
- tokenProgramAddress: e.tokenProgram,
250
- totalClaimed: BigInt(e.totalClaimedEmissions.toString()),
251
- lastSeenTotalAccruedEmissions: BigInt(e.lastSeenTotalAccruedEmissions.toString()),
252
- index: e.index,
253
- }))
254
- }
255
- if (this.flavor.flavor === "kamino") {
256
- return this.flavor.kaminoSyState.account.emissions.map((e) => ({
257
- escrowAccountAddress: e.escrowAccount,
258
- mint: e.mint,
259
- tokenProgramAddress: e.tokenProgram,
260
- totalClaimed: BigInt(e.totalClaimedEmissions.toString()),
261
- lastSeenTotalAccruedEmissions: BigInt(e.lastSeenTotalAccruedEmissions.toString()),
262
- index: e.index,
263
- }))
264
- }
265
- if (this.flavor.flavor === "jitoRestaking") {
266
- return this.flavor.jitoSyState.account.emissions.map((e) => ({
267
- escrowAccountAddress: e.escrowAccount,
268
- mint: e.mint,
269
- tokenProgramAddress: e.tokenProgram,
270
- totalClaimed: BigInt(e.totalClaimedEmissions.toString()),
271
- lastSeenTotalAccruedEmissions: BigInt(e.lastSeenTotalAccruedEmissions.toString()),
272
- index: e.index,
273
- }))
274
- }
275
- if (this.flavor.flavor === "perena") {
276
- return this.flavor.perenaSyState.account.emissions.map((e) => ({
277
- escrowAccountAddress: e.escrowAccount,
278
- mint: e.mint,
279
- tokenProgramAddress: e.tokenProgram,
280
- totalClaimed: BigInt(e.totalClaimedEmissions.toString()),
281
- lastSeenTotalAccruedEmissions: BigInt(e.lastSeenTotalAccruedEmissions.toString()),
282
- index: e.index,
283
- }))
284
- }
285
- if (this.flavor.flavor === "generic") {
286
- return this.flavor.genericSyState.account.emissions.map((e) => ({
287
- escrowAccountAddress: e.escrowAccount,
288
- mint: e.mint,
289
- tokenProgramAddress: e.tokenProgram,
290
- totalClaimed: BigInt(e.totalClaimedEmissions.toString()),
291
- lastSeenTotalAccruedEmissions: BigInt(e.lastSeenTotalAccruedEmissions.toString()),
292
- index: e.index,
293
- }))
294
- }
295
- throw new Error("Unknown flavor")
296
- }
297
-
298
- /** Get the escrow token account addresses for the emissions, in order */
299
- get emissionTokenAccounts(): PublicKey[] {
300
- return this.emissions.map((e) => e.escrowAccountAddress)
301
- }
302
-
303
- /** Pass-through SY account owned by the market */
304
- get tokenSyEscrow(): PublicKey {
305
- return this.state.tokenSyEscrow
306
- }
307
-
308
- /** SY account that holds treasury SY fees from PT trading */
309
- get tokenFeeTreasurySy(): PublicKey {
310
- return this.state.tokenFeeTreasurySy
311
- }
312
-
313
- /** Market liquidity for PT */
314
- get tokenPtEscrow(): PublicKey {
315
- return this.state.tokenPtEscrow
316
- }
317
-
318
- get tokenLpEscrow(): PublicKey {
319
- return this.state.tokenLpEscrow
320
- }
321
-
322
- get currentSyExchangeRate(): number {
323
- return this.flavor.currentSyExchangeRate
324
- }
325
-
326
- /** Special account for event emit self-cpi */
327
- get eventAuthority(): PublicKey {
328
- return emitEventAuthority(this.env.coreProgramId)
329
- }
330
-
331
- get currentPtPriceInSy(): number {
332
- return this.currentPtPriceInAsset / this.currentSyExchangeRate
333
- }
334
-
335
- get currentPtPriceInAsset(): number {
336
- const marketCalculator = this.marketCalculator()
337
- return marketCalculator.exchangeRate
338
- }
339
-
340
- get ptDiscount(): number {
341
- return 1 / this.currentPtPriceInAsset
342
- }
343
-
344
- get lpPriceInAsset(): number {
345
- // Calculate total value of liquidity in asset units
346
- const liquidityPoolTvl =
347
- Number(this.syBalance) * this.flavor.currentSyExchangeRate + Number(this.ptBalance) / this.currentPtPriceInAsset
348
- // Return LP price in asset units (0 if no supply to avoid division by zero)
349
- return Number(this.lpSupply) === 0 ? 0 : liquidityPoolTvl / Number(this.lpSupply)
350
- }
351
-
352
- // Calculate total value of liquidity in asset units
353
- get liquidityPoolTvl(): number {
354
- return (
355
- Number(this.syBalance) * this.flavor.currentSyExchangeRate + Number(this.ptBalance) / this.currentPtPriceInAsset
356
- )
357
- }
358
-
359
- get secondsRemaining(): number {
360
- const timeNow = Date.now() / 1000
361
- return Math.max(0, Math.round(this.state.expirationTs - timeNow))
362
- }
363
-
364
- get absolutePtYield(): number {
365
- const ptAssetExchangeRate = this.ptDiscount
366
- return (1 - ptAssetExchangeRate) / ptAssetExchangeRate
367
- }
368
-
369
- /** Annualize a rate given the number of seconds remaining until maturity */
370
- static annualize(rate: number, secondsRemaining: number) {
371
- return (rate * SECONDS_PER_YEAR) / secondsRemaining
372
- }
373
-
374
- static annualizeApy(rate: number, secondsRemaining: number) {
375
- return (1 + rate) ** (SECONDS_PER_YEAR / secondsRemaining) - 1
376
- }
377
-
378
- /** Annualized PT fixed rate */
379
- get ptApr(): number {
380
- return Market.annualize(this.absolutePtYield, this.secondsRemaining)
381
- }
382
-
383
- get ptApy(): number {
384
- return Market.annualizeApy(this.absolutePtYield, this.secondsRemaining)
385
- }
386
-
387
- /** The fee rate taken off of trade fees (typically around 20%) expressed as a BPS number */
388
- get feeTreasuryBps(): number {
389
- return this.state.feeTreasurySyBps
390
- }
391
-
392
- /** The fee rate on assets when trading PT
393
- * Expressed as a rational number
394
- * eg 0.01 = 1%
395
- */
396
- get feeRatePtTrade(): number {
397
- return 1 - this.marketCalculator().feeRate
398
- }
399
-
400
- /** The fee rate taken off of trade fees (typically around 20%) expressed as a rational number */
401
- get feeTreasuryRate(): number {
402
- return this.feeTreasuryBps / 10_000
403
- }
404
-
405
- /** Calculate amount of LP tokens to expect for tokens in */
406
- lpOutForTokensIn(syInIntent: bigint, ptInIntent: bigint): LiquidityAdd {
407
- return lpOutForTokensIn({
408
- syIntent: Number(syInIntent),
409
- ptIntent: Number(ptInIntent),
410
- lpSupply: Number(this.lpSupply),
411
- syLiquidity: Number(this.syBalance),
412
- ptLiquidity: Number(this.ptBalance),
413
- })
414
- }
415
-
416
- marketCalculator() {
417
- const timeNow = Date.now() / 1000
418
- const secondsRemaining = Math.max(0, Math.round(this.state.expirationTs - timeNow))
419
- return new MarketCalculator({
420
- liquiditySy: parseInt(this.syBalance.toString()),
421
- liquidityPt: parseInt(this.ptBalance.toString()),
422
- currentSyExchangeRate: this.currentSyExchangeRate,
423
- lnFeeRateRoot: this.state.lnFeeRateRoot,
424
- secondsRemaining,
425
- lpTokenSupply: this.lpSupply,
426
- rateScalarRoot: this.state.rateScalarRoot,
427
- lastLnImpliedRate: this.state.lastLnImpliedRate,
428
- maxNetBalanceChangeNegativePercentage: this.state.liquidityNetBalanceLimits.maxNetBalanceChangeNegativePercentage,
429
- maxNetBalanceChangePositivePercentage: this.state.liquidityNetBalanceLimits.maxNetBalanceChangePositivePercentage,
430
- windowStartTimestamp: this.state.liquidityNetBalanceLimits.windowStartTimestamp,
431
- windowStartNetBalance: this.state.liquidityNetBalanceLimits.windowStartNetBalance.toNumber(),
432
- windowDurationSeconds: this.state.liquidityNetBalanceLimits.windowDurationSeconds,
433
- feeTreasurySyBps: this.state.feeTreasurySyBps,
434
- })
435
- }
436
-
437
- /** Deposit a pair of tokens as liquidity to the market
438
- * Adds PT & SY from the `depositor` to the market
439
- *
440
- * Due to unforeseeable slippage, the PT & SY amounts intended are effectively the maximum amounts
441
- * The minimum LP tokens to receive is specified by `minLpOut`
442
- *
443
- * The token accounts themselves are optional, and will be derived from the depositor's wallet if not provided
444
- */
445
- ixDepositLiquidity({
446
- ptInIntent,
447
- syInIntent,
448
- minLpOut,
449
- depositor,
450
- ptSrc: ptSrcParam,
451
- sySrc: sySrcParam,
452
- lpDst: lpDstParam,
453
- }: {
454
- /** Intended (maximum) amount of PT in */
455
- ptInIntent: bigint
456
- /** Intended (maximum) amount of SY in */
457
- syInIntent: bigint
458
- /** Minimum LP tokens out */
459
- minLpOut: bigint
460
- depositor: PublicKey
461
- ptSrc?: PublicKey
462
- sySrc?: PublicKey
463
- lpDst?: PublicKey
464
- }): TransactionInstruction {
465
- const sySrc = sySrcParam || getAssociatedTokenAddressSync(this.mintSy, depositor, true, TOKEN_PROGRAM_ID)
466
- const ptSrc = ptSrcParam || getAssociatedTokenAddressSync(this.mintPt, depositor, true, TOKEN_PROGRAM_ID)
467
- const lpDst = lpDstParam || getAssociatedTokenAddressSync(this.mintLp, depositor, true, TOKEN_PROGRAM_ID)
468
-
469
- const syRemAccounts = this.cpiAccounts.depositSy
470
-
471
- const ix = exponentCore.createMarketTwoDepositLiquidityInstruction(
472
- {
473
- depositor,
474
- market: this.selfAddress,
475
- mintLp: this.mintLp,
476
- tokenPtSrc: ptSrc,
477
- tokenSySrc: sySrc,
478
- tokenLpDst: lpDst,
479
- tokenPtEscrow: this.tokenPtEscrow,
480
- tokenSyEscrow: this.tokenSyEscrow,
481
- addressLookupTable: this.addressLookupTable,
482
- syProgram: this.syProgram,
483
- tokenProgram: TOKEN_PROGRAM_ID,
484
- eventAuthority: this.vault.eventAuthority,
485
- program: exponentCore.EXPONENTCORE_PROGRAM_ID,
486
- },
487
- { ptIntent: ptInIntent, syIntent: syInIntent, minLpOut },
488
- )
489
- ix.keys.push(...syRemAccounts)
490
- return ix
491
- }
492
-
493
- ixModifyMarketSetting({ signer, adminAction }: { signer: PublicKey; adminAction: exponentCore.MarketAdminAction }): TransactionInstruction {
494
- return exponentCore.createModifyMarketSettingInstruction(
495
- {
496
- market: this.selfAddress,
497
- adminState: getExponentAdminStatePda(),
498
- signer,
499
- systemProgram: SystemProgram.programId,
500
- },
501
- { action: adminAction },
502
- )
503
- }
504
-
505
- ixModifyFarm({
506
- newRate,
507
- untilTimestamp,
508
- signer,
509
- farmMint,
510
- farmTokenProgram,
511
- farmTokenSrc: farmTokenSrcParam,
512
- }: {
513
- newRate: bigint
514
- untilTimestamp: number
515
- signer: PublicKey
516
- farmMint: PublicKey
517
- farmTokenProgram: PublicKey
518
- farmTokenSrc?: PublicKey
519
- }): TransactionInstruction {
520
- const farmTokenSrc = farmTokenSrcParam || getAssociatedTokenAddressSync(farmMint, signer, true, farmTokenProgram)
521
- const tokenFarm = getAssociatedTokenAddressSync(farmMint, this.selfAddress, true, farmTokenProgram)
522
-
523
- return exponentCore.createModifyFarmInstruction(
524
- {
525
- market: this.selfAddress,
526
- signer,
527
- mint: farmMint,
528
- adminState: getExponentAdminStatePda(),
529
- tokenSource: farmTokenSrc,
530
- tokenFarm,
531
- tokenProgram: farmTokenProgram,
532
- },
533
- { untilTimestamp, newRate },
534
- )
535
- }
536
-
537
- /**
538
- * Redeem LP tokens for PT & SY (liquidity removal)
539
- *
540
- * The lpIn is exactly the amount of LP tokens to burn
541
- * The minimum PT & SY out are specified by minPtOut & minSyOut
542
- * The transaction may fail due to unforeseeable slippage on the redemption rate
543
- *
544
- * The token accounts themselves are optional, and will be derived from the withdrawer's wallet if not provided
545
- */
546
- ixWithdrawLiquidity({
547
- lpIn,
548
- withdrawer,
549
- minPtOut,
550
- minSyOut,
551
- ptDst: ptDstParam,
552
- syDst: syDstParam,
553
- lpSrc: lpSrcParam,
554
- }: {
555
- lpIn: bigint
556
- withdrawer: PublicKey
557
- minPtOut: bigint
558
- minSyOut: bigint
559
- ptDst?: PublicKey
560
- syDst?: PublicKey
561
- lpSrc?: PublicKey
562
- }) {
563
- const ptDst = ptDstParam || getAssociatedTokenAddressSync(this.mintPt, withdrawer, true, TOKEN_PROGRAM_ID)
564
- const syDst = syDstParam || getAssociatedTokenAddressSync(this.mintSy, withdrawer, true, TOKEN_PROGRAM_ID)
565
- const lpSrc = lpSrcParam || getAssociatedTokenAddressSync(this.mintLp, withdrawer, true, TOKEN_PROGRAM_ID)
566
-
567
- const ptDstAtaIx = createAssociatedTokenAccountIdempotentInstruction(withdrawer, ptDst, withdrawer, this.mintPt)
568
- const syDstAtaIx = createAssociatedTokenAccountIdempotentInstruction(withdrawer, syDst, withdrawer, this.mintSy)
569
- const lpSrcAtaIx = createAssociatedTokenAccountIdempotentInstruction(withdrawer, lpSrc, withdrawer, this.mintLp)
570
-
571
- const syRemAccounts = this.cpiAccounts.withdrawSy
572
-
573
- const ix = exponentCore.createMarketTwoWithdrawLiquidityInstruction(
574
- {
575
- withdrawer,
576
- market: this.selfAddress,
577
- tokenPtDst: ptDst,
578
- tokenSyDst: syDst,
579
- tokenPtEscrow: this.tokenPtEscrow,
580
- tokenSyEscrow: this.tokenSyEscrow,
581
- tokenLpSrc: lpSrc,
582
- mintLp: this.mintLp,
583
- addressLookupTable: this.addressLookupTable,
584
- tokenProgram: TOKEN_PROGRAM_ID,
585
- syProgram: this.syProgram,
586
- eventAuthority: this.vault.eventAuthority,
587
- program: exponentCore.EXPONENTCORE_PROGRAM_ID,
588
- },
589
- { lpIn, minPtOut, minSyOut },
590
- )
591
- ix.keys.push(...syRemAccounts)
592
-
593
- return { ixs: [ix], setupIxs: [ptDstAtaIx, syDstAtaIx, lpSrcAtaIx] }
594
- }
595
-
596
- /** Buy PT with SY
597
- *
598
- * The trader is the account that sends the SY
599
- * The amountPt is the exact amount of PT the trader intends to buy
600
- * The syConstraint is the maximum amount of SY the trader is willing to spend
601
- *
602
- * The token accounts themselves are optional, and will be derived from the trader's wallet if not provided
603
- */
604
- async ixBuyPt({
605
- trader,
606
- amountPt,
607
- maxSySpend,
608
- tokenPt,
609
- tokenSy,
610
- }: {
611
- trader: PublicKey
612
- amountPt: bigint
613
- maxSySpend: bigint
614
- tokenPt?: PublicKey
615
- tokenSy?: PublicKey
616
- }) {
617
- return this.ixTradePt({
618
- trader,
619
- traderPt: amountPt,
620
- syConstraint: maxSySpend,
621
- isBuy: true,
622
- tokenPt,
623
- tokenSy,
624
- })
625
- }
626
-
627
- /**
628
- * Sell PT for SY
629
- * The trader is the account that sends the PT
630
- * The amountPt is the exact amount of PT the trader intends to sell
631
- * The minSyReceive is the minimum amount of SY the trader is willing to receive
632
- *
633
- * The token accounts themselves are optional, and will be derived from the trader's wallet if not provided
634
- */
635
- async ixSellPt({
636
- trader,
637
- amountPt,
638
- minSyReceive,
639
- tokenPt,
640
- tokenSy,
641
- }: {
642
- trader: PublicKey
643
- amountPt: bigint
644
- minSyReceive: bigint
645
- tokenPt?: PublicKey
646
- tokenSy?: PublicKey
647
- }) {
648
- return this.ixTradePt({
649
- trader,
650
- traderPt: amountPt,
651
- syConstraint: minSyReceive,
652
- isBuy: false,
653
- tokenPt,
654
- tokenSy,
655
- })
656
- }
657
-
658
- ixTradePt({
659
- trader,
660
- traderPt,
661
- syConstraint,
662
- isBuy,
663
- tokenPt: tokenPtParam,
664
- tokenSy: tokenSyParam,
665
- }: {
666
- trader: PublicKey
667
- traderPt: bigint
668
- syConstraint: bigint
669
- isBuy: boolean
670
- tokenPt?: PublicKey
671
- tokenSy?: PublicKey
672
- }) {
673
- const tokenPt = tokenPtParam || getAssociatedTokenAddressSync(this.mintPt, trader, true, TOKEN_PROGRAM_ID)
674
- const tokenSy = tokenSyParam || getAssociatedTokenAddressSync(this.mintSy, trader, true, TOKEN_PROGRAM_ID)
675
-
676
- const tokenSyAtaIx = createAssociatedTokenAccountIdempotentInstruction(trader, tokenSy, trader, this.mintSy)
677
- const tokenPtAtaIx = createAssociatedTokenAccountIdempotentInstruction(trader, tokenPt, trader, this.mintPt)
678
-
679
- const remainingAccounts = [
680
- ...this.cpiAccounts.getSyState,
681
- ...this.cpiAccounts.depositSy,
682
- ...this.cpiAccounts.withdrawSy,
683
- ]
684
-
685
- const netTraderPt = isBuy ? traderPt : -traderPt
686
- const syConstraintSigned = isBuy ? -syConstraint : syConstraint
687
-
688
- const ix = exponentCore.createTradePtInstruction(
689
- {
690
- trader,
691
- market: this.selfAddress,
692
- tokenSyTrader: tokenSy,
693
- tokenPtTrader: tokenPt,
694
- tokenSyEscrow: this.tokenSyEscrow,
695
- tokenPtEscrow: this.tokenPtEscrow,
696
- addressLookupTable: this.addressLookupTable,
697
- tokenProgram: TOKEN_PROGRAM_ID,
698
- syProgram: this.syProgram,
699
- tokenFeeTreasurySy: this.vault.state.treasurySyTokenAccount,
700
- eventAuthority: this.vault.eventAuthority,
701
- program: exponentCore.EXPONENTCORE_PROGRAM_ID,
702
- },
703
- { netTraderPt, syConstraint: syConstraintSigned },
704
- )
705
- ix.keys.push(...remainingAccounts)
706
-
707
- return { ixs: [ix], setupIxs: [tokenPtAtaIx, tokenSyAtaIx] }
708
- }
709
-
710
- /** Sell YT for SY
711
- *
712
- * The trader is the account that sends the YT
713
- *
714
- * The amountYt is the exact amount of YT the trader intends to sell
715
- *
716
- * The minSyOut is the minimum amount of SY the trader is willing to receive
717
- *
718
- * The token accounts themselves are optional, and will be derived from the trader's wallet if not provided
719
- */
720
- ixSellYt({
721
- trader,
722
- ytIn,
723
- minSyOut,
724
- ytSrc: ytSrcParam,
725
- ptSrc: ptSrcParam,
726
- syDst: syDstParam,
727
- }: {
728
- trader: PublicKey
729
- ytIn: bigint
730
- minSyOut: bigint
731
- ytSrc?: PublicKey
732
- ptSrc?: PublicKey
733
- syDst?: PublicKey
734
- }) {
735
- const syDst = syDstParam || getAssociatedTokenAddressSync(this.mintSy, trader, true, TOKEN_PROGRAM_ID)
736
- const ptSrc = ptSrcParam || getAssociatedTokenAddressSync(this.mintPt, trader, true, TOKEN_PROGRAM_ID)
737
- const ytSrc = ytSrcParam || getAssociatedTokenAddressSync(this.mintYt, trader, true, TOKEN_PROGRAM_ID)
738
-
739
- const syDstAtaIxs = createAssociatedTokenAccountIdempotentInstruction(trader, syDst, trader, this.mintSy)
740
- const ptSrcAtaIxs = createAssociatedTokenAccountIdempotentInstruction(trader, ptSrc, trader, this.mintPt)
741
- const ytSrcAtaIxs = createAssociatedTokenAccountIdempotentInstruction(trader, ytSrc, trader, this.mintYt)
742
-
743
- const mergeAccounts = this.vault.mergeAccounts({ owner: trader, ytSrc, ptSrc, syDst })
744
- const remainingAccounts = uniqueRemainingAccounts([
745
- ...this.cpiAccounts.getSyState,
746
- ...this.cpiAccounts.depositSy,
747
- ...mergeAccounts.remainingAccounts,
748
- ])
749
- remainingAccounts.push({ pubkey: exponentCore.EXPONENTCORE_PROGRAM_ID, isWritable: false, isSigner: false })
750
-
751
- const ix = exponentCore.createSellYtInstruction(
752
- {
753
- trader,
754
- market: this.selfAddress,
755
- tokenYtTrader: ytSrc,
756
- tokenPtTrader: ptSrc,
757
- tokenSyTrader: syDst,
758
- tokenSyEscrow: this.tokenSyEscrow,
759
- tokenPtEscrow: this.tokenPtEscrow,
760
- addressLookupTable: this.addressLookupTable,
761
- tokenFeeTreasurySy: this.vault.state.treasurySyTokenAccount,
762
- tokenProgram: TOKEN_PROGRAM_ID,
763
- vault: mergeAccounts.mainAccounts.vault,
764
- authorityVault: mergeAccounts.mainAccounts.authority,
765
- tokenSyEscrowVault: mergeAccounts.mainAccounts.escrowSy,
766
- mintYt: this.mintYt,
767
- mintPt: this.mintPt,
768
- addressLookupTableVault: mergeAccounts.mainAccounts.addressLookupTable,
769
- yieldPositionVault: mergeAccounts.mainAccounts.yieldPosition,
770
- syProgram: this.syProgram,
771
- eventAuthority: this.vault.eventAuthority,
772
- program: exponentCore.EXPONENTCORE_PROGRAM_ID,
773
- },
774
- { ytIn, minSyOut },
775
- )
776
- ix.keys.push(...remainingAccounts)
777
-
778
- return { ixs: [ix], setupIxs: [syDstAtaIxs, ptSrcAtaIxs, ytSrcAtaIxs] }
779
- }
780
-
781
- /** Buy YT with SY
782
- *
783
- * The trader is the account that sends the SY
784
- *
785
- * The ytOut is the exact amount of YT the trader intends to buy
786
- *
787
- * The maxSyIn is the maximum amount of SY the trader is willing to spend
788
- *
789
- * The token accounts themselves are optional, and will be derived from the trader's wallet if not provided
790
- */
791
- ixBuyYt({
792
- trader,
793
- ytOut,
794
- maxSyIn,
795
- ytTrader: ytTraderParam,
796
- ptTrader: ptTraderParam,
797
- syTrader: syTraderParam,
798
- }: {
799
- trader: PublicKey
800
- ytOut: bigint
801
- maxSyIn: bigint
802
- ytTrader?: PublicKey
803
- ptTrader?: PublicKey
804
- syTrader?: PublicKey
805
- }) {
806
- const syTrader = syTraderParam || getAssociatedTokenAddressSync(this.mintSy, trader, true, TOKEN_PROGRAM_ID)
807
- const ptTrader = ptTraderParam || getAssociatedTokenAddressSync(this.mintPt, trader, true, TOKEN_PROGRAM_ID)
808
- const ytTrader = ytTraderParam || getAssociatedTokenAddressSync(this.mintYt, trader, true, TOKEN_PROGRAM_ID)
809
-
810
- const syTraderAtaIx = createAssociatedTokenAccountIdempotentInstruction(trader, syTrader, trader, this.mintSy)
811
- const ptTraderAtaIx = createAssociatedTokenAccountIdempotentInstruction(trader, ptTrader, trader, this.mintPt)
812
- const ytTraderAtaIx = createAssociatedTokenAccountIdempotentInstruction(trader, ytTrader, trader, this.mintYt)
813
-
814
- const stripAccounts = this.vault.stripAccounts({
815
- depositor: trader,
816
- ytDst: ytTrader,
817
- ptDst: ptTrader,
818
- sySrc: syTrader,
819
- })
820
-
821
- const remainingAccounts = uniqueRemainingAccounts([
822
- ...this.cpiAccounts.getSyState,
823
- ...this.cpiAccounts.withdrawSy,
824
- ...this.cpiAccounts.depositSy,
825
- ...stripAccounts.remainingAccounts,
826
- ])
827
- remainingAccounts.push({ pubkey: exponentCore.EXPONENTCORE_PROGRAM_ID, isWritable: false, isSigner: false })
828
-
829
- const ix = exponentCore.createBuyYtInstruction(
830
- {
831
- trader,
832
- market: this.selfAddress,
833
- tokenSyTrader: syTrader,
834
- tokenYtTrader: ytTrader,
835
- tokenPtTrader: ptTrader,
836
- tokenSyEscrow: this.tokenSyEscrow,
837
- tokenPtEscrow: this.tokenPtEscrow,
838
- tokenFeeTreasurySy: this.vault.state.treasurySyTokenAccount,
839
- tokenProgram: TOKEN_PROGRAM_ID,
840
- addressLookupTable: this.addressLookupTable,
841
- syProgram: this.syProgram,
842
- vaultAuthority: stripAccounts.mainAccounts.authority,
843
- vault: stripAccounts.mainAccounts.vault,
844
- tokenSyEscrowVault: stripAccounts.mainAccounts.escrowSy,
845
- mintYt: this.mintYt,
846
- mintPt: this.mintPt,
847
- addressLookupTableVault: stripAccounts.mainAccounts.addressLookupTable,
848
- yieldPosition: stripAccounts.mainAccounts.yieldPosition,
849
- eventAuthority: this.vault.eventAuthority,
850
- program: exponentCore.EXPONENTCORE_PROGRAM_ID,
851
- },
852
- { syIn: maxSyIn, ytOut },
853
- )
854
- ix.keys.push(...remainingAccounts)
855
-
856
- return { ixs: [ix], setupIxs: [syTraderAtaIx, ptTraderAtaIx, ytTraderAtaIx] }
857
- }
858
-
859
- ixInitLpPosition({ owner, feePayer }: { owner: PublicKey; feePayer?: PublicKey }): TransactionInstruction {
860
- const lpPosition = this.xponPda.marketLpPosition({ market: this.selfAddress, owner })
861
- return exponentCore.createInitLpPositionInstruction({
862
- feePayer: feePayer || owner,
863
- owner,
864
- market: this.selfAddress,
865
- lpPosition,
866
- systemProgram: SystemProgram.programId,
867
- eventAuthority: this.vault.eventAuthority,
868
- program: exponentCore.EXPONENTCORE_PROGRAM_ID,
869
- })
870
- }
871
-
872
- /** Deposit LP tokens into the farming module to earn rewards */
873
- ixDepositLp({
874
- owner,
875
- amount,
876
- lpSrc: lpSrcParam,
877
- }: {
878
- owner: PublicKey
879
- amount: bigint
880
- lpSrc?: PublicKey
881
- }): TransactionInstruction {
882
- const lpSrc = lpSrcParam || getAssociatedTokenAddressSync(this.mintLp, owner, true, TOKEN_PROGRAM_ID)
883
- const lpPosition = this.xponPda.marketLpPosition({ market: this.selfAddress, owner })
884
-
885
- const ix = exponentCore.createMarketDepositLpInstruction(
886
- {
887
- owner,
888
- market: this.selfAddress,
889
- lpPosition,
890
- tokenLpSrc: lpSrc,
891
- tokenLpEscrow: this.tokenLpEscrow,
892
- mintLp: this.mintLp,
893
- syProgram: this.syProgram,
894
- addressLookupTable: this.addressLookupTable,
895
- tokenProgram: TOKEN_PROGRAM_ID,
896
- systemProgram: SystemProgram.programId,
897
- eventAuthority: this.vault.eventAuthority,
898
- program: exponentCore.EXPONENTCORE_PROGRAM_ID,
899
- },
900
- { amount },
901
- )
902
- ix.keys.push(...this.cpiAccounts.getPositionState)
903
- return ix
904
- }
905
-
906
- /** Withdraw LP tokens from the farming module */
907
- ixWithdrawLp({
908
- owner,
909
- amount,
910
- lpDst: lpDstParam,
911
- }: {
912
- owner: PublicKey
913
- amount: bigint
914
- lpDst?: PublicKey
915
- }): TransactionInstruction {
916
- const lpDst = lpDstParam || getAssociatedTokenAddressSync(this.mintLp, owner, true, TOKEN_PROGRAM_ID)
917
-
918
- const lpPosition = this.xponPda.marketLpPosition({ market: this.selfAddress, owner })
919
- const ix = exponentCore.createMarketWithdrawLpInstruction(
920
- {
921
- owner,
922
- market: this.selfAddress,
923
- mintLp: this.mintLp,
924
- lpPosition,
925
- tokenLpDst: lpDst,
926
- tokenLpEscrow: this.tokenLpEscrow,
927
- syProgram: this.syProgram,
928
- addressLookupTable: this.addressLookupTable,
929
- tokenProgram: TOKEN_PROGRAM_ID,
930
- systemProgram: SystemProgram.programId,
931
- eventAuthority: this.vault.eventAuthority,
932
- program: exponentCore.EXPONENTCORE_PROGRAM_ID,
933
- },
934
- { amount },
935
- )
936
- ix.keys.push(...this.cpiAccounts.getPositionState)
937
- return ix
938
- }
939
-
940
- async ixWrapperCollectInterest({
941
- claimer,
942
- tokenSyDst: tokenSyDstParam,
943
- }: {
944
- claimer: PublicKey
945
- tokenSyDst?: PublicKey
946
- }) {
947
- const yieldPosition = this.xponPda.yieldPosition({ owner: claimer, vault: this.vault.selfAddress })
948
- const tokenSyDst = tokenSyDstParam || getAssociatedTokenAddressSync(this.mintSy, claimer, true, TOKEN_PROGRAM_ID)
949
- const tokenBaseClaimer = getAssociatedTokenAddressSync(
950
- this.flavor.mintBase,
951
- claimer,
952
- true,
953
- this.flavor.baseTokenProgram,
954
- )
955
- const tokenBaseClaimerAtaIx = createAssociatedTokenAccountIdempotentInstruction(
956
- claimer,
957
- tokenBaseClaimer,
958
- claimer,
959
- this.flavor.mintBase,
960
- this.flavor.baseTokenProgram,
961
- )
962
-
963
- const tokenSyClaimer = getAssociatedTokenAddressSync(this.mintSy, claimer, true)
964
- const tokenSyClaimerAtaIx = createAssociatedTokenAccountIdempotentInstruction(
965
- claimer,
966
- tokenSyClaimer,
967
- claimer,
968
- this.mintSy,
969
- )
970
-
971
- const remainingAccounts = uniqueRemainingAccounts([
972
- ...this.vault.cpiAccounts.getSyState,
973
- ...this.vault.cpiAccounts.withdrawSy,
974
- ])
975
-
976
- const redeemSyIx = await this.flavor.ixRedeemSy({
977
- amountSy: "0",
978
- redeemer: claimer,
979
- redeemerBaseTokenAccount: tokenBaseClaimer,
980
- redeemerSyTokenAccount: tokenSyDst,
981
- })
982
-
983
- const ix = exponentCore.createWrapperCollectInterestInstruction(
984
- {
985
- claimer,
986
- authority: this.vault.state.authority,
987
- vault: this.vault.selfAddress,
988
- addressLookupTable: this.vault.addressLookupTable,
989
- escrowSy: this.vault.escrowSy,
990
- syProgram: this.syProgram,
991
- tokenProgram: TOKEN_PROGRAM_ID,
992
- yieldPosition,
993
- tokenSyDst,
994
- treasurySyTokenAccount: this.vault.state.treasurySyTokenAccount,
995
- eventAuthority: this.vault.eventAuthority,
996
- program: exponentCore.EXPONENTCORE_PROGRAM_ID,
997
- },
998
- { redeemSyAccountsLength: redeemSyIx.keys.length },
999
- )
1000
- ix.keys.push(...redeemSyIx.keys.concat(remainingAccounts))
1001
-
1002
- return {
1003
- ixs: [
1004
- ...(await this.flavor.preIxs({ signer: claimer })),
1005
- ix,
1006
- ...(await this.flavor.postIxs({ signer: claimer })),
1007
- ],
1008
- setupIxs: [tokenBaseClaimerAtaIx, tokenSyClaimerAtaIx],
1009
- }
1010
- }
1011
-
1012
- async ixWrapperBuyPt({
1013
- owner,
1014
- ptOut,
1015
- maxBaseIn,
1016
- tokenSyTrader: tokenSyTraderParam,
1017
- tokenPtTrader: tokenPtTraderParam,
1018
- tokenBaseTrader: tokenBaseTraderParam,
1019
- }: {
1020
- owner: PublicKey
1021
- ptOut: bigint
1022
- maxBaseIn: bigint
1023
- tokenSyTrader?: PublicKey
1024
- tokenPtTrader?: PublicKey
1025
- tokenBaseTrader?: PublicKey
1026
- }) {
1027
- const tokenSyTrader =
1028
- tokenSyTraderParam || getAssociatedTokenAddressSync(this.mintSy, owner, true, TOKEN_PROGRAM_ID)
1029
- const tokenPtTrader =
1030
- tokenPtTraderParam || getAssociatedTokenAddressSync(this.mintPt, owner, true, TOKEN_PROGRAM_ID)
1031
- const tokenBaseTrader =
1032
- tokenBaseTraderParam ||
1033
- getAssociatedTokenAddressSync(this.flavor.mintBase, owner, true, this.flavor.baseTokenProgram)
1034
-
1035
- const tokenSyTraderAtaIx = createAssociatedTokenAccountIdempotentInstruction(
1036
- owner,
1037
- tokenSyTrader,
1038
- owner,
1039
- this.mintSy,
1040
- )
1041
- const tokenPtTraderAtaIx = createAssociatedTokenAccountIdempotentInstruction(
1042
- owner,
1043
- tokenPtTrader,
1044
- owner,
1045
- this.mintPt,
1046
- )
1047
- const tokenBaseTraderAtaIx = createAssociatedTokenAccountIdempotentInstruction(
1048
- owner,
1049
- tokenBaseTrader,
1050
- owner,
1051
- this.flavor.mintBase,
1052
- this.flavor.baseTokenProgram,
1053
- )
1054
-
1055
- const mintSyIx = await this.flavor.ixMintSy({
1056
- amountBase: "0",
1057
- depositor: owner,
1058
- depositorBaseTokenAccount: tokenBaseTrader,
1059
- depositorSyTokenAccount: tokenSyTrader,
1060
- })
1061
-
1062
- const mintSyRemAccounts = mintSyIx.keys
1063
-
1064
- mintSyRemAccounts.push({
1065
- pubkey: exponentCore.EXPONENTCORE_PROGRAM_ID,
1066
- isWritable: false,
1067
- isSigner: false,
1068
- })
1069
-
1070
- const remainingAccounts = uniqueRemainingAccounts([
1071
- ...this.cpiAccounts.getSyState,
1072
- ...this.cpiAccounts.depositSy,
1073
- ])
1074
-
1075
- const ix = exponentCore.createWrapperBuyPtInstruction(
1076
- {
1077
- buyer: owner,
1078
- market: this.selfAddress,
1079
- tokenSyTrader,
1080
- tokenPtTrader,
1081
- tokenSyEscrow: this.tokenSyEscrow,
1082
- tokenPtEscrow: this.tokenPtEscrow,
1083
- addressLookupTable: this.addressLookupTable,
1084
- tokenProgram: TOKEN_PROGRAM_ID,
1085
- syProgram: this.syProgram,
1086
- tokenFeeTreasurySy: this.state.tokenFeeTreasurySy,
1087
- eventAuthority: this.vault.eventAuthority,
1088
- program: exponentCore.EXPONENTCORE_PROGRAM_ID,
1089
- },
1090
- { ptAmount: ptOut, maxBaseAmount: maxBaseIn, mintSyRemAccountsUntil: mintSyRemAccounts.length - 1 },
1091
- )
1092
- ix.keys.push(...mintSyRemAccounts.concat(remainingAccounts))
1093
-
1094
- return {
1095
- ixs: [...(await this.flavor.preIxs({ signer: owner })), ix, ...(await this.flavor.postIxs({ signer: owner }))],
1096
- setupIxs: [tokenSyTraderAtaIx, tokenPtTraderAtaIx, tokenBaseTraderAtaIx],
1097
- }
1098
- }
1099
-
1100
- async ixWrapperSellPt({
1101
- owner,
1102
- amount,
1103
- minBaseOut,
1104
- tokenSyTrader: tokenSyTraderParam,
1105
- tokenPtTrader: tokenPtTraderParam,
1106
- tokenBaseTrader: tokenBaseTraderParam,
1107
- }: {
1108
- owner: PublicKey
1109
- amount: bigint
1110
- minBaseOut: bigint
1111
- tokenSyTrader?: PublicKey
1112
- tokenPtTrader?: PublicKey
1113
- tokenBaseTrader?: PublicKey
1114
- }) {
1115
- const tokenSyTrader =
1116
- tokenSyTraderParam || getAssociatedTokenAddressSync(this.mintSy, owner, true, TOKEN_PROGRAM_ID)
1117
- const tokenPtTrader =
1118
- tokenPtTraderParam || getAssociatedTokenAddressSync(this.mintPt, owner, true, TOKEN_PROGRAM_ID)
1119
- const tokenBaseTrader =
1120
- tokenBaseTraderParam ||
1121
- getAssociatedTokenAddressSync(this.flavor.mintBase, owner, true, this.flavor.baseTokenProgram)
1122
-
1123
- const tokenSyTraderAtaIx = createAssociatedTokenAccountIdempotentInstruction(
1124
- owner,
1125
- tokenSyTrader,
1126
- owner,
1127
- this.mintSy,
1128
- )
1129
- const tokenPtTraderAtaIx = createAssociatedTokenAccountIdempotentInstruction(
1130
- owner,
1131
- tokenPtTrader,
1132
- owner,
1133
- this.mintPt,
1134
- )
1135
- const tokenBaseTraderAtaIx = createAssociatedTokenAccountIdempotentInstruction(
1136
- owner,
1137
- tokenBaseTrader,
1138
- owner,
1139
- this.flavor.mintBase,
1140
- this.flavor.baseTokenProgram,
1141
- )
1142
-
1143
- const redeemSyIx = await this.flavor.ixRedeemSy({
1144
- amountSy: "0",
1145
- redeemer: owner,
1146
- redeemerBaseTokenAccount: tokenBaseTrader,
1147
- redeemerSyTokenAccount: tokenSyTrader,
1148
- })
1149
-
1150
- const redeemSyRemAccounts = redeemSyIx.keys
1151
-
1152
- const remainingAccounts = uniqueRemainingAccounts([...this.cpiAccounts.getSyState, ...this.cpiAccounts.withdrawSy])
1153
-
1154
- const ix = exponentCore.createWrapperSellPtInstruction(
1155
- {
1156
- seller: owner,
1157
- market: this.selfAddress,
1158
- tokenSyTrader,
1159
- tokenPtTrader,
1160
- tokenSyEscrow: this.tokenSyEscrow,
1161
- tokenPtEscrow: this.tokenPtEscrow,
1162
- addressLookupTable: this.addressLookupTable,
1163
- tokenProgram: TOKEN_PROGRAM_ID,
1164
- syProgram: this.syProgram,
1165
- tokenFeeTreasurySy: this.state.tokenFeeTreasurySy,
1166
- eventAuthority: this.vault.eventAuthority,
1167
- program: exponentCore.EXPONENTCORE_PROGRAM_ID,
1168
- },
1169
- { amountPt: amount, minBaseAmount: minBaseOut, redeemSyRemAccountsUntil: redeemSyRemAccounts.length },
1170
- )
1171
- ix.keys.push(...redeemSyRemAccounts.concat(remainingAccounts))
1172
-
1173
- return {
1174
- ixs: [...(await this.flavor.preIxs({ signer: owner })), ix, ...(await this.flavor.postIxs({ signer: owner }))],
1175
- setupIxs: [tokenSyTraderAtaIx, tokenPtTraderAtaIx, tokenBaseTraderAtaIx],
1176
- }
1177
- }
1178
-
1179
- async ixWrapperBuyYt({
1180
- owner,
1181
- ytOut,
1182
- maxBaseIn,
1183
- tokenSyTrader: tokenSyTraderParam,
1184
- tokenPtTrader: tokenPtTraderParam,
1185
- tokenYtTrader: tokenYtTraderParam,
1186
- tokenBaseTrader: tokenBaseTraderParam,
1187
- }: {
1188
- owner: PublicKey
1189
- ytOut: bigint
1190
- maxBaseIn: bigint
1191
- tokenSyTrader?: PublicKey
1192
- tokenPtTrader?: PublicKey
1193
- tokenYtTrader?: PublicKey
1194
- tokenBaseTrader?: PublicKey
1195
- }) {
1196
- const tokenSyTrader =
1197
- tokenSyTraderParam || getAssociatedTokenAddressSync(this.mintSy, owner, true, TOKEN_PROGRAM_ID)
1198
- const tokenPtTrader =
1199
- tokenPtTraderParam || getAssociatedTokenAddressSync(this.mintPt, owner, true, TOKEN_PROGRAM_ID)
1200
- const tokenYtTrader =
1201
- tokenYtTraderParam || getAssociatedTokenAddressSync(this.mintYt, owner, true, TOKEN_PROGRAM_ID)
1202
- const tokenBaseTrader =
1203
- tokenBaseTraderParam ||
1204
- getAssociatedTokenAddressSync(this.flavor.mintBase, owner, true, this.flavor.baseTokenProgram)
1205
-
1206
- const tokenSyTraderAtaIx = createAssociatedTokenAccountIdempotentInstruction(
1207
- owner,
1208
- tokenSyTrader,
1209
- owner,
1210
- this.mintSy,
1211
- )
1212
- const tokenPtTraderAtaIx = createAssociatedTokenAccountIdempotentInstruction(
1213
- owner,
1214
- tokenPtTrader,
1215
- owner,
1216
- this.mintPt,
1217
- )
1218
- const tokenYtTraderAtaIx = createAssociatedTokenAccountIdempotentInstruction(
1219
- owner,
1220
- tokenYtTrader,
1221
- owner,
1222
- this.mintYt,
1223
- )
1224
-
1225
- const mintSyIx = await this.flavor.ixMintSy({
1226
- amountBase: "0",
1227
- depositor: owner,
1228
- depositorBaseTokenAccount: tokenBaseTrader,
1229
- depositorSyTokenAccount: tokenSyTrader,
1230
- })
1231
-
1232
- const mintSyRemAccounts = mintSyIx.keys
1233
-
1234
- const remainingAccounts = uniqueRemainingAccounts([
1235
- ...this.cpiAccounts.getSyState,
1236
- ...this.vault.cpiAccounts.depositSy,
1237
- ...this.vault.cpiAccounts.getSyState,
1238
- ...this.cpiAccounts.withdrawSy,
1239
- ...this.cpiAccounts.getPositionState,
1240
- ])
1241
-
1242
- const allRemainingAccounts = mintSyRemAccounts.concat(remainingAccounts)
1243
-
1244
- const ix1 = exponentCore.createWrapperBuyYtInstruction(
1245
- {
1246
- buyer: owner,
1247
- market: this.selfAddress,
1248
- tokenSyTrader,
1249
- tokenYtTrader,
1250
- tokenPtTrader,
1251
- tokenSyEscrow: this.tokenSyEscrow,
1252
- tokenPtEscrow: this.tokenPtEscrow,
1253
- marketAddressLookupTable: this.addressLookupTable,
1254
- tokenProgram: TOKEN_PROGRAM_ID,
1255
- syProgram: this.syProgram,
1256
- vaultAuthority: this.vault.authority,
1257
- vault: this.vault.selfAddress,
1258
- tokenSyEscrowVault: this.vault.escrowSy,
1259
- mintYt: this.vault.mintYt,
1260
- mintPt: this.vault.mintPt,
1261
- vaultAddressLookupTable: this.vault.addressLookupTable,
1262
- userYieldPosition: this.xponPda.yieldPosition({ vault: this.vault.selfAddress, owner }),
1263
- yieldPosition: this.vault.state.yieldPositonAddress,
1264
- escrowYt: this.vault.escrowYt,
1265
- systemProgram: SystemProgram.programId,
1266
- tokenFeeTreasurySy: this.state.tokenFeeTreasurySy,
1267
- eventAuthority: this.vault.eventAuthority,
1268
- program: exponentCore.EXPONENTCORE_PROGRAM_ID,
1269
- },
1270
- { ytOut, maxBaseAmount: maxBaseIn, mintSyAccountsLength: mintSyRemAccounts.length },
1271
- )
1272
- ix1.keys.push(...allRemainingAccounts)
1273
-
1274
- return {
1275
- ixs: [...(await this.flavor.preIxs({ signer: owner })), ix1, ...(await this.flavor.postIxs({ signer: owner }))],
1276
- setupIxs: [tokenSyTraderAtaIx, tokenPtTraderAtaIx, tokenYtTraderAtaIx],
1277
- }
1278
- }
1279
-
1280
- async ixWrapperSellYt({
1281
- owner,
1282
- amount,
1283
- minBaseOut,
1284
- tokenBaseTrader: tokenBaseTraderParam,
1285
- tokenSyTrader: tokenSyTraderParam,
1286
- tokenYtTrader: tokenYtTraderParam,
1287
- tokenPtTrader: tokenPtTraderParam,
1288
- }: {
1289
- owner: PublicKey
1290
- amount: bigint
1291
- minBaseOut: bigint
1292
- tokenBaseTrader?: PublicKey
1293
- tokenSyTrader?: PublicKey
1294
- tokenYtTrader?: PublicKey
1295
- tokenPtTrader?: PublicKey
1296
- }) {
1297
- const tokenBaseTrader =
1298
- tokenBaseTraderParam ||
1299
- getAssociatedTokenAddressSync(this.flavor.mintBase, owner, true, this.flavor.baseTokenProgram)
1300
- const tokenSyTrader =
1301
- tokenSyTraderParam || getAssociatedTokenAddressSync(this.mintSy, owner, true, TOKEN_PROGRAM_ID)
1302
- const tokenYtTrader =
1303
- tokenYtTraderParam || getAssociatedTokenAddressSync(this.mintYt, owner, true, TOKEN_PROGRAM_ID)
1304
- const tokenPtTrader =
1305
- tokenPtTraderParam || getAssociatedTokenAddressSync(this.mintPt, owner, true, TOKEN_PROGRAM_ID)
1306
-
1307
- const tokenSyTraderAtaIx = createAssociatedTokenAccountIdempotentInstruction(
1308
- owner,
1309
- tokenSyTrader,
1310
- owner,
1311
- this.mintSy,
1312
- )
1313
- const tokenPtTraderAtaIx = createAssociatedTokenAccountIdempotentInstruction(
1314
- owner,
1315
- tokenPtTrader,
1316
- owner,
1317
- this.mintPt,
1318
- )
1319
- const tokenYtTraderAtaIx = createAssociatedTokenAccountIdempotentInstruction(
1320
- owner,
1321
- tokenYtTrader,
1322
- owner,
1323
- this.mintYt,
1324
- )
1325
- const tokenBaseTraderAtaIx = createAssociatedTokenAccountIdempotentInstruction(
1326
- owner,
1327
- tokenBaseTrader,
1328
- owner,
1329
- this.flavor.mintBase,
1330
- this.flavor.baseTokenProgram,
1331
- )
1332
-
1333
- const redeemSyIx = await this.flavor.ixRedeemSy({
1334
- amountSy: "0",
1335
- redeemer: owner,
1336
- redeemerBaseTokenAccount: tokenBaseTrader,
1337
- redeemerSyTokenAccount: tokenSyTrader,
1338
- })
1339
-
1340
- const redeemSyRemAccounts = redeemSyIx.keys
1341
-
1342
- const remainingAccounts = uniqueRemainingAccounts([
1343
- ...this.cpiAccounts.getSyState,
1344
- ...this.cpiAccounts.withdrawSy,
1345
- ...this.vault.cpiAccounts.depositSy,
1346
- ])
1347
-
1348
- const ix1 = exponentCore.createWithdrawYtInstruction(
1349
- {
1350
- owner,
1351
- vault: this.vault.selfAddress,
1352
- userYieldPosition: this.xponPda.yieldPosition({ vault: this.vault.selfAddress, owner }),
1353
- ytDst: tokenYtTrader,
1354
- escrowYt: this.vault.escrowYt,
1355
- tokenProgram: TOKEN_PROGRAM_ID,
1356
- authority: this.vault.authority,
1357
- syProgram: this.syProgram,
1358
- addressLookupTable: this.vault.addressLookupTable,
1359
- yieldPosition: this.vault.state.yieldPositonAddress,
1360
- systemProgram: SystemProgram.programId,
1361
- eventAuthority: this.vault.eventAuthority,
1362
- program: exponentCore.EXPONENTCORE_PROGRAM_ID,
1363
- },
1364
- { amount },
1365
- )
1366
- ix1.keys.push(...remainingAccounts)
1367
-
1368
- const ix2 = exponentCore.createWrapperSellYtInstruction(
1369
- {
1370
- seller: owner,
1371
- market: this.selfAddress,
1372
- tokenSyTrader,
1373
- tokenYtTrader,
1374
- tokenPtTrader,
1375
- tokenSyEscrow: this.tokenSyEscrow,
1376
- tokenPtEscrow: this.tokenPtEscrow,
1377
- marketAddressLookupTable: this.addressLookupTable,
1378
- tokenProgram: TOKEN_PROGRAM_ID,
1379
- syProgram: this.syProgram,
1380
- vaultAuthority: this.vault.authority,
1381
- vault: this.vault.selfAddress,
1382
- tokenSyEscrowVault: this.vault.escrowSy,
1383
- mintYt: this.vault.mintYt,
1384
- mintPt: this.vault.mintPt,
1385
- vaultAddressLookupTable: this.vault.addressLookupTable,
1386
- yieldPosition: this.vault.state.yieldPositonAddress,
1387
- tokenFeeTreasurySy: this.state.tokenFeeTreasurySy,
1388
- eventAuthority: this.vault.eventAuthority,
1389
- program: exponentCore.EXPONENTCORE_PROGRAM_ID,
1390
- },
1391
- { ytAmount: amount, minBaseAmount: minBaseOut, redeemSyAccountsUntil: redeemSyRemAccounts.length },
1392
- )
1393
- ix2.keys.push(...redeemSyRemAccounts.concat(remainingAccounts))
1394
-
1395
- return {
1396
- ixs: [
1397
- ix1,
1398
- ...(await this.flavor.preIxs({ signer: owner })),
1399
- ix2,
1400
- ...(await this.flavor.postIxs({ signer: owner })),
1401
- ],
1402
- setupIxs: [tokenSyTraderAtaIx, tokenPtTraderAtaIx, tokenYtTraderAtaIx, tokenBaseTraderAtaIx],
1403
- }
1404
- }
1405
-
1406
- ixCollectMarketEmission({
1407
- owner,
1408
- emissionIndex,
1409
- emissionDst,
1410
- }: {
1411
- owner: PublicKey
1412
- emissionIndex: number
1413
- emissionDst?: PublicKey
1414
- }) {
1415
- const emission = this.emissions[emissionIndex]
1416
- const tokenEmissionDst =
1417
- emissionDst || getAssociatedTokenAddressSync(emission.mint, owner, true, emission.tokenProgramAddress)
1418
-
1419
- const tokenEmissionDstIx = createAssociatedTokenAccountIdempotentInstruction(
1420
- owner,
1421
- tokenEmissionDst,
1422
- owner,
1423
- emission.mint,
1424
- )
1425
- const ix = exponentCore.createMarketCollectEmissionInstruction(
1426
- {
1427
- owner,
1428
- market: this.selfAddress,
1429
- lpPosition: this.xponPda.marketLpPosition({ market: this.selfAddress, owner }),
1430
- tokenEmissionEscrow: this.marketEmissions.trackers[emissionIndex].tokenEscrow,
1431
- tokenEmissionDst,
1432
- tokenProgram: emission.tokenProgramAddress,
1433
- addressLookupTable: this.addressLookupTable,
1434
- syProgram: this.syProgram,
1435
- eventAuthority: this.eventAuthority,
1436
- program: exponentCore.EXPONENTCORE_PROGRAM_ID,
1437
- },
1438
- { emissionIndex },
1439
- )
1440
- ix.keys.push(...this.cpiAccounts.claimEmission[emissionIndex])
1441
-
1442
- return {
1443
- ixs: [ix],
1444
- setupIxs: [tokenEmissionDstIx],
1445
- }
1446
- }
1447
-
1448
- /** Provide liquidity from a base asset - and receive YT and LP tokens in return */
1449
- async ixProvideLiquidityNoPriceImpact({
1450
- depositor,
1451
- amountBase,
1452
- minLpOut,
1453
- tokenSyDepositor: tokenSyDepositorParam,
1454
- tokenYtDepositor: tokenYtDepositorParam,
1455
- tokenPtDepositor: tokenPtDepositorParam,
1456
- tokenBaseDepositor: tokenBaseDepositorParam,
1457
- tokenLpDepositor: tokenLpDepositorParam,
1458
- }: {
1459
- depositor: PublicKey
1460
- amountBase: bigint
1461
- minLpOut: bigint
1462
- tokenSyDepositor?: PublicKey
1463
- tokenYtDepositor?: PublicKey
1464
- tokenPtDepositor?: PublicKey
1465
- tokenBaseDepositor?: PublicKey
1466
- tokenLpDepositor?: PublicKey
1467
- }) {
1468
- const tokenSyDepositor =
1469
- tokenSyDepositorParam || getAssociatedTokenAddressSync(this.mintSy, depositor, true, TOKEN_PROGRAM_ID)
1470
- const tokenYtDepositor =
1471
- tokenYtDepositorParam || getAssociatedTokenAddressSync(this.mintYt, depositor, true, TOKEN_PROGRAM_ID)
1472
- const tokenPtDepositor =
1473
- tokenPtDepositorParam || getAssociatedTokenAddressSync(this.mintPt, depositor, true, TOKEN_PROGRAM_ID)
1474
- const tokenBaseDepositor =
1475
- tokenBaseDepositorParam ||
1476
- getAssociatedTokenAddressSync(this.flavor.mintBase, depositor, true, this.flavor.baseTokenProgram)
1477
- const tokenLpDepositor =
1478
- tokenLpDepositorParam || getAssociatedTokenAddressSync(this.mintLp, depositor, true, TOKEN_PROGRAM_ID)
1479
-
1480
- console.log("Mint Base: ", this.flavor.mintBase.toBase58())
1481
-
1482
- const tokenSyDepositorAtaIx = createAssociatedTokenAccountIdempotentInstruction(
1483
- depositor,
1484
- tokenSyDepositor,
1485
- depositor,
1486
- this.mintSy,
1487
- )
1488
- const tokenYtDepositorAtaIx = createAssociatedTokenAccountIdempotentInstruction(
1489
- depositor,
1490
- tokenYtDepositor,
1491
- depositor,
1492
- this.mintYt,
1493
- )
1494
- const tokenPtDepositorAtaIx = createAssociatedTokenAccountIdempotentInstruction(
1495
- depositor,
1496
- tokenPtDepositor,
1497
- depositor,
1498
- this.mintPt,
1499
- )
1500
-
1501
- const tokenLpDepositorAtaIx = createAssociatedTokenAccountIdempotentInstruction(
1502
- depositor,
1503
- tokenLpDepositor,
1504
- depositor,
1505
- this.mintLp,
1506
- )
1507
-
1508
- // amountBase and minLpOut are already bigint
1509
-
1510
- // TODO - fix this
1511
- const mintSyIx = await this.flavor.ixMintSy({
1512
- // argument does not matter - since we are just getting the keys
1513
- amountBase: "0",
1514
- depositor,
1515
- depositorBaseTokenAccount: tokenBaseDepositor,
1516
- depositorSyTokenAccount: tokenSyDepositor,
1517
- })
1518
-
1519
- const mintSyRemAccounts = mintSyIx.keys
1520
-
1521
- const beforeVaultAccounts = [...this.vault.cpiAccounts.getSyState, ...this.vault.cpiAccounts.depositSy]
1522
- // Log vault accounts before filtering
1523
- // console.log("Before filtering vault accounts:", beforeVaultAccounts.length, "accounts")
1524
-
1525
- // Filter out TOKEN_PROGRAM_ID and SystemProgram.programId from vault remaining accounts
1526
- const vaultCpiRemainingAccounts = beforeVaultAccounts.filter(
1527
- (account) => account.pubkey.toBase58() !== TOKEN_PROGRAM_ID.toBase58(),
1528
- )
1529
-
1530
- // Log vault accounts after filtering
1531
- // console.log("After filtering vault accounts:", vaultCpiRemainingAccounts.length, "accounts")
1532
-
1533
- // Log market accounts before filtering
1534
- const beforeMarketAccounts = [...this.cpiAccounts.depositSy]
1535
- // console.log("Before filtering market accounts:", beforeMarketAccounts.length, "accounts")
1536
-
1537
- // Filter out TOKEN_PROGRAM_ID and SystemProgram.programId from market remaining accounts
1538
- const marketCpiRemainingAccounts = beforeMarketAccounts.filter(
1539
- (account) =>
1540
- account.pubkey.toBase58() !== TOKEN_PROGRAM_ID.toBase58() &&
1541
- account.pubkey.toBase58() !== SystemProgram.programId.toBase58() &&
1542
- account.pubkey.toBase58() !== this.selfAddress.toBase58(),
1543
- )
1544
-
1545
- // Log market accounts after filtering
1546
- // console.log("After filtering market accounts:", marketCpiRemainingAccounts.length, "accounts")
1547
-
1548
- // These remaining accounts can be in any order, and they can be unique-ified
1549
- const unorderedRemainingAccounts = uniqueRemainingAccounts([
1550
- ...vaultCpiRemainingAccounts,
1551
- ...marketCpiRemainingAccounts,
1552
- ])
1553
-
1554
- const allRemainingAccounts = [...mintSyRemAccounts, ...unorderedRemainingAccounts]
1555
-
1556
- const lpPosition = this.xponPda.marketLpPosition({ market: this.selfAddress, owner: depositor })
1557
-
1558
- const ix = exponentCore.createWrapperProvideLiquidityInstruction(
1559
- {
1560
- depositor,
1561
- authority: this.vault.authority,
1562
- vault: this.vault.selfAddress,
1563
- market: this.selfAddress,
1564
- tokenPtEscrow: this.tokenPtEscrow,
1565
- tokenSyEscrow: this.tokenSyEscrow,
1566
- tokenLpDst: tokenLpDepositor,
1567
- mintLp: this.mintLp,
1568
- tokenSyDepositor,
1569
- escrowSy: this.vault.escrowSy,
1570
- tokenYtDepositor,
1571
- tokenPtDepositor,
1572
- mintYt: this.vault.mintYt,
1573
- mintPt: this.vault.mintPt,
1574
- tokenProgram: TOKEN_PROGRAM_ID,
1575
- vaultAddressLookupTable: this.vault.addressLookupTable,
1576
- marketAddressLookupTable: this.addressLookupTable,
1577
- syProgram: this.syProgram,
1578
- userYieldPosition: this.xponPda.yieldPosition({ vault: this.vault.selfAddress, owner: depositor }),
1579
- escrowYt: this.vault.escrowYt,
1580
- tokenLpEscrow: this.tokenLpEscrow,
1581
- lpPosition,
1582
- vaultRobotYieldPosition: this.vault.state.yieldPositonAddress,
1583
- systemProgram: SystemProgram.programId,
1584
- eventAuthority: this.vault.eventAuthority,
1585
- program: exponentCore.EXPONENTCORE_PROGRAM_ID,
1586
- },
1587
- { amountBase, minLpOut, mintBaseAccountsUntil: mintSyRemAccounts.length },
1588
- )
1589
- ix.keys.push(...allRemainingAccounts)
1590
-
1591
- return {
1592
- ixs: [
1593
- ...(await this.flavor.preIxs({ signer: depositor })),
1594
- ix,
1595
- ...(await this.flavor.postIxs({ signer: depositor })),
1596
- ],
1597
- setupIxs: [tokenSyDepositorAtaIx, tokenYtDepositorAtaIx, tokenPtDepositorAtaIx, tokenLpDepositorAtaIx],
1598
- }
1599
- }
1600
-
1601
- async ixProvideLiquidityBase({
1602
- depositor,
1603
- amountBase,
1604
- minLpOut,
1605
- externalPtToBuy,
1606
- externalSyConstraint,
1607
- tokenSyDepositor: tokenSyDepositorParam,
1608
- tokenYtDepositor: tokenYtDepositorParam,
1609
- tokenPtDepositor: tokenPtDepositorParam,
1610
- tokenBaseDepositor: tokenBaseDepositorParam,
1611
- tokenLpDepositor: tokenLpDepositorParam,
1612
- }: {
1613
- depositor: PublicKey
1614
- amountBase: bigint
1615
- minLpOut: bigint
1616
- externalPtToBuy: bigint
1617
- externalSyConstraint: bigint
1618
- tokenSyDepositor?: PublicKey
1619
- tokenYtDepositor?: PublicKey
1620
- tokenPtDepositor?: PublicKey
1621
- tokenBaseDepositor?: PublicKey
1622
- tokenLpDepositor?: PublicKey
1623
- }) {
1624
- const tokenSyDepositor =
1625
- tokenSyDepositorParam || getAssociatedTokenAddressSync(this.mintSy, depositor, true, TOKEN_PROGRAM_ID)
1626
- const tokenYtDepositor =
1627
- tokenYtDepositorParam || getAssociatedTokenAddressSync(this.mintYt, depositor, true, TOKEN_PROGRAM_ID)
1628
- const tokenPtDepositor =
1629
- tokenPtDepositorParam || getAssociatedTokenAddressSync(this.mintPt, depositor, true, TOKEN_PROGRAM_ID)
1630
- const tokenBaseDepositor =
1631
- tokenBaseDepositorParam ||
1632
- getAssociatedTokenAddressSync(this.flavor.mintBase, depositor, true, this.flavor.baseTokenProgram)
1633
- const tokenLpDepositor =
1634
- tokenLpDepositorParam || getAssociatedTokenAddressSync(this.mintLp, depositor, true, TOKEN_PROGRAM_ID)
1635
-
1636
- const tokenSyAtaIx = createAssociatedTokenAccountIdempotentInstruction(
1637
- depositor,
1638
- tokenSyDepositor,
1639
- depositor,
1640
- this.mintSy,
1641
- )
1642
- const tokenYtAtaIx = createAssociatedTokenAccountIdempotentInstruction(
1643
- depositor,
1644
- tokenYtDepositor,
1645
- depositor,
1646
- this.mintYt,
1647
- )
1648
- const tokenPtAtaIx = createAssociatedTokenAccountIdempotentInstruction(
1649
- depositor,
1650
- tokenPtDepositor,
1651
- depositor,
1652
- this.mintPt,
1653
- )
1654
- const tokenBaseAtaIx = createAssociatedTokenAccountIdempotentInstruction(
1655
- depositor,
1656
- tokenBaseDepositor,
1657
- depositor,
1658
- this.flavor.mintBase,
1659
- this.flavor.baseTokenProgram,
1660
- )
1661
- const tokenLpAtaIx = createAssociatedTokenAccountIdempotentInstruction(
1662
- depositor,
1663
- tokenLpDepositor,
1664
- depositor,
1665
- this.mintLp,
1666
- )
1667
-
1668
- const lpPosition = this.xponPda.marketLpPosition({ market: this.selfAddress, owner: depositor })
1669
-
1670
- const remainingAccounts = uniqueRemainingAccounts([
1671
- ...this.cpiAccounts.depositSy,
1672
- ...this.cpiAccounts.getPositionState,
1673
- ])
1674
-
1675
- const mintSyIx = await this.flavor.ixMintSy({
1676
- amountBase: "0",
1677
- depositor,
1678
- depositorBaseTokenAccount: tokenBaseDepositor,
1679
- depositorSyTokenAccount: tokenSyDepositor,
1680
- })
1681
-
1682
- const mintSyRemAccounts = mintSyIx.keys
1683
-
1684
- const ix = exponentCore.createWrapperProvideLiquidityBaseInstruction(
1685
- {
1686
- depositor,
1687
- market: this.selfAddress,
1688
- tokenPtEscrow: this.tokenPtEscrow,
1689
- tokenSyEscrow: this.tokenSyEscrow,
1690
- tokenLpDst: tokenLpDepositor,
1691
- mintLp: this.mintLp,
1692
- tokenSyDepositor,
1693
- tokenPtDepositor,
1694
- tokenProgram: TOKEN_PROGRAM_ID,
1695
- marketAddressLookupTable: this.addressLookupTable,
1696
- syProgram: this.syProgram,
1697
- tokenFeeTreasurySy: this.state.tokenFeeTreasurySy,
1698
- tokenLpEscrow: this.tokenLpEscrow,
1699
- lpPosition,
1700
- systemProgram: SystemProgram.programId,
1701
- eventAuthority: this.vault.eventAuthority,
1702
- program: exponentCore.EXPONENTCORE_PROGRAM_ID,
1703
- },
1704
- { amountBase, minLpOut, mintSyAccountsUntil: mintSyRemAccounts.length, externalPtToBuy, externalSyConstraint },
1705
- )
1706
- ix.keys.push(...mintSyRemAccounts.concat(remainingAccounts))
1707
-
1708
- return {
1709
- ixs: [
1710
- ...(await this.flavor.preIxs({ signer: depositor })),
1711
- ix,
1712
- ...(await this.flavor.postIxs({ signer: depositor })),
1713
- ],
1714
- setupIxs: [tokenSyAtaIx, tokenYtAtaIx, tokenPtAtaIx, tokenBaseAtaIx, tokenLpAtaIx],
1715
- }
1716
- }
1717
-
1718
- async ixProvideLiquidityClassic({
1719
- depositor,
1720
- amountBase,
1721
- amountPt,
1722
- minLpOut,
1723
- tokenSyDepositor: tokenSyDepositorParam,
1724
- tokenYtDepositor: tokenYtDepositorParam,
1725
- tokenPtDepositor: tokenPtDepositorParam,
1726
- tokenBaseDepositor: tokenBaseDepositorParam,
1727
- tokenLpDepositor: tokenLpDepositorParam,
1728
- }: {
1729
- depositor: PublicKey
1730
- amountBase: bigint
1731
- amountPt: bigint
1732
- minLpOut: bigint
1733
- tokenSyDepositor?: PublicKey
1734
- tokenYtDepositor?: PublicKey
1735
- tokenPtDepositor?: PublicKey
1736
- tokenBaseDepositor?: PublicKey
1737
- tokenLpDepositor?: PublicKey
1738
- }) {
1739
- const tokenSyDepositor =
1740
- tokenSyDepositorParam || getAssociatedTokenAddressSync(this.mintSy, depositor, true, TOKEN_PROGRAM_ID)
1741
- const tokenYtDepositor =
1742
- tokenYtDepositorParam || getAssociatedTokenAddressSync(this.mintYt, depositor, true, TOKEN_PROGRAM_ID)
1743
- const tokenPtDepositor =
1744
- tokenPtDepositorParam || getAssociatedTokenAddressSync(this.mintPt, depositor, true, TOKEN_PROGRAM_ID)
1745
- const tokenBaseDepositor =
1746
- tokenBaseDepositorParam ||
1747
- getAssociatedTokenAddressSync(this.flavor.mintBase, depositor, true, this.flavor.baseTokenProgram)
1748
- const tokenLpDepositor =
1749
- tokenLpDepositorParam || getAssociatedTokenAddressSync(this.mintLp, depositor, true, TOKEN_PROGRAM_ID)
1750
-
1751
- const tokenSyAtaIx = createAssociatedTokenAccountIdempotentInstruction(
1752
- depositor,
1753
- tokenSyDepositor,
1754
- depositor,
1755
- this.mintSy,
1756
- )
1757
-
1758
- const tokenYtAtaIx = createAssociatedTokenAccountIdempotentInstruction(
1759
- depositor,
1760
- tokenYtDepositor,
1761
- depositor,
1762
- this.mintYt,
1763
- )
1764
-
1765
- const tokenPtAtaIx = createAssociatedTokenAccountIdempotentInstruction(
1766
- depositor,
1767
- tokenPtDepositor,
1768
- depositor,
1769
- this.mintPt,
1770
- )
1771
-
1772
- const tokenLpAtaIx = createAssociatedTokenAccountIdempotentInstruction(
1773
- depositor,
1774
- tokenLpDepositor,
1775
- depositor,
1776
- this.mintLp,
1777
- )
1778
-
1779
- const lpPosition = this.xponPda.marketLpPosition({ market: this.selfAddress, owner: depositor })
1780
-
1781
- const remainingAccounts = uniqueRemainingAccounts([
1782
- ...this.cpiAccounts.depositSy,
1783
- ...this.cpiAccounts.getPositionState,
1784
- ])
1785
-
1786
- const mintSyIx = await this.flavor.ixMintSy({
1787
- amountBase: "0",
1788
- depositor,
1789
- depositorBaseTokenAccount: tokenBaseDepositor,
1790
- depositorSyTokenAccount: tokenSyDepositor,
1791
- })
1792
-
1793
- const mintSyRemAccounts = mintSyIx.keys
1794
-
1795
- const ix = exponentCore.createWrapperProvideLiquidityClassicInstruction(
1796
- {
1797
- depositor,
1798
- market: this.selfAddress,
1799
- tokenPtEscrow: this.tokenPtEscrow,
1800
- tokenSyEscrow: this.tokenSyEscrow,
1801
- tokenLpDst: tokenLpDepositor,
1802
- mintLp: this.mintLp,
1803
- tokenSyDepositor,
1804
- tokenPtDepositor,
1805
- tokenProgram: TOKEN_PROGRAM_ID,
1806
- marketAddressLookupTable: this.addressLookupTable,
1807
- syProgram: this.syProgram,
1808
- tokenLpEscrow: this.tokenLpEscrow,
1809
- lpPosition,
1810
- systemProgram: SystemProgram.programId,
1811
- eventAuthority: this.vault.eventAuthority,
1812
- program: exponentCore.EXPONENTCORE_PROGRAM_ID,
1813
- },
1814
- { amountBase, amountPt, minLpOut, mintSyAccountsUntil: mintSyRemAccounts.length },
1815
- )
1816
- ix.keys.push(...mintSyRemAccounts.concat(remainingAccounts))
1817
-
1818
- return {
1819
- ixs: [
1820
- ...(await this.flavor.preIxs({ signer: depositor })),
1821
- ix,
1822
- ...(await this.flavor.postIxs({ signer: depositor })),
1823
- ],
1824
- setupIxs: [tokenSyAtaIx, tokenYtAtaIx, tokenPtAtaIx, tokenLpAtaIx],
1825
- }
1826
- }
1827
-
1828
- async ixWithdrawLiquidityToBase({
1829
- owner,
1830
- amountLp,
1831
- minBaseOut,
1832
- tokenSyWithdrawer: tokenSyWithdrawerParam,
1833
- tokenYtWithdrawer: tokenYtWithdrawerParam,
1834
- tokenPtWithdrawer: tokenPtWithdrawerParam,
1835
- tokenBaseWithdrawer: tokenBaseWithdrawerParam,
1836
- tokenLpWithdrawer: tokenLpWithdrawerParam,
1837
- }: {
1838
- owner: PublicKey
1839
- amountLp: bigint
1840
- minBaseOut: bigint
1841
- tokenSyWithdrawer?: PublicKey
1842
- tokenYtWithdrawer?: PublicKey
1843
- tokenPtWithdrawer?: PublicKey
1844
- tokenBaseWithdrawer?: PublicKey
1845
- tokenLpWithdrawer?: PublicKey
1846
- }) {
1847
- const tokenSyWithdrawer =
1848
- tokenSyWithdrawerParam || getAssociatedTokenAddressSync(this.mintSy, owner, true, TOKEN_PROGRAM_ID)
1849
- const tokenYtWithdrawer =
1850
- tokenYtWithdrawerParam || getAssociatedTokenAddressSync(this.mintYt, owner, true, TOKEN_PROGRAM_ID)
1851
- const tokenPtWithdrawer =
1852
- tokenPtWithdrawerParam || getAssociatedTokenAddressSync(this.mintPt, owner, true, TOKEN_PROGRAM_ID)
1853
- const tokenBaseWithdrawer =
1854
- tokenBaseWithdrawerParam ||
1855
- getAssociatedTokenAddressSync(this.flavor.mintBase, owner, true, this.flavor.baseTokenProgram)
1856
- const tokenLpWithdrawer =
1857
- tokenLpWithdrawerParam || getAssociatedTokenAddressSync(this.mintLp, owner, true, TOKEN_PROGRAM_ID)
1858
-
1859
- const tokenSyAtaIx = createAssociatedTokenAccountIdempotentInstruction(owner, tokenSyWithdrawer, owner, this.mintSy)
1860
- const tokenYtAtaIx = createAssociatedTokenAccountIdempotentInstruction(owner, tokenYtWithdrawer, owner, this.mintYt)
1861
- const tokenPtAtaIx = createAssociatedTokenAccountIdempotentInstruction(owner, tokenPtWithdrawer, owner, this.mintPt)
1862
- const tokenBaseAtaIx = createAssociatedTokenAccountIdempotentInstruction(
1863
- owner,
1864
- tokenBaseWithdrawer,
1865
- owner,
1866
- this.flavor.mintBase,
1867
- this.flavor.baseTokenProgram,
1868
- )
1869
- const tokenLpAtaIx = createAssociatedTokenAccountIdempotentInstruction(owner, tokenLpWithdrawer, owner, this.mintLp)
1870
-
1871
- const lpPosition = this.xponPda.marketLpPosition({ market: this.selfAddress, owner })
1872
-
1873
- const remainingAccounts = uniqueRemainingAccounts([
1874
- ...this.cpiAccounts.withdrawSy,
1875
- ...this.cpiAccounts.getPositionState,
1876
- ])
1877
-
1878
- const redeemSyIx = await this.flavor.ixRedeemSy({
1879
- amountSy: "0",
1880
- redeemer: owner,
1881
- redeemerBaseTokenAccount: tokenBaseWithdrawer,
1882
- redeemerSyTokenAccount: tokenSyWithdrawer,
1883
- })
1884
-
1885
- const redeemSyRemAccounts = redeemSyIx.keys
1886
-
1887
- const minSyOut = Number(minBaseOut) / this.currentSyExchangeRate
1888
-
1889
- const ix = exponentCore.createWrapperWithdrawLiquidityInstruction(
1890
- {
1891
- withdrawer: owner,
1892
- market: this.selfAddress,
1893
- tokenPtEscrow: this.tokenPtEscrow,
1894
- tokenSyEscrow: this.tokenSyEscrow,
1895
- tokenLpSrc: tokenLpWithdrawer,
1896
- mintLp: this.mintLp,
1897
- tokenSyWithdrawer,
1898
- tokenPtWithdrawer,
1899
- tokenProgram: TOKEN_PROGRAM_ID,
1900
- marketAddressLookupTable: this.addressLookupTable,
1901
- syProgram: this.syProgram,
1902
- tokenLpEscrow: this.tokenLpEscrow,
1903
- tokenFeeTreasurySy: this.state.tokenFeeTreasurySy,
1904
- lpPosition,
1905
- systemProgram: SystemProgram.programId,
1906
- eventAuthority: this.vault.eventAuthority,
1907
- program: exponentCore.EXPONENTCORE_PROGRAM_ID,
1908
- },
1909
- { amountLp, syConstraint: BigInt(minSyOut.toFixed(0)), redeemSyAccountsLength: redeemSyRemAccounts.length },
1910
- )
1911
- ix.keys.push(...redeemSyRemAccounts.concat(remainingAccounts))
1912
-
1913
- return {
1914
- ixs: [...(await this.flavor.preIxs({ signer: owner })), ix, ...(await this.flavor.postIxs({ signer: owner }))],
1915
- setupIxs: [tokenSyAtaIx, tokenYtAtaIx, tokenPtAtaIx, tokenBaseAtaIx, tokenLpAtaIx],
1916
- }
1917
- }
1918
-
1919
- async ixWithdrawLiquidityClassic({
1920
- owner,
1921
- amountLp,
1922
- tokenSyWithdrawer: tokenSyWithdrawerParam,
1923
- tokenYtWithdrawer: tokenYtWithdrawerParam,
1924
- tokenPtWithdrawer: tokenPtWithdrawerParam,
1925
- tokenBaseWithdrawer: tokenBaseWithdrawerParam,
1926
- tokenLpWithdrawer: tokenLpWithdrawerParam,
1927
- }: {
1928
- owner: PublicKey
1929
- amountLp: bigint
1930
- tokenSyWithdrawer?: PublicKey
1931
- tokenYtWithdrawer?: PublicKey
1932
- tokenPtWithdrawer?: PublicKey
1933
- tokenBaseWithdrawer?: PublicKey
1934
- tokenLpWithdrawer?: PublicKey
1935
- }) {
1936
- const tokenSyWithdrawer =
1937
- tokenSyWithdrawerParam || getAssociatedTokenAddressSync(this.mintSy, owner, true, TOKEN_PROGRAM_ID)
1938
- const tokenYtWithdrawer =
1939
- tokenYtWithdrawerParam || getAssociatedTokenAddressSync(this.mintYt, owner, true, TOKEN_PROGRAM_ID)
1940
- const tokenPtWithdrawer =
1941
- tokenPtWithdrawerParam || getAssociatedTokenAddressSync(this.mintPt, owner, true, TOKEN_PROGRAM_ID)
1942
- const tokenBaseWithdrawer =
1943
- tokenBaseWithdrawerParam ||
1944
- getAssociatedTokenAddressSync(this.flavor.mintBase, owner, true, this.flavor.baseTokenProgram)
1945
- const tokenLpWithdrawer =
1946
- tokenLpWithdrawerParam || getAssociatedTokenAddressSync(this.mintLp, owner, true, TOKEN_PROGRAM_ID)
1947
-
1948
- const tokenSyAtaIx = createAssociatedTokenAccountIdempotentInstruction(owner, tokenSyWithdrawer, owner, this.mintSy)
1949
- const tokenYtAtaIx = createAssociatedTokenAccountIdempotentInstruction(owner, tokenYtWithdrawer, owner, this.mintYt)
1950
- const tokenPtAtaIx = createAssociatedTokenAccountIdempotentInstruction(owner, tokenPtWithdrawer, owner, this.mintPt)
1951
- const tokenBaseAtaIx = createAssociatedTokenAccountIdempotentInstruction(
1952
- owner,
1953
- tokenBaseWithdrawer,
1954
- owner,
1955
- this.flavor.mintBase,
1956
- this.flavor.baseTokenProgram,
1957
- )
1958
- const tokenLpAtaIx = createAssociatedTokenAccountIdempotentInstruction(owner, tokenLpWithdrawer, owner, this.mintLp)
1959
-
1960
- const lpPosition = this.xponPda.marketLpPosition({ market: this.selfAddress, owner })
1961
-
1962
- const remainingAccounts = uniqueRemainingAccounts([
1963
- ...this.cpiAccounts.withdrawSy,
1964
- ...this.cpiAccounts.getPositionState,
1965
- ])
1966
-
1967
- const redeemSyIx = await this.flavor.ixRedeemSy({
1968
- amountSy: "0",
1969
- redeemer: owner,
1970
- redeemerBaseTokenAccount: tokenBaseWithdrawer,
1971
- redeemerSyTokenAccount: tokenSyWithdrawer,
1972
- })
1973
-
1974
- const redeemSyRemAccounts = redeemSyIx.keys
1975
-
1976
- const ixn = exponentCore.createWrapperWithdrawLiquidityClassicInstruction(
1977
- {
1978
- withdrawer: owner,
1979
- market: this.selfAddress,
1980
- tokenPtEscrow: this.tokenPtEscrow,
1981
- tokenSyEscrow: this.tokenSyEscrow,
1982
- tokenLpSrc: tokenLpWithdrawer,
1983
- mintLp: this.mintLp,
1984
- tokenSyWithdrawer,
1985
- tokenPtWithdrawer,
1986
- tokenProgram: TOKEN_PROGRAM_ID,
1987
- marketAddressLookupTable: this.addressLookupTable,
1988
- syProgram: this.syProgram,
1989
- tokenLpEscrow: this.tokenLpEscrow,
1990
- lpPosition,
1991
- systemProgram: SystemProgram.programId,
1992
- eventAuthority: this.vault.eventAuthority,
1993
- program: exponentCore.EXPONENTCORE_PROGRAM_ID,
1994
- },
1995
- { amountLp, redeemSyAccountsLength: redeemSyRemAccounts.length },
1996
- )
1997
- ixn.keys.push(...redeemSyRemAccounts.concat(remainingAccounts))
1998
-
1999
- return {
2000
- ixs: [...(await this.flavor.preIxs({ signer: owner })), ixn, ...(await this.flavor.postIxs({ signer: owner }))],
2001
- setupIxs: [tokenSyAtaIx, tokenYtAtaIx, tokenPtAtaIx, tokenBaseAtaIx, tokenLpAtaIx],
2002
- }
2003
- }
2004
-
2005
- claimFarmEmissions({
2006
- owner,
2007
- mint,
2008
- tokenProgram,
2009
- tokenDst: tokenDstParam,
2010
- }: {
2011
- owner: PublicKey
2012
- mint: PublicKey
2013
- tokenProgram: PublicKey
2014
- tokenDst?: PublicKey
2015
- }) {
2016
- const tokenDst = tokenDstParam || getAssociatedTokenAddressSync(mint, owner, true, tokenProgram)
2017
- const lpPosition = this.xponPda.marketLpPosition({ market: this.selfAddress, owner })
2018
-
2019
- const tokenFarm = getAssociatedTokenAddressSync(mint, this.selfAddress, true, tokenProgram)
2020
- const tokenAtaIx = createAssociatedTokenAccountIdempotentInstruction(owner, tokenDst, owner, mint)
2021
-
2022
- const ix = exponentCore.createClaimFarmEmissionsInstruction(
2023
- {
2024
- owner,
2025
- market: this.selfAddress,
2026
- lpPosition,
2027
- tokenDst,
2028
- mint,
2029
- tokenFarm,
2030
- tokenProgram,
2031
- eventAuthority: this.eventAuthority,
2032
- program: exponentCore.EXPONENTCORE_PROGRAM_ID,
2033
- },
2034
- { amount: exponentCore.amount("All") },
2035
- )
2036
-
2037
- return {
2038
- ixs: [ix],
2039
- setupIxs: [tokenAtaIx],
2040
- }
2041
- }
2042
-
2043
- ixAddStandaloneEmission({
2044
- signer,
2045
- emissionMint,
2046
- emissionTokenProgram = TOKEN_PROGRAM_ID,
2047
- altAddresses,
2048
- cpiAccounts,
2049
- }: {
2050
- signer: PublicKey
2051
- emissionMint: PublicKey
2052
- emissionTokenProgram?: PublicKey
2053
- altAddresses: PublicKey[]
2054
- cpiAccounts: CpiAccountsRaw
2055
- }) {
2056
- const altUtil = extendAddressLookupTable(altAddresses, cpiAccounts)
2057
-
2058
- const tokenEmission = getAssociatedTokenAddressSync(emissionMint, this.selfAddress, true, emissionTokenProgram)
2059
- const ix = exponentCore.createAddMarketEmissionInstruction(
2060
- {
2061
- market: this.selfAddress,
2062
- signer,
2063
- feePayer: signer,
2064
- mintNew: emissionMint,
2065
- adminState: getExponentAdminStatePda(),
2066
- tokenEmission,
2067
- tokenProgram: emissionTokenProgram,
2068
- systemProgram: SystemProgram.programId,
2069
- },
2070
- { cpiAccounts: altUtil.cpiAccountIndexes },
2071
- )
2072
-
2073
- return {
2074
- extendAddressLookupTableExtensionAccounts: altUtil.addressLookupTableExtension,
2075
- addMarketEmissionIx: ix,
2076
- }
2077
- }
2078
-
2079
- addFarm({
2080
- signer,
2081
- farmMint,
2082
- farmRewardTokenProgram,
2083
- emissionsRate,
2084
- untilTimestamp,
2085
- farmRewardSrc: farmRewardSrcParam,
2086
- feePayer: feePayerParam,
2087
- }: {
2088
- signer: PublicKey
2089
- farmMint: PublicKey
2090
- farmRewardTokenProgram: PublicKey
2091
- emissionsRate: number
2092
- untilTimestamp: number
2093
- farmRewardSrc?: PublicKey
2094
- feePayer?: PublicKey
2095
- }) {
2096
- const feePayer = feePayerParam || signer
2097
- const farmRewardEscrow = getAssociatedTokenAddressSync(farmMint, this.selfAddress, true, farmRewardTokenProgram)
2098
- const farmRewardSrc =
2099
- farmRewardSrcParam || getAssociatedTokenAddressSync(farmMint, signer, true, farmRewardTokenProgram)
2100
-
2101
- const ix = exponentCore.createAddFarmInstruction(
2102
- {
2103
- market: this.selfAddress,
2104
- signer,
2105
- feePayer,
2106
- mintNew: farmMint,
2107
- adminState: getExponentAdminStatePda(),
2108
- tokenSource: farmRewardSrc,
2109
- tokenFarm: farmRewardEscrow,
2110
- tokenProgram: farmRewardTokenProgram,
2111
- systemProgram: SystemProgram.programId,
2112
- },
2113
- { tokenRate: BigInt(emissionsRate), untilTimestamp },
2114
- )
2115
-
2116
- return {
2117
- ixs: [ix],
2118
- }
2119
- }
2120
-
2121
- static fromJson(json: MarketJson, env: Environment, connection: Connection): Market {
2122
- const state: MarketArgs = {
2123
- seedId: [json.seedId],
2124
- ptBalance: BigInt(json.ptBalance),
2125
- syBalance: BigInt(json.syBalance),
2126
- lpSupply: BigInt(json.lpSupply),
2127
- lpEscrowAmount: BigInt(json.lpEscrowAmount),
2128
- maxLpSupply: BigInt(json.maxLpSupply),
2129
- rateScalarRoot: json.rateScalarRoot,
2130
- lnFeeRateRoot: json.lnFeeRateRoot,
2131
- lastLnImpliedRate: json.lastLnImpliedRate,
2132
- expirationTs: json.expirationTs,
2133
- addressLookupTable: new PublicKey(json.addressLookupTable),
2134
- mintSy: new PublicKey(json.mintSy),
2135
- mintPt: new PublicKey(json.mintPt),
2136
- mintLp: new PublicKey(json.mintLp),
2137
- tokenPtEscrow: new PublicKey(json.tokenPtEscrow),
2138
- tokenSyEscrow: new PublicKey(json.tokenSyEscrow),
2139
- tokenLpEscrow: new PublicKey(json.tokenLpEscrow),
2140
- syProgram: new PublicKey(json.syProgram),
2141
- cpiAccounts: deserializeCpiAccountsRaw(json.cpiAccounts),
2142
- feeTreasurySyBps: json.feeTreasurySyBps,
2143
- tokenFeeTreasurySy: new PublicKey(json.treasurySyTokenAccount),
2144
- lpFarm: {
2145
- farmEmissions: json.lpFarm.farmEmissions.map((e) => ({
2146
- mint: new PublicKey(e.mint),
2147
- tokenRate: new BN(e.tokenRate),
2148
- expiryTimestamp: e.expiryTimestamp,
2149
- index: new PreciseNumber(e.index).anchorify(),
2150
- })),
2151
- lastSeenTimestamp: json.lpFarm.lastSeenTimestamp,
2152
- },
2153
- liquidityNetBalanceLimits: {
2154
- windowStartTimestamp: json.liquidityNetBalanceLimits.windowStartTimestamp,
2155
- windowStartNetBalance: new BN(json.liquidityNetBalanceLimits.windowStartNetBalance),
2156
- maxNetBalanceChangeNegativePercentage: json.liquidityNetBalanceLimits.maxNetBalanceChangeNegativePercentage,
2157
- maxNetBalanceChangePositivePercentage: json.liquidityNetBalanceLimits.maxNetBalanceChangePositivePercentage,
2158
- windowDurationSeconds: json.liquidityNetBalanceLimits.windowDurationSeconds,
2159
- },
2160
- emissions: {
2161
- trackers: json.emissions.trackers.map((e) => ({
2162
- tokenEscrow: new PublicKey(e.tokenEscrow),
2163
- lpShareIndex: e.lpShareIndex,
2164
- lastSeenStaged: e.lastSeenStaged,
2165
- })),
2166
- },
2167
- vault: Vault.loadFromJson(json.vault, new PublicKey(json.vault.selfAddress), env, connection),
2168
- sySupply: BigInt(json.sySupply),
2169
- statusFlags: json.statusFlags,
2170
- isCurrentFlashSwap: json.isCurrentFlashSwap,
2171
- flavor: deserializeFlavor(json.flavor),
2172
- syPosition: deserializeSyPosition(json.syPosition),
2173
- }
2174
-
2175
- return new Market(state, new PublicKey(json.address), env, connection)
2176
- }
2177
-
2178
- /** Calculate available liquidity for PT trades
2179
- * @param isBuy - true if buying PT with SY, false if selling PT for SY
2180
- * @param sizePt - amount of PT to trade (in PT decimals)
2181
- * @returns amount of PT that can be traded given current liquidity
2182
- */
2183
- liquidityAvailable(isBuy: boolean, sizePt: bigint): bigint {
2184
- const calc = this.marketCalculator()
2185
-
2186
- if (isBuy) {
2187
- // When buying PT, we're limited by SY liquidity
2188
- // Convert PT amount to SY using current price
2189
- const syNeeded = Number(sizePt) * calc.exchangeRate
2190
- // Available SY in the market
2191
- const syAvailable = Number(this.syBalance)
2192
-
2193
- if (syNeeded <= syAvailable) {
2194
- return sizePt
2195
- } else {
2196
- // Calculate max PT that can be bought with available SY
2197
- return BigInt(Math.floor(syAvailable / calc.exchangeRate))
2198
- }
2199
- } else {
2200
- // When selling PT, we're limited by PT liquidity in the market
2201
- const ptAvailable = this.ptBalance
2202
-
2203
- if (sizePt <= ptAvailable) {
2204
- return sizePt
2205
- } else {
2206
- return ptAvailable
2207
- }
2208
- }
2209
- }
2210
-
2211
- /**
2212
- * Reallocate market data
2213
- * @param additionalBytes - number of additional bytes to allocate
2214
- * @returns transaction instruction to realloc market
2215
- */
2216
- realloc_market({ signer, additionalBytes }: { signer: PublicKey; additionalBytes: number }) {
2217
- const ix = exponentCore.createReallocMarketInstruction(
2218
- {
2219
- market: this.selfAddress,
2220
- signer,
2221
- adminState: getExponentAdminStatePda(),
2222
- systemProgram: SystemProgram.programId,
2223
- rent: SYSVAR_RENT_PUBKEY,
2224
- },
2225
- { additionalBytes: BigInt(additionalBytes) },
2226
- )
2227
-
2228
- return {
2229
- ixs: [ix],
2230
- }
2231
- }
2232
- }
2233
-
2234
- export type MarketJson = {
2235
- /** The market's public key */
2236
- address: string
2237
- /** The market's seed ID */
2238
- seedId: number
2239
- /** The market's address lookup table public key */
2240
- addressLookupTable: string
2241
- /** The market's SY escrow account public key - this is a pass-through account which moves SY between an end-user and the SY program where it is deposited and withdrawn from */
2242
- tokenSyEscrow: string
2243
- /** The market's PT escrow account public key - this account holds the market's PT liquidity*/
2244
- tokenPtEscrow: string
2245
- /** The market's LP escrow account public key - this account holds the market's LP tokens which are used to farm rewards */
2246
- tokenLpEscrow: string
2247
-
2248
- /** Token account that holds the market's SY fees */
2249
- treasurySyTokenAccount: string
2250
-
2251
- /** The market's LP supply */
2252
- lpSupply: string
2253
-
2254
- /** The SY program ID */
2255
- syProgram: string
2256
-
2257
- mintPt: string
2258
- mintSy: string
2259
- mintLp: string
2260
-
2261
- /** The market's PT balance */
2262
- ptBalance: string
2263
- /** The market's SY balance */
2264
- syBalance: string
2265
-
2266
- /** The market's LP escrow amount */
2267
- lpEscrowAmount: string
2268
-
2269
- /** The market's current SY rate */
2270
- currentSyRate: number
2271
-
2272
- /** The market's expiration timestamp */
2273
- expirationTs: number
2274
-
2275
- /** The market's expiration date */
2276
- expirationDate: string
2277
-
2278
- /** The number of seconds remaining until the market expires */
2279
- secondsRemaining: number
2280
-
2281
- /** The market's maximum LP supply */
2282
- maxLpSupply: string
2283
-
2284
- lnFeeRateRoot: number
2285
-
2286
- rateScalarRoot: number
2287
-
2288
- feeTreasurySyBps: number
2289
-
2290
- lastLnImpliedRate: number
2291
-
2292
- /** The current rate scalar, taking into account the time decay*/
2293
- currentRateScalar: number
2294
-
2295
- /** The current rate anchor that preserves the last implied rate */
2296
- currentRateAnchor: number
2297
-
2298
- /** How many SY are required to buy 1 PT */
2299
- currentPtPriceInSy: number
2300
-
2301
- /** How many assets are required to buy 1 PT */
2302
- currentPtPriceInAsset: number
2303
-
2304
- /** Proportion of PT in terms of assets */
2305
- proportionPtInAsset: number
2306
-
2307
- /** Proportion of PT in terms of SY */
2308
- proportionPtInSy: number
2309
-
2310
- /** Current fee rate */
2311
- currentFeeRate: number
2312
-
2313
- /** CPI accounts */
2314
- cpiAccounts: CpiAccountsRawJson
2315
-
2316
- /** Annualized yield for PT */
2317
- ptApr: number
2318
-
2319
- vault: VaultJson
2320
-
2321
- sySupply: string
2322
-
2323
- statusFlags: number
2324
-
2325
- isCurrentFlashSwap: boolean
2326
-
2327
- flavor: FlavorGenericStateJson
2328
-
2329
- syPosition: SyPositionJson
2330
-
2331
- ptApy: number
2332
-
2333
- /** Emission tokens */
2334
- emissions: {
2335
- trackers: {
2336
- tokenEscrow: string
2337
- lpShareIndex: number
2338
- lastSeenStaged: number
2339
- }[]
2340
- }
2341
-
2342
- liquidityNetBalanceLimits: {
2343
- windowStartTimestamp: number
2344
- windowStartNetBalance: string
2345
- maxNetBalanceChangeNegativePercentage: number
2346
- maxNetBalanceChangePositivePercentage: number
2347
- windowDurationSeconds: number
2348
- }
2349
-
2350
- lpFarm: {
2351
- lastSeenTimestamp: number
2352
- farmEmissions: {
2353
- mint: string
2354
- /** Tokens per second */
2355
- tokenRate: string
2356
- expiryTimestamp: number
2357
- /** Index for converting LP shares into earned emissions */
2358
- index: string
2359
- }[]
2360
- }
2361
- }
2362
-
2363
- function toJson(market: Market): MarketJson {
2364
- const marketCalculator = market.marketCalculator()
2365
- return {
2366
- treasurySyTokenAccount: market.state.tokenFeeTreasurySy.toBase58(),
2367
- address: market.selfAddress.toBase58(),
2368
- addressLookupTable: market.addressLookupTable.toBase58(),
2369
- tokenSyEscrow: market.tokenSyEscrow.toBase58(),
2370
- tokenPtEscrow: market.tokenPtEscrow.toBase58(),
2371
- tokenLpEscrow: market.tokenLpEscrow.toBase58(),
2372
- lpSupply: market.state.lpSupply.toString(),
2373
- syProgram: market.state.syProgram.toBase58(),
2374
- mintPt: market.state.mintPt.toBase58(),
2375
- mintSy: market.state.mintSy.toBase58(),
2376
- mintLp: market.state.mintLp.toBase58(),
2377
- feeTreasurySyBps: market.state.feeTreasurySyBps,
2378
- ptBalance: market.state.ptBalance.toString(),
2379
- syBalance: market.state.syBalance.toString(),
2380
- currentSyRate: market.flavor.currentSyExchangeRate,
2381
- expirationTs: market.state.expirationTs,
2382
- expirationDate: new Date(market.state.expirationTs * 1000).toISOString(),
2383
- lnFeeRateRoot: market.state.lnFeeRateRoot,
2384
- rateScalarRoot: market.state.rateScalarRoot,
2385
- lastLnImpliedRate: market.state.lastLnImpliedRate,
2386
- currentPtPriceInSy: market.currentPtPriceInSy,
2387
- currentPtPriceInAsset: market.currentPtPriceInAsset,
2388
- secondsRemaining: market.secondsRemaining,
2389
- proportionPtInAsset: marketCalculator.proportionPtInAsset,
2390
- proportionPtInSy: marketCalculator.proportionPtInSy,
2391
- currentFeeRate: marketCalculator.feeRate,
2392
- currentRateScalar: marketCalculator.rateScalar,
2393
- currentRateAnchor: marketCalculator.findRateAnchor(),
2394
- cpiAccounts: serializeCpiAccountsRaw(market.cpiAccounts),
2395
- emissions: {
2396
- trackers: market.marketEmissions.trackers.map((e) => ({
2397
- tokenEscrow: e.tokenEscrow.toBase58(),
2398
- lpShareIndex: e.lpShareIndex,
2399
- lastSeenStaged: e.lastSeenStaged,
2400
- })),
2401
- },
2402
- ptApr: market.ptApr,
2403
- ptApy: market.ptApy,
2404
- lpEscrowAmount: market.state.lpEscrowAmount.toString(),
2405
- maxLpSupply: market.state.maxLpSupply.toString(),
2406
- liquidityNetBalanceLimits: {
2407
- windowStartTimestamp: market.state.liquidityNetBalanceLimits.windowStartTimestamp,
2408
- windowStartNetBalance: market.state.liquidityNetBalanceLimits.windowStartNetBalance.toString(),
2409
- maxNetBalanceChangeNegativePercentage:
2410
- market.state.liquidityNetBalanceLimits.maxNetBalanceChangeNegativePercentage,
2411
- maxNetBalanceChangePositivePercentage:
2412
- market.state.liquidityNetBalanceLimits.maxNetBalanceChangePositivePercentage,
2413
- windowDurationSeconds: market.state.liquidityNetBalanceLimits.windowDurationSeconds,
2414
- },
2415
- lpFarm: {
2416
- lastSeenTimestamp: market.state.lpFarm.lastSeenTimestamp,
2417
- farmEmissions: market.state.lpFarm.farmEmissions.map((e) => ({
2418
- mint: e.mint.toBase58(),
2419
- tokenRate: e.tokenRate.toString(),
2420
- expiryTimestamp: e.expiryTimestamp,
2421
- index: PreciseNumber.fromRaw(e.index[0]).valueString,
2422
- })),
2423
- },
2424
- vault: market.vault.toJson(),
2425
- sySupply: market.state.sySupply.toString(),
2426
- statusFlags: market.state.statusFlags,
2427
- isCurrentFlashSwap: market.state.isCurrentFlashSwap,
2428
- // @ts-ignore
2429
- flavor: serializeFlavor(market.state.flavor),
2430
- syPosition: serializeSyPosition(market.state.syPosition),
2431
- }
2432
- }