@defuse-protocol/intents-sdk 0.45.0 → 0.45.1

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.
@@ -1,5 +1,7 @@
1
+ const require_route_enum = require('./route-enum.cjs');
1
2
 
2
3
  //#region src/constants/withdrawal-timing.ts
4
+ const HOT_EXTRA_TIMEOUT_MS = 720 * 1e3;
3
5
  /**
4
6
  * Withdrawal timing p99 values (in seconds) by CAIP-2 chain identifier.
5
7
  * Used to derive CompletionStats for chain-aware polling.
@@ -31,25 +33,34 @@ const WITHDRAWAL_P99_BY_CHAIN = {
31
33
  };
32
34
  /**
33
35
  * Default stats for chains without timing data.
34
- * Conservative 2-hour timeout with gradual phase transitions.
36
+ * Conservative 6-hour timeout (3x 2-hour p99) with gradual phase transitions.
35
37
  */
36
38
  const DEFAULT_WITHDRAWAL_STATS = {
37
39
  p50: 6e4,
38
40
  p90: 6e5,
39
- p99: 72e5
41
+ p99: 216e5
40
42
  };
41
43
  /**
42
- * Returns CompletionStats for the given chain.
44
+ * Returns CompletionStats for the given chain and bridge.
43
45
  * Derives p50/p90 from p99 using reasonable ratios with minimum floors.
46
+ * Timeout (p99 field) is set to 3x of the actual p99, with extra 12 minutes for HOT bridge.
44
47
  */
45
- function getWithdrawalStatsForChain(caip2) {
46
- const p99Seconds = WITHDRAWAL_P99_BY_CHAIN[caip2];
47
- if (p99Seconds == null) return DEFAULT_WITHDRAWAL_STATS;
48
+ function getWithdrawalStatsForChain(options) {
49
+ const p99Seconds = WITHDRAWAL_P99_BY_CHAIN[options.chain];
50
+ if (p99Seconds == null) {
51
+ const extraTimeout$1 = options.bridgeRoute === require_route_enum.RouteEnum.HotBridge ? HOT_EXTRA_TIMEOUT_MS : 0;
52
+ return {
53
+ ...DEFAULT_WITHDRAWAL_STATS,
54
+ p99: DEFAULT_WITHDRAWAL_STATS.p99 + extraTimeout$1
55
+ };
56
+ }
48
57
  const p99 = p99Seconds * 1e3;
58
+ const timeout = p99 * 3;
59
+ const extraTimeout = options.bridgeRoute === require_route_enum.RouteEnum.HotBridge ? HOT_EXTRA_TIMEOUT_MS : 0;
49
60
  return {
50
61
  p50: Math.max(5e3, p99 * .15),
51
62
  p90: Math.max(3e4, p99 * .5),
52
- p99
63
+ p99: timeout + extraTimeout
53
64
  };
54
65
  }
55
66
 
@@ -1,4 +1,7 @@
1
+ import { RouteEnum } from "./route-enum.js";
2
+
1
3
  //#region src/constants/withdrawal-timing.ts
4
+ const HOT_EXTRA_TIMEOUT_MS = 720 * 1e3;
2
5
  /**
3
6
  * Withdrawal timing p99 values (in seconds) by CAIP-2 chain identifier.
4
7
  * Used to derive CompletionStats for chain-aware polling.
@@ -30,25 +33,34 @@ const WITHDRAWAL_P99_BY_CHAIN = {
30
33
  };
31
34
  /**
32
35
  * Default stats for chains without timing data.
33
- * Conservative 2-hour timeout with gradual phase transitions.
36
+ * Conservative 6-hour timeout (3x 2-hour p99) with gradual phase transitions.
34
37
  */
35
38
  const DEFAULT_WITHDRAWAL_STATS = {
36
39
  p50: 6e4,
37
40
  p90: 6e5,
38
- p99: 72e5
41
+ p99: 216e5
39
42
  };
40
43
  /**
41
- * Returns CompletionStats for the given chain.
44
+ * Returns CompletionStats for the given chain and bridge.
42
45
  * Derives p50/p90 from p99 using reasonable ratios with minimum floors.
46
+ * Timeout (p99 field) is set to 3x of the actual p99, with extra 12 minutes for HOT bridge.
43
47
  */
44
- function getWithdrawalStatsForChain(caip2) {
45
- const p99Seconds = WITHDRAWAL_P99_BY_CHAIN[caip2];
46
- if (p99Seconds == null) return DEFAULT_WITHDRAWAL_STATS;
48
+ function getWithdrawalStatsForChain(options) {
49
+ const p99Seconds = WITHDRAWAL_P99_BY_CHAIN[options.chain];
50
+ if (p99Seconds == null) {
51
+ const extraTimeout$1 = options.bridgeRoute === RouteEnum.HotBridge ? HOT_EXTRA_TIMEOUT_MS : 0;
52
+ return {
53
+ ...DEFAULT_WITHDRAWAL_STATS,
54
+ p99: DEFAULT_WITHDRAWAL_STATS.p99 + extraTimeout$1
55
+ };
56
+ }
47
57
  const p99 = p99Seconds * 1e3;
58
+ const timeout = p99 * 3;
59
+ const extraTimeout = options.bridgeRoute === RouteEnum.HotBridge ? HOT_EXTRA_TIMEOUT_MS : 0;
48
60
  return {
49
61
  p50: Math.max(5e3, p99 * .15),
50
62
  p90: Math.max(3e4, p99 * .5),
51
- p99
63
+ p99: timeout + extraTimeout
52
64
  };
53
65
  }
54
66
 
@@ -5,7 +5,10 @@ let _defuse_protocol_internal_utils = require("@defuse-protocol/internal-utils")
5
5
  //#region src/core/withdrawal-watcher.ts
6
6
  const MAX_CONSECUTIVE_ERRORS = 3;
7
7
  async function watchWithdrawal(args) {
8
- const stats = require_withdrawal_timing.getWithdrawalStatsForChain(args.wid.landingChain);
8
+ const stats = require_withdrawal_timing.getWithdrawalStatsForChain({
9
+ chain: args.wid.landingChain,
10
+ bridgeRoute: args.bridge.route
11
+ });
9
12
  let consecutiveErrors = 0;
10
13
  try {
11
14
  return await (0, _defuse_protocol_internal_utils.poll)(async () => {
@@ -4,7 +4,10 @@ import { BaseError, POLL_PENDING, PollTimeoutError, poll } from "@defuse-protoco
4
4
  //#region src/core/withdrawal-watcher.ts
5
5
  const MAX_CONSECUTIVE_ERRORS = 3;
6
6
  async function watchWithdrawal(args) {
7
- const stats = getWithdrawalStatsForChain(args.wid.landingChain);
7
+ const stats = getWithdrawalStatsForChain({
8
+ chain: args.wid.landingChain,
9
+ bridgeRoute: args.bridge.route
10
+ });
8
11
  let consecutiveErrors = 0;
9
12
  try {
10
13
  return await poll(async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defuse-protocol/intents-sdk",
3
- "version": "0.45.0",
3
+ "version": "0.45.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "repository": {