@clonegod/ttd-bsc-common 3.1.78 → 3.1.80

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.
@@ -7,26 +7,26 @@ function pickMatchingTier(tiers, actualAmountIn) {
7
7
  if (!tiers || tiers.length === 0)
8
8
  return null;
9
9
  if (tiers.length === 1)
10
- return { tier: tiers[0], mode: 'single_tier' };
10
+ return { tier: tiers[0], mode: 'single_tier', lo_pct: tiers[0].pct, hi_pct: tiers[0].pct };
11
11
  const sorted = [...tiers].sort((a, b) => a.amount_in - b.amount_in);
12
12
  const top = sorted[sorted.length - 1];
13
13
  if (actualAmountIn < sorted[0].amount_in) {
14
- return { tier: sorted[0], mode: 'extrapolated_low' };
14
+ return { tier: sorted[0], mode: 'extrapolated_low', lo_pct: null, hi_pct: sorted[0].pct };
15
15
  }
16
16
  if (actualAmountIn > top.amount_in) {
17
- return { tier: top, mode: 'extrapolated_high' };
17
+ return { tier: top, mode: 'extrapolated_high', lo_pct: top.pct, hi_pct: null };
18
18
  }
19
19
  for (let i = 0; i < sorted.length - 1; i++) {
20
20
  const lower = sorted[i];
21
21
  const upper = sorted[i + 1];
22
22
  if (actualAmountIn >= lower.amount_in && actualAmountIn <= upper.amount_in) {
23
23
  if (actualAmountIn === lower.amount_in)
24
- return { tier: lower, mode: 'exact' };
24
+ return { tier: lower, mode: 'exact', lo_pct: lower.pct, hi_pct: lower.pct };
25
25
  if (actualAmountIn === upper.amount_in)
26
- return { tier: upper, mode: 'exact' };
26
+ return { tier: upper, mode: 'exact', lo_pct: upper.pct, hi_pct: upper.pct };
27
27
  const span = upper.amount_in - lower.amount_in;
28
28
  if (span <= 0)
29
- return { tier: lower, mode: 'exact' };
29
+ return { tier: lower, mode: 'exact', lo_pct: lower.pct, hi_pct: lower.pct };
30
30
  const ratio = (actualAmountIn - lower.amount_in) / span;
31
31
  const lerp = (a, b) => a + ratio * (b - a);
32
32
  return {
@@ -40,10 +40,12 @@ function pickMatchingTier(tiers, actualAmountIn) {
40
40
  fee_usd: lerp(lower.fee_usd, upper.fee_usd),
41
41
  },
42
42
  mode: 'interpolated',
43
+ lo_pct: lower.pct,
44
+ hi_pct: upper.pct,
43
45
  };
44
46
  }
45
47
  }
46
- return { tier: top, mode: 'extrapolated_high' };
48
+ return { tier: top, mode: 'extrapolated_high', lo_pct: top.pct, hi_pct: null };
47
49
  }
48
50
  class QuotePriceVerify {
49
51
  constructor() {
@@ -111,6 +113,8 @@ class QuotePriceVerify {
111
113
  matched_pct: parseFloat(match.tier.pct.toFixed(4)),
112
114
  mode: match.mode,
113
115
  tier_amount_in: match.tier.amount_in,
116
+ lo_pct: match.lo_pct,
117
+ hi_pct: match.hi_pct,
114
118
  };
115
119
  }
116
120
  else {
@@ -230,6 +234,8 @@ class QuotePriceVerify {
230
234
  matched_tier_pct: primaryTierInfo.matched_pct,
231
235
  matched_tier_mode: primaryTierInfo.mode,
232
236
  matched_tier_amount_in: primaryTierInfo.tier_amount_in,
237
+ matched_tier_lo_pct: primaryTierInfo.lo_pct,
238
+ matched_tier_hi_pct: primaryTierInfo.hi_pct,
233
239
  }),
234
240
  });
235
241
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-bsc-common",
3
- "version": "3.1.78",
3
+ "version": "3.1.80",
4
4
  "description": "BSC common library",
5
5
  "license": "UNLICENSED",
6
6
  "main": "dist/index.js",