@reflectmoney/stable.ts 1.0.3 → 1.0.5

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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # @reflectmoney/stable.ts | Reflect SDK
1
+ # Reflect Money SDK
2
2
 
3
- A TypeScript SDK for interacting with the Reflect programs on Solana. This SDK provides high-level abstractions for minting, redeeming and managing stablecoins, administrative operations, and protocol integrations.
3
+ A TypeScript SDK for interacting with the Reflect programs on Solana. This SDK provides high-level abstractions for minting, redeeming, and managing stablecoins, administrative operations, and protocol integrations.
4
4
 
5
5
  ## Installation
6
6
 
@@ -15,8 +15,8 @@ yarn add @reflectmoney/stable.ts
15
15
  The Reflect SDK enables developers to interact with the protocol via three main Reflect stablecoins:
16
16
 
17
17
  1. **USDC+ (Index 0)**: Stablecoin backed by USDC deployed in various money markets
18
- 2. **JLP Hedged (Index 1)**: Stablecoin backed by the JLP token, neutralised with perpetual hedging strategies
19
- 3. **LST Delta-Neutral (Index 2)**: Stablecoin backed by LSTs hedged by perpetual futures position
18
+ 2. **JLP Hedged (Index 1)**: Stablecoin backed by the JLP token, neutralized with perpetual hedging strategies
19
+ 3. **LST Delta-Neutral (Index 2)**: Stablecoin backed by LSTs hedged by perpetual futures positions
20
20
 
21
21
  ## Architecture
22
22
 
@@ -25,41 +25,28 @@ The SDK is organized into several key components:
25
25
  ### Core Classes
26
26
 
27
27
  #### `Stablecoin` (Abstract Base Class)
28
- The foundation for all stablecoin implementations. Provides abstract functions and common interface for:
29
- - minting,
30
- - redemption,
31
- - administrative operations.
28
+ The foundation for all stablecoin implementations. Provides abstract functions and a common interface for:
29
+ - Minting
30
+ - Redemption
31
+ - Administrative operations
32
32
 
33
33
  **Key Methods:**
34
- - `initialize()` - Initialize and set-up the stablecoin (admin-only)
35
34
  - `mint()` - Create mint instructions
36
35
  - `redeem()` - Create redemption instructions
37
- - `rebalance()` - Create rebalancing instructions (admin-only)
38
- - `updateCap()` - Update supply cap (admin-only)
39
- - `updateRecipients()` - Update fee recipients (admin-only)
36
+ - `rebalance()` - Create rebalance instructions (admin-only or permissionless, depending on the strategy)
40
37
 
41
38
  #### `ReflectKeeper`
42
- Administrative client for protocol-level operations (admin-only):
43
- - Protocol initialization
44
- - Role and permission management
45
- - Action freezing/unfreezing
46
- - Admin account creation
47
-
48
- **Key Methods:**
49
- - `initializeMain()` - Initialize the main account with the program configuration
50
- - `freezeProtocolAction()` - Freeze/unfreeze protocol actions
51
- - `updateRoleHolderProtocol()` - Update protocol-level permissions
52
- - `createAdminAccount()` - Manage admin accounts
39
+ Administrative client for protocol-level operations (admin-only).
53
40
 
54
41
  #### `PdaClient`
55
42
  Utility class for deriving PDAs:
56
43
  - Configuration program accounts
57
44
  - Stablecoin controllers
58
45
  - Permission accounts
59
- - External protocol integrations (Drift, Jupiter, Tokenised Bond)
46
+ - External protocol integrations (Drift, Jupiter, Tokenized Bond)
60
47
 
61
- #### `ReflectTokenisedBond`
62
- Client for tokenized bonds program used for wrapping base stablecoins into yield-bearing receipts. Allows for:
48
+ #### `ReflectTokenizedBond`
49
+ Client for the tokenized bonds program used for wrapping base stablecoins into yield-bearing receipts. Allows for:
63
50
  - Vault creation and management
64
51
  - Receipt token generation
65
52
  - Deposit and withdrawal operations
@@ -68,33 +55,33 @@ Client for tokenized bonds program used for wrapping base stablecoins into yield
68
55
 
69
56
  #### `UsdcPlusStablecoin`
70
57
  USDC+ is a stablecoin backed by USDC deployed in money markets. Implementation details:
71
- - Live
58
+ - Status: Live
72
59
  - Strategy ID: 0
73
60
  - Collateral: USDC
74
- - Integrated with tokenised bonds program on the protocol level.
75
- - Users only receive the yield-bearing stablecoin.
76
- - Doesn't require rebalancing, as hedge is always preserved.
61
+ - Integrated with the tokenized bonds program at the protocol level
62
+ - Users only receive the yield-bearing stablecoin
63
+ - Does not require rebalancing
77
64
 
78
65
  #### `UsdjStablecoin`
79
- Stablecoin backed by JLP neutralised with perpetual hedging:
80
- - Coming soon
66
+ Stablecoin backed by JLP neutralized with perpetual hedging:
67
+ - Status: Coming soon
81
68
  - Strategy ID: 1
82
69
  - Collateral: JLP (Jupiter LP tokens)
83
- - Requires manual wrapping via the Tokenised Bonds program.
84
- - Requires rebalancing, currently permissioned.
85
-
70
+ - Requires manual wrapping via the Tokenized Bonds program
71
+ - Requires rebalancing, currently permissioned
86
72
 
87
73
  #### `LstStablecoin`
88
74
  Liquid staking token delta-neutral strategy:
89
- - Live
75
+ - Status: Live
90
76
  - Strategy ID: 2
91
- - Collateral: Various LSTs (mSOL, jitoSOL, etc.) - use `load()` functionality to fetch currently supported list of collateral assets.
92
- - Requires manual wrapping via the Tokenised Bonds program.
93
- - Requires rebalancing, currently permissioned.
77
+ - Collateral: Various LSTs (mSOL, jitoSOL, etc.) - use `load()` functionality to fetch the currently supported list of collateral assets
78
+ - Requires manual wrapping via the Tokenized Bonds program
79
+ - Requires rebalancing, currently permissioned
94
80
 
95
81
  ## Usage
96
82
 
97
- Follow snippets below to mint and redeem Reflect stablecoins. All Stablecoin subclasses expose methods following the same schema, so the code below works interchangeably with minor changes - simply change between the three:
83
+ Follow the snippets below to mint and redeem Reflect stablecoins. All Stablecoin subclasses expose methods following the same schema, so the code below works interchangeably with minor changes - simply change between the three:
84
+
98
85
  ```typescript
99
86
  const stablecoin = new UsdcPlusStablecoin(connection);
100
87
  const stablecoin = new UsdjStablecoin(connection);
@@ -105,19 +92,19 @@ const stablecoin = new LstStablecoin(connection);
105
92
 
106
93
  ```typescript
107
94
  import { UsdcPlusStablecoin } from '@reflectmoney/stable.ts';
108
- import { PublicKey } from '@solana/web3.js';
95
+ import { PublicKey, Keypair, Connection, TransactionMessage, VersionedTransaction } from '@solana/web3.js';
109
96
  import BN from 'bn.js';
110
97
 
111
98
  // Use an actual user's public key, read from wallet adapter or local environment.
112
99
  const user = Keypair.generate();
113
100
  const stablecoin = new UsdcPlusStablecoin(connection);
114
101
 
115
- // Load controller data for most up-to-date stablecoin setup.
102
+ // Load controller data for the most up-to-date stablecoin setup.
116
103
  await stablecoin.load(connection);
117
104
 
118
- // Mint stablecoins against LST collateral
105
+ // Mint stablecoins against USDC collateral
119
106
  const instructions = await stablecoin.mint(
120
- userPublicKey,
107
+ user.publicKey,
121
108
  new BN(1000 * 1_000_000), // Deposit collateral of 1,000 USDC (6 decimals)
122
109
  new BN(999 * 1_000_000), // Minimum received USDC+ (0.1% slippage protection)
123
110
  );
@@ -138,7 +125,7 @@ const message = new TransactionMessage({
138
125
 
139
126
  const transaction = new VersionedTransaction(message);
140
127
 
141
- // Transaction signature and landing logic, adjust for your needs.
128
+ // Transaction signature and confirmation logic, adjust for your needs.
142
129
  transaction.sign([user]);
143
130
  await connection.sendRawTransaction(transaction.serialize());
144
131
  ```
@@ -147,20 +134,20 @@ await connection.sendRawTransaction(transaction.serialize());
147
134
 
148
135
  ```typescript
149
136
  import { UsdcPlusStablecoin } from '@reflectmoney/stable.ts';
150
- import { PublicKey } from '@solana/web3.js';
137
+ import { PublicKey, Keypair, Connection, TransactionMessage, VersionedTransaction } from '@solana/web3.js';
151
138
  import BN from 'bn.js';
152
139
 
153
140
  // Use an actual user's public key, read from wallet adapter or local environment.
154
141
  const user = Keypair.generate();
155
142
  const stablecoin = new UsdcPlusStablecoin(connection);
156
143
 
157
- // Load controller data for most up-to-date stablecoin setup.
144
+ // Load controller data for the most up-to-date stablecoin setup.
158
145
  await stablecoin.load(connection);
159
146
 
160
- // Redeems USDC+ into USDC
147
+ // Redeem USDC+ into USDC
161
148
  const instructions = await stablecoin.redeem(
162
- userPublicKey,
163
- new BN(999 * 1_000_000), // Burn 1,000 of USDC+
149
+ user.publicKey,
150
+ new BN(999 * 1_000_000), // Burn 999 of USDC+
164
151
  new BN(1_000 * 1_000_000), // Minimum received USDC (USDC+ is yield bearing, so you'll receive more USDC over time)
165
152
  );
166
153
 
@@ -180,14 +167,14 @@ const message = new TransactionMessage({
180
167
 
181
168
  const transaction = new VersionedTransaction(message);
182
169
 
183
- // Transaction signature and landing logic, adjust for your needs.
170
+ // Transaction signature and confirmation logic, adjust for your needs.
184
171
  transaction.sign([user]);
185
172
  await connection.sendRawTransaction(transaction.serialize());
186
173
  ```
187
174
 
188
175
  ### Integration with External Protocols
189
176
 
190
- The SDK is built in integration with:
177
+ The SDK is built with integration for:
191
178
  - **Drift Protocol**: For perpetual futures and spot trading
192
179
  - **Jupiter Protocol**: For LP token operations and swaps
193
180
  - **Pyth Network**: For price oracle data
@@ -1,7 +1,7 @@
1
1
  import { AccountMeta, Connection, Keypair, PublicKey, TransactionInstruction } from "@solana/web3.js";
2
2
  import BN from "bn.js";
3
3
  import { DriftClient } from "@drift-labs/sdk";
4
- import { Action } from "../generated/reflect_main";
4
+ import { Action, Strategy } from "../generated/reflect_main";
5
5
  import { StablecoinMetadata, Collateral } from "../types";
6
6
  /**
7
7
  * Abstract base class for all stablecoin implementations in the Reflect protocol.
@@ -22,6 +22,8 @@ export declare abstract class Stablecoin {
22
22
  connection: Connection;
23
23
  /** Public key of the controller account for this stablecoin */
24
24
  controller: PublicKey;
25
+ /** Public key of the controller account for this stablecoin */
26
+ strategy: Strategy;
25
27
  /** Array of collateral assets backing this stablecoin */
26
28
  collaterals: Collateral[];
27
29
  /** Public key of the stablecoin mint */
@@ -59,8 +59,8 @@ class LstStablecoin extends Stablecoin_1.Stablecoin {
59
59
  */
60
60
  load(connection) {
61
61
  return __awaiter(this, void 0, void 0, function* () {
62
- const { lsts, baseStrategy: { mint } } = yield reflect_main_1.DriftLstController.fromAccountAddress(connection, this.controller);
63
- this.stablecoinMint = mint;
62
+ const { lsts, baseStrategy, } = yield reflect_main_1.DriftLstController.fromAccountAddress(connection, this.controller);
63
+ this.stablecoinMint = baseStrategy.mint;
64
64
  this.lstMap = lsts;
65
65
  this.collaterals = lsts.map(({ marketIndex }) => {
66
66
  var _a;
@@ -68,6 +68,7 @@ class LstStablecoin extends Stablecoin_1.Stablecoin {
68
68
  .find(({ marketIndex: index }) => index === marketIndex);
69
69
  return { mint: market === null || market === void 0 ? void 0 : market.mint, oracle: ((_a = market === null || market === void 0 ? void 0 : market.oracle) === null || _a === void 0 ? void 0 : _a.toBase58()) || "" };
70
70
  });
71
+ this.strategy = baseStrategy;
71
72
  });
72
73
  }
73
74
  /**
@@ -14,6 +14,7 @@ export declare class UsdcPlusStablecoin extends Stablecoin {
14
14
  * @param stablecoinMintOverride - Optional override for the stablecoin mint address
15
15
  */
16
16
  constructor(connection: Connection, stablecoinMintOverride?: PublicKey);
17
+ load(): Promise<void>;
17
18
  /**
18
19
  * Initializes the USDC stablecoin with the specified parameters.
19
20
  * Creates receipt tokens, initializes vault, and initializes the stablecoin.
@@ -40,6 +40,13 @@ class UsdcPlusStablecoin extends Stablecoin_1.Stablecoin {
40
40
  if (stablecoinMintOverride)
41
41
  this.stablecoinMint = stablecoinMintOverride;
42
42
  }
43
+ load() {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ const { baseStrategy, } = yield reflect_main_1.DriftUsdcController.fromAccountAddress(this.connection, this.controller);
46
+ this.stablecoinMint = baseStrategy.mint;
47
+ this.strategy = baseStrategy;
48
+ });
49
+ }
43
50
  /**
44
51
  * Initializes the USDC stablecoin with the specified parameters.
45
52
  * Creates receipt tokens, initializes vault, and initializes the stablecoin.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reflectmoney/stable.ts",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "type": "module",
5
5
  "author": "stablecoinjesus @ Palindrome Engineering",
6
6
  "repository": {