@reflectmoney/stable.ts 1.0.3 → 1.0.4
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 +39 -52
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
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,
|
|
19
|
-
3. **LST Delta-Neutral (Index 2)**: Stablecoin backed by LSTs hedged by perpetual futures
|
|
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
|
-
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
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
|
|
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,
|
|
46
|
+
- External protocol integrations (Drift, Jupiter, Tokenized Bond)
|
|
60
47
|
|
|
61
|
-
#### `
|
|
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
|
|
75
|
-
- Users only receive the yield-bearing stablecoin
|
|
76
|
-
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
105
|
+
// Mint stablecoins against USDC collateral
|
|
119
106
|
const instructions = await stablecoin.mint(
|
|
120
|
-
|
|
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
|
|
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
|
-
//
|
|
147
|
+
// Redeem USDC+ into USDC
|
|
161
148
|
const instructions = await stablecoin.redeem(
|
|
162
|
-
|
|
163
|
-
new BN(999 * 1_000_000), // Burn
|
|
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
|
|
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
|
|
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
|