@reflectmoney/stable.ts 1.0.4 → 1.0.6
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.
|
@@ -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 */
|
|
@@ -25,10 +25,8 @@ export declare class LstStablecoin extends Stablecoin {
|
|
|
25
25
|
/**
|
|
26
26
|
* Loads the LST controller data from the blockchain.
|
|
27
27
|
* Updates the stablecoin mint and LST mapping information.
|
|
28
|
-
*
|
|
29
|
-
* @param connection - Solana connection instance
|
|
30
28
|
*/
|
|
31
|
-
load(
|
|
29
|
+
load(): Promise<void>;
|
|
32
30
|
/**
|
|
33
31
|
* Initializes the LST stablecoin with the specified parameters.
|
|
34
32
|
* Sets up the controller with cap, mint, and recipient information.
|
|
@@ -54,13 +54,11 @@ class LstStablecoin extends Stablecoin_1.Stablecoin {
|
|
|
54
54
|
/**
|
|
55
55
|
* Loads the LST controller data from the blockchain.
|
|
56
56
|
* Updates the stablecoin mint and LST mapping information.
|
|
57
|
-
*
|
|
58
|
-
* @param connection - Solana connection instance
|
|
59
57
|
*/
|
|
60
|
-
load(
|
|
58
|
+
load() {
|
|
61
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
const { lsts, baseStrategy
|
|
63
|
-
this.stablecoinMint = mint;
|
|
60
|
+
const { lsts, baseStrategy, } = yield reflect_main_1.DriftLstController.fromAccountAddress(this.connection, this.controller);
|
|
61
|
+
this.stablecoinMint = baseStrategy.mint;
|
|
64
62
|
this.lstMap = lsts;
|
|
65
63
|
this.collaterals = lsts.map(({ marketIndex }) => {
|
|
66
64
|
var _a;
|
|
@@ -68,6 +66,7 @@ class LstStablecoin extends Stablecoin_1.Stablecoin {
|
|
|
68
66
|
.find(({ marketIndex: index }) => index === marketIndex);
|
|
69
67
|
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
68
|
});
|
|
69
|
+
this.strategy = baseStrategy;
|
|
71
70
|
});
|
|
72
71
|
}
|
|
73
72
|
/**
|
|
@@ -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.
|