@vultisig/core-chain 1.1.0 → 1.2.0

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.
Files changed (102) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/dist/amount/toChainAmount.d.ts +6 -1
  3. package/dist/amount/toChainAmount.d.ts.map +1 -1
  4. package/dist/amount/toChainAmount.js +88 -0
  5. package/dist/amount/toChainAmount.js.map +1 -1
  6. package/dist/chains/cosmos/qbtc/claim/BtcAddressType.d.ts +7 -0
  7. package/dist/chains/cosmos/qbtc/claim/BtcAddressType.d.ts.map +1 -0
  8. package/dist/chains/cosmos/qbtc/claim/BtcAddressType.js +9 -0
  9. package/dist/chains/cosmos/qbtc/claim/BtcAddressType.js.map +1 -0
  10. package/dist/chains/cosmos/qbtc/claim/ClaimableUtxo.d.ts +8 -0
  11. package/dist/chains/cosmos/qbtc/claim/ClaimableUtxo.d.ts.map +1 -0
  12. package/dist/chains/cosmos/qbtc/claim/ClaimableUtxo.js +2 -0
  13. package/dist/chains/cosmos/qbtc/claim/ClaimableUtxo.js.map +1 -0
  14. package/dist/chains/cosmos/qbtc/claim/broadcastClaimTx.d.ts +25 -0
  15. package/dist/chains/cosmos/qbtc/claim/broadcastClaimTx.d.ts.map +1 -0
  16. package/dist/chains/cosmos/qbtc/claim/broadcastClaimTx.js +43 -0
  17. package/dist/chains/cosmos/qbtc/claim/broadcastClaimTx.js.map +1 -0
  18. package/dist/chains/cosmos/qbtc/claim/buildClaimTx.d.ts +26 -0
  19. package/dist/chains/cosmos/qbtc/claim/buildClaimTx.d.ts.map +1 -0
  20. package/dist/chains/cosmos/qbtc/claim/buildClaimTx.js +57 -0
  21. package/dist/chains/cosmos/qbtc/claim/buildClaimTx.js.map +1 -0
  22. package/dist/chains/cosmos/qbtc/claim/computeClaimHashes.d.ts +49 -0
  23. package/dist/chains/cosmos/qbtc/claim/computeClaimHashes.d.ts.map +1 -0
  24. package/dist/chains/cosmos/qbtc/claim/computeClaimHashes.js +85 -0
  25. package/dist/chains/cosmos/qbtc/claim/computeClaimHashes.js.map +1 -0
  26. package/dist/chains/cosmos/qbtc/claim/detectBtcAddressType.d.ts +14 -0
  27. package/dist/chains/cosmos/qbtc/claim/detectBtcAddressType.d.ts.map +1 -0
  28. package/dist/chains/cosmos/qbtc/claim/detectBtcAddressType.js +31 -0
  29. package/dist/chains/cosmos/qbtc/claim/detectBtcAddressType.js.map +1 -0
  30. package/dist/chains/cosmos/qbtc/claim/getClaimWithProofDisabled.d.ts +3 -0
  31. package/dist/chains/cosmos/qbtc/claim/getClaimWithProofDisabled.d.ts.map +1 -0
  32. package/dist/chains/cosmos/qbtc/claim/getClaimWithProofDisabled.js +13 -0
  33. package/dist/chains/cosmos/qbtc/claim/getClaimWithProofDisabled.js.map +1 -0
  34. package/dist/chains/cosmos/qbtc/claim/getClaimableUtxos.d.ts +14 -0
  35. package/dist/chains/cosmos/qbtc/claim/getClaimableUtxos.d.ts.map +1 -0
  36. package/dist/chains/cosmos/qbtc/claim/getClaimableUtxos.js +22 -0
  37. package/dist/chains/cosmos/qbtc/claim/getClaimableUtxos.js.map +1 -0
  38. package/dist/chains/cosmos/qbtc/claim/proofService.d.ts +50 -0
  39. package/dist/chains/cosmos/qbtc/claim/proofService.d.ts.map +1 -0
  40. package/dist/chains/cosmos/qbtc/claim/proofService.js +71 -0
  41. package/dist/chains/cosmos/qbtc/claim/proofService.js.map +1 -0
  42. package/dist/chains/cosmos/thor/lp/halts.d.ts +56 -0
  43. package/dist/chains/cosmos/thor/lp/halts.d.ts.map +1 -0
  44. package/dist/chains/cosmos/thor/lp/halts.js +95 -0
  45. package/dist/chains/cosmos/thor/lp/halts.js.map +1 -0
  46. package/dist/chains/cosmos/thor/lp/index.d.ts +34 -11
  47. package/dist/chains/cosmos/thor/lp/index.d.ts.map +1 -1
  48. package/dist/chains/cosmos/thor/lp/index.js +9 -15
  49. package/dist/chains/cosmos/thor/lp/index.js.map +1 -1
  50. package/dist/chains/cosmos/thor/lp/lockup.d.ts +47 -0
  51. package/dist/chains/cosmos/thor/lp/lockup.d.ts.map +1 -0
  52. package/dist/chains/cosmos/thor/lp/lockup.js +56 -0
  53. package/dist/chains/cosmos/thor/lp/lockup.js.map +1 -0
  54. package/dist/chains/cosmos/thor/lp/lpChainMap.d.ts +25 -0
  55. package/dist/chains/cosmos/thor/lp/lpChainMap.d.ts.map +1 -0
  56. package/dist/chains/cosmos/thor/lp/lpChainMap.js +30 -0
  57. package/dist/chains/cosmos/thor/lp/lpChainMap.js.map +1 -0
  58. package/dist/chains/cosmos/thor/lp/math.d.ts +129 -0
  59. package/dist/chains/cosmos/thor/lp/math.d.ts.map +1 -0
  60. package/dist/chains/cosmos/thor/lp/math.js +227 -0
  61. package/dist/chains/cosmos/thor/lp/math.js.map +1 -0
  62. package/dist/chains/cosmos/thor/lp/memberPool.d.ts +4 -0
  63. package/dist/chains/cosmos/thor/lp/memberPool.d.ts.map +1 -0
  64. package/dist/chains/cosmos/thor/lp/memberPool.js +24 -0
  65. package/dist/chains/cosmos/thor/lp/memberPool.js.map +1 -0
  66. package/dist/chains/cosmos/thor/lp/memo.d.ts +38 -17
  67. package/dist/chains/cosmos/thor/lp/memo.d.ts.map +1 -1
  68. package/dist/chains/cosmos/thor/lp/memo.js +40 -16
  69. package/dist/chains/cosmos/thor/lp/memo.js.map +1 -1
  70. package/dist/chains/cosmos/thor/lp/pairing.d.ts +30 -0
  71. package/dist/chains/cosmos/thor/lp/pairing.d.ts.map +1 -0
  72. package/dist/chains/cosmos/thor/lp/pairing.js +44 -0
  73. package/dist/chains/cosmos/thor/lp/pairing.js.map +1 -0
  74. package/dist/chains/cosmos/thor/lp/payload.d.ts +30 -10
  75. package/dist/chains/cosmos/thor/lp/payload.d.ts.map +1 -1
  76. package/dist/chains/cosmos/thor/lp/payload.js +30 -18
  77. package/dist/chains/cosmos/thor/lp/payload.js.map +1 -1
  78. package/dist/chains/cosmos/thor/lp/position.d.ts +15 -22
  79. package/dist/chains/cosmos/thor/lp/position.d.ts.map +1 -1
  80. package/dist/chains/cosmos/thor/lp/position.js +82 -35
  81. package/dist/chains/cosmos/thor/lp/position.js.map +1 -1
  82. package/dist/chains/cosmos/thor/lp/positions.d.ts +15 -0
  83. package/dist/chains/cosmos/thor/lp/positions.d.ts.map +1 -0
  84. package/dist/chains/cosmos/thor/lp/positions.js +47 -0
  85. package/dist/chains/cosmos/thor/lp/positions.js.map +1 -0
  86. package/dist/chains/cosmos/thor/lp/types.d.ts +45 -0
  87. package/dist/chains/cosmos/thor/lp/types.d.ts.map +1 -0
  88. package/dist/chains/cosmos/thor/lp/types.js +2 -0
  89. package/dist/chains/cosmos/thor/lp/types.js.map +1 -0
  90. package/dist/chains/cosmos/thor/lp/validation.d.ts +32 -7
  91. package/dist/chains/cosmos/thor/lp/validation.d.ts.map +1 -1
  92. package/dist/chains/cosmos/thor/lp/validation.js +76 -11
  93. package/dist/chains/cosmos/thor/lp/validation.js.map +1 -1
  94. package/dist/chains/utxo/tx/buildSignBitcoinFromPsbt.d.ts +21 -0
  95. package/dist/chains/utxo/tx/buildSignBitcoinFromPsbt.d.ts.map +1 -0
  96. package/dist/chains/utxo/tx/buildSignBitcoinFromPsbt.js +182 -0
  97. package/dist/chains/utxo/tx/buildSignBitcoinFromPsbt.js.map +1 -0
  98. package/package.json +90 -5
  99. package/dist/chains/cosmos/thor/lp/affiliate.d.ts +0 -16
  100. package/dist/chains/cosmos/thor/lp/affiliate.d.ts.map +0 -1
  101. package/dist/chains/cosmos/thor/lp/affiliate.js +0 -16
  102. package/dist/chains/cosmos/thor/lp/affiliate.js.map +0 -1
@@ -0,0 +1,14 @@
1
+ import { ClaimableUtxo } from './ClaimableUtxo.js';
2
+ type GetClaimableUtxosInput = {
3
+ btcAddress: string;
4
+ };
5
+ /**
6
+ * Fetches Bitcoin UTXOs for the given address via Blockchair and returns them
7
+ * as claimable candidates on the QBTC chain.
8
+ *
9
+ * Note: this does not cross-check with the QBTC chain to filter
10
+ * already-claimed UTXOs — see btcq-org/qbtc#134.
11
+ */
12
+ export declare const getClaimableUtxos: ({ btcAddress, }: GetClaimableUtxosInput) => Promise<ClaimableUtxo[]>;
13
+ export {};
14
+ //# sourceMappingURL=getClaimableUtxos.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getClaimableUtxos.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/qbtc/claim/getClaimableUtxos.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C,KAAK,sBAAsB,GAAG;IAC5B,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAU,iBAErC,sBAAsB,KAAG,OAAO,CAAC,aAAa,EAAE,CAalD,CAAA"}
@@ -0,0 +1,22 @@
1
+ import { Chain } from '@vultisig/core-chain/Chain';
2
+ import { getUtxoAddressInfo } from '@vultisig/core-chain/chains/utxo/client/getUtxoAddressInfo';
3
+ /**
4
+ * Fetches Bitcoin UTXOs for the given address via Blockchair and returns them
5
+ * as claimable candidates on the QBTC chain.
6
+ *
7
+ * Note: this does not cross-check with the QBTC chain to filter
8
+ * already-claimed UTXOs — see btcq-org/qbtc#134.
9
+ */
10
+ export const getClaimableUtxos = async ({ btcAddress, }) => {
11
+ const response = await getUtxoAddressInfo({
12
+ address: btcAddress,
13
+ chain: Chain.Bitcoin,
14
+ });
15
+ const utxos = response.data[btcAddress]?.utxo ?? [];
16
+ return utxos.map(({ transaction_hash, index, value }) => ({
17
+ txid: transaction_hash,
18
+ vout: index,
19
+ amount: value,
20
+ }));
21
+ };
22
+ //# sourceMappingURL=getClaimableUtxos.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getClaimableUtxos.js","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/qbtc/claim/getClaimableUtxos.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAA;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4DAA4D,CAAA;AAQ/F;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAAE,EACtC,UAAU,GACa,EAA4B,EAAE;IACrD,MAAM,QAAQ,GAAG,MAAM,kBAAkB,CAAC;QACxC,OAAO,EAAE,UAAU;QACnB,KAAK,EAAE,KAAK,CAAC,OAAO;KACrB,CAAC,CAAA;IAEF,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,IAAI,IAAI,EAAE,CAAA;IAEnD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,gBAAgB,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;QACxD,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,KAAK;QACX,MAAM,EAAE,KAAK;KACd,CAAC,CAAC,CAAA;AACL,CAAC,CAAA"}
@@ -0,0 +1,50 @@
1
+ /** Base URL for the QBTC proof service. */
2
+ export declare const defaultProofServiceUrl = "https://proof.qbtc.network";
3
+ /** Checks whether the proof service is healthy and ready. */
4
+ export declare const checkProofServiceHealth: ({ baseUrl, }?: {
5
+ baseUrl?: string;
6
+ }) => Promise<boolean>;
7
+ type UtxoRef = {
8
+ txid: string;
9
+ vout: number;
10
+ };
11
+ type GenerateClaimProofInput = {
12
+ /** r-component of the ECDSA signature (hex string). */
13
+ signatureR: string;
14
+ /** s-component of the ECDSA signature (hex string). */
15
+ signatureS: string;
16
+ /** Compressed secp256k1 public key (66-char hex string). */
17
+ publicKey: string;
18
+ /** UTXOs to include in the claim. */
19
+ utxos: UtxoRef[];
20
+ /** QBTC bech32 address of the claimer. */
21
+ claimerAddress: string;
22
+ /** QBTC chain ID (e.g., "qbtc-1"). */
23
+ chainId: string;
24
+ /** Proof service base URL. Defaults to {@link defaultProofServiceUrl}. */
25
+ baseUrl?: string;
26
+ };
27
+ type GenerateClaimProofResponse = {
28
+ /** Hex-encoded PLONK ZK proof. */
29
+ proof: string;
30
+ /** 64-char hex MessageHash. */
31
+ message_hash: string;
32
+ /** 40-char hex AddressHash (Hash160). */
33
+ address_hash: string;
34
+ /** 64-char hex QBTCAddressHash. */
35
+ qbtc_address_hash: string;
36
+ /** UTXOs included in the proof. */
37
+ utxos: UtxoRef[];
38
+ /** QBTC claimer address. */
39
+ claimer_address: string;
40
+ };
41
+ export type { GenerateClaimProofResponse as ClaimProofResult };
42
+ /**
43
+ * Calls the proof service to generate a PLONK ZK proof for the QBTC claim.
44
+ * This proves BTC address ownership without revealing the private key,
45
+ * public key, or signature.
46
+ *
47
+ * Timeout: up to 300 seconds — proof generation is computationally expensive.
48
+ */
49
+ export declare const generateClaimProof: ({ signatureR, signatureS, publicKey, utxos, claimerAddress, chainId, baseUrl, }: GenerateClaimProofInput) => Promise<GenerateClaimProofResponse>;
50
+ //# sourceMappingURL=proofService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proofService.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/qbtc/claim/proofService.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,eAAO,MAAM,sBAAsB,+BAA+B,CAAA;AASlE,6DAA6D;AAC7D,eAAO,MAAM,uBAAuB,GAAU,eAE3C;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,KAAG,OAAO,CAAC,OAAO,CAS7C,CAAA;AAED,KAAK,OAAO,GAAG;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,KAAK,uBAAuB,GAAG;IAC7B,uDAAuD;IACvD,UAAU,EAAE,MAAM,CAAA;IAClB,uDAAuD;IACvD,UAAU,EAAE,MAAM,CAAA;IAClB,4DAA4D;IAC5D,SAAS,EAAE,MAAM,CAAA;IACjB,qCAAqC;IACrC,KAAK,EAAE,OAAO,EAAE,CAAA;IAChB,0CAA0C;IAC1C,cAAc,EAAE,MAAM,CAAA;IACtB,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAA;IACf,0EAA0E;IAC1E,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,KAAK,0BAA0B,GAAG;IAChC,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAA;IACb,+BAA+B;IAC/B,YAAY,EAAE,MAAM,CAAA;IACpB,yCAAyC;IACzC,YAAY,EAAE,MAAM,CAAA;IACpB,mCAAmC;IACnC,iBAAiB,EAAE,MAAM,CAAA;IACzB,mCAAmC;IACnC,KAAK,EAAE,OAAO,EAAE,CAAA;IAChB,4BAA4B;IAC5B,eAAe,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,YAAY,EAAE,0BAA0B,IAAI,gBAAgB,EAAE,CAAA;AA2B9D;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAU,iFAQtC,uBAAuB,KAAG,OAAO,CAAC,0BAA0B,CAiC9D,CAAA"}
@@ -0,0 +1,71 @@
1
+ /** Base URL for the QBTC proof service. */
2
+ export const defaultProofServiceUrl = 'https://proof.qbtc.network';
3
+ const proofGenerationTimeoutMs = 300_000;
4
+ /** Checks whether the proof service is healthy and ready. */
5
+ export const checkProofServiceHealth = async ({ baseUrl = defaultProofServiceUrl, } = {}) => {
6
+ try {
7
+ const response = await fetch(`${baseUrl}/health`);
8
+ if (!response.ok)
9
+ return false;
10
+ const data = await response.json();
11
+ return data.status === 'healthy' && data.setup_loaded === true;
12
+ }
13
+ catch {
14
+ return false;
15
+ }
16
+ };
17
+ const isHexWithLength = (value, length) => typeof value === 'string' &&
18
+ value.length === length &&
19
+ /^[0-9a-f]+$/i.test(value);
20
+ /** Validates the proof service response matches expected field formats. */
21
+ const assertValidClaimProofResponse = (data) => {
22
+ if (typeof data.proof !== 'string' || data.proof.length === 0) {
23
+ throw new Error('Invalid proof service response: missing proof');
24
+ }
25
+ if (!isHexWithLength(data.message_hash, 64)) {
26
+ throw new Error('Invalid proof service response: invalid message_hash');
27
+ }
28
+ if (!isHexWithLength(data.address_hash, 40)) {
29
+ throw new Error('Invalid proof service response: invalid address_hash');
30
+ }
31
+ if (!isHexWithLength(data.qbtc_address_hash, 64)) {
32
+ throw new Error('Invalid proof service response: invalid qbtc_address_hash');
33
+ }
34
+ };
35
+ /**
36
+ * Calls the proof service to generate a PLONK ZK proof for the QBTC claim.
37
+ * This proves BTC address ownership without revealing the private key,
38
+ * public key, or signature.
39
+ *
40
+ * Timeout: up to 300 seconds — proof generation is computationally expensive.
41
+ */
42
+ export const generateClaimProof = async ({ signatureR, signatureS, publicKey, utxos, claimerAddress, chainId, baseUrl = defaultProofServiceUrl, }) => {
43
+ const controller = new AbortController();
44
+ const timeout = setTimeout(() => controller.abort(), proofGenerationTimeoutMs);
45
+ try {
46
+ const response = await fetch(`${baseUrl}/prove`, {
47
+ method: 'POST',
48
+ headers: { 'Content-Type': 'application/json' },
49
+ signal: controller.signal,
50
+ body: JSON.stringify({
51
+ signature_r: signatureR,
52
+ signature_s: signatureS,
53
+ public_key: publicKey,
54
+ utxos: utxos.map(({ txid, vout }) => ({ txid, vout })),
55
+ claimer_address: claimerAddress,
56
+ chain_id: chainId,
57
+ }),
58
+ });
59
+ if (!response.ok) {
60
+ const text = await response.text();
61
+ throw new Error(`Proof service error (${response.status}): ${text}`);
62
+ }
63
+ const data = await response.json();
64
+ assertValidClaimProofResponse(data);
65
+ return data;
66
+ }
67
+ finally {
68
+ clearTimeout(timeout);
69
+ }
70
+ };
71
+ //# sourceMappingURL=proofService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proofService.js","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/qbtc/claim/proofService.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,MAAM,CAAC,MAAM,sBAAsB,GAAG,4BAA4B,CAAA;AAElE,MAAM,wBAAwB,GAAG,OAAO,CAAA;AAOxC,6DAA6D;AAC7D,MAAM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AAE,CAAA;QAC9D,6BAA6B,CAAC,IAAI,CAAC,CAAA;QACnC,OAAO,IAAI,CAAA;IACb,CAAC;YAAS,CAAC;QACT,YAAY,CAAC,OAAO,CAAC,CAAA;IACvB,CAAC;AACH,CAAC,CAAA"}
@@ -0,0 +1,56 @@
1
+ export type LpHaltStatus = {
2
+ chain: string;
3
+ depositable: boolean;
4
+ withdrawable: boolean;
5
+ /** Human-readable reasons, empty when both flags are `true`. */
6
+ reasons: string[];
7
+ /** Raw flags from thornode for downstream consumers that want detail. */
8
+ raw: {
9
+ halted: boolean;
10
+ chain_trading_paused: boolean;
11
+ chain_lp_actions_paused: boolean;
12
+ global_trading_paused: boolean;
13
+ };
14
+ };
15
+ /**
16
+ * Look up the LP halt / pause status for every THORChain-supported chain
17
+ * in a single thornode round-trip.
18
+ *
19
+ * Returns one `LpHaltStatus` per chain in `/thorchain/inbound_addresses`.
20
+ * Useful for "which pools can I actually add to right now?" queries.
21
+ */
22
+ export declare const getThorchainLpHaltStatusAll: () => Promise<LpHaltStatus[]>;
23
+ /**
24
+ * Look up the LP halt / pause status for a specific chain by its
25
+ * THORChain-pool-prefix (e.g. `BTC`, `ETH`, `DOGE`).
26
+ *
27
+ * Throws when the chain is not in the inbound_addresses response. Prefer
28
+ * `getThorchainLpHaltStatusAll` + filter if you want a nullable result.
29
+ */
30
+ export declare const getThorchainLpHaltStatus: (chain: string) => Promise<LpHaltStatus>;
31
+ /**
32
+ * Look up the per-pool LP deposit pause status from mimir.
33
+ *
34
+ * THORChain can pause LP deposits for a SPECIFIC pool via the mimir flag
35
+ * `PAUSELPDEPOSIT-{chain}-{asset}` independently of the chain-level
36
+ * `chain_lp_actions_paused` flag in `inbound_addresses`. When that flag
37
+ * is set, `/thorchain/pool/{asset}.status` still reports `Available` and
38
+ * new LP add transactions are silently accepted into the mempool — but
39
+ * the THORChain handler rejects them at execution time with an internal
40
+ * error, wasting the user's native fee.
41
+ *
42
+ * Use this helper (or `assertPoolDepositable` which already calls it) as
43
+ * a pre-flight gate before building an LP add payload to catch that case.
44
+ *
45
+ * Returns `{ paused: false }` when the mimir flag is unset or zero.
46
+ * Returns `{ paused: true, mimirKey, mimirValue }` when paused. Does NOT
47
+ * throw — the caller decides whether to block, warn, or continue.
48
+ */
49
+ export declare const getThorchainLpPoolPauseStatus: (pool: string) => Promise<{
50
+ paused: false;
51
+ } | {
52
+ paused: true;
53
+ mimirKey: string;
54
+ mimirValue: number;
55
+ }>;
56
+ //# sourceMappingURL=halts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"halts.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/thor/lp/halts.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,OAAO,CAAA;IACpB,YAAY,EAAE,OAAO,CAAA;IACrB,gEAAgE;IAChE,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,yEAAyE;IACzE,GAAG,EAAE;QACH,MAAM,EAAE,OAAO,CAAA;QACf,oBAAoB,EAAE,OAAO,CAAA;QAC7B,uBAAuB,EAAE,OAAO,CAAA;QAChC,qBAAqB,EAAE,OAAO,CAAA;KAC/B,CAAA;CACF,CAAA;AA2CD;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,QAAa,OAAO,CAC1D,YAAY,EAAE,CAYf,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,GACnC,OAAO,MAAM,KACZ,OAAO,CAAC,YAAY,CAUtB,CAAA;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,6BAA6B,GACxC,MAAM,MAAM,KACX,OAAO,CACN;IAAE,MAAM,EAAE,KAAK,CAAA;CAAE,GACjB;IAAE,MAAM,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CASzD,CAAA"}
@@ -0,0 +1,95 @@
1
+ import { getThorchainInboundAddress } from '../getThorchainInboundAddress.js';
2
+ import { getThorchainMimir, poolPauseMimirKey } from './validation.js';
3
+ const buildStatus = (raw) => {
4
+ const reasons = [];
5
+ if (raw.halted)
6
+ reasons.push(`${raw.chain} chain is halted`);
7
+ if (raw.global_trading_paused)
8
+ reasons.push('global trading paused');
9
+ if (raw.chain_trading_paused)
10
+ reasons.push(`${raw.chain} chain trading paused`);
11
+ if (raw.chain_lp_actions_paused)
12
+ reasons.push(`${raw.chain} LP actions paused`);
13
+ // Deposit gate: any of these block new LP adds
14
+ const depositable = !raw.halted &&
15
+ !raw.chain_lp_actions_paused &&
16
+ !raw.chain_trading_paused &&
17
+ !raw.global_trading_paused;
18
+ // Withdraw gate: halt + lp_actions_paused block withdraws.
19
+ // global_trading_paused may delay but does not block withdraws at the
20
+ // protocol level (the message is accepted; the outbound is queued).
21
+ const withdrawable = !raw.halted && !raw.chain_lp_actions_paused;
22
+ return {
23
+ chain: raw.chain,
24
+ depositable,
25
+ withdrawable,
26
+ reasons,
27
+ raw: {
28
+ halted: raw.halted,
29
+ chain_trading_paused: raw.chain_trading_paused,
30
+ chain_lp_actions_paused: raw.chain_lp_actions_paused,
31
+ global_trading_paused: raw.global_trading_paused,
32
+ },
33
+ };
34
+ };
35
+ /**
36
+ * Look up the LP halt / pause status for every THORChain-supported chain
37
+ * in a single thornode round-trip.
38
+ *
39
+ * Returns one `LpHaltStatus` per chain in `/thorchain/inbound_addresses`.
40
+ * Useful for "which pools can I actually add to right now?" queries.
41
+ */
42
+ export const getThorchainLpHaltStatusAll = async () => {
43
+ const addresses = await getThorchainInboundAddress();
44
+ return addresses.map(a => buildStatus({
45
+ chain: a.chain,
46
+ halted: a.halted,
47
+ chain_trading_paused: a.chain_trading_paused,
48
+ chain_lp_actions_paused: a.chain_lp_actions_paused,
49
+ global_trading_paused: a.global_trading_paused,
50
+ }));
51
+ };
52
+ /**
53
+ * Look up the LP halt / pause status for a specific chain by its
54
+ * THORChain-pool-prefix (e.g. `BTC`, `ETH`, `DOGE`).
55
+ *
56
+ * Throws when the chain is not in the inbound_addresses response. Prefer
57
+ * `getThorchainLpHaltStatusAll` + filter if you want a nullable result.
58
+ */
59
+ export const getThorchainLpHaltStatus = async (chain) => {
60
+ const all = await getThorchainLpHaltStatusAll();
61
+ const upper = chain.toUpperCase();
62
+ const match = all.find(s => s.chain.toUpperCase() === upper);
63
+ if (!match) {
64
+ throw new Error(`getThorchainLpHaltStatus: chain ${chain} not found in inbound_addresses`);
65
+ }
66
+ return match;
67
+ };
68
+ /**
69
+ * Look up the per-pool LP deposit pause status from mimir.
70
+ *
71
+ * THORChain can pause LP deposits for a SPECIFIC pool via the mimir flag
72
+ * `PAUSELPDEPOSIT-{chain}-{asset}` independently of the chain-level
73
+ * `chain_lp_actions_paused` flag in `inbound_addresses`. When that flag
74
+ * is set, `/thorchain/pool/{asset}.status` still reports `Available` and
75
+ * new LP add transactions are silently accepted into the mempool — but
76
+ * the THORChain handler rejects them at execution time with an internal
77
+ * error, wasting the user's native fee.
78
+ *
79
+ * Use this helper (or `assertPoolDepositable` which already calls it) as
80
+ * a pre-flight gate before building an LP add payload to catch that case.
81
+ *
82
+ * Returns `{ paused: false }` when the mimir flag is unset or zero.
83
+ * Returns `{ paused: true, mimirKey, mimirValue }` when paused. Does NOT
84
+ * throw — the caller decides whether to block, warn, or continue.
85
+ */
86
+ export const getThorchainLpPoolPauseStatus = async (pool) => {
87
+ const mimir = await getThorchainMimir();
88
+ const mimirKey = poolPauseMimirKey(pool);
89
+ const mimirValue = mimir[mimirKey];
90
+ if (typeof mimirValue === 'number' && mimirValue > 0) {
91
+ return { paused: true, mimirKey, mimirValue };
92
+ }
93
+ return { paused: false };
94
+ };
95
+ //# sourceMappingURL=halts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"halts.js","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/thor/lp/halts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0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AAE,QAAQ,EAAE,UAAU,EAAE,CAAA;IAC/C,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAA;AAC1B,CAAC,CAAA"}
@@ -1,22 +1,45 @@
1
1
  /**
2
2
  * THORChain liquidity-pool primitives.
3
3
  *
4
- * Pure-function memo + payload builders alongside thin Midgard / thornode
5
- * fetchers. Used by `vultisig-mcp-ts` (which exposes them as MCP tools) and
6
- * eventually by `vultiagent-poc` once the SDK migration (VA-133) lands.
4
+ * Pure-function memo + payload builders, chain-prefix mapping, paired-
5
+ * address resolution, pool-math (slippage/units/share), and thin
6
+ * Midgard / thornode fetchers. Used by `vultisig-mcp-ts` (MCP tools) and
7
+ * by `vultiagent-poc` (hand-rolled signing until VA-133 lands).
7
8
  *
8
- * v1 surface is intentionally narrow: asymmetric RUNE-side adds and
9
- * removes only. Asset-side adds (BTC/ETH/etc inbound vault) and explicit
10
- * symmetric pairing are deferred until the end-to-end chat flow has shipped.
9
+ * v2 surface (current):
10
+ * - asym RUNE-side add + remove with optional auto-pair (matches iOS /
11
+ * vultisig-windows extension behavior)
12
+ * - asset-side add with inbound / router / approval detection
13
+ * - LP math: liquidity units, pool share, slippage, one-shot estimator
14
+ * - position read-back: single pool + multi-pool
15
+ * - lockup awareness (mimir-driven)
16
+ * - halt / pause status per chain
17
+ *
18
+ * Deliberately excluded:
19
+ * - savers (deprecated on-chain 2025-01-04)
20
+ * - RUNEPool (separate product)
21
+ * - secured assets (handled by `@vultisig/rujira`)
22
+ * - affiliate on LP memos (matches iOS / extension native behavior)
11
23
  */
12
- export { VULTISIG_AFFILIATE_LP_BPS, VULTISIG_AFFILIATE_NAME, } from './affiliate.js';
13
24
  export type { AddLpMemoInput, RemoveLpMemoInput } from './memo.js';
14
25
  export { addLpMemo, removeLpMemo } from './memo.js';
15
26
  export type { BuildThorchainLpAddPayloadInput, BuildThorchainLpRemovePayloadInput, ThorchainLpAddPayload, ThorchainLpRemovePayload, } from './payload.js';
16
27
  export { buildThorchainLpAddPayload, buildThorchainLpRemovePayload, } from './payload.js';
17
28
  export type { GetThorchainPoolsOptions, ThorchainPoolSummary, } from './pools.js';
18
- export { getThorchainPools, thorchainMidgardBaseUrl } from './pools.js';
19
- export type { GetThorchainLpPositionInput, ThorchainLpPosition, } from './position.js';
20
- export { getThorchainLpPosition } from './position.js';
21
- export { assertPoolDepositable } from './validation.js';
29
+ export { assertValidPoolId, getThorchainPools, isValidPoolId, thorchainMidgardBaseUrl, } from './pools.js';
30
+ export type { GetThorchainLpPositionInput } from './position.js';
31
+ export type { ThorchainLpPosition } from './types.js';
32
+ export { getThorchainLpPosition, getThorchainLpPositionFromThornode, } from './position.js';
33
+ export { assertPoolDepositable, getThorchainMimir, poolPauseMimirKey, } from './validation.js';
34
+ export type { VaultAddressMap } from './pairing.js';
35
+ export { resolvePairedAddressForLpAdd, } from './pairing.js';
36
+ export type { LpSide } from './pairing.js';
37
+ export { lpChainMap, chainPrefixToChain, chainToLpPrefix } from './lpChainMap.js';
38
+ export type { PoolState, SlippageResult, EstimateLpAddResult } from './math.js';
39
+ export { getLiquidityUnits, getPoolShare, getLpAddSlippage, estimateLpAdd, } from './math.js';
40
+ export { getThorchainLpPositions } from './positions.js';
41
+ export type { LpWithdrawReadiness, } from './lockup.js';
42
+ export { getThorchainLpLockupSeconds, getLpWithdrawReadiness, THORCHAIN_BLOCK_TIME_SECONDS, } from './lockup.js';
43
+ export type { LpHaltStatus } from './halts.js';
44
+ export { getThorchainLpHaltStatus, getThorchainLpHaltStatusAll, getThorchainLpPoolPauseStatus, } from './halts.js';
22
45
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/thor/lp/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EACL,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,aAAa,CAAA;AACpB,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAA;AAC/D,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAChD,YAAY,EACV,+BAA+B,EAC/B,kCAAkC,EAClC,qBAAqB,EACrB,wBAAwB,GACzB,MAAM,WAAW,CAAA;AAClB,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,GAC9B,MAAM,WAAW,CAAA;AAClB,YAAY,EACV,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA;AACpE,YAAY,EACV,2BAA2B,EAC3B,mBAAmB,GACpB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/thor/lp/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAA;AAC/D,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAChD,YAAY,EACV,+BAA+B,EAC/B,kCAAkC,EAClC,qBAAqB,EACrB,wBAAwB,GACzB,MAAM,WAAW,CAAA;AAClB,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,GAC9B,MAAM,WAAW,CAAA;AAClB,YAAY,EACV,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,SAAS,CAAA;AAChB,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,uBAAuB,GACxB,MAAM,SAAS,CAAA;AAChB,YAAY,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAA;AAC7D,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EACL,sBAAsB,EACtB,kCAAkC,GACnC,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,cAAc,CAAA;AAGrB,YAAY,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,EACL,4BAA4B,GAC7B,MAAM,WAAW,CAAA;AAClB,YAAY,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9E,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAA;AAC5E,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,aAAa,GACd,MAAM,QAAQ,CAAA;AACf,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACrD,YAAY,EACV,mBAAmB,GACpB,MAAM,UAAU,CAAA;AACjB,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,EACtB,4BAA4B,GAC7B,MAAM,UAAU,CAAA;AACjB,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,6BAA6B,GAC9B,MAAM,SAAS,CAAA"}
@@ -1,18 +1,12 @@
1
- /**
2
- * THORChain liquidity-pool primitives.
3
- *
4
- * Pure-function memo + payload builders alongside thin Midgard / thornode
5
- * fetchers. Used by `vultisig-mcp-ts` (which exposes them as MCP tools) and
6
- * eventually by `vultiagent-poc` once the SDK migration (VA-133) lands.
7
- *
8
- * v1 surface is intentionally narrow: asymmetric RUNE-side adds and
9
- * removes only. Asset-side adds (BTC/ETH/etc → inbound vault) and explicit
10
- * symmetric pairing are deferred until the end-to-end chat flow has shipped.
11
- */
12
- export { VULTISIG_AFFILIATE_LP_BPS, VULTISIG_AFFILIATE_NAME, } from './affiliate.js';
13
1
  export { addLpMemo, removeLpMemo } from './memo.js';
14
2
  export { buildThorchainLpAddPayload, buildThorchainLpRemovePayload, } from './payload.js';
15
- export { getThorchainPools, thorchainMidgardBaseUrl } from './pools.js';
16
- export { getThorchainLpPosition } from './position.js';
17
- export { assertPoolDepositable } from './validation.js';
3
+ export { assertValidPoolId, getThorchainPools, isValidPoolId, thorchainMidgardBaseUrl, } from './pools.js';
4
+ export { getThorchainLpPosition, getThorchainLpPositionFromThornode, } from './position.js';
5
+ export { assertPoolDepositable, getThorchainMimir, poolPauseMimirKey, } from './validation.js';
6
+ export { resolvePairedAddressForLpAdd, } from './pairing.js';
7
+ export { lpChainMap, chainPrefixToChain, chainToLpPrefix } from './lpChainMap.js';
8
+ export { getLiquidityUnits, getPoolShare, getLpAddSlippage, estimateLpAdd, } from './math.js';
9
+ export { getThorchainLpPositions } from './positions.js';
10
+ export { getThorchainLpLockupSeconds, getLpWithdrawReadiness, THORCHAIN_BLOCK_TIME_SECONDS, } from './lockup.js';
11
+ export { getThorchainLpHaltStatus, getThorchainLpHaltStatusAll, getThorchainLpPoolPauseStatus, } from './halts.js';
18
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/thor/lp/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EACL,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAOhD,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,GAC9B,MAAM,WAAW,CAAA;AAKlB,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA;AAKpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/thor/lp/index.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAOhD,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,GAC9B,MAAM,WAAW,CAAA;AAKlB,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,uBAAuB,GACxB,MAAM,SAAS,CAAA;AAGhB,OAAO,EACL,sBAAsB,EACtB,kCAAkC,GACnC,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,cAAc,CAAA;AAIrB,OAAO,EACL,4BAA4B,GAC7B,MAAM,WAAW,CAAA;AAElB,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9E,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,aAAa,GACd,MAAM,QAAQ,CAAA;AACf,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAIrD,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,EACtB,4BAA4B,GAC7B,MAAM,UAAU,CAAA;AAEjB,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,6BAA6B,GAC9B,MAAM,SAAS,CAAA"}
@@ -0,0 +1,47 @@
1
+ import type { ThorchainLpPosition } from './types.js';
2
+ /**
3
+ * THORChain target block time in seconds. The chain runs on CometBFT /
4
+ * Tendermint with a 6-second block target. Mainnet averages are stable
5
+ * enough that we treat this as a constant — for lockup countdown UIs
6
+ * that's plenty of precision.
7
+ */
8
+ export declare const THORCHAIN_BLOCK_TIME_SECONDS = 6;
9
+ /**
10
+ * Read the current `LIQUIDITYLOCKUPBLOCKS` mimir value from thornode and
11
+ * convert to seconds.
12
+ *
13
+ * Mainnet value as of 2025-04: 600 blocks = 3600 seconds = 1 hour.
14
+ *
15
+ * Note: per the THORChain FAQ ("no lockup period") the mimir value exists
16
+ * but the protocol does not operationally restrict users from withdrawing.
17
+ * Treat this as a UX hint, not a correctness requirement. The broadcast-
18
+ * time error is the real backstop if a withdraw hits too early.
19
+ */
20
+ export declare const getThorchainLpLockupSeconds: () => Promise<number>;
21
+ export type LpWithdrawReadiness = {
22
+ isWithdrawable: boolean;
23
+ /**
24
+ * Unix seconds (UTC) at which the withdraw window opens. Equal to
25
+ * `dateLastAdded + lockupSeconds`. In the past when `isWithdrawable`.
26
+ */
27
+ unlockAtUnix: number;
28
+ /**
29
+ * Seconds remaining until `unlockAtUnix`. Zero when already withdrawable.
30
+ */
31
+ remainingSeconds: number;
32
+ };
33
+ /**
34
+ * Compute whether a position is currently past its lockup window.
35
+ *
36
+ * `position.dateLastAdded` is a unix-seconds timestamp string from
37
+ * Midgard. `lockupSeconds` is the current mimir-driven window from
38
+ * `getThorchainLpLockupSeconds()` — the caller can pass it in if they
39
+ * already have it (to avoid an extra mimir round-trip) or omit it and
40
+ * let this helper fetch it.
41
+ */
42
+ export declare const getLpWithdrawReadiness: ({ position, lockupSeconds: providedLockupSeconds, nowUnix, }: {
43
+ position: Pick<ThorchainLpPosition, "dateLastAdded">;
44
+ lockupSeconds?: number;
45
+ nowUnix?: number;
46
+ }) => Promise<LpWithdrawReadiness>;
47
+ //# sourceMappingURL=lockup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lockup.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/thor/lp/lockup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAGlD;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,IAAI,CAAA;AAE7C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,2BAA2B,QAAa,OAAO,CAAC,MAAM,CASlE,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,cAAc,EAAE,OAAO,CAAA;IACvB;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAA;IACpB;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAA;CACzB,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,GAAU,8DAI1C;IACD,QAAQ,EAAE,IAAI,CAAC,mBAAmB,EAAE,eAAe,CAAC,CAAA;IACpD,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,KAAG,OAAO,CAAC,mBAAmB,CAmB9B,CAAA"}
@@ -0,0 +1,56 @@
1
+ import { getThorchainMimir } from './validation.js';
2
+ /**
3
+ * THORChain target block time in seconds. The chain runs on CometBFT /
4
+ * Tendermint with a 6-second block target. Mainnet averages are stable
5
+ * enough that we treat this as a constant — for lockup countdown UIs
6
+ * that's plenty of precision.
7
+ */
8
+ export const THORCHAIN_BLOCK_TIME_SECONDS = 6;
9
+ /**
10
+ * Read the current `LIQUIDITYLOCKUPBLOCKS` mimir value from thornode and
11
+ * convert to seconds.
12
+ *
13
+ * Mainnet value as of 2025-04: 600 blocks = 3600 seconds = 1 hour.
14
+ *
15
+ * Note: per the THORChain FAQ ("no lockup period") the mimir value exists
16
+ * but the protocol does not operationally restrict users from withdrawing.
17
+ * Treat this as a UX hint, not a correctness requirement. The broadcast-
18
+ * time error is the real backstop if a withdraw hits too early.
19
+ */
20
+ export const getThorchainLpLockupSeconds = async () => {
21
+ const mimir = await getThorchainMimir();
22
+ const blocks = mimir['LIQUIDITYLOCKUPBLOCKS'];
23
+ if (typeof blocks !== 'number' || !Number.isFinite(blocks) || blocks < 0) {
24
+ throw new Error(`getThorchainLpLockupSeconds: mimir did not include a valid LIQUIDITYLOCKUPBLOCKS value`);
25
+ }
26
+ return blocks * THORCHAIN_BLOCK_TIME_SECONDS;
27
+ };
28
+ /**
29
+ * Compute whether a position is currently past its lockup window.
30
+ *
31
+ * `position.dateLastAdded` is a unix-seconds timestamp string from
32
+ * Midgard. `lockupSeconds` is the current mimir-driven window from
33
+ * `getThorchainLpLockupSeconds()` — the caller can pass it in if they
34
+ * already have it (to avoid an extra mimir round-trip) or omit it and
35
+ * let this helper fetch it.
36
+ */
37
+ export const getLpWithdrawReadiness = async ({ position, lockupSeconds: providedLockupSeconds, nowUnix = Math.floor(Date.now() / 1000), }) => {
38
+ const lockupSeconds = providedLockupSeconds ?? (await getThorchainLpLockupSeconds());
39
+ const lastAdded = Number(position.dateLastAdded);
40
+ if (!Number.isFinite(lastAdded) || lastAdded <= 0) {
41
+ // No valid last-add timestamp — assume withdrawable (fresh / unknown).
42
+ return {
43
+ isWithdrawable: true,
44
+ unlockAtUnix: 0,
45
+ remainingSeconds: 0,
46
+ };
47
+ }
48
+ const unlockAtUnix = lastAdded + lockupSeconds;
49
+ const remainingSeconds = Math.max(unlockAtUnix - nowUnix, 0);
50
+ return {
51
+ isWithdrawable: remainingSeconds === 0,
52
+ unlockAtUnix,
53
+ remainingSeconds,
54
+ };
55
+ };
56
+ //# sourceMappingURL=lockup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lockup.js","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/thor/lp/lockup.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAEhD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAA;AAE7C;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,KAAK,IAAqB,EAAE;IACrE,MAAM,KAAK,GAAG,MAAM,iBAAiB,EAAE,CAAA;IACvC,MAAM,MAAM,GAAG,KAAK,CAAC,uBAAuB,CAAC,CAAA;IAC7C,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QACzE,MAAM,IAAI,KAAK,CACb,wFAAwF,CACzF,CAAA;IACH,CAAC;IACD,OAAO,MAAM,GAAG,4BAA4B,CAAA;AAC9C,CAAC,CAAA;AAeD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,EAAE,EAC3C,QAAQ,EACR,aAAa,EAAE,qBAAqB,EACpC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAKxC,EAAgC,EAAE;IACjC,MAAM,aAAa,GACjB,qBAAqB,IAAI,CAAC,MAAM,2BAA2B,EAAE,CAAC,CAAA;IAChE,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAA;IAChD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,SAAS,IAAI,CAAC,EAAE,CAAC;QAClD,uEAAuE;QACvE,OAAO;YACL,cAAc,EAAE,IAAI;YACpB,YAAY,EAAE,CAAC;YACf,gBAAgB,EAAE,CAAC;SACpB,CAAA;IACH,CAAC;IACD,MAAM,YAAY,GAAG,SAAS,GAAG,aAAa,CAAA;IAC9C,MAAM,gBAAgB,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,GAAG,OAAO,EAAE,CAAC,CAAC,CAAA;IAC5D,OAAO;QACL,cAAc,EAAE,gBAAgB,KAAK,CAAC;QACtC,YAAY;QACZ,gBAAgB;KACjB,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,25 @@
1
+ import { Chain } from '@vultisig/core-chain/Chain';
2
+ /**
3
+ * Mapping from THORChain pool-id chain prefix to the SDK's `Chain` enum.
4
+ *
5
+ * This is the reverse of `thorchainLpChainCode` in the sibling
6
+ * `thorchainLp.ts` module (which maps `Chain` → prefix string). We derive
7
+ * it here instead of hand-rolling to keep the two directions in lockstep
8
+ * automatically.
9
+ *
10
+ * Reference: vultisig-windows (the extension)
11
+ * `core/ui/storage/defiPositions.tsx` uses the same map.
12
+ */
13
+ export declare const lpChainMap: Readonly<Record<string, Chain>>;
14
+ /**
15
+ * Resolve a THORChain pool-id chain prefix (e.g. `BTC`, `ETH`, `GAIA`) to
16
+ * the SDK's `Chain` enum. Returns `undefined` for unknown prefixes.
17
+ */
18
+ export declare const chainPrefixToChain: (prefix: string) => Chain | undefined;
19
+ /**
20
+ * Resolve a `Chain` enum value to the THORChain pool-id prefix (e.g.
21
+ * `Chain.Bitcoin` → `BTC`). Returns `undefined` for chains THORChain does
22
+ * not support in pools.
23
+ */
24
+ export declare const chainToLpPrefix: (chain: Chain) => string | undefined;
25
+ //# sourceMappingURL=lpChainMap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lpChainMap.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/thor/lp/lpChainMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAA;AAIlD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAUtD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,QAAQ,MAAM,KAAG,KAAK,GAAG,SAC1B,CAAA;AAElC;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO,KAAK,KAAG,MAAM,GAAG,SAC3B,CAAA"}
@@ -0,0 +1,30 @@
1
+ import { thorchainLpChainCode } from '../thorchainLp.js';
2
+ /**
3
+ * Mapping from THORChain pool-id chain prefix to the SDK's `Chain` enum.
4
+ *
5
+ * This is the reverse of `thorchainLpChainCode` in the sibling
6
+ * `thorchainLp.ts` module (which maps `Chain` → prefix string). We derive
7
+ * it here instead of hand-rolling to keep the two directions in lockstep
8
+ * automatically.
9
+ *
10
+ * Reference: vultisig-windows (the extension)
11
+ * `core/ui/storage/defiPositions.tsx` uses the same map.
12
+ */
13
+ export const lpChainMap = Object.freeze(Object.entries(thorchainLpChainCode).reduce((acc, [chainKey, prefix]) => {
14
+ if (prefix) {
15
+ acc[prefix] = chainKey;
16
+ }
17
+ return acc;
18
+ }, {}));
19
+ /**
20
+ * Resolve a THORChain pool-id chain prefix (e.g. `BTC`, `ETH`, `GAIA`) to
21
+ * the SDK's `Chain` enum. Returns `undefined` for unknown prefixes.
22
+ */
23
+ export const chainPrefixToChain = (prefix) => lpChainMap[prefix.toUpperCase()];
24
+ /**
25
+ * Resolve a `Chain` enum value to the THORChain pool-id prefix (e.g.
26
+ * `Chain.Bitcoin` → `BTC`). Returns `undefined` for chains THORChain does
27
+ * not support in pools.
28
+ */
29
+ export const chainToLpPrefix = (chain) => thorchainLpChainCode[chain];
30
+ //# sourceMappingURL=lpChainMap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lpChainMap.js","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/thor/lp/lpChainMap.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAErD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,UAAU,GAAoC,MAAM,CAAC,MAAM,CACtE,MAAM,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,MAAM,CACzC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,EAAE;IAC1B,IAAI,MAAM,EAAE,CAAC;QACX,GAAG,CAAC,MAAM,CAAC,GAAG,QAAiB,CAAA;IACjC,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC,EACD,EAAE,CACH,CACF,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,MAAc,EAAqB,EAAE,CACtE,UAAU,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAA;AAElC;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAY,EAAsB,EAAE,CAClE,oBAAoB,CAAC,KAAK,CAAC,CAAA"}