@runesx/api-client 0.3.0 → 0.5.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.
@@ -1,6 +1,5 @@
1
1
  // src/utils/liquidityUtils.mjs
2
- import { BigNumber } from 'bignumber.js';
3
-
2
+ import { SafeBigNumber as BigNumber } from './safeBigNumber.mjs';
4
3
  import { getRunesPriceUSD, getTokenPriceInRunes } from './swapUtils.mjs';
5
4
 
6
5
  export function normalizeTokenPairFrontend(coinA, coinB, pools) {
@@ -111,7 +110,7 @@ export function getPoolRatioFrontend(pool) {
111
110
  return reserveADecimal.div(reserveBDecimal);
112
111
  }
113
112
 
114
- export function estimateLiquidityFrontend({ coinA, coinB, amountA, amountB, pools, coins }) {
113
+ export function estimateLiquidityFrontend({ coinA, coinB, amountA, amountB, pools }) {
115
114
  if ((amountA === null && amountB === null) || (amountA !== null && amountB !== null)) {
116
115
  throw new Error('Provide either amountA or amountB, but not both or neither');
117
116
  }
@@ -1,9 +1,10 @@
1
1
  // src/utils/priceUtils.mjs
2
- import { BigNumber } from 'bignumber.js';
3
2
 
4
3
  import { getPools } from '../store/poolStore.mjs';
5
4
  import { getCoinByTicker } from '../store/coinStore.mjs';
6
5
 
6
+ import { SafeBigNumber as BigNumber } from './safeBigNumber.mjs';
7
+
7
8
  export function createPriceUtils() {
8
9
  const getRunesPriceUSD = () => {
9
10
  const pools = getPools();
@@ -0,0 +1,11 @@
1
+ // src/utils/safeBigNumber.mjs
2
+ // Isolated BigNumber constructor aligned with the backend's SafeBigNumber
3
+ // (runesx-api/src/utils/safeBigNumber.mjs). Uses the same DECIMAL_PLACES=40
4
+ // and EXPONENTIAL_AT=[-100, 100] configuration to ensure estimation arithmetic
5
+ // matches backend financial calculations.
6
+ import BigNumber from 'bignumber.js';
7
+
8
+ export const SafeBigNumber = BigNumber.clone({
9
+ DECIMAL_PLACES: 40,
10
+ EXPONENTIAL_AT: [-100, 100],
11
+ });