@reflectmoney/stable.ts 1.0.0 → 1.0.1

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.
@@ -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.1",
4
4
  "type": "module",
5
5
  "author": "stablecoinjesus @ Palindrome Engineering",
6
6
  "repository": {