@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 +5 -0
- package/dist/src/lib.js +6 -5
- package/package.json +1 -1
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.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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));
|