@orbs-network/twap 1.8.4 → 1.8.6

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.
@@ -8,6 +8,7 @@ export interface TokenData {
8
8
  export interface Config {
9
9
  chainId: number;
10
10
  chainName: string;
11
+ twapVersion: number;
11
12
  twapAddress: string;
12
13
  lensAddress: string;
13
14
  bidDelaySeconds: number;
@@ -22,6 +23,7 @@ export declare const ChainConfigs: {
22
23
  eth: {
23
24
  chainName: string;
24
25
  chainId: number;
26
+ twapVersion: number;
25
27
  twapAddress: string;
26
28
  lensAddress: string;
27
29
  bidDelaySeconds: number;
@@ -36,6 +38,7 @@ export declare const ChainConfigs: {
36
38
  ftm: {
37
39
  chainName: string;
38
40
  chainId: number;
41
+ twapVersion: number;
39
42
  twapAddress: string;
40
43
  lensAddress: string;
41
44
  bidDelaySeconds: number;
@@ -50,6 +53,7 @@ export declare const ChainConfigs: {
50
53
  poly: {
51
54
  chainName: string;
52
55
  chainId: number;
56
+ twapVersion: number;
53
57
  twapAddress: string;
54
58
  lensAddress: string;
55
59
  bidDelaySeconds: number;
@@ -64,6 +68,7 @@ export declare const ChainConfigs: {
64
68
  avax: {
65
69
  chainName: string;
66
70
  chainId: number;
71
+ twapVersion: number;
67
72
  twapAddress: string;
68
73
  lensAddress: string;
69
74
  bidDelaySeconds: number;
@@ -87,6 +92,7 @@ export declare const isNativeAddress: (address: string) => boolean;
87
92
  export declare const chainConfig: (chainId: number) => {
88
93
  chainName: string;
89
94
  chainId: number;
95
+ twapVersion: number;
90
96
  twapAddress: string;
91
97
  lensAddress: string;
92
98
  bidDelaySeconds: number;
@@ -100,6 +106,7 @@ export declare const chainConfig: (chainId: number) => {
100
106
  } | {
101
107
  chainName: string;
102
108
  chainId: number;
109
+ twapVersion: number;
103
110
  twapAddress: string;
104
111
  lensAddress: string;
105
112
  bidDelaySeconds: number;
@@ -113,6 +120,7 @@ export declare const chainConfig: (chainId: number) => {
113
120
  } | {
114
121
  chainName: string;
115
122
  chainId: number;
123
+ twapVersion: number;
116
124
  twapAddress: string;
117
125
  lensAddress: string;
118
126
  bidDelaySeconds: number;
@@ -126,6 +134,7 @@ export declare const chainConfig: (chainId: number) => {
126
134
  } | {
127
135
  chainName: string;
128
136
  chainId: number;
137
+ twapVersion: number;
129
138
  twapAddress: string;
130
139
  lensAddress: string;
131
140
  bidDelaySeconds: number;
@@ -11,6 +11,7 @@ exports.ChainConfigs = {
11
11
  eth: {
12
12
  chainName: "eth",
13
13
  chainId: 1,
14
+ twapVersion: 0,
14
15
  twapAddress: "",
15
16
  lensAddress: "",
16
17
  bidDelaySeconds: 60,
@@ -25,6 +26,7 @@ exports.ChainConfigs = {
25
26
  ftm: {
26
27
  chainName: "ftm",
27
28
  chainId: 250,
29
+ twapVersion: 3,
28
30
  twapAddress: "0xBb9F828E34A1327607c3e4eA3dD35891398DD5EE",
29
31
  lensAddress: "0x042799657E971855eD619046aeDf7F30DB56d2D6",
30
32
  bidDelaySeconds: 60,
@@ -39,6 +41,7 @@ exports.ChainConfigs = {
39
41
  poly: {
40
42
  chainName: "poly",
41
43
  chainId: 137,
44
+ twapVersion: 3,
42
45
  twapAddress: "0xBAFdE1cc254BB94Be5866d5a86ddafde4BB44EEF",
43
46
  lensAddress: "0xc918bdC47264687796Cd54FE362FaC4f8b99Eb55",
44
47
  bidDelaySeconds: 60,
@@ -53,6 +56,7 @@ exports.ChainConfigs = {
53
56
  avax: {
54
57
  chainName: "avax",
55
58
  chainId: 43114,
59
+ twapVersion: 3,
56
60
  twapAddress: "0xD63430c74C8E70D9dbdCA04C6a9E6E9E929028DA",
57
61
  lensAddress: "0xD13609A8ace04D11Ea2FFE176B69dF77C6d9375E",
58
62
  bidDelaySeconds: 60,
package/dist/src/lib.d.ts CHANGED
@@ -3,7 +3,6 @@ import BN from "bignumber.js";
3
3
  import type { TWAP } from "../typechain-hardhat/contracts";
4
4
  import type { Lens } from "../typechain-hardhat/contracts/periphery";
5
5
  import { Paraswap } from "./paraswap";
6
- import ParaswapRoute = Paraswap.ParaswapRoute;
7
6
  export declare const twapAbi: any;
8
7
  export declare const lensAbi: any;
9
8
  export declare const takerAbi: any;
@@ -21,6 +20,11 @@ export declare class TWAPLib {
21
20
  maxPossibleChunks: (srcToken: TokenData, srcAmount: BN.Value, srcUsd: BN.Value) => number;
22
21
  srcChunkAmount: (srcAmount: BN.Value, totalChunks: BN.Value) => BN;
23
22
  totalChunks: (srcAmount: BN.Value, srcChunkAmount: BN.Value) => number;
23
+ estimatedDelayBetweenChunksMillis: () => number;
24
+ /**
25
+ * includes the bidding war and block settelment
26
+ */
27
+ fillDelayUiMillis: (totalChunks: BN.Value, maxDurationMillis: BN.Value) => number;
24
28
  fillDelayMillis: (totalChunks: BN.Value, maxDurationMillis: BN.Value) => number;
25
29
  dstMinAmountOut: (srcToken: TokenData, dstToken: TokenData, srcChunkAmount: BN.Value, limitDstPriceFor1Src: BN.Value, isMarketOrder: boolean) => BN;
26
30
  dstPriceFor1Src: (srcToken: TokenData, dstToken: TokenData, srcUsdMarket: BN.Value, dstUsdMarket: BN.Value, srcChunkAmount: BN.Value, dstMinAmountOut: BN.Value) => BN;
@@ -49,7 +53,7 @@ export declare class TWAPLib {
49
53
  raw: string[] | Paraswap.ParaswapRoute;
50
54
  data: string;
51
55
  }>;
52
- convertRouteToSwapData(route: ParaswapRoute): Promise<{
56
+ convertRouteToSwapData(route: Paraswap.ParaswapRoute): Promise<{
53
57
  raw: string[];
54
58
  data: string;
55
59
  } | {
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.6",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/orbs-network/twap.git"