@reflectmoney/stable.ts 1.1.0 → 1.1.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 (178) hide show
  1. package/dist/classes/ReflectTokenisedBond.js +7 -0
  2. package/dist/stablecoins/LstStablecoin.js +14 -1
  3. package/dist/stablecoins/UsdcPlusStablecoin.js +6 -1
  4. package/package.json +1 -1
  5. package/dist/classes/PdaClient.d.ts +0 -131
  6. package/dist/classes/Reflect.d.ts +0 -7
  7. package/dist/classes/ReflectAdmin.d.ts +0 -104
  8. package/dist/classes/ReflectAdmin.js +0 -219
  9. package/dist/classes/ReflectKeeper.d.ts +0 -107
  10. package/dist/classes/ReflectTokenisedBond.d.ts +0 -75
  11. package/dist/classes/Stablecoin.d.ts +0 -187
  12. package/dist/classes/index.d.ts +0 -4
  13. package/dist/constants/drift.d.ts +0 -6
  14. package/dist/constants/index.d.ts +0 -7
  15. package/dist/constants/jupiter.d.ts +0 -4
  16. package/dist/constants/lookupTables.d.ts +0 -4
  17. package/dist/constants/lst.d.ts +0 -3
  18. package/dist/constants/pyth.d.ts +0 -1
  19. package/dist/constants/usdc.d.ts +0 -6
  20. package/dist/constants/wsol.d.ts +0 -6
  21. package/dist/errors/ReflectError.d.ts +0 -4
  22. package/dist/generated/reflect_main/accounts/DriftJlpController.d.ts +0 -116
  23. package/dist/generated/reflect_main/accounts/DriftLstController.d.ts +0 -110
  24. package/dist/generated/reflect_main/accounts/DriftUsdcController.d.ts +0 -136
  25. package/dist/generated/reflect_main/accounts/Main.d.ts +0 -112
  26. package/dist/generated/reflect_main/accounts/PerpMarket.d.ts +0 -228
  27. package/dist/generated/reflect_main/accounts/PrelaunchOracle.d.ts +0 -132
  28. package/dist/generated/reflect_main/accounts/PythLazerOracle.d.ts +0 -126
  29. package/dist/generated/reflect_main/accounts/RebalanceLst.d.ts +0 -113
  30. package/dist/generated/reflect_main/accounts/SpotMarket.d.ts +0 -379
  31. package/dist/generated/reflect_main/accounts/User.d.ts +0 -223
  32. package/dist/generated/reflect_main/accounts/UserPermissions.d.ts +0 -108
  33. package/dist/generated/reflect_main/accounts/UserStats.d.ts +0 -213
  34. package/dist/generated/reflect_main/accounts/index.d.ts +0 -38
  35. package/dist/generated/reflect_main/errors/index.d.ts +0 -969
  36. package/dist/generated/reflect_main/index.d.ts +0 -19
  37. package/dist/generated/reflect_main/instructions/addLstDrift.d.ts +0 -49
  38. package/dist/generated/reflect_main/instructions/addSubAccount.d.ts +0 -54
  39. package/dist/generated/reflect_main/instructions/captureSpreadDrift.d.ts +0 -66
  40. package/dist/generated/reflect_main/instructions/captureSpreadDriftS1.d.ts +0 -58
  41. package/dist/generated/reflect_main/instructions/createAdminAccount.d.ts +0 -51
  42. package/dist/generated/reflect_main/instructions/createUserStatsAccount.d.ts +0 -52
  43. package/dist/generated/reflect_main/instructions/depositDrift.d.ts +0 -73
  44. package/dist/generated/reflect_main/instructions/freezeProgram.d.ts +0 -54
  45. package/dist/generated/reflect_main/instructions/freezeProtocolAction.d.ts +0 -55
  46. package/dist/generated/reflect_main/instructions/freezeStrategyAction.d.ts +0 -58
  47. package/dist/generated/reflect_main/instructions/index.d.ts +0 -34
  48. package/dist/generated/reflect_main/instructions/initDriftAccountsS1.d.ts +0 -54
  49. package/dist/generated/reflect_main/instructions/initDriftControllerS1.d.ts +0 -60
  50. package/dist/generated/reflect_main/instructions/initDriftControllerS3.d.ts +0 -58
  51. package/dist/generated/reflect_main/instructions/initMain.d.ts +0 -43
  52. package/dist/generated/reflect_main/instructions/mintDriftS1.d.ts +0 -86
  53. package/dist/generated/reflect_main/instructions/mintDriftS3.d.ts +0 -86
  54. package/dist/generated/reflect_main/instructions/processSwapDeposit.d.ts +0 -69
  55. package/dist/generated/reflect_main/instructions/processSwapWithdraw.d.ts +0 -69
  56. package/dist/generated/reflect_main/instructions/redeemDriftS1.d.ts +0 -87
  57. package/dist/generated/reflect_main/instructions/redeemDriftS3.d.ts +0 -87
  58. package/dist/generated/reflect_main/instructions/settlePnl.d.ts +0 -55
  59. package/dist/generated/reflect_main/instructions/settlePnlMulti.d.ts +0 -65
  60. package/dist/generated/reflect_main/instructions/suspendSplProtocol.d.ts +0 -54
  61. package/dist/generated/reflect_main/instructions/suspendSplStrategy.d.ts +0 -56
  62. package/dist/generated/reflect_main/instructions/swapOrca.d.ts +0 -81
  63. package/dist/generated/reflect_main/instructions/swapOrcaTwoHop.d.ts +0 -101
  64. package/dist/generated/reflect_main/instructions/updateActionRoleProtocol.d.ts +0 -58
  65. package/dist/generated/reflect_main/instructions/updateActionRoleStrategy.d.ts +0 -60
  66. package/dist/generated/reflect_main/instructions/updateAttenuation.d.ts +0 -57
  67. package/dist/generated/reflect_main/instructions/updateCap.d.ts +0 -55
  68. package/dist/generated/reflect_main/instructions/updateRebalanceSlippage.d.ts +0 -55
  69. package/dist/generated/reflect_main/instructions/updateRecipients.d.ts +0 -56
  70. package/dist/generated/reflect_main/instructions/updateRoleHolderProtocol.d.ts +0 -60
  71. package/dist/generated/reflect_main/instructions/updateRoleHolderStrategy.d.ts +0 -60
  72. package/dist/generated/reflect_main/types/AMM.d.ts +0 -102
  73. package/dist/generated/reflect_main/types/AccKey.d.ts +0 -15
  74. package/dist/generated/reflect_main/types/AccessControl.d.ts +0 -18
  75. package/dist/generated/reflect_main/types/AccessMap.d.ts +0 -17
  76. package/dist/generated/reflect_main/types/Action.d.ts +0 -35
  77. package/dist/generated/reflect_main/types/ActionMapping.d.ts +0 -19
  78. package/dist/generated/reflect_main/types/AssetTier.d.ts +0 -23
  79. package/dist/generated/reflect_main/types/Attenuation.d.ts +0 -16
  80. package/dist/generated/reflect_main/types/BalanceType.d.ts +0 -20
  81. package/dist/generated/reflect_main/types/Capture.d.ts +0 -17
  82. package/dist/generated/reflect_main/types/ContractTier.d.ts +0 -24
  83. package/dist/generated/reflect_main/types/ContractType.d.ts +0 -20
  84. package/dist/generated/reflect_main/types/CorpAction.d.ts +0 -19
  85. package/dist/generated/reflect_main/types/CustodyInfo.d.ts +0 -20
  86. package/dist/generated/reflect_main/types/DirectionCollateral.d.ts +0 -20
  87. package/dist/generated/reflect_main/types/DirectionPosition.d.ts +0 -20
  88. package/dist/generated/reflect_main/types/DriftControllerBase.d.ts +0 -15
  89. package/dist/generated/reflect_main/types/DriftJlpControllerFixedAccounts.d.ts +0 -18
  90. package/dist/generated/reflect_main/types/DriftLstData.d.ts +0 -17
  91. package/dist/generated/reflect_main/types/Ema.d.ts +0 -17
  92. package/dist/generated/reflect_main/types/Externals.d.ts +0 -16
  93. package/dist/generated/reflect_main/types/FlowControl.d.ts +0 -17
  94. package/dist/generated/reflect_main/types/HistoricalIndexData.d.ts +0 -19
  95. package/dist/generated/reflect_main/types/HistoricalOracleData.d.ts +0 -20
  96. package/dist/generated/reflect_main/types/Holding.d.ts +0 -21
  97. package/dist/generated/reflect_main/types/Holdings.d.ts +0 -17
  98. package/dist/generated/reflect_main/types/InsuranceClaim.d.ts +0 -19
  99. package/dist/generated/reflect_main/types/InsuranceFund.d.ts +0 -24
  100. package/dist/generated/reflect_main/types/JlpRebalanceSettings.d.ts +0 -15
  101. package/dist/generated/reflect_main/types/KillSwitch.d.ts +0 -15
  102. package/dist/generated/reflect_main/types/LevelRoles.d.ts +0 -16
  103. package/dist/generated/reflect_main/types/MarketStatus.d.ts +0 -27
  104. package/dist/generated/reflect_main/types/MarketType.d.ts +0 -20
  105. package/dist/generated/reflect_main/types/ModifyOrderParams.d.ts +0 -32
  106. package/dist/generated/reflect_main/types/ModifyOrderPolicy.d.ts +0 -20
  107. package/dist/generated/reflect_main/types/Movements.d.ts +0 -19
  108. package/dist/generated/reflect_main/types/OracleGuardRails.d.ts +0 -18
  109. package/dist/generated/reflect_main/types/OracleSource.d.ts +0 -34
  110. package/dist/generated/reflect_main/types/OracleValidity.d.ts +0 -25
  111. package/dist/generated/reflect_main/types/Order.d.ts +0 -43
  112. package/dist/generated/reflect_main/types/OrderDirection.d.ts +0 -20
  113. package/dist/generated/reflect_main/types/OrderParams.d.ts +0 -36
  114. package/dist/generated/reflect_main/types/OrderStatus.d.ts +0 -22
  115. package/dist/generated/reflect_main/types/OrderTriggerCondition.d.ts +0 -22
  116. package/dist/generated/reflect_main/types/OrderType.d.ts +0 -23
  117. package/dist/generated/reflect_main/types/PermissionLevel.d.ts +0 -51
  118. package/dist/generated/reflect_main/types/PerpHedge.d.ts +0 -17
  119. package/dist/generated/reflect_main/types/PerpPosition.d.ts +0 -29
  120. package/dist/generated/reflect_main/types/PoolBalance.d.ts +0 -17
  121. package/dist/generated/reflect_main/types/Position.d.ts +0 -20
  122. package/dist/generated/reflect_main/types/PositionDirection.d.ts +0 -20
  123. package/dist/generated/reflect_main/types/PositionDrift.d.ts +0 -18
  124. package/dist/generated/reflect_main/types/PostOnlyParam.d.ts +0 -22
  125. package/dist/generated/reflect_main/types/Price.d.ts +0 -41
  126. package/dist/generated/reflect_main/types/PriceComp.d.ts +0 -19
  127. package/dist/generated/reflect_main/types/PriceDivergenceGuardRails.d.ts +0 -16
  128. package/dist/generated/reflect_main/types/PriceInfo.d.ts +0 -21
  129. package/dist/generated/reflect_main/types/PriceStatus.d.ts +0 -22
  130. package/dist/generated/reflect_main/types/PriceType.d.ts +0 -20
  131. package/dist/generated/reflect_main/types/Program.d.ts +0 -19
  132. package/dist/generated/reflect_main/types/ProgramStatus.d.ts +0 -20
  133. package/dist/generated/reflect_main/types/Recipient.d.ts +0 -17
  134. package/dist/generated/reflect_main/types/Recipients.d.ts +0 -17
  135. package/dist/generated/reflect_main/types/Role.d.ts +0 -25
  136. package/dist/generated/reflect_main/types/ShiftCollateral.d.ts +0 -19
  137. package/dist/generated/reflect_main/types/ShiftPosition.d.ts +0 -17
  138. package/dist/generated/reflect_main/types/ShortHolding.d.ts +0 -17
  139. package/dist/generated/reflect_main/types/SplBase.d.ts +0 -17
  140. package/dist/generated/reflect_main/types/SplMain.d.ts +0 -22
  141. package/dist/generated/reflect_main/types/Spls.d.ts +0 -17
  142. package/dist/generated/reflect_main/types/SpotBalanceType.d.ts +0 -20
  143. package/dist/generated/reflect_main/types/SpotPosition.d.ts +0 -23
  144. package/dist/generated/reflect_main/types/Status.d.ts +0 -21
  145. package/dist/generated/reflect_main/types/Strategy.d.ts +0 -32
  146. package/dist/generated/reflect_main/types/StrategyPadding.d.ts +0 -15
  147. package/dist/generated/reflect_main/types/StrategyRoleEntry.d.ts +0 -17
  148. package/dist/generated/reflect_main/types/SubAccount.d.ts +0 -17
  149. package/dist/generated/reflect_main/types/Update.d.ts +0 -20
  150. package/dist/generated/reflect_main/types/UserFees.d.ts +0 -20
  151. package/dist/generated/reflect_main/types/ValidityGuardRails.d.ts +0 -18
  152. package/dist/generated/reflect_main/types/index.d.ts +0 -80
  153. package/dist/generated/reflect_tokenised_bonds/accounts/Admin.d.ts +0 -101
  154. package/dist/generated/reflect_tokenised_bonds/accounts/Config.d.ts +0 -108
  155. package/dist/generated/reflect_tokenised_bonds/accounts/Vault.d.ts +0 -116
  156. package/dist/generated/reflect_tokenised_bonds/accounts/index.d.ts +0 -11
  157. package/dist/generated/reflect_tokenised_bonds/errors/index.d.ts +0 -144
  158. package/dist/generated/reflect_tokenised_bonds/index.d.ts +0 -19
  159. package/dist/generated/reflect_tokenised_bonds/instructions/createVault.d.ts +0 -50
  160. package/dist/generated/reflect_tokenised_bonds/instructions/deposit.d.ts +0 -62
  161. package/dist/generated/reflect_tokenised_bonds/instructions/index.d.ts +0 -4
  162. package/dist/generated/reflect_tokenised_bonds/instructions/initialize.d.ts +0 -43
  163. package/dist/generated/reflect_tokenised_bonds/instructions/withdraw.d.ts +0 -62
  164. package/dist/generated/reflect_tokenised_bonds/types/DepositArgs.d.ts +0 -17
  165. package/dist/generated/reflect_tokenised_bonds/types/Permissions.d.ts +0 -21
  166. package/dist/generated/reflect_tokenised_bonds/types/WithdrawArgs.d.ts +0 -16
  167. package/dist/generated/reflect_tokenised_bonds/types/index.d.ts +0 -3
  168. package/dist/helpers/getOrcaQuote.d.ts +0 -3
  169. package/dist/idl/perpetuals.d.ts +0 -5771
  170. package/dist/index.d.ts +0 -8
  171. package/dist/stablecoins/JlpStablecoin.d.ts +0 -1
  172. package/dist/stablecoins/JlpStablecoin.js +0 -44
  173. package/dist/stablecoins/LstStablecoin.d.ts +0 -65
  174. package/dist/stablecoins/UsdcPlusStablecoin.d.ts +0 -68
  175. package/dist/stablecoins/UsdcStablecoin.d.ts +0 -64
  176. package/dist/stablecoins/UsdcStablecoin.js +0 -145
  177. package/dist/stablecoins/UsdjStablecoin.d.ts +0 -1
  178. package/dist/stablecoins/index.d.ts +0 -3
@@ -177,5 +177,12 @@ class ReflectTokenisedBond {
177
177
  return ix;
178
178
  });
179
179
  }
180
+ getVault(vaultId) {
181
+ return __awaiter(this, void 0, void 0, function* () {
182
+ const vault = PdaClient_1.PdaClient.deriveLpVault(vaultId);
183
+ const data = yield reflect_tokenised_bonds_1.Vault.fromAccountAddress(this.connection, vault);
184
+ return data;
185
+ });
186
+ }
180
187
  }
181
188
  exports.ReflectTokenisedBond = ReflectTokenisedBond;
@@ -280,7 +280,7 @@ class LstStablecoin extends Stablecoin_1.Stablecoin {
280
280
  *
281
281
  * @returns Promise resolving to the USD exchange rate as a number
282
282
  */
283
- getUsdExchangeRate() {
283
+ getBaseUsdExchangeRate() {
284
284
  return __awaiter(this, void 0, void 0, function* () {
285
285
  const usdBalances = yield Promise.all(this
286
286
  .collaterals
@@ -312,5 +312,18 @@ class LstStablecoin extends Stablecoin_1.Stablecoin {
312
312
  return totalUsdValue;
313
313
  });
314
314
  }
315
+ getReceiptUsdExchangeRate() {
316
+ return __awaiter(this, void 0, void 0, function* () {
317
+ const baseUsdExchangeRate = yield this.getBaseUsdExchangeRate();
318
+ const vault = yield this.tokenisedBondsClient.getVault(this.index);
319
+ const { amount: poolDeposits } = yield (0, spl_token_1.getAccount)(this.connection, classes_1.PdaClient.deriveLpVaultPool(this.index), "confirmed");
320
+ const { supply: receiptSupply, decimals: receiptDecimals } = yield (0, spl_token_1.getMint)(this.connection, vault.receiptTokenMint, "confirmed");
321
+ const exchangeRate = new bn_js_1.default(poolDeposits.toString()) // with deposit decimals equal receipt decimals
322
+ .mul(new bn_js_1.default(baseUsdExchangeRate)) // with exchange rate precision
323
+ .div(new bn_js_1.default(receiptSupply.toString())) // with receipt decimals, cancel out deposit decimals
324
+ .toNumber();
325
+ return exchangeRate;
326
+ });
327
+ }
315
328
  }
316
329
  exports.LstStablecoin = LstStablecoin;
@@ -254,7 +254,7 @@ class UsdcPlusStablecoin extends Stablecoin_1.Stablecoin {
254
254
  *
255
255
  * @returns Promise resolving to the USD exchange rate as a number
256
256
  */
257
- getUsdExchangeRate() {
257
+ getBaseUsdExchangeRate() {
258
258
  return __awaiter(this, void 0, void 0, function* () {
259
259
  const { scaledBalance, balanceType } = this
260
260
  .driftClient
@@ -275,5 +275,10 @@ class UsdcPlusStablecoin extends Stablecoin_1.Stablecoin {
275
275
  return exchangeRate.toNumber();
276
276
  });
277
277
  }
278
+ getReceiptUsdExchangeRate() {
279
+ return __awaiter(this, void 0, void 0, function* () {
280
+ return this.getBaseUsdExchangeRate();
281
+ });
282
+ }
278
283
  }
279
284
  exports.UsdcPlusStablecoin = UsdcPlusStablecoin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reflectmoney/stable.ts",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "type": "commonjs",
5
5
  "author": "stablecoinjesus @ Palindrome Engineering",
6
6
  "repository": {
@@ -1,131 +0,0 @@
1
- import { PublicKey } from "@solana/web3.js";
2
- /**
3
- * Utility class for deriving Program Derived Addresses (PDAs) used throughout the Reflect protocol.
4
- * Provides static methods to generate deterministic addresses for various program accounts
5
- * including main program accounts, controllers, permissions, and external protocol integrations.
6
- */
7
- export declare class PdaClient {
8
- /**
9
- * Derives the main program account address.
10
- * This is the primary account that stores global protocol state.
11
- *
12
- * @returns PublicKey of the main program account
13
- */
14
- static deriveMain(): PublicKey;
15
- /**
16
- * Derives the permissions account address for a specific user.
17
- * This account stores the user's role-based permissions within the protocol.
18
- *
19
- * @param user - Public key of the user
20
- * @returns PublicKey of the user's permissions account
21
- */
22
- static derivePermissions(user: PublicKey): PublicKey;
23
- /**
24
- * Derives the controller account address for a specific strategy.
25
- * Each stablecoin strategy has its own controller account.
26
- *
27
- * @param strategy - Strategy index (0: USDC+, 1: JLP, 2: LST)
28
- * @returns PublicKey of the strategy controller account
29
- */
30
- static deriveController(strategy: number): PublicKey;
31
- /**
32
- * Derives the controller account address with bump seed for a specific strategy.
33
- * Returns both the public key and the bump seed.
34
- *
35
- * @param strategy - Strategy index (0: USDC+, 1: JLP, 2: LST)
36
- * @returns Array containing [PublicKey, number] where number is the bump seed
37
- */
38
- static deriveControllerWithBump(strategy: number): [PublicKey, number];
39
- /**
40
- * Derives the rebalance details account address for a specific strategy.
41
- * This account stores information about rebalancing operations.
42
- *
43
- * @param strategy - Strategy index (0: USDC+, 1: JLP, 2: LST)
44
- * @returns PublicKey of the rebalance details account
45
- */
46
- static deriveRebalanceDetails(strategy: number): PublicKey;
47
- /**
48
- * Derives the Jupiter Perpetuals program account address.
49
- * Used for integration with Jupiter's perpetuals protocol.
50
- *
51
- * @returns PublicKey of the Jupiter Perpetuals account
52
- */
53
- static deriveJupiterPerpetuals(): PublicKey;
54
- /**
55
- * Derives the Jupiter LP pool account address.
56
- * Used for JLP (Jupiter LP) token operations.
57
- *
58
- * @returns PublicKey of the JLP pool account
59
- */
60
- static deriveJlpPool(): PublicKey;
61
- /**
62
- * Derives the Jupiter event authority account address.
63
- * Used for event emission in Jupiter protocol interactions.
64
- *
65
- * @returns PublicKey of the Jupiter event authority account
66
- */
67
- static deriveEventAuthority(): PublicKey;
68
- /**
69
- * Derives the Jupiter transfer authority account address.
70
- * Used for token transfer operations in Jupiter protocol.
71
- *
72
- * @returns PublicKey of the Jupiter transfer authority account
73
- */
74
- static deriveTransferAuthority(): PublicKey;
75
- /**
76
- * Gets the Drift vault address for a specific mint.
77
- * Looks up the market index for the mint and derives the corresponding vault address.
78
- *
79
- * @param mint - Public key of the token mint
80
- * @returns Promise resolving to the PublicKey of the Drift vault account
81
- */
82
- static getDriftVaultFromMint(mint: PublicKey): Promise<PublicKey>;
83
- /**
84
- * Derives the token metadata account address for a mint.
85
- * Used for storing token metadata information.
86
- *
87
- * @param mint - Public key of the token mint
88
- * @returns PublicKey of the metadata account
89
- */
90
- static deriveMetadataAccount(mint: PublicKey): PublicKey;
91
- /**
92
- * Derives the custody account address for a pool and token combination.
93
- * Used in Jupiter protocol for token custody management.
94
- *
95
- * @param pool - Public key of the pool
96
- * @param token - Public key of the token
97
- * @returns PublicKey of the custody account
98
- */
99
- static deriveCustody(pool: PublicKey, token: PublicKey): PublicKey;
100
- /**
101
- * Derives the LP config account address.
102
- * Used for tokenized bonds program configuration.
103
- *
104
- * @returns PublicKey of the LP config account
105
- */
106
- static deriveLpConfig(): PublicKey;
107
- /**
108
- * Derives the LP admin account address for a specific admin.
109
- * Used for tokenized bonds program administration.
110
- *
111
- * @param admin - Public key of the admin
112
- * @returns PublicKey of the LP admin account
113
- */
114
- static deriveLpAdmin(admin: PublicKey): PublicKey;
115
- /**
116
- * Derives the LP vault account address for a specific vault ID.
117
- * Used for tokenized bonds vault management.
118
- *
119
- * @param vaultId - Numeric identifier for the vault
120
- * @returns PublicKey of the LP vault account
121
- */
122
- static deriveLpVault(vaultId: number): PublicKey;
123
- /**
124
- * Derives the LP vault pool account address for a specific vault ID.
125
- * Used for tokenized bonds vault pool management.
126
- *
127
- * @param vaultId - Numeric identifier for the vault
128
- * @returns PublicKey of the LP vault pool account
129
- */
130
- static deriveLpVaultPool(vaultId: number): PublicKey;
131
- }
@@ -1,7 +0,0 @@
1
- import { Connection } from "@solana/web3.js";
2
- import { Main } from "../generated/reflect_main";
3
- export declare class Reflect {
4
- connection: Connection;
5
- constructor(connection: Connection);
6
- fetchMain(): Promise<Main>;
7
- }
@@ -1,104 +0,0 @@
1
- import { Connection, PublicKey } from "@solana/web3.js";
2
- import { Action, Role, Update } from "../generated/reflect_main";
3
- /**
4
- * Administrative client for the Reflect protocol.
5
- * Provides functionality for protocol-level administration including:
6
- * - Protocol initialization and setup
7
- * - Role and permission management
8
- * - Action freezing/unfreezing
9
- * - Admin account creation and management
10
- *
11
- * This class is used by protocol administrators to manage global settings,
12
- * user permissions, and protocol-wide configurations.
13
- */
14
- export declare class ReflectAdmin {
15
- /** Public key of the admin user */
16
- private admin;
17
- /** Public key of the main program account */
18
- private main;
19
- /** Solana connection instance for RPC communication */
20
- private connection;
21
- /**
22
- * Creates a new ReflectAdmin instance.
23
- *
24
- * @param admin - Public key of the admin user
25
- * @param connection - Solana connection instance
26
- */
27
- constructor({ admin, connection }: {
28
- admin: PublicKey;
29
- connection: Connection;
30
- });
31
- /**
32
- * Creates the main program account. This is the initial step of protocol setup.
33
- *
34
- * @param admin - Public key of the initial admin
35
- * @returns TransactionInstruction for initializing the main account
36
- */
37
- static initializeMain(admin: PublicKey): import("@solana/web3.js").TransactionInstruction;
38
- /**
39
- * Freezes or unfreezes a specific protocol action.
40
- *
41
- * @param freeze - Whether to freeze (true) or unfreeze (false) the action
42
- * @param action - The action to freeze/unfreeze
43
- * @returns Promise resolving to a TransactionInstruction
44
- */
45
- freezeProtocolAction(freeze: boolean, action: Action): Promise<import("@solana/web3.js").TransactionInstruction>;
46
- /**
47
- * Freezes or unfreezes a specific DEX program.
48
- *
49
- * @param freeze - Whether to freeze (true) or unfreeze (false) the program
50
- * @param programIndex - Index of the program to freeze/unfreeze
51
- * @returns Promise resolving to a TransactionInstruction
52
- */
53
- freezeDex(freeze: boolean, programIndex: number): Promise<import("@solana/web3.js").TransactionInstruction>;
54
- /**
55
- * Creates a new admin account with specified permissions.
56
- *
57
- * @param signer - Public key of the caller (must be existing admin)
58
- * @param newAdmin - Public key of the new admin to create
59
- * @returns Promise resolving to a TransactionInstruction
60
- */
61
- createAdminAccount(signer: PublicKey, newAdmin: PublicKey): Promise<import("@solana/web3.js").TransactionInstruction>;
62
- /**
63
- * Updates role holder permissions at the protocol level.
64
- *
65
- * @param signer - Public key of the admin signer
66
- * @param adminToUpdate - Public key of the admin whose permissions are being updated
67
- * @param affectedRole - The role being modified
68
- * @param update - The type of update (Grant or Revoke)
69
- * @returns Promise resolving to a TransactionInstruction
70
- */
71
- updateRoleHolderProtocol(signer: PublicKey, adminToUpdate: PublicKey, affectedRole: Role, update: Update): Promise<import("@solana/web3.js").TransactionInstruction>;
72
- /**
73
- * Updates role holder permissions for a specific strategy.
74
- *
75
- * @param signer - Public key of the admin signer
76
- * @param strategyId - ID of the strategy to update permissions for
77
- * @param adminToUpdate - Public key of the admin whose permissions are being updated
78
- * @param affectedRole - The role being modified
79
- * @param update - The type of update (Grant or Revoke)
80
- * @returns Promise resolving to a TransactionInstruction
81
- */
82
- updateRoleHolderStrategy(signer: PublicKey, strategyId: number, adminToUpdate: PublicKey, affectedRole: Role, update: Update): Promise<import("@solana/web3.js").TransactionInstruction>;
83
- /**
84
- * Updates action role permissions for a specific strategy.
85
- *
86
- * @param signer - Public key of the admin signer
87
- * @param strategyId - ID of the strategy to update permissions for
88
- * @param action - The action being modified
89
- * @param affectedRole - The role being modified
90
- * @param update - The type of update (Grant or Revoke)
91
- * @returns Promise resolving to a TransactionInstruction
92
- */
93
- updateActionRoleStrategy(signer: PublicKey, strategyId: number, action: Action, affectedRole: Role, update: Update): Promise<import("@solana/web3.js").TransactionInstruction>;
94
- /**
95
- * Updates action role permissions at the protocol level.
96
- *
97
- * @param signer - Public key of the admin signer
98
- * @param action - The action being modified
99
- * @param affectedRole - The role being modified
100
- * @param update - The type of update (Grant or Revoke)
101
- * @returns Promise resolving to a TransactionInstruction
102
- */
103
- updateActionRoleProtocol(signer: PublicKey, action: Action, affectedRole: Role, update: Update): Promise<import("@solana/web3.js").TransactionInstruction>;
104
- }
@@ -1,219 +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.ReflectAdmin = void 0;
13
- const web3_js_1 = require("@solana/web3.js");
14
- const reflect_main_1 = require("../generated/reflect_main");
15
- const PdaClient_1 = require("./PdaClient");
16
- /**
17
- * Administrative client for the Reflect protocol.
18
- * Provides functionality for protocol-level administration including:
19
- * - Protocol initialization and setup
20
- * - Role and permission management
21
- * - Action freezing/unfreezing
22
- * - Admin account creation and management
23
- *
24
- * This class is used by protocol administrators to manage global settings,
25
- * user permissions, and protocol-wide configurations.
26
- */
27
- class ReflectAdmin {
28
- /**
29
- * Creates a new ReflectAdmin instance.
30
- *
31
- * @param admin - Public key of the admin user
32
- * @param connection - Solana connection instance
33
- */
34
- constructor({ admin, connection }) {
35
- this.admin = admin;
36
- this.connection = connection;
37
- this.main = PdaClient_1.PdaClient.deriveMain();
38
- }
39
- /**
40
- * Creates the main program account. This is the initial step of protocol setup.
41
- *
42
- * @param admin - Public key of the initial admin
43
- * @returns TransactionInstruction for initializing the main account
44
- */
45
- static initializeMain(admin) {
46
- const [main] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("main")], reflect_main_1.PROGRAM_ID);
47
- const ix = (0, reflect_main_1.createInitMainInstruction)({
48
- main,
49
- admin,
50
- systemProgram: web3_js_1.SystemProgram.programId,
51
- creds: PdaClient_1.PdaClient.derivePermissions(admin)
52
- }, reflect_main_1.PROGRAM_ID);
53
- return ix;
54
- }
55
- /**
56
- * Freezes or unfreezes a specific protocol action.
57
- *
58
- * @param freeze - Whether to freeze (true) or unfreeze (false) the action
59
- * @param action - The action to freeze/unfreeze
60
- * @returns Promise resolving to a TransactionInstruction
61
- */
62
- freezeProtocolAction(freeze, action) {
63
- return __awaiter(this, void 0, void 0, function* () {
64
- const ix = (0, reflect_main_1.createFreezeProtocolActionInstruction)({
65
- admin: this.admin,
66
- main: this.main,
67
- systemProgram: web3_js_1.SystemProgram.programId,
68
- adminPermissions: PdaClient_1.PdaClient.derivePermissions(this.admin),
69
- }, {
70
- freeze,
71
- action
72
- });
73
- return ix;
74
- });
75
- }
76
- /**
77
- * Freezes or unfreezes a specific DEX program.
78
- *
79
- * @param freeze - Whether to freeze (true) or unfreeze (false) the program
80
- * @param programIndex - Index of the program to freeze/unfreeze
81
- * @returns Promise resolving to a TransactionInstruction
82
- */
83
- freezeDex(freeze, programIndex) {
84
- return __awaiter(this, void 0, void 0, function* () {
85
- const ix = (0, reflect_main_1.createFreezeProgramInstruction)({
86
- admin: this.admin,
87
- main: this.main,
88
- systemProgram: web3_js_1.SystemProgram.programId,
89
- adminPermissions: PdaClient_1.PdaClient.derivePermissions(this.admin),
90
- }, {
91
- freeze,
92
- programIndex
93
- });
94
- return ix;
95
- });
96
- }
97
- /**
98
- * Creates a new admin account with specified permissions.
99
- *
100
- * @param signer - Public key of the caller (must be existing admin)
101
- * @param newAdmin - Public key of the new admin to create
102
- * @returns Promise resolving to a TransactionInstruction
103
- */
104
- createAdminAccount(signer, newAdmin) {
105
- return __awaiter(this, void 0, void 0, function* () {
106
- const ix = (0, reflect_main_1.createCreateAdminAccountInstruction)({
107
- caller: signer,
108
- newCreds: PdaClient_1.PdaClient.derivePermissions(newAdmin),
109
- systemProgram: web3_js_1.SystemProgram.programId,
110
- }, {
111
- newAdmin
112
- }, reflect_main_1.PROGRAM_ID);
113
- return ix;
114
- });
115
- }
116
- /**
117
- * Updates role holder permissions at the protocol level.
118
- *
119
- * @param signer - Public key of the admin signer
120
- * @param adminToUpdate - Public key of the admin whose permissions are being updated
121
- * @param affectedRole - The role being modified
122
- * @param update - The type of update (Grant or Revoke)
123
- * @returns Promise resolving to a TransactionInstruction
124
- */
125
- updateRoleHolderProtocol(signer, adminToUpdate, affectedRole, update) {
126
- return __awaiter(this, void 0, void 0, function* () {
127
- const ix = (0, reflect_main_1.createUpdateRoleHolderProtocolInstruction)({
128
- admin: signer,
129
- adminPermissions: PdaClient_1.PdaClient.derivePermissions(signer),
130
- main: PdaClient_1.PdaClient.deriveMain(),
131
- systemProgram: web3_js_1.SystemProgram.programId,
132
- updateAdminPermissions: PdaClient_1.PdaClient.derivePermissions(adminToUpdate),
133
- // Dummy strategy account.
134
- strategy: PdaClient_1.PdaClient.deriveController(0)
135
- }, {
136
- update,
137
- accessLevel: affectedRole,
138
- }, reflect_main_1.PROGRAM_ID);
139
- return ix;
140
- });
141
- }
142
- /**
143
- * Updates role holder permissions for a specific strategy.
144
- *
145
- * @param signer - Public key of the admin signer
146
- * @param strategyId - ID of the strategy to update permissions for
147
- * @param adminToUpdate - Public key of the admin whose permissions are being updated
148
- * @param affectedRole - The role being modified
149
- * @param update - The type of update (Grant or Revoke)
150
- * @returns Promise resolving to a TransactionInstruction
151
- */
152
- updateRoleHolderStrategy(signer, strategyId, adminToUpdate, affectedRole, update) {
153
- return __awaiter(this, void 0, void 0, function* () {
154
- const ix = (0, reflect_main_1.createUpdateRoleHolderStrategyInstruction)({
155
- admin: signer,
156
- adminPermissions: PdaClient_1.PdaClient.derivePermissions(signer),
157
- main: PdaClient_1.PdaClient.deriveMain(),
158
- systemProgram: web3_js_1.SystemProgram.programId,
159
- updateAdminPermissions: PdaClient_1.PdaClient.derivePermissions(adminToUpdate),
160
- strategy: PdaClient_1.PdaClient.deriveController(strategyId)
161
- }, {
162
- update,
163
- role: affectedRole,
164
- }, reflect_main_1.PROGRAM_ID);
165
- return ix;
166
- });
167
- }
168
- /**
169
- * Updates action role permissions for a specific strategy.
170
- *
171
- * @param signer - Public key of the admin signer
172
- * @param strategyId - ID of the strategy to update permissions for
173
- * @param action - The action being modified
174
- * @param affectedRole - The role being modified
175
- * @param update - The type of update (Grant or Revoke)
176
- * @returns Promise resolving to a TransactionInstruction
177
- */
178
- updateActionRoleStrategy(signer, strategyId, action, affectedRole, update) {
179
- return __awaiter(this, void 0, void 0, function* () {
180
- const ix = (0, reflect_main_1.createUpdateActionRoleStrategyInstruction)({
181
- admin: signer,
182
- adminPermissions: PdaClient_1.PdaClient.derivePermissions(signer),
183
- main: PdaClient_1.PdaClient.deriveMain(),
184
- systemProgram: web3_js_1.SystemProgram.programId,
185
- strategy: PdaClient_1.PdaClient.deriveController(strategyId)
186
- }, {
187
- update,
188
- role: affectedRole,
189
- action
190
- }, reflect_main_1.PROGRAM_ID);
191
- return ix;
192
- });
193
- }
194
- /**
195
- * Updates action role permissions at the protocol level.
196
- *
197
- * @param signer - Public key of the admin signer
198
- * @param action - The action being modified
199
- * @param affectedRole - The role being modified
200
- * @param update - The type of update (Grant or Revoke)
201
- * @returns Promise resolving to a TransactionInstruction
202
- */
203
- updateActionRoleProtocol(signer, action, affectedRole, update) {
204
- return __awaiter(this, void 0, void 0, function* () {
205
- const ix = (0, reflect_main_1.createUpdateActionRoleProtocolInstruction)({
206
- admin: signer,
207
- adminPermissions: PdaClient_1.PdaClient.derivePermissions(signer),
208
- main: PdaClient_1.PdaClient.deriveMain(),
209
- systemProgram: web3_js_1.SystemProgram.programId,
210
- }, {
211
- action,
212
- role: affectedRole,
213
- update
214
- }, reflect_main_1.PROGRAM_ID);
215
- return ix;
216
- });
217
- }
218
- }
219
- exports.ReflectAdmin = ReflectAdmin;
@@ -1,107 +0,0 @@
1
- /// <reference types="@drift-labs/sdk/node_modules/@solana/web3.js" />
2
- /// <reference types="jito-ts/node_modules/@solana/web3.js" />
3
- import { Connection, PublicKey } from "@solana/web3.js";
4
- import { Action, Role, Update, UserPermissions } from "../generated/reflect_main";
5
- /**
6
- * Administrative client for the Reflect protocol.
7
- * Provides functionality for protocol-level administration including:
8
- * - Protocol initialization and setup
9
- * - Role and permission management
10
- * - Action freezing/unfreezing
11
- * - Admin account creation and management
12
- *
13
- * This class is used by protocol administrators to manage global settings,
14
- * user permissions, and protocol-wide configurations.
15
- */
16
- export declare class ReflectKeeper {
17
- /** Public key of the admin user */
18
- private admin;
19
- /** Public key of the main program account */
20
- private main;
21
- /** Solana connection instance for RPC communication */
22
- private connection;
23
- /**
24
- * Creates a new ReflectKeeper instance.
25
- *
26
- * @param admin - Public key of the admin user
27
- * @param connection - Solana connection instance
28
- */
29
- constructor({ admin, connection }: {
30
- admin: PublicKey;
31
- connection: Connection;
32
- });
33
- /**
34
- * Creates the main program account. This is the initial step of protocol setup.
35
- *
36
- * @param admin - Public key of the initial admin
37
- * @returns TransactionInstruction for initializing the main account
38
- */
39
- static initializeMain(admin: PublicKey): import("@solana/web3.js").TransactionInstruction;
40
- getPermissionAccount(): Promise<UserPermissions>;
41
- /**
42
- * Freezes or unfreezes a specific protocol action.
43
- *
44
- * @param freeze - Whether to freeze (true) or unfreeze (false) the action
45
- * @param action - The action to freeze/unfreeze
46
- * @returns Promise resolving to a TransactionInstruction
47
- */
48
- freezeProtocolAction(freeze: boolean, action: Action): Promise<import("@solana/web3.js").TransactionInstruction>;
49
- /**
50
- * Freezes or unfreezes a specific DEX program.
51
- *
52
- * @param freeze - Whether to freeze (true) or unfreeze (false) the program
53
- * @param programIndex - Index of the program to freeze/unfreeze
54
- * @returns Promise resolving to a TransactionInstruction
55
- */
56
- freezeDex(freeze: boolean, programIndex: number): Promise<import("@solana/web3.js").TransactionInstruction>;
57
- /**
58
- * Creates a new admin account with specified permissions.
59
- *
60
- * @param signer - Public key of the caller (must be existing admin)
61
- * @param newAdmin - Public key of the new admin to create
62
- * @returns Promise resolving to a TransactionInstruction
63
- */
64
- createAdminAccount(signer: PublicKey, newAdmin: PublicKey): Promise<import("@solana/web3.js").TransactionInstruction>;
65
- /**
66
- * Updates role holder permissions at the protocol level.
67
- *
68
- * @param signer - Public key of the admin signer
69
- * @param adminToUpdate - Public key of the admin whose permissions are being updated
70
- * @param affectedRole - The role being modified
71
- * @param update - The type of update (Grant or Revoke)
72
- * @returns Promise resolving to a TransactionInstruction
73
- */
74
- updateRoleHolderProtocol(signer: PublicKey, adminToUpdate: PublicKey, affectedRole: Role, update: Update): Promise<import("@solana/web3.js").TransactionInstruction>;
75
- /**
76
- * Updates role holder permissions for a specific strategy.
77
- *
78
- * @param signer - Public key of the admin signer
79
- * @param strategyId - ID of the strategy to update permissions for
80
- * @param adminToUpdate - Public key of the admin whose permissions are being updated
81
- * @param affectedRole - The role being modified
82
- * @param update - The type of update (Grant or Revoke)
83
- * @returns Promise resolving to a TransactionInstruction
84
- */
85
- updateRoleHolderStrategy(signer: PublicKey, strategyId: number, adminToUpdate: PublicKey, affectedRole: Role, update: Update): Promise<import("@solana/web3.js").TransactionInstruction>;
86
- /**
87
- * Updates action role permissions for a specific strategy.
88
- *
89
- * @param signer - Public key of the admin signer
90
- * @param strategyId - ID of the strategy to update permissions for
91
- * @param action - The action being modified
92
- * @param affectedRole - The role being modified
93
- * @param update - The type of update (Grant or Revoke)
94
- * @returns Promise resolving to a TransactionInstruction
95
- */
96
- updateActionRoleStrategy(signer: PublicKey, strategyId: number, action: Action, affectedRole: Role, update: Update): Promise<import("@solana/web3.js").TransactionInstruction>;
97
- /**
98
- * Updates action role permissions at the protocol level.
99
- *
100
- * @param signer - Public key of the admin signer
101
- * @param action - The action being modified
102
- * @param affectedRole - The role being modified
103
- * @param update - The type of update (Grant or Revoke)
104
- * @returns Promise resolving to a TransactionInstruction
105
- */
106
- updateActionRoleProtocol(signer: PublicKey, action: Action, affectedRole: Role, update: Update): Promise<import("@solana/web3.js").TransactionInstruction>;
107
- }