@orbs-network/twap 1.8.4 → 1.8.5

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/dist/src/lib.d.ts CHANGED
@@ -21,6 +21,11 @@ export declare class TWAPLib {
21
21
  maxPossibleChunks: (srcToken: TokenData, srcAmount: BN.Value, srcUsd: BN.Value) => number;
22
22
  srcChunkAmount: (srcAmount: BN.Value, totalChunks: BN.Value) => BN;
23
23
  totalChunks: (srcAmount: BN.Value, srcChunkAmount: BN.Value) => number;
24
+ estimatedDelayBetweenChunksMillis: () => number;
25
+ /**
26
+ * includes the bidding war and block settelment
27
+ */
28
+ fillDelayUiMillis: (totalChunks: BN.Value, maxDurationMillis: BN.Value) => number;
24
29
  fillDelayMillis: (totalChunks: BN.Value, maxDurationMillis: BN.Value) => number;
25
30
  dstMinAmountOut: (srcToken: TokenData, dstToken: TokenData, srcChunkAmount: BN.Value, limitDstPriceFor1Src: BN.Value, isMarketOrder: boolean) => BN;
26
31
  dstPriceFor1Src: (srcToken: TokenData, dstToken: TokenData, srcUsdMarket: BN.Value, dstUsdMarket: BN.Value, srcChunkAmount: BN.Value, dstMinAmountOut: BN.Value) => BN;
package/dist/src/lib.js CHANGED
@@ -39,11 +39,12 @@ class TWAPLib {
39
39
  .toNumber();
40
40
  this.srcChunkAmount = (srcAmount, totalChunks) => (0, bignumber_js_1.default)(srcAmount).div(totalChunks).integerValue(bignumber_js_1.default.ROUND_FLOOR);
41
41
  this.totalChunks = (srcAmount, srcChunkAmount) => (0, bignumber_js_1.default)(srcAmount).div(srcChunkAmount).integerValue(bignumber_js_1.default.ROUND_CEIL).toNumber();
42
- this.fillDelayMillis = (totalChunks, maxDurationMillis) => (0, bignumber_js_1.default)(totalChunks).lte(1) || (0, bignumber_js_1.default)(maxDurationMillis).lte(this.config.bidDelaySeconds * 1000 * 2)
43
- ? 0
44
- : bignumber_js_1.default.max((0, bignumber_js_1.default)(maxDurationMillis)
45
- .div(totalChunks)
46
- .minus((0, bignumber_js_1.default)(this.config.bidDelaySeconds * 1000 * 2)), 0).toNumber();
42
+ this.estimatedDelayBetweenChunksMillis = () => this.config.bidDelaySeconds * 1000 * 2;
43
+ /**
44
+ * includes the bidding war and block settelment
45
+ */
46
+ this.fillDelayUiMillis = (totalChunks, maxDurationMillis) => bignumber_js_1.default.max((0, bignumber_js_1.default)(totalChunks).gt(1) ? (0, bignumber_js_1.default)(maxDurationMillis).div(totalChunks) : 0, (0, bignumber_js_1.default)(this.estimatedDelayBetweenChunksMillis())).toNumber();
47
+ this.fillDelayMillis = (totalChunks, maxDurationMillis) => this.fillDelayUiMillis(totalChunks, maxDurationMillis) - this.estimatedDelayBetweenChunksMillis();
47
48
  this.dstMinAmountOut = (srcToken, dstToken, srcChunkAmount, limitDstPriceFor1Src, isMarketOrder) => isMarketOrder
48
49
  ? (0, bignumber_js_1.default)(1)
49
50
  : bignumber_js_1.default.max(1, (0, web3_candies_1.convertDecimals)((0, bignumber_js_1.default)(srcChunkAmount).times(limitDstPriceFor1Src), srcToken.decimals, dstToken.decimals).integerValue(bignumber_js_1.default.ROUND_FLOOR));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbs-network/twap",
3
- "version": "1.8.4",
3
+ "version": "1.8.5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/orbs-network/twap.git"