@proton/wrap-constants 0.2.12 → 0.2.14

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.
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
- "version": "0.2.12",
8
+ "version": "0.2.14",
9
9
  "license": "MIT",
10
10
  "main": "dist/index.js",
11
11
  "typings": "dist/index.d.ts",
@@ -44,5 +44,5 @@
44
44
  "resolutions": {
45
45
  "typescript": "4.5"
46
46
  },
47
- "gitHead": "796855ce0ae3b02de26749a01b7811e8a00fbee1"
47
+ "gitHead": "4a586efe8a76b054d3406b45606b80bc79ba3e40"
48
48
  }
package/src/math.ts CHANGED
@@ -12,12 +12,12 @@ import { FEE_FACTOR } from './constants'
12
12
  */
13
13
  export const compute_transfer = (pool1: BN.Instance, pool2: BN.Instance, swap: BN.Instance, exchange_fee: number, precision: number): BN => {
14
14
  const term1 = pool2
15
- const term2over = pool1.multipliedBy(pool2)
15
+ const term2over = pool1.times(pool2)
16
16
  const term2under = pool1.plus(swap)
17
- const term2 = term2over.dividedBy(term2under).integerValue(BN.ROUND_DOWN)
17
+ const term2 = term2over.div(term2under).integerValue(BN.ROUND_DOWN)
18
18
  const term = term1.minus(term2)
19
- const fee = new BN(exchange_fee).dividedBy(FEE_FACTOR)
20
- const result = term.minus(term.multipliedBy(fee))
19
+ const fee = new BN(exchange_fee).div(FEE_FACTOR)
20
+ const result = term.minus(term.times(fee))
21
21
 
22
22
  return result.integerValue(BN.ROUND_DOWN).shiftedBy(-precision)
23
23
  }
@@ -59,7 +59,7 @@ export const compute_transfer_curve = (
59
59
  i = MAX_ITERATIONS;
60
60
  while ( x != x_prev && i--) {
61
61
  x_prev = F(x);
62
- x = +new BN(x * x + c).dividedBy(2 * x + b).toFixed(0, BN.ROUND_DOWN)
62
+ x = +new BN(x * x + c).div(2 * x + b).toFixed(0, BN.ROUND_DOWN)
63
63
  }
64
64
 
65
65
  if (reserve_out <= x) {
@@ -71,7 +71,7 @@ export const compute_transfer_curve = (
71
71
 
72
72
  // Fee + 1
73
73
  // +1 covers small precision issues
74
- const fee = amount_out_with_fee.multipliedBy(exchange_fee).dividedBy(FEE_FACTOR).plus(1).toFixed(0, BN.ROUND_DOWN);
74
+ const fee = amount_out_with_fee.times(exchange_fee).div(FEE_FACTOR).plus(1).toFixed(0, BN.ROUND_DOWN);
75
75
 
76
76
  // Amount out
77
77
  const amount_out = amount_out_with_fee.minus(fee)
@@ -80,9 +80,9 @@ export const compute_transfer_curve = (
80
80
  }
81
81
 
82
82
  export const compute_liquidity = (amount_lt: BN.Instance, pool: BN.Instance, lt_supply: BN.Instance, precision: number): number => {
83
- const over = amount_lt.multipliedBy(pool)
83
+ const over = amount_lt.times(pool)
84
84
  const under = lt_supply
85
- const result = over.dividedBy(under).integerValue(BN.ROUND_DOWN)
85
+ const result = over.div(under).integerValue(BN.ROUND_DOWN)
86
86
 
87
87
  return +(result.shiftedBy(-precision).toFixed(precision, BN.ROUND_DOWN))
88
88
  }
@@ -65,6 +65,15 @@ export const getDepthParser = z.object({
65
65
  })
66
66
  export type GetDepth = z.infer<typeof getDepthParser>
67
67
 
68
+ export const dailyParser = z.object({
69
+ market_id: z.number(),
70
+ first: z.number(),
71
+ last: z.number(),
72
+ bid: z.number(),
73
+ ask: z.number(),
74
+ })
75
+ export type Daily = z.infer<typeof dailyParser>
76
+
68
77
  export const tradeParser = z.object({
69
78
  block_num: z.number(),
70
79
  block_time: z.string(),