@reflectmoney/stable.ts 1.2.4 → 1.2.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.
@@ -68,6 +68,9 @@ class UsdcPlusStablecoin extends Stablecoin_1.Stablecoin {
68
68
  const subscribed = yield this.driftClient.subscribe();
69
69
  if (!subscribed)
70
70
  throw new Error("Failed to subscribe to Drift Client");
71
+ const addedController = yield this.driftClient.addUser(0, this.controllerKey);
72
+ if (!addedController)
73
+ throw new Error("Failed to add controller account to Drift Client");
71
74
  });
72
75
  }
73
76
  /**
@@ -272,12 +275,13 @@ class UsdcPlusStablecoin extends Stablecoin_1.Stablecoin {
272
275
  const { supply, decimals } = yield (0, spl_token_1.getMint)(this.connection, this.stablecoinMint, "confirmed");
273
276
  const [{ mint: usdcMint }] = this.collaterals;
274
277
  const { data: [{ price: { expo, price } }] } = yield this.getCollateralPrice(usdcMint);
278
+ console.log({ price, expo });
275
279
  const exchangeRate = usdcAmount
276
280
  .mul(new bn_js_1.default(price))
277
281
  .mul(new bn_js_1.default(constants_1.EXCHANGE_RATE_PRECISION)) // gives us exhcnage rate precision
278
282
  .div(new bn_js_1.default(supply.toString())) // price per stablecoin
279
- .div(new bn_js_1.default(10 ** decimals)) // cancels out the USDC decimals
280
- .div(new bn_js_1.default(10 ** expo)); // cancels out the price decimals
283
+ .div(new bn_js_1.default(10).pow(new bn_js_1.default(decimals))) // cancels out the USDC decimals
284
+ .div(new bn_js_1.default(10).pow(new bn_js_1.default(expo).abs())); // cancels out the price decimals
281
285
  return exchangeRate.toNumber();
282
286
  });
283
287
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reflectmoney/stable.ts",
3
- "version": "1.2.4",
3
+ "version": "1.2.6",
4
4
  "type": "commonjs",
5
5
  "author": "stablecoinjesus @ Palindrome Engineering",
6
6
  "repository": {