@reflectmoney/stable.ts 1.0.0 → 1.0.2

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 (304) hide show
  1. package/README.md +178 -7
  2. package/dist/classes/PdaClient.d.ts +112 -0
  3. package/dist/classes/PdaClient.js +112 -0
  4. package/dist/classes/ReflectAdmin.d.ts +87 -2
  5. package/dist/classes/ReflectAdmin.js +84 -1
  6. package/dist/classes/ReflectTokenisedBond.d.ts +57 -0
  7. package/dist/classes/ReflectTokenisedBond.js +56 -0
  8. package/dist/classes/Stablecoin.d.ts +139 -1
  9. package/dist/classes/Stablecoin.js +83 -1
  10. package/dist/stablecoins/LstStablecoin.d.ts +47 -0
  11. package/dist/stablecoins/LstStablecoin.js +46 -0
  12. package/package.json +1 -1
  13. package/dist/classes/Strategy.d.ts +0 -30
  14. package/dist/classes/Strategy.js +0 -196
  15. package/dist/generated/accounts/DriftJlpController.d.ts +0 -114
  16. package/dist/generated/accounts/DriftJlpController.js +0 -169
  17. package/dist/generated/accounts/DriftLstController.d.ts +0 -108
  18. package/dist/generated/accounts/DriftLstController.js +0 -165
  19. package/dist/generated/accounts/DriftUsdcController.d.ts +0 -102
  20. package/dist/generated/accounts/DriftUsdcController.js +0 -158
  21. package/dist/generated/accounts/Main.d.ts +0 -110
  22. package/dist/generated/accounts/Main.js +0 -165
  23. package/dist/generated/accounts/PerpMarket.d.ts +0 -226
  24. package/dist/generated/accounts/PerpMarket.js +0 -307
  25. package/dist/generated/accounts/PrelaunchOracle.d.ts +0 -130
  26. package/dist/generated/accounts/PrelaunchOracle.js +0 -224
  27. package/dist/generated/accounts/PythLazerOracle.d.ts +0 -124
  28. package/dist/generated/accounts/PythLazerOracle.js +0 -210
  29. package/dist/generated/accounts/RebalanceLst.d.ts +0 -111
  30. package/dist/generated/accounts/RebalanceLst.js +0 -175
  31. package/dist/generated/accounts/SpotMarket.d.ts +0 -377
  32. package/dist/generated/accounts/SpotMarket.js +0 -601
  33. package/dist/generated/accounts/User.d.ts +0 -221
  34. package/dist/generated/accounts/User.js +0 -331
  35. package/dist/generated/accounts/UserPermissions.d.ts +0 -106
  36. package/dist/generated/accounts/UserPermissions.js +0 -161
  37. package/dist/generated/accounts/UserStats.d.ts +0 -211
  38. package/dist/generated/accounts/UserStats.js +0 -323
  39. package/dist/generated/accounts/index.d.ts +0 -38
  40. package/dist/generated/accounts/index.js +0 -55
  41. package/dist/generated/errors/index.d.ts +0 -1024
  42. package/dist/generated/errors/index.js +0 -1761
  43. package/dist/generated/index.d.ts +0 -19
  44. package/dist/generated/index.js +0 -36
  45. package/dist/generated/instructions/addLstDrift.d.ts +0 -49
  46. package/dist/generated/instructions/addLstDrift.js +0 -106
  47. package/dist/generated/instructions/addSubAccount.d.ts +0 -54
  48. package/dist/generated/instructions/addSubAccount.js +0 -121
  49. package/dist/generated/instructions/adjustHedgeS2.d.ts +0 -69
  50. package/dist/generated/instructions/adjustHedgeS2.js +0 -157
  51. package/dist/generated/instructions/captureSpreadDrift.d.ts +0 -56
  52. package/dist/generated/instructions/captureSpreadDrift.js +0 -120
  53. package/dist/generated/instructions/createAdminAccount.d.ts +0 -53
  54. package/dist/generated/instructions/createAdminAccount.js +0 -95
  55. package/dist/generated/instructions/createUserStatsAccount.d.ts +0 -54
  56. package/dist/generated/instructions/createUserStatsAccount.js +0 -121
  57. package/dist/generated/instructions/depositDrift.d.ts +0 -73
  58. package/dist/generated/instructions/depositDrift.js +0 -142
  59. package/dist/generated/instructions/freezeProgram.d.ts +0 -54
  60. package/dist/generated/instructions/freezeProgram.js +0 -95
  61. package/dist/generated/instructions/freezeProtocolAction.d.ts +0 -55
  62. package/dist/generated/instructions/freezeProtocolAction.js +0 -96
  63. package/dist/generated/instructions/freezeStrategyAction.d.ts +0 -58
  64. package/dist/generated/instructions/freezeStrategyAction.js +0 -102
  65. package/dist/generated/instructions/index.d.ts +0 -41
  66. package/dist/generated/instructions/index.js +0 -57
  67. package/dist/generated/instructions/initDriftAccountsS1.d.ts +0 -56
  68. package/dist/generated/instructions/initDriftAccountsS1.js +0 -126
  69. package/dist/generated/instructions/initDriftControllerS1.d.ts +0 -60
  70. package/dist/generated/instructions/initDriftControllerS1.js +0 -108
  71. package/dist/generated/instructions/initDriftControllerS2.d.ts +0 -66
  72. package/dist/generated/instructions/initDriftControllerS2.js +0 -125
  73. package/dist/generated/instructions/initDriftControllerS3.d.ts +0 -58
  74. package/dist/generated/instructions/initDriftControllerS3.js +0 -103
  75. package/dist/generated/instructions/initMain.d.ts +0 -43
  76. package/dist/generated/instructions/initMain.js +0 -91
  77. package/dist/generated/instructions/mintDriftS1.d.ts +0 -90
  78. package/dist/generated/instructions/mintDriftS1.js +0 -184
  79. package/dist/generated/instructions/mintDriftS2.d.ts +0 -80
  80. package/dist/generated/instructions/mintDriftS2.js +0 -161
  81. package/dist/generated/instructions/mintDriftS3.d.ts +0 -86
  82. package/dist/generated/instructions/mintDriftS3.js +0 -174
  83. package/dist/generated/instructions/processSwapDeposit.d.ts +0 -79
  84. package/dist/generated/instructions/processSwapDeposit.js +0 -161
  85. package/dist/generated/instructions/processSwapDepositIntrospection.d.ts +0 -79
  86. package/dist/generated/instructions/processSwapDepositIntrospection.js +0 -161
  87. package/dist/generated/instructions/processSwapWithdraw.d.ts +0 -68
  88. package/dist/generated/instructions/processSwapWithdraw.js +0 -157
  89. package/dist/generated/instructions/processSwapWithdrawIntrospection.d.ts +0 -68
  90. package/dist/generated/instructions/processSwapWithdrawIntrospection.js +0 -157
  91. package/dist/generated/instructions/rebalanceJlp.d.ts +0 -81
  92. package/dist/generated/instructions/rebalanceJlp.js +0 -187
  93. package/dist/generated/instructions/redeem2DriftS2.d.ts +0 -80
  94. package/dist/generated/instructions/redeem2DriftS2.js +0 -161
  95. package/dist/generated/instructions/redeemDriftS1.d.ts +0 -91
  96. package/dist/generated/instructions/redeemDriftS1.js +0 -185
  97. package/dist/generated/instructions/redeemDriftS2.d.ts +0 -80
  98. package/dist/generated/instructions/redeemDriftS2.js +0 -161
  99. package/dist/generated/instructions/redeemDriftS3.d.ts +0 -87
  100. package/dist/generated/instructions/redeemDriftS3.js +0 -175
  101. package/dist/generated/instructions/settlePnl.d.ts +0 -55
  102. package/dist/generated/instructions/settlePnl.js +0 -114
  103. package/dist/generated/instructions/settlePnlMulti.d.ts +0 -65
  104. package/dist/generated/instructions/settlePnlMulti.js +0 -117
  105. package/dist/generated/instructions/suspendLstProtocol.d.ts +0 -54
  106. package/dist/generated/instructions/suspendLstProtocol.js +0 -96
  107. package/dist/generated/instructions/suspendLstStrategy.d.ts +0 -56
  108. package/dist/generated/instructions/suspendLstStrategy.js +0 -101
  109. package/dist/generated/instructions/swapOrca.d.ts +0 -78
  110. package/dist/generated/instructions/swapOrca.js +0 -153
  111. package/dist/generated/instructions/swapOrcaTwoHop.d.ts +0 -98
  112. package/dist/generated/instructions/swapOrcaTwoHop.js +0 -200
  113. package/dist/generated/instructions/updateActionRoleProtocol.d.ts +0 -58
  114. package/dist/generated/instructions/updateActionRoleProtocol.js +0 -99
  115. package/dist/generated/instructions/updateActionRoleStrategy.d.ts +0 -61
  116. package/dist/generated/instructions/updateActionRoleStrategy.js +0 -105
  117. package/dist/generated/instructions/updateAttenuation.d.ts +0 -56
  118. package/dist/generated/instructions/updateAttenuation.js +0 -100
  119. package/dist/generated/instructions/updateCap.d.ts +0 -55
  120. package/dist/generated/instructions/updateCap.js +0 -99
  121. package/dist/generated/instructions/updateRebalanceSlippage.d.ts +0 -55
  122. package/dist/generated/instructions/updateRebalanceSlippage.js +0 -99
  123. package/dist/generated/instructions/updateRecipients.d.ts +0 -56
  124. package/dist/generated/instructions/updateRecipients.js +0 -101
  125. package/dist/generated/instructions/updateRoleHolderProtocol.d.ts +0 -61
  126. package/dist/generated/instructions/updateRoleHolderProtocol.js +0 -109
  127. package/dist/generated/instructions/updateRoleHolderStrategy.d.ts +0 -62
  128. package/dist/generated/instructions/updateRoleHolderStrategy.js +0 -110
  129. package/dist/generated/types/AMM.d.ts +0 -102
  130. package/dist/generated/types/AMM.js +0 -127
  131. package/dist/generated/types/AccKey.d.ts +0 -15
  132. package/dist/generated/types/AccKey.js +0 -38
  133. package/dist/generated/types/AccessControl.d.ts +0 -18
  134. package/dist/generated/types/AccessControl.js +0 -43
  135. package/dist/generated/types/AccessMap.d.ts +0 -17
  136. package/dist/generated/types/AccessMap.js +0 -42
  137. package/dist/generated/types/Action.d.ts +0 -36
  138. package/dist/generated/types/Action.js +0 -63
  139. package/dist/generated/types/ActionMapping.d.ts +0 -19
  140. package/dist/generated/types/ActionMapping.js +0 -44
  141. package/dist/generated/types/AssetTier.d.ts +0 -23
  142. package/dist/generated/types/AssetTier.js +0 -50
  143. package/dist/generated/types/Attenuation.d.ts +0 -16
  144. package/dist/generated/types/Attenuation.js +0 -41
  145. package/dist/generated/types/BalanceType.d.ts +0 -20
  146. package/dist/generated/types/BalanceType.js +0 -47
  147. package/dist/generated/types/ContractTier.d.ts +0 -24
  148. package/dist/generated/types/ContractTier.js +0 -51
  149. package/dist/generated/types/ContractType.d.ts +0 -20
  150. package/dist/generated/types/ContractType.js +0 -47
  151. package/dist/generated/types/CorpAction.d.ts +0 -19
  152. package/dist/generated/types/CorpAction.js +0 -46
  153. package/dist/generated/types/CustodyInfo.d.ts +0 -20
  154. package/dist/generated/types/CustodyInfo.js +0 -45
  155. package/dist/generated/types/DirectionCollateral.d.ts +0 -20
  156. package/dist/generated/types/DirectionCollateral.js +0 -47
  157. package/dist/generated/types/DirectionPosition.d.ts +0 -20
  158. package/dist/generated/types/DirectionPosition.js +0 -47
  159. package/dist/generated/types/DriftControllerBase.d.ts +0 -15
  160. package/dist/generated/types/DriftControllerBase.js +0 -38
  161. package/dist/generated/types/DriftJlpControllerFixedAccounts.d.ts +0 -18
  162. package/dist/generated/types/DriftJlpControllerFixedAccounts.js +0 -43
  163. package/dist/generated/types/DriftLstData.d.ts +0 -17
  164. package/dist/generated/types/DriftLstData.js +0 -42
  165. package/dist/generated/types/Ema.d.ts +0 -17
  166. package/dist/generated/types/Ema.js +0 -42
  167. package/dist/generated/types/Externals.d.ts +0 -16
  168. package/dist/generated/types/Externals.js +0 -39
  169. package/dist/generated/types/HistoricalIndexData.d.ts +0 -19
  170. package/dist/generated/types/HistoricalIndexData.js +0 -44
  171. package/dist/generated/types/HistoricalOracleData.d.ts +0 -20
  172. package/dist/generated/types/HistoricalOracleData.js +0 -45
  173. package/dist/generated/types/Holding.d.ts +0 -21
  174. package/dist/generated/types/Holding.js +0 -46
  175. package/dist/generated/types/Holdings.d.ts +0 -17
  176. package/dist/generated/types/Holdings.js +0 -42
  177. package/dist/generated/types/InitControllerS2Args.d.ts +0 -23
  178. package/dist/generated/types/InitControllerS2Args.js +0 -48
  179. package/dist/generated/types/InsuranceClaim.d.ts +0 -19
  180. package/dist/generated/types/InsuranceClaim.js +0 -44
  181. package/dist/generated/types/InsuranceFund.d.ts +0 -24
  182. package/dist/generated/types/InsuranceFund.js +0 -49
  183. package/dist/generated/types/JlpRebalanceSettings.d.ts +0 -15
  184. package/dist/generated/types/JlpRebalanceSettings.js +0 -38
  185. package/dist/generated/types/KillSwitch.d.ts +0 -15
  186. package/dist/generated/types/KillSwitch.js +0 -38
  187. package/dist/generated/types/LevelRoles.d.ts +0 -16
  188. package/dist/generated/types/LevelRoles.js +0 -39
  189. package/dist/generated/types/MarketStatus.d.ts +0 -27
  190. package/dist/generated/types/MarketStatus.js +0 -54
  191. package/dist/generated/types/MarketType.d.ts +0 -20
  192. package/dist/generated/types/MarketType.js +0 -47
  193. package/dist/generated/types/MintJlpArgs.d.ts +0 -15
  194. package/dist/generated/types/MintJlpArgs.js +0 -38
  195. package/dist/generated/types/ModifyOrderParams.d.ts +0 -32
  196. package/dist/generated/types/ModifyOrderParams.js +0 -57
  197. package/dist/generated/types/ModifyOrderPolicy.d.ts +0 -20
  198. package/dist/generated/types/ModifyOrderPolicy.js +0 -47
  199. package/dist/generated/types/Movements.d.ts +0 -19
  200. package/dist/generated/types/Movements.js +0 -44
  201. package/dist/generated/types/OracleGuardRails.d.ts +0 -18
  202. package/dist/generated/types/OracleGuardRails.js +0 -43
  203. package/dist/generated/types/OracleSource.d.ts +0 -34
  204. package/dist/generated/types/OracleSource.js +0 -61
  205. package/dist/generated/types/OracleValidity.d.ts +0 -25
  206. package/dist/generated/types/OracleValidity.js +0 -52
  207. package/dist/generated/types/Order.d.ts +0 -43
  208. package/dist/generated/types/Order.js +0 -68
  209. package/dist/generated/types/OrderDirection.d.ts +0 -20
  210. package/dist/generated/types/OrderDirection.js +0 -47
  211. package/dist/generated/types/OrderParams.d.ts +0 -36
  212. package/dist/generated/types/OrderParams.js +0 -61
  213. package/dist/generated/types/OrderStatus.d.ts +0 -22
  214. package/dist/generated/types/OrderStatus.js +0 -49
  215. package/dist/generated/types/OrderTriggerCondition.d.ts +0 -22
  216. package/dist/generated/types/OrderTriggerCondition.js +0 -49
  217. package/dist/generated/types/OrderType.d.ts +0 -23
  218. package/dist/generated/types/OrderType.js +0 -50
  219. package/dist/generated/types/PermissionLevel.d.ts +0 -45
  220. package/dist/generated/types/PermissionLevel.js +0 -48
  221. package/dist/generated/types/PerpHedge.d.ts +0 -17
  222. package/dist/generated/types/PerpHedge.js +0 -42
  223. package/dist/generated/types/PerpPosition.d.ts +0 -29
  224. package/dist/generated/types/PerpPosition.js +0 -54
  225. package/dist/generated/types/PoolBalance.d.ts +0 -17
  226. package/dist/generated/types/PoolBalance.js +0 -42
  227. package/dist/generated/types/Position.d.ts +0 -20
  228. package/dist/generated/types/Position.js +0 -45
  229. package/dist/generated/types/PositionDirection.d.ts +0 -20
  230. package/dist/generated/types/PositionDirection.js +0 -47
  231. package/dist/generated/types/PositionDrift.d.ts +0 -18
  232. package/dist/generated/types/PositionDrift.js +0 -43
  233. package/dist/generated/types/PostOnlyParam.d.ts +0 -22
  234. package/dist/generated/types/PostOnlyParam.js +0 -49
  235. package/dist/generated/types/Price.d.ts +0 -41
  236. package/dist/generated/types/Price.js +0 -66
  237. package/dist/generated/types/PriceComp.d.ts +0 -19
  238. package/dist/generated/types/PriceComp.js +0 -44
  239. package/dist/generated/types/PriceDivergenceGuardRails.d.ts +0 -16
  240. package/dist/generated/types/PriceDivergenceGuardRails.js +0 -41
  241. package/dist/generated/types/PriceInfo.d.ts +0 -21
  242. package/dist/generated/types/PriceInfo.js +0 -46
  243. package/dist/generated/types/PriceStatus.d.ts +0 -22
  244. package/dist/generated/types/PriceStatus.js +0 -49
  245. package/dist/generated/types/PriceType.d.ts +0 -20
  246. package/dist/generated/types/PriceType.js +0 -47
  247. package/dist/generated/types/ProcessSwapDepositArgs.d.ts +0 -15
  248. package/dist/generated/types/ProcessSwapDepositArgs.js +0 -38
  249. package/dist/generated/types/ProcessSwapDepositIntrospectionArgs.d.ts +0 -15
  250. package/dist/generated/types/ProcessSwapDepositIntrospectionArgs.js +0 -38
  251. package/dist/generated/types/Program.d.ts +0 -19
  252. package/dist/generated/types/Program.js +0 -44
  253. package/dist/generated/types/ProgramStatus.d.ts +0 -20
  254. package/dist/generated/types/ProgramStatus.js +0 -47
  255. package/dist/generated/types/RebalanceConfig.d.ts +0 -15
  256. package/dist/generated/types/RebalanceConfig.js +0 -38
  257. package/dist/generated/types/Recipient.d.ts +0 -17
  258. package/dist/generated/types/Recipient.js +0 -42
  259. package/dist/generated/types/Recipients.d.ts +0 -17
  260. package/dist/generated/types/Recipients.js +0 -42
  261. package/dist/generated/types/RedeemJlpArgs.d.ts +0 -15
  262. package/dist/generated/types/RedeemJlpArgs.js +0 -38
  263. package/dist/generated/types/Role.d.ts +0 -25
  264. package/dist/generated/types/Role.js +0 -52
  265. package/dist/generated/types/ShiftCollateral.d.ts +0 -19
  266. package/dist/generated/types/ShiftCollateral.js +0 -44
  267. package/dist/generated/types/ShiftPosition.d.ts +0 -17
  268. package/dist/generated/types/ShiftPosition.js +0 -42
  269. package/dist/generated/types/ShortHolding.d.ts +0 -17
  270. package/dist/generated/types/ShortHolding.js +0 -42
  271. package/dist/generated/types/SplBase.d.ts +0 -17
  272. package/dist/generated/types/SplBase.js +0 -42
  273. package/dist/generated/types/SplMain.d.ts +0 -22
  274. package/dist/generated/types/SplMain.js +0 -47
  275. package/dist/generated/types/Spls.d.ts +0 -17
  276. package/dist/generated/types/Spls.js +0 -42
  277. package/dist/generated/types/SpotBalanceType.d.ts +0 -20
  278. package/dist/generated/types/SpotBalanceType.js +0 -47
  279. package/dist/generated/types/SpotPosition.d.ts +0 -23
  280. package/dist/generated/types/SpotPosition.js +0 -48
  281. package/dist/generated/types/Status.d.ts +0 -20
  282. package/dist/generated/types/Status.js +0 -47
  283. package/dist/generated/types/Strategy.d.ts +0 -31
  284. package/dist/generated/types/Strategy.js +0 -56
  285. package/dist/generated/types/StrategyRoleEntry.d.ts +0 -17
  286. package/dist/generated/types/StrategyRoleEntry.js +0 -42
  287. package/dist/generated/types/SubAccount.d.ts +0 -17
  288. package/dist/generated/types/SubAccount.js +0 -42
  289. package/dist/generated/types/Update.d.ts +0 -20
  290. package/dist/generated/types/Update.js +0 -47
  291. package/dist/generated/types/UserFees.d.ts +0 -20
  292. package/dist/generated/types/UserFees.js +0 -45
  293. package/dist/generated/types/ValidityGuardRails.d.ts +0 -18
  294. package/dist/generated/types/ValidityGuardRails.js +0 -43
  295. package/dist/generated/types/index.d.ts +0 -83
  296. package/dist/generated/types/index.js +0 -99
  297. package/dist/strategies/JlpStrategy.d.ts +0 -17
  298. package/dist/strategies/JlpStrategy.js +0 -337
  299. package/dist/strategies/LstStrategy.d.ts +0 -19
  300. package/dist/strategies/LstStrategy.js +0 -169
  301. package/dist/strategies/UsdcStrategy.d.ts +0 -12
  302. package/dist/strategies/UsdcStrategy.js +0 -89
  303. package/dist/strategies/index.d.ts +0 -3
  304. package/dist/strategies/index.js +0 -19
@@ -2,12 +2,59 @@ import { Stablecoin } from "../classes/Stablecoin";
2
2
  import { Connection, PublicKey, TransactionInstruction } from "@solana/web3.js";
3
3
  import { DriftLstData } from "../generated/reflect_main";
4
4
  import BN from "bn.js";
5
+ /**
6
+ * LST (Liquid Staking Token) Delta-Neutral Stablecoin implementation.
7
+ * Extends the base Stablecoin class to provide LST-specific functionality
8
+ * including delta-neutral strategies with perpetual hedging.
9
+ *
10
+ * This stablecoin allows users to mint stablecoins against LST collateral
11
+ * while maintaining delta-neutral exposure through perpetual futures hedging.
12
+ * Strategy ID: 2
13
+ */
5
14
  export declare class LstStablecoin extends Stablecoin {
15
+ /** Array of LST data containing market indices and sub-account mappings */
6
16
  lstMap: DriftLstData[];
17
+ /**
18
+ * Creates a new LST Stablecoin instance.
19
+ *
20
+ * @param connection - Solana connection instance for RPC communication
21
+ * @param stablecoinMintOverride - Optional override for the stablecoin mint address
22
+ * @param collateralMintsOverride - Optional override for collateral mint addresses
23
+ */
7
24
  constructor(connection: Connection, stablecoinMintOverride?: PublicKey, collateralMintsOverride?: PublicKey[]);
25
+ /**
26
+ * Loads the LST controller data from the blockchain.
27
+ * Updates the stablecoin mint and LST mapping information.
28
+ *
29
+ * @param connection - Solana connection instance
30
+ */
8
31
  load(connection: Connection): Promise<void>;
32
+ /**
33
+ * Initializes the LST stablecoin with the specified parameters.
34
+ * Sets up the controller with cap, mint, and recipient information.
35
+ *
36
+ * @param signer - Public key of the signer/initializer
37
+ * @param cap - Maximum supply cap as a BN
38
+ * @param mint - Public key of the stablecoin mint
39
+ * @param recipientAddresses - Array of recipient public keys for fee distribution
40
+ * @param recipientCuts - Array of fee cuts (percentages) corresponding to each recipient
41
+ * @returns Promise resolving to an array of TransactionInstruction objects
42
+ */
9
43
  initialize(signer: PublicKey, cap: BN, mint: PublicKey, recipientAddresses: PublicKey[], recipientCuts: number[]): Promise<TransactionInstruction[]>;
44
+ /**
45
+ * Constructs the required accounts for LST mint/redeem transactions.
46
+ *
47
+ * @param signer - Public key of the transaction signer
48
+ * @param lst - Public key of the LST being used as collateral
49
+ * @returns Promise resolving to the constructed accounts object of type T
50
+ */
10
51
  constructAccounts<T>(signer: PublicKey, lst: PublicKey): Promise<T>;
52
+ /**
53
+ * Constructs remaining accounts for LST transactions.
54
+ * Includes USDC spot market, SOL oracle, and SOL perpetual market accounts.
55
+ *
56
+ * @returns Promise resolving to an array of AccountMeta objects
57
+ */
11
58
  constructRemainingAccounts(): Promise<{
12
59
  pubkey: PublicKey;
13
60
  isWritable: boolean;
@@ -21,7 +21,23 @@ const reflect_main_1 = require("../generated/reflect_main");
21
21
  const sdk_1 = require("@drift-labs/sdk");
22
22
  const spl_token_1 = require("@solana/spl-token");
23
23
  const nodewallet_1 = __importDefault(require("@coral-xyz/anchor/dist/cjs/nodewallet"));
24
+ /**
25
+ * LST (Liquid Staking Token) Delta-Neutral Stablecoin implementation.
26
+ * Extends the base Stablecoin class to provide LST-specific functionality
27
+ * including delta-neutral strategies with perpetual hedging.
28
+ *
29
+ * This stablecoin allows users to mint stablecoins against LST collateral
30
+ * while maintaining delta-neutral exposure through perpetual futures hedging.
31
+ * Strategy ID: 2
32
+ */
24
33
  class LstStablecoin extends Stablecoin_1.Stablecoin {
34
+ /**
35
+ * Creates a new LST Stablecoin instance.
36
+ *
37
+ * @param connection - Solana connection instance for RPC communication
38
+ * @param stablecoinMintOverride - Optional override for the stablecoin mint address
39
+ * @param collateralMintsOverride - Optional override for collateral mint addresses
40
+ */
25
41
  constructor(connection, stablecoinMintOverride, collateralMintsOverride) {
26
42
  super(2, "Single-Sided LST Delta-Neutral", connection);
27
43
  this.driftClient = new sdk_1.DriftClient({
@@ -35,6 +51,12 @@ class LstStablecoin extends Stablecoin_1.Stablecoin {
35
51
  if (collateralMintsOverride)
36
52
  this.collaterals = collateralMintsOverride.map(mint => ({ mint, oracle: "" }));
37
53
  }
54
+ /**
55
+ * Loads the LST controller data from the blockchain.
56
+ * Updates the stablecoin mint and LST mapping information.
57
+ *
58
+ * @param connection - Solana connection instance
59
+ */
38
60
  load(connection) {
39
61
  return __awaiter(this, void 0, void 0, function* () {
40
62
  const { lsts, baseStrategy: { mint } } = yield reflect_main_1.DriftLstController.fromAccountAddress(connection, this.controller);
@@ -48,6 +70,17 @@ class LstStablecoin extends Stablecoin_1.Stablecoin {
48
70
  });
49
71
  });
50
72
  }
73
+ /**
74
+ * Initializes the LST stablecoin with the specified parameters.
75
+ * Sets up the controller with cap, mint, and recipient information.
76
+ *
77
+ * @param signer - Public key of the signer/initializer
78
+ * @param cap - Maximum supply cap as a BN
79
+ * @param mint - Public key of the stablecoin mint
80
+ * @param recipientAddresses - Array of recipient public keys for fee distribution
81
+ * @param recipientCuts - Array of fee cuts (percentages) corresponding to each recipient
82
+ * @returns Promise resolving to an array of TransactionInstruction objects
83
+ */
51
84
  initialize(signer, cap, mint, recipientAddresses, recipientCuts) {
52
85
  return __awaiter(this, void 0, void 0, function* () {
53
86
  const ix = (0, reflect_main_1.createInitDriftControllerS3Instruction)({
@@ -65,6 +98,13 @@ class LstStablecoin extends Stablecoin_1.Stablecoin {
65
98
  return [ix];
66
99
  });
67
100
  }
101
+ /**
102
+ * Constructs the required accounts for LST mint/redeem transactions.
103
+ *
104
+ * @param signer - Public key of the transaction signer
105
+ * @param lst - Public key of the LST being used as collateral
106
+ * @returns Promise resolving to the constructed accounts object of type T
107
+ */
68
108
  constructAccounts(signer, lst) {
69
109
  return __awaiter(this, void 0, void 0, function* () {
70
110
  const { marketIndex: lstMarketIndex } = sdk_1.SpotMarkets["mainnet-beta"]
@@ -101,6 +141,12 @@ class LstStablecoin extends Stablecoin_1.Stablecoin {
101
141
  return accounts;
102
142
  });
103
143
  }
144
+ /**
145
+ * Constructs remaining accounts for LST transactions.
146
+ * Includes USDC spot market, SOL oracle, and SOL perpetual market accounts.
147
+ *
148
+ * @returns Promise resolving to an array of AccountMeta objects
149
+ */
104
150
  constructRemainingAccounts() {
105
151
  return __awaiter(this, void 0, void 0, function* () {
106
152
  const { marketIndex: usdcMarketIndex, oracle: usdcOracle, } = sdk_1.SpotMarkets["mainnet-beta"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reflectmoney/stable.ts",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
5
  "author": "stablecoinjesus @ Palindrome Engineering",
6
6
  "repository": {
@@ -1,30 +0,0 @@
1
- import { AccountMeta, Connection, Keypair, PublicKey, TransactionInstruction } from "@solana/web3.js";
2
- import BN from "bn.js";
3
- import { DriftClient } from "@drift-labs/sdk";
4
- import { Action } from "../generated";
5
- import { StablecoinMetadata } from "../types";
6
- export declare abstract class Strategy {
7
- index: number;
8
- name: string;
9
- connection: Connection;
10
- controller: PublicKey;
11
- collateralMints: PublicKey[];
12
- stablecoinMint: PublicKey;
13
- driftClient?: DriftClient;
14
- constructor(index: number, name: string, connection: Connection);
15
- initializeTokenAccounts(owner: PublicKey, mints: PublicKey[], signer: PublicKey): Promise<TransactionInstruction[]>;
16
- updateCap(signer: PublicKey, newCap: BN | number): Promise<TransactionInstruction>;
17
- freezeCollateral(signer: PublicKey, freeze: boolean, mint: PublicKey): Promise<TransactionInstruction>;
18
- freezeCollateralStrategy(signer: PublicKey, freeze: boolean, mint: PublicKey): Promise<TransactionInstruction>;
19
- updateRecipients(signer: PublicKey, recipients: Map<PublicKey, number>): Promise<TransactionInstruction>;
20
- initializeStrategyDriftAccount(signer: PublicKey, subAccountId?: number): Promise<TransactionInstruction>;
21
- initializeStrategyDriftStatsAccount(signer: PublicKey): Promise<TransactionInstruction>;
22
- freeze(signer: PublicKey, freeze: boolean, action: Action): Promise<TransactionInstruction>;
23
- initializeStablecoin(signer: PublicKey, tokenKeypair: Keypair, metadata?: StablecoinMetadata): Promise<TransactionInstruction[]>;
24
- abstract constructAccounts<T>(signer: PublicKey, ...args: any[]): Promise<T>;
25
- abstract constructRemainingAccounts(): Promise<AccountMeta[]>;
26
- abstract initialize(signer: PublicKey, ...args: any[]): Promise<TransactionInstruction[]>;
27
- abstract mint(signer: PublicKey, amount: BN | number, minimumReceived: BN | number, ...args: any[]): Promise<TransactionInstruction[]>;
28
- abstract redeem(signer: PublicKey, amount: BN | number, minimumReceived: BN | number, ...args: any[]): Promise<TransactionInstruction[]>;
29
- abstract rebalance(signer: PublicKey): Promise<TransactionInstruction[]>;
30
- }
@@ -1,196 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Strategy = void 0;
13
- const web3_js_1 = require("@solana/web3.js");
14
- const sdk_1 = require("@drift-labs/sdk");
15
- const generated_1 = require("../generated");
16
- const PdaClient_1 = require("./PdaClient");
17
- const spl_token_1 = require("@solana/spl-token");
18
- const constants_1 = require("../constants");
19
- const mpl_token_metadata_1 = require("@metaplex-foundation/mpl-token-metadata");
20
- class Strategy {
21
- constructor(index, name, connection) {
22
- this.index = index;
23
- this.name = name;
24
- this.connection = connection;
25
- this.controller = PdaClient_1.PdaClient.deriveController(this.index);
26
- }
27
- initializeTokenAccounts(owner, mints, signer) {
28
- return __awaiter(this, void 0, void 0, function* () {
29
- const instructions = [];
30
- for (const mint of mints) {
31
- const ata = (0, spl_token_1.getAssociatedTokenAddressSync)(mint, owner, true);
32
- let isInitialized = false;
33
- try {
34
- let account = yield this.connection.getAccountInfo(ata);
35
- isInitialized = account !== null;
36
- }
37
- catch (err) {
38
- isInitialized = false;
39
- }
40
- if (!isInitialized) {
41
- instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(signer, ata, owner, mint));
42
- }
43
- }
44
- return instructions;
45
- });
46
- }
47
- updateCap(signer, newCap) {
48
- return __awaiter(this, void 0, void 0, function* () {
49
- const ix = (0, generated_1.createUpdateCapInstruction)({
50
- admin: signer,
51
- main: PdaClient_1.PdaClient.deriveMain(),
52
- adminPermissions: PdaClient_1.PdaClient.derivePermissions(signer),
53
- systemProgram: web3_js_1.SystemProgram.programId,
54
- strategy: this.controller
55
- }, {
56
- newCap,
57
- }, generated_1.PROGRAM_ID);
58
- return ix;
59
- });
60
- }
61
- freezeCollateral(signer, freeze, mint) {
62
- return __awaiter(this, void 0, void 0, function* () {
63
- const ix = (0, generated_1.createSuspendLstProtocolInstruction)({
64
- admin: signer,
65
- adminPermissions: PdaClient_1.PdaClient.derivePermissions(signer),
66
- main: PdaClient_1.PdaClient.deriveMain(),
67
- systemProgram: web3_js_1.SystemProgram.programId,
68
- }, {
69
- freeze,
70
- lstMint: mint
71
- }, generated_1.PROGRAM_ID);
72
- return ix;
73
- });
74
- }
75
- freezeCollateralStrategy(signer, freeze, mint) {
76
- return __awaiter(this, void 0, void 0, function* () {
77
- const ix = (0, generated_1.createSuspendLstStrategyInstruction)({
78
- admin: signer,
79
- adminPermissions: PdaClient_1.PdaClient.derivePermissions(signer),
80
- main: PdaClient_1.PdaClient.deriveMain(),
81
- systemProgram: web3_js_1.SystemProgram.programId,
82
- strategy: this.controller
83
- }, {
84
- freeze,
85
- lstMint: mint
86
- }, generated_1.PROGRAM_ID);
87
- return ix;
88
- });
89
- }
90
- updateRecipients(signer, recipients) {
91
- return __awaiter(this, void 0, void 0, function* () {
92
- const ix = (0, generated_1.createUpdateRecipientsInstruction)({
93
- main: PdaClient_1.PdaClient.deriveMain(),
94
- adminPermissions: PdaClient_1.PdaClient.derivePermissions(signer),
95
- systemProgram: web3_js_1.SystemProgram.programId,
96
- admin: signer,
97
- strategy: this.controller
98
- }, {
99
- recipientAddresses: [...recipients.keys()],
100
- recipientCuts: [...recipients.values()],
101
- }, generated_1.PROGRAM_ID);
102
- return ix;
103
- });
104
- }
105
- initializeStrategyDriftAccount(signer_1) {
106
- return __awaiter(this, arguments, void 0, function* (signer, subAccountId = 0) {
107
- const userAccount = (0, sdk_1.getUserAccountPublicKeySync)(constants_1.DRIFT_PROGRAM_ID, this.controller, subAccountId);
108
- const userStats = (0, sdk_1.getUserStatsAccountPublicKey)(constants_1.DRIFT_PROGRAM_ID, this.controller);
109
- const [_, controllerBump] = PdaClient_1.PdaClient.deriveControllerWithBump(this.index);
110
- const ix = (0, generated_1.createAddSubAccountInstruction)({
111
- admin: signer,
112
- drift: constants_1.DRIFT_PROGRAM_ID,
113
- state: yield (0, sdk_1.getDriftStateAccountPublicKey)(constants_1.DRIFT_PROGRAM_ID),
114
- userStats,
115
- userAccount,
116
- adminPermissions: PdaClient_1.PdaClient.derivePermissions(signer),
117
- main: PdaClient_1.PdaClient.deriveMain(),
118
- rent: web3_js_1.SYSVAR_RENT_PUBKEY,
119
- systemProgram: web3_js_1.SystemProgram.programId,
120
- lstController: this.controller
121
- }, generated_1.PROGRAM_ID);
122
- return ix;
123
- });
124
- }
125
- initializeStrategyDriftStatsAccount(signer) {
126
- return __awaiter(this, void 0, void 0, function* () {
127
- const userAccount = (0, sdk_1.getUserAccountPublicKeySync)(constants_1.DRIFT_PROGRAM_ID, this.controller, 0);
128
- const userStats = (0, sdk_1.getUserStatsAccountPublicKey)(constants_1.DRIFT_PROGRAM_ID, this.controller);
129
- const [_, controllerBump] = PdaClient_1.PdaClient.deriveControllerWithBump(this.index);
130
- const ix = (0, generated_1.createCreateUserStatsAccountInstruction)({
131
- admin: signer,
132
- main: PdaClient_1.PdaClient.deriveMain(),
133
- drift: constants_1.DRIFT_PROGRAM_ID,
134
- userStats,
135
- userAccount,
136
- adminPermissions: PdaClient_1.PdaClient.derivePermissions(signer),
137
- controller: this.controller,
138
- rent: web3_js_1.SYSVAR_RENT_PUBKEY,
139
- state: yield (0, sdk_1.getDriftStateAccountPublicKey)(constants_1.DRIFT_PROGRAM_ID),
140
- systemProgram: web3_js_1.SystemProgram.programId,
141
- }, generated_1.PROGRAM_ID);
142
- return ix;
143
- });
144
- }
145
- freeze(signer, freeze, action) {
146
- return __awaiter(this, void 0, void 0, function* () {
147
- const ix = (0, generated_1.createFreezeStrategyActionInstruction)({
148
- admin: signer,
149
- main: PdaClient_1.PdaClient.deriveMain(),
150
- adminPermissions: PdaClient_1.PdaClient.derivePermissions(signer),
151
- systemProgram: web3_js_1.SystemProgram.programId,
152
- strategy: this.controller,
153
- }, {
154
- freeze,
155
- action,
156
- strategyId: this.index
157
- });
158
- return ix;
159
- });
160
- }
161
- initializeStablecoin(signer, tokenKeypair, metadata) {
162
- return __awaiter(this, void 0, void 0, function* () {
163
- const instructions = [];
164
- const createAccountInstruction = web3_js_1.SystemProgram.createAccount({
165
- lamports: yield this.connection.getMinimumBalanceForRentExemption(spl_token_1.MINT_SIZE),
166
- space: spl_token_1.MINT_SIZE,
167
- fromPubkey: signer,
168
- newAccountPubkey: tokenKeypair.publicKey,
169
- programId: spl_token_1.TOKEN_PROGRAM_ID
170
- });
171
- instructions.push(createAccountInstruction);
172
- const initializeMintInstruction = (0, spl_token_1.createInitializeMint2Instruction)(tokenKeypair.publicKey, 6, signer, signer);
173
- instructions.push(initializeMintInstruction);
174
- if (metadata) {
175
- const createMetadataInstruction = (0, mpl_token_metadata_1.createCreateMetadataAccountV3Instruction)({
176
- metadata: PdaClient_1.PdaClient.deriveMetadataAccount(tokenKeypair.publicKey),
177
- mint: tokenKeypair.publicKey,
178
- mintAuthority: signer,
179
- payer: signer,
180
- updateAuthority: signer
181
- }, {
182
- createMetadataAccountArgsV3: {
183
- data: metadata,
184
- isMutable: true,
185
- collectionDetails: null
186
- }
187
- });
188
- instructions.push(createMetadataInstruction);
189
- }
190
- const setAuthorityInstruction = (0, spl_token_1.createSetAuthorityInstruction)(tokenKeypair.publicKey, signer, spl_token_1.AuthorityType.MintTokens, this.controller);
191
- instructions.push(setAuthorityInstruction);
192
- return instructions;
193
- });
194
- }
195
- }
196
- exports.Strategy = Strategy;
@@ -1,114 +0,0 @@
1
- /**
2
- * This code was GENERATED using the solita package.
3
- * Please DO NOT EDIT THIS FILE, instead rerun solita to update it or write a wrapper to add functionality.
4
- *
5
- * See: https://github.com/metaplex-foundation/solita
6
- */
7
- import * as web3 from '@solana/web3.js';
8
- import * as beet from '@metaplex-foundation/beet';
9
- import * as beetSolana from '@metaplex-foundation/beet-solana';
10
- import { Strategy } from '../types/Strategy';
11
- import { DriftControllerBase } from '../types/DriftControllerBase';
12
- import { PerpHedge } from '../types/PerpHedge';
13
- import { JlpRebalanceSettings } from '../types/JlpRebalanceSettings';
14
- /**
15
- * Arguments used to create {@link DriftJlpController}
16
- * @category Accounts
17
- * @category generated
18
- */
19
- export type DriftJlpControllerArgs = {
20
- baseStrategy: Strategy;
21
- baseDrift: DriftControllerBase;
22
- jlpMarketIndex: number;
23
- driftPerpMarketsHedge: PerpHedge[];
24
- jlpMint: web3.PublicKey;
25
- rebalanceSettings: JlpRebalanceSettings;
26
- };
27
- export declare const driftJlpControllerDiscriminator: number[];
28
- /**
29
- * Holds the data for the {@link DriftJlpController} Account and provides de/serialization
30
- * functionality for that data
31
- *
32
- * @category Accounts
33
- * @category generated
34
- */
35
- export declare class DriftJlpController implements DriftJlpControllerArgs {
36
- readonly baseStrategy: Strategy;
37
- readonly baseDrift: DriftControllerBase;
38
- readonly jlpMarketIndex: number;
39
- readonly driftPerpMarketsHedge: PerpHedge[];
40
- readonly jlpMint: web3.PublicKey;
41
- readonly rebalanceSettings: JlpRebalanceSettings;
42
- private constructor();
43
- /**
44
- * Creates a {@link DriftJlpController} instance from the provided args.
45
- */
46
- static fromArgs(args: DriftJlpControllerArgs): DriftJlpController;
47
- /**
48
- * Deserializes the {@link DriftJlpController} from the data of the provided {@link web3.AccountInfo}.
49
- * @returns a tuple of the account data and the offset up to which the buffer was read to obtain it.
50
- */
51
- static fromAccountInfo(accountInfo: web3.AccountInfo<Buffer>, offset?: number): [DriftJlpController, number];
52
- /**
53
- * Retrieves the account info from the provided address and deserializes
54
- * the {@link DriftJlpController} from its data.
55
- *
56
- * @throws Error if no account info is found at the address or if deserialization fails
57
- */
58
- static fromAccountAddress(connection: web3.Connection, address: web3.PublicKey, commitmentOrConfig?: web3.Commitment | web3.GetAccountInfoConfig): Promise<DriftJlpController>;
59
- /**
60
- * Provides a {@link web3.Connection.getProgramAccounts} config builder,
61
- * to fetch accounts matching filters that can be specified via that builder.
62
- *
63
- * @param programId - the program that owns the accounts we are filtering
64
- */
65
- static gpaBuilder(programId?: web3.PublicKey): beetSolana.GpaBuilder<DriftJlpControllerArgs & {
66
- accountDiscriminator: number[];
67
- }>;
68
- /**
69
- * Deserializes the {@link DriftJlpController} from the provided data Buffer.
70
- * @returns a tuple of the account data and the offset up to which the buffer was read to obtain it.
71
- */
72
- static deserialize(buf: Buffer, offset?: number): [DriftJlpController, number];
73
- /**
74
- * Serializes the {@link DriftJlpController} into a Buffer.
75
- * @returns a tuple of the created Buffer and the offset up to which the buffer was written to store it.
76
- */
77
- serialize(): [Buffer, number];
78
- /**
79
- * Returns the byteSize of a {@link Buffer} holding the serialized data of
80
- * {@link DriftJlpController} for the provided args.
81
- *
82
- * @param args need to be provided since the byte size for this account
83
- * depends on them
84
- */
85
- static byteSize(args: DriftJlpControllerArgs): number;
86
- /**
87
- * Fetches the minimum balance needed to exempt an account holding
88
- * {@link DriftJlpController} data from rent
89
- *
90
- * @param args need to be provided since the byte size for this account
91
- * depends on them
92
- * @param connection used to retrieve the rent exemption information
93
- */
94
- static getMinimumBalanceForRentExemption(args: DriftJlpControllerArgs, connection: web3.Connection, commitment?: web3.Commitment): Promise<number>;
95
- /**
96
- * Returns a readable version of {@link DriftJlpController} properties
97
- * and can be used to convert to JSON and/or logging
98
- */
99
- pretty(): {
100
- baseStrategy: Strategy;
101
- baseDrift: DriftControllerBase;
102
- jlpMarketIndex: number;
103
- driftPerpMarketsHedge: PerpHedge[];
104
- jlpMint: string;
105
- rebalanceSettings: JlpRebalanceSettings;
106
- };
107
- }
108
- /**
109
- * @category Accounts
110
- * @category generated
111
- */
112
- export declare const driftJlpControllerBeet: beet.FixableBeetStruct<DriftJlpController, DriftJlpControllerArgs & {
113
- accountDiscriminator: number[];
114
- }>;
@@ -1,169 +0,0 @@
1
- "use strict";
2
- /**
3
- * This code was GENERATED using the solita package.
4
- * Please DO NOT EDIT THIS FILE, instead rerun solita to update it or write a wrapper to add functionality.
5
- *
6
- * See: https://github.com/metaplex-foundation/solita
7
- */
8
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- var desc = Object.getOwnPropertyDescriptor(m, k);
11
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
- desc = { enumerable: true, get: function() { return m[k]; } };
13
- }
14
- Object.defineProperty(o, k2, desc);
15
- }) : (function(o, m, k, k2) {
16
- if (k2 === undefined) k2 = k;
17
- o[k2] = m[k];
18
- }));
19
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
- Object.defineProperty(o, "default", { enumerable: true, value: v });
21
- }) : function(o, v) {
22
- o["default"] = v;
23
- });
24
- var __importStar = (this && this.__importStar) || function (mod) {
25
- if (mod && mod.__esModule) return mod;
26
- var result = {};
27
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
- __setModuleDefault(result, mod);
29
- return result;
30
- };
31
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
32
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
33
- return new (P || (P = Promise))(function (resolve, reject) {
34
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
35
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
36
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
37
- step((generator = generator.apply(thisArg, _arguments || [])).next());
38
- });
39
- };
40
- Object.defineProperty(exports, "__esModule", { value: true });
41
- exports.driftJlpControllerBeet = exports.DriftJlpController = exports.driftJlpControllerDiscriminator = void 0;
42
- const web3 = __importStar(require("@solana/web3.js"));
43
- const beet = __importStar(require("@metaplex-foundation/beet"));
44
- const beetSolana = __importStar(require("@metaplex-foundation/beet-solana"));
45
- const Strategy_1 = require("../types/Strategy");
46
- const DriftControllerBase_1 = require("../types/DriftControllerBase");
47
- const PerpHedge_1 = require("../types/PerpHedge");
48
- const JlpRebalanceSettings_1 = require("../types/JlpRebalanceSettings");
49
- exports.driftJlpControllerDiscriminator = [55, 62, 4, 59, 216, 18, 89, 118];
50
- /**
51
- * Holds the data for the {@link DriftJlpController} Account and provides de/serialization
52
- * functionality for that data
53
- *
54
- * @category Accounts
55
- * @category generated
56
- */
57
- class DriftJlpController {
58
- constructor(baseStrategy, baseDrift, jlpMarketIndex, driftPerpMarketsHedge, jlpMint, rebalanceSettings) {
59
- this.baseStrategy = baseStrategy;
60
- this.baseDrift = baseDrift;
61
- this.jlpMarketIndex = jlpMarketIndex;
62
- this.driftPerpMarketsHedge = driftPerpMarketsHedge;
63
- this.jlpMint = jlpMint;
64
- this.rebalanceSettings = rebalanceSettings;
65
- }
66
- /**
67
- * Creates a {@link DriftJlpController} instance from the provided args.
68
- */
69
- static fromArgs(args) {
70
- return new DriftJlpController(args.baseStrategy, args.baseDrift, args.jlpMarketIndex, args.driftPerpMarketsHedge, args.jlpMint, args.rebalanceSettings);
71
- }
72
- /**
73
- * Deserializes the {@link DriftJlpController} from the data of the provided {@link web3.AccountInfo}.
74
- * @returns a tuple of the account data and the offset up to which the buffer was read to obtain it.
75
- */
76
- static fromAccountInfo(accountInfo, offset = 0) {
77
- return DriftJlpController.deserialize(accountInfo.data, offset);
78
- }
79
- /**
80
- * Retrieves the account info from the provided address and deserializes
81
- * the {@link DriftJlpController} from its data.
82
- *
83
- * @throws Error if no account info is found at the address or if deserialization fails
84
- */
85
- static fromAccountAddress(connection, address, commitmentOrConfig) {
86
- return __awaiter(this, void 0, void 0, function* () {
87
- const accountInfo = yield connection.getAccountInfo(address, commitmentOrConfig);
88
- if (accountInfo == null) {
89
- throw new Error(`Unable to find DriftJlpController account at ${address}`);
90
- }
91
- return DriftJlpController.fromAccountInfo(accountInfo, 0)[0];
92
- });
93
- }
94
- /**
95
- * Provides a {@link web3.Connection.getProgramAccounts} config builder,
96
- * to fetch accounts matching filters that can be specified via that builder.
97
- *
98
- * @param programId - the program that owns the accounts we are filtering
99
- */
100
- static gpaBuilder(programId = new web3.PublicKey('9CtYQNCz3LaQ9DnqXa83q6gdHGwMeN6aQ7KqqotBmeke')) {
101
- return beetSolana.GpaBuilder.fromStruct(programId, exports.driftJlpControllerBeet);
102
- }
103
- /**
104
- * Deserializes the {@link DriftJlpController} from the provided data Buffer.
105
- * @returns a tuple of the account data and the offset up to which the buffer was read to obtain it.
106
- */
107
- static deserialize(buf, offset = 0) {
108
- return exports.driftJlpControllerBeet.deserialize(buf, offset);
109
- }
110
- /**
111
- * Serializes the {@link DriftJlpController} into a Buffer.
112
- * @returns a tuple of the created Buffer and the offset up to which the buffer was written to store it.
113
- */
114
- serialize() {
115
- return exports.driftJlpControllerBeet.serialize(Object.assign({ accountDiscriminator: exports.driftJlpControllerDiscriminator }, this));
116
- }
117
- /**
118
- * Returns the byteSize of a {@link Buffer} holding the serialized data of
119
- * {@link DriftJlpController} for the provided args.
120
- *
121
- * @param args need to be provided since the byte size for this account
122
- * depends on them
123
- */
124
- static byteSize(args) {
125
- const instance = DriftJlpController.fromArgs(args);
126
- return exports.driftJlpControllerBeet.toFixedFromValue(Object.assign({ accountDiscriminator: exports.driftJlpControllerDiscriminator }, instance)).byteSize;
127
- }
128
- /**
129
- * Fetches the minimum balance needed to exempt an account holding
130
- * {@link DriftJlpController} data from rent
131
- *
132
- * @param args need to be provided since the byte size for this account
133
- * depends on them
134
- * @param connection used to retrieve the rent exemption information
135
- */
136
- static getMinimumBalanceForRentExemption(args, connection, commitment) {
137
- return __awaiter(this, void 0, void 0, function* () {
138
- return connection.getMinimumBalanceForRentExemption(DriftJlpController.byteSize(args), commitment);
139
- });
140
- }
141
- /**
142
- * Returns a readable version of {@link DriftJlpController} properties
143
- * and can be used to convert to JSON and/or logging
144
- */
145
- pretty() {
146
- return {
147
- baseStrategy: this.baseStrategy,
148
- baseDrift: this.baseDrift,
149
- jlpMarketIndex: this.jlpMarketIndex,
150
- driftPerpMarketsHedge: this.driftPerpMarketsHedge,
151
- jlpMint: this.jlpMint.toBase58(),
152
- rebalanceSettings: this.rebalanceSettings,
153
- };
154
- }
155
- }
156
- exports.DriftJlpController = DriftJlpController;
157
- /**
158
- * @category Accounts
159
- * @category generated
160
- */
161
- exports.driftJlpControllerBeet = new beet.FixableBeetStruct([
162
- ['accountDiscriminator', beet.uniformFixedSizeArray(beet.u8, 8)],
163
- ['baseStrategy', Strategy_1.strategyBeet],
164
- ['baseDrift', DriftControllerBase_1.driftControllerBaseBeet],
165
- ['jlpMarketIndex', beet.u16],
166
- ['driftPerpMarketsHedge', beet.array(PerpHedge_1.perpHedgeBeet)],
167
- ['jlpMint', beetSolana.publicKey],
168
- ['rebalanceSettings', JlpRebalanceSettings_1.jlpRebalanceSettingsBeet],
169
- ], DriftJlpController.fromArgs, 'DriftJlpController');