@reflectmoney/stable.ts 2.6.0 → 2.7.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.
@@ -246,4 +246,12 @@ export declare abstract class Stablecoin<T extends Controller> {
246
246
  * @returns Promise resolving to the amount of base tokens that would be returned
247
247
  */
248
248
  abstract simulateRedeemMath(amount: BN): Promise<BN>;
249
+ /**
250
+ * Abstract method to cleanup the stablecoin.
251
+ * Must be implemented by concrete stablecoin classes.
252
+ * Used to unsubscribe all connections to websockets.
253
+ *
254
+ * @returns Promise resolving to void
255
+ */
256
+ abstract cleanup(): Promise<void>;
249
257
  }
@@ -104,4 +104,5 @@ export declare class LstStablecoin extends Stablecoin<DriftLstController> {
104
104
  getReceiptToCollateralExchangeRate(): Promise<number>;
105
105
  simulateMintMath(): Promise<BN>;
106
106
  simulateRedeemMath(): Promise<BN>;
107
+ cleanup(): Promise<void>;
107
108
  }
@@ -345,5 +345,10 @@ class LstStablecoin extends Stablecoin_1.Stablecoin {
345
345
  return new bn_js_1.default(0);
346
346
  });
347
347
  }
348
+ cleanup() {
349
+ return __awaiter(this, void 0, void 0, function* () {
350
+ yield this.driftClient.unsubscribe();
351
+ });
352
+ }
348
353
  }
349
354
  exports.LstStablecoin = LstStablecoin;
@@ -48,7 +48,11 @@ class UsdcPlusStablecoin extends Stablecoin_1.Stablecoin {
48
48
  connection,
49
49
  env: devnet ? "devnet" : "mainnet-beta",
50
50
  wallet: new nodewallet_1.default(web3_js_1.Keypair.generate()),
51
- authority: this.controllerKey
51
+ authority: this.controllerKey,
52
+ accountSubscription: {
53
+ type: "polling",
54
+ accountLoader: new sdk_1.BulkAccountLoader(connection, "confirmed", 1000),
55
+ }
52
56
  });
53
57
  this.isPermissioned = true;
54
58
  this.devnet = devnet;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reflectmoney/stable.ts",
3
- "version": "2.6.0",
3
+ "version": "2.7.1",
4
4
  "type": "commonjs",
5
5
  "author": "stablecoinjesus @ Palindrome Engineering",
6
6
  "repository": {