@reflectmoney/stable.ts 1.2.5 → 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.
|
@@ -275,12 +275,13 @@ class UsdcPlusStablecoin extends Stablecoin_1.Stablecoin {
|
|
|
275
275
|
const { supply, decimals } = yield (0, spl_token_1.getMint)(this.connection, this.stablecoinMint, "confirmed");
|
|
276
276
|
const [{ mint: usdcMint }] = this.collaterals;
|
|
277
277
|
const { data: [{ price: { expo, price } }] } = yield this.getCollateralPrice(usdcMint);
|
|
278
|
+
console.log({ price, expo });
|
|
278
279
|
const exchangeRate = usdcAmount
|
|
279
280
|
.mul(new bn_js_1.default(price))
|
|
280
281
|
.mul(new bn_js_1.default(constants_1.EXCHANGE_RATE_PRECISION)) // gives us exhcnage rate precision
|
|
281
282
|
.div(new bn_js_1.default(supply.toString())) // price per stablecoin
|
|
282
|
-
.div(new bn_js_1.default(10
|
|
283
|
-
.div(new bn_js_1.default(10
|
|
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
|
|
284
285
|
return exchangeRate.toNumber();
|
|
285
286
|
});
|
|
286
287
|
}
|